config

package
v0.107.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCompactModel = "model1"
View Source
const DefaultCompactPct = 50
View Source
const DefaultGoalMaxRounds = 100
View Source
const SecretCmdTimeout = 5 * time.Second
View Source
const SystemSeed = `` /* 5834-byte string literal not displayed */

Variables

View Source
var HookEvents = []string{
	"SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "PostToolUseFailure",
	"PreCompact", "PostCompact", "Stop", "SessionEnd",
}

HookEvents lists the lifecycle events a hooks entry may name.

Functions

func BrainInstructions added in v0.103.0

func BrainInstructions() string

func BrainPath added in v0.103.0

func BrainPath() string

func Dir

func Dir() (string, error)

func Exists

func Exists() bool

func ExpandTemplate

func ExpandTemplate(v string) (string, error)

func IsWholeRef

func IsWholeRef(v string) bool

func LoadCatalogs

func LoadCatalogs() map[string]Catalog

func LogEvent

func LogEvent(op, detail string)

func MarkSetupDone

func MarkSetupDone()

func MigrateProjectDir added in v0.107.0

func MigrateProjectDir(project string) error

func Path added in v0.107.0

func Path() (string, error)

Path returns the default configuration file path.

func ProjectDir added in v0.107.0

func ProjectDir(project string) string

func ProjectGoalMaxRounds

func ProjectGoalMaxRounds(dir string) int

func ProjectID added in v0.103.0

func ProjectID(dir string) string

func ReadJSON

func ReadJSON(name string, v any) error

func ResolveEnvMap

func ResolveEnvMap(env map[string]string) (map[string]string, error)

func ResolveEnvMapContext added in v0.103.0

func ResolveEnvMapContext(ctx context.Context, env map[string]string) (map[string]string, error)

func ResolveHeader

func ResolveHeader(v string) (string, error)

func ResolveHeaderContext added in v0.103.0

func ResolveHeaderContext(ctx context.Context, v string) (string, error)

func ResolveSecret

func ResolveSecret(v string) (string, error)

func ResolveSecretContext added in v0.103.0

func ResolveSecretContext(ctx context.Context, v string) (string, error)

func SaveCatalogs

func SaveCatalogs(cats map[string]Catalog) error

func SetProjectGoalMaxRounds

func SetProjectGoalMaxRounds(dir string, n int) error

func SetupDone

func SetupDone() bool

func SystemInstructions added in v0.106.0

func SystemInstructions() string

func SystemPath added in v0.106.0

func SystemPath() string

func Trust

func Trust(dir string) error

func Trusted

func Trusted(dir string) bool

func TrustedPath added in v0.103.0

func TrustedPath() (string, error)

func UserDir added in v0.107.0

func UserDir() (string, error)

func WriteJSON

func WriteJSON(name string, v any) error

Types

type AIApprovalConfig added in v0.107.6

type AIApprovalConfig struct {
	Mode     string `json:"mode"`
	Provider string `json:"provider,omitempty"`
	Model    string `json:"model,omitempty"`
}

func (AIApprovalConfig) Enabled added in v0.107.6

func (c AIApprovalConfig) Enabled() bool

func (*AIApprovalConfig) UnmarshalJSON added in v0.107.6

func (c *AIApprovalConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts the read-only perRun marker that /v1/settings adds (capability ai_review_per_run), so a host can write back exactly what it read. The marker is never stored; any other unknown field is still rejected.

func (AIApprovalConfig) Validate added in v0.107.6

func (c AIApprovalConfig) Validate() error

type BrowserConfig

type BrowserConfig struct {
	Mode string `json:"mode,omitempty"`

	CDPURL string `json:"cdpUrl,omitempty"`

	AllowPrivateURLs bool `json:"allowPrivateUrls,omitempty"`

	Enabled *bool `json:"enabled,omitempty"`
}

type Catalog

type Catalog struct {
	FetchedAt time.Time       `json:"fetchedAt"`
	BaseURL   string          `json:"baseUrl"`
	Models    []ModelInfoLite `json:"models"`
}

func (Catalog) ContextLength

func (c Catalog) ContextLength(id string) int

func (Catalog) Efforts

func (c Catalog) Efforts(id string) []string

func (Catalog) Find

func (c Catalog) Find(id string) *ModelInfoLite

func (Catalog) MaxCompletionTokens

func (c Catalog) MaxCompletionTokens(id string) int

func (Catalog) Pricing

func (c Catalog) Pricing(id string) (ai.TokenRates, bool)

func (Catalog) Stale

func (c Catalog) Stale() bool

func (Catalog) SupportsVision

func (c Catalog) SupportsVision(id string) (vision, found bool)

type ComputerConfig

type ComputerConfig struct {
	Backend        string   `json:"backend,omitempty"`
	Command        []string `json:"command,omitempty"`
	ApprovalPolicy string   `json:"approvalPolicy,omitempty"`

	Allow []string `json:"allow,omitempty"`

	Deny []string `json:"deny,omitempty"`

	DefaultDeny *bool `json:"defaultDeny,omitempty"`

	Enabled *bool `json:"enabled,omitempty"`
}

type Config

type Config struct {

	// Image is optional. Public JSON is redacted; marshalConfig uses private disk types.
	Image           *imaging.ImageSettings `json:"image,omitempty"`
	Language        string                 `json:"language,omitempty"`
	DefaultModel    string                 `json:"defaultModel"`
	DefaultProvider string                 `json:"defaultProvider,omitempty"`
	DefaultEffort   string                 `json:"defaultEffort,omitempty"`
	CompactModel    string                 `json:"compactModel,omitempty"`
	CompactProvider string                 `json:"compactProvider,omitempty"`
	CompactPct      int                    `json:"compactPct,omitempty"`
	TaskModel       string                 `json:"taskModel,omitempty"`
	TaskProvider    string                 `json:"taskProvider,omitempty"`
	Theme           string                 `json:"theme,omitempty"`
	Mouse           *bool                  `json:"mouse,omitempty"`
	Thinking        *bool                  `json:"thinking,omitempty"`
	CollapsePaste   *bool                  `json:"collapsePaste,omitempty"`
	GoalMaxRounds   int                    `json:"goalMaxRounds,omitempty"`

	WorktreeSubagents *bool `json:"worktreeSubagents,omitempty"`
	MaxRetries        int   `json:"maxRetries,omitempty"`

	Experimental []string            `json:"experimental,omitempty"`
	Providers    map[string]Provider `json:"providers"`
	// ProviderOrder is the user's display order. It is persisted per provider inside
	// metadata (see providerOrderMetadataKey); empty means providers sort by ID.
	ProviderOrder []string `json:"-"`

	Models map[string]Model `json:"-"`

	MCPServers map[string]MCPServer `json:"mcp,omitempty"`

	LSPServers map[string]LSPServer `json:"lsp,omitempty"`

	Browser BrowserConfig `json:"browser,omitzero"`

	// Memory is persisted in the memorySwitchSuffix file, never in config.json; the key is still
	// read so values written by earlier builds of the switch carry over.
	Memory MemoryConfig `json:"memory,omitzero"`

	AIApproval AIApprovalConfig  `json:"aiApproval,omitzero"`
	Computer   ComputerConfig    `json:"computer,omitzero"`
	Sandbox    SandboxConfig     `json:"sandbox,omitzero"`
	Hooks      map[string][]Hook `json:"hooks,omitempty"`

	RulesCompat RulesCompatConfig `json:"rulesCompat,omitzero"`
	// contains filtered or unexported fields
}

func Default

func Default() *Config

func Load

func Load() (*Config, error)

func LoadFile added in v0.107.0

func LoadFile(path string) (*Config, error)

LoadFile reads a configuration without changing the user's default file.

func (*Config) AdoptMemory added in v0.107.6

func (c *Config) AdoptMemory(from *Config)

AdoptMemory takes the switch from a freshly loaded config, with the disk state that load observed, so this config shows it and a later Save writes it only when the disk needs it (a legacy config.json value still moves into the switch file).

func (*Config) ImageConfigUnavailable added in v0.107.6

func (c *Config) ImageConfigUnavailable() bool

ImageConfigUnavailable reports an isolated optional configuration failure. The original image document is retained privately for subsequent saves.

func (*Config) OrderedProviderIDs added in v0.107.6

func (c *Config) OrderedProviderIDs() []string

OrderedProviderIDs returns every configured provider ID in display order: IDs listed in ProviderOrder first, then any remaining providers sorted by ID.

func (*Config) RemoveProvider

func (c *Config) RemoveProvider(name string)

func (*Config) Resolve

func (c *Config) Resolve(model, provider string) (Provider, Model, string, error)

func (*Config) Save

func (c *Config) Save() error

func (*Config) SaveFile added in v0.107.0

func (c *Config) SaveFile(filename string) error

SaveFile atomically replaces the explicit backend configuration, including an empty catalog.

func (*Config) Snapshot

func (c *Config) Snapshot() *Config

type CustomHeader added in v0.107.0

type CustomHeader struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Hook added in v0.103.0

type Hook struct {
	Command string `json:"command"`
	Shell   string `json:"shell,omitempty"`
	Timeout int    `json:"timeout,omitempty"`
}

type LSPServer

type LSPServer struct {
	Command     []string          `json:"command,omitempty"`
	Extensions  []string          `json:"extensions,omitempty"`
	RootMarkers []string          `json:"rootMarkers,omitempty"`
	Env         map[string]string `json:"env,omitempty"`
	Enabled     *bool             `json:"enabled,omitempty"`
}

type MCPServer

type MCPServer struct {
	Command        []string          `json:"command,omitempty"`
	Env            map[string]string `json:"env,omitempty"`
	Cwd            string            `json:"cwd,omitempty"`
	URL            string            `json:"url,omitempty"`
	Headers        map[string]string `json:"headers,omitempty"`
	Enabled        *bool             `json:"enabled,omitempty"`
	Note           string            `json:"note,omitempty"`
	StartupTimeout int               `json:"startupTimeout,omitempty"`
	ToolTimeout    int               `json:"toolTimeout,omitempty"`
}

type MemoryConfig added in v0.107.6

type MemoryConfig struct {
	Enabled *bool `json:"enabled,omitempty"`
}

MemoryConfig is the memory master switch. Off stops memory injection, hidden extraction and the agent memory tools; stored memories and the memory management API stay available.

func (MemoryConfig) IsEnabled added in v0.107.6

func (m MemoryConfig) IsEnabled() bool

IsEnabled defaults to true so configurations written before the switch keep memory on.

type Model

type Model struct {
	Name             string   `json:"name,omitempty"`
	DisplayName      string   `json:"displayName,omitempty"`
	OwnedBy          string   `json:"ownedBy,omitempty"`
	LimitsSource     string   `json:"limitsSource,omitempty"`
	OutputModalities []string `json:"outputModalities,omitempty"`
	// ImageAdapter explicitly selects an image protocol; "disabled" opts out of discovery.
	ImageAdapter    string   `json:"imageAdapter,omitempty"`
	InputModalities []string `json:"inputModalities,omitempty"`
	Providers       []string `json:"providers"`
	ID              string   `json:"id,omitempty"`

	Context int `json:"context,omitempty"`

	MaxOut int `json:"maxOut,omitempty"`

	Vision bool `json:"vision,omitempty"`

	SamplingParams *SamplingParams `json:"samplingParams,omitempty"`

	// ProviderMetadata holds per-provider metadata that differs from the
	// shared fields above; use ForProvider to read a provider's view of the model.
	ProviderMetadata map[string]Model `json:"providerMetadata,omitempty"`
}

func (Model) ContextWindow

func (m Model) ContextWindow() int

func (*Model) DropProvider added in v0.107.6

func (m *Model) DropProvider(provider string)

DropProvider removes provider from m. When the remaining providers all carry overrides, the first one is promoted to the shared metadata so the record stays as small as possible.

func (Model) ForProvider added in v0.107.6

func (m Model) ForProvider(provider string) Model

ForProvider returns m with the metadata the given provider declared for it. Models are keyed globally by ID, so two providers serving the same ID may disagree on context window, max output or modalities; the shared record holds one variant and ProviderMetadata holds the rest.

func (Model) Metadata added in v0.107.6

func (m Model) Metadata() Model

Metadata returns the provider-independent part of m: everything except the provider list, ID and per-provider overrides.

func (*Model) SetProviderMetadata added in v0.107.6

func (m *Model) SetProviderMetadata(provider string, meta Model)

SetProviderMetadata records meta as provider's view of m, storing an override only when it differs from the shared metadata.

type ModelInfoLite

type ModelInfoLite struct {
	ID                  string         `json:"id"`
	ContextLength       int            `json:"contextLength,omitempty"`
	MaxCompletionTokens int            `json:"maxCompletionTokens,omitempty"`
	ReasoningEfforts    []string       `json:"reasoningEfforts,omitempty"`
	Pricing             *ai.TokenRates `json:"pricing,omitempty"`
	InputModalities     []string       `json:"inputModalities,omitempty"`
}

type PiModel

type PiModel struct {
	ID               string   `json:"id"`
	Name             string   `json:"name,omitempty"`
	DisplayName      string   `json:"displayName,omitempty"`
	OwnedBy          string   `json:"ownedBy,omitempty"`
	LimitsSource     string   `json:"limitsSource,omitempty"`
	OutputModalities []string `json:"outputModalities,omitempty"`
	// ImageAdapter explicitly selects an image protocol; "disabled" opts out of discovery.
	ImageAdapter    string          `json:"imageAdapter,omitempty"`
	InputModalities []string        `json:"inputModalities,omitempty"`
	API             string          `json:"api,omitempty"`
	Reasoning       bool            `json:"reasoning,omitempty"`
	Input           []string        `json:"input,omitempty"`
	ContextWindow   int             `json:"contextWindow,omitempty"`
	MaxTokens       int             `json:"maxTokens,omitempty"`
	SamplingParams  *SamplingParams `json:"samplingParams,omitempty"`
}

type PromptFile added in v0.106.0

type PromptFile struct {
	Scope string
	Path  string
	Text  string
	// User marks the user's own standing rules (for example ~/.claude/CLAUDE.md), as
	// opposed to rules that belong to the project tree.
	User bool
}

func InstructionFiles added in v0.107.13

func InstructionFiles(wd string) []PromptFile

InstructionFiles returns every instruction file that applies to wd, in prompt order: user-level compatibility files first, then each directory from the project root down to wd. Within a directory the order is AGENTS.md, CLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md, .claude/CLAUDE.local.md, .cursorrules, .cursor/rules and finally the native .liveagent/brain.md, so later (deeper, more local) files win on conflicts.

A file reachable through several names (symlinks, hard links, case-insensitive filesystems) and a file whose text repeats an earlier one are included once.

func ProjectPromptFiles added in v0.106.0

func ProjectPromptFiles(wd string) []PromptFile

ProjectPromptFiles returns the project-tree instruction files, root first.

type Provider

type Provider struct {
	Name                   string               `json:"name,omitempty"`
	Type                   string               `json:"type,omitempty"`
	BaseURL                string               `json:"baseUrl"`
	IsFullURL              bool                 `json:"isFullUrl,omitempty"`
	ModelsURL              string               `json:"modelsUrl,omitempty"`
	API                    string               `json:"api"`
	APIKey                 string               `json:"apiKey"`
	CustomHeaders          []CustomHeader       `json:"customHeaders,omitempty"`
	ActiveModels           []string             `json:"activeModels"`
	ModelOrder             []string             `json:"modelOrder,omitempty"`
	RequestFormat          string               `json:"requestFormat,omitempty"`
	Reasoning              string               `json:"reasoning,omitempty"`
	PromptCacheHintMode    string               `json:"promptCacheHintMode,omitempty"`
	NativeWebSearchEnabled bool                 `json:"nativeWebSearchEnabled,omitempty"`
	UseSystemProxy         bool                 `json:"useSystemProxy,omitempty"`
	Metadata               map[string]any       `json:"metadata,omitempty"`
	PromptCachingEnabled   *bool                `json:"promptCachingEnabled,omitempty"`
	PromptCacheRetention   string               `json:"promptCacheRetention,omitempty"`
	RetryPolicy            map[string]any       `json:"retryPolicy,omitempty"`
	UsageQuery             map[string]any       `json:"usageQuery,omitempty"`
	CacheSessionAffinity   *bool                `json:"cacheSessionAffinity,omitempty"`
	CacheControlFormat     string               `json:"cacheControlFormat,omitempty"`
	CacheCapabilities      ai.CacheCapabilities `json:"cacheCapabilities,omitzero"`

	Models []PiModel `json:"models"`
}

func (Provider) Key

func (p Provider) Key() string

func (Provider) ModelActive added in v0.107.0

func (p Provider) ModelActive(id string) bool

func (Provider) ResolveKey

func (p Provider) ResolveKey() (string, error)

func (Provider) ResolveKeyContext added in v0.103.0

func (p Provider) ResolveKeyContext(ctx context.Context) (string, error)

type RulesCompatConfig added in v0.107.13

type RulesCompatConfig struct {
	Claude *bool `json:"claude,omitempty"`
	Cursor *bool `json:"cursor,omitempty"`
}

RulesCompatConfig toggles discovery of instruction files written for other agent harnesses. Both sources default to on; set a field to false to opt out.

claude: CLAUDE.md, CLAUDE.local.md, .claude/CLAUDE*.md, ~/.claude/CLAUDE.md, .claude/skills
cursor: .cursor/rules/*.md|*.mdc and the legacy .cursorrules

func RulesCompatSettings added in v0.107.13

func RulesCompatSettings() RulesCompatConfig

RulesCompatSettings reads the rulesCompat switches straight from config.json. It never writes defaults, so prompt assembly stays free of side effects; any read or parse problem falls back to the defaults (everything on).

func (RulesCompatConfig) ClaudeEnabled added in v0.107.13

func (r RulesCompatConfig) ClaudeEnabled() bool

func (RulesCompatConfig) CursorEnabled added in v0.107.13

func (r RulesCompatConfig) CursorEnabled() bool

type SamplingParams

type SamplingParams struct {
	Temperature *float64 `json:"temperature,omitempty"`
	TopP        *float64 `json:"top_p,omitempty"`
}

type SandboxConfig added in v0.103.0

type SandboxConfig struct {
	Mode     string   `json:"mode,omitempty"`
	Backend  string   `json:"backend,omitempty"`
	Network  *bool    `json:"network,omitempty"`
	Writable []string `json:"writable,omitempty"`
	ReadOnly []string `json:"readOnly,omitempty"`
}

func (SandboxConfig) Policy added in v0.103.0

func (s SandboxConfig) Policy(root string) *sandbox.Policy

type UnknownModelError

type UnknownModelError struct {
	Model string
	// contains filtered or unexported fields
}

func (*UnknownModelError) Error

func (e *UnknownModelError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL