import type {AgentInfo, AgentKnowledgeBinding, AgentToolBinding,} from './types'; import {api} from '#/api/request'; export interface RequestResult { data: T; errorCode: number; message?: string; } export function getAgentDetail(id: number | string) { return api.get>('/api/v1/agent/getDetail', { params: { id }, }); } export function saveAgent(agent: AgentInfo) { return api.post>('/api/v1/agent/save', agent); } export function updateAgent(agent: AgentInfo) { return api.post>('/api/v1/agent/update', agent); } export function removeAgent(id: number | string) { return api.post('/api/v1/agent/remove', { id }); } export function updateAgentToolBindings( agentId: number | string, bindings: AgentToolBinding[], ) { return api.post>( '/api/v1/agent/toolBinding/update', { agentId, bindings }, ); } export function updateAgentKnowledgeBindings( agentId: number | string, bindings: AgentKnowledgeBinding[], ) { return api.post>( '/api/v1/agent/knowledgeBinding/update', { agentId, bindings }, ); } export function submitAgentPublishApproval(id: number | string) { return api.post>( '/api/v1/agent/submitPublishApproval', { id }, ); } export function submitAgentOfflineApproval(id: number | string) { return api.post>( '/api/v1/agent/submitOfflineApproval', { id }, ); } export function submitAgentDeleteApproval(id: number | string) { return api.post>( '/api/v1/agent/submitDeleteApproval', { id }, ); } export function approveAgentRun(requestId: string, resumeToken: string) { return api.post('/api/v1/agent/run/approve', { requestId, resumeToken, }); } export function rejectAgentRun( requestId: string, resumeToken: string, reason?: string, ) { return api.post('/api/v1/agent/run/reject', { requestId, resumeToken, reason, }); } export function clearAgentDraftSession(sessionId: string) { return api.post('/api/v1/agent/chat/draft/clear', { sessionId, }); } export function getAgentCategories() { return api.get>('/api/v1/agentCategory/visibleList', { params: { sortKey: 'sortNo', sortType: 'asc' }, }); } export function getAgentModels() { return api.get>('/api/v1/model/list', { params: { modelType: 'chatModel', added: true }, }); } export function getPublishedKnowledgeList() { return api.get>('/api/v1/documentCollection/list', { params: { publishedOnly: true }, }); }