Documentation
¶
Overview ¶
Package agent is the in-process code.Agent implementation. One Agent owns the workspace and all open sessions for that workspace; each session has its own *harness.Agent, transcript, and usage. The shared workspace surfaces MCP/LSP/Rewind through code.Workspace.
The pkg/agent import is aliased `harness` throughout to avoid collision with this package's own name.
Index ¶
- func BuildInstructions(data prompt.SectionData) string
- func ReadProjectInstructions(wd string) string
- type Agent
- func (a *Agent) AutoSelectModel(ctx context.Context)
- func (a *Agent) Cancel(id string)
- func (a *Agent) Close() error
- func (a *Agent) DeleteSession(_ context.Context, id string) error
- func (a *Agent) Effort() (string, []string)
- func (a *Agent) FetchUpstreamModels(ctx context.Context)
- func (a *Agent) HasSession(id string) bool
- func (a *Agent) ListSessions(_ context.Context) ([]code.SessionInfo, error)
- func (a *Agent) LoadSession(_ context.Context, id string) error
- func (a *Agent) Messages(id string) []harness.Message
- func (a *Agent) Models() ([]code.Model, string)
- func (a *Agent) Name() string
- func (a *Agent) NewSession(_ context.Context) (string, error)
- func (a *Agent) PlanMode(id string) bool
- func (a *Agent) Save(id string) error
- func (a *Agent) Send(ctx context.Context, id string, input []harness.Content) iter.Seq2[harness.Message, error]
- func (a *Agent) SessionsDir() string
- func (a *Agent) SetEffort(_ context.Context, value string) error
- func (a *Agent) SetModel(_ context.Context, id string) error
- func (a *Agent) SetPlanMode(id string, plan bool)
- func (a *Agent) SetUI(ui code.UI)
- func (a *Agent) Tools(id string) []tool.Tool
- func (a *Agent) Usage(id string) harness.Usage
- func (a *Agent) Workspace() *code.Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildInstructions ¶
func BuildInstructions(data prompt.SectionData) string
BuildInstructions composes the system prompt from a section-data snapshot.
func ReadProjectInstructions ¶
ReadProjectInstructions is an uncached read for callers (TUI status bar, /init flows) that need the assembled block without a session.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is the wingman in-process implementation of code.Agent. Model and effort are agent-wide (mirrors the previous server.s.model/s.effort design) and applied to every session's request via closures on the embedded harness.Config.
func New ¶
New constructs an in-process code.Agent rooted at the workspace.
func (*Agent) AutoSelectModel ¶
AutoSelectModel picks a default model id from the upstream catalog when none has been set yet.
func (*Agent) FetchUpstreamModels ¶
FetchUpstreamModels populates the cache of upstream model ids so subsequent Models() calls can filter code.AvailableModels down to what the configured upstream actually serves. Call once at startup.
func (*Agent) HasSession ¶
HasSession reports whether the agent is tracking a session id in memory. Useful for the server's lazy-create check (don't restore state for a session that's already in memory).
func (*Agent) ListSessions ¶
func (*Agent) NewSession ¶
NewSession mints a UUID and lazy-builds the in-memory state. Nothing is persisted to disk yet — that happens after the first Save().
func (*Agent) Save ¶
Save persists a session's transcript. Called after each turn by consumers that want chat to survive a restart. No-op if not loaded.
func (*Agent) SessionsDir ¶
func (*Agent) SetPlanMode ¶
func (*Agent) SetUI ¶
SetUI installs the elicitation UI used by ask_user and shell-confirm hooks. Without a UI the agent falls back to accepted defaults (Confirm → true, Ask → ""); set one before the first turn if you want the user to be prompted. Safe to call concurrently.