Documentation
¶
Index ¶
- Constants
- Variables
- func HasAgentsConfig() bool
- func SessionIDFromContext(ctx context.Context) string
- func SessionsDir(workingDir string) string
- func UnattendedElicitation(req tool.ElicitRequest) tool.ElicitResult
- func WithSessionID(ctx context.Context, sid string) context.Context
- type Agent
- type AgentDef
- type Command
- type CommandProvider
- type HistorySnapshot
- type HistorySnapshotProvider
- type HistoryVersion
- type HistoryVersionProvider
- type Mode
- type SessionInfo
- type SessionLoadStreamer
- type TurnEvent
- type TurnFeatureProvider
- type TurnFeatures
- type TurnInput
- type TurnInputIntent
- type TurnInputSnapshot
- type TurnInputState
- type TurnManager
- func (m *TurnManager) CancelAll(sessionID string)
- func (m *TurnManager) CancelCurrent(sessionID string)
- func (m *TurnManager) ClearQueue(sessionID string)
- func (m *TurnManager) Close()
- func (m *TurnManager) Features(sessionID string) TurnFeatures
- func (m *TurnManager) RemoveQueued(sessionID, inputID string) error
- func (m *TurnManager) ReplaceQueued(sessionID, inputID string, replacement TurnInput) error
- func (m *TurnManager) Resume(sessionID string) bool
- func (m *TurnManager) SetHandler(handler func(TurnEvent))
- func (m *TurnManager) Snapshot(sessionID string) TurnSnapshot
- func (m *TurnManager) Submit(ctx context.Context, sessionID string, input TurnInput) (TurnInputSnapshot, error)
- type TurnSnapshot
- type TurnSteerer
- type UI
- type Workspace
- func (w *Workspace) ChangesFingerprint(ctx context.Context) uint64
- func (w *Workspace) Close()
- func (w *Workspace) DefinitionLocations(ctx context.Context, filePath string, content *string, line, column int) ([]lsp.DefLocation, error)
- func (w *Workspace) Diagnostics(ctx context.Context) lsp.WorkspaceDiagnosticsReport
- func (w *Workspace) Diff(ctx context.Context, path string, layer changes.DiffLayer) (changes.FileDiff, error)
- func (w *Workspace) Diffs(ctx context.Context) ([]changes.FileDiff, error)
- func (w *Workspace) DocumentSymbolItems(ctx context.Context, filePath string, content *string) ([]lsp.DocumentSymbol, []lsp.SymbolInformation, error)
- func (w *Workspace) FileDiagnostics(ctx context.Context, filePath string, content *string) ([]lsp.Diagnostic, bool, error)
- func (w *Workspace) GitBranches(ctx context.Context, refresh bool) ([]changes.GitBranch, string, error)
- func (w *Workspace) GitCheckoutBranch(ctx context.Context, name, remote string) error
- func (w *Workspace) GitCommit(ctx context.Context, message string) (string, error)
- func (w *Workspace) GitCreateBranch(ctx context.Context, name string) error
- func (w *Workspace) GitPull(ctx context.Context) (string, error)
- func (w *Workspace) GitPush(ctx context.Context) (string, error)
- func (w *Workspace) GitStage(ctx context.Context, paths []string) error
- func (w *Workspace) GitStatus(ctx context.Context) (changes.GitStatus, error)
- func (w *Workspace) GitUnstage(ctx context.Context, paths []string) error
- func (w *Workspace) HasChanges() bool
- func (w *Workspace) HasLSP() bool
- func (w *Workspace) HasNativeGit() bool
- func (w *Workspace) HoverInformation(ctx context.Context, filePath string, content *string, line, column int) (string, error)
- func (w *Workspace) ImplementationLocations(ctx context.Context, filePath string, content *string, line, column int) ([]lsp.DefLocation, error)
- func (w *Workspace) InitMCP(ctx context.Context) error
- func (w *Workspace) IsGitRepo() bool
- func (w *Workspace) ManagedTools() (mcpTools, lspTools, graphTools []tool.Tool)
- func (w *Workspace) MemoryContent() string
- func (w *Workspace) ReferenceLocations(ctx context.Context, filePath string, content *string, line, column int) ([]lsp.DefLocation, error)
- func (w *Workspace) RevertChange(ctx context.Context, path string) error
- func (w *Workspace) SyncProjectMode()
- func (w *Workspace) TypeDefinitionLocations(ctx context.Context, filePath string, content *string, line, column int) ([]lsp.DefLocation, error)
- func (w *Workspace) WarmUp()
- func (w *Workspace) WithEditDiagnostics(tools []tool.Tool) []tool.Tool
Constants ¶
const ( AgentModeID = "agent" PlanModeID = "plan" UnattendedModeID = "unattended" )
const BuiltinAgentName = "wingman"
Variables ¶
var ( ErrTurnInProgress = agent.ErrTurnInProgress ErrEmptyInput = agent.ErrEmptyInput )
var ( // ErrNoActiveTurn means a steer lost the active-turn boundary race. ErrNoActiveTurn = errors.New("no active turn") // ErrTurnNotSteerable means the active backend turn rejects same-turn input. ErrTurnNotSteerable = errors.New("active turn is not steerable") // ErrInputNotQueued means a queue mutation targeted a non-queued input. ErrInputNotQueued = errors.New("turn input is not queued") // ErrDuplicateInput means an input ID is already live in the session. ErrDuplicateInput = errors.New("turn input id already exists") // ErrInvalidIntent means the input requested an unsupported routing mode. ErrInvalidIntent = errors.New("invalid turn input intent") )
Functions ¶
func HasAgentsConfig ¶ added in v0.8.3
func HasAgentsConfig() bool
func SessionIDFromContext ¶ added in v0.7.0
func SessionsDir ¶ added in v0.6.9
func UnattendedElicitation ¶ added in v0.12.7
func UnattendedElicitation(req tool.ElicitRequest) tool.ElicitResult
UnattendedElicitation resolves questions without UI. Defaults win, followed by the first (recommended) option; required free-text questions are declined rather than answered with fabricated input.
Types ¶
type Agent ¶
type Agent interface {
Name() string
Workspace() *Workspace
Models(sessionID string) (available []model.Model, current string)
SetModel(ctx context.Context, sessionID, id string) error
Effort(sessionID string) (current string, options []string)
SetEffort(ctx context.Context, sessionID, value string) error
Modes(sessionID string) (available []Mode, current string)
SetMode(ctx context.Context, sessionID, modeID string) error
ListSessions(ctx context.Context) ([]SessionInfo, error)
NewSession(ctx context.Context) (string, error)
LoadSession(ctx context.Context, id string) error
DeleteSession(ctx context.Context, id string) error
Messages(sessionID string) []agent.Message
Usage(sessionID string) agent.Usage
// Send starts one turn and returns its event stream. Immediate validation
// and busy-session failures are returned directly; errors that happen after
// the turn starts are yielded by the stream. Send never queues implicitly.
// Once Send returns successfully, the agent owns input and callers may reuse
// or mutate their slice.
Send(ctx context.Context, sessionID string, input []agent.Content) (iter.Seq2[agent.Message, error], error)
Cancel(sessionID string)
Close() error
}
type AgentDef ¶ added in v0.7.0
type AgentDef struct {
Name string `json:"name"`
Command string `json:"command"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
}
func LoadAgents ¶ added in v0.7.0
type CommandProvider ¶ added in v0.12.0
CommandProvider exposes agent-defined slash commands for clients that can present command discovery alongside their own local commands.
type HistorySnapshot ¶ added in v0.12.9
HistorySnapshot is an atomic view of a session's retained messages. Revision changes only when existing history is rewritten (for example by compaction), not when messages are appended normally.
type HistorySnapshotProvider ¶ added in v0.12.9
type HistorySnapshotProvider interface {
HistorySnapshot(sessionID string) HistorySnapshot
}
HistorySnapshotProvider lets UIs distinguish an append from a history rewrite. Agents without rewrite behavior may continue to expose Messages.
type HistoryVersion ¶ added in v0.12.9
HistoryVersion is a cheap discriminator for retained history. Revision changes on rewrites; MessageCount changes on ordinary appends.
type HistoryVersionProvider ¶ added in v0.12.9
type HistoryVersionProvider interface {
HistoryVersion(sessionID string) HistoryVersion
}
HistoryVersionProvider lets polling UIs avoid cloning a complete history snapshot when neither its length nor rewrite revision changed.
type Mode ¶ added in v0.8.0
func UnattendedMode ¶ added in v0.12.7
func UnattendedMode() Mode
type SessionInfo ¶ added in v0.7.0
type SessionLoadStreamer ¶ added in v0.8.8
type TurnEvent ¶ added in v0.10.9
type TurnEvent struct {
SessionID string
InputID string
State TurnInputState
Intent TurnInputIntent
Position int
// StreamEvent carries a transport lifecycle boundary separately from
// conversational messages.
StreamEvent agent.StreamEvent
// Message is only valid for the duration of the synchronous event handler.
// Handlers that retain it must copy its content.
Message *agent.Message
Err error
// Executed is true only for the primary input whose Agent.Send call ended.
// Steered and removed queued inputs also receive terminal states but must not
// trigger turn-finalization side effects such as checkpoints.
Executed bool
}
type TurnFeatureProvider ¶ added in v0.10.9
type TurnFeatureProvider interface {
TurnFeatures(sessionID string) TurnFeatures
}
TurnFeatureProvider advertises optional in-turn behavior. FIFO follow-up queueing is supplied by TurnManager for every Agent; providers only need to advertise behavior that must be implemented by the backend itself.
type TurnFeatures ¶ added in v0.10.9
type TurnFeatures struct {
Steer bool `json:"steer"`
}
type TurnInput ¶ added in v0.10.9
type TurnInput struct {
ID string
Content []agent.Content
Intent TurnInputIntent
}
type TurnInputIntent ¶ added in v0.10.9
type TurnInputIntent string
const ( TurnInputFollowUp TurnInputIntent = "follow_up" TurnInputSteer TurnInputIntent = "steer" )
type TurnInputSnapshot ¶ added in v0.10.9
type TurnInputSnapshot struct {
ID string
State TurnInputState
Intent TurnInputIntent
Position int
}
type TurnInputState ¶ added in v0.10.9
type TurnInputState string
const ( TurnInputQueued TurnInputState = "queued" TurnInputActive TurnInputState = "active" TurnInputSteered TurnInputState = "steered" TurnInputCompleted TurnInputState = "completed" TurnInputCancelled TurnInputState = "cancelled" TurnInputFailed TurnInputState = "failed" )
type TurnManager ¶ added in v0.10.9
type TurnManager struct {
// contains filtered or unexported fields
}
TurnManager provides the session-level execution semantics shared by the web UI and other multi-turn clients. It guarantees one Agent.Send call per session at a time, supplies a FIFO follow-up queue for every backend, and uses native steering only when the backend explicitly supports it.
func NewTurnManager ¶ added in v0.10.9
func NewTurnManager(ctx context.Context, a Agent, handler func(TurnEvent)) *TurnManager
func (*TurnManager) CancelAll ¶ added in v0.10.9
func (m *TurnManager) CancelAll(sessionID string)
CancelAll interrupts the active turn and cancels every queued follow-up.
func (*TurnManager) CancelCurrent ¶ added in v0.10.9
func (m *TurnManager) CancelCurrent(sessionID string)
CancelCurrent interrupts the active turn and pauses queued follow-ups.
func (*TurnManager) ClearQueue ¶ added in v0.10.9
func (m *TurnManager) ClearQueue(sessionID string)
func (*TurnManager) Close ¶ added in v0.10.9
func (m *TurnManager) Close()
func (*TurnManager) Features ¶ added in v0.10.9
func (m *TurnManager) Features(sessionID string) TurnFeatures
func (*TurnManager) RemoveQueued ¶ added in v0.10.9
func (m *TurnManager) RemoveQueued(sessionID, inputID string) error
func (*TurnManager) ReplaceQueued ¶ added in v0.10.9
func (m *TurnManager) ReplaceQueued(sessionID, inputID string, replacement TurnInput) error
func (*TurnManager) Resume ¶ added in v0.10.9
func (m *TurnManager) Resume(sessionID string) bool
func (*TurnManager) SetHandler ¶ added in v0.10.9
func (m *TurnManager) SetHandler(handler func(TurnEvent))
func (*TurnManager) Snapshot ¶ added in v0.10.9
func (m *TurnManager) Snapshot(sessionID string) TurnSnapshot
func (*TurnManager) Submit ¶ added in v0.10.9
func (m *TurnManager) Submit(ctx context.Context, sessionID string, input TurnInput) (TurnInputSnapshot, error)
Submit accepts an input exactly once. A steer that loses a turn-boundary race automatically becomes a FIFO follow-up instead of being discarded.
type TurnSnapshot ¶ added in v0.10.9
type TurnSnapshot struct {
Inputs []TurnInputSnapshot
Paused bool
Features TurnFeatures
}
type TurnSteerer ¶ added in v0.10.9
TurnSteerer injects input into the currently active turn. ErrNoActiveTurn and ErrTurnNotSteerable ask TurnManager to preserve the input as a FIFO follow-up; other errors are returned to the caller. Implementations must not mutate input and must copy its content if they retain it after Steer returns.
type Workspace ¶ added in v0.6.9
type Workspace struct {
Root *os.Root
RootPath string
MemoryPath string
ScratchPath string
Skills []skill.Skill
Plugins []plugin.Plugin
MCP *mcp.Manager
LSP *lsp.Manager
Changes *changes.Manager
Graph *graph.Engine
// contains filtered or unexported fields
}
func NewWorkspace ¶ added in v0.6.9
func (*Workspace) ChangesFingerprint ¶ added in v0.12.6
func (*Workspace) DefinitionLocations ¶ added in v0.12.12
func (w *Workspace) DefinitionLocations(ctx context.Context, filePath string, content *string, line, column int) ([]lsp.DefLocation, error)
DefinitionLocations resolves a position in a disk file or in-memory editor buffer using the language server associated with the file.
func (*Workspace) Diagnostics ¶ added in v0.6.9
func (w *Workspace) Diagnostics(ctx context.Context) lsp.WorkspaceDiagnosticsReport
func (*Workspace) DocumentSymbolItems ¶ added in v0.12.12
func (w *Workspace) DocumentSymbolItems(ctx context.Context, filePath string, content *string) ([]lsp.DocumentSymbol, []lsp.SymbolInformation, error)
func (*Workspace) FileDiagnostics ¶ added in v0.12.12
func (w *Workspace) FileDiagnostics(ctx context.Context, filePath string, content *string) ([]lsp.Diagnostic, bool, error)
FileDiagnostics returns diagnostics for one disk file or in-memory editor buffer. The boolean is false when the server has not produced a result yet.
func (*Workspace) GitBranches ¶ added in v0.12.6
func (*Workspace) GitCheckoutBranch ¶ added in v0.12.6
func (*Workspace) GitCreateBranch ¶ added in v0.12.6
func (*Workspace) GitUnstage ¶ added in v0.12.6
func (*Workspace) HasChanges ¶ added in v0.12.6
func (*Workspace) HasNativeGit ¶ added in v0.12.6
func (*Workspace) HoverInformation ¶ added in v0.12.12
func (*Workspace) ImplementationLocations ¶ added in v0.12.12
func (*Workspace) ManagedTools ¶ added in v0.7.0
func (*Workspace) MemoryContent ¶ added in v0.6.9
func (*Workspace) ReferenceLocations ¶ added in v0.12.12
func (*Workspace) RevertChange ¶ added in v0.12.6
func (*Workspace) SyncProjectMode ¶ added in v0.6.9
func (w *Workspace) SyncProjectMode()