config

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HelpText string

Functions

func ConfigBaseDir

func ConfigBaseDir() string

ConfigBaseDir returns the base config directory (parent of tools.d/).

func LoadAll

func LoadAll(embeddedDefaults ...map[string]string) ([]ConfigTool, *GlobalConfig, []error)

LoadAll loads configs from all search directories (first match wins per name), then merges embedded defaults (lowest priority). Also loads the global config.

func SearchDirs

func SearchDirs() []string

SearchDirs returns the directories to search for tool config files. When AGENT_CALLABLE_CONFIG_DIR is set, only that directory is used (exclusive override).

Types

type AuditConfig

type AuditConfig struct {
	File               string `toml:"file"`                 // path to the audit log file (empty = disabled)
	Mode               string `toml:"mode"`                 // "blocked", "allowed", "all" (default: "all")
	MaxEntries         int    `toml:"max_entries"`          // max log lines kept (0 = unlimited)
	MaskSecrets        bool   `toml:"mask_secrets"`         // mask sensitive values in logged commands
	IncludeAuditChecks bool   `toml:"include_audit_checks"` // log --audit and --claude dry-run checks
}

AuditConfig configures the audit trail.

type ConfigTool

type ConfigTool struct {
	ToolConfig
	AllowAll bool // true when allowed = ["*"]
}

ConfigTool is the internal representation after loading.

func LoadDir

func LoadDir(dir string) ([]ConfigTool, []error)

LoadDir loads all .toml files from a directory. Each file defines tools as [toolname] sections.

func ParseTOML

func ParseTOML(content string) ([]ConfigTool, error)

ParseTOML parses a TOML string into ConfigTools.

func (ConfigTool) ToToolSpec

func (ct ConfigTool) ToToolSpec(writableDirs []string) *spec.ConfigToolSpec

ToToolSpec converts a ConfigTool to a spec.ToolSpec. writableDirs is passed from GlobalConfig for write_target checking.

type GlobalConfig

type GlobalConfig struct {
	WritableDirs []string        `toml:"writable_dirs"`
	AllowOnAny   []string        `toml:"allow_on_any"`
	Audit        AuditConfig     `toml:"audit"`
	Builtins     map[string]bool `toml:"builtins"`
}

GlobalConfig is loaded from config.toml (not tools.d/).

func LoadGlobalConfig

func LoadGlobalConfig() (*GlobalConfig, error)

LoadGlobalConfig loads config.toml from the base config directory.

type ToolConfig

type ToolConfig struct {
	Name           string              `toml:"name"`
	Mode           string              `toml:"mode"`
	Allowed        []string            `toml:"allowed"`
	Subcommands    map[string][]string `toml:"subcommands"`
	Env            map[string]string   `toml:"env"`
	FlagsWithValue []string            `toml:"flags_with_value"`
	WriteTarget    string              `toml:"write_target"`
	WriteFlags     []string            `toml:"write_flags"`
	DeniedFlags    []string            `toml:"denied_flags"`
}

ToolConfig represents a tool section in a TOML config file. The Name field is set from the TOML section key, not from the file content.

func (*ToolConfig) Validate

func (c *ToolConfig) Validate() error

Validate checks a ToolConfig for structural correctness.

Jump to

Keyboard shortcuts

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