You've already forked agentic-coding-workflow
feat(web): acp api client (agent_kinds)
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
import { request } from './client'
|
||||||
|
|
||||||
|
// Admin DTO from `internal/acp/dto.go: AgentKindAdminDTO`.
|
||||||
|
export interface AgentKindAdmin {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
display_name: string
|
||||||
|
description: string
|
||||||
|
binary_path: string
|
||||||
|
args: string[]
|
||||||
|
env_keys: string[]
|
||||||
|
enabled: boolean
|
||||||
|
created_by: string
|
||||||
|
created_at: string
|
||||||
|
updated_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public DTO (non-admin view) from `internal/acp/dto.go: AgentKindPublicDTO`.
|
||||||
|
export interface AgentKindPublic {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
display_name: string
|
||||||
|
enabled: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type guard distinguishing admin vs public DTO based on presence of admin-only fields.
|
||||||
|
export function isAgentKindAdmin(k: AgentKindAdmin | AgentKindPublic): k is AgentKindAdmin {
|
||||||
|
return 'binary_path' in k
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateAgentKindReq {
|
||||||
|
name: string
|
||||||
|
display_name: string
|
||||||
|
description?: string
|
||||||
|
binary_path: string
|
||||||
|
args?: string[]
|
||||||
|
env?: Record<string, string>
|
||||||
|
enabled?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateAgentKindReq {
|
||||||
|
display_name?: string
|
||||||
|
description?: string
|
||||||
|
binary_path?: string
|
||||||
|
args?: string[]
|
||||||
|
env?: Record<string, string>
|
||||||
|
enabled?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const enc = (v: string) => encodeURIComponent(v)
|
||||||
|
|
||||||
|
export const acpApi = {
|
||||||
|
agentKinds: {
|
||||||
|
list: () =>
|
||||||
|
request<(AgentKindAdmin | AgentKindPublic)[]>('/api/v1/acp/agent-kinds'),
|
||||||
|
get: (id: string) =>
|
||||||
|
request<AgentKindAdmin>(`/api/v1/acp/agent-kinds/${enc(id)}`),
|
||||||
|
create: (req: CreateAgentKindReq) =>
|
||||||
|
request<AgentKindAdmin>('/api/v1/acp/agent-kinds', { method: 'POST', body: req }),
|
||||||
|
update: (id: string, req: UpdateAgentKindReq) =>
|
||||||
|
request<AgentKindAdmin>(`/api/v1/acp/agent-kinds/${enc(id)}`, { method: 'PATCH', body: req }),
|
||||||
|
remove: (id: string) =>
|
||||||
|
request<void>(`/api/v1/acp/agent-kinds/${enc(id)}`, { method: 'DELETE' }),
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user