config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package validator provides config validation utilities.

Index

Constants

View Source
const (
	ProviderZAIPayg   = "zai_payg"
	ProviderZAICoding = "zai_coding"
)
View Source
const ProviderXiaomiTokenPlan = "xiaomi_mimo_token_plan"

Variables

This section is empty.

Functions

func APIKeyForProvider

func APIKeyForProvider(provider string) string

APIKeyForProvider reads the API key for a provider from the OS secret store.

func ActiveGateway

func ActiveGateway(ctx context.Context) string

ActiveGateway returns the user's setup gateway (never an aggregator owner slug like moonshotai).

func ActiveModel

func ActiveModel(ctx context.Context) string

ActiveModel returns the selected model from eyrie provider.json (not hawk settings).

func ActiveProvider

func ActiveProvider(ctx context.Context) string

ActiveProvider returns the selected provider from eyrie provider.json.

func AllCanonicalModelIDs

func AllCanonicalModelIDs() []string

AllCanonicalModelIDs returns sorted canonical model IDs from the eyrie catalog.

func AllCatalogProviders

func AllCatalogProviders() []string

AllCatalogProviders returns provider IDs from eyrie (providers + deployments, not hawk constants).

func AllEnvKeyStatus

func AllEnvKeyStatus() string

AllEnvKeyStatus returns a comma-separated summary of providers with credentials set.

func AllSetupGateways

func AllSetupGateways() []string

AllSetupGateways returns gateway IDs where users paste API keys (eyrie registry only). Aggregator owner slugs from OpenRouter/CanopyWave catalogs (ai21, alibaba, …) are excluded.

func ApplyEyrieCredentials

func ApplyEyrieCredentials(ctx context.Context) (*setup.ApplyCredentialsResult, error)

ApplyEyrieCredentials discovers the catalog and writes provider.json (routing only on disk).

func ApplyEyrieCredentialsForProvider

func ApplyEyrieCredentialsForProvider(ctx context.Context, providerID string) (*setup.ApplyCredentialsResult, error)

ApplyEyrieCredentialsForProvider refreshes live models for one provider after /config saves a key.

func ApplyXiaomiTokenPlanRegionEnv

func ApplyXiaomiTokenPlanRegionEnv(ctx context.Context)

ApplyXiaomiTokenPlanRegionEnv sets process env from provider.json before credential probe.

func ApplyZAIRegionEnv

func ApplyZAIRegionEnv(ctx context.Context)

ApplyZAIRegionEnv sets process envs from provider.json before probe/fetch/chat.

func AutoRefreshCatalog

func AutoRefreshCatalog(ctx context.Context, out io.Writer, verbose bool) error

AutoRefreshCatalog runs eyrie discover (remote + live APIs when keys are set).

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to the given bool value.

func BuildContext

func BuildContext() string

BuildContext assembles the full context string for the system prompt.

func BuildContextWithDirs

func BuildContextWithDirs(addDirs []string) string

BuildContextWithDirs assembles context including additional user-specified directories.

func CachedModelCountForProvider

func CachedModelCountForProvider(provider string) int

CachedModelCountForProvider returns model count from the on-disk catalog only (no network).

func CatalogCachePathForDisplay

func CatalogCachePathForDisplay() string

CatalogCachePathForDisplay returns the path users should care about.

func CatalogEmptyHint

func CatalogEmptyHint(ctx context.Context) string

CatalogEmptyHint returns actionable guidance when the catalog has no models.

func CatalogReady

func CatalogReady(ctx context.Context) bool

CatalogReady reports whether the eyrie catalog cache exists and has models.

func CatalogStatusLine

func CatalogStatusLine(ctx context.Context) string

CatalogStatusLine returns a short one-line status for the TUI welcome banner.

func CheapestModelForProvider

func CheapestModelForProvider(provider, fallback string) string

CheapestModelForProvider picks the lowest input-priced model from eyrie's catalog.

func ClearActiveSelection

func ClearActiveSelection(ctx context.Context) error

ClearActiveSelection removes persisted provider/model from provider.json.

func CompiledCatalogV1

func CompiledCatalogV1() *catalog.CompiledCatalogV1

CompiledCatalogV1 loads the eyrie catalog from cache or bootstrap wiring (no network).

func ConfigProviderList

func ConfigProviderList(custom []CustomProviderConfig) []string

ConfigProviderList returns provider names for the /config UI from catalog + custom providers.

func ConfiguredCredentialProviders

func ConfiguredCredentialProviders() []string

ConfiguredCredentialProviders returns setup gateways with a stored API key.

func DefaultModelForProvider

func DefaultModelForProvider(provider string) string

func DefaultModelProviderFilter

func DefaultModelProviderFilter(ctx context.Context) string

DefaultModelProviderFilter picks which eyrie provider to list models for when the UI has no explicit filter. Host prefs (settings) win; otherwise eyrie routing/deployments decide.

func DeploymentRoutingEnabled

func DeploymentRoutingEnabled(s Settings) bool

DeploymentRoutingEnabled decides whether hawk uses catalog-backed deployment routing (same rules as eyrie CLI). HAWK_DEPLOYMENT_ROUTING overrides; otherwise settings flag, otherwise provider.json shape via eyrie/setup.

func DeploymentRoutingLabel

func DeploymentRoutingLabel(settings Settings) string

DeploymentRoutingLabel returns a short on/off label for the config hub.

func DeploymentStatusReport

func DeploymentStatusReport(ctx context.Context, activeModel string) (string, error)

DeploymentStatusReport returns hawk deployment routing diagnostics.

func DiscoverCatalogAfterSetup

func DiscoverCatalogAfterSetup(ctx context.Context, out io.Writer)

DiscoverCatalogAfterSetup runs during optional hawk setup after API keys are saved.

func EnsureCatalogAvailable

func EnsureCatalogAvailable(ctx context.Context) error

EnsureCatalogAvailable returns an error when the production catalog cache is missing or empty.

func EnvKeyStatus

func EnvKeyStatus(provider string) string

EnvKeyStatus returns set, empty, or local from the OS credential store.

func ExampleModelHints

func ExampleModelHints() (anthropic, openai string)

ExampleModelHints returns short example model aliases for user-facing error messages.

func FetchModelsForProvider

func FetchModelsForProvider(provider string) ([]catalog.ModelCatalogEntry, error)

FetchModelsForProvider returns models from the eyrie catalog (dynamic; no hawk hardcoded lists). RefreshModelCatalogV1 is the explicit network refresh boundary.

func FirstRunSetupHint

func FirstRunSetupHint(ctx context.Context) string

FirstRunSetupHint returns a short banner line for the welcome screen.

func FormatApplyCredentialsSummary

func FormatApplyCredentialsSummary(result *setup.ApplyCredentialsResult) string

func FormatCatalogHealth

func FormatCatalogHealth(h CatalogHealth) string

FormatCatalogHealth returns human-readable catalog status for hawk doctor.

func FormatConfigProviderError

func FormatConfigProviderError(providerID string, err error) string

FormatConfigProviderError maps eyrie setup errors to user-facing /config hints.

func FormatCredentialCLIStatus

func FormatCredentialCLIStatus(ctx context.Context) string

FormatCredentialCLIStatus returns hawk credentials status output (providers, not raw env names).

func FormatDeveloperPathReport

func FormatDeveloperPathReport(ctx context.Context) string

FormatDeveloperPathReport renders the developer path readiness report for CLI/TUI.

func FormatEcosystemPanel

func FormatEcosystemPanel(ctx context.Context, provider, model string) string

FormatEcosystemPanel summarizes eyrie, yaad, and tok integration for doctor and status output.

func GatewayDisplayName

func GatewayDisplayName(gatewayID string) string

func GatewayForModel

func GatewayForModel(modelID string) string

GatewayForModel resolves the setup gateway for a model id.

func Getenv

func Getenv(key string) string

Getenv returns the value of an environment variable. Delegates to internal/env to avoid import cycles for callers in packages that already import internal/config.

func GitContext

func GitContext() string

GitContext returns git info for the system prompt.

func HasConfiguredDeployment

func HasConfiguredDeployment(ctx context.Context) bool

HasConfiguredDeployment reports whether at least one eyrie deployment has credentials.

func HasConfiguredDeploymentCached

func HasConfiguredDeploymentCached(ctx context.Context) bool

HasConfiguredDeploymentCached is a fast cached check for the /config TUI only.

func HasSelectedModel

func HasSelectedModel() bool

HasSelectedModel reports whether eyrie provider.json has a selected model.

func HasStoredCredentialForProvider

func HasStoredCredentialForProvider(ctx context.Context, providerID string) bool

HasStoredCredentialForProvider reports whether the OS secret store has a key for this gateway.

func InvalidateCatalogHealthCache

func InvalidateCatalogHealthCache()

InvalidateCatalogHealthCache drops cached catalog health (after refresh).

func InvalidateConfigUICache

func InvalidateConfigUICache()

InvalidateConfigUICache drops in-memory catalog and credential snapshots (call after refresh/key changes).

func IsMinimalMode

func IsMinimalMode(s Settings) bool

IsMinimalMode reports whether minimal mode is enabled in the settings.

func IsSetupGateway

func IsSetupGateway(providerID string) bool

IsSetupGateway reports whether id is a registered setup gateway.

func LoadAPIKeysFromStore

func LoadAPIKeysFromStore() map[string]string

LoadAPIKeysFromStore reads API keys for all eyrie catalog providers from the OS secret store.

func LoadAgentDir

func LoadAgentDir() string

LoadAgentDir returns the path to .agent/ if it exists.

func LoadAgentsMD

func LoadAgentsMD() string

LoadAgentsMD reads AGENTS.md from the current directory or parents.

func LoadAgentsMDFrom

func LoadAgentsMDFrom(start string) string

LoadAgentsMDFrom reads AGENTS.md from start or its parents.

func MaskCredentialForProvider

func MaskCredentialForProvider(ctx context.Context, provider string) string

MaskCredentialForProvider returns a partially masked API key for UI display.

func MigrateProviderConfig

func MigrateProviderConfig() error

MigrateProviderConfig upgrades ~/.hawk/provider.json to deployment v2 in place.

func MigrateProviderSecrets

func MigrateProviderSecrets() error

MigrateProviderSecrets strips api keys from on-disk provider.json (one-time hygiene).

func ModelIDsForProvider

func ModelIDsForProvider(provider string) ([]string, error)

func NeedsFirstRunSetup

func NeedsFirstRunSetup(ctx context.Context) bool

NeedsFirstRunSetup is true when the user should complete /config (API key and/or model).

func NeedsXiaomiTokenPlanRegion

func NeedsXiaomiTokenPlanRegion(providerID string) bool

NeedsXiaomiTokenPlanRegion reports whether the Token Plan gateway still needs a cluster pick.

func NeedsZAIRegion

func NeedsZAIRegion(providerID string) bool

NeedsZAIRegion reports whether the Z.AI gateway still needs a region pick for the chosen plan.

func NormalizeProviderForEngine

func NormalizeProviderForEngine(provider string) string

NormalizeProviderForEngine maps hawk provider aliases to eyrie canonical names. This is the boundary where hawk names become engine/eyrie names.

func ParseEnvFile

func ParseEnvFile(path string) (map[string]string, error)

ParseEnvFile parses a .env file and returns a map of key-value pairs. Supports: KEY=value, KEY="quoted value", KEY='single quoted', comments (#), empty lines, export prefix, and multiline values with \.

func PersistAPIKey

func PersistAPIKey(ctx context.Context, envKey, secret string) error

PersistAPIKey saves a provider API key via eyrie (OS secret store).

func PrepareCatalogForSession

func PrepareCatalogForSession(ctx context.Context, out io.Writer, opts CatalogStartupOptions) error

PrepareCatalogForSession ensures a usable, fresh catalog before chat/print. By default hawk auto-discovers when the cache is missing, empty, or stale.

func PrepareCredentialDiscovery

func PrepareCredentialDiscovery(ctx context.Context)

PrepareCredentialDiscovery prepares runtime credential discovery without reading legacy files.

func PrimaryAPIKeyEnvForDeployment

func PrimaryAPIKeyEnvForDeployment(deploymentID string) string

PrimaryAPIKeyEnvForDeployment returns the env var name for a deployment's API key.

func ProviderAPIKeyEnv

func ProviderAPIKeyEnv(provider string) string

ProviderAPIKeyEnv returns the API key env var for a provider (registry first for setup gateways).

func ProviderIDForDeployment

func ProviderIDForDeployment(deploymentID string) string

ProviderIDForDeployment returns the catalog provider id for a deployment (e.g. anthropic-direct → anthropic).

func ProviderOfModel

func ProviderOfModel(modelName string) string

ProviderOfModel resolves catalog provider for a canonical model ID or alias.

func RefreshCatalogAfterCredentials

func RefreshCatalogAfterCredentials(ctx context.Context, out io.Writer) error

RefreshCatalogAfterCredentials runs eyrie discover after /config saves API keys.

func RefreshConfigCredSnapshot

func RefreshConfigCredSnapshot(ctx context.Context)

RefreshConfigCredSnapshot re-reads keychain status for setup gateways (call when opening /config).

func RefreshGatewayCatalog

func RefreshGatewayCatalog(ctx context.Context, providerID string) (string, error)

RefreshGatewayCatalog fetches live models for one gateway and updates the cache.

func RefreshModelCatalogV1

func RefreshModelCatalogV1(ctx context.Context) (string, error)

RefreshModelCatalogV1 asks eyrie to refresh the remote catalog and provider APIs using env API keys.

func RemoveStoredCredential

func RemoveStoredCredential(ctx context.Context, target string) ([]string, error)

RemoveStoredCredential deletes stored API key(s) for a provider name or env var.

func ResolveCanonicalModel

func ResolveCanonicalModel(model string) string

ResolveCanonicalModel maps aliases and native IDs to catalog canonical model IDs.

func RoutingPreviewJSON

func RoutingPreviewJSON(ctx context.Context, model string) (string, error)

RoutingPreviewJSON returns effective routing for a model (eyrie routing JSON preview).

func SaveCredential

func SaveCredential(ctx context.Context, inference CredentialInference, secret string) error

SaveCredential validates, probes, and stores via eyrie keychain.

func SaveGlobal

func SaveGlobal(s Settings) error

SaveGlobal saves settings to the global config file.

func SaveProjectOrGlobalDeploymentRouting

func SaveProjectOrGlobalDeploymentRouting(enabled bool) error

SaveProjectOrGlobalDeploymentRouting persists the flag to user settings.

func ScheduleBackgroundCatalogRefresh

func ScheduleBackgroundCatalogRefresh(ctx context.Context)

ScheduleBackgroundCatalogRefresh silently refreshes the catalog when it is already stale, or after StaleAfter passes during a long interactive session.

func SetActiveModel

func SetActiveModel(ctx context.Context, modelID string) error

SetActiveModel persists model selection to eyrie provider.json.

func SetActiveProvider

func SetActiveProvider(ctx context.Context, provider string) error

SetActiveProvider persists provider selection to eyrie provider.json.

func SetGlobalSetting

func SetGlobalSetting(key, value string) error

SetGlobalSetting updates a supported scalar/list setting in Hawk user config. Hawk: API keys are NOT stored in settings.json. Use /config and the OS secret store.

func SetXiaomiTokenPlanRegion

func SetXiaomiTokenPlanRegion(region string) error

SetXiaomiTokenPlanRegion persists region (cn, sgp, ams) and syncs env for probe/discovery.

func SetZAIRegion

func SetZAIRegion(providerID, region string) error

SetZAIRegion persists the region (international or cn) for the given Z.AI gateway and syncs env + derived base.

func SettingValue

func SettingValue(s Settings, key string) (string, bool)

SettingValue returns a display-safe value for a supported setting key.

func SetupGatewayCredentialEnv

func SetupGatewayCredentialEnv(providerID string) string

SetupGatewayCredentialEnv returns the registry env var for a setup gateway (e.g. XIAOMI_MIMO_PAYG_API_KEY).

func ShouldClearSelectionAfterCredentialRemove

func ShouldClearSelectionAfterCredentialRemove(ctx context.Context, removedProvider string) bool

ShouldClearSelectionAfterCredentialRemove reports whether provider/model should reset.

func StartupCatalogPrefetch

func StartupCatalogPrefetch(ctx context.Context)

StartupCatalogPrefetch refreshes the catalog in the background when the cache needs it.

func SyncSelectionWithCredentials

func SyncSelectionWithCredentials(ctx context.Context)

SyncSelectionWithCredentials clears stale provider/model when keys are missing.

func TryAutoRefreshCatalog

func TryAutoRefreshCatalog(ctx context.Context) error

TryAutoRefreshCatalog refreshes once when the cache cannot be read (e.g. mid-session).

func XiaomiTokenPlanRegionLabel

func XiaomiTokenPlanRegionLabel() string

XiaomiTokenPlanRegionLabel returns the saved cluster id for UI (cn, sgp, ams) or "" if unset.

func ZAIRegionLabel

func ZAIRegionLabel(providerID string) string

ZAIRegionLabel returns the saved region label or "".

Types

type Attribution

type Attribution = types.Attribution

Attribution controls how hawk identifies itself in git commits.

type CatalogHealth

type CatalogHealth struct {
	CachePath   string
	Exists      bool
	Modified    time.Time
	SizeBytes   int64
	Models      int
	Deployments int
	Offerings   int
	Stale       bool
	StaleAfter  time.Time
	Source      string
	Error       string
}

CatalogHealth summarizes the on-disk eyrie model catalog for doctor / status output.

func CatalogHealthReport

func CatalogHealthReport(ctx context.Context) CatalogHealth

CatalogHealthReport inspects ~/.eyrie/model_catalog.json (or EYRIE_MODEL_CATALOG_PATH).

type CatalogStartupOptions

type CatalogStartupOptions struct {
	ForceRefresh    bool
	SkipAutoRefresh bool
	VerboseOutput   bool // full DiscoverReport; default is one line
}

CatalogStartupOptions controls automatic catalog refresh at hawk startup.

type CredentialInference

type CredentialInference struct {
	ProviderID   string
	DeploymentID string
	EnvVar       string
	DisplayName  string
}

CredentialInference is one eyrie provider match for a pasted API key.

func CredentialInferenceForProvider

func CredentialInferenceForProvider(providerID string) (CredentialInference, error)

CredentialInferenceForProvider returns save metadata for a gateway chosen in /config.

func InferCredentialsFromAPIKey

func InferCredentialsFromAPIKey(ctx context.Context, secret string) []CredentialInference

InferCredentialsFromAPIKey is deprecated; select gateway first, then paste the key.

func InferenceFromOption

func InferenceFromOption(opt CredentialProviderOption) CredentialInference

InferenceFromOption converts a provider picker row to persistence metadata.

func LocalCredentialInference

func LocalCredentialInference(providerID string) (CredentialInference, error)

LocalCredentialInference returns setup metadata for no-key providers (e.g. Ollama).

type CredentialProviderOption

type CredentialProviderOption struct {
	ProviderID   string
	DeploymentID string
	EnvVar       string
	DisplayName  string
	Inferred     bool
	RequiresKey  bool
	Rank         int
}

CredentialProviderOption is one eyrie provider row for /config pickers.

type CredentialResolveResult

type CredentialResolveResult struct {
	FormatOK                bool
	FormatError             string
	Providers               []CredentialProviderOption
	ProbeDisambiguationUsed bool
}

CredentialResolveResult is eyrie paste-key resolution (format check + full provider list; no prefix inference).

func ResolveCredential

func ResolveCredential(ctx context.Context, secret string) CredentialResolveResult

ResolveCredential validates format and lists all providers from eyrie registry.

type CustomProviderConfig

type CustomProviderConfig struct {
	Name      string `json:"name"`
	BaseURL   string `json:"base_url"`
	APIKeyEnv string `json:"api_key_env,omitempty"`
	Model     string `json:"model,omitempty"`
}

CustomProviderConfig defines a user-specified OpenAI-compatible provider.

type DeveloperPathReport

type DeveloperPathReport struct {
	Checks      []PathCheck
	ChatReady   bool
	SecureReady bool
	Ready       bool
	NextStep    string
}

DeveloperPathReport summarizes developer readiness (setup, security, sandbox, ecosystem).

func EvaluateDeveloperPath

func EvaluateDeveloperPath(ctx context.Context) DeveloperPathReport

EvaluateDeveloperPath builds the developer path readiness report.

type EnvManager

type EnvManager struct {
	Vars          map[string]*EnvVar  `json:"vars"`
	Profiles      map[string][]string `json:"profiles"`
	ActiveProfile string              `json:"active_profile"`
	// contains filtered or unexported fields
}

EnvManager manages environment variables, profiles, and secrets.

func NewEnvManager

func NewEnvManager() *EnvManager

NewEnvManager creates a new EnvManager with initialized maps.

func (*EnvManager) Diff

func (em *EnvManager) Diff(other *EnvManager) []string

Diff returns a list of differences between this EnvManager and another.

func (*EnvManager) Export

func (em *EnvManager) Export(format string) string

Export returns the environment variables in the specified format. Supported formats: "env" (KEY=value), "json" (JSON object), "shell" (export KEY=value).

func (*EnvManager) Get

func (em *EnvManager) Get(key string) string

Get returns the value of an environment variable, or empty string if not found.

func (*EnvManager) GetRequired

func (em *EnvManager) GetRequired(key string) (string, error)

GetRequired returns the value of a required environment variable. Returns an error if the variable is not set or is empty.

func (*EnvManager) ListForDisplay

func (em *EnvManager) ListForDisplay() string

ListForDisplay returns a formatted string showing all environment variables. Secret values are partially masked; the source is displayed for each variable.

func (*EnvManager) Load

func (em *EnvManager) Load(sources ...string) error

Load reads environment variables from explicit file sources when provided. By default only the OS environment is used — API keys are not loaded from .env files.

func (*EnvManager) LoadProfile

func (em *EnvManager) LoadProfile(name string) error

LoadProfile activates a named profile, setting its variables as active.

func (*EnvManager) MaskSecrets

func (em *EnvManager) MaskSecrets(text string) string

MaskSecrets replaces known secret values in the given text with "***".

func (*EnvManager) SaveProfile

func (em *EnvManager) SaveProfile(name string, vars []string) error

SaveProfile saves a named profile with the given list of variable keys.

func (*EnvManager) Set

func (em *EnvManager) Set(key, value string, secret bool)

Set sets an environment variable with the given key and value. If secret is true, the value will be masked in display output.

func (*EnvManager) Validate

func (em *EnvManager) Validate() []string

Validate checks that all required variables are set and returns warnings for missing optional but recommended variables.

type EnvVar

type EnvVar struct {
	Key         string `json:"key"`
	Value       string `json:"value"`
	Source      string `json:"source"` // "env", "file", "profile", "default"
	Secret      bool   `json:"secret"`
	Required    bool   `json:"required"`
	Description string `json:"description,omitempty"`
}

EnvVar represents a single environment variable with metadata.

type MCPServerConfig

type MCPServerConfig struct {
	Name    string            `json:"name"`
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Type    string            `json:"type,omitempty"`    // "stdio" (default), "sse", "http"
	URL     string            `json:"url,omitempty"`     // for sse/http transports
	Headers map[string]string `json:"headers,omitempty"` // custom headers for sse/http
}

MCPServerConfig defines an MCP server to connect at startup.

type ModelOption

type ModelOption struct {
	ID          string
	DisplayName string
}

ModelOption is one hawk /config model row.

func OptionsFromSetupUI

func OptionsFromSetupUI(ui *setup.SetupUI, providerFilter string) []ModelOption

OptionsFromSetupUI builds picker rows; providerFilter limits to one provider.

type PathCheck

type PathCheck struct {
	Section  string
	Name     string
	Status   PathCheckStatus
	Detail   string
	FixHint  string
	Blocking bool
}

PathCheck is one row in the developer path readiness report.

type PathCheckStatus

type PathCheckStatus string

PathCheckStatus is pass, warn, or fail for one readiness row.

const (
	PathPass PathCheckStatus = "pass"
	PathWarn PathCheckStatus = "warn"
	PathFail PathCheckStatus = "fail"
)

type Settings

type Settings struct {
	// Model and Provider are legacy fields read only for one-time migration into eyrie provider.json.
	// Hawk does not persist model/provider here; use SetActiveModel / SetActiveProvider.
	Model                   string                 `json:"model,omitempty"`
	Provider                string                 `json:"provider,omitempty"`
	Theme                   string                 `json:"theme,omitempty"`
	AutoAllow               []string               `json:"auto_allow,omitempty"`      // tools to always allow
	AllowedTools            []string               `json:"allowedTools,omitempty"`    // archive-compatible allow rules
	DisallowedTools         []string               `json:"disallowedTools,omitempty"` // archive-compatible deny rules
	MaxBudgetUSD            float64                `json:"max_budget_usd,omitempty"`  // cost cap per session
	CustomHeaders           map[string]string      `json:"custom_headers,omitempty"`
	MCPServers              []MCPServerConfig      `json:"mcp_servers,omitempty"`
	CustomProviders         []CustomProviderConfig `json:"custom_providers,omitempty"`
	RepoMap                 *bool                  `json:"repo_map,omitempty"`
	RepoMapMaxTokens        int                    `json:"repo_map_max_tokens,omitempty"`
	Sandbox                 string                 `json:"sandbox,omitempty"`                    // sandbox mode: strict, workspace, off
	AutoCommit              *bool                  `json:"auto_commit,omitempty"`                // auto-commit file changes
	Autonomy                int                    `json:"autonomy,omitempty"`                   // autonomy level 0-4
	ModelRoles              *routing.ModelRoles    `json:"model_roles,omitempty"`                // per-role model overrides
	AutoCompactThresholdPct int                    `json:"auto_compact_threshold_pct,omitempty"` // token % to trigger auto-compact (default 85)
	Frugal                  bool                   `json:"frugal,omitempty"`                     // aggressive cost optimization: cascade to cheap models, lower max_tokens, earlier compaction
	Attribution             *Attribution           `json:"attribution,omitempty"`
	DeploymentRouting       *bool                  `json:"deployment_routing,omitempty"`   // use catalog deployment router when true / unset + provider.json qualifies
	MinimalMode             *bool                  `json:"minimal_mode,omitempty"`         // restrict to core tools only for a focused experience
	GLMThinkingEnabled      *bool                  `json:"glm_thinking_enabled,omitempty"` // GLM/Z.ai extended reasoning toggle; nil = model default
	TuiMouse                *bool                  `json:"tui_mouse,omitempty"`            // TUI mouse capture; false preserves native click-drag copy
}

Settings holds hawk configuration. Hawk: no API keys stored here. Secrets come from the OS secret store via eyrie.

func LoadGlobalSettings

func LoadGlobalSettings() Settings

LoadGlobalSettings loads only Hawk's user config settings.json.

func LoadSettings

func LoadSettings() Settings

LoadSettings loads settings from user config.

func LoadSettingsWithOverride

func LoadSettingsWithOverride(override string) (Settings, error)

LoadSettingsWithOverride loads normal settings plus a JSON object or JSON file override.

func MergeSettings

func MergeSettings(base, override Settings) Settings

MergeSettings applies override fields on top of base using project-style precedence.

func (*Settings) UnmarshalJSON

func (s *Settings) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both Go-era snake_case keys and archive-style camelCase keys.

type SetupState

type SetupState struct {
	HasCredentials bool
	HasModel       bool
	NeedsSetup     bool
	Hint           string
}

SetupState is a single evaluation of first-run /config requirements.

func EvaluateSetup

func EvaluateSetup(ctx context.Context) SetupState

EvaluateSetup loads the OS credential store and reports whether /config is still required.

func EvaluateSetupCached

func EvaluateSetupCached(ctx context.Context) SetupState

EvaluateSetupCached uses the in-memory credential snapshot (fast; for TUI hot paths).

type ToolPreset

type ToolPreset struct {
	Name  string   `json:"name"`
	Tools []string `json:"tools"` // nil means all tools allowed
}

ToolPreset maps a named preset to a list of allowed tools.

func ToolPresetByName

func ToolPresetByName(name string) (ToolPreset, bool)

ToolPresetByName returns a built-in tool preset by name.

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
	Value   string `json:"value,omitempty"`
}

ValidationError represents a config validation error.

func (ValidationError) Error

func (e ValidationError) Error() string

type ValidationResult

type ValidationResult struct {
	Errors []ValidationError `json:"errors"`
	Valid  bool              `json:"valid"`
}

ValidationResult contains all validation errors.

func ValidateSettings

func ValidateSettings(s Settings) ValidationResult

ValidateSettings validates a Settings object.

func (ValidationResult) Error

func (r ValidationResult) Error() string

Error returns a formatted error string.

Jump to

Keyboard shortcuts

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