agent

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package agent builds the system prompt and relays a provider turn to the transport, buffering text deltas so the UI receives smooth, batched updates instead of a flood of tiny frames. It is plugin-agnostic: the prompt is assembled from the connection's protocol/title, the AI mode, and the tool names — never plugin-specific logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTitle

func GenerateTitle(ctx context.Context, provider engine.Provider, model, userMessage, assistantReply string) string

GenerateTitle asks the model for a short conversation title from the first exchange. It returns "" on any failure so the caller can fall back.

func Relay

func Relay(ctx context.Context, in <-chan engine.StreamEvent, sink func(engine.StreamEvent))

Relay forwards every event from in to sink, coalescing consecutive text deltas into batched frames. It returns when in closes or ctx is cancelled.

func SystemPrompt

func SystemPrompt(in PromptInput) string

SystemPrompt assembles the agent's instructions for one connection.

Types

type Composite

type Composite struct {
	// contains filtered or unexported fields
}

Composite dispatches tool calls to either route tools or subagents.

func NewComposite

func NewComposite(base toolExecutor, subagents ...*Subagent) *Composite

NewComposite combines the route tool set with subagents.

func (*Composite) Execute

func (c *Composite) Execute(ctx context.Context, call engine.ToolCall) (any, error)

Execute routes to the matching subagent, else to the base tool set.

func (*Composite) Specs

func (c *Composite) Specs() []engine.ToolSpec

Specs is the full catalogue (route tools + subagents).

type PromptInput

type PromptInput struct {
	ConnectionTitle string
	Protocol        string
	AIMode          string
	Tools           []string
	// RecentOps are pre-formatted recent audit lines for the user on this
	// connection, so the agent can explain a just-failed action.
	RecentOps []string
	// HasSubagent indicates an investigate subagent is available.
	HasSubagent bool
}

PromptInput is the dynamic context the system prompt is built from.

type Subagent

type Subagent struct {
	// contains filtered or unexported fields
}

Subagent runs a nested, read-only turn and returns a concise summary.

func NewSubagent

func NewSubagent(name string, provider engine.Provider, model string, ro toolExecutor, protocol string) *Subagent

NewSubagent builds the investigation subagent over a read-only tool set.

func (*Subagent) Execute

func (sa *Subagent) Execute(ctx context.Context, call engine.ToolCall) (any, error)

Execute runs the nested turn.

func (*Subagent) Spec

func (sa *Subagent) Spec() engine.ToolSpec

Spec is the tool the parent model calls to delegate a read-only investigation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL