From 651e7a69ece46f078ad338f0ce3f154ff558007e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Tue, 30 Jun 2026 21:50:35 -0400 Subject: [PATCH] Fix Composio API endpoints to match verified v3 contract Updated getTools to use the validated toolkit_slug parameter and per-toolkit fetching. Updated executeTool to use the verified path POST /api/v3/tools/execute/{TOOL_NAME} with entityId and arguments fields. Updated normalizeToolSchema to use slug and input_parameters from the actual API response format. --- .../main/services/composio/composio-client.ts | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/AgentCompany-New/src/main/services/composio/composio-client.ts b/AgentCompany-New/src/main/services/composio/composio-client.ts index 043b1cbd..6656dcc7 100644 --- a/AgentCompany-New/src/main/services/composio/composio-client.ts +++ b/AgentCompany-New/src/main/services/composio/composio-client.ts @@ -21,27 +21,31 @@ export class ComposioClient { constructor(private readonly apiKey: string) {} async getTools(toolkits: string[]): Promise { - const params = new URLSearchParams(); - for (const toolkit of toolkits) params.append("toolkit", toolkit); - params.set("limit", "50"); - const url = `${BASE_URL}/tools?${params.toString()}`; - const response = await this.request("GET", url); - if (!Array.isArray(response.items)) return []; - return (response.items as Array>).map(normalizeToolSchema); + const all: ComposioToolSchema[] = []; + for (const toolkit of toolkits) { + const params = new URLSearchParams({ toolkit_slug: toolkit, limit: "20" }); + const url = `${BASE_URL}/tools?${params.toString()}`; + const response = await this.request("GET", url); + if (Array.isArray(response.items)) { + all.push(...(response.items as Array>).map(normalizeToolSchema)); + } + } + return all; } + async executeTool(input: { toolName: string; arguments: Record; entityId: string; connectedAccountId?: string; }): Promise { - const url = `${BASE_URL}/tools/${encodeURIComponent(input.toolName)}/execute`; + const url = `${BASE_URL}/tools/execute/${encodeURIComponent(input.toolName)}`; const body: Record = { - entity_id: input.entityId, - input: input.arguments, + entityId: input.entityId, + arguments: input.arguments, }; - if (input.connectedAccountId) body.connected_account_id = input.connectedAccountId; + if (input.connectedAccountId) body.connectedAccountId = input.connectedAccountId; const response = await this.request("POST", url, body); return { data: typeof response === "object" && response !== null ? response as Record : {}, @@ -110,11 +114,11 @@ export class ComposioClient { } function normalizeToolSchema(raw: Record): ComposioToolSchema { - const params = raw.parameters ?? raw.inputSchema ?? raw.input_schema ?? {}; + const params = raw.input_parameters ?? raw.parameters ?? raw.inputSchema ?? {}; const schema = typeof params === "object" && params !== null ? params as Record : {}; return { - name: String(raw.name ?? raw.slug ?? ""), - description: String(raw.description ?? raw.display_name ?? ""), + name: String(raw.slug ?? raw.name ?? ""), + description: String(raw.description ?? "").slice(0, 300), parameters: { type: "object", properties: (schema.properties ?? {}) as Record,