Documentation
¶
Overview ¶
Package agent knows the coding agents a launch can start, Claude Code and OpenAI Codex, and checks the options a launch passes them, so every place that stores those options (profiles, prompts, and launch defaults) and the launcher that passes them apply the same rules.
Each agent is a backend spec: its command, the environment variable that points it at a profile's config directory, the entries that mark such a directory, its effort levels, model suggestions, and permission modes, the flags the launcher sets itself (and so may not be added by hand), and how a launch's model, effort, access, extra directories, and session name become its command-line flags. Adding a backend adds a spec here; the launcher, the profiles, and the editors read everything else from it.
It also reads extra flags typed on one line, quoted the way a shell would, into one argument each. CheckOverrides and CheckSettings check a model, an effort level, and extra flags the way the prompt and launch-default editors show them, as FieldErrors.
The package is pure: it reads no files and runs nothing.
Index ¶
- Constants
- Variables
- func AnyEffortLevels() []string
- func Args(id ID, o Options) ([]string, error)
- func CheckAccess(id ID, args []string) error
- func CheckExtra(id ID, args []string) error
- func CheckFenced(id ID, args []string) error
- func CheckSettings(in Settings) (Checked, []FieldError)
- func CloneArgs(m map[ID][]string) map[ID][]string
- func CloneModels(m map[ID]string) map[ID]string
- func ConversationArgs(id ID, o ConversationOptions) ([]string, error)
- func ConversationFloor(id ID) string
- func ConversationToolPrefix(id ID, server string) string
- func EffortLevels(id ID) []string
- func EqualArgs(a, b map[ID][]string) bool
- func EqualModels(a, b map[ID]string) bool
- func FenceFiles(id ID, a Access, built fence.Fence, program string) ([]fence.File, error)
- func FenceFloor(id ID) string
- func FieldFor(field string, id ID) string
- func HeadlessArgs(id ID, o HeadlessOptions) ([]string, error)
- func HeadlessEnv(id ID, env []string) []string
- func HeadlessFiles(id ID, schema string) ([]fence.File, error)
- func Join(args []string) string
- func JoinArgs(m map[ID][]string) map[ID]string
- func KeepsPreset(id ID, p fence.Preset) (bool, string)
- func Known(id ID) bool
- func ParseVersion(out []byte) string
- func PluginArgs(id ID, op PluginOp, r PluginRef) ([]string, error)
- func PluginToolPrefix(id ID, plugin, server string) string
- func PromptLast(id ID) bool
- func Split(line string) ([]string, error)
- func StrictSchema(schema string) (string, error)
- func ValidPermissionMode(id ID, mode string) bool
- func ValidSessionID(id string) bool
- func ValidateEffort(id ID, effort string) error
- func ValidateEffortAny(effort string) error
- func ValidateModel(model string) error
- type Access
- type AccessKind
- type Agent
- type Background
- type Checked
- type Choice
- type ConversationOptions
- type ConversationSpec
- type Fence
- type FencedRun
- type FieldError
- type File
- type Headless
- type HeadlessOptions
- type ID
- type Marker
- type Options
- type PluginListing
- type PluginOp
- type PluginOutcome
- type PluginRef
- type PluginResult
- type PluginSkill
- type PluginSpec
- type PresetKeep
- type ReservedFlagError
- type Settings
- type SignIn
- type SignInState
- type ValidationError
Constants ¶
const ( FieldModel = "model" FieldModels = "models" FieldEffort = "effort" FieldExtraFlags = "extraFlags" )
Fields a FieldError from CheckOverrides and CheckSettings names, matching the editors' JSON names.
const FenceSettingsName = "settings.json"
FenceSettingsName is the file in a fenced run's folder that holds the agent's fence settings: its rules, its hook, and its sandbox.
const MCPConfigName = "mcp.json"
MCPConfigName is the file of a conversation's folder that holds a turn's MCP config, as ConversationFiles writes it and ConversationOptions.MCPConfig names it.
const ReportSchemaName = "report-schema.json"
ReportSchemaName is the file in a background run's folder that holds the report's schema, for an agent that reads it from a file (Codex's --output-schema).
Variables ¶
var ( // ErrNoConversation is returned for an agent the app holds no conversation with. ErrNoConversation = errors.New("the agent holds no conversation with the app") // ErrInvalidConversation is returned for a turn's options, or its files, a turn can't // start with. ErrInvalidConversation = errors.New("invalid conversation turn") // ErrInvalidPlugin is returned for a plugin, or a plugin command, that can't be written. ErrInvalidPlugin = errors.New("invalid plugin") // ErrPluginOutput is returned for what a plugin command printed when it isn't the JSON // it was asked for. ErrPluginOutput = errors.New("unreadable plugin command output") )
var ( // ErrInvalidEffort is returned for an effort level the agent does not accept. ErrInvalidEffort = errors.New("unknown effort level") // ErrInvalidModel is returned for a model name the agent could misread. ErrInvalidModel = errors.New("invalid model name") // ErrReservedFlag is returned for an extra flag the launcher sets itself. ErrReservedFlag = errors.New("reserved flag") // ErrEmptyFlag is returned for an empty extra argument. ErrEmptyFlag = errors.New("empty argument") // ErrNULByte is returned for an argument holding a NUL byte, which no process // argument can carry. ErrNULByte = errors.New("value contains a NUL byte") // ErrTilde is returned for an argument that starts with ~: launch scripts quote every // argument, so no shell expands it. ErrTilde = errors.New("~ is not expanded") // ErrUnterminatedQuote is returned by Split for a quote that is never closed. ErrUnterminatedQuote = errors.New("unterminated quote") // ErrEndOfFlags is returned for a "--" in extra arguments: everything after it would // be read as the prompt. ErrEndOfFlags = errors.New(`"--" can't be added: everything after it would be read as the prompt`) )
var ( // ErrNoBackground is returned for an agent that can't run in the background. ErrNoBackground = errors.New("the agent can't run in the background") // ErrInvalidBudget is returned for a budget that isn't a positive amount. ErrInvalidBudget = errors.New("invalid budget") // ErrInvalidHeadless is returned for headless options a run can't start with. ErrInvalidHeadless = errors.New("invalid background run") )
var ErrFencedDirs = errors.New("a fenced run takes no extra directories: its file tools stay in its worktree")
ErrFencedDirs is returned for a fenced run given extra directories: its file tools stay in its worktree.
var ErrInvalidAccess = errors.New("unknown access")
ErrInvalidAccess is returned for an access kind this build does not know.
var ErrInvalidPermissionMode = errors.New("unknown permission mode")
ErrInvalidPermissionMode is returned for a permission mode the agent does not accept.
var ErrInvalidSchema = errors.New("invalid report schema")
ErrInvalidSchema is returned for a report's schema the strict form can't be made of.
var ErrInvalidSessionID = errors.New("invalid session ID")
ErrInvalidSessionID is returned for a session ID that is not a UUID, or for a launch that both starts a session with an ID and resumes one.
var ErrPresetNotKept = errors.New("this agent can't keep the tools preset")
ErrPresetNotKept is returned for a tools preset the agent can't keep in a background run.
var ErrUnknownAgent = errors.New("unknown coding agent")
ErrUnknownAgent is returned for an agent ID this build does not know.
Functions ¶
func AnyEffortLevels ¶
func AnyEffortLevels() []string
AnyEffortLevels returns every effort level some agent accepts, lowest first.
func Args ¶
Args returns the flags a launch passes the agent with id, in order: model, effort, access, extra directories, extra arguments, session name, and the session to start or resume. It refuses a model or effort level the agent would not accept, a permission mode it does not have, and a session ID that is not one.
func CheckAccess ¶
CheckAccess returns the first of args that sets a permission switch of the agent with id, as a ReservedFlagError, or nil. Permissions come only from the launcher's own policy, so an outside contributor's item can never be launched with more access than it allows, whatever a profile's extra arguments say.
func CheckExtra ¶
CheckExtra checks extra arguments added by a profile, a prompt, or a launch default for the agent with id. Each must be non-empty and free of NUL bytes, must not start with ~ or give a flag a value that does (--add-dir=~/x), since nothing expands it, must not be "--", and must not set a flag the launcher owns (see ReservedFlagError), including a config override of a value the launcher sets, such as Codex's -c model=<name>.
func CheckFenced ¶ added in v0.4.0
CheckFenced checks the extra arguments of a background run, as CheckExtra checks every launch's, and also refuses each flag the routine's fence sets or that would loosen it: the tools and settings flags, extra directories, plugins and MCP servers, and the headless run's own (see ReservedFlagError).
func CheckSettings ¶
func CheckSettings(in Settings) (Checked, []FieldError)
CheckSettings checks Settings the way the prompt and launch-default editors show them. It returns them ready to store, and a FieldError for each problem: an agent this build does not know (on FieldModels or FieldExtraFlags), a model the agent would misread or flags it cannot take (on FieldFor(FieldModels, id) or FieldFor(FieldExtraFlags, id)), and an effort level no agent accepts (on FieldEffort).
func CloneArgs ¶
CloneArgs returns a deep copy of each agent's extra arguments with the empty lists left out; never nil.
func CloneModels ¶
CloneModels returns each agent's model with the blank ones left out; never nil.
func ConversationArgs ¶ added in v0.7.0
func ConversationArgs(id ID, o ConversationOptions) ([]string, error)
ConversationArgs returns the flags a conversation's turn passes the agent with id, in order, once each option checks out: the stream, nobody to answer, the session started or resumed and its name, the model and effort, none of the agent's own tools and none of the user's or a folder's settings, the turn's MCP server alone and its every tool allowed, the budget, and the instructions. The prompt comes on stdin, never on the command line.
func ConversationFloor ¶ added in v0.7.0
ConversationFloor returns the oldest version of the agent with id that takes every flag a conversation's turn and the plugin commands pass, or "" for an agent that holds no conversation.
func ConversationToolPrefix ¶ added in v0.7.0
ConversationToolPrefix returns what the name of every tool of the MCP server named server starts with, in a turn of the agent with id: every tool an in-app turn may use starts with it. It is "" for an agent that holds no conversation, or a name that isn't a server's, which no tool can be checked against.
func EffortLevels ¶
EffortLevels returns the effort levels the agent with id accepts, lowest first, or nil for an agent this build does not know.
func EqualArgs ¶
EqualArgs reports whether two agents' extra arguments are the same, an empty list and no entry being the same.
func EqualModels ¶
EqualModels reports whether two agents' models are the same, a blank model and no entry being the same.
func FenceFiles ¶ added in v0.4.0
FenceFiles returns the files the agent's fence needs in the run's folder, beside the policy fence.WriteRun writes: for Claude Code, its settings, with the fence hook (the app's own executable, program, in its hook mode), the rules, attribution off, and for a sandboxed preset, the sandbox. The access must be AccessFence in the run's folder, and built the fence worked out for its preset.
func FenceFloor ¶ added in v0.4.0
FenceFloor returns the oldest version of the agent whose flags every tools preset it keeps uses, or "" for an agent that keeps none.
func HeadlessArgs ¶ added in v0.4.0
func HeadlessArgs(id ID, o HeadlessOptions) ([]string, error)
HeadlessArgs returns the flags a background run passes the agent with id, in order, once each option checks out: the stream, nobody to answer, the session, the model and effort, the fence's access (its preset's mode and tools, no MCP server, and its settings), the budget, the report's schema, the system note, and the extra arguments. The prompt comes on stdin, never on the command line.
func HeadlessEnv ¶ added in v0.4.0
HeadlessEnv returns env without the variables that steer the agent with id itself, as a session the agent runs inside would leave them for a child (Claude Code's CLAUDECODE, CLAUDE_CODE_*, and the like), so a background run never takes on another session's settings. env itself is never changed, and the copy is never nil.
func HeadlessFiles ¶ added in v0.4.0
HeadlessFiles returns the files a background run of the agent with id reads from its own folder beside its fence's, for the report's schema: for an agent that reads its schema from a file (Codex), the schema in its strict form (StrictSchema), named ReportSchemaName; none for one that takes it on the command line, or with no schema.
func Join ¶
Join writes arguments on one line that Split reads back unchanged, each as textutil.ShellWord writes it: as is when a shell reads it as itself, as --add-dir=/srv/x is, and single-quoted otherwise.
func JoinArgs ¶
JoinArgs writes each agent's extra arguments on one line, as the editors show them; never nil.
func KeepsPreset ¶ added in v0.4.0
KeepsPreset reports whether the agent can keep a tools preset in a background run, and when it can't, why, as the builder says it.
func ParseVersion ¶ added in v0.4.0
ParseVersion returns the version an agent's VersionArgs printed, "" when there is none.
func PluginArgs ¶ added in v0.7.0
PluginArgs returns the arguments, after the agent's program, of the agent with id's plugin command op, each asking for its one line of JSON (ParsePluginResult, or ParsePluginList for PluginList): install needs r's plugin and its marketplace's folder, uninstall its plugin and marketplace, and the marketplace's removal its marketplace.
func PluginToolPrefix ¶ added in v0.7.0
PluginToolPrefix returns what the name of every tool of the plugin's MCP server starts with, in the user's own sessions of the agent with id; "" as ConversationToolPrefix returns it.
func PromptLast ¶
PromptLast reports whether the agent's prompt follows its flags, after "--", rather than coming first. An unknown agent reports false.
func Split ¶
Split reads extra flags typed on one line into one argument each, the way a POSIX shell splits words, but without expanding anything: whitespace separates arguments, single quotes keep everything up to the next single quote, double quotes keep everything but an escaped \" or \\, and a backslash outside quotes keeps the next character. Two single quotes in a row make an empty argument. An unclosed quote is an ErrUnterminatedQuote. Split(Join(args)) returns args.
func StrictSchema ¶ added in v0.4.0
StrictSchema returns a report's JSON schema in the strict form an agent that keeps to its schema strictly needs (Codex's --output-schema, as S6 found on codex-cli 0.163.0, which refused the draft schema): every object closed to other properties (additionalProperties false) with every property required, a property the schema left optional nullable instead, and an enum given the type of its values. The schema is one object; what it says otherwise is kept as it is. The result is on one line, its keys sorted.
func ValidPermissionMode ¶
ValidPermissionMode reports whether mode is one of the agent's permission modes.
func ValidSessionID ¶
ValidSessionID reports whether id can be passed as a session ID: a UUID (see sessionIDPattern).
func ValidateEffort ¶
ValidateEffort accepts "" (the agent's default) or one of the agent's EffortLevels.
func ValidateEffortAny ¶
ValidateEffortAny accepts "" or a level some agent accepts, for an effort shared by every agent, as prompts and launch defaults store it.
func ValidateModel ¶
ValidateModel accepts "" (the agent's default) or a model alias or full name: one word of printable characters, at most 100 long, that does not start with "-", so the agent can never read it as a flag.
Types ¶
type Access ¶
type Access struct {
Kind AccessKind
Mode string
// Fence is a background run's tools preset, for AccessFence alone.
Fence *Fence
}
Access is a launch's permissions: a kind, for AccessMode the mode, and for AccessFence the fence.
func FenceAccess ¶ added in v0.4.0
FenceAccess returns the access of a background run under a preset; base is the click's access, which only the profile's own preset keeps.
func (Access) InRun ¶ added in v0.4.0
InRun returns the access with its fence's settings in the run's folder dir. Any other access is returned as it is.
type AccessKind ¶
type AccessKind string
AccessKind is what a session may do without asking, as the launcher's trust policy decides it. Each agent turns it into its own flags.
const ( // AccessDefault passes no permission flag, so the agent's own settings apply. AccessDefault AccessKind = "" // AccessMode starts the session in one of the agent's permission modes (Access.Mode). AccessMode AccessKind = "mode" // AccessFull starts the session with full access: no prompts and no sandbox. AccessFull AccessKind = "full" // AccessPlan starts the session planning only: it reads, and changes nothing. AccessPlan AccessKind = "plan" // AccessPlanAllowFull starts the session planning, and lets it switch to full access // once the plan is accepted, where the agent can. AccessPlanAllowFull AccessKind = "plan-allow-full" )
Access kinds.
const AccessFence AccessKind = "fence"
AccessFence starts a background run under a routine's tools preset (Access.Fence): the preset brings its own permission mode and rules, whatever the profile says, and the profile's own preset starts from the access a click would (Fence.Base), within the fence's hard lines. Only the launcher's resolvePermission chooses it, below the trust rule, so an outside contributor's item still runs planning only.
type Agent ¶
type Agent struct {
// ID is what profiles and launch defaults store, such as "claude".
ID ID `json:"id"`
// Name is what the UI shows, as in "Open in Claude".
Name string `json:"name"`
// Command is the program a launch script runs.
Command string `json:"command"`
// ConfigEnv is the environment variable that points the agent at a profile's config
// directory, such as CLAUDE_CONFIG_DIR.
ConfigEnv string `json:"configEnv"`
// ConfigDir is the agent's default config directory under the home directory, such
// as ".claude". A sibling named ConfigDir_<name> or ConfigDir-<name> is profile
// <name>.
ConfigDir string `json:"configDir"`
// Markers are the entries that mark the agent's config directory.
Markers []Marker `json:"markers"`
// EffortLevels are the effort levels the agent accepts, lowest first.
EffortLevels []Choice `json:"effortLevels"`
// Models suggests model names; any model name the agent accepts works too.
Models []Choice `json:"models"`
// PermissionModes are the permission modes a profile may set, besides full access.
PermissionModes []Choice `json:"permissionModes"`
// PlanLabel names the agent's planning mode, which launches use for outside
// contributors' items: "Plan mode" or "Read-only".
PlanLabel string `json:"planLabel"`
// SessionNames reports that a launch can name the session.
SessionNames bool `json:"sessionNames"`
// SessionIDs reports that a launch passes the agent the session's ID, so the app
// follows the session from its start. Without it, the app finds the agent's own ID
// once the session starts.
SessionIDs bool `json:"sessionIds"`
// FastMode reports that a launch can start the session in the agent's Fast mode.
FastMode bool `json:"fastMode"`
// ConfigOverrides reports an agent that takes the effort level and Fast mode only as
// config overrides, and runs a session started with any outside its shared app
// server, where the app can't see that it waits for the user. A launch passes it the
// effort only when the user's settings say to.
ConfigOverrides bool `json:"configOverrides"`
// AuthFile is the file in a config directory that holds the agent's sign-in, or ""
// when the app does not check the agent's sign-in. Only its presence is checked; it is
// never read.
AuthFile string `json:"authFile"`
// AuthEnv lists environment variables that sign the agent in with a key instead.
AuthEnv []string `json:"authEnv"`
// ModelsCache is the file in a config directory where the agent keeps the models it
// offers, or "" when it keeps none the app reads.
ModelsCache string `json:"modelsCache"`
// VersionArgs are the arguments after Command that print the agent's version, such
// as --version; ParseVersion reads what they print.
VersionArgs []string `json:"versionArgs"`
// SignInArgs are the arguments after Command that say whether a profile is signed in,
// run with ConfigEnv set to the profile's config directory (unset for the default
// profile); ParseSignIn reads what they print. They only read the sign-in, never
// change it.
SignInArgs []string `json:"signInArgs"`
// KeyEnv lists the environment variables that would sign the agent in with an API key
// in place of the profile's own sign-in. A sign-in check runs without them, so it says
// whether the profile itself is signed in (as on a subscription, through the browser),
// never whether a key in the login shell's environment would do.
KeyEnv []string `json:"keyEnv"`
// LoginArgs are the arguments after Command that sign a profile in, which the user
// runs in a terminal under the profile's ConfigEnv: the app never signs in for them,
// since signing in needs a browser and the user.
LoginArgs []string `json:"loginArgs"`
// StatusPart is the part of the agent's provider's status page the agent depends on,
// as the service status catalog names it, such as "claude.code": while it reports a
// major outage, Autopilot holds new starts of the agent, if the user asks it to.
StatusPart string `json:"statusPart"`
// Background is what the agent can do in the background, for the routine builder: its
// headless capabilities, and each tools preset it keeps, or why not.
Background Background `json:"background"`
}
Agent is a coding agent the launcher can start. Every field is a plain value.
type Background ¶ added in v0.4.0
type Background struct {
Headless
// Presets are the tools presets, from the narrowest, each kept or not.
Presets []PresetKeep `json:"presets"`
}
Background is what an agent can do in the background, as the routine builder shows it: its headless capabilities, and whether it keeps each tools preset, or why not.
type Checked ¶
Checked is Settings ready to store: the models that are set, trimmed, and the extra arguments of each agent that has any. Neither map is nil.
type ConversationOptions ¶ added in v0.7.0
type ConversationOptions struct {
// SessionID is the conversation's ID, a UUID the app minted, and Resume says the turn
// takes it up again rather than starting it.
SessionID string
Resume bool
// Name is what the session is called in the user's own lists of sessions, or "".
Name string
// Model and Effort are "" for the agent's own default.
Model string
Effort string
// MCPConfig is the absolute path of the turn's MCP config (ConversationFiles), and
// SystemPromptFile that of the file holding the instructions the turn reads beside the
// agent's own system prompt.
MCPConfig string
SystemPromptFile string
// Server is the MCP server the config names, whose tools are the only ones the turn has
// and every one of which it may call.
Server string
// BudgetUSD is the turn's budget in dollars, which the agent keeps to itself: one turn's,
// never the conversation's.
BudgetUSD float64
}
ConversationOptions are what one turn of a conversation passes its agent, besides the prompt, which it reads on stdin. There is no field for extra arguments: a profile's own never reach a conversation.
type ConversationSpec ¶ added in v0.7.0
ConversationSpec is the MCP server a turn, or a plugin, starts: its name, and the program it runs with its arguments, as the app's own executable in its tool mode. The agent never spells the tool mode's flags: they come in Args.
type Fence ¶ added in v0.4.0
type Fence struct {
// Preset is the routine's tools preset.
Preset fence.Preset
// Base is the access a click would start with, which only the profile's own preset
// starts from; every other preset brings its own mode, so it is zero.
Base Access
// Settings is the absolute path of the settings file FenceFiles writes, in the run's
// own folder, which the runner sets once it has one (Access.InRun).
Settings string
// TakenOver reports the run's conversation resumed in the user's terminal (Take over):
// someone answers now, so each fixed preset asks about whatever its rules don't allow
// rather than refusing it, and its rules, its hook, and its sandbox still hold. The
// profile's own preset starts from the click's access either way.
TakenOver bool
// Policy is the run's fence policy, as fence.Build worked it out for the worktree, or
// as read back from the run's folder for Take over; Hook is the fence hook's program,
// the app's own executable. An agent that names its sandbox and its hook on the
// command line (Codex) writes its flags from them; one that keeps them in its settings
// file (Claude Code) needs neither. Both are unset until the run's fence is worked out,
// as in a preview (Access.Worked).
Policy *fence.Policy
Hook string
}
Fence is a background run's access under a tools preset.
type FencedRun ¶ added in v0.4.0
FencedRun is what a fenced background run needs beside its argv, whose access flags Args writes from the same AccessFence: its fence, the files its folder holds, and the line its unattended note gains.
func PrepareFence ¶ added in v0.4.0
PrepareFence works a fenced run out for the agent with id: the fence its spec builds (fence.Build), under the access's preset and in the folder its settings are in, and the agent's own files for it (FenceFiles), whose hook is the app's own executable, program. The runner calls it as the run starts, under the worktree's lock, then Write.
type FieldError ¶
type FieldError struct {
// Field is the field's JSON name, such as "model".
Field string `json:"field"`
// Message is a sentence saying what is wrong and how to fix it.
Message string `json:"message"`
}
FieldError is a problem with one field of something being saved.
func CheckOverrides ¶
func CheckOverrides(id ID, model, effort, flags string) ([]string, []FieldError)
CheckOverrides checks the launch settings a prompt or a launch default may set for the agent with id: the model, the effort level, and the extra flags typed on one line. It returns the extra flags as arguments, or nil with a FieldError when they cannot be read or used, and a FieldError for a model or effort level the agent would not accept.
type File ¶ added in v0.7.0
File is a file the agent reads, which the app writes for it: its path, relative to the folder it goes in and slash-separated, and its bytes.
func ConversationFiles ¶ added in v0.7.0
func ConversationFiles(id ID, s ConversationSpec) ([]File, error)
ConversationFiles returns the files a conversation's turn of the agent with id reads from its folder: for Claude Code, its MCP config (MCPConfigName), which names the server s alone.
func PluginFiles ¶ added in v0.7.0
func PluginFiles(id ID, p PluginSpec) ([]File, error)
PluginFiles returns the files of the plugin's local marketplace for the agent with id, relative to the marketplace's folder, which the app keeps current and the agent loads in place: the marketplace that lists the plugin, the plugin's manifest, its skill, and its MCP server. The plugin carries no settings, hooks, or permission rules, so a session asks the user before every call of its tools.
type Headless ¶ added in v0.4.0
type Headless struct {
// Background reports an agent that runs headless in the background at all.
Background bool `json:"background"`
// Budget reports an agent that keeps to a per-run budget in dollars of its own, so its
// run may go on once the app quits; Cost one that reports what a run cost, and Usage
// one that reports the tokens it used, which a cap in tokens counts.
Budget bool `json:"budget"`
Cost bool `json:"cost"`
Usage bool `json:"usage"`
// UsageLive reports an agent whose stream reports its tokens as the run goes, so the
// runner stops it once it passes a budget in tokens; one that reports them only as the
// run ends (Codex) has its budget checked then, its time limit bounding the run.
UsageLive bool `json:"usageLive"`
// Structured reports an agent that returns the run's report in the shape asked.
Structured bool `json:"structured"`
// Resume reports an agent whose background run the user can take over in the terminal.
Resume bool `json:"resume"`
// ReadsTrust reports an agent whose background run stops at its workspace trust
// question unless its folder is trusted, so the launcher trusts the worktree first;
// one that reads no trust (Codex, which leaves the user's config unread) is never
// trusted there.
ReadsTrust bool `json:"readsTrust"`
// MinVersion is the oldest version whose flags every background run uses, "" for an
// agent with no background runs.
MinVersion string `json:"minVersion"`
}
Headless is what an agent can do in the background, as its spec declares it. The engine, the builder, and readiness read these, never an agent's name.
func HeadlessOf ¶ added in v0.4.0
HeadlessOf returns what the agent with id can do in the background: nothing for an agent with no headless half yet, and an error only for an agent this build doesn't know.
type HeadlessOptions ¶ added in v0.4.0
type HeadlessOptions struct {
// Model and Effort are "" for the agent's own default.
Model string
Effort string
// Access is the fence's (AccessFence), as the launcher's permission rule chose it, in
// the run's folder.
Access Access
// SessionID is the ID the app minted for the run's session.
SessionID string
// Schema is the JSON schema of the report the agent returns, on one line, or "".
Schema string
// BudgetUSD is the run's budget in dollars, which an agent with Headless.Budget keeps
// to itself; 0 sets none.
BudgetUSD float64
// SystemNote is the system note every unattended run gets, its fence's line included,
// or "".
SystemNote string
// Extra are the profile's, the prompt's, and the launch default's extra arguments,
// checked with CheckFenced.
Extra []string
}
HeadlessOptions are what a background run passes its agent, besides the prompt, which it reads on stdin.
type ID ¶
type ID string
ID names a coding agent, as profiles, settings, and launch defaults store it.
type Marker ¶
type Marker struct {
// Name is the entry's name, such as "settings.json".
Name string `json:"name"`
// Dir reports a directory rather than a file.
Dir bool `json:"dir"`
}
Marker is an entry an agent writes into a config directory it runs with. A directory that holds one of an agent's markers is that agent's config directory.
type Options ¶
type Options struct {
// Model and Effort are "" for the agent's own default.
Model string
Effort string
// Access is the session's permissions.
Access Access
// AddDirs are extra directories the session may use, as absolute paths.
AddDirs []string
// Extra are extra arguments, one argv element each, passed as they are.
Extra []string
// SessionName names the session, or is "". An agent without SessionNames ignores it.
SessionName string
// SessionID is the ID the app minted for a new session, or "". An agent without
// SessionIDs ignores it.
SessionID string
// ResumeID is the agent's own ID of a session to resume instead of starting one, or
// "". A session resumed takes no prompt.
ResumeID string
// Fast starts the session in the agent's Fast mode. An agent without FastMode
// ignores it.
Fast bool
// TakeOver resumes a background run's conversation in the user's terminal: an agent
// whose resume keeps the run's unattended note (Codex's developer instructions persist
// in the thread) is first told that someone answers now. It applies only with
// ResumeID.
TakeOver bool
}
Options are what a launch passes an agent, besides its prompt. The launcher has checked the directories and the extra arguments.
type PluginListing ¶ added in v0.7.0
type PluginListing struct {
// ID is <plugin>@<marketplace>, Version the version installed, and Scope where it is
// installed ("user").
ID string `json:"id"`
Version string `json:"version"`
Scope string `json:"scope"`
// Enabled reports it on, and ReadFromFolder is the folder it loads in place from, or ""
// for one loaded from its copy.
Enabled bool `json:"enabled"`
ReadFromFolder string `json:"readFromFolder"`
}
PluginListing is a plugin as the agent's plugin list says it is installed (ParsePluginList).
func ParsePluginList ¶ added in v0.7.0
func ParsePluginList(stdout []byte) ([]PluginListing, error)
ParsePluginList reads what Claude Code's plugin list printed on stdout with --json: one JSON array, over as many lines as it takes, of every plugin installed; never nil.
type PluginOp ¶ added in v0.7.0
type PluginOp string
PluginOp is what one of the agent's plugin commands does.
const ( // PluginInstall installs the plugin from its local marketplace's folder, adding the // marketplace as it does. PluginInstall PluginOp = "install" // PluginUninstall uninstalls it. PluginUninstall PluginOp = "uninstall" // PluginRemoveMarketplace removes its local marketplace. PluginRemoveMarketplace PluginOp = "removeMarketplace" // PluginList lists every plugin installed. PluginList PluginOp = "list" )
The plugin commands.
type PluginOutcome ¶ added in v0.7.0
type PluginOutcome string
PluginOutcome is how a plugin command says it went.
const ( // PluginOK is a command that did what it was asked, or found it already done, as an // install of a plugin already installed. PluginOK PluginOutcome = "ok" // PluginFailed is one that didn't, its FailureCode saying why. PluginFailed PluginOutcome = "failed" )
The outcomes.
type PluginRef ¶ added in v0.7.0
PluginRef names what a plugin command acts on: the plugin, its marketplace, and the marketplace's folder (PluginFiles'), each as the command needs it.
type PluginResult ¶ added in v0.7.0
type PluginResult struct {
// Command is the command's own word for itself ("install", "uninstall",
// "marketplace-remove"), and Outcome how it went.
Command string `json:"command"`
Outcome PluginOutcome `json:"outcome"`
// PluginID names the plugin it acted on, <plugin>@<marketplace>, or "".
PluginID string `json:"pluginId"`
// Message says what happened, in the agent's words, and FailureCode why a command
// failed ("not_installed"), or "".
Message string `json:"message"`
FailureCode string `json:"failureCode"`
}
PluginResult is what one of the agent's plugin commands says it did (ParsePluginResult).
func ParsePluginResult ¶ added in v0.7.0
func ParsePluginResult(stdout []byte) (PluginResult, error)
ParsePluginResult reads what one of Claude Code's plugin commands printed on stdout with --json (PluginArgs): its one line of JSON, among blank lines and any line that isn't one. Its exit code says nothing more: a failed command exits 1, and its line says why.
func (PluginResult) OK ¶ added in v0.7.0
func (r PluginResult) OK() bool
OK reports a command that did what it was asked.
type PluginSkill ¶ added in v0.7.0
PluginSkill is a plugin's skill: its plain lowercase name, the description the agent reads to pick it, and its instructions.
type PluginSpec ¶ added in v0.7.0
type PluginSpec struct {
// Name is the plugin's, and Marketplace that of the local marketplace that lists it,
// the folder PluginFiles fills: plain lowercase names.
Name string
Marketplace string
// Version is the plugin's (major.minor.patch), Description what the plugin and its
// marketplace say they are, and Author who makes it and owns the marketplace.
Version string
Description string
Author string
// Skill is the one skill it carries, and Server the MCP server its tools come from.
Skill PluginSkill
Server ConversationSpec
}
PluginSpec is the plugin that brings the app's MCP server and its skill to the user's own sessions of the agent, in a local marketplace of its own.
type PresetKeep ¶ added in v0.4.0
type PresetKeep struct {
Preset fence.Preset `json:"preset"`
Kept bool `json:"kept"`
Why string `json:"why"`
}
PresetKeep is whether an agent keeps one tools preset in the background, and when it doesn't, why, as the builder says it.
func Presets ¶ added in v0.4.0
func Presets(id ID) []PresetKeep
Presets returns whether the agent with id keeps each tools preset, from the narrowest; every one is refused for an agent this build doesn't know.
type ReservedFlagError ¶
type ReservedFlagError struct {
// Flag is the option the argument sets, such as "--model" or "-w", without any value,
// or for a config override, the option and its key, such as "-c model".
Flag string
// Reason completes the sentence "<flag> ...": what to do instead.
Reason string
// Access reports a flag that changes the session's permissions.
Access bool
}
ReservedFlagError is returned for an extra flag the launcher sets itself. Its message says which setting owns the flag.
func (*ReservedFlagError) Error ¶
func (e *ReservedFlagError) Error() string
Error reads like "--model is set by the Model setting".
func (*ReservedFlagError) Is ¶
func (e *ReservedFlagError) Is(target error) bool
Is makes a ReservedFlagError match ErrReservedFlag.
type Settings ¶
type Settings struct {
// Models is each agent's model.
Models map[ID]string
// Effort is the effort level, shared by every agent; an agent that lacks it is
// launched with its own default.
Effort string
// ExtraFlags is each agent's extra arguments typed on one line, quoted as in a shell.
ExtraFlags map[ID]string
}
Settings are the launch settings a prompt or a launch default stores: one effort level for every agent, and each agent's own model and extra flags. A setting that is "" (or an agent with no entry) inherits.
type SignIn ¶ added in v0.4.0
type SignIn struct {
State SignInState `json:"state"`
// Method is how it is signed in, in the agent's own word ("claude.ai", "chatgpt",
// "apiKey"), "" when it doesn't say.
Method string `json:"method"`
// Subscription is the subscription's type ("max", "pro"), "" when it doesn't say.
Subscription string `json:"subscription"`
// ExpiresAt is when the sign-in expires, nil when it doesn't say.
ExpiresAt *time.Time `json:"expiresAt"`
}
SignIn is a profile's sign-in, as its agent's sign-in command says it.
func ParseSignIn ¶ added in v0.4.0
ParseSignIn reads what the agent's SignInArgs printed, on stdout and stderr together (Codex's `login status` writes to stderr alone), and whether the command exited cleanly. An agent this build doesn't know is unknown.
type SignInState ¶ added in v0.4.0
type SignInState string
SignInState is what an agent's sign-in command says of a profile.
const ( // SignedIn is a profile signed in, through the browser on a subscription or else. SignedIn SignInState = "signedIn" // SignedOut is a profile that isn't. SignedOut SignInState = "signedOut" // SignInUnknown is output the parser couldn't read: the command may have changed. SignInUnknown SignInState = "unknown" )
The states.
type ValidationError ¶
type ValidationError struct {
Err error
Fields []FieldError
}
ValidationError lists why something cannot be saved, one FieldError per problem. It matches Err, the error naming what could not be saved, such as "the prompt can't be saved".
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error reads like "<Err>: <each field's message>".
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Unwrap returns Err, so errors.Is matches it.