code

package
v0.11.7 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const BuiltinAgentName = "wingman"

Variables

View Source
var (
	ErrTurnInProgress = agent.ErrTurnInProgress
	ErrEmptyInput     = agent.ErrEmptyInput
)
View Source
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")
)
View Source
var AvailableModels = []Model{
	{ID: "claude-sonnet-5", Name: "Claude Sonnet 5"},
	{ID: "claude-sonnet-4-6", Name: "Claude Sonnet 4.6"},
	{ID: "claude-sonnet-4-5", Name: "Claude Sonnet 4.5"},
	{ID: "claude-haiku-4-5", Name: "Claude Haiku 4.5"},

	{ID: "gpt-5.6-sol", Name: "GPT 5.6 Sol"},
	{ID: "gpt-5.6-terra", Name: "GPT 5.6 Terra"},
	{ID: "gpt-5.6-luna", Name: "GPT 5.6 Luna"},

	{ID: "gpt-5.5", Name: "GPT 5.5"},
	{ID: "gpt-5.4", Name: "GPT 5.4"},

	{ID: "gpt-5.3-codex", Name: "GPT 5.3 Codex"},
	{ID: "gpt-5.2-codex", Name: "GPT 5.2 Codex"},

	{ID: "claude-opus-4-8", Name: "Claude Opus 4.8"},
	{ID: "claude-opus-4-7", Name: "Claude Opus 4.7"},
	{ID: "claude-opus-4-6", Name: "Claude Opus 4.6"},
	{ID: "claude-opus-4-5", Name: "Claude Opus 4.5"},

	{ID: "claude-fable-5", Name: "Claude Fable 5"},
	{ID: "claude-mythos-5", Name: "Claude Mythos 5"},

	{ID: "glm-5.2", Name: "GLM 5.2"},
	{ID: "glm-5.1", Name: "GLM 5.1"},

	{ID: "deepseek-v4-pro", Name: "DeepSeek V4 Pro"},
	{ID: "deepseek-v4-flash", Name: "DeepSeek V4 Flash"},
}

Functions

func HasAgentsConfig added in v0.8.3

func HasAgentsConfig() bool

func ModelEffortBounds added in v0.11.6

func ModelEffortBounds(id string) (lowest, highest string)

ModelEffortBounds returns the reasoning-effort range a model supports; empty means unbounded on that side. Callers clamp out-of-range requests to the nearest bound instead of failing. Only known constraints are listed.

func ModelFamilyOf added in v0.11.2

func ModelFamilyOf(id string) string

ModelFamilyOf groups models by vendor line (claude, gpt, glm, …) so automatic selection stays within one family when possible: switching families mid-session drops encrypted reasoning state.

func ModelName

func ModelName(id string) string

func SessionIDFromContext added in v0.7.0

func SessionIDFromContext(ctx context.Context) string

func SessionsDir added in v0.6.9

func SessionsDir(workingDir string) string

func WithSessionID added in v0.7.0

func WithSessionID(ctx context.Context, sid string) context.Context

Types

type Agent

type Agent interface {
	Name() string

	Workspace() *Workspace

	Models(sessionID string) (available []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

func LoadAgents() []AgentDef

type Mode added in v0.8.0

type Mode struct {
	ID          string
	Name        string
	Description string
}

type Model

type Model struct {
	ID   string
	Name string
}

type ModelClass added in v0.11.2

type ModelClass int

ModelClass buckets models by capability for automatic per-role selection: large drives planning, medium drives coding, small drives utility calls (recaps, compaction summaries).

const (
	ModelClassMedium ModelClass = iota
	ModelClassLarge
	ModelClassSmall
)

func ModelClassOf added in v0.11.2

func ModelClassOf(id string) ModelClass

type SessionInfo added in v0.7.0

type SessionInfo struct {
	ID        string
	Title     string
	UpdatedAt time.Time
}

type SessionLoadStreamer added in v0.8.8

type SessionLoadStreamer interface {
	LoadSessionStream(ctx context.Context, id string) iter.Seq2[[]agent.Message, error]
}

type TurnEvent added in v0.10.9

type TurnEvent struct {
	SessionID string
	InputID   string
	State     TurnInputState
	Intent    TurnInputIntent
	Position  int
	// 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

type TurnSteerer interface {
	Steer(ctx context.Context, sessionID string, input TurnInput) error
}

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 UI

type UI interface {
	Elicit(ctx context.Context, req tool.ElicitRequest) (tool.ElicitResult, error)
	Confirm(ctx context.Context, message string) (bool, error)
}

type Workspace added in v0.6.9

type Workspace struct {
	Root        *os.Root
	RootPath    string
	MemoryPath  string
	ScratchPath string

	Skills []skill.Skill

	MCP *mcp.Manager

	LSP    *lsp.Manager
	Rewind *rewind.Manager
	Graph  *graph.Engine
	// contains filtered or unexported fields
}

func NewWorkspace added in v0.6.9

func NewWorkspace(workDir string) (*Workspace, error)

func (*Workspace) Checkpoints added in v0.6.9

func (w *Workspace) Checkpoints() ([]rewind.Checkpoint, error)

func (*Workspace) Close added in v0.6.9

func (w *Workspace) Close()

func (*Workspace) Commit added in v0.6.9

func (w *Workspace) Commit(msg string) error

func (*Workspace) Diagnostics added in v0.6.9

func (w *Workspace) Diagnostics(ctx context.Context) map[string][]lsp.Diagnostic

func (*Workspace) Diffs added in v0.6.9

func (w *Workspace) Diffs() ([]rewind.FileDiff, error)

func (*Workspace) HasLSP added in v0.10.3

func (w *Workspace) HasLSP() bool

func (*Workspace) HasRewind added in v0.10.3

func (w *Workspace) HasRewind() bool

func (*Workspace) InitMCP added in v0.6.9

func (w *Workspace) InitMCP(ctx context.Context) error

func (*Workspace) IsGitRepo added in v0.6.9

func (w *Workspace) IsGitRepo() bool

func (*Workspace) ManagedTools added in v0.7.0

func (w *Workspace) ManagedTools() (mcpTools, lspTools, graphTools []tool.Tool)

func (*Workspace) MemoryContent added in v0.6.9

func (w *Workspace) MemoryContent() string

func (*Workspace) Restore added in v0.6.9

func (w *Workspace) Restore(hash string) error

func (*Workspace) RewindFingerprint added in v0.10.3

func (w *Workspace) RewindFingerprint() uint64

func (*Workspace) SyncProjectMode added in v0.6.9

func (w *Workspace) SyncProjectMode()

func (*Workspace) WarmUp added in v0.6.9

func (w *Workspace) WarmUp()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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