Documentation
¶
Overview ¶
Package config loads and validates ~/.config/smif/config.toml (RFC 7.6).
Decoding is strict: unknown keys are rejected. Validation enforces every rule the daemon relies on for safety (R-ISO-3), including the catch-all rule at the end of each agent's rule list.
Index ¶
- Constants
- Variables
- func AddRemote(file, host string) (bool, error)
- func BuiltinProfiles() map[string]Profile
- func ContextWarnTokens(v string) (int64, error)
- func IntentMatches(glob, intent string) bool
- func PriorityLevel(p string) int
- func RemoveRemote(file, host string) (bool, error)
- func ValidHarnessName(s string) bool
- func ValidIntent(s string) bool
- func ValidRemote(host string) bool
- func WatchdogEvery(v string) (time.Duration, error)
- type Agent
- type Config
- func (c *Config) Accepts(to *Agent, from string) bool
- func (c *Config) Agent(id string) *Agent
- func (c *Config) AgentForPath(dir string) *Agent
- func (c *Config) AgentIDs() []string
- func (c *Config) EffectiveProfile(agentID, name string) (Profile, error)
- func (c *Config) HarnessCommand(name string) string
- func (c *Config) IsTestCommand(command string) bool
- func (c *Config) ListedProcesses() map[string]string
- func (c *Config) Validate() error
- type Daemon
- type Defaults
- type Duration
- type Harness
- type Match
- type Profile
- type Rule
Constants ¶
const (
Human = "human"
)
Reserved principals that are not agents.
Variables ¶
var ( Kinds = []string{"tell", "ask", "event", "reply"} Priorities = []string{"low", "normal", "high", "urgent"} Handlers = []string{"command", "worker", "escalate", "digest", "drop"} PermissionModes = []string{"default", "acceptEdits", "plan", "bypassPermissions"} WriteScopes = []string{"none", "worktree", "direct"} Efforts = []string{"low", "medium", "high", "xhigh", "max"} )
Kinds, priorities, handlers and modes accepted by the schema.
Functions ¶
func AddRemote ¶ added in v0.2.0
AddRemote puts host in daemon.remotes in the config file and keeps the rest of the file as it is, comments included. It reports false when the host is already there. The edit must parse back to the expected list, or the file stays untouched.
func BuiltinProfiles ¶
BuiltinProfiles returns triage, fix, answer and release (RFC 6.2).
func ContextWarnTokens ¶ added in v0.2.0
ContextWarnTokens reads daemon.context_warn: a positive token count with an optional k or m, or "off" (0).
func IntentMatches ¶
IntentMatches reports whether a dotted intent matches a glob.
func PriorityLevel ¶
PriorityLevel converts a priority name to 0..3 (-1 if unknown).
func RemoveRemote ¶ added in v0.3.0
RemoveRemote takes host out of daemon.remotes. It reports false when the host was not there.
func ValidHarnessName ¶ added in v0.2.0
ValidHarnessName reports whether s can name a harness.
func ValidRemote ¶ added in v0.2.0
ValidRemote says whether host can go in daemon.remotes.
Types ¶
type Agent ¶
type Agent struct {
Repo string `toml:"repo"`
BaseRef string `toml:"base_ref"`
AcceptFrom []string `toml:"accept_from"`
BudgetUSD float64 `toml:"budget_usd"`
BudgetTokens int64 `toml:"budget_tokens"`
OnBudget string `toml:"on_budget"` // hold | escalate
DirectConflict string `toml:"direct_conflict"` // hold | worktree
AllowBypass bool `toml:"allow_bypass"`
PR bool `toml:"pr"`
MaxHops int `toml:"max_hops"`
MaxAttempts int `toml:"max_attempts"`
Rules []*Rule `toml:"rules"`
// ProfileOverrides lets an agent change fields of a named profile.
ProfileOverrides map[string]map[string]any `toml:"profile_overrides"`
ID string `toml:"-"`
}
Agent is one project role.
type Config ¶
type Config struct {
Daemon Daemon `toml:"daemon"`
Defaults Defaults `toml:"defaults"`
Profiles map[string]Profile `toml:"profiles"`
Agents map[string]*Agent `toml:"agents"`
// Prompts are the human's saved prompts (ADR-0015): name → one line of
// text, sent to a session with `p` in the UI or as @name.
Prompts map[string]string `toml:"prompts"`
// Harnesses adds coding agents with no code (ADR-0021): their sessions
// show at the Listed level, and `n` can start them.
Harnesses map[string]Harness `toml:"harnesses"`
// Path is where the config was loaded from (not part of the file).
Path string `toml:"-"`
// Warnings are non-fatal findings from Validate.
Warnings []string `toml:"-"`
// contains filtered or unexported fields
}
Config is the whole file.
func (*Config) Accepts ¶
Accepts reports whether the agent accepts traffic from sender (R-SEC-2). The default is every configured agent plus the human.
func (*Config) AgentForPath ¶
AgentForPath returns the agent whose repo contains dir (longest match). Symlinks are resolved on both sides, so a symlinked checkout matches.
func (*Config) EffectiveProfile ¶
EffectiveProfile returns profile name for agent id with overrides applied.
func (*Config) HarnessCommand ¶ added in v0.2.0
HarnessCommand is the program that starts a harness, from the config or the built-in table ("" = none).
func (*Config) IsTestCommand ¶ added in v0.2.0
IsTestCommand reports a shell command that runs tests: a built-in pattern or one of daemon.test_commands.
func (*Config) ListedProcesses ¶ added in v0.2.0
ListedProcesses maps the configured process names to their harness.
type Daemon ¶
type Daemon struct {
MaxWorkers int `toml:"max_workers"`
CommandPool int `toml:"command_pool"`
DefaultTTL Duration `toml:"default_ttl"`
PresenceTTL Duration `toml:"presence_ttl"`
Notify string `toml:"notify"` // "os", "none" or "log:<path>"
// SessionNotify says which session changes raise a notification
// (ADR-0014): "waiting,answered" (default), "waiting", "answered" or
// "none".
SessionNotify string `toml:"session_notify"`
// NotifyURL gets a POST for each notification (ADR-0021): https, or
// http to localhost. Empty is off. It can hold a topic's secret, so
// no log, error or doctor line names it.
NotifyURL string `toml:"notify_url"`
// Remotes are ssh hosts that run smif too (ADR-0023): their sessions show
// here, read only.
Remotes []string `toml:"remotes"`
// KeepAwake stops idle sleep on macOS while a session works.
KeepAwake bool `toml:"keep_awake"`
// Watchdogs (ADR-0015), each a duration or "off": remind again while a
// session waits in its tab (every RemindWaiting, at most 3 times), and
// tell once when a working session writes nothing for AlertSilent or
// works longer than AlertLongTurn.
RemindWaiting string `toml:"remind_waiting"`
AlertSilent string `toml:"alert_silent"`
AlertLongTurn string `toml:"alert_long_turn"`
// TestCommands adds regexes to the built-in test command patterns of
// the session facts (ADR-0021). ContextWarn is the context size over
// which a session's row shows it: "200k", "1m", a count, or "off".
TestCommands []string `toml:"test_commands"`
ContextWarn string `toml:"context_warn"`
// Terminal types the human's prompts into idle sessions (ADR-0012):
// "auto" (Terminal.app on macOS), "none" (off) or "log:<path>" (tests).
Terminal string `toml:"terminal"`
RateLimitPerMinute int `toml:"rate_limit_per_minute"`
MaxThreadMessages int `toml:"max_thread_messages"`
PingPongLimit int `toml:"ping_pong_limit"`
PingPongWindow Duration `toml:"ping_pong_window"`
AgingStep Duration `toml:"aging_step"`
RetryBackoff []Duration `toml:"retry_backoff"`
OverloadExtra int `toml:"overload_extra_attempts"`
MessageRetention Duration `toml:"message_retention"`
TranscriptRetain Duration `toml:"transcript_retention"`
BlobGrace Duration `toml:"blob_grace"`
BranchRetention Duration `toml:"branch_retention"`
AuditRetention Duration `toml:"audit_retention"`
LogRetention Duration `toml:"log_retention"`
}
Daemon holds process-wide settings.
type Defaults ¶
type Defaults struct {
ClaudeCommand string `toml:"claude_command"`
MaxHops int `toml:"max_hops"`
MaxAttempts int `toml:"max_attempts"`
CommandTimeout Duration `toml:"command_timeout"`
MaxOutputBytes int64 `toml:"max_output_bytes"`
RotateAtTokens int64 `toml:"rotate_at_tokens"`
RotateAfterRuns int `toml:"rotate_after_runs"`
}
Defaults apply to every agent unless overridden.
type Duration ¶
Duration is a time.Duration decoded from strings such as "6h" or "30m". A trailing "d" (days) is also accepted.
func (Duration) MarshalText ¶
func (*Duration) UnmarshalText ¶
type Harness ¶ added in v0.2.0
Harness is one [harnesses.<name>] table. Process lists the process names of the agent, Command the program that starts it. A name that a built-in provider owns may set Command only.
type Match ¶
type Match struct {
From any `toml:"from"`
Kind any `toml:"kind"`
Intent string `toml:"intent"`
PriorityAtLeast string `toml:"priority_at_least"`
// contains filtered or unexported fields
}
Match is the rule predicate. From and Kind accept a string or a list.
func (*Match) IsCatchAll ¶
IsCatchAll reports whether the match has no predicate at all.
type Profile ¶
type Profile struct {
Model string `toml:"model"`
Effort string `toml:"effort"`
PermissionMode string `toml:"permission_mode"`
AllowedTools []string `toml:"allowed_tools"`
DisallowedTools []string `toml:"disallowed_tools"`
WriteScope string `toml:"write_scope"`
MaxTurns int `toml:"max_turns"`
TimeoutS int `toml:"timeout_s"`
Policy string `toml:"policy"`
OnwardMCP bool `toml:"onward_mcp"`
// Hooks lets the user's and the repo's Claude Code hooks run inside the
// worker. Off by default: hooks have side effects outside the worker
// (memory capture, checkpoints, nested claude calls).
Hooks bool `toml:"hooks"`
Minimal bool `toml:"minimal"`
MaxCostUSD float64 `toml:"max_cost_usd"`
ExtraArgs []string `toml:"extra_args"`
// Harness runs the worker on another coding agent: "" is Claude Code,
// "codex" is `codex exec`, read only (ADR-0022).
Harness string `toml:"harness"`
}
Profile is a named worker runtime (RFC 6.2).
type Rule ¶
type Rule struct {
ID string `toml:"id"`
Match Match `toml:"match"`
Handler string `toml:"handler"`
Profile string `toml:"profile"`
Command []string `toml:"command"`
Timeout Duration `toml:"timeout"`
Cooldown Duration `toml:"cooldown"`
ReopenAfter int `toml:"reopen_after"`
}
Rule maps matching messages to a handler (RFC 6.1).