agent

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	FieldModel      = "model"
	FieldModels     = "models"
	FieldEffort     = "effort"
	FieldExtraFlags = "extraFlags"
)

Fields a FieldError from CheckOverrides and CheckSettings names, matching the editors' JSON names.

View Source
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.

View Source
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

View Source
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`)
)
View Source
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")
)
View Source
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.

View Source
var ErrInvalidAccess = errors.New("unknown access")

ErrInvalidAccess is returned for an access kind this build does not know.

View Source
var ErrInvalidPermissionMode = errors.New("unknown permission mode")

ErrInvalidPermissionMode is returned for a permission mode the agent does not accept.

View Source
var ErrInvalidSchema = errors.New("invalid report schema")

ErrInvalidSchema is returned for a report's schema the strict form can't be made of.

View Source
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.

View Source
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.

View Source
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

func Args(id ID, o Options) ([]string, error)

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

func CheckAccess(id ID, args []string) error

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

func CheckExtra(id ID, args []string) error

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

func CheckFenced(id ID, args []string) error

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

func CloneArgs(m map[ID][]string) map[ID][]string

CloneArgs returns a deep copy of each agent's extra arguments with the empty lists left out; never nil.

func CloneModels

func CloneModels(m map[ID]string) map[ID]string

CloneModels returns each agent's model with the blank ones left out; never nil.

func EffortLevels

func EffortLevels(id ID) []string

EffortLevels returns the effort levels the agent with id accepts, lowest first, or nil for an agent this build does not know.

func EqualArgs

func EqualArgs(a, b map[ID][]string) bool

EqualArgs reports whether two agents' extra arguments are the same, an empty list and no entry being the same.

func EqualModels

func EqualModels(a, b map[ID]string) bool

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

func FenceFiles(id ID, a Access, built fence.Fence, program string) ([]fence.File, error)

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

func FenceFloor(id ID) string

FenceFloor returns the oldest version of the agent whose flags every tools preset it keeps uses, or "" for an agent that keeps none.

func FieldFor

func FieldFor(field string, id ID) string

FieldFor names one agent's entry of a per-agent field, as in "models.codex".

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

func HeadlessEnv(id ID, env []string) []string

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

func HeadlessFiles(id ID, schema string) ([]fence.File, error)

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

func Join(args []string) string

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

func JoinArgs(m map[ID][]string) map[ID]string

JoinArgs writes each agent's extra arguments on one line, as the editors show them; never nil.

func KeepsPreset added in v0.4.0

func KeepsPreset(id ID, p fence.Preset) (bool, string)

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 Known

func Known(id ID) bool

Known reports whether id names an agent; Inherit names none.

func ParseVersion added in v0.4.0

func ParseVersion(out []byte) string

ParseVersion returns the version an agent's VersionArgs printed, "" when there is none.

func PromptLast

func PromptLast(id ID) bool

PromptLast reports whether the agent's prompt follows its flags, after "--", rather than coming first. An unknown agent reports false.

func Split

func Split(line string) ([]string, error)

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

func StrictSchema(schema string) (string, error)

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

func ValidPermissionMode(id ID, mode string) bool

ValidPermissionMode reports whether mode is one of the agent's permission modes.

func ValidSessionID

func ValidSessionID(id string) bool

ValidSessionID reports whether id can be passed as a session ID: a UUID (see sessionIDPattern).

func ValidateEffort

func ValidateEffort(id ID, effort string) error

ValidateEffort accepts "" (the agent's default) or one of the agent's EffortLevels.

func ValidateEffortAny

func ValidateEffortAny(effort string) error

ValidateEffortAny accepts "" or a level some agent accepts, for an effort shared by every agent, as prompts and launch defaults store it.

func ValidateModel

func ValidateModel(model string) error

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

func FenceAccess(preset fence.Preset, base Access) Access

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

func (a Access) InRun(dir string) Access

InRun returns the access with its fence's settings in the run's folder dir. Any other access is returned as it is.

func (Access) TakenOver added in v0.4.0

func (a Access) TakenOver() Access

TakenOver returns the access of a fenced run's conversation resumed in the user's terminal: the same fence, asking rather than refusing (Fence.TakenOver). Any other access is returned as it is.

func (Access) Worked added in v0.4.0

func (a Access) Worked(p fence.Policy, hook string) Access

Worked returns the access with the fence worked out for its run: its policy, and the fence hook's program, "" for none (a run taken over runs no hook). 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.

func All

func All() []Agent

All returns every agent, the default first. Each call returns fresh copies.

func Default

func Default() Agent

Default returns the agent used when nothing names one.

func Lookup

func Lookup(id ID) (Agent, error)

Lookup returns the agent with id, or the default agent for Inherit.

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

type Checked struct {
	Models map[ID]string
	Args   map[ID][]string
}

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 Choice

type Choice struct {
	Value string `json:"value"`
	Label string `json:"label"`
}

Choice is one value an agent setting can take, with what the UI calls it.

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

type FencedRun struct {
	Fence fence.Fence
	Files []fence.File
	Note  string
}

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

func PrepareFence(id ID, a Access, s fence.Spec, program string) (FencedRun, error)

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.

func (FencedRun) Write added in v0.4.0

func (r FencedRun) Write(dir string) error

Write writes the run's files into its folder (fence.WriteRun).

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 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

func HeadlessOf(id ID) (Headless, error)

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.

const (
	// Inherit is no choice of agent: a launch default or a launch that leaves the choice
	// to the next layer.
	Inherit ID = ""

	// Claude is Claude Code, the default agent.
	Claude ID = "claude"

	// Codex is OpenAI Codex.
	Codex ID = "codex"
)

The coding agents, and the empty choice.

func IDs

func IDs() []ID

IDs returns every agent's ID, the default first.

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 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

func ParseSignIn(id ID, out []byte, exitOK bool) SignIn

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.

Jump to

Keyboard shortcuts

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