Documentation
¶
Overview ¶
Bridge between the agent framework and a Bubble Tea program, turning callbacks into messages and prompts into answers
Index ¶
- Constants
- Variables
- func Base(configured string, tools []string) string
- func CheckMatcher(m string) error
- func GatherFacts(dir, model string, missionAttached bool, scratch string) prompt.Facts
- func NewestSession(ctx context.Context, store *session.Store, root string) (string, error)
- func ParseSetting(s string) (string, string, error)
- func RegisterHook(build func(AgentInfo) agent.Hook) error
- func RegisterKind(k Kind) error
- func RegisterPrompt(fragment func(ctx context.Context, a *App, ep Endpoint) string) error
- func RegisterSetting(s Setting) error
- func RegisterTools(build func(a *App) ([]tool.Tool, error)) error
- func RegisterWorkflow(w Workflow) error
- func RunFrom(ctx context.Context) string
- func Save(dir string, sources []string, fields ...Field) error
- func ScratchDir(sessionID string) string
- func StatePath(root string) (string, error)
- func WithRun(ctx context.Context, id string) context.Context
- type AgentInfo
- type Answer
- type App
- func (a *App) AddHook(scope Scope, e HookEntry) error
- func (a *App) AddRule(scope Scope, d policy.Decision, rule string) error
- func (a *App) Announce(msg any)
- func (a *App) Busy(l *Live) bool
- func (a *App) Close(ctx context.Context) error
- func (a *App) CloseServer(name string) error
- func (a *App) Create() (*Live, error)
- func (a *App) CreateKind(ctx context.Context, name string) (*Live, error)
- func (a *App) CreateOn(ep Endpoint, kind string) (*Live, error)
- func (a *App) Current() *Live
- func (a *App) EndpointNamed(ctx context.Context, profile, model string) (Endpoint, error)
- func (a *App) EnvironmentFor(ctx context.Context, model string, offered []string) (string, error)
- func (a *App) FactsFor(ctx context.Context) *facts.Store
- func (a *App) FindProfile(name string) (profiles.Profile, bool)
- func (a *App) Fork(l *Live, n int) (*Live, error)
- func (a *App) ForkStored(ctx context.Context, id string) (*Live, error)
- func (a *App) Ghosted(s *session.Session) bool
- func (a *App) HookEntries() ([]HookEntry, error)
- func (a *App) Instances() []Instance
- func (a *App) Kind(name string) (Kind, bool)
- func (a *App) KindOf(sess *session.Session) (Kind, bool)
- func (a *App) Kinds() []Kind
- func (a *App) LiveByID(id string) *Live
- func (a *App) LiveOf(sess *session.Session) *Live
- func (a *App) LiveOfRun(id string) *Live
- func (a *App) Lives() []*Live
- func (a *App) Metered(ctx context.Context, sess *session.Session) context.Context
- func (a *App) MissionsFor(ctx context.Context) *mission.Store
- func (a *App) MoveProfile(name string, delta int) error
- func (a *App) NewAgent(name string, sess *session.Session) (*agent.Agent, error)
- func (a *App) Offered(kind Kind) []string
- func (a *App) Open(ctx context.Context, id string) (*Live, error)
- func (a *App) OpenEndpoint(ctx context.Context, name, model string) (Endpoint, error)
- func (a *App) ProfileInUse(name string) bool
- func (a *App) ProjectInstructions() string
- func (a *App) PromptFor(ctx context.Context, ep Endpoint, kind Kind) (string, error)
- func (a *App) PutKind(k Kind) error
- func (a *App) Release(l *Live) error
- func (a *App) ReloadHooks() error
- func (a *App) ReloadProfiles() error
- func (a *App) ReloadRules() error
- func (a *App) RemoveHook(e HookEntry) error
- func (a *App) RemoveProfile(name string) error
- func (a *App) RemoveRule(e RuleEntry) error
- func (a *App) RemoveServer(name string) error
- func (a *App) ReplaceHook(old, e HookEntry) error
- func (a *App) ReplaceRule(old RuleEntry, d policy.Decision, rule string) error
- func (a *App) RestartServer(ctx context.Context, old string, cfg ServerConfig) error
- func (a *App) RuleEntries() ([]RuleEntry, error)
- func (a *App) Run(ctx context.Context, missionID string, input []protocol.Part) (*Run, error)
- func (a *App) RunOn(ctx context.Context, l *Live, missionID string, input []protocol.Part) (*Run, error)
- func (a *App) SaveProfile(old string, p profiles.Profile) error
- func (a *App) SaveServer(scope Scope, old string, cfg ServerConfig) error
- func (a *App) ScopeOf(path string) string
- func (a *App) ScratchFor(ctx context.Context) (string, error)
- func (a *App) Select(l *Live)
- func (a *App) ServerEntries() ([]ServerEntry, error)
- func (a *App) SessionFor(ctx context.Context) *session.Session
- func (a *App) SessionStart(ctx context.Context, source string) error
- func (a *App) SetDefaultEndpoint(name string, ep Endpoint)
- func (a *App) SetDefaultModel(id string)
- func (a *App) SetEndpointOn(ctx context.Context, l *Live, name string, ep Endpoint) error
- func (a *App) SetKindOn(l *Live, name string) error
- func (a *App) SetModelOn(l *Live, id string)
- func (a *App) SetProfileEnabled(name string, on bool) error
- func (a *App) SetServerEnabled(name string, on bool) (ServerConfig, error)
- func (a *App) SetToolEnabled(name string, on bool) error
- func (a *App) Shadowed(name string) bool
- func (a *App) Stuck() []Stuck
- func (a *App) StuckOf(profile string) (Stuck, bool)
- func (a *App) TrackAll()
- type ApprovalDoneMsg
- type ApprovalMsg
- type Approver
- type Asking
- type AttemptMsg
- type BuildOptions
- type Choice
- type Compaction
- type Config
- func (c Config) CompactThreshold(window int) int
- func (c Config) OptionAsAlt() bool
- func (c Config) PruneAfter() int
- func (c *Config) SaveSetting(dir, key, value string) error
- func (c Config) SessionsPath() (string, error)
- func (c *Config) Set(key, value string) error
- func (c Config) Setting(key string) string
- func (c Config) SystemPrompt() (string, error)
- func (c Config) WithEnv() Config
- type Controller
- func (c *Controller) Active() []*Run
- func (c *Controller) Busy() bool
- func (c *Controller) Cancel(id string) error
- func (c *Controller) Children(id string) []*Run
- func (c *Controller) Done(id string) (<-chan struct{}, bool)
- func (c *Controller) Get(id string) (*Run, bool)
- func (c *Controller) Interrupt(id string) error
- func (c *Controller) Runs() []*Run
- func (c *Controller) Shutdown()
- func (c *Controller) Start(ctx context.Context, a *agent.Agent, missionID string, input []protocol.Part) (*Run, error)
- func (c *Controller) Steer(id string, parts ...protocol.Part) error
- type Endpoint
- type EventMsg
- type FactMsg
- type Field
- type Flow
- func (f *Flow) Done() <-chan struct{}
- func (f *Flow) Elapsed() time.Duration
- func (f *Flow) Err() error
- func (f *Flow) Finished() time.Time
- func (f *Flow) Interrupt(r *Run) error
- func (f *Flow) Note(l *Live, level Level, text string)
- func (f *Flow) Notify(level Level, text string)
- func (f *Flow) Open(ctx context.Context, kind string) (*Live, error)
- func (f *Flow) Panel(key string)
- func (f *Flow) Running() bool
- func (f *Flow) SetStatus(text string)
- func (f *Flow) Start(ctx context.Context, l *Live, missionID string, input []protocol.Part) (*Run, error)
- func (f *Flow) Status() string
- func (f *Flow) Steer(r *Run, parts ...protocol.Part) error
- func (f *Flow) Wait(ctx context.Context, r *Run) (protocol.Response, error)
- type FlowDoneMsg
- type Flows
- func (fs *Flows) Active() []*Flow
- func (fs *Flows) Cancel(id string) error
- func (fs *Flows) Get(id string) (*Flow, bool)
- func (fs *Flows) List() []*Flow
- func (fs *Flows) Restart(ctx context.Context, id string, w Workflow, live *Live, arg string) (*Flow, error)
- func (fs *Flows) Shutdown()
- func (fs *Flows) Start(ctx context.Context, w Workflow, live *Live, arg string) (*Flow, error)
- type HookEntry
- type HookOutputMsg
- type Instance
- type JobMsg
- type Kind
- type Level
- type Live
- type MCP
- func (m *MCP) Add(ctx context.Context, cfg ServerConfig) error
- func (m *MCP) Close()
- func (m *MCP) Connect(ctx context.Context, name string) error
- func (m *MCP) Disconnect(name string) error
- func (m *MCP) Reconnect(ctx context.Context, name string) error
- func (m *MCP) Remove(name string) error
- func (m *MCP) Status() []ServerStatus
- type MCPMsg
- type Meter
- func (m *Meter) Apply(run string, ev agent.Event)
- func (m *Meter) Attempts() []provider.Attempt
- func (m *Meter) Begin(a provider.Attempt)
- func (m *Meter) Bind(run, session string)
- func (m *Meter) Observe(a provider.Attempt)
- func (m *Meter) SessionOf(run string, ev agent.Event) string
- func (m *Meter) Sessions() []string
- func (m *Meter) SetCatalog(model profiles.Model, providerName string)
- func (m *Meter) SetThreshold(n int)
- func (m *Meter) Snapshot() Telemetry
- func (m *Meter) SnapshotOf(session string) (Telemetry, bool)
- func (m *Meter) Track(session string, model profiles.Model, providerName string, threshold int)
- type MissionMsg
- type NoteData
- type NoteMsg
- type NoticeMsg
- type OpenedMsg
- type PanelMsg
- type Pending
- type ProgressMsg
- type Pruning
- type Pump
- type Question
- type QuestionDoneMsg
- type QuestionMsg
- type Questioner
- func (q *Questioner) Answer(id int, answers []Answer) bool
- func (q *Questioner) Ask(ctx context.Context, run, sessionID string, questions []Question) ([]Answer, error)
- func (q *Questioner) Close()
- func (q *Questioner) Decline(id int) bool
- func (q *Questioner) ForSession(id string) *Asking
- func (q *Questioner) Len() int
- func (q *Questioner) Pending() []*Asking
- type RuleEntry
- type Run
- type RunDoneMsg
- type SavedMsg
- type Saver
- type Scope
- type Sender
- type ServerConfig
- type ServerEntry
- type ServerStatus
- type Setting
- type ShellConfig
- type Stuck
- type Subagents
- type Target
- type Telemetry
- type TerminalConfig
- type ToolStat
- type ToolsConfig
- type UIConfig
- type WebConfig
- type Workflow
Constants ¶
const ( ProjectDir = ".icebath" ConfigFile = "config.json" RulesFile = "rules.json" HooksFile = "hooks.json" SessionsDir = "sessions" // Directory under the user configuration directory holding the state each project keeps between runs ProjectsDir = "projects" )
Name of the project directory and of the files inside it and the user configuration directory
const ( ProfileEnv = "ICEBATH_PROFILE" ModelEnv = "ICEBATH_MODEL" )
Environment variables that override the chosen profile and model
Share of the model context window at which compaction runs when compact_threshold is unset
const DefaultPruneAfter = 10
Assistant turns a tool result stays in requests when prune_after is unset
const DefaultScrollback = 10000
Rows a terminal window keeps above its screen unless configured
const KindsDir = "kinds"
Directory under a configuration directory holding one kind per JSON file
const NoKind = "none"
Name that stands for no kind wherever a kind is chosen
const NoteKind = "note"
Record kind of a note a workflow wrote into a session for the person
Variables ¶
var ErrClosed = errors.New("harness: approver closed")
Error an ask returns once the approver was closed
var ErrNoProfile = errors.New("harness: no profile is open, pick one in config or pass -profile")
Error of a run or an open while nothing names a profile
var ErrQuestionsClosed = errors.New("harness: questioner closed")
Error an ask returns once the questioner was closed
var Scopes = []Scope{ScopeProject, ScopeUser}
Scopes a new entry may be written to, the project first
Functions ¶
func Base ¶
Base prompt of a session offered the tools, the conduct of a coding agent and then the configured instructions
func CheckMatcher ¶
Checks that a matcher compiles as a regular expression
func GatherFacts ¶
Facts about the machine as it stands, the working directory given by the caller
func NewestSession ¶
Id of the newest stored session of the project that no other icebath has open, sub-agent sessions left out
func ParseSetting ¶
Parses a numeric or bare value for a setting override such as max_tokens=4096
func RegisterHook ¶
Adds a hook every agent built later runs with, built per agent
func RegisterKind ¶
Makes a kind available to every app built later, refusing an invalid or duplicate one
func RegisterPrompt ¶
Adds text to the system prompt of every run, composed per turn and left out when empty
func RegisterSetting ¶
Makes a setting known to the configuration, refusing a built in key, an invalid default or a duplicate
func RegisterTools ¶
Adds tools every app built later offers, built once the app stands
func RegisterWorkflow ¶
Makes a workflow available as a command, refusing an invalid or duplicate one
func Save ¶
Writes each value into every file setting it, else the user file, and removes unset ones from every file
func ScratchDir ¶
Directory under the system temp directory a session may fill with working notes and temporary files
Types ¶
type Answer ¶ added in v1.0.12
type Answer struct {
Picked []string `json:"picked,omitempty"`
Text string `json:"text,omitempty"`
Declined bool `json:"declined,omitempty"`
}
Answer the person gave one question, the labels picked or the text typed, declined when they gave neither
type App ¶
type App struct {
Config Config
Root string
Primary Endpoint
Tools *tool.Registry
Shell *shell.Shell
Files files.Options
Rules *policy.Rules
Mode *policy.ModeSwitch
Memory *policy.Memory
Gate policy.Gate
Approver *Approver
Questions *Questioner
Pump *Pump
Meter *Meter
MCP *MCP
Facts *facts.Store
Missions *mission.Store
Subagents *agent.Subagents
Store *session.Store
Session *session.Session
Control *Controller
Saver *Saver
Flows *Flows
System string
// Profiles the profile files hold, in file order
Profiles []Instance
// Working directory the configuration was discovered under
Dir string
// contains filtered or unexported fields
}
Everything built from a configuration, shared by the terminal app and the headless runner
func (*App) Announce ¶ added in v1.0.11
Posts a message into the program for an extension that mirrors the live sessions
func (*App) Close ¶
Stops runs, closes servers and the shell, saves every open session and fires the SessionEnd hooks
func (*App) CloseServer ¶
Closes and forgets the server when it is open, waiting for it to exit
func (*App) CreateKind ¶
Opens a fresh session of the kind beside the ones already open, on the endpoint the kind names or the default
func (*App) CreateOn ¶
Opens a fresh session on an opened endpoint beside the ones already open, running as the kind when the app knows it and as none otherwise
func (*App) EndpointNamed ¶
Endpoint of a profile by name with the model, the default for an empty or unknown name and the default with its model swapped for the name of the default profile
func (*App) EnvironmentFor ¶
Environment block of a run offered the tools, the machine as it stands now
func (*App) FindProfile ¶
Profile by name, a written one before the built in one it may shadow
func (*App) Fork ¶
Opens a fork of an open session cut at n entries on the same endpoint and writes it to the store
func (*App) ForkStored ¶
Opens a full fork of a stored session, the open one when it is open here, without taking the source from another process
func (*App) Ghosted ¶
Reports whether the session stays off disk, by the ghost of its profile or of the session it serves
func (*App) HookEntries ¶
Every hook the configuration files hold, in read order and event order
func (*App) KindOf ¶
Kind the session runs as, false while it runs as none or as one the app no longer knows
func (*App) Metered ¶ added in v1.0.15
Context whose requests and agent events the meter charges to the session, for work on it outside any run
func (*App) MissionsFor ¶
Mission store the calling run plans into, the selected one outside a run
func (*App) MoveProfile ¶
Moves a written profile delta places through its file
func (*App) NewAgent ¶
Builds an agent on the session with every configured hook, the endpoint of the session and the shared gate
func (*App) Offered ¶ added in v1.0.14
Built in tools the kind offers and the registry has on, in guide order
func (*App) Open ¶
Opens a stored session beside the ones already open, returning the open one when it already is
func (*App) OpenEndpoint ¶
Opens a profile as an endpoint without changing the app, usable off the event loop
func (*App) ProfileInUse ¶
Reports whether the profile is the default or any open session runs on it
func (*App) ProjectInstructions ¶
Instructions of the project, one block per file found from the root down to the working directory
func (*App) PromptFor ¶
Prompt of a run as the kind, its base, the project and environment blocks, then every registered fragment
func (*App) PutKind ¶ added in v1.0.11
Replaces the kind of the same name or adds it, so runs started from now on follow it, refusing an invalid one
func (*App) Release ¶
Writes an open session that holds anything, gives its lease back and forgets it, selecting another when it was the selected one
func (*App) ReloadHooks ¶
Reads every hook file again and puts its hooks in force for later runs
func (*App) ReloadRules ¶
Reads every rule file again and puts its rules in force
func (*App) RemoveHook ¶
Deletes a hook from the file holding it
func (*App) RemoveProfile ¶
Deletes a written profile, refusing one in use
func (*App) RemoveRule ¶
Deletes a rule from the file holding it
func (*App) RemoveServer ¶
Deletes a server from every file configuring it, leaving the close to CloseServer
func (*App) ReplaceHook ¶
Replaces a hook in the file holding it
func (*App) ReplaceRule ¶
Replaces a rule in the file holding it
func (*App) RestartServer ¶
Closes the server named old and opens it under cfg unless turned off, blocking while the old one exits
func (*App) RuleEntries ¶
Every rule the configuration files hold, in read order
func (*App) RunOn ¶
func (a *App) RunOn(ctx context.Context, l *Live, missionID string, input []protocol.Part) (*Run, error)
Starts a run on an open session
func (*App) SaveProfile ¶
Writes a profile over the one named old, or adds it to the user file when old is empty
func (*App) SaveServer ¶
func (a *App) SaveServer(scope Scope, old string, cfg ServerConfig) error
Writes a server over old in its file or into the config file of the scope, without restarting it
func (*App) ScratchFor ¶
Scratch directory of the calling run's session, created when missing, empty with no session
func (*App) ServerEntries ¶
func (a *App) ServerEntries() ([]ServerEntry, error)
Servers the configuration files hold, a later file replacing an earlier namesake in place
func (*App) SessionFor ¶
Session of the calling run, the selected one outside a run
func (*App) SessionStart ¶
Fires the SessionStart hooks
func (*App) SetDefaultEndpoint ¶
Moves new sessions to an opened endpoint, and every open session of that profile left without a model
func (*App) SetDefaultModel ¶
Changes the model new sessions start on
func (*App) SetEndpointOn ¶
Moves an open session to an opened endpoint, now the default, forgetting its stored copy when the profile is ghost
func (*App) SetKindOn ¶
Makes an open session run as the kind from its next run, an empty name or none returning it to the plain agent
func (*App) SetModelOn ¶
Changes the model of an open session, moving the default along when the session is on the default profile
func (*App) SetProfileEnabled ¶
Turns a written profile on or off, refusing to turn off one in use
func (*App) SetServerEnabled ¶
func (a *App) SetServerEnabled(name string, on bool) (ServerConfig, error)
Turns a server on or off in the file configuring it, returning the settings RestartServer opens it under
func (*App) SetToolEnabled ¶
Turns a tool on or off and saves the names turned off
type ApprovalDoneMsg ¶
Approval that was answered, cancelled or timed out
type Approver ¶
type Approver struct {
// contains filtered or unexported fields
}
Asker that posts each request into the program and waits for the answer the program hands back
func NewApprover ¶
func (*Approver) Answer ¶
Delivers the answer to a pending approval and reports whether one was waiting
type Asking ¶ added in v1.0.12
type Asking struct {
ID int
Run string
Session string
Questions []Question
Asked time.Time
// contains filtered or unexported fields
}
Questions of one tool call waiting on the person
type AttemptMsg ¶
type AttemptMsg struct {
Attempt provider.Attempt
// Id of the session the attempt served, empty when its run is bound to none
Session string
Telemetry Telemetry
}
One provider attempt with the telemetry of its session afterwards, the totals for an attempt of no session
type BuildOptions ¶
type BuildOptions struct {
// Session to resume, a new one when empty
Resume string
// Working directory of the shell and base of relative paths, the process directory when empty
Dir string
}
Options a caller passes beside the configuration
type Choice ¶ added in v1.0.12
type Choice struct {
Label string `json:"label"`
Description string `json:"description,omitempty"`
}
One answer a question offers
type Compaction ¶
type Compaction struct {
// Context tokens at which old turns are summarized, unset for the default share of the window and zero to never compact
Threshold *int `json:"threshold,omitempty"`
// Messages kept verbatim after the summary
Keep int `json:"keep,omitempty"`
// Profile and model writing summaries, the main model when empty
Model *Target `json:"model,omitempty"`
// Extra guidance appended to the summary instructions
Instructions string `json:"instructions,omitempty"`
}
Compaction settings
type Config ¶
type Config struct {
Profile string `json:"profile,omitempty"`
Model string `json:"model,omitempty"`
// System prompt text, or the file it is read from
System string `json:"system,omitempty"`
SystemFile string `json:"system_file,omitempty"`
// Permission mode such as default, acceptEdits, plan or bypassPermissions
Mode string `json:"mode,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
MaxRounds int `json:"max_rounds,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
Extra map[string]json.RawMessage `json:"extra,omitempty"`
Compaction Compaction `json:"compaction,omitempty"`
Pruning Pruning `json:"pruning,omitempty"`
Permissions policy.RuleSet `json:"permissions,omitempty"`
Hooks agent.HookConfig `json:"hooks,omitempty"`
MCP []ServerConfig `json:"mcp,omitempty"`
Subagents Subagents `json:"subagents,omitempty"`
Shell ShellConfig `json:"shell,omitempty"`
Web WebConfig `json:"web,omitempty"`
Tools ToolsConfig `json:"tools,omitempty"`
UI UIConfig `json:"ui,omitempty"`
Terminal TerminalConfig `json:"terminal,omitempty"`
// Values of the settings extensions register, by key
Settings map[string]string `json:"settings,omitempty"`
// Project root for hooks, rules and servers, the working directory when empty
Root string `json:"root,omitempty"`
// Directory sessions are written to, sessions under the configuration directory when empty
SessionsDir string `json:"sessions_dir,omitempty"`
// Extra profile lists loaded before the user list
ProfileFiles []string `json:"profile_files,omitempty"`
// Catalog files loaded over the built in one
CatalogFiles []string `json:"catalog_files,omitempty"`
// Files the configuration was read from, in load order
Sources []string `json:"-"`
}
Everything the shell app and the headless runner need, read from files, environment and flags
func Discover ¶
Reads the user configuration, then the project configuration under dir, then the environment, later layers winning
func ReadConfig ¶
Reads one configuration file, ignoring keys it does not know
func ReadConfigFile ¶
func (Config) CompactThreshold ¶
Context tokens at which compaction runs for a model with that window, the default share when unset
func (Config) OptionAsAlt ¶ added in v1.0.13
Reports whether characters a Mac Option key types are read as alt chords, on under macOS unless set
func (Config) PruneAfter ¶
Assistant turns a tool result stays in requests, the default when unset
func (*Config) SaveSetting ¶
Applies a setting and saves it so the next start under dir reads the same value
func (Config) SessionsPath ¶
Directory sessions are stored in, created on demand
func (*Config) Set ¶
Applies a KEY=VALUE override to the configuration, an empty value unsetting the setting
func (Config) SystemPrompt ¶
System prompt from the inline text or the named file
type Controller ¶
type Controller struct {
Pump *Pump
Saver *Saver
Meter *Meter
Missions *mission.Store
// Subagent tool whose children the controller can cancel and steer
Subagents *agent.Subagents
// Mission store of a session, the shared one when nil or when it answers nil
MissionsOf func(*session.Session) *mission.Store
// Hears every root run as it ends, before the program does
OnEnd func(*Run)
// contains filtered or unexported fields
}
Starts, steers, interrupts and cancels runs and keeps a registry of them and their children
func NewController ¶
func NewController(send Sender, pump *Pump) *Controller
func (*Controller) Active ¶
func (c *Controller) Active() []*Run
Runs still going, root runs first then children by start time
func (*Controller) Children ¶
func (c *Controller) Children(id string) []*Run
Children of a run in start order
func (*Controller) Done ¶
func (c *Controller) Done(id string) (<-chan struct{}, bool)
Channel closed when the run ends
func (*Controller) Interrupt ¶
func (c *Controller) Interrupt(id string) error
Asks the agent to stop after the current turn or tool round
func (*Controller) Shutdown ¶
func (c *Controller) Shutdown()
Stops every run and waits for them to end
type Endpoint ¶
type Endpoint struct {
Profile profiles.Profile
Provider *provider.Provider
Model string
Catalog profiles.Model
// Base prompt the profile names, read as the endpoint opened, empty while it names none or the built in one
System string
}
One endpoint the app opened, with the model it serves
type Field ¶
type Field struct {
Path []string
Value any
// Removes the value from every file holding it instead of writing one
Unset bool
}
One value at a path inside a configuration file
type Flow ¶
type Flow struct {
ID string
Name string
Arg string
App *App
// Session the workflow was started from, nil when it started without one
Live *Live
Started time.Time
// contains filtered or unexported fields
}
One running or finished workflow with what it may do
func (*Flow) Interrupt ¶ added in v1.0.11
Asks the run to stop after the turn or tool round it is in
func (*Flow) Note ¶ added in v1.0.11
Writes a note for the person into the transcript of the session, stored with it and shown at once
func (*Flow) Open ¶
Opens a fresh session of the kind, the default kind when empty, and announces it so a card shows it
func (*Flow) Panel ¶ added in v1.0.11
Asks the terminal to open the panel beside the sessions of the workflow
func (*Flow) Start ¶
func (f *Flow) Start(ctx context.Context, l *Live, missionID string, input []protocol.Part) (*Run, error)
Starts a run on the session with the input, assigning it to a mission when one is named, refusing a session with a run going
type FlowDoneMsg ¶
Workflow that reached its end
type Flows ¶
type Flows struct {
// contains filtered or unexported fields
}
Starts, lists and stops workflows and keeps a registry of them
type HookEntry ¶
type HookEntry struct {
Event agent.HookEvent
Matcher string
Command string
Timeout int
Path string
}
One hook command with the event and matcher it runs for and the file holding it
type HookOutputMsg ¶
Hook output that is not part of a verdict, such as plain text a hook printed
type Kind ¶
type Kind struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
// Base prompt sent in place of the built in one
System string `json:"system,omitempty"`
// Text appended to the base prompt
Append string `json:"append,omitempty"`
// Tool names offered, every tool when empty
Tools []string `json:"tools,omitempty"`
// Tool names withheld
Deny []string `json:"deny,omitempty"`
// Profile and model sessions created with the kind start on, the default endpoint when nil
Model *Target `json:"model,omitempty"`
// Tool rounds one run may take, the configured limit when zero
MaxRounds int `json:"max_rounds,omitempty"`
// Output tokens one model turn may produce, the configured limit when zero
MaxTokens int `json:"max_tokens,omitempty"`
// Assistant turns a tool result stays in requests, the configured window when zero
PruneAfter int `json:"prune_after,omitempty"`
// Hooks every agent of the kind runs with
Hooks []agent.Hook `json:"-"`
// Extension or file the kind came from
Source string `json:"-"`
}
Named recipe an agent is built from, a session type
type Live ¶
type Live struct {
Session *session.Session
Facts *facts.Store
Missions *mission.Store
Endpoint Endpoint
// contains filtered or unexported fields
}
Session open in the shell with the stores that log into it and the endpoint its runs go to
func (*Live) ExpandsThinking ¶ added in v1.0.14
Reports whether the thinking of its runs opens in the transcript as it arrives
func (*Live) SetExpandThinking ¶ added in v1.0.14
Opens the thinking of its runs in the transcript as it arrives, or leaves each block folded
type MCP ¶
Keeps MCP servers connected and their tools registered, swapping tools off the callback goroutine
func (*MCP) Add ¶
func (m *MCP) Add(ctx context.Context, cfg ServerConfig) error
Adds a server and connects it in the background unless it starts disabled
func (*MCP) Close ¶
func (m *MCP) Close()
Closes every server and waits for background work to finish
func (*MCP) Disconnect ¶
Closes the server, dropping its tools from the registry
func (*MCP) Status ¶
func (m *MCP) Status() []ServerStatus
State of every server in configuration order
type Meter ¶
type Meter struct {
// contains filtered or unexported fields
}
Provider observer and agent event consumer that keeps the telemetry of every session and their totals current
func (*Meter) Apply ¶
Updates the totals and the session of the run with usage, cost, tools, context and throughput of an event
func (*Meter) Begin ¶
Records when a request leaves, the origin the first token of its session is timed from
func (*Meter) Bind ¶ added in v1.0.15
Charges the attempts and events labeled with the run id to the session
func (*Meter) SessionOf ¶ added in v1.0.15
Session id an event of the run is charged to, empty when no session is bound
func (*Meter) Sessions ¶ added in v1.0.15
Ids of the sessions with telemetry in the order the meter first saw them
func (*Meter) SetCatalog ¶
Uses an explicit catalog entry for the totals and for runs bound to no session
func (*Meter) SetThreshold ¶
Records the compaction threshold of the totals
func (*Meter) Snapshot ¶
Totals over every session, the context summed and the per session gauges left at zero
func (*Meter) SnapshotOf ¶ added in v1.0.15
Telemetry of one session, false when the meter has never seen it
type MissionMsg ¶
Mission store change of one session
type NoteMsg ¶ added in v1.0.11
Text a workflow wrote into the transcript of a session for the person, kept with the session
type NoticeMsg ¶
type NoticeMsg struct {
Text string
Level Level
// Workflow that raised it, empty for none
Flow string
}
Text a workflow or extension wants the person to see
type Pending ¶
type Pending struct {
ID int
Run string
Agent string
Request policy.Request
Asked time.Time
// contains filtered or unexported fields
}
One approval waiting for a person
type ProgressMsg ¶
Output or progress a running tool reported
type Pruning ¶
type Pruning struct {
// Assistant turns a tool result stays in requests before a stub replaces it, unset for the default and zero to never prune
After *int `json:"after,omitempty"`
}
Tool result pruning settings
type Pump ¶
type Pump struct {
// contains filtered or unexported fields
}
Observer that forwards events as messages, merging streamed deltas so a fast model never floods the program
type Question ¶ added in v1.0.12
type Question struct {
Text string `json:"question"`
Header string `json:"header,omitempty"`
Choices []Choice `json:"options"`
Multi bool `json:"multi_select,omitempty"`
}
Question put to the person, answered by picking choices or typing an answer of their own
type QuestionDoneMsg ¶ added in v1.0.12
Questions that were answered, declined or abandoned
type QuestionMsg ¶ added in v1.0.12
type QuestionMsg struct {
Asking *Asking
}
Question a person must answer
type Questioner ¶ added in v1.0.12
type Questioner struct {
// contains filtered or unexported fields
}
Asker that posts each set of questions into the program and waits for the answers the program hands back
func NewQuestioner ¶ added in v1.0.12
func NewQuestioner(send Sender) *Questioner
func (*Questioner) Answer ¶ added in v1.0.12
func (q *Questioner) Answer(id int, answers []Answer) bool
Delivers one answer per question to a pending ask and reports whether one was waiting for that many
func (*Questioner) Ask ¶ added in v1.0.12
func (q *Questioner) Ask(ctx context.Context, run, sessionID string, questions []Question) ([]Answer, error)
Posts the questions for the session and blocks until every one is answered or the context ends
func (*Questioner) Close ¶ added in v1.0.12
func (q *Questioner) Close()
Refuses every later ask and declines the ones waiting
func (*Questioner) Decline ¶ added in v1.0.12
func (q *Questioner) Decline(id int) bool
Answers every question of a pending ask as declined and reports whether one was waiting
func (*Questioner) ForSession ¶ added in v1.0.12
func (q *Questioner) ForSession(id string) *Asking
Oldest ask waiting on the session, nil while none is
func (*Questioner) Len ¶ added in v1.0.12
func (q *Questioner) Len() int
func (*Questioner) Pending ¶ added in v1.0.12
func (q *Questioner) Pending() []*Asking
Asks waiting, oldest first
type Run ¶
type Run struct {
ID string
Name string
Mission string
Agent *agent.Agent
Session *session.Session
// Run id of the parent, empty at the root
Parent string
Depth int
// Tool call that spawned a child run
CallID string
Description string
Started time.Time
// contains filtered or unexported fields
}
One agent run the controller started or discovered as a child of one it started
type RunDoneMsg ¶
Run that reached its end
type SavedMsg ¶
type SavedMsg struct {
Session string
Path string
// Listing entry of the session as saved, so a card need not read the store again
Info session.Info
Err error
}
Session written to the store
type Saver ¶
type Saver struct {
Store *session.Store
// Reports whether a session stays off disk, nothing of it written while it does
Off func(*session.Session) bool
// contains filtered or unexported fields
}
Writes sessions to a store after a short quiet period so a burst costs one write, skipping empty sessions
type Scope ¶
type Scope string
Where a new entry is written, the project directory or the user configuration directory
type ServerConfig ¶
type ServerConfig struct {
Name string `json:"name"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
Dir string `json:"dir,omitempty"`
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
// Seconds each handshake and listing may take
Timeout int `json:"timeout,omitempty"`
// Starts disabled, connected only on request
Disabled bool `json:"disabled,omitempty"`
}
One MCP server as configuration names it, over stdio when a command is given and streamable HTTP when a URL is
type ServerEntry ¶
type ServerEntry struct {
Config ServerConfig
Path string
}
One MCP server with the file configuring it
type ServerStatus ¶
type ServerStatus struct {
Name string
Config ServerConfig
State mcp.State
Err error
Tools []string
Attempts int
Info mcp.ServerInfo
Since time.Time
}
Connection and tool state of one managed server
type Setting ¶
type Setting struct {
Key string
Help string
// Values the setting may take, a choice when set
Choices []string
// Floor, ceiling and step of a number, no ceiling when it sits at or under the floor
Lo, Hi, Step float64
Integer bool
// Further check of a value after the choice or range one
Check func(value string) error
// Shown masked wherever it is edited, for a key or token
Secret bool
// Holds a profile name, rewritten when that profile is renamed
Profile bool
// Extension the setting came from
Source string
}
Setting an extension adds to the configuration, saved under settings in the configuration file
func LookupSetting ¶
Setting registered under the key
type ShellConfig ¶
type ShellConfig struct {
// Seconds a command may run when the model names no timeout
Timeout int `json:"timeout,omitempty"`
// Seconds the model may ask for at most
MaxTimeout int `json:"max_timeout,omitempty"`
// KEY=VALUE pairs every command sees
Env []string `json:"env,omitempty"`
}
Shell settings
type Stuck ¶ added in v1.0.11
Profile whose endpoint refuses every call until the person acts, with the refusal and when it was first heard
type Subagents ¶
type Subagents struct {
MaxDepth int `json:"max_depth,omitempty"`
Parallel bool `json:"parallel,omitempty"`
// Seconds one child may run
Timeout int `json:"timeout,omitempty"`
// Profile and model children use, the main one when empty
Model *Target `json:"model,omitempty"`
}
Subagent settings
type Telemetry ¶
type Telemetry struct {
Model string
Provider string
// Tokens the next request will carry, summed over every session in the totals
Context int
// Context window of the model, zero when unknown
ContextLimit int
// Context at which compaction runs, zero when none is configured
Threshold int
Usage protocol.Usage
// Dollars spent over the session, zero when no pricing is known
Cost float64
// Whether the model has pricing, so the cost means something
Priced bool
// Share of the last request of the session served from cache, zero in the totals
CacheRatio float64
// Output tokens per second of the current or last turn of the session, zero in the totals
TokensPerSecond float64
// Whether the session is in a turn, false in the totals
Streaming bool
Requests int
Retries int
Failures int
LastRequestID string
LastLatency time.Duration
AvgLatency time.Duration
// Time from the request start to the first token of the current or last turn, zero in the totals
FirstToken time.Duration
RateLimit provider.RateLimit
// Dollars per run id
Costs map[string]float64
// Calls and estimated result tokens per tool name
Tools map[string]ToolStat
// Estimated result tokens over every tool call
ToolTokens int
}
What the model layer has done so far, as a card can show it
type TerminalConfig ¶ added in v1.0.10
type TerminalConfig struct {
// Command line the shell of a terminal window runs, the login shell of the user when empty
Shell string `json:"shell,omitempty"`
// Rows a terminal window keeps above its screen, nil for the default
Scrollback *int `json:"scrollback,omitempty"`
}
Terminal window settings
type ToolsConfig ¶
type ToolsConfig struct {
// Tool names withheld from the model and refused when called
Disabled []string `json:"disabled,omitempty"`
}
Tool settings
type UIConfig ¶
type UIConfig struct {
// Theme name such as blackwall, light, contrast or plain
Theme string `json:"theme,omitempty"`
// Motion scale from zero for snapping to one for full springs
Motion *float64 `json:"motion,omitempty"`
// Main slot share of the width
Ratio float64 `json:"ratio,omitempty"`
// Cascade lights the focused card's border with a flowing energy comet
Cascade *bool `json:"cascade,omitempty"`
// Characters a Mac Option key types read as alt chords, nil for on under macOS only
OptionAsAlt *bool `json:"option_as_alt,omitempty"`
}
Appearance settings
type WebConfig ¶
type WebConfig struct {
// Disables the fetch tool
Disabled bool `json:"disabled,omitempty"`
}
Web fetch settings
type Workflow ¶
type Workflow struct {
Name string
Title string
Description string
// Placeholder of the argument, asked for when the command comes without one, none when empty
Arg string
Run func(ctx context.Context, f *Flow, arg string) error
// Picks the id of the next flow, unique across processes, the per process counter when nil
NextID func(app *App) (string, error)
// Extension the workflow came from
Source string
}
Named procedure that drives sessions and runs, offered as a command
func LookupWorkflow ¶
Workflow registered under the name