Documentation
¶
Overview ¶
Package validator provides config validation utilities.
Index ¶
- Constants
- func APIKeyForProvider(provider string) string
- func ActiveGateway(ctx context.Context) string
- func ActiveModel(ctx context.Context) string
- func ActiveProvider(ctx context.Context) string
- func AllCanonicalModelIDs() []string
- func AllCatalogProviders() []string
- func AllEnvKeyStatus() string
- func AllSetupGateways() []string
- func ApplyEyrieCredentials(ctx context.Context) (*setup.ApplyCredentialsResult, error)
- func ApplyEyrieCredentialsForProvider(ctx context.Context, providerID string) (*setup.ApplyCredentialsResult, error)
- func ApplyXiaomiTokenPlanRegionEnv(ctx context.Context)
- func ApplyZAIRegionEnv(ctx context.Context)
- func AutoRefreshCatalog(ctx context.Context, out io.Writer, verbose bool) error
- func BoolPtr(b bool) *bool
- func BuildContext() string
- func BuildContextWithDirs(addDirs []string) string
- func CachedModelCountForProvider(provider string) int
- func CatalogCachePathForDisplay() string
- func CatalogEmptyHint(ctx context.Context) string
- func CatalogReady(ctx context.Context) bool
- func CatalogStatusLine(ctx context.Context) string
- func CheapestModelForProvider(provider, fallback string) string
- func ClearActiveSelection(ctx context.Context) error
- func CompiledCatalogV1() *catalog.CompiledCatalogV1
- func ConfigProviderList(custom []CustomProviderConfig) []string
- func ConfiguredCredentialProviders() []string
- func DefaultModelForProvider(provider string) string
- func DefaultModelProviderFilter(ctx context.Context) string
- func DeploymentRoutingEnabled(s Settings) bool
- func DeploymentRoutingLabel(settings Settings) string
- func DeploymentStatusReport(ctx context.Context, activeModel string) (string, error)
- func DiscoverCatalogAfterSetup(ctx context.Context, out io.Writer)
- func EnsureCatalogAvailable(ctx context.Context) error
- func EnvKeyStatus(provider string) string
- func ExampleModelHints() (anthropic, openai string)
- func FetchModelsForProvider(provider string) ([]catalog.ModelCatalogEntry, error)
- func FirstRunSetupHint(ctx context.Context) string
- func FormatApplyCredentialsSummary(result *setup.ApplyCredentialsResult) string
- func FormatCatalogHealth(h CatalogHealth) string
- func FormatConfigProviderError(providerID string, err error) string
- func FormatCredentialCLIStatus(ctx context.Context) string
- func FormatDeveloperPathReport(ctx context.Context) string
- func FormatEcosystemPanel(ctx context.Context, provider, model string) string
- func GatewayDisplayName(gatewayID string) string
- func GatewayForModel(modelID string) string
- func Getenv(key string) string
- func GitContext() string
- func HasConfiguredDeployment(ctx context.Context) bool
- func HasConfiguredDeploymentCached(ctx context.Context) bool
- func HasSelectedModel() bool
- func HasStoredCredentialForProvider(ctx context.Context, providerID string) bool
- func InvalidateCatalogHealthCache()
- func InvalidateConfigUICache()
- func IsMinimalMode(s Settings) bool
- func IsSetupGateway(providerID string) bool
- func LoadAPIKeysFromStore() map[string]string
- func LoadAgentDir() string
- func LoadAgentsMD() string
- func LoadAgentsMDFrom(start string) string
- func MaskCredentialForProvider(ctx context.Context, provider string) string
- func MigrateProviderConfig() error
- func MigrateProviderSecrets() error
- func ModelIDsForProvider(provider string) ([]string, error)
- func NeedsFirstRunSetup(ctx context.Context) bool
- func NeedsXiaomiTokenPlanRegion(providerID string) bool
- func NeedsZAIRegion(providerID string) bool
- func NormalizeProviderForEngine(provider string) string
- func ParseEnvFile(path string) (map[string]string, error)
- func PersistAPIKey(ctx context.Context, envKey, secret string) error
- func PrepareCatalogForSession(ctx context.Context, out io.Writer, opts CatalogStartupOptions) error
- func PrepareCredentialDiscovery(ctx context.Context)
- func PrimaryAPIKeyEnvForDeployment(deploymentID string) string
- func ProviderAPIKeyEnv(provider string) string
- func ProviderIDForDeployment(deploymentID string) string
- func ProviderOfModel(modelName string) string
- func RefreshCatalogAfterCredentials(ctx context.Context, out io.Writer) error
- func RefreshConfigCredSnapshot(ctx context.Context)
- func RefreshGatewayCatalog(ctx context.Context, providerID string) (string, error)
- func RefreshModelCatalogV1(ctx context.Context) (string, error)
- func RemoveStoredCredential(ctx context.Context, target string) ([]string, error)
- func ResolveCanonicalModel(model string) string
- func RoutingPreviewJSON(ctx context.Context, model string) (string, error)
- func SaveCredential(ctx context.Context, inference CredentialInference, secret string) error
- func SaveGlobal(s Settings) error
- func SaveProjectOrGlobalDeploymentRouting(enabled bool) error
- func ScheduleBackgroundCatalogRefresh(ctx context.Context)
- func SetActiveModel(ctx context.Context, modelID string) error
- func SetActiveProvider(ctx context.Context, provider string) error
- func SetGlobalSetting(key, value string) error
- func SetXiaomiTokenPlanRegion(region string) error
- func SetZAIRegion(providerID, region string) error
- func SettingValue(s Settings, key string) (string, bool)
- func SetupGatewayCredentialEnv(providerID string) string
- func ShouldClearSelectionAfterCredentialRemove(ctx context.Context, removedProvider string) bool
- func StartupCatalogPrefetch(ctx context.Context)
- func SyncSelectionWithCredentials(ctx context.Context)
- func TryAutoRefreshCatalog(ctx context.Context) error
- func XiaomiTokenPlanRegionLabel() string
- func ZAIRegionLabel(providerID string) string
- type Attribution
- type CatalogHealth
- type CatalogStartupOptions
- type CredentialInference
- func CredentialInferenceForProvider(providerID string) (CredentialInference, error)
- func InferCredentialsFromAPIKey(ctx context.Context, secret string) []CredentialInference
- func InferenceFromOption(opt CredentialProviderOption) CredentialInference
- func LocalCredentialInference(providerID string) (CredentialInference, error)
- type CredentialProviderOption
- type CredentialResolveResult
- type CustomProviderConfig
- type DeveloperPathReport
- type EnvManager
- func (em *EnvManager) Diff(other *EnvManager) []string
- func (em *EnvManager) Export(format string) string
- func (em *EnvManager) Get(key string) string
- func (em *EnvManager) GetRequired(key string) (string, error)
- func (em *EnvManager) ListForDisplay() string
- func (em *EnvManager) Load(sources ...string) error
- func (em *EnvManager) LoadProfile(name string) error
- func (em *EnvManager) MaskSecrets(text string) string
- func (em *EnvManager) SaveProfile(name string, vars []string) error
- func (em *EnvManager) Set(key, value string, secret bool)
- func (em *EnvManager) Validate() []string
- type EnvVar
- type MCPServerConfig
- type ModelOption
- type PathCheck
- type PathCheckStatus
- type Settings
- type SetupState
- type ToolPreset
- type ValidationError
- type ValidationResult
Constants ¶
const ( ProviderZAIPayg = "zai_payg" ProviderZAICoding = "zai_coding" )
const ProviderXiaomiTokenPlan = "xiaomi_mimo_token_plan"
Variables ¶
This section is empty.
Functions ¶
func APIKeyForProvider ¶
APIKeyForProvider reads the API key for a provider from the OS secret store.
func ActiveGateway ¶
ActiveGateway returns the user's setup gateway (never an aggregator owner slug like moonshotai).
func ActiveModel ¶
ActiveModel returns the selected model from eyrie provider.json (not hawk settings).
func ActiveProvider ¶
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 ¶
ApplyXiaomiTokenPlanRegionEnv sets process env from provider.json before credential probe.
func ApplyZAIRegionEnv ¶
ApplyZAIRegionEnv sets process envs from provider.json before probe/fetch/chat.
func AutoRefreshCatalog ¶
AutoRefreshCatalog runs eyrie discover (remote + live APIs when keys are set).
func BuildContext ¶
func BuildContext() string
BuildContext assembles the full context string for the system prompt.
func BuildContextWithDirs ¶
BuildContextWithDirs assembles context including additional user-specified directories.
func CachedModelCountForProvider ¶
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 ¶
CatalogEmptyHint returns actionable guidance when the catalog has no models.
func CatalogReady ¶
CatalogReady reports whether the eyrie catalog cache exists and has models.
func CatalogStatusLine ¶
CatalogStatusLine returns a short one-line status for the TUI welcome banner.
func CheapestModelForProvider ¶
CheapestModelForProvider picks the lowest input-priced model from eyrie's catalog.
func ClearActiveSelection ¶
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 DefaultModelProviderFilter ¶
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 ¶
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 ¶
DeploymentRoutingLabel returns a short on/off label for the config hub.
func DeploymentStatusReport ¶
DeploymentStatusReport returns hawk deployment routing diagnostics.
func DiscoverCatalogAfterSetup ¶
DiscoverCatalogAfterSetup runs during optional hawk setup after API keys are saved.
func EnsureCatalogAvailable ¶
EnsureCatalogAvailable returns an error when the production catalog cache is missing or empty.
func EnvKeyStatus ¶
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 ¶
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 ¶
FormatConfigProviderError maps eyrie setup errors to user-facing /config hints.
func FormatCredentialCLIStatus ¶
FormatCredentialCLIStatus returns hawk credentials status output (providers, not raw env names).
func FormatDeveloperPathReport ¶
FormatDeveloperPathReport renders the developer path readiness report for CLI/TUI.
func FormatEcosystemPanel ¶
FormatEcosystemPanel summarizes eyrie, yaad, and tok integration for doctor and status output.
func GatewayDisplayName ¶
func GatewayForModel ¶
GatewayForModel resolves the setup gateway for a model id.
func Getenv ¶
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 HasConfiguredDeployment ¶
HasConfiguredDeployment reports whether at least one eyrie deployment has credentials.
func HasConfiguredDeploymentCached ¶
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 ¶
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 ¶
IsMinimalMode reports whether minimal mode is enabled in the settings.
func IsSetupGateway ¶
IsSetupGateway reports whether id is a registered setup gateway.
func LoadAPIKeysFromStore ¶
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 ¶
LoadAgentsMDFrom reads AGENTS.md from start or its parents.
func MaskCredentialForProvider ¶
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 NeedsFirstRunSetup ¶
NeedsFirstRunSetup is true when the user should complete /config (API key and/or model).
func NeedsXiaomiTokenPlanRegion ¶
NeedsXiaomiTokenPlanRegion reports whether the Token Plan gateway still needs a cluster pick.
func NeedsZAIRegion ¶
NeedsZAIRegion reports whether the Z.AI gateway still needs a region pick for the chosen plan.
func NormalizeProviderForEngine ¶
NormalizeProviderForEngine maps hawk provider aliases to eyrie canonical names. This is the boundary where hawk names become engine/eyrie names.
func ParseEnvFile ¶
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 ¶
PersistAPIKey saves a provider API key via eyrie (OS secret store).
func PrepareCatalogForSession ¶
PrepareCatalogForSession ensures a usable, fresh catalog before chat/print. By default hawk auto-discovers when the cache is missing, empty, or stale.
func PrepareCredentialDiscovery ¶
PrepareCredentialDiscovery prepares runtime credential discovery without reading legacy files.
func PrimaryAPIKeyEnvForDeployment ¶
PrimaryAPIKeyEnvForDeployment returns the env var name for a deployment's API key.
func ProviderAPIKeyEnv ¶
ProviderAPIKeyEnv returns the API key env var for a provider (registry first for setup gateways).
func ProviderIDForDeployment ¶
ProviderIDForDeployment returns the catalog provider id for a deployment (e.g. anthropic-direct → anthropic).
func ProviderOfModel ¶
ProviderOfModel resolves catalog provider for a canonical model ID or alias.
func RefreshCatalogAfterCredentials ¶
RefreshCatalogAfterCredentials runs eyrie discover after /config saves API keys.
func RefreshConfigCredSnapshot ¶
RefreshConfigCredSnapshot re-reads keychain status for setup gateways (call when opening /config).
func RefreshGatewayCatalog ¶
RefreshGatewayCatalog fetches live models for one gateway and updates the cache.
func RefreshModelCatalogV1 ¶
RefreshModelCatalogV1 asks eyrie to refresh the remote catalog and provider APIs using env API keys.
func RemoveStoredCredential ¶
RemoveStoredCredential deletes stored API key(s) for a provider name or env var.
func ResolveCanonicalModel ¶
ResolveCanonicalModel maps aliases and native IDs to catalog canonical model IDs.
func RoutingPreviewJSON ¶
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 ¶
SaveGlobal saves settings to the global config file.
func SaveProjectOrGlobalDeploymentRouting ¶
SaveProjectOrGlobalDeploymentRouting persists the flag to user settings.
func ScheduleBackgroundCatalogRefresh ¶
ScheduleBackgroundCatalogRefresh silently refreshes the catalog when it is already stale, or after StaleAfter passes during a long interactive session.
func SetActiveModel ¶
SetActiveModel persists model selection to eyrie provider.json.
func SetActiveProvider ¶
SetActiveProvider persists provider selection to eyrie provider.json.
func SetGlobalSetting ¶
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 ¶
SetXiaomiTokenPlanRegion persists region (cn, sgp, ams) and syncs env for probe/discovery.
func SetZAIRegion ¶
SetZAIRegion persists the region (international or cn) for the given Z.AI gateway and syncs env + derived base.
func SettingValue ¶
SettingValue returns a display-safe value for a supported setting key.
func SetupGatewayCredentialEnv ¶
SetupGatewayCredentialEnv returns the registry env var for a setup gateway (e.g. XIAOMI_MIMO_PAYG_API_KEY).
func ShouldClearSelectionAfterCredentialRemove ¶
ShouldClearSelectionAfterCredentialRemove reports whether provider/model should reset.
func StartupCatalogPrefetch ¶
StartupCatalogPrefetch refreshes the catalog in the background when the cache needs it.
func SyncSelectionWithCredentials ¶
SyncSelectionWithCredentials clears stale provider/model when keys are missing.
func TryAutoRefreshCatalog ¶
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 ¶
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 ¶
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 LoadSettingsWithOverride ¶
LoadSettingsWithOverride loads normal settings plus a JSON object or JSON file override.
func MergeSettings ¶
MergeSettings applies override fields on top of base using project-style precedence.
func (*Settings) UnmarshalJSON ¶
UnmarshalJSON accepts both Go-era snake_case keys and archive-style camelCase keys.
type SetupState ¶
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.
Source Files
¶
- catalog_api.go
- catalog_health.go
- catalog_startup.go
- config.go
- credentials_store.go
- deployment.go
- deployment_status.go
- deployments_ui.go
- developer_path.go
- ecosystem_report.go
- envmanager.go
- eyrie_apply.go
- eyrie_selection.go
- migrate_provider_secrets.go
- provider_filter.go
- settings.go
- setup_status.go
- ui_cache.go
- validator.go
- xiaomi_setup.go
- zai_setup.go