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 BuiltinProfiles() map[string]Profile
- func IntentMatches(glob, intent string) bool
- func PriorityLevel(p string) int
- func ValidIntent(s string) bool
- func WatchdogEvery(v string) (time.Duration, error)
- type Agent
- type Config
- type Daemon
- type Defaults
- type Duration
- 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 BuiltinProfiles ¶
BuiltinProfiles returns triage, fix, answer and release (RFC 6.2).
func IntentMatches ¶
IntentMatches reports whether a dotted intent matches a glob.
func PriorityLevel ¶
PriorityLevel converts a priority name to 0..3 (-1 if unknown).
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"`
// 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:"-"`
}
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.
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"`
// 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"`
// 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 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"`
}
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).