feat(agent): add create agent endpoint to agent client

This commit is contained in:
icarus 2025-09-18 14:08:31 +08:00
parent 231a923c9d
commit 825c376c5c
2 changed files with 28 additions and 1 deletions

View File

@ -1,4 +1,11 @@
import { ListAgentsResponseSchema, type ListAgentsResponse } from '@types'
import {
AgentForm,
CreateAgentRequest,
CreateAgentResponse,
CreateAgentResponseSchema,
type ListAgentsResponse,
ListAgentsResponseSchema
} from '@types'
import { Axios, AxiosRequestConfig } from 'axios'
type ApiVersion = 'v1'
@ -31,4 +38,18 @@ export class AgentClient {
throw new Error('Failed to list agents.', { cause: error })
}
}
public async createAgent(agent: AgentForm): Promise<CreateAgentResponse> {
const url = `/${this.apiVersion}/agents`
try {
const payload = {
...agent
} satisfies CreateAgentRequest
const response = await this.axios.post(url, payload)
const data = CreateAgentResponseSchema.parse(response.data)
return data
} catch (error) {
throw new Error('Failed to create agent.', { cause: error })
}
}
}

View File

@ -112,6 +112,12 @@ export interface SessionMessageContent {
agentType: string // The type of agent that generated this message (e.g., 'claude-code', 'openai', etc.)
}
// Not implemented fields:
// - plan_model: Optional model for planning/thinking tasks
// - small_model: Optional lightweight model for quick responses
// - mcps: Optional array of MCP (Model Control Protocol) tool IDs
// - allowed_tools: Optional array of permitted tool IDs
// - configuration: Optional agent settings (temperature, top_p, etc.)
export type AgentForm = {
type: AgentType
name: string