Documentation
¶
Overview ¶
Package config loads the agent's runtime configuration. Settings come from two JSON files merged over safe defaults: a machine-level user config (~/.config/ipsupport-code/config.json — the LM Studio endpoint, written by first-run setup) and a per-workspace config (<workspace>/.agent/config.json — the permission policy). A protective deny floor is unioned in afterwards so a workspace config can never drop the most dangerous-command guards.
Index ¶
- Variables
- func DefaultKBPath() string
- func DefaultSkillsPath() string
- func DefaultTracePath() string
- func DefaultUsagePath() string
- func GlobalExists() bool
- func GlobalPath() string
- func KnownProviders() []string
- func SaveChannel(channel string) error
- func SaveGlobal(name string, l LLM) error
- func SaveProviders(provider string, providers map[string]LLM) error
- func SaveUsageRetention(days int) error
- func SaveWorkspacePolicy(workspace string, run RunPolicy, file FilePolicy) error
- func SystemPromptPath() string
- type AgentProfile
- type Config
- type FilePolicy
- type LLM
- type RunPolicy
Constants ¶
This section is empty.
Variables ¶
var ProviderTemplates = map[string]LLM{
"openai": {BaseURL: "https://api.openai.com/v1", Model: "gpt-4o-mini"},
"anthropic": {BaseURL: "https://api.anthropic.com/v1", Model: "claude-3-5-sonnet-latest"},
"grok": {BaseURL: "https://api.x.ai/v1", Model: "grok-2-latest"},
"groq": {BaseURL: "https://api.groq.com/openai/v1", Model: "llama-3.3-70b-versatile"},
"openrouter": {BaseURL: "https://openrouter.ai/api/v1", Model: "openai/gpt-4o-mini"},
}
ProviderTemplates are built-in OpenAI-compatible providers: base URL (and a sensible default model) are known, so the user only needs to add an API key.
Functions ¶
func DefaultKBPath ¶
func DefaultKBPath() string
DefaultKBPath is the global knowledge-base location.
func DefaultSkillsPath ¶
func DefaultSkillsPath() string
DefaultSkillsPath is the global skills directory.
func DefaultTracePath ¶
func DefaultTracePath() string
DefaultTracePath is the global decision-trace (training dataset) location.
func DefaultUsagePath ¶ added in v0.4.5
func DefaultUsagePath() string
DefaultUsagePath is the global token-usage ledger location.
func GlobalExists ¶
func GlobalExists() bool
GlobalExists reports whether the user config file is present.
func KnownProviders ¶ added in v0.4.0
func KnownProviders() []string
KnownProviders lists the built-in template names (sorted), for help/listing.
func SaveChannel ¶ added in v0.2.0
SaveChannel persists the update channel (stable|nightly).
func SaveGlobal ¶
SaveGlobal writes the machine-level settings (display name + LLM connection) to the user config file, creating its directory.
func SaveProviders ¶ added in v0.4.0
SaveProviders persists the active provider name and the external provider presets (which may include API keys — the file is written 0600).
func SaveUsageRetention ¶ added in v0.5.0
SaveUsageRetention persists the usage-ledger retention window (days; 0 = keep forever).
func SaveWorkspacePolicy ¶
func SaveWorkspacePolicy(workspace string, run RunPolicy, file FilePolicy) error
SaveWorkspacePolicy persists the run/file permission policy to the workspace config (<workspace>/.agent/config.json) so /permissions changes survive a restart. Any other keys already in that file are preserved.
func SystemPromptPath ¶ added in v0.3.0
func SystemPromptPath() string
SystemPromptPath is the optional global system-prompt override file; if it (or a workspace .agent/system.md) exists, it replaces the built-in base prompt.
Types ¶
type AgentProfile ¶ added in v0.6.0
type AgentProfile struct {
Provider string `json:"provider"`
Model string `json:"model,omitempty"`
Prompt string `json:"prompt,omitempty"`
}
AgentProfile is a named sub-agent target for the `agent` tool: which provider and model to run the sub-agent on, plus an optional role prompt (e.g. "you are a strict code reviewer").
type Config ¶
type Config struct {
Name string `json:"name,omitempty"` // display name (renameable)
Channel string `json:"channel,omitempty"` // update channel: stable | nightly
Provider string `json:"provider,omitempty"` // active provider ("" / "local" = LLM below)
LLM LLM `json:"llm"` // the local connection (the "local" provider)
Providers map[string]LLM `json:"providers,omitempty"` // external provider presets
Run RunPolicy `json:"run"`
File FilePolicy `json:"file"`
KBPath string `json:"kb_path,omitempty"`
TracePath string `json:"trace_path,omitempty"`
UsagePath string `json:"usage_path,omitempty"`
// UsageRetentionDays auto-drops usage-ledger entries older than N days on
// startup. 0 keeps history forever.
UsageRetentionDays int `json:"usage_retention_days,omitempty"`
// Prices overrides the built-in per-model price estimates for /usage cost:
// model-id substring → [input, output] USD per 1M tokens.
Prices map[string][2]float64 `json:"prices,omitempty"`
// Agents are named sub-agent profiles for the `agent` tool (delegate a task to
// another model/provider): name → {provider, model, optional role prompt}.
Agents map[string]AgentProfile `json:"agents,omitempty"`
SkillsPath string `json:"skills_path,omitempty"`
Workspace string `json:"-"` // resolved absolute workspace root
}
Config is the merged runtime configuration.
type FilePolicy ¶
type FilePolicy struct {
Default string `json:"default"`
Jail string `json:"jail"`
AllowWrite []string `json:"allow_write"`
DenyWrite []string `json:"deny_write"`
}
FilePolicy gates file writes and confines all file ops to Jail (empty = no jail). AllowWrite/DenyWrite are globs applied to writes; reads are jail-checked only.
type LLM ¶
type LLM struct {
BaseURL string `json:"base_url"`
Model string `json:"model"`
Temperature float64 `json:"temperature"`
MaxSteps int `json:"max_steps"`
APIKey string `json:"api_key,omitempty"`
// Type selects extra capabilities: "lmstudio" uses LM Studio's native API
// (rich model list, context detection); anything else is plain OpenAI-compat.
Type string `json:"type,omitempty"`
// ContextWindow is the model's context size in tokens; auto-compact triggers
// as the prompt approaches it. 0 disables auto-compact.
ContextWindow int `json:"context_window,omitempty"`
}
LLM describes the OpenAI-compatible endpoint (LM Studio by default). The same shape points at OpenAI or a LiteLLM proxy by changing BaseURL/APIKey.
func ResolveProvider ¶ added in v0.4.0
ResolveProvider returns the connection for an external provider name, merging a user preset over the built-in template and falling back to the env var for the key. Not for "local" (that's cfg.LLM). false if the name is unknown.
type RunPolicy ¶
type RunPolicy struct {
Default string `json:"default"`
Allow []string `json:"allow"`
Deny []string `json:"deny"`
// TimeoutSeconds is the default wall-clock limit for a shell command. 0 uses
// the built-in default (60s). A command may pass a larger per-call `timeout`.
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
}
RunPolicy gates shell execution. Resolution per command: a Deny glob (matched anywhere) blocks, an Allow glob (whole command) auto-runs, otherwise Default.