/** * AI provider registry — canonical list of every provider nostr-station * can talk to, split into two distinct surfaces: * * - terminal-native: spawned as a PTY subprocess (Claude Code, OpenCode). * cwd-scoped to the active project. No API key needed — the tool owns * its own auth. Lives behind the dashboard's terminal panel. * * - api: OpenAI-compat or Anthropic-native HTTP APIs, proxied from the * Chat pane via /api/ai/chat. Needs a key stored in the OS keychain. * * Keep the two surfaces separate — a user's default for "Open in AI" can * be a terminal-native provider while the Chat pane uses a different API * provider. Never try to render an API provider as a terminal tab, or * spawn a terminal-native provider as a proxy — they're different beasts. * * This registry is STATIC. What's in ~/.config/nostr-station/ai-config.json * is which of these the user has configured + any per-provider overrides * (custom baseUrl, default model, etc.) — see src/lib/ai-config.ts. */ export type ProviderType = 'terminal-native' | 'api'; interface ProviderBase { id: string; displayName: string; type: ProviderType; } /** * Terminal-native provider — a binary we spawn in a PTY tab with the * project path as cwd. The tool handles its own auth (Claude Code logs * in via the `claude` CLI; OpenCode via its own setup flow). The dashboard * doesn't need an API key. */ export interface TerminalProvider extends ProviderBase { type: 'terminal-native'; binary: string; } /** * API provider — proxied HTTP endpoint. `flavor` picks which wire format * the proxy uses — Anthropic-native (x-api-key + /v1/messages) vs. * OpenAI-compat (Bearer + /v1/chat/completions). */ export interface ApiProvider extends ProviderBase { type: 'api'; baseUrl: string; defaultModel: string; flavor: 'anthropic' | 'openai-compat'; bareKey?: string; } export type Provider = TerminalProvider | ApiProvider; /** * Master list. Keep the IDs stable — they're used as keychain account * names (`ai:`), ai-config.json keys, and CLI args. * * Adding a provider: pick an ID, add an entry, done. The Chat pane and * Config panel enumerate this registry at runtime. */ export declare const PROVIDERS: Record; export declare function getProvider(id: string): Provider | null; export declare function listProviders(): Provider[]; export declare function listTerminalNative(): TerminalProvider[]; export declare function listApi(): ApiProvider[]; /** * Keychain account name for an API provider's stored key. * Format: `ai:`. Paired with the existing service name * `nostr-station` in src/lib/keychain.ts. */ export declare function keychainAccountFor(providerId: string): `ai:${string}`; /** * Best-effort inference of a provider-id from a legacy base URL * (the single-provider world stored base URL in ~/.claude_env). Used * only by the one-shot migration in ai-config.ts — new code should * always carry an explicit providerId instead. * * Empty baseUrl → 'anthropic' (the Anthropic-native default). */ export declare function inferIdFromBaseUrl(baseUrl: string): string; export {};