- Separate MCP server metadata from connection spec for cleaner architecture - Add comprehensive server entry fields: name, description, tags, homepage, docs - Remove legacy format compatibility logic from extract_server_spec - Implement data validation and filtering in get_servers_snapshot_for - Add strict id consistency check in upsert_in_config_for - Enhance import logic with defensive programming for corrupted data - Simplify frontend by removing normalization logic (moved to backend) - Improve error messages with contextual information - Add comprehensive i18n support for new metadata fields
100 lines
2.8 KiB
TypeScript
100 lines
2.8 KiB
TypeScript
export type ProviderCategory =
|
||
| "official" // 官方
|
||
| "cn_official" // 国产官方
|
||
| "aggregator" // 聚合网站
|
||
| "third_party" // 第三方供应商
|
||
| "custom"; // 自定义
|
||
|
||
export interface Provider {
|
||
id: string;
|
||
name: string;
|
||
settingsConfig: Record<string, any>; // 应用配置对象:Claude 为 settings.json;Codex 为 { auth, config }
|
||
websiteUrl?: string;
|
||
// 新增:供应商分类(用于差异化提示/能力开关)
|
||
category?: ProviderCategory;
|
||
createdAt?: number; // 添加时间戳(毫秒)
|
||
// 可选:供应商元数据(仅存于 ~/.cc-switch/config.json,不写入 live 配置)
|
||
meta?: ProviderMeta;
|
||
}
|
||
|
||
export interface AppConfig {
|
||
providers: Record<string, Provider>;
|
||
current: string;
|
||
}
|
||
|
||
// 自定义端点配置
|
||
export interface CustomEndpoint {
|
||
url: string;
|
||
addedAt: number;
|
||
lastUsed?: number;
|
||
}
|
||
|
||
// 供应商元数据(字段名与后端一致,保持 snake_case)
|
||
export interface ProviderMeta {
|
||
// 自定义端点:以 URL 为键,值为端点信息
|
||
custom_endpoints?: Record<string, CustomEndpoint>;
|
||
}
|
||
|
||
// 应用设置类型(用于 SettingsModal 与 Tauri API)
|
||
export interface Settings {
|
||
// 是否在系统托盘(macOS 菜单栏)显示图标
|
||
showInTray: boolean;
|
||
// 点击关闭按钮时是否最小化到托盘而不是关闭应用
|
||
minimizeToTrayOnClose: boolean;
|
||
// 启用 Claude 插件联动(写入 ~/.claude/config.json 的 primaryApiKey)
|
||
enableClaudePluginIntegration?: boolean;
|
||
// 覆盖 Claude Code 配置目录(可选)
|
||
claudeConfigDir?: string;
|
||
// 覆盖 Codex 配置目录(可选)
|
||
codexConfigDir?: string;
|
||
// 首选语言(可选,默认中文)
|
||
language?: "en" | "zh";
|
||
// Claude 自定义端点列表
|
||
customEndpointsClaude?: Record<string, CustomEndpoint>;
|
||
// Codex 自定义端点列表
|
||
customEndpointsCodex?: Record<string, CustomEndpoint>;
|
||
}
|
||
|
||
// MCP 服务器连接参数(宽松:允许扩展字段)
|
||
export interface McpServerSpec {
|
||
// 可选:社区常见 .mcp.json 中 stdio 配置可不写 type
|
||
type?: "stdio" | "http";
|
||
// stdio 字段
|
||
command?: string;
|
||
args?: string[];
|
||
env?: Record<string, string>;
|
||
cwd?: string;
|
||
// http 字段
|
||
url?: string;
|
||
headers?: Record<string, string>;
|
||
// 通用字段
|
||
[key: string]: any;
|
||
}
|
||
|
||
// MCP 服务器条目(含元信息)
|
||
export interface McpServer {
|
||
id: string;
|
||
name?: string;
|
||
description?: string;
|
||
tags?: string[];
|
||
homepage?: string;
|
||
docs?: string;
|
||
enabled?: boolean;
|
||
server: McpServerSpec;
|
||
source?: string;
|
||
[key: string]: any;
|
||
}
|
||
|
||
// MCP 配置状态
|
||
export interface McpStatus {
|
||
userConfigPath: string;
|
||
userConfigExists: boolean;
|
||
serverCount: number;
|
||
}
|
||
|
||
// 新:来自 config.json 的 MCP 列表响应
|
||
export interface McpConfigResponse {
|
||
configPath: string;
|
||
servers: Record<string, McpServer>;
|
||
}
|