/** * Load the ZPL user API key from (in priority order): * * 1. ~/.zpl/config.toml — written by `npx zpl-engine-mcp setup` device flow. * Preferred because a config file is not logged by Claude Desktop / Cursor, * is per-user (not per-project), and survives MCP client updates. * * 2. process.env.ZPL_API_KEY / ZPL_ENGINE_KEY — legacy path, still supported * so existing users don't break. `env-keys.ts::resolveZplApiKey()` is the * single source of truth for env-name lookup. * * Returns the raw key string as-is (no format validation) plus a tag for * debugging / first-run messages. Format validation lives in `index.ts` where * the user-visible error text is assembled. * * Never logs the key. File read is best-effort — if the file exists but is * malformed, we warn to stderr and fall through to the env var so the user * still gets *some* way to run the MCP. */ export type ApiKeySource = "config" | "env" | "none"; export interface LoadedApiKey { key: string; source: ApiKeySource; } /** Absolute path to the config.toml the `setup` subcommand writes. */ export declare function getConfigPath(): string; /** * Parse the single `api_key = "..."` line out of our config.toml. * We deliberately don't pull in a TOML library — the file is written by our * own `setup` command with a known shape, and the only value the MCP needs * at startup is `api_key`. Keeps the dep tree at 1 package. * * Accepts both double and single quotes. Comments (#) and whitespace OK. * Returns undefined on any parse failure — caller decides what to do. */ export declare function parseApiKeyFromToml(raw: string): string | undefined; /** Read a single named string field from our minimal config.toml. */ export declare function parseTomlString(raw: string, field: string): string | undefined; /** * Best-effort plan lookup from local config. * * Engine doesn't expose a /api/me endpoint yet (TODO M3.x), so we can't * auto-detect plan from the server. v3.7.2 adds `plan` to config.toml so * users can set it once after setup and zpl_quota / zpl_alert estimates * stay accurate. Precedence: env var > config.toml > "free". */ export declare function loadPlan(): Promise; /** * Load the API key. v4.1.7 (audit 2026-05-13): aligned precedence with * the CLI — ENV wins over file. Previously MCP did file-wins-over-env, * which meant a dual-tool user with `ZPL_API_KEY=staging` in shell and a * prod key in `~/.zpl/config.toml` saw CLI hit staging but MCP hit prod. * Same machine, same file, same env var, different behaviour. v4.1.7 * flips MCP so both tools resolve identically: env first (12-factor * standard), config.toml as fallback. * * Migration impact: zero for normal users (most have ONE source). Users * who relied on file-wins must `unset ZPL_API_KEY` before running MCP * via `npx`. The setup wizard still writes config.toml first; that path * is unchanged. */ export declare function loadApiKey(): Promise;