Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package config loads agent settings from an optional YAML file layered over defaults.

Index

Constants

View Source
const (
	DefaultWebFetchMaxBytes       = 2 << 20
	DefaultWebFetchTimeoutSeconds = 20
	MaxWebFetchTimeoutSeconds     = 120
)

Web fetch defaults and limits.

View Source
const (
	DefaultAskUserMaxQuestions = 3
	MaxAskUserQuestions        = 20
)

DefaultAskUserMaxQuestions is the default ask_user.max_questions, and MaxAskUserQuestions its upper bound.

View Source
const (
	DecisionAllow = "allow"
	DecisionAsk   = "ask"
	DecisionDeny  = "deny"
)

Permissions decisions.

View Source
const (
	DefaultLSPWaitMS                = 3000
	MinLSPWaitMS                    = 100
	MaxLSPWaitMS                    = 30000
	DefaultLSPMaxDiagnostics        = 20
	MaxLSPMaxDiagnostics            = 200
	DefaultLSPStartupTimeoutSeconds = 15
	MaxLSPStartupTimeoutSeconds     = 300
	MaxLSPServers                   = 8
)

LSP defaults and limits.

View Source
const DefaultMaxFormatErrors = 3

DefaultMaxFormatErrors is the default MaxFormatErrors.

View Source
const DefaultMaxImageBytes = 5 << 20

DefaultMaxImageBytes is the default max_image_bytes (5 MiB).

View Source
const DefaultMaxStopContinuations = 5

DefaultMaxStopContinuations is the default hooks.max_stop_continuations.

View Source
const DefaultMaxTruncations = 3

DefaultMaxTruncations is the default MaxTruncations.

View Source
const DefaultSnapshotMaxFileBytes = 2 << 20

DefaultSnapshotMaxFileBytes is the default snapshots.max_file_bytes.

View Source
const DefaultSubagentMaxSteps = 30

DefaultSubagentMaxSteps is the step cap of a delegate child when subagents.max_steps is 0.

View Source
const DefaultToolOutputDir = ".tinyagent/tool-output"

DefaultToolOutputDir is the default tool_output_files.dir.

View Source
const DefaultToolOutputMaxRuns = 20

DefaultToolOutputMaxRuns is the default tool_output_files.max_runs.

View Source
const DefaultWorkerMaxSteps = 60

DefaultWorkerMaxSteps is a worker's step cap when subagents.workers.max_steps is 0.

Variables

View Source
var BuiltinProviders = []string{"openai", "openrouter", "anthropic", "ollama", "codex"}

BuiltinProviders are reserved and can't be used as a providers[].id.

View Source
var DefaultWorkerTools = []string{"read_file", "list_files", "grep", "write_file", "edit_file", "apply_patch", "bash"}

DefaultWorkerTools are a worker's tools when subagents.workers.tools is empty.

View Source
var ErrInvalidProvider = errors.New("invalid provider")

ErrInvalidProvider wraps every providers validation error, so callers can exit 2 for them.

View Source
var OTelProtocols = []string{"http/protobuf", "http/json"}

OTelProtocols are the supported OTLP transports.

View Source
var ProviderAPIs = []string{"chat", "responses", "anthropic"}

ProviderAPIs are the accepted providers[].api values.

View Source
var WorkerToolChoices = []string{"read_file", "list_files", "grep", "write_file", "edit_file", "apply_patch", "bash", "start_process", "read_process", "stop_process"}

WorkerToolChoices are the tool names subagents.workers.tools accepts.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the per-user config file, tinyagent/config.yaml under os.UserConfigDir, whether or not it exists.

func Find

func Find(explicit string) string

Find returns the config file to Load: explicit if set, else the per-user config if it exists, else "" for the defaults. A user config that exists but can't be read is still returned, so Load reports it by name.

func MatchResource added in v0.5.0

func MatchResource(patterns []string, uri string) bool

MatchResource reports whether uri matches one of patterns: equal to an exact pattern, or starting with the text before a trailing "*". URIs are compared literally, without normalization or decoding.

func OTelProtocolError added in v0.6.0

func OTelProtocolError(src, p string) error

OTelProtocolError is the error for an unsupported OTLP protocol from src.

func ProfileNames added in v0.5.0

func ProfileNames(path string) ([]string, error)

ProfileNames returns the names in the config file's profiles: section, sorted lexicographically. It runs the same structural checks applyProfiles does (name charset, duplicates, mapping shape, null and unknown keys), so an invalid section is an error rather than a partial list. An empty path means no config file is in use and yields no names; a missing or unreadable file is an error naming the path.

func ValidEnvironment added in v0.5.0

func ValidEnvironment(name string) bool

ValidEnvironment reports whether name is a known environment.

func ValidInherit added in v0.5.0

func ValidInherit(mode string) bool

ValidInherit reports whether mode is a known command_env.inherit value.

func ValidOTelProtocol added in v0.6.0

func ValidOTelProtocol(p string) bool

ValidOTelProtocol reports whether p is a supported OTLP protocol.

func ValidateResourcePatterns added in v0.5.0

func ValidateResourcePatterns(patterns []string) error

ValidateResourcePatterns rejects empty, duplicate and bare "*" resource patterns, and "*" anywhere but at the end.

Types

type ACP added in v0.5.0

type ACP struct {
	// ClientMCPServers starts the MCP servers an ACP client sends with
	// session/new, exposing all their tools (off by default: they are
	// ignored and named in the session's first message).
	ClientMCPServers bool `yaml:"client_mcp_servers"`
}

ACP configures the --acp editor mode.

type AdditionalDir added in v0.5.0

type AdditionalDir struct {
	// Path is an absolute directory outside --cwd.
	Path string `yaml:"path"`
	// Mode is "read" or "write"; it is required.
	Mode string `yaml:"mode"`
}

AdditionalDir is one additional_dirs entry.

type AgentConfig

type AgentConfig struct {
	ReadOnly bool `yaml:"read_only"`
	// Sandbox confines bash and start_process commands at the OS level:
	// writes only under --cwd, a per-run temp dir and SandboxWritablePaths.
	Sandbox bool `yaml:"sandbox"`
	// SandboxNetwork lets sandboxed commands use the network.
	SandboxNetwork bool `yaml:"sandbox_network"`
	// SandboxWritablePaths are extra absolute directories commands may write.
	SandboxWritablePaths []string `yaml:"sandbox_writable_paths,omitempty"`
	// SandboxAllowedDomains limits sandboxed commands' network to these
	// hosts (exact, "*.domain" or IP, optional ":port"), over HTTP and HTTPS
	// through a filtering proxy. Empty keeps the network denied.
	SandboxAllowedDomains []string `yaml:"sandbox_allowed_domains,omitempty"`
	// Environment selects where bash and start_process commands run:
	// "local" (the default, also "") or "container".
	Environment string `yaml:"environment"`
	// Container configures the "container" environment.
	Container Container `yaml:"container"`
	// CommandEnv is the environment policy for local bash and start_process
	// commands. The zero value inherits tinyagent's whole environment.
	CommandEnv CommandEnv `yaml:"command_env"`
	// FileAccess denies the built-in file tools access to matching paths.
	// The zero value denies nothing.
	FileAccess FileAccess `yaml:"file_access"`
	// RedactSecrets masks known secret values in command, process, MCP,
	// web_fetch and hook output before the model sees it (off by default;
	// --redact-secrets overrides Enabled).
	RedactSecrets RedactSecrets `yaml:"redact_secrets"`
	// AdditionalDirs are directories outside --cwd that the built-in file
	// tools, --sandbox and the container environment may also reach. Empty
	// (the default) keeps everything inside --cwd. --add-dir-read and
	// --add-dir-write replace this list.
	AdditionalDirs []AdditionalDir `yaml:"additional_dirs,omitempty"`
	// Model is the provider/model used when neither -m nor $AGENT_MODEL sets
	// one. "" falls back to the built-in default.
	Model string `yaml:"model"`

	SystemPrompt string  `yaml:"system_prompt"`
	StepLimit    int     `yaml:"step_limit"`
	CostLimit    float64 `yaml:"cost_limit"`
	WallTimeSec  int     `yaml:"wall_time_seconds"`
	// MaxFormatErrors ends the run after this many consecutive steps whose
	// tool calls are all malformed. Must be >= 1; default 3.
	MaxFormatErrors int `yaml:"max_format_errors"`
	// MaxOutputTokens is the per-request output-token budget sent to the
	// provider; 0 (the default) keeps the provider default (8192 for
	// Anthropic). Not to be confused with MaxOutputChars, which caps tool
	// output.
	MaxOutputTokens int `yaml:"max_output_tokens"`
	// MaxTruncations ends the run after this many consecutive responses cut
	// off at the output-token limit. Must be >= 1; default 3.
	MaxTruncations int `yaml:"max_truncations"`

	BashTimeoutSec int `yaml:"bash_timeout_seconds"`
	MaxOutputChars int `yaml:"max_output_chars"`
	// MaxBackgroundProcesses bounds how many start_process processes may run
	// at once.
	MaxBackgroundProcesses int `yaml:"max_background_processes"`

	// Optional price override in USD per million tokens, for models
	// missing from the built-in price table.
	InputPricePerMTok  float64 `yaml:"input_price_per_mtok"`
	OutputPricePerMTok float64 `yaml:"output_price_per_mtok"`

	// ContextWindow, in tokens, overrides the built-in context window table.
	// 0 uses the table.
	ContextWindow int `yaml:"context_window"`

	// FallbackModels is the opt-in fallback chain: provider/model specs
	// tried in order when a request still fails with HTTP 429, 5xx or a
	// network error after the provider's retries. Empty (the default)
	// never switches. --fallback-model replaces it; --no-fallback clears it.
	FallbackModels []string `yaml:"fallback_models,omitempty"`

	// ReasoningEffort is sent to the provider's reasoning control: none,
	// minimal, low, medium, high, xhigh, or max. "" sends nothing, so the
	// model's default applies.
	ReasoningEffort string `yaml:"reasoning_effort"`

	// OpenAIAPI picks the openai provider's transport: auto (the default;
	// the Responses API for api.openai.com, Chat Completions when
	// OPENAI_BASE_URL points elsewhere), responses, or chat. Other providers
	// ignore it.
	OpenAIAPI string `yaml:"openai_api"`

	MCPServers []MCPServer `yaml:"mcp_servers,omitempty"`

	// Providers are named model providers selectable as "<id>/<model>".
	// They come only from the user config or -c.
	Providers []Provider `yaml:"providers,omitempty"`

	// Hooks are trusted local executables run around matching tool calls.
	Hooks Hooks `yaml:"hooks,omitempty"`

	// Permissions is the opt-in tool permission policy: allow/ask/deny rules
	// matched on the tool name and its main argument, applied before hooks.
	// The zero value enforces nothing.
	Permissions Permissions `yaml:"permissions"`

	// CommandTools are user-defined tools that run a fixed argv filled in
	// with schema-checked arguments, without a shell. They come only from
	// the user config or -c.
	CommandTools []CommandTool `yaml:"command_tools,omitempty"`

	// Plan configures the opt-in update_plan tool (off by default).
	Plan Plan `yaml:"plan,omitempty"`
	// Images configures the opt-in view_image tool and MCP image
	// pass-through (off by default).
	Images Images `yaml:"images,omitempty"`
	// MaxImageBytes caps one image's raw size. Must be >= 1; default 5 MiB.
	MaxImageBytes int `yaml:"max_image_bytes"`
	// ApplyPatch offers the opt-in apply_patch tool (off by default;
	// --apply-patch overrides it).
	ApplyPatch bool `yaml:"apply_patch"`
	// ScopedAgentsMD also delivers AGENTS.md files in directories below
	// --cwd with the results of file tools touching paths there (off by
	// default; --scoped-agents-md overrides it).
	ScopedAgentsMD bool `yaml:"scoped_agents_md"`
	// Subagents configures the opt-in delegate tool, which runs a
	// read-only child agent (off by default; --subagents overrides
	// Enabled).
	Subagents Subagents `yaml:"subagents"`
	// WebFetch configures the opt-in web_fetch tool (off by default;
	// --web-fetch overrides Enabled).
	WebFetch WebFetch `yaml:"web_fetch"`
	// AskUser configures the opt-in ask_user tool, which ends a run with
	// one question for the user (off by default; --ask-user overrides
	// Enabled).
	AskUser AskUser `yaml:"ask_user"`
	// LSP configures opt-in language servers: diagnostics appended to edit
	// results and the read-only lsp tool (off by default; --lsp overrides
	// Enabled). It comes only from the user config or -c.
	LSP LSP `yaml:"lsp"`
	// Skills turns on Agent Skills discovery from .agents/skills (off by
	// default; --skills / --no-skills override it).
	Skills bool `yaml:"skills"`
	// LogDB is the opt-in SQLite event log.
	LogDB LogDB `yaml:"log_db"`
	// OTel is the opt-in OpenTelemetry (OTLP/HTTP) trace export.
	OTel OTel `yaml:"otel"`
	// ToolOutputFiles saves the full text of over-limit tool results to
	// per-run files the model can page (off by default;
	// --tool-output-files overrides Enabled).
	ToolOutputFiles ToolOutputFiles `yaml:"tool_output_files"`
	// Snapshots configures opt-in workspace snapshots for --rewind (off by
	// default; --snapshots overrides enabled). It may be written as a bare
	// bool (snapshots: true) or as a mapping.
	Snapshots Snapshots `yaml:"snapshots"`
	// ACP configures the --acp editor mode.
	ACP ACP `yaml:"acp"`
}

func Default

func Default() AgentConfig

func Load

func Load(path string) (AgentConfig, error)

Load returns the defaults overlaid with the YAML file at path. An empty path returns the defaults. Unknown keys are an error, so a typo can't silently drop a setting.

func LoadProfile added in v0.5.0

func LoadProfile(path, profile string) (AgentConfig, error)

LoadProfile is Load with the named profile from the file's profiles: section merged over the base settings before decoding and validation. An empty profile applies none; the profiles: section is still validated. With a profile selected, every invalid-config error is an *InvalidError and names the profile.

type AskUser added in v0.5.0

type AskUser struct {
	Enabled bool `yaml:"enabled"`
	// MaxQuestions caps the questions one run may ask, counted across
	// its whole resume chain: 1 to MaxAskUserQuestions.
	MaxQuestions int `yaml:"max_questions"`
}

AskUser configures the ask_user tool.

type CommandEnv added in v0.5.0

type CommandEnv struct {
	Inherit        string            `yaml:"inherit"` // all (default, also ""), core or none
	ExcludeSecrets bool              `yaml:"exclude_secrets"`
	Exclude        []string          `yaml:"exclude,omitempty"` // names or * / ? globs
	Pass           []string          `yaml:"pass,omitempty"`    // names or globs
	Set            map[string]string `yaml:"set,omitempty"`
}

CommandEnv decides which environment variables bash and start_process commands receive. It is applied in order: the Inherit base, then ExcludeSecrets, Exclude, Pass (re-adding from tinyagent's environment) and Set.

func (CommandEnv) Configured added in v0.5.0

func (c CommandEnv) Configured() bool

Configured reports whether c changes the inherited environment at all.

func (CommandEnv) Validate added in v0.5.0

func (c CommandEnv) Validate() error

Validate checks the policy's names and globs. The error names the key.

type CommandTool added in v0.5.0

type CommandTool struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	// Parameters is the JSON Schema of the arguments, in the
	// --output-schema subset; nil means no arguments.
	Parameters map[string]any `yaml:"parameters,omitempty"`
	// Argv is the command; an element that is exactly {{name}} is replaced
	// by the argument name.
	Argv []string `yaml:"argv"`
	// TimeoutSec is the per-call timeout; 0 means bash_timeout_seconds.
	TimeoutSec int `yaml:"timeout_seconds,omitempty"`
	// Dir is the working directory, relative to --cwd and inside it; ""
	// means --cwd.
	Dir string `yaml:"dir,omitempty"`
}

CommandTool is one command_tools entry. tools.NewCommandTools checks it.

type Container added in v0.5.0

type Container struct {
	Runtime string   `yaml:"runtime"` // docker (default) or podman
	Image   string   `yaml:"image"`
	RunArgs []string `yaml:"run_args,omitempty"` // extra `run` arguments
}

Container is the image and runtime used by the "container" environment.

type FileAccess added in v0.5.0

type FileAccess struct {
	DenyRead  []string `yaml:"deny_read,omitempty"`
	DenyWrite []string `yaml:"deny_write,omitempty"`
}

FileAccess lists gitignore-style patterns, relative to --cwd, that the built-in file tools refuse. DenyRead paths are also write-denied. It does not apply to bash, start_process, hooks or MCP servers.

func (FileAccess) Configured added in v0.5.0

func (f FileAccess) Configured() bool

Configured reports whether any rule is set.

func (FileAccess) Validate added in v0.5.0

func (f FileAccess) Validate() error

Validate rejects empty patterns, ! negation (reserved for later) and bad glob syntax.

type Hook added in v0.5.0

type Hook struct {
	Match   string   `yaml:"match,omitempty"` // whole-name Go regexp; "" matches every tool
	Command string   `yaml:"command"`
	Args    []string `yaml:"args,omitempty"`
	Env     []string `yaml:"env,omitempty"`
	// TimeoutSec is nil when unset (30 seconds); 0 is rejected.
	TimeoutSec *int   `yaml:"timeout_seconds,omitempty"`
	OnError    string `yaml:"on_error,omitempty"` // pre_tool only: deny (default) or allow
}

Hook runs one local command for tool calls whose name matches Match.

type Hooks added in v0.5.0

type Hooks struct {
	PreTool  []Hook `yaml:"pre_tool,omitempty"`
	PostTool []Hook `yaml:"post_tool,omitempty"`
	// Stop hooks run when a run is about to end Submitted or Completed and
	// can send the model back to work. Match and OnError are rejected.
	Stop []Hook `yaml:"stop,omitempty"`
	// MaxStopContinuations caps how many times stop hooks may send the
	// model back to work in one run; nil means DefaultMaxStopContinuations.
	MaxStopContinuations *int `yaml:"max_stop_continuations,omitempty"`
}

Hooks lists the commands run before and after matching tool calls, and the stop hooks that verify a run before it ends successfully.

type Images added in v0.5.0

type Images struct {
	Enabled bool `yaml:"enabled"`
}

Images turns on sending images to vision-capable models.

type InvalidError added in v0.5.0

type InvalidError struct{ Err error }

InvalidError is a config error that should exit with usage status 2.

func (*InvalidError) Error added in v0.5.0

func (e *InvalidError) Error() string

func (*InvalidError) Unwrap added in v0.5.0

func (e *InvalidError) Unwrap() error

type LSP added in v0.5.0

type LSP struct {
	Enabled bool `yaml:"enabled"`
	// DiagnosticsAfterEdit appends new diagnostics to write_file, edit_file
	// and apply_patch results (default true). false keeps only the lsp tool.
	DiagnosticsAfterEdit bool `yaml:"diagnostics_after_edit"`
	// DiagnosticsWaitMS is the longest wait for diagnostics after an edit
	// (MinLSPWaitMS..MaxLSPWaitMS; default 3000).
	DiagnosticsWaitMS int `yaml:"diagnostics_wait_ms"`
	// MaxDiagnostics caps the diagnostics listed per file (1..200;
	// default 20).
	MaxDiagnostics int `yaml:"max_diagnostics"`
	// Severity is the lowest severity reported: error (default) or
	// warning (errors and warnings).
	Severity string      `yaml:"severity"`
	Servers  []LSPServer `yaml:"servers,omitempty"`
}

LSP configures opt-in language servers. Servers are trusted executables configured only in the user config or -c, launched directly (no shell) with a minimal environment, like MCP servers.

func DefaultLSP added in v0.5.0

func DefaultLSP() LSP

DefaultLSP is the lsp section's defaults: off, diagnostics after edits when on, 3000 ms wait, 20 diagnostics, errors only.

func (LSP) CheckEnabled added in v0.5.0

func (l LSP) CheckEnabled(file string) error

CheckEnabled reports an error when LSP is on without servers. file names the config file in the message ("" when there is none).

func (LSP) CheckEnv added in v0.5.0

func (l LSP) CheckEnv(file string) error

CheckEnv reports a forwarded environment variable that is not set.

func (LSP) Validate added in v0.5.0

func (l LSP) Validate() error

Validate checks the limits and every server entry. Whether servers are configured at all is checked once the --lsp flag has been applied (CheckEnabled), and forwarded variables at startup (CheckEnv).

type LSPServer added in v0.5.0

type LSPServer struct {
	Name       string   `yaml:"name"`
	Command    string   `yaml:"command"`
	Args       []string `yaml:"args,omitempty"`
	Extensions []string `yaml:"extensions"`
	// Env names host environment variables to forward; each must be set.
	Env []string `yaml:"env,omitempty"`
	// InitializationOptions is passed to the server's initialize request.
	InitializationOptions map[string]any `yaml:"initialization_options,omitempty"`
	// StartupTimeoutSeconds bounds start and initialize (1..300; 0 means
	// DefaultLSPStartupTimeoutSeconds).
	StartupTimeoutSeconds int `yaml:"startup_timeout_seconds"`
}

LSPServer is one language server, used for files with its extensions.

type LogDB added in v0.5.0

type LogDB struct {
	Enabled bool `yaml:"enabled"`
	// Path is the database file; "" means .tinyagent/tinyagent.db under
	// --cwd. A relative path is resolved against --cwd; "~/" is expanded.
	Path string `yaml:"path"`
	// Level is "metadata" (default; no prompt, message, argument or output
	// bodies) or "full".
	Level string `yaml:"level"`
	// MaxDays and MaxRuns prune older runs at run start; 0 keeps all.
	MaxDays int `yaml:"max_days"`
	MaxRuns int `yaml:"max_runs"`
	// MaxPayloadBytes caps each stored event payload; 0 means 65536.
	MaxPayloadBytes int `yaml:"max_payload_bytes"`
}

LogDB configures the opt-in SQLite event log. It is off unless Enabled (or --log-db) is set.

type MCPServer added in v0.4.0

type MCPServer struct {
	Alias   string   `yaml:"alias"`
	Command string   `yaml:"command"`
	Args    []string `yaml:"args,omitempty"`
	Tools   []string `yaml:"tools"`
	// Resources allowlists the resource URIs the model may list and read:
	// each pattern is an exact URI or a literal prefix ending in "*".
	Resources           []string `yaml:"resources,omitempty"`
	Env                 []string `yaml:"env,omitempty"`
	DiscoveryTimeoutSec int      `yaml:"discovery_timeout_seconds"`
	CallTimeoutSec      int      `yaml:"call_timeout_seconds"`
	// SetEnv holds NAME=value pairs set for the server, and AllTools
	// exposes every tool it lists. Only servers an ACP client supplies
	// use them; a config file can't set either.
	SetEnv   []string `yaml:"-"`
	AllTools bool     `yaml:"-"`
}

MCPServer grants access to selected tools and resources from one local stdio server. At least one of Tools and Resources must be nonempty.

type OTel added in v0.6.0

type OTel struct {
	Enabled bool `yaml:"enabled"`
	// Endpoint is the OTLP/HTTP base URL; /v1/traces is appended.
	Endpoint string `yaml:"endpoint"`
	// Protocol is http/protobuf or http/json.
	Protocol string `yaml:"protocol"`
	// HeadersEnv names environment variables whose values are k=v,k2=v2
	// header lists. Header values never come from the config itself.
	HeadersEnv []string `yaml:"headers_env"`
	// Timeout bounds each export, retries included, and the final flush,
	// as a Go duration such as "10s".
	Timeout string `yaml:"timeout"`
	// ServiceName is the resource service.name.
	ServiceName string `yaml:"service_name"`
	// Content adds redacted task, assistant, argument and output text.
	Content bool `yaml:"content"`
	// MaxAttributeBytes caps each content attribute; 0 means 4096.
	MaxAttributeBytes int `yaml:"max_attribute_bytes"`
}

OTel configures the opt-in OpenTelemetry trace export. It is off unless Enabled (or --otel) is set; OTEL_* variables alone never turn it on. Empty fields fall back to the standard OTEL_EXPORTER_OTLP_* variables.

func (OTel) Validate added in v0.6.0

func (o OTel) Validate() error

Validate checks the settings that don't depend on the environment.

type PermissionRule added in v0.8.0

type PermissionRule struct {
	// Tool is a "|"-separated list of tool-name globs ("*" wildcard). It is
	// required.
	Tool string `yaml:"tool"`
	// Command matches the shell command text (bash, start_process, and
	// command tools' resolved argv). At most one of command, path and host
	// may be set.
	Command string `yaml:"command,omitempty"`
	// Path matches a path relative to --cwd in the file_access syntax (for
	// apply_patch, when any path matches).
	Path string `yaml:"path,omitempty"`
	// Host matches a web_fetch URL host in the sandbox_allowed_domains
	// syntax.
	Host string `yaml:"host,omitempty"`
	// Decision is allow, ask or deny; it is required.
	Decision string `yaml:"decision"`
	// Message is shown to the model on deny.
	Message string `yaml:"message,omitempty"`
}

PermissionRule is one permissions.rules entry.

type Permissions added in v0.8.0

type Permissions struct {
	// Default is the decision when no rule matches: allow (default), ask or
	// deny.
	Default string `yaml:"default"`
	// NonInteractive is what an ask becomes when nobody can answer (no
	// terminal, --json, or an ACP client that does not answer): deny
	// (default) or allow.
	NonInteractive string `yaml:"non_interactive"`
	// Rules are evaluated in order; a deny or ask matches when any of its
	// patterns match, and an allow matches only when every compound-command
	// segment is covered. A profile's rules replace the base list.
	Rules []PermissionRule `yaml:"rules,omitempty"`
}

Permissions is the opt-in tool permission policy. A rule matches a tool call by tool name and, optionally, one primary argument (the command text, a path, or a URL host). Decisions are applied deny > ask > allow > default.

func (Permissions) Configured added in v0.8.0

func (p Permissions) Configured() bool

Configured reports whether any permission rule or setting is present.

func (Permissions) Validate added in v0.8.0

func (p Permissions) Validate() error

Validate checks the policy's settings and rules. The error names the offending key and rule index.

type Plan added in v0.5.0

type Plan struct {
	Enabled bool `yaml:"enabled"`
}

Plan configures the persistent plan tool.

type Provider added in v0.5.0

type Provider struct {
	ID      string `yaml:"id"`
	API     string `yaml:"api"` // chat, responses or anthropic
	BaseURL string `yaml:"base_url"`
	// APIKeyEnv names the variable holding the API key; "" sends no key.
	APIKeyEnv string `yaml:"api_key_env,omitempty"`
	// Headers are static, non-secret request headers.
	Headers map[string]string `yaml:"headers,omitempty"`
	// EnvHeaders maps a header name to the variable holding its value.
	EnvHeaders map[string]string `yaml:"env_headers,omitempty"`
	// Models holds per-model metadata, matched by exact model name.
	Models map[string]ProviderModel `yaml:"models,omitempty"`
}

Provider is one config-defined model provider. Secrets come only from the environment variables it names, never from the file itself.

type ProviderModel added in v0.5.0

type ProviderModel struct {
	InputPricePerMTok  float64 `yaml:"input_price_per_mtok"`
	OutputPricePerMTok float64 `yaml:"output_price_per_mtok"`
	// CacheReadMultiplier is the cache-read price as a multiple of the
	// input price, in (0, 1]; 0 means the default 0.1.
	CacheReadMultiplier float64 `yaml:"cache_read_multiplier"`
	ContextWindow       int     `yaml:"context_window"`
}

ProviderModel is price and context-window metadata for one model of a configured provider. Zero values mean unknown.

type RedactSecrets added in v0.5.0

type RedactSecrets struct {
	Enabled bool `yaml:"enabled"`
	// Env names more variables (names or * / ? globs) whose values are
	// secrets, beyond the secret-named ones.
	Env []string `yaml:"env,omitempty"`
	// Allow names variables (names or globs) not to treat as secrets.
	Allow []string `yaml:"allow,omitempty"`
	// Patterns also masks token-shaped strings (sk-..., ghp_..., Bearer ...).
	Patterns bool `yaml:"patterns"`
}

RedactSecrets configures masking of known secret values in tool output.

func (RedactSecrets) Validate added in v0.5.0

func (r RedactSecrets) Validate() error

Validate checks env and allow. The error names the key.

type Snapshots added in v0.5.0

type Snapshots struct {
	Enabled bool `yaml:"enabled"`
	// MaxFileBytes is the largest file captured; larger files are skipped
	// and reported. Must be >= 1; default 2 MiB.
	MaxFileBytes int64 `yaml:"max_file_bytes"`
}

Snapshots configures workspace snapshots.

func (*Snapshots) UnmarshalYAML added in v0.5.0

func (s *Snapshots) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML accepts "snapshots: true" as well as the mapping form, and rejects unknown keys in the mapping.

type Subagents added in v0.5.0

type Subagents struct {
	Enabled bool `yaml:"enabled"`
	// Model is the provider/model children use; "" means the parent's
	// model.
	Model string `yaml:"model"`
	// MaxSteps caps each child's model calls; 0 means
	// DefaultSubagentMaxSteps.
	MaxSteps int `yaml:"max_steps"`
	// Workers configures the opt-in worker tool (--workers), whose
	// children may edit files and run commands in their own Git worktree.
	// nil when the config has no subagents.workers section.
	Workers *Workers `yaml:"workers"`
}

Subagents configures the opt-in delegate tool.

type ToolOutputFiles added in v0.5.0

type ToolOutputFiles struct {
	Enabled bool `yaml:"enabled"`
	// Dir is relative to --cwd and must stay inside it; "" means
	// DefaultToolOutputDir.
	Dir string `yaml:"dir"`
	// MaxRuns keeps this many earlier run directories at run start; 0
	// keeps all.
	MaxRuns int `yaml:"max_runs"`
}

ToolOutputFiles configures saving over-limit tool output.

type WebFetch added in v0.5.0

type WebFetch struct {
	Enabled bool `yaml:"enabled"`
	// AllowedDomains lists the hosts web_fetch may read, in the
	// sandbox_allowed_domains syntax. Required when Enabled.
	AllowedDomains []string `yaml:"allowed_domains,omitempty"`
	// MaxBytes caps the body read per fetch. Must be >= 1; default 2 MiB.
	MaxBytes int `yaml:"max_bytes"`
	// TimeoutSeconds caps each fetch, redirects included (1..120;
	// default 20).
	TimeoutSeconds int `yaml:"timeout_seconds"`
}

WebFetch configures the opt-in web_fetch tool, which reads allowlisted URLs in tinyagent's own process, separately from command network access.

func (WebFetch) Validate added in v0.5.0

func (w WebFetch) Validate() error

Validate checks the limits and allowlist syntax. An empty allowlist with Enabled is checked after flags apply (see the CLI).

type Workers added in v0.8.0

type Workers struct {
	Enabled bool `yaml:"enabled"`
	// Model is the provider/model workers use; "" means the parent's.
	Model string `yaml:"model"`
	// MaxSteps caps each worker's model calls; 0 means
	// DefaultWorkerMaxSteps.
	MaxSteps int `yaml:"max_steps"`
	// MaxConcurrent is the cap on workers running at once (1..4; 0 means
	// 1). This version runs worker calls one at a time.
	MaxConcurrent int `yaml:"max_concurrent"`
	// Tools are the tools a worker may use, intersected with the parent's;
	// empty means DefaultWorkerTools.
	Tools []string `yaml:"tools"`
}

Workers configures the opt-in worker and apply_worker tools.

Jump to

Keyboard shortcuts

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