cc-haha/desktop/src/api/agents.ts
程序员阿江(Relakkes) 211226c7a1 feat(agents): update API types, store, i18n, and tests for new agent model
- Update AgentDefinition type with agentType, source, isActive, modelDisplay fields
- Refactor agentStore to support activeAgents/allAgents with cwd parameter
- Add i18n strings for agent browser UI (source labels, summary, status)
- Update server agents API with serialization helpers and override resolution
- Update tests to match new agent data structure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 16:45:51 +08:00

37 lines
745 B
TypeScript

import { api } from './client'
export type AgentSource =
| 'built-in'
| 'plugin'
| 'userSettings'
| 'projectSettings'
| 'localSettings'
| 'flagSettings'
| 'policySettings'
export type AgentDefinition = {
agentType: string
description?: string
model?: string
modelDisplay?: string
tools?: string[]
systemPrompt?: string
color?: string
source: AgentSource
baseDir?: string
overriddenBy?: AgentSource
isActive: boolean
}
export type AgentListResponse = {
activeAgents: AgentDefinition[]
allAgents: AgentDefinition[]
}
export const agentsApi = {
list: (cwd?: string) => {
const query = cwd ? `?cwd=${encodeURIComponent(cwd)}` : ''
return api.get<AgentListResponse>(`/api/agents${query}`)
},
}