/** * User-layer runtime settings. * * SkaileSettings represents the personal, machine-specific overrides stored in * .skaile/settings.json (gitignored). Project-level defaults (framework, agent * definition, resource connections, hooks) belong in skaile.yaml via SkWorkspaceConfig. * * Resolution order (highest priority first): * 1. CLI flags / API overrides * 2. Environment variables (API keys only) * 3. .skaile/settings.json (project-local, walking upward) * 4. ~/.skaile/settings.json (user global) * 5. skaile.yaml defaults: (via resolveSkWorkspaceConfig — no duplicate YAML parser) * 6. Built-in SETTINGS_DEFAULTS */ import { type CloudTransportConfig } from "./workspace-config.js"; /** * All supported LLM and voice provider identifiers. * @docLink packages/core/settings#all-providers */ export declare const ALL_PROVIDERS: readonly ["anthropic", "openai", "google", "mistral", "groq", "openrouter", "deepseek", "xai", "together", "fireworks", "deepgram", "elevenlabs"]; /** * Union of supported LLM and voice provider identifiers. * @docLink packages/core/settings#provider */ export type Provider = (typeof ALL_PROVIDERS)[number]; /** * Personal runtime settings — stored in .skaile/settings.json (gitignored). * Contains only user-specific overrides: credentials, preferred model/driver. * * Project-level config (framework, resources, hooks, agent definition) lives * in skaile.yaml as SkWorkspaceConfig. App-specific fields (voice, domains) * are added by forge-common-backend via AppSettings. * @docLink packages/core/settings#skaile-settings */ export interface SkaileSettings { /** Active LLM provider identifier (e.g. "anthropic", "openai"). */ provider?: string; /** Active model identifier (e.g. "claude-opus-5"). */ model?: string; /** Bridge driver to use: "omp", "claude-sdk", or "codex". */ driver?: string; /** * AI cloud transport for claude-sdk (`default|bedrock|vertex|azure|gateway`). * Absent = default (provider's native API). Sourced from skaile.yaml * `agent-config..cloud`; string-typed for forward compat. * * @since 1.3.0 */ cloud?: string; /** * Non-secret cloud transport settings (camelCase; converted once from the * skaile.yaml `cloud_config` snake_case wire shape). * * @since 1.3.0 */ cloudConfig?: CloudTransportConfig; /** API keys keyed by provider identifier. Merged with env-var keys at resolution time. */ apiKeys?: Record; /** Framework install path overrides. Normally derived from skaile.yaml defaults. */ skillsDir?: string; /** Override for the agents directory. Normally derived from skaile.yaml defaults. */ agentsDir?: string; /** Override for the prompts directory. Normally derived from skaile.yaml defaults. */ promptsDir?: string; /** AI Asset Store API URL (default: https://store.skaile.ai) */ storeUrl?: string; /** JWT access token for the AI Asset Store */ storeJwt?: string; /** Refresh token for JWT renewal */ storeRefreshToken?: string; } /** * Built-in default settings. Lowest-priority layer in resolveSettings(). * Override via .skaile/settings.json, ~/.skaile/settings.json, or env vars. * * `model` is deliberately absent. A hardcoded default here is not a floor a * consumer can opt out of: because `loadSettings` and `resolveSettings` spread * these defaults *under* every other layer, deleting `model` from a settings * file does not unset it — the built-in comes back. A caller therefore cannot * express "no model configured" and cannot route an unconfigured session to its * own per-backend default; it silently inherits whichever id was pinned here, * however stale. Leaving it unset lets each driver apply its own current * default (omp omits `--model`; claude-sdk falls back to the `sonnet` rolling * alias), which is the one that ages correctly. * * @docLink packages/core/settings#settings-defaults */ export declare const SETTINGS_DEFAULTS: SkaileSettings; /** * Rename legacy field names in a raw parsed settings object to their current equivalents. * Maps `defaultProvider` → `provider`, `defaultModel` → `model`, `defaultAgentType` → `driver`. * * @param raw - Raw object from JSON.parse of a settings file * @returns Settings with legacy keys renamed to current ones * @docLink packages/core/settings#map-legacy-fields */ export declare function mapLegacyFields(raw: Record): SkaileSettings; /** * Return the path to the user-global settings file: `~/.skaile/settings.json`. * @docLink packages/core/settings#global-settings-path */ export declare function globalSettingsPath(): string; /** * Return the path to the project-local settings file: `/.skaile/settings.json`. * * @param projectDir - Absolute path to the project root * @returns Absolute path to the project settings file * @docLink packages/core/settings#project-settings-path */ export declare function projectSettingsPath(projectDir: string): string; /** * Load and parse a settings JSON file, merging over SETTINGS_DEFAULTS. * Returns defaults if the file does not exist or cannot be parsed. * * @param filePath - Absolute path to a settings.json file * @returns Parsed settings merged with built-in defaults * @docLink packages/core/settings#load-settings */ export declare function loadSettings(filePath: string): Promise; /** * Persist settings to a JSON file, creating parent directories as needed. * * @param settings - Settings object to serialize * @param filePath - Absolute path to write the settings.json file * @docLink packages/core/settings#save-settings */ export declare function saveSettings(settings: SkaileSettings, filePath: string): Promise; /** * Walk upward from `projectDir` (max 10 levels) and collect all * `.skaile/settings.json` paths found along the way. * Results are ordered nearest-to-root first. * * @param projectDir - Starting directory for the upward walk * @returns Array of absolute paths to settings files found * @docLink packages/core/settings#walk-for-settings */ export declare function walkForSettings(projectDir: string): string[]; /** * One-time migration from old config locations to .skaile/settings.json. * Does not delete old files — user can do that manually. * @docLink packages/core/settings#migrate-settings */ export declare function migrateSettings(projectDir: string): Promise; /** * Resolve effective settings through the 6-layer priority chain: * overrides > env vars (PREFERRED_PROVIDER, PREFERRED_MODEL, *_API_KEY) > * .skaile/settings.json (walks upward) > ~/.skaile/settings.json > * skaile.yaml agent_config defaults > SETTINGS_DEFAULTS. * * @param projectDir - Root directory of the project being operated on * @param overrides - Optional top-priority overrides (CLI flags, API body) * @returns Merged effective settings * @docLink packages/core/settings#resolve-settings */ export declare function resolveSettings(projectDir: string, overrides?: Partial): Promise; /** * Return the environment variable name for a provider's API key. * e.g. `providerEnvKey('anthropic')` → `'ANTHROPIC_API_KEY'` * * @param provider - Provider identifier (e.g. "anthropic", "openai") * @returns Environment variable name for that provider's API key * @docLink packages/core/settings#provider-env-key */ export declare function providerEnvKey(provider: string): string; /** * Return the active API key for the given provider. * The matching environment variable (`*_API_KEY`) takes priority over * the value stored in `settings.apiKeys`. * Applies to `cloud: default`/`gateway` only — bedrock/vertex/azure sessions * carry their credentials as env bundles resolved by the runner instead. * * @param provider - Provider identifier (e.g. "anthropic") * @param settings - Current effective settings * @returns API key string, or undefined if not configured * @docLink packages/core/settings#resolve-api-key */ export declare function resolveApiKey(provider: string, settings: SkaileSettings): string | undefined; /** * Return a masked version of an API key for safe logging. * Shows only the last four characters (e.g. `'****abc1'`). * * @param key - Raw API key to mask * @returns Masked key string, or empty string if key is falsy * @docLink packages/core/settings#mask-api-key */ export declare function maskApiKey(key: string): string; /** * An API key resolved with information about where it came from. * @docLink packages/core/settings#resolved-key */ export interface ResolvedKey { /** Masked API key value (last 4 chars visible). */ key: string; /** Whether the key came from an environment variable or stored settings. */ source: "env" | "stored"; } /** * Scan process.env (plus any `extraEnv` overrides) for recognized API key * variables and return them as a partial `apiKeys` record keyed by provider id. * * @param extraEnv - Additional environment entries to merge over process.env * @returns Partial apiKeys record containing only providers whose key was found * @docLink packages/core/settings#detect-env-api-keys */ export declare function detectEnvApiKeys(extraEnv?: Record): Record; /** * Build a resolved key map for all known providers with source info and masked values. * Env-var keys take priority over stored keys when both exist. * * @param settings - Current effective settings (provides stored apiKeys) * @param envKeys - Keys detected from environment (e.g. from detectEnvApiKeys()) * @returns Map from provider id to resolved key info; omits providers with no key * @docLink packages/core/settings#resolve-all-keys */ export declare function resolveAllKeys(settings: SkaileSettings, envKeys: Record): Record; //# sourceMappingURL=settings.d.ts.map