mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 22:10:21 +08:00
feat(agent): add create agent endpoint to agent client
This commit is contained in:
parent
231a923c9d
commit
825c376c5c
@ -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'
|
import { Axios, AxiosRequestConfig } from 'axios'
|
||||||
|
|
||||||
type ApiVersion = 'v1'
|
type ApiVersion = 'v1'
|
||||||
@ -31,4 +38,18 @@ export class AgentClient {
|
|||||||
throw new Error('Failed to list agents.', { cause: error })
|
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 })
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,6 +112,12 @@ export interface SessionMessageContent {
|
|||||||
agentType: string // The type of agent that generated this message (e.g., 'claude-code', 'openai', etc.)
|
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 = {
|
export type AgentForm = {
|
||||||
type: AgentType
|
type: AgentType
|
||||||
name: string
|
name: string
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user