Documentation
¶
Index ¶
- Constants
- Variables
- func DockerMCPAvailabilityCached() (available bool, known bool)
- func GlobalCacheDir() string
- func GlobalConfig() string
- func GlobalConfigData() string
- func GlobalSkillsDirs() []string
- func GlobalWorkspaceDir() string
- func HasInitialDataConfig(store *ConfigStore) bool
- func IsDockerMCPAvailable() bool
- func MarkProjectInitialized(store *ConfigStore) error
- func ProjectConfigs(cwd string) []string
- func ProjectNeedsInitialization(store *ConfigStore) (bool, error)
- func ProjectSkillsDir(workingDir string) []string
- func Providers(_ *Config) ([]catwalk.Provider, error)
- func PushPopSeshatEnv() func()
- func RefreshDockerMCPAvailability() bool
- type Agent
- type Attribution
- type Completions
- type Config
- func (c *Config) EnabledProviders() []ProviderConfig
- func (c *Config) GetModel(provider, model string) *catwalk.Model
- func (c *Config) GetModelByType(modelType SelectedModelType) *catwalk.Model
- func (c *Config) GetProviderForModel(modelType SelectedModelType) *ProviderConfig
- func (c *Config) IsConfigured() bool
- func (c *Config) IsDockerMCPEnabled() bool
- func (c *Config) LargeModel() *catwalk.Model
- func (c *Config) SetupAgents()
- func (c *Config) SmallModel() *catwalk.Model
- func (c *Config) ValidateHooks() error
- type ConfigStore
- func (s *ConfigStore) CaptureStalenessSnapshot(paths []string)
- func (s *ConfigStore) Config() *Config
- func (s *ConfigStore) ConfigStaleness() StalenessResult
- func (s *ConfigStore) DisableDockerMCP() error
- func (s *ConfigStore) EnableDockerMCP() error
- func (s *ConfigStore) HasConfigField(scope Scope, key string) bool
- func (s *ConfigStore) ImportCopilot() (*oauth.Token, bool)
- func (s *ConfigStore) KnownProviders() []catwalk.Provider
- func (s *ConfigStore) LoadedPaths() []string
- func (s *ConfigStore) Overrides() *RuntimeOverrides
- func (s *ConfigStore) PersistDockerMCPConfig(mcpConfig MCPConfig) error
- func (s *ConfigStore) PrepareDockerMCPConfig() (MCPConfig, error)
- func (s *ConfigStore) RefreshOAuthToken(ctx context.Context, scope Scope, providerID string) error
- func (s *ConfigStore) RefreshStalenessSnapshot() error
- func (s *ConfigStore) ReloadFromDisk(ctx context.Context) error
- func (s *ConfigStore) RemoveConfigField(scope Scope, key string) error
- func (s *ConfigStore) Resolve(key string) (string, error)
- func (s *ConfigStore) Resolver() VariableResolver
- func (s *ConfigStore) SetCompactMode(scope Scope, enabled bool) error
- func (s *ConfigStore) SetConfigField(scope Scope, key string, value any) error
- func (s *ConfigStore) SetConfigFields(scope Scope, kv map[string]any) error
- func (s *ConfigStore) SetProviderAPIKey(scope Scope, providerID string, apiKey any) error
- func (s *ConfigStore) SetTransparentBackground(scope Scope, enabled bool) error
- func (s *ConfigStore) SetupAgents()
- func (s *ConfigStore) UpdatePreferredModel(scope Scope, modelType SelectedModelType, model SelectedModel) error
- func (s *ConfigStore) WorkingDir() string
- type Expander
- type HookConfig
- type ImageGenerationConfig
- type LSP
- type LSPConfig
- type LSPs
- type MCP
- type MCPConfig
- type MCPType
- type MCPs
- type Options
- type Permissions
- type ProjectInitFlag
- type ProviderConfig
- type RuntimeOverrides
- type Scope
- type SelectedModel
- type SelectedModelType
- type ShellResolverOption
- type SpeechToTextConfig
- type StalenessResult
- type TUIOptions
- type TextToSpeechConfig
- type ToolGrep
- type ToolLs
- type Tools
- type TrailerStyle
- type VariableResolver
Constants ¶
const ( AgentCoder string = "coder" AgentTask string = "task" )
const DockerMCPName = "docker"
DockerMCPName is the name of the Docker MCP configuration.
const (
InitFlagFilename = "init"
)
Variables ¶
var ErrNoWorkspaceConfig = fmt.Errorf("no workspace config path configured")
ErrNoWorkspaceConfig is returned when a workspace-scoped write is attempted on a ConfigStore that has no workspace config path.
Functions ¶
func DockerMCPAvailabilityCached ¶
DockerMCPAvailabilityCached returns the cached Docker MCP availability and whether the cached value is still fresh.
func GlobalCacheDir ¶
func GlobalCacheDir() string
GlobalCacheDir returns the path to the global cache directory for the application.
func GlobalConfig ¶
func GlobalConfig() string
GlobalConfig returns the global configuration file path for the application.
func GlobalConfigData ¶
func GlobalConfigData() string
GlobalConfigData returns the runtime-root data config path for the application. This config is used when the app overrides configurations instead of updating the global config.
func GlobalSkillsDirs ¶
func GlobalSkillsDirs() []string
GlobalSkillsDirs returns the default directories for Agent Skills. Skills in these directories are auto-discovered and their files can be read without permission prompts.
func GlobalWorkspaceDir ¶
func GlobalWorkspaceDir() string
GlobalWorkspaceDir returns the path to the global server workspace directory. This directory acts as a meta-workspace for the server process, giving it a real workingDir so that config loading, scoped writes, and provider resolution behave identically to project workspaces.
func HasInitialDataConfig ¶
func HasInitialDataConfig(store *ConfigStore) bool
func IsDockerMCPAvailable ¶
func IsDockerMCPAvailable() bool
IsDockerMCPAvailable checks if Docker MCP is available by running 'docker mcp version'.
func MarkProjectInitialized ¶
func MarkProjectInitialized(store *ConfigStore) error
func ProjectConfigs ¶
ProjectConfigs returns list of current project configs paths.
func ProjectNeedsInitialization ¶
func ProjectNeedsInitialization(store *ConfigStore) (bool, error)
func ProjectSkillsDir ¶
ProjectSkillsDir returns the default project directories for which Seshat will look for skills.
func Providers ¶
Providers returns the seshat provider catalog as catwalk.Provider values so the TUI models dialog can render them. The list is built once from pkg/config.AvailableProviders() (the SDK's own registry) extended with the display-only model IDs in extra_models.json. No network I/O.
func PushPopSeshatEnv ¶
func PushPopSeshatEnv() func()
func RefreshDockerMCPAvailability ¶
func RefreshDockerMCPAvailability() bool
RefreshDockerMCPAvailability refreshes and caches Docker MCP availability.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
// This is the id of the system prompt used by the agent
Disabled bool `json:"disabled,omitempty"`
Model SelectedModelType `json:"model" jsonschema:"required,description=The model type to use for this agent,enum=large,enum=small,default=large"`
// The available tools for the agent
// if this is nil, all tools are available
AllowedTools []string `json:"allowed_tools,omitempty"`
// this tells us which MCPs are available for this agent
// if this is empty all mcps are available
// the string array is the list of tools from the AllowedMCP the agent has available
// if the string array is nil, all tools from the AllowedMCP are available
AllowedMCP map[string][]string `json:"allowed_mcp,omitempty"`
// Overrides the context paths for this agent
ContextPaths []string `json:"context_paths,omitempty"`
}
type Attribution ¶
type Attribution struct {
TrailerStyle TrailerStyle `` /* 169-byte string literal not displayed */
CoAuthoredBy *bool `json:"co_authored_by,omitempty" jsonschema:"description=Deprecated: use trailer_style instead"`
GeneratedWith bool `` /* 138-byte string literal not displayed */
}
func (Attribution) JSONSchemaExtend ¶
func (Attribution) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend marks the co_authored_by field as deprecated in the schema.
type Completions ¶
type Completions struct {
MaxDepth *int `json:"max_depth,omitempty" jsonschema:"description=Maximum depth for the ls tool,default=0,example=10"`
MaxItems *int `` /* 126-byte string literal not displayed */
}
Completions defines options for the completions UI.
func (Completions) Limits ¶
func (c Completions) Limits() (depth, items int)
type Config ¶
type Config struct {
Schema string `json:"$schema,omitempty"`
// We currently only support large/small as values here.
Models map[SelectedModelType]SelectedModel `` /* 162-byte string literal not displayed */
// Recently used models stored in the data directory config.
RecentModels map[SelectedModelType][]SelectedModel `json:"recent_models,omitempty" jsonschema:"-"`
// The providers that are configured
Providers *csync.Map[string, ProviderConfig] `json:"providers,omitempty" jsonschema:"description=AI provider configurations"`
ImageGeneration *ImageGenerationConfig `json:"image_generation,omitempty" jsonschema:"description=Image generation tool configuration"`
TextToSpeech *TextToSpeechConfig `json:"text_to_speech,omitempty" jsonschema:"description=Text-to-speech tool configuration"`
SpeechToText *SpeechToTextConfig `json:"speech_to_text,omitempty" jsonschema:"description=Speech-to-text tool configuration"`
MCP MCPs `json:"mcp,omitempty" jsonschema:"description=Model Context Protocol server configurations"`
LSP LSPs `json:"lsp,omitempty" jsonschema:"description=Language Server Protocol configurations"`
Options *Options `json:"options,omitempty" jsonschema:"description=General application options"`
Permissions *Permissions `json:"permissions,omitempty" jsonschema:"description=Permission settings for tool usage"`
Tools Tools `json:"tools,omitzero" jsonschema:"description=Tool configurations"`
Hooks map[string][]HookConfig `json:"hooks,omitempty" jsonschema:"description=User-defined shell commands that fire on hook events (e.g. PreToolUse)"`
Agents map[string]Agent `json:"-"`
}
Config holds the configuration for Seshat.
func (*Config) EnabledProviders ¶
func (c *Config) EnabledProviders() []ProviderConfig
func (*Config) GetModelByType ¶
func (c *Config) GetModelByType(modelType SelectedModelType) *catwalk.Model
func (*Config) GetProviderForModel ¶
func (c *Config) GetProviderForModel(modelType SelectedModelType) *ProviderConfig
func (*Config) IsConfigured ¶
IsConfigured return true if at least one provider is configured
func (*Config) IsDockerMCPEnabled ¶
IsDockerMCPEnabled checks if Docker MCP is already configured.
func (*Config) LargeModel ¶
func (*Config) SetupAgents ¶
func (c *Config) SetupAgents()
func (*Config) SmallModel ¶
func (*Config) ValidateHooks ¶
ValidateHooks normalizes event names and checks that every configured hook has a command and a syntactically valid matcher regex. Matcher compilation used for matching is owned by hooks.Runner; this function only validates up front so the user sees config errors at load time rather than on the first tool call.
type ConfigStore ¶
type ConfigStore struct {
// contains filtered or unexported fields
}
ConfigStore is the single entry point for all config access. It owns the pure-data Config, runtime state (working directory, resolver, known providers), and persistence to both global and workspace config files.
mu serialises all config file mutations (SetConfigFields, RemoveConfigField, RefreshOAuthToken) to prevent both in-process goroutine races and, together with the shared lock.File, cross-process races on the config file.
reloadMu serialises ReloadFromDisk calls to prevent concurrent reloads from racing on store fields. autoReload uses TryLock on reloadMu to skip redundant reloads when one is already in progress.
func Load ¶
func Load(workingDir, dataDir string, debug bool) (*ConfigStore, error)
Load loads the configuration from the default paths and returns a ConfigStore that owns both the pure-data Config and all runtime state.
func LoadForMCP ¶
func LoadForMCP(workingDir string) (*ConfigStore, error)
LoadForMCP loads a minimal ConfigStore suitable for initializing MCP clients. It skips provider configuration and model selection so it succeeds even when no AI provider is set up.
func NewTestStore ¶
func NewTestStore(cfg *Config, loadedPaths ...string) *ConfigStore
NewTestStore creates a ConfigStore for testing purposes.
func (*ConfigStore) CaptureStalenessSnapshot ¶
func (s *ConfigStore) CaptureStalenessSnapshot(paths []string)
CaptureStalenessSnapshot captures snapshots for the given paths, building the tracked config paths list. Paths are deduplicated and normalized.
func (*ConfigStore) Config ¶
func (s *ConfigStore) Config() *Config
Config returns the pure-data config struct (read-only after load).
func (*ConfigStore) ConfigStaleness ¶
func (s *ConfigStore) ConfigStaleness() StalenessResult
ConfigStaleness checks whether any tracked config files have changed on disk since the last snapshot. Returns dirty=true if any files changed or went missing, along with sorted lists of affected paths. Stat errors are captured in Errors map but still treated as non-existence for dirty detection.
func (*ConfigStore) DisableDockerMCP ¶
func (s *ConfigStore) DisableDockerMCP() error
DisableDockerMCP removes Docker MCP configuration and persists the change.
func (*ConfigStore) EnableDockerMCP ¶
func (s *ConfigStore) EnableDockerMCP() error
EnableDockerMCP adds Docker MCP configuration and persists it.
func (*ConfigStore) HasConfigField ¶
func (s *ConfigStore) HasConfigField(scope Scope, key string) bool
HasConfigField checks whether a key exists in the config file for the given scope.
func (*ConfigStore) ImportCopilot ¶
func (s *ConfigStore) ImportCopilot() (*oauth.Token, bool)
ImportCopilot attempts to import a GitHub Copilot token from disk.
func (*ConfigStore) KnownProviders ¶
func (s *ConfigStore) KnownProviders() []catwalk.Provider
KnownProviders returns the list of known providers.
func (*ConfigStore) LoadedPaths ¶
func (s *ConfigStore) LoadedPaths() []string
LoadedPaths returns the config file paths that were successfully loaded.
func (*ConfigStore) Overrides ¶
func (s *ConfigStore) Overrides() *RuntimeOverrides
Overrides returns the runtime overrides for this store.
func (*ConfigStore) PersistDockerMCPConfig ¶
func (s *ConfigStore) PersistDockerMCPConfig(mcpConfig MCPConfig) error
PersistDockerMCPConfig persists a previously prepared Docker MCP configuration to the global config file.
func (*ConfigStore) PrepareDockerMCPConfig ¶
func (s *ConfigStore) PrepareDockerMCPConfig() (MCPConfig, error)
PrepareDockerMCPConfig validates Docker MCP availability and stages the Docker MCP configuration in memory.
func (*ConfigStore) RefreshOAuthToken ¶
RefreshOAuthToken refreshes the OAuth token for the given provider.
It uses two-phase locking: the pre-check (reading the config file to see if another process already refreshed) happens under the config lock, then the HTTP exchange runs without any lock held, and finally the result is persisted via SetConfigFields (which acquires the lock internally). If the exchange fails — e.g. because another process already rotated the refresh token — the disk is re-checked under lock to recover the other process's token.
func (*ConfigStore) RefreshStalenessSnapshot ¶
func (s *ConfigStore) RefreshStalenessSnapshot() error
RefreshStalenessSnapshot captures fresh snapshots of all tracked config files. Call this after reloading config to clear dirty state.
func (*ConfigStore) ReloadFromDisk ¶
func (s *ConfigStore) ReloadFromDisk(ctx context.Context) error
ReloadFromDisk re-runs the config load/merge flow and updates the in-memory config atomically. It rebuilds the staleness snapshot after successful reload. On failure, the store state is rolled back to its previous state. Concurrent calls are serialised via reloadMu.
func (*ConfigStore) RemoveConfigField ¶
func (s *ConfigStore) RemoveConfigField(scope Scope, key string) error
RemoveConfigField removes a key from the config file for the given scope. After a successful write, it automatically reloads config to keep in-memory state fresh.
The write is protected by an in-process mutex and a cross-process flock.
func (*ConfigStore) Resolve ¶
func (s *ConfigStore) Resolve(key string) (string, error)
Resolve resolves a variable reference using the configured resolver.
func (*ConfigStore) Resolver ¶
func (s *ConfigStore) Resolver() VariableResolver
Resolver returns the variable resolver.
func (*ConfigStore) SetCompactMode ¶
func (s *ConfigStore) SetCompactMode(scope Scope, enabled bool) error
SetCompactMode sets the compact mode setting and persists it.
func (*ConfigStore) SetConfigField ¶
func (s *ConfigStore) SetConfigField(scope Scope, key string, value any) error
SetConfigField sets a key/value pair in the config file for the given scope. After a successful write, it automatically reloads config to keep in-memory state fresh.
func (*ConfigStore) SetConfigFields ¶
func (s *ConfigStore) SetConfigFields(scope Scope, kv map[string]any) error
SetConfigFields sets multiple key/value pairs in the config file for the given scope in a single write. After a successful write, it automatically reloads config to keep in-memory state fresh. This is preferred over multiple SetConfigField calls when writing several fields atomically to avoid intermediate reloads with partial state.
The write is protected by an in-process mutex and a cross-process flock to prevent races between concurrent writers in different processes.
func (*ConfigStore) SetProviderAPIKey ¶
func (s *ConfigStore) SetProviderAPIKey(scope Scope, providerID string, apiKey any) error
SetProviderAPIKey sets the API key for a provider and persists it.
func (*ConfigStore) SetTransparentBackground ¶
func (s *ConfigStore) SetTransparentBackground(scope Scope, enabled bool) error
SetTransparentBackground sets the transparent background setting and persists it.
func (*ConfigStore) SetupAgents ¶
func (s *ConfigStore) SetupAgents()
SetupAgents configures the coder and task agents on the config.
func (*ConfigStore) UpdatePreferredModel ¶
func (s *ConfigStore) UpdatePreferredModel(scope Scope, modelType SelectedModelType, model SelectedModel) error
UpdatePreferredModel updates the preferred model for the given type and persists it to the config file at the given scope.
func (*ConfigStore) WorkingDir ¶
func (s *ConfigStore) WorkingDir() string
WorkingDir returns the current working directory.
type Expander ¶
Expander is the single-value shell expansion seam used by shellVariableResolver. Production wires it to shell.ExpandValue; tests can inject a fake via WithExpander.
type HookConfig ¶
type HookConfig struct {
// Regex pattern tested against the tool name. Empty means match all.
Matcher string `json:"matcher,omitempty" jsonschema:"description=Regex pattern tested against the tool name. Empty means match all tools."`
// Shell command to execute.
Command string `json:"command" jsonschema:"required,description=Shell command to execute when the hook fires"`
// Timeout in seconds. Default 30.
Timeout int `json:"timeout,omitempty" jsonschema:"description=Timeout in seconds for the hook command,default=30"`
}
HookConfig defines a user-configured shell command that fires on a hook event (e.g. PreToolUse). This is a pure-data struct: matcher compilation is owned by hooks.Runner so a JSON round-trip, merge, or reload can't silently drop compiled state.
func (*HookConfig) TimeoutDuration ¶
func (h *HookConfig) TimeoutDuration() time.Duration
TimeoutDuration returns the hook timeout as a time.Duration, defaulting to 30s.
type ImageGenerationConfig ¶
type LSPConfig ¶
type LSPConfig struct {
Disabled bool `json:"disabled,omitempty" jsonschema:"description=Whether this LSP server is disabled,default=false"`
Command string `json:"command,omitempty" jsonschema:"description=Command to execute for the LSP server,example=gopls"`
Args []string `json:"args,omitempty" jsonschema:"description=Arguments to pass to the LSP server command"`
Env map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables to set to the LSP server command"`
FileTypes []string `` /* 152-byte string literal not displayed */
RootMarkers []string `` /* 161-byte string literal not displayed */
InitOptions map[string]any `` /* 128-byte string literal not displayed */
Options map[string]any `json:"options,omitempty" jsonschema:"description=LSP server-specific settings passed during initialization"`
Timeout int `` /* 132-byte string literal not displayed */
}
func (LSPConfig) ResolvedArgs ¶
func (l LSPConfig) ResolvedArgs(r VariableResolver) ([]string, error)
ResolvedArgs returns l.Args with every element expanded through the given resolver. A fresh slice is allocated; l.Args is never mutated. On the first resolution failure it returns nil and an error identifying the offending positional index; the inner resolver error is already sanitized by ResolveValue and is wrapped with %w so errors.Is/As continues to work.
Empty resolved values are kept (a deliberate "empty positional arg" like --flag "" is sometimes valid), matching MCPConfig.ResolvedArgs.
The resolver choice matters: in server mode pass the shell resolver so $VAR / $(cmd) expand; in client mode pass IdentityResolver so the template is forwarded verbatim.
func (LSPConfig) ResolvedEnv ¶
func (l LSPConfig) ResolvedEnv(r VariableResolver) (map[string]string, error)
ResolvedEnv returns l.Env with every value expanded through the given resolver. A fresh map is allocated; l.Env is never mutated. On the first resolution failure it returns nil and an error that identifies the offending key; the inner resolver error is already sanitized by ResolveValue and is wrapped with %w so errors.Is/As continues to work.
Empty resolved values are kept ("FOO=" is a legitimate request; opt out via ${VAR:+...}), matching MCPConfig.ResolvedEnv.
Shape note: this returns map[string]string rather than the []string shape MCPConfig.ResolvedEnv uses because the consumer (powernap.ClientConfig.Environment in internal/lsp/client.go) takes a map directly — returning a []string here would only force a round-trip back to a map at the call site.
See ResolvedArgs for guidance on picking a resolver.
type MCPConfig ¶
type MCPConfig struct {
Command string `json:"command,omitempty" jsonschema:"description=Command to execute for stdio MCP servers,example=npx"`
Env map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables to set for the MCP server"`
Args []string `json:"args,omitempty" jsonschema:"description=Arguments to pass to the MCP server command"`
Type MCPType `json:"type" jsonschema:"required,description=Type of MCP connection,enum=stdio,enum=sse,enum=http,default=stdio"`
URL string `json:"url,omitempty" jsonschema:"description=URL for HTTP or SSE MCP servers,format=uri,example=http://localhost:3000/mcp"`
Disabled bool `json:"disabled,omitempty" jsonschema:"description=Whether this MCP server is disabled,default=false"`
DisabledTools []string `` /* 126-byte string literal not displayed */
EnabledTools []string `json:"enabled_tools,omitempty" jsonschema:"description=Allow list of tools from this MCP server,example=get-library-doc"`
Timeout int `` /* 140-byte string literal not displayed */
// Headers are HTTP headers for HTTP/SSE MCP servers. Values run
// through shell expansion at MCP startup, so $VAR and $(cmd)
// work. A header whose value resolves to the empty string (unset
// bare $VAR under lenient nounset, $(echo), or literal "") is
// omitted from the outgoing request rather than sent as
// "Header:".
Headers map[string]string `json:"headers,omitempty" jsonschema:"description=HTTP headers for HTTP/SSE MCP servers"`
}
func DockerMCPConfig ¶
func DockerMCPConfig() MCPConfig
DockerMCPConfig returns the default Docker MCP stdio configuration.
func (MCPConfig) ResolvedArgs ¶
func (m MCPConfig) ResolvedArgs(r VariableResolver) ([]string, error)
ResolvedArgs returns m.Args with every element expanded through the given resolver. A fresh slice is allocated; m.Args is never mutated. On the first resolution failure it returns nil and an error identifying the offending positional index; the inner resolver error is already sanitized by ResolveValue and is wrapped with %w so errors.Is/As continues to work.
See ResolvedEnv for guidance on picking a resolver.
func (MCPConfig) ResolvedEnv ¶
func (m MCPConfig) ResolvedEnv(r VariableResolver) ([]string, error)
ResolvedEnv returns m.Env with every value expanded through the given resolver. The returned slice is of the form "KEY=value" sorted by key so callers get deterministic output; the receiver's Env map is not mutated. On the first resolution failure it returns nil and an error that identifies the offending key; the inner resolver error is already sanitized by ResolveValue and is wrapped with %w so errors.Is/As continues to work. Callers are expected to surface it (for MCP, via StateError on the status card) rather than silently spawn the server with an empty credential.
The resolver choice matters: in server mode pass the shell resolver so $VAR / $(cmd) expand; in client mode pass IdentityResolver so the template is forwarded verbatim and expansion happens on the server.
func (MCPConfig) ResolvedHeaders ¶
func (m MCPConfig) ResolvedHeaders(r VariableResolver) (map[string]string, error)
ResolvedHeaders returns m.Headers with every value expanded through the given resolver. A fresh map is allocated; m.Headers is never mutated. On the first resolution failure it returns nil and an error identifying the offending header name; the inner resolver error is already sanitized by ResolveValue and is wrapped with %w so errors.Is/As continues to work.
A header whose value resolves to the empty string (unset bare $VAR under lenient nounset, $(echo), or literal "") is omitted from the returned map — sending "X-Auth:" with an empty value is rejected by some providers and the user's intent in "optional, env-gated header" is clearly "absent when the var isn't set."
See ResolvedEnv for guidance on picking a resolver.
func (MCPConfig) ResolvedURL ¶
func (m MCPConfig) ResolvedURL(r VariableResolver) (string, error)
ResolvedURL returns m.URL expanded through the given resolver. The receiver is not mutated. Errors from the resolver are already sanitized by ResolveValue and are wrapped with %w for errors.Is/As.
URLs run through the same shell-expansion pipeline as the other fields, so a literal '$' (e.g. OData query strings containing $filter/$select) must be escaped as '\$' or '${DOLLAR:-$}' to avoid being interpreted as a variable reference. Same constraint already applies to command, args, env, and headers.
See ResolvedEnv for guidance on picking a resolver.
type MCPs ¶
func LoadMCPConfig ¶
LoadMCPConfig reads and normalizes MCPs from config files without running the full provider-configuration pipeline. Safe to call from a workspace that only needs to display MCP state in the UI.
type Options ¶
type Options struct {
ContextPaths []string `` /* 151-byte string literal not displayed */
SkillsPaths []string `` /* 182-byte string literal not displayed */
TUI *TUIOptions `json:"tui,omitempty" jsonschema:"description=Terminal user interface options"`
Debug bool `json:"debug,omitempty" jsonschema:"description=Enable debug logging,default=false"`
DebugLSP bool `json:"debug_lsp,omitempty" jsonschema:"description=Enable debug logging for LSP servers,default=false"`
DisableAutoSummarize bool `json:"disable_auto_summarize,omitempty" jsonschema:"description=Disable automatic conversation summarization,default=false"`
// DataDirectory is where Seshat keeps per-project state such as
// the SQLite database and workspace overrides. Relative paths are
// resolved against the working directory; absolute paths are used
// verbatim. After defaulting the stored value is always absolute.
DataDirectory string `` /* 218-byte string literal not displayed */
DisabledTools []string `` /* 147-byte string literal not displayed */
DisableProviderAutoUpdate bool `json:"disable_provider_auto_update,omitempty" jsonschema:"description=Disable providers auto-update,default=false"`
DisableDefaultProviders bool `` /* 262-byte string literal not displayed */
Attribution *Attribution `json:"attribution,omitempty" jsonschema:"description=Attribution settings for generated content"`
DisableMetrics bool `json:"disable_metrics,omitempty" jsonschema:"description=Disable sending metrics,default=false"`
InitializeAs string `` /* 220-byte string literal not displayed */
AutoLSP *bool `json:"auto_lsp,omitempty" jsonschema:"description=Automatically setup LSPs based on root markers,default=true"`
Progress *bool `json:"progress,omitempty" jsonschema:"description=Show indeterminate progress updates during long operations,default=true"`
DisableNotifications bool `` /* 151-byte string literal not displayed */
NotificationStyle string `` /* 322-byte string literal not displayed */
DisabledSkills []string `` /* 134-byte string literal not displayed */
}
type Permissions ¶
type Permissions struct {
AllowedTools []string `` /* 133-byte string literal not displayed */
}
type ProjectInitFlag ¶
type ProjectInitFlag struct {
Initialized bool `json:"initialized"`
}
type ProviderConfig ¶
type ProviderConfig struct {
// The provider's id.
ID string `json:"id,omitempty" jsonschema:"description=Unique identifier for the provider,example=openai"`
// The provider's name, used for display purposes.
Name string `json:"name,omitempty" jsonschema:"description=Human-readable name for the provider,example=OpenAI"`
// The provider's API endpoint.
BaseURL string `` /* 127-byte string literal not displayed */
// The provider type, e.g. "openai", "anthropic", etc. if empty it defaults to openai.
Type catwalk.Type `` /* 189-byte string literal not displayed */
// The provider's API key.
APIKey string `json:"api_key,omitempty" jsonschema:"description=API key for authentication with the provider,example=$OPENAI_API_KEY"`
// The original API key template before resolution (for re-resolution on auth errors).
APIKeyTemplate string `json:"-"`
// OAuthToken for providers that use OAuth2 authentication.
OAuthToken *oauth.Token `json:"oauth,omitempty" jsonschema:"description=OAuth2 token for authentication with the provider"`
// Marks the provider as disabled.
Disable bool `json:"disable,omitempty" jsonschema:"description=Whether this provider is disabled,default=false"`
// Custom system prompt prefix.
SystemPromptPrefix string `json:"system_prompt_prefix,omitempty" jsonschema:"description=Custom prefix to add to system prompts for this provider"`
// Extra headers to send with each request to the provider. Values
// run through shell expansion at config-load time, so $VAR and
// $(cmd) work the same way they do in MCP headers. A header whose
// value resolves to the empty string (unset bare $VAR under
// lenient nounset, $(echo), or literal "") is omitted from the
// outgoing request rather than sent as "Header:".
ExtraHeaders map[string]string `json:"extra_headers,omitempty" jsonschema:"description=Additional HTTP headers to send with requests"`
// ExtraBody is merged verbatim into OpenAI-compatible request
// bodies. String values are NOT shell-expanded: this is a plain
// JSON passthrough so that arbitrary provider-extension fields
// (numbers, nested objects, booleans) round-trip without a
// recursive walker guessing at intent. If you need an env-var-
// driven value at request time, put it in extra_headers, or in
// the provider's top-level api_key / base_url, all of which do
// expand.
ExtraBody map[string]any `` /* 146-byte string literal not displayed */
ProviderOptions map[string]any `json:"provider_options,omitempty" jsonschema:"description=Additional provider-specific options for this provider"`
// Used to pass extra parameters to the provider.
ExtraParams map[string]string `json:"-"`
// Skip cost accumulation for this provider when using subscription or flat rate billing.
FlatRate bool `json:"flat_rate,omitempty" jsonschema:"description=Flat-rate mode for this provider"`
// The provider models
Models []catwalk.Model `json:"models,omitempty" jsonschema:"description=List of models available from this provider"`
}
func (*ProviderConfig) SetupGitHubCopilot ¶
func (c *ProviderConfig) SetupGitHubCopilot()
func (*ProviderConfig) TestConnection ¶
func (c *ProviderConfig) TestConnection(resolver VariableResolver) error
func (*ProviderConfig) ToProvider ¶
func (c *ProviderConfig) ToProvider() catwalk.Provider
ToProvider converts the ProviderConfig to a catwalk.Provider.
type RuntimeOverrides ¶
type RuntimeOverrides struct {
SkipPermissionRequests bool
}
RuntimeOverrides holds per-session settings that are never persisted to disk. They are applied on top of the loaded Config and survive only for the lifetime of the process (or workspace).
type Scope ¶
type Scope int
Scope determines which config file is targeted for read/write operations.
type SelectedModel ¶
type SelectedModel struct {
// The model id as used by the provider API.
// Required.
Model string `json:"model" jsonschema:"required,description=The model ID as used by the provider API,example=gpt-4o"`
// The model provider, same as the key/id used in the providers config.
// Required.
Provider string `` /* 129-byte string literal not displayed */
// Only used by models that use the openai provider and need this set.
ReasoningEffort string `` /* 146-byte string literal not displayed */
// Used by anthropic models that can reason to indicate if the model should think.
Think bool `json:"think,omitempty" jsonschema:"description=Enable thinking mode for Anthropic models that support reasoning"`
// Overrides the default model configuration.
MaxTokens int64 `json:"max_tokens,omitempty" jsonschema:"description=Maximum number of tokens for model responses,maximum=200000,example=4096"`
Temperature *float64 `json:"temperature,omitempty" jsonschema:"description=Sampling temperature,minimum=0,maximum=1,example=0.7"`
TopP *float64 `json:"top_p,omitempty" jsonschema:"description=Top-p (nucleus) sampling parameter,minimum=0,maximum=1,example=0.9"`
TopK *int64 `json:"top_k,omitempty" jsonschema:"description=Top-k sampling parameter"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty" jsonschema:"description=Frequency penalty to reduce repetition"`
PresencePenalty *float64 `json:"presence_penalty,omitempty" jsonschema:"description=Presence penalty to increase topic diversity"`
// Override provider specific options.
ProviderOptions map[string]any `json:"provider_options,omitempty" jsonschema:"description=Additional provider-specific options for the model"`
}
type SelectedModelType ¶
type SelectedModelType string
const ( SelectedModelTypeLarge SelectedModelType = "large" SelectedModelTypeSmall SelectedModelType = "small" )
func (SelectedModelType) String ¶
func (s SelectedModelType) String() string
String returns the string representation of the SelectedModelType.
type ShellResolverOption ¶
type ShellResolverOption func(*shellVariableResolver)
ShellResolverOption customizes shell variable resolver construction.
func WithExpander ¶
func WithExpander(e Expander) ShellResolverOption
WithExpander overrides the expansion function used by the resolver. Primarily intended for tests; production callers should not need this.
type SpeechToTextConfig ¶
type SpeechToTextConfig struct {
Provider string `json:"provider,omitempty" jsonschema:"description=Provider ID used for speech-to-text,example=openai"`
Model string `json:"model,omitempty" jsonschema:"description=Optional model override for speech-to-text,example=whisper-1"`
Language string `json:"language,omitempty" jsonschema:"description=Optional language hint for speech-to-text,example=en"`
}
type StalenessResult ¶
type StalenessResult struct {
Dirty bool
Changed []string
Missing []string
Errors map[string]error // stat errors by path
}
StalenessResult contains the result of a staleness check.
type TUIOptions ¶
type TUIOptions struct {
CompactMode bool `json:"compact_mode,omitempty" jsonschema:"description=Enable compact mode for the TUI interface,default=false"`
DiffMode string `json:"diff_mode,omitempty" jsonschema:"description=Diff mode for the TUI interface,enum=unified,enum=split"`
VerboseSteps bool `json:"verbose_steps,omitempty" jsonschema:"description=Show full agent step narration between tool calls,default=false"`
Completions Completions `json:"completions,omitzero" jsonschema:"description=Completions UI options"`
Transparent *bool `json:"transparent,omitempty" jsonschema:"description=Enable transparent background for the TUI interface,default=false"`
}
type TextToSpeechConfig ¶
type TextToSpeechConfig struct {
Provider string `json:"provider,omitempty" jsonschema:"description=Provider ID used for text-to-speech,example=openai"`
Model string `json:"model,omitempty" jsonschema:"description=Optional model override for text-to-speech,example=tts-1"`
Voice string `json:"voice,omitempty" jsonschema:"description=Optional voice override for text-to-speech,example=alloy"`
Format string `json:"format,omitempty" jsonschema:"description=Optional output format override for text-to-speech,example=mp3"`
}
type ToolGrep ¶
type ToolGrep struct {
Timeout *time.Duration `json:"timeout,omitempty" jsonschema:"description=Timeout for the grep tool call,default=5s,example=10s"`
}
func (ToolGrep) GetTimeout ¶
GetTimeout returns the user-defined timeout or the default.
type ToolLs ¶
type TrailerStyle ¶
type TrailerStyle string
const ( TrailerStyleNone TrailerStyle = "none" TrailerStyleCoAuthoredBy TrailerStyle = "co-authored-by" TrailerStyleAssistedBy TrailerStyle = "assisted-by" )
type VariableResolver ¶
func IdentityResolver ¶
func IdentityResolver() VariableResolver
IdentityResolver returns a VariableResolver that passes values through unchanged.
func NewShellVariableResolver ¶
func NewShellVariableResolver(e env.Env, opts ...ShellResolverOption) VariableResolver
NewShellVariableResolver returns a VariableResolver that delegates to the embedded shell (the same interpreter used by the bash tool and hooks). Supported constructs match shell.ExpandValue: $VAR, ${VAR}, ${VAR:-default}, $(command), quoting, and escapes. Unset variables expand to the empty string by default, matching bash; use ${VAR:?message} to require a value and fail loudly when it is missing. The stricter "unset is always an error" mode is gated globally by shell.NoUnset.