Documentation
¶
Index ¶
- Constants
- func ConfigToMap(cfg Config) map[string]any
- func DefaultWorkspaceDir() string
- func FixedConfigPath() string
- func FormatLegacyKeyWarnings(warnings []LegacyKeyWarning) string
- func LoadRaw(path string) ([]byte, error)
- func MCPServerEnabled(server MCPServer) bool
- func MCPServerIsRemote(server MCPServer) bool
- func NeedsSetup(cfg Config) bool
- func PatchYAML(path string, updates map[string]any) error
- func ResolveAllLLMTiers(cfg *Config) (map[string]ResolvedLLMTier, error)
- func ResolveConfigPath(raw string) string
- func SaveRaw(path string, content []byte) error
- func TarsHomeDir() string
- type APIConfig
- type AgentRuntimeAgent
- type AgentRuntimeConfig
- type AgentRuntimeTaskOverrideConfig
- type AssistantConfig
- type AutomationConfig
- type ChannelConfig
- type CompactionConfig
- type Config
- type ExtensionConfig
- type FieldMeta
- type LLMConfig
- type LLMProviderSettings
- type LLMTierBinding
- type LegacyKeyWarning
- type MCPServer
- type MemoryConfig
- type ResolvedLLMTier
- type RuntimeConfig
- type ToolConfig
- type UsageConfig
- type UsagePrice
Constants ¶
const ( PlanClarifyModeSmart = "smart" PlanClarifyModeAuto = "auto" PlanClarifyModeAsk = "ask" )
Plan clarify mode constants — keep in sync with the values rendered by the Settings dropdown and the prompt branches in internal/prompt/builder.go.
const ( MCPTransportStdio = "stdio" MCPTransportStreamableHTTP = "streamable_http" MCPTransportSSE = "sse" MCPTransportWebSocket = "websocket" )
const ( MCPAuthModeNone = "none" MCPAuthModeBearer = "bearer" MCPAuthModeOAuth = "oauth" )
const DefaultConfigFilename = "config/default.yaml"
Variables ¶
This section is empty.
Functions ¶
func ConfigToMap ¶ added in v0.14.0
ConfigToMap converts a Config to a flat map keyed by YAML keys.
func DefaultWorkspaceDir ¶ added in v0.15.2
func DefaultWorkspaceDir() string
DefaultWorkspaceDir returns the default workspace directory (~/.tars/workspace).
func FixedConfigPath ¶ added in v0.15.2
func FixedConfigPath() string
FixedConfigPath returns the fixed config file path (~/.tars/config/config.yaml). This path is not user-overridable; all commands use it.
func FormatLegacyKeyWarnings ¶ added in v0.26.1
func FormatLegacyKeyWarnings(warnings []LegacyKeyWarning) string
FormatLegacyKeyWarnings returns a human-readable summary of legacy key warnings suitable for CLI output.
func MCPServerEnabled ¶ added in v0.11.0
func MCPServerIsRemote ¶ added in v0.11.0
func NeedsSetup ¶ added in v0.31.129
NeedsSetup returns true when the loaded config cannot start the LLM router. It is the single source of truth shared between the healthz handler, the setup status handler, and the boot path (see Phase 2).
Conditions (any one triggers needs_setup=true):
- cfg.LLMProviders is empty
- cfg.LLMTiers is missing any of: heavy, standard, light
- any of those three tier bindings has empty (or whitespace-only) provider or model
This function does NOT validate that referenced provider aliases exist in cfg.LLMProviders — that check belongs to ResolveAllLLMTiers at boot time. Only structural completeness is checked here.
func PatchYAML ¶ added in v0.14.0
PatchYAML reads the YAML file at path, merges the given key-value updates, and writes the result back. Unknown keys are ignored.
func ResolveAllLLMTiers ¶ added in v0.25.0
func ResolveAllLLMTiers(cfg *Config) (map[string]ResolvedLLMTier, error)
ResolveAllLLMTiers resolves every tier present in cfg.LLMTiers and returns them keyed by normalized tier name. It is the single entry point used by buildLLMRouter — callers should not iterate cfg.LLMTiers directly.
Returns the first resolution error encountered (fail loud).
Note: this function does NOT enforce that heavy/standard/light are all present. That check lives in the router construction path (llm.NewRouter) so that the error message can reference the tier interface rather than the config schema.
func ResolveConfigPath ¶
func SaveRaw ¶ added in v0.14.0
SaveRaw writes raw content to the config file at the given path. It validates that the content is valid YAML before writing.
func TarsHomeDir ¶ added in v0.15.2
func TarsHomeDir() string
TarsHomeDir returns the base directory for TARS data (~/.tars).
Types ¶
type AgentRuntimeAgent ¶ added in v0.31.5
type AgentRuntimeAgent struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Command string `json:"command"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
Enabled bool `json:"enabled,omitempty"`
}
type AgentRuntimeConfig ¶ added in v0.31.5
type AgentRuntimeConfig struct {
AgentRuntimeEnabled bool
AgentRuntimeDefaultAgent string
AgentRuntimeAgents []AgentRuntimeAgent
AgentRuntimeTaskOverride AgentRuntimeTaskOverrideConfig
AgentRuntimeAgentsWatch bool
AgentRuntimeAgentsWatchDebounceMS int
AgentRuntimePersistenceEnabled bool
AgentRuntimeRunsPersistenceEnabled bool
AgentRuntimeChannelsPersistenceEnabled bool
AgentRuntimeRunsMaxRecords int
AgentRuntimeChannelsMaxMessagesPerChannel int
AgentRuntimeSubagentsMaxThreads int
AgentRuntimeSubagentsMaxDepth int
AgentRuntimeConsensusEnabled bool
AgentRuntimeConsensusMaxFanout int
AgentRuntimeConsensusBudgetTokens int
AgentRuntimeConsensusBudgetUSD float64
AgentRuntimeConsensusTimeoutSeconds int
AgentRuntimeConsensusAllowedAliases []string
AgentRuntimeConsensusConcurrentRuns int
AgentRuntimePersistenceDir string
AgentRuntimeRestoreOnStartup bool
AgentRuntimeReportSummaryEnabled bool
AgentRuntimeArchiveEnabled bool
AgentRuntimeArchiveDir string
AgentRuntimeArchiveRetentionDays int
AgentRuntimeArchiveMaxFileBytes int
}
type AgentRuntimeTaskOverrideConfig ¶ added in v0.31.5
type AssistantConfig ¶ added in v0.6.0
type AutomationConfig ¶ added in v0.6.0
type AutomationConfig struct {
AgentMaxIterations int
CronRunHistoryLimit int
NotifyCommand string
NotifyWhenNoClients bool
ScheduleTimezone string
// Pulse is the system-surface watchdog. All fields default to
// conservative values so it runs silently until signals appear.
PulseEnabled bool
PulseInterval string // duration string, e.g. "1m"
PulseTimeout string // duration string, e.g. "2m"
PulseActiveHours string
PulseTimezone string
PulseMinSeverity string
PulseAllowedAutofixes []string
PulseNotifyTelegram bool
PulseNotifySessionEvents bool
PulseCronFailureThreshold int
PulseStuckRunMinutes int
PulseDiskWarnPercent float64
PulseDiskCriticalPercent float64
PulseDeliveryFailureThreshold int
PulseDeliveryFailureWindow string // duration string, e.g. "10m"
// PulseReflectionFailureThreshold is the number of consecutive
// reflection run failures that causes pulse to emit a reflection-
// failure signal.
PulseReflectionFailureThreshold int
// Reflection is the nightly batch runner (memory + KB cleanup).
ReflectionEnabled bool
ReflectionSleepWindow string // "HH:MM-HH:MM" in ReflectionTimezone
ReflectionTimezone string
ReflectionTickInterval string // duration string, e.g. "5m"
ReflectionEmptySessionAge string // duration string, e.g. "24h"
ReflectionMemoryLookbackHours int
ReflectionMaxTurnsPerSession int
}
type ChannelConfig ¶ added in v0.6.0
type CompactionConfig ¶ added in v0.25.0
type Config ¶
type Config struct {
RuntimeConfig
APIConfig
LLMConfig
MemoryConfig
UsageConfig
AutomationConfig
AssistantConfig
CompactionConfig
ToolConfig
AgentRuntimeConfig
ChannelConfig
ExtensionConfig
}
Config holds top-level runtime settings grouped by concern.
type ExtensionConfig ¶ added in v0.6.0
type ExtensionConfig struct {
SkillsEnabled bool
SkillsWatch bool
SkillsWatchDebounceMS int
SkillsExtraDirs []string
SkillsBundledDir string
PluginsEnabled bool
PluginsWatch bool
PluginsWatchDebounceMS int
PluginsExtraDirs []string
PluginsBundledDir string
PluginsAllowMCPServers bool
MCPServers []MCPServer
MCPCommandAllowlist []string
}
type FieldMeta ¶ added in v0.14.0
type FieldMeta struct {
Key string `json:"key"`
Path string `json:"path"`
Section string `json:"section"`
Type string `json:"type"` // "string", "int", "float", "bool", "json"
Label string `json:"label"`
Description string `json:"description"`
Impact []string `json:"impact,omitempty"`
DefaultValue any `json:"default_value,omitempty"`
RequiresRestart bool `json:"requires_restart"`
Sensitive bool `json:"sensitive,omitempty"`
Options []string `json:"options,omitempty"`
}
FieldMeta describes a single configuration field for UI rendering.
type LLMConfig ¶ added in v0.6.0
type LLMConfig struct {
// LLMProviders is the named provider pool. Each entry describes
// "where to call + how to authenticate" — credentials, base URL,
// auth mode. It does NOT carry a model; models are bound at the
// tier level via LLMTierBinding. One provider can therefore serve
// multiple models by being referenced from multiple tiers.
LLMProviders map[string]LLMProviderSettings
// LLMTiers binds each tier name (typically "heavy"/"standard"/"light")
// to a provider alias (key in LLMProviders) + a concrete model + the
// optional per-call knobs. A tier's binding.Provider must exist in
// LLMProviders or resolution errors.
LLMTiers map[string]LLMTierBinding
// LLMDefaultTier is the tier used when a role has no explicit
// mapping in LLMRoleDefaults. Must be a key in LLMTiers.
LLMDefaultTier string
// LLMRoleDefaults maps a canonical role name (e.g. "chat_main",
// "pulse_decider") to a tier name ("heavy"|"standard"|"light"). Roles
// absent from the map fall back to LLMDefaultTier. Role names are
// validated at router build time via llm.ParseRole — this package
// does not import internal/llm.
LLMRoleDefaults map[string]string
}
LLMConfig holds the named provider pool + tier bindings that together describe every LLM endpoint TARS will call. See docs/plans/llm-provider-pool.md for the schema rationale.
Legacy flat fields (LLMProvider, LLMAuthMode, ..., LLMTierHeavy/Standard/ Light) were removed in the cutover commit — user configs must migrate to llm_providers + llm_tiers.
type LLMProviderSettings ¶ added in v0.25.0
type LLMProviderSettings struct {
Kind string `json:"kind" yaml:"kind"`
AuthMode string `json:"auth_mode" yaml:"auth_mode"`
OAuthProvider string `json:"oauth_provider" yaml:"oauth_provider"`
BaseURL string `json:"base_url" yaml:"base_url"`
APIKey string `json:"api_key" yaml:"api_key"`
ServiceTier string `json:"service_tier" yaml:"service_tier"`
}
LLMProviderSettings is one entry in the named provider pool. It holds "where to call + how to authenticate" but NOT "what model to call". Models are bound at the tier level (LLMTierBinding.Model) so that one provider can serve multiple models.
Kind identifies the provider type ("anthropic", "openai", "openai-codex", "gemini", "gemini-native", "kimi", "claude-code-cli") and maps to the value passed to llm.NewProvider.Provider. The config package does not validate Kind against a closed list — llm.NewProvider returns a clear error for unknown kinds, keeping the config package free of an internal/llm import.
ServiceTier is the provider-level default applied when a tier binding does not set its own. Tier-level ServiceTier (LLMTierBinding) takes precedence when non-empty; see ResolveLLMTier for the merge order.
type LLMTierBinding ¶ added in v0.25.0
type LLMTierBinding struct {
Provider string `json:"provider" yaml:"provider"`
Model string `json:"model" yaml:"model"`
ReasoningEffort string `json:"reasoning_effort" yaml:"reasoning_effort"`
ThinkingBudget int `json:"thinking_budget" yaml:"thinking_budget"`
ServiceTier string `json:"service_tier" yaml:"service_tier"`
}
LLMTierBinding binds a tier to a provider alias + concrete model + per-call knobs. Provider must be a key in cfg.LLMProviders — the resolver rejects unknown aliases with a loud error.
ServiceTier here overrides the provider-level default when non-empty. ReasoningEffort and ThinkingBudget are pure per-tier values (providers do not set them at the pool level).
type LegacyKeyWarning ¶ added in v0.26.1
LegacyKeyWarning describes a removed config key and its migration path.
func DetectLegacyKeys ¶ added in v0.26.1
func DetectLegacyKeys(path string) []LegacyKeyWarning
DetectLegacyKeys reads a YAML config file and returns warnings for any removed keys found. Returns nil if the file does not exist or contains no legacy keys.
type MCPServer ¶
type MCPServer struct {
Name string `json:"name"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
Transport string `json:"transport,omitempty"`
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
AuthMode string `json:"auth_mode,omitempty"`
AuthTokenEnv string `json:"auth_token_env,omitempty"`
OAuthProvider string `json:"oauth_provider,omitempty"`
Source string `json:"source,omitempty"`
}
func NormalizeMCPServer ¶ added in v0.11.0
type MemoryConfig ¶ added in v0.6.0
type ResolvedLLMTier ¶ added in v0.25.0
type ResolvedLLMTier struct {
Tier string
// From the referenced provider pool entry
Kind string
AuthMode string
OAuthProvider string
BaseURL string
APIKey string
// From the tier binding
Model string
ReasoningEffort string
ThinkingBudget int
// ServiceTier: binding override when set, otherwise provider default
ServiceTier string
// Provenance — alias of the provider pool entry that served this tier
ProviderAlias string
}
ResolvedLLMTier is the flat, final view of one tier's effective LLM configuration after merging the named provider pool entry and the tier binding. The router builder consumes this struct directly — callers never read cfg.LLMProviders or cfg.LLMTiers in isolation.
ProviderAlias records which pool entry served this tier so that tars doctor and startup logs can show provenance (e.g. "heavy → codex / gpt-5.4").
func ResolveLLMTier ¶ added in v0.25.0
func ResolveLLMTier(cfg *Config, tier string) (ResolvedLLMTier, error)
ResolveLLMTier returns the effective settings for the given tier. The tier name is normalized (lowercased, trimmed) before lookup.
Errors (all loud — no silent fallback):
- cfg is nil
- tier is empty
- cfg.LLMTiers[tier] is missing
- binding.Provider is empty
- cfg.LLMProviders[binding.Provider] is missing
- resolved Kind is empty
- binding.Model is empty
Kind is normalized to lowercase; other string fields are trimmed. Kind value is NOT validated against a closed list — llm.NewProvider rejects unknown kinds with a clear error at router build time, and the config package must stay free of an internal/llm import.
type RuntimeConfig ¶ added in v0.6.0
type RuntimeConfig struct {
WorkspaceDir string
SessionDefaultID string
SessionTelegramScope string
StyleDirectnessDefault int
StyleHumorDefault int
StyleCautionDefault int
StyleAutonomyDefault int
LogLevel string
LogFile string
LogRotateMaxSizeMB int
LogRotateMaxDays int
LogRotateMaxBackups int
// PlanClarifyMode controls whether the LLM asks clarifying questions
// before drafting a plan. One of "smart" (default), "auto", or "ask".
// See internal/prompt/builder.go for behavior per mode.
PlanClarifyMode string
}
type ToolConfig ¶ added in v0.6.0
type ToolConfig struct {
ToolsWebSearchEnabled bool
ToolsWebFetchEnabled bool
ToolsDefaultSet string
ToolsAllowHighRiskUser bool
ToolsWebSearchAPIKey string
ToolsWebSearchProvider string
ToolsWebSearchPerplexityAPIKey string
ToolsWebSearchPerplexityModel string
ToolsWebSearchPerplexityBaseURL string
ToolsWebSearchCacheTTLSeconds int
ToolsWebFetchPrivateHostAllowlist []string
ToolsWebFetchAllowPrivateHosts bool
ToolsApplyPatchEnabled bool
ToolsMessageEnabled bool
ToolsAgentRuntimeEnabled bool
}