Documentation
¶
Overview ¶
Package config loads spackle.toml and merges it with defaults. Flags are applied on top by the CLI. API keys are never read from config or flags: config only names the environment variable that holds one.
Index ¶
Constants ¶
const ( ProviderAnthropic = "anthropic" ProviderOpenAI = "openai" ProviderOpenAICompatible = "openai-compatible" ProviderOllama = "ollama" )
Provider names.
const DefaultFile = "spackle.toml"
DefaultFile is the config file looked up in the working directory.
Variables ¶
var Stages = []string{"planner", "investigator", "prover", "reviewer", "fixer", "mechanical"}
Stages lists the pipeline stages that can have their own model.
Functions ¶
func DefaultKeyEnv ¶
DefaultKeyEnv returns the conventional API key variable for a provider.
Types ¶
type Budget ¶
type Budget struct {
Tokens int `toml:"tokens"`
USD float64 `toml:"usd"`
WallTime Duration `toml:"wall_time"`
SandboxRuns int `toml:"sandbox_runs"`
MaxFindings int `toml:"max_findings"`
// MaxTurns caps tool-use turns for one agent task.
MaxTurns int `toml:"max_turns"`
}
Budget holds the hard caps of a run. Zero means "use the default"; caps cannot be turned off.
type Config ¶
type Config struct {
Model Model `toml:"model"`
Stages map[string]Model `toml:"stages"`
Budget Budget `toml:"budget"`
Scope Scope `toml:"scope"`
Sandbox Sandbox `toml:"sandbox"`
Fix Fix `toml:"fix"`
Output Output `toml:"output"`
Pricing map[string]Price `toml:"pricing"`
Offline bool `toml:"offline"`
// StateDir is where runs and caches are stored.
StateDir string `toml:"state_dir"`
}
Config is the whole configuration.
func Load ¶
Load reads the config file at path over the defaults. When path is empty it looks for spackle.toml in the working directory and returns the defaults if there is none. The second result is the file that was read, or "" when none was.
type Duration ¶
Duration parses TOML strings such as "30m".
func (*Duration) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Fix ¶
type Fix struct {
Enabled *bool `toml:"enabled"`
MaxAttempts int `toml:"max_attempts"`
// PR pushes the fix branch and opens a pull request.
PR bool `toml:"pr"`
}
Fix configures the fixer.
type Model ¶
type Model struct {
Provider string `toml:"provider"`
Model string `toml:"model"`
BaseURL string `toml:"base_url"`
// APIKeyEnv names the environment variable holding the API key.
APIKeyEnv string `toml:"api_key_env"`
// MaxOutputTokens caps one completion.
MaxOutputTokens int `toml:"max_output_tokens"`
}
Model selects a provider and model.
func (Model) Configured ¶
Configured reports whether a provider has been chosen.
type Output ¶
type Output struct {
Formats []string `toml:"formats"`
Dir string `toml:"dir"`
// FailOn is the lowest severity that makes scan exit 1.
FailOn string `toml:"fail_on"`
}
Output configures reports.
type Price ¶
type Price struct {
InputPerMTok float64 `toml:"input_per_mtok"`
OutputPerMTok float64 `toml:"output_per_mtok"`
}
Price is the cost of a model per million tokens, in USD.
type Sandbox ¶
type Sandbox struct {
Runtime string `toml:"runtime"` // auto|docker|podman|none
Network string `toml:"network"` // none, or scope to let a proof reach an authorized running target
MemoryMB int `toml:"memory_mb"`
CPUs float64 `toml:"cpus"`
PIDs int `toml:"pids"`
Timeout Duration `toml:"timeout"`
Images map[string]string `toml:"images"`
}
Sandbox configures the container runtime.
type Scope ¶
type Scope struct {
// Hosts lists authorized hosts as host or host:port.
Hosts []string `toml:"hosts"`
PathPrefixes []string `toml:"path_prefixes"`
// AllowUnsafeMethods permits POST, PUT, PATCH and DELETE probes.
AllowUnsafeMethods bool `toml:"allow_unsafe_methods"`
MaxRequests int `toml:"max_requests"`
RequestsPerSecond float64 `toml:"requests_per_second"`
// Statement is the operator's own note on why they are authorized,
// recorded in the ledger.
Statement string `toml:"statement"`
}
Scope is the authorized scope for live targets.