diff --git a/src/api/agents.ts b/src/api/agents.ts index 0a6a328..c752f29 100644 --- a/src/api/agents.ts +++ b/src/api/agents.ts @@ -57,6 +57,7 @@ export interface ExternalToolPluginPayload { baseUrl: string; authType: 'none' | 'bearer' | 'basic' | 'apiKey'; authConfig: Record; + headers?: Record | null; apis: ExternalToolApi[]; } diff --git a/src/components/ExternalToolEditor.tsx b/src/components/ExternalToolEditor.tsx index 6d988da..5f84086 100644 --- a/src/components/ExternalToolEditor.tsx +++ b/src/components/ExternalToolEditor.tsx @@ -19,8 +19,9 @@ interface ToolApiFormValue extends Omit { +interface ToolPluginFormValue extends Omit { authConfig?: string; + headers?: string; apis: ToolApiFormValue[]; } @@ -185,6 +186,7 @@ export default function ExternalToolEditor({ open, agentId, plugin, onClose, onS baseUrl: values.baseUrl.trim(), authType: values.authType, authConfig: parseJsonObject(values.authConfig, '认证配置', values.authType === 'none') || {}, + headers: parseJsonObject(values.headers, '统一请求头', true), apis: values.apis.map((item) => ({ name: item.name.trim(), description: item.description.trim(), @@ -235,6 +237,7 @@ export default function ExternalToolEditor({ open, agentId, plugin, onClose, onS baseUrl: plugin.baseUrl, authType: plugin.authType, authConfig: JSON.stringify(plugin.authConfig || {}, null, 2), + headers: JSON.stringify(plugin.headers || {}, null, 2), apis: plugin.apis.map((item) => ({ name: item.name, description: item.description, @@ -255,6 +258,7 @@ export default function ExternalToolEditor({ open, agentId, plugin, onClose, onS baseUrl: '', authType: 'bearer', authConfig: JSON.stringify({ token: '' }, null, 2), + headers: JSON.stringify({}, null, 2), apis: [{ ...EMPTY_API }], }, ); @@ -273,6 +277,13 @@ export default function ExternalToolEditor({ open, agentId, plugin, onClose, onS + + +