/** * Provider 配置类型定义 * * 管理模型供应商的 API Key 配置: * - 读写 ~/.local/share/opencode/auth.json(仅 type=api 的增删改,OAuth 只读) * - 缓存 opencode models 命令输出(按 provider 分组) * - 提供列表、获取、设置、删除 API Key 的功能 */ /** Provider 认证类型 */ export type ProviderAuthType = 'api' | 'oauth'; /** API 类型 Provider 配置(可读写) */ export interface ApiProviderConfig { type: 'api'; key: string; [key: string]: unknown; } /** OAuth 类型 Provider 配置(只读) */ export interface OAuthProviderConfig { type: 'oauth'; access: string; refresh: string; expires: number; accountId?: string; [key: string]: unknown; } /** Provider 配置联合类型 */ export type ProviderConfig = ApiProviderConfig | OAuthProviderConfig; /** Provider 信息摘要 */ export interface ProviderSummary { providerId: string; type: ProviderAuthType; /** 是否已配置(type=api 有 key,type=oauth 有 access token) */ configured: boolean; /** 是否可编辑(仅 type=api 可编辑) */ editable: boolean; /** 供应商显示名称(从 opename 映射,可选) */ displayName?: string; source?: 'api' | 'oauth' | 'custom' | 'config' | 'models'; disabled?: boolean; models?: string[]; modelCount?: number; } export interface CustomProviderModelConfig { name: string; } export interface CustomProviderConfig { npm: '@ai-sdk/openai-compatible'; name: string; options: { baseURL: string; headers?: Record; }; models: Record; } export interface ProviderOverridesConfig { providers: Record; disabledProviders: string[]; hiddenModels: Record; } export interface CustomProviderInput { providerId: string; name: string; baseURL: string; apiKey?: string; envKey?: string; models: Array<{ id: string; name: string; }>; headers?: Record; } /** 模型信息 */ export interface ModelInfo { providerId: string; modelId: string; name?: string; providerName?: string; visible?: boolean; custom?: boolean; /** 完整模型标识符(provider/model) */ fullName: string; } /** 模型缓存(按 provider 分组) */ export type ModelsCache = Map; /** OpenCode auth.json 文件内容 */ export type OpenCodeAuthConfig = Record; /** * 解析 ~/.local/share/opencode/auth.json 路径 * 可通过环境变量 OPENCODE_AUTH_PATH 覆盖(用于测试) */ export declare function getOpenCodeAuthPath(): string; /** * 常见 Provider ID 到显示名称的映射 */ export declare const PROVIDER_DISPLAY_NAMES: Record; /** * 内置 Provider 列表(opencode 原生支持的供应商) * 这些供应商可以通过 opencode providers login 进行 OAuth 登录 */ export declare const BUILTIN_PROVIDERS: string[]; /** * 判断 provider 是否可编辑(仅 type=api 可编辑) */ export declare function isProviderEditable(config: ProviderConfig): boolean; //# sourceMappingURL=types.d.ts.map