feat(settings): add model provider management with full CRUD support

Add a new settings page for managing API model providers (name, API URL,
API key, applicable agent types). Includes database migration, SeaORM
entity, backend CRUD commands/handlers, frontend settings UI with agent
type filter, add/edit/delete dialogs, and i18n support for all 10 locales.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
xintaofei
2026-04-05 16:35:14 +08:00
parent 6359651247
commit ba19299696
32 changed files with 1501 additions and 11 deletions

View File

@@ -57,6 +57,7 @@ import type {
ChatChannelInfo,
ChannelStatusInfo,
ChatChannelMessageLog,
ModelProviderInfo,
} from "./types"
export async function listConversations(params?: {
@@ -1468,3 +1469,40 @@ export async function weixinCheckQrcode(
}> {
return getTransport().call("weixin_check_qrcode", { channelId, qrcode })
}
// ---------------------------------------------------------------------------
// Model Providers
// ---------------------------------------------------------------------------
export async function listModelProviders(): Promise<ModelProviderInfo[]> {
return getTransport().call("list_model_providers")
}
export async function createModelProvider(params: {
name: string
apiUrl: string
apiKey: string
agentTypes: string[]
}): Promise<ModelProviderInfo> {
return getTransport().call("create_model_provider", params)
}
export async function updateModelProvider(params: {
id: number
name?: string | null
apiUrl?: string | null
apiKey?: string | null
agentTypes?: string[] | null
}): Promise<ModelProviderInfo> {
return getTransport().call("update_model_provider", {
id: params.id,
name: params.name ?? null,
apiUrl: params.apiUrl ?? null,
apiKey: params.apiKey ?? null,
agentTypes: params.agentTypes ?? null,
})
}
export async function deleteModelProvider(id: number): Promise<void> {
return getTransport().call("delete_model_provider", { id })
}

View File

@@ -220,6 +220,15 @@ export function compareAgentType(a: AgentType, b: AgentType): number {
return aIndex - bIndex
}
export const ALL_AGENT_TYPES: AgentType[] = [
"claude_code",
"codex",
"open_code",
"gemini",
"open_claw",
"cline",
]
export const AGENT_LABELS: Record<AgentType, string> = {
claude_code: "Claude Code",
codex: "Codex",
@@ -888,3 +897,13 @@ export interface ChatChannelMessageLog {
error_detail: string | null
created_at: string
}
export interface ModelProviderInfo {
id: number
name: string
api_url: string
api_key_masked: string
agent_types: AgentType[]
created_at: string
updated_at: string
}