Documentation
¶
Index ¶
- func Home() string
- func LiteKVGetAll() map[string]string
- func LiteKVRemove(key string) error
- func LiteKVSet(key, value string) error
- func LoadDotEnv()
- func ReconcileKVArrayWithFile(kvKey, path string)
- func SaveSidecarSettings(s SidecarSettings) error
- func SeedLiteKVFromDesktop()
- func SetDevMode()
- type SidecarSettings
- func (s SidecarSettings) EffectiveConfirmThreshold() int
- func (s SidecarSettings) EffectiveEgressMode() string
- func (s SidecarSettings) EffectiveMaxIterations() int
- func (s SidecarSettings) EffectiveMaxOutputTokens() int
- func (s SidecarSettings) EffectiveOllamaNumCtx() int
- func (s SidecarSettings) EffectiveTaskTimeout() time.Duration
- func (s SidecarSettings) EffectiveUserMessageDelay() time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Home ¶
func Home() string
Home returns the Tollecode data directory (~/.tollecode or ~/.tollecode-dev).
func LiteKVGetAll ¶
LiteKVGetAll returns a copy of the whole shared Lite KV map.
func LoadDotEnv ¶
func LoadDotEnv()
LoadDotEnv reads $HOME/.tollecode/.env and sets any variables not already present in the process environment. Silently no-ops if the file is absent.
This lives in config rather than selfhost because loading the user's .env is useful in every build — provider API keys are the common case — while selfhost is compiled in only under the `selfhost` build tag.
func ReconcileKVArrayWithFile ¶
func ReconcileKVArrayWithFile(kvKey, path string)
ReconcileKVArrayWithFile keeps a Lite KV array (kvKey inside lite_kv.json, read by the Lite desktop/web UI) and a JSON-array file at path (read by the CLI/agent runtime) in sync, so array configs like teams cut across every surface.
It is ADD-ONLY, matched by each element's "id": an element in one store but missing from the other is copied over; existing elements are never modified. That makes it safe to run on every startup — it can't clobber data a surface already has, and it writes only when something is actually added.
func SaveSidecarSettings ¶
func SaveSidecarSettings(s SidecarSettings) error
SaveSidecarSettings persists s and updates the cache.
func SeedLiteKVFromDesktop ¶
func SeedLiteKVFromDesktop()
SeedLiteKVFromDesktop imports the Tauri desktop app's KV settings into the shared store, but ONLY when the shared store is still empty — so it never clobbers data the web UI has since written. Best-effort: any failure (no sqlite3 CLI, no desktop DB, parse error) is silently ignored.
The desktop persists its KV in a SQLite `kv_store(key,value)` table under the Tauri app-config dir. We read it via the `sqlite3` CLI (present by default on macOS) rather than adding a SQLite driver dependency to the sidecar.
Types ¶
type SidecarSettings ¶
type SidecarSettings struct {
// MaxToolIterations caps the agentic loop. 0 means use the built-in default.
MaxToolIterations int `json:"maxToolIterations,omitempty"`
// ConfirmContinue, when true, pauses the agent near the iteration limit and
// asks the user whether to continue instead of failing hard.
ConfirmContinue bool `json:"confirmContinue,omitempty"`
// ConfirmContinueThreshold is the iteration number at which the pause fires.
// 0 means 80% of MaxToolIterations (or the built-in default).
ConfirmContinueThreshold int `json:"confirmContinueThreshold,omitempty"`
// TaskTimeoutMinutes is the wall-clock deadline for a todo task (single or team).
// 0 means use the built-in default (120 minutes).
TaskTimeoutMinutes int `json:"taskTimeoutMinutes,omitempty"`
// UserMessageDelayMs is the delay (in milliseconds) before a user message sent
// during a live stream starts a new agent turn. 0 means use the built-in default
// of 1500 ms. This keeps brief follow-ups from interrupting an active stream.
UserMessageDelayMs int `json:"userMessageDelayMs,omitempty"`
// OllamaNumCtx is the context-window size (num_ctx) requested from Ollama. It is
// the effective runtime context window for Ollama models — the value the UI shows
// as the limit and the threshold against which auto-compaction fires. 0 means use
// the built-in default of 32768.
OllamaNumCtx int `json:"ollamaNumCtx,omitempty"`
// MaxOutputTokens is the per-response output-token budget requested from every
// provider (Anthropic max_tokens, OpenAI max_tokens, Ollama num_predict). Each
// provider still clamps it down to its model's real output ceiling, so a large
// value is safe. 0 means use the built-in default of 32000.
MaxOutputTokens int `json:"maxOutputTokens,omitempty"`
// EgressMode controls the outbound secrets/PII guardrail applied to every LLM
// request: "off" (no scan), "log" (flag the finding but send unchanged — the
// default), or "redact" (replace detected secrets/PII with typed placeholders
// before the request leaves the machine). "" means the default ("log").
EgressMode string `json:"egressMode,omitempty"`
// ChannelShellAutoAllow lets chat-channel agents (Slack/Telegram/Discord) run
// shell commands with no human approval step. It is OFF by default: chat
// surfaces are unattended and an incoming message can carry injected content,
// so autonomous shell execution there is high-risk (the injection -> run_shell
// chain). Operators must opt in explicitly to restore auto-run behavior.
ChannelShellAutoAllow bool `json:"channelShellAutoAllow,omitempty"`
}
SidecarSettings holds user-configurable sidecar-level preferences that are separate from provider config. Persisted to ~/.tollecode/sidecar_settings.json.
func GetSidecarSettings ¶
func GetSidecarSettings() SidecarSettings
GetSidecarSettings returns the cached settings (loaded at startup). Falls back to a fresh disk read if not yet initialised.
func LoadSidecarSettings ¶
func LoadSidecarSettings() SidecarSettings
LoadSidecarSettings reads settings from disk (or returns defaults).
func (SidecarSettings) EffectiveConfirmThreshold ¶
func (s SidecarSettings) EffectiveConfirmThreshold() int
EffectiveConfirmThreshold returns the iteration at which the confirm prompt fires.
func (SidecarSettings) EffectiveEgressMode ¶
func (s SidecarSettings) EffectiveEgressMode() string
EffectiveEgressMode returns the outbound-guardrail mode, defaulting to "log" (observe-only) and rejecting unknown values.
func (SidecarSettings) EffectiveMaxIterations ¶
func (s SidecarSettings) EffectiveMaxIterations() int
EffectiveMaxIterations returns the resolved iteration limit (never < 10).
func (SidecarSettings) EffectiveMaxOutputTokens ¶
func (s SidecarSettings) EffectiveMaxOutputTokens() int
EffectiveMaxOutputTokens returns the per-response output-token budget to request from providers. Defaults to 32000 and is clamped to a sane floor so a misconfigured tiny value can't truncate every turn. Providers cap it to the model's real output ceiling, so there is no upper clamp here.
func (SidecarSettings) EffectiveOllamaNumCtx ¶
func (s SidecarSettings) EffectiveOllamaNumCtx() int
EffectiveOllamaNumCtx returns the Ollama context-window size to request at runtime. Defaults to 32768 and is clamped to a sane floor so a misconfigured tiny value can't truncate every conversation.
func (SidecarSettings) EffectiveTaskTimeout ¶
func (s SidecarSettings) EffectiveTaskTimeout() time.Duration
EffectiveTaskTimeout returns the wall-clock limit for a todo task. Defaults to 2 hours when not configured.
func (SidecarSettings) EffectiveUserMessageDelay ¶
func (s SidecarSettings) EffectiveUserMessageDelay() time.Duration
EffectiveUserMessageDelay returns the delay before a queued user message during a live stream is processed. Defaults to 1500 ms when not configured.