config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.2.1"

Functions

func ClawPath

func ClawPath() string

ClawPath returns the root directory for framework installations. When CLAW_PATH is set, all framework config/binary paths (e.g., ~/.zeroclaw/config.toml) resolve under CLAW_PATH instead of ~. This enables isolated testing without disturbing real installations.

func CoerceJSONNumbers

func CoerceJSONNumbers(v interface{})

CoerceJSONNumbers recursively walks a value decoded from JSON and converts float64 values that are whole numbers (e.g., 42617.0) to int64 (42617). This prevents the TOML encoder from writing "port = 42617.0" when the original config had "port = 42617".

func ConfigDir

func ConfigDir() (string, error)

func ConfigPath

func ConfigPath() (string, error)

func EnrichedEnv

func EnrichedEnv() []string

EnrichedEnv returns a copy of the current environment with common tool directories prepended to PATH. This ensures exec.Command can find binaries like cargo, go, npm, pip, etc. even when the Eyrie server is started from a non-interactive shell (e.g., launchd, systemd) that doesn't source ~/.bashrc or ~/.zshrc.

func ExpandHome

func ExpandHome(path string) string

ExpandHome replaces a leading ~ with the user's home directory, or with CLAW_PATH if set. This means all framework paths like ~/.zeroclaw/config.toml automatically resolve to $CLAW_PATH/.zeroclaw/config.toml when the env var is present.

func LookPathEnriched

func LookPathEnriched(command string) string

LookPathEnriched resolves a command name against the enriched PATH (the same dirs added by EnrichedEnv). Use this before exec.Command so binaries in ~/go/bin, ~/.cargo/bin, etc. are found even when the Eyrie process's own PATH doesn't include them.

func ParseJSONFile

func ParseJSONFile(path string, target any) error

ParseJSONFile reads and unmarshals a JSON file into the given target.

func ParseTOMLFile

func ParseTOMLFile(path string, target any) error

ParseTOMLFile reads and unmarshals a TOML file into the given target.

func PatchConfigFile

func PatchConfigFile(path string, format string, fields map[string]any) error

PatchConfigFile reads a config file, patches the given dot-path fields, and writes back atomically. Creates the file (with parent dirs) if it doesn't exist. format is "toml", "json", or "yaml".

func Save

func Save(cfg Config) error

Save writes the config to the config file.

func SetNestedValue

func SetNestedValue(m map[string]any, path string, value any) bool

SetNestedValue sets a value at a dot-separated path in a nested map, creating intermediate maps as needed. Returns false if a non-map node blocked the path (e.g., "a.b" where "a" is a string, not a map).

func ValidateRawFormat

func ValidateRawFormat(format, content string) error

ValidateRawFormat checks that a raw config string is syntactically valid for the given format (toml, json, yaml). Returns nil on success.

func WriteConfigAtomic

func WriteConfigAtomic(path string, format string, data interface{}) error

WriteConfigAtomic writes config file atomically based on format

func WriteJSONAtomic

func WriteJSONAtomic(path string, data interface{}) error

WriteJSONAtomic writes JSON config atomically using temp file + rename

func WriteRawAtomic

func WriteRawAtomic(path string, content string) error

WriteRawAtomic writes a raw string to a file atomically. Used when the config is already in its target format (e.g., raw TOML text from the editor) and should be preserved as-is without re-encoding.

func WriteTOMLAtomic

func WriteTOMLAtomic(path string, data interface{}) error

WriteTOMLAtomic writes TOML config atomically using temp file + rename

func WriteYAMLAtomic

func WriteYAMLAtomic(path string, data interface{}) error

WriteYAMLAtomic writes YAML config atomically using temp file + rename

Types

type Config

type Config struct {
	Dashboard DashboardConfig `toml:"dashboard"`
	Discovery DiscoveryConfig `toml:"discovery"`
	Agents    []ManualAgent   `toml:"agents"`
}

func DefaultConfig

func DefaultConfig() Config

func Load

func Load() (Config, error)

type DashboardConfig

type DashboardConfig struct {
	Port        int    `toml:"port"`
	Host        string `toml:"host"`
	OpenBrowser bool   `toml:"open_browser"`
}

type DiscoveryConfig

type DiscoveryConfig struct {
	IntervalSeconds int      `toml:"interval_seconds"`
	ConfigPaths     []string `toml:"config_paths"`
}

type HiddenStore

type HiddenStore struct {
	// contains filtered or unexported fields
}

HiddenStore persists hidden session keys per agent. Stored in ~/.eyrie/hidden_sessions.json with mode 0600.

func NewHiddenStore

func NewHiddenStore() (*HiddenStore, error)

func (*HiddenStore) Hide

func (hs *HiddenStore) Hide(agentName, sessionKey string) error

func (*HiddenStore) IsHidden

func (hs *HiddenStore) IsHidden(agentName, sessionKey string) bool

func (*HiddenStore) Unhide

func (hs *HiddenStore) Unhide(agentName, sessionKey string) error

type KeyVault

type KeyVault struct {
	// contains filtered or unexported fields
}

KeyVault centralizes API key management across all agent frameworks. Keys are stored in ~/.eyrie/keys.json with mode 0600. Environment variables take precedence over the on-disk store (e.g. ANTHROPIC_API_KEY overrides the "anthropic" key). Follows the TokenStore pattern exactly.

func GetKeyVault

func GetKeyVault() *KeyVault

GetKeyVault returns the process-wide KeyVault singleton, creating it on first call. Safe to call from any goroutine.

func NewKeyVault

func NewKeyVault() (*KeyVault, error)

func (*KeyVault) Delete

func (v *KeyVault) Delete(provider string) error

Delete removes an API key for the given provider and saves. On save() failure the key is restored so memory doesn't diverge from disk.

func (*KeyVault) EnvSlice

func (v *KeyVault) EnvSlice() []string

EnvSlice builds environment variable assignments for all stored keys using the provider-to-envvar mapping. Unknown providers are skipped because we don't know which env var the framework expects.

func (*KeyVault) Get

func (v *KeyVault) Get(provider string) string

Get returns the API key for the given provider. Environment variable takes precedence: the vault checks the provider's mapped env var (from providerEnvMap, consistent with EnvSlice) before falling back to <PROVIDER>_API_KEY (uppercased), then the on-disk store.

func (*KeyVault) List

func (v *KeyVault) List() map[string]string

List returns a copy of all stored keys (not env vars).

func (*KeyVault) Set

func (v *KeyVault) Set(provider, key string) error

Set stores an API key for the given provider and saves atomically. On save() failure the in-memory map is rolled back so it stays consistent with what actually made it to disk.

func (*KeyVault) ValidateKey

func (v *KeyVault) ValidateKey(ctx context.Context, provider, key string) error

ValidateKey probes the provider's API to check if the key is valid. Returns nil for unknown or local providers (ollama, custom) — they pass without validation. Uses a 5-second timeout.

type ManualAgent

type ManualAgent struct {
	Name      string `toml:"name"`
	Framework string `toml:"framework"`
	URL       string `toml:"url"`
	Token     string `toml:"token,omitempty"`
}

type TokenStore

type TokenStore struct {
	// contains filtered or unexported fields
}

TokenStore persists bearer tokens keyed by agent name. Tokens are stored in ~/.eyrie/tokens.json with mode 0600.

func NewTokenStore

func NewTokenStore() (*TokenStore, error)

func (*TokenStore) Get

func (ts *TokenStore) Get(agentName string) string

func (*TokenStore) Set

func (ts *TokenStore) Set(agentName, token string) error

Jump to

Keyboard shortcuts

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