@customclaw/composio 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import { describe, it, expect, vi } from "vitest";
2
2
  import { ComposioClient } from "./client.js";
3
3
  import { parseComposioConfig } from "./config.js";
4
+ import { createComposioExecuteTool } from "./tools/execute.js";
4
5
  // Mock the Composio SDK
5
6
  vi.mock("@composio/core", () => ({
6
7
  Composio: vi.fn().mockImplementation(() => ({
@@ -143,3 +144,41 @@ describe("session caching", () => {
143
144
  expect(instance.toolRouter.create).toHaveBeenCalledTimes(1);
144
145
  });
145
146
  });
147
+ describe("execute tool string arguments (GLM-5 workaround)", () => {
148
+ function makeTool() {
149
+ const client = makeClient();
150
+ const config = parseComposioConfig({ config: { apiKey: "test-key" } });
151
+ return createComposioExecuteTool(client, config);
152
+ }
153
+ it("parses string arguments as JSON", async () => {
154
+ const tool = makeTool();
155
+ const result = await tool.execute("test", {
156
+ tool_slug: "GMAIL_FETCH_EMAILS",
157
+ arguments: '{"user_id": "me", "max_results": 5}',
158
+ });
159
+ expect(result.details).toHaveProperty("success", true);
160
+ });
161
+ it("handles object arguments normally", async () => {
162
+ const tool = makeTool();
163
+ const result = await tool.execute("test", {
164
+ tool_slug: "GMAIL_FETCH_EMAILS",
165
+ arguments: { user_id: "me", max_results: 5 },
166
+ });
167
+ expect(result.details).toHaveProperty("success", true);
168
+ });
169
+ it("falls back to empty args on invalid JSON string", async () => {
170
+ const tool = makeTool();
171
+ const result = await tool.execute("test", {
172
+ tool_slug: "GMAIL_FETCH_EMAILS",
173
+ arguments: "not valid json",
174
+ });
175
+ expect(result.details).toHaveProperty("success", true);
176
+ });
177
+ it("falls back to empty args when arguments is missing", async () => {
178
+ const tool = makeTool();
179
+ const result = await tool.execute("test", {
180
+ tool_slug: "GMAIL_FETCH_EMAILS",
181
+ });
182
+ expect(result.details).toHaveProperty("success", true);
183
+ });
184
+ });
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { composioPluginConfigSchema, parseComposioConfig } from "./config.js";
2
2
  import { createComposioClient } from "./client.js";
3
+ import { createComposioSearchTool } from "./tools/search.js";
3
4
  import { createComposioExecuteTool } from "./tools/execute.js";
4
5
  import { createComposioConnectionsTool } from "./tools/connections.js";
5
6
  import { registerComposioCli } from "./cli.js";
@@ -47,6 +48,12 @@ const composioPlugin = {
47
48
  return client;
48
49
  };
49
50
  // Register tools (lazily create client on first use)
51
+ api.registerTool({
52
+ ...createComposioSearchTool(ensureClient(), config),
53
+ execute: async (toolCallId, params) => {
54
+ return createComposioSearchTool(ensureClient(), config).execute(toolCallId, params);
55
+ },
56
+ });
50
57
  api.registerTool({
51
58
  ...createComposioExecuteTool(ensureClient(), config),
52
59
  execute: async (toolCallId, params) => {
@@ -73,18 +80,16 @@ const composioPlugin = {
73
80
  You have access to Composio tools for third-party integrations (Gmail, Sentry, etc.).
74
81
 
75
82
  ## Usage
76
- 1. Use \`composio_manage_connections\` with action="status" to check if a toolkit is connected. Use action="create" to generate an auth URL if needed.
77
- 2. Use \`composio_execute_tool\` with a tool_slug and arguments to execute actions.
78
-
79
- ## Common tool slugs
80
- - GMAIL_FETCH_EMAILS, GMAIL_SEND_EMAIL, GMAIL_GET_PROFILE
81
- - SENTRY_LIST_ISSUES, SENTRY_GET_ISSUE
83
+ 1. Use \`composio_search_tools\` to find tools and their parameter schemas.
84
+ 2. Use \`composio_manage_connections\` with action="status" to check if a toolkit is connected. Use action="create" to generate an auth URL if needed.
85
+ 3. Use \`composio_execute_tool\` with the tool_slug and arguments from search results.
82
86
 
87
+ Always search first to get the correct parameter schema before executing a tool.
83
88
  Tool slugs are uppercase. If a tool fails with auth errors, prompt the user to connect the toolkit.
84
89
  </composio-tools>`,
85
90
  };
86
91
  });
87
- api.logger.info("[composio] Plugin registered with 2 tools and CLI commands");
92
+ api.logger.info("[composio] Plugin registered with 3 tools and CLI commands");
88
93
  },
89
94
  };
90
95
  export default composioPlugin;
@@ -31,8 +31,15 @@ export function createComposioExecuteTool(client, _config) {
31
31
  details: { error: "tool_slug is required" },
32
32
  };
33
33
  }
34
- const args = params.arguments && typeof params.arguments === "object" && !Array.isArray(params.arguments)
35
- ? params.arguments
34
+ let rawArgs = params.arguments;
35
+ if (typeof rawArgs === "string") {
36
+ try {
37
+ rawArgs = JSON.parse(rawArgs);
38
+ }
39
+ catch { }
40
+ }
41
+ const args = rawArgs && typeof rawArgs === "object" && !Array.isArray(rawArgs)
42
+ ? rawArgs
36
43
  : {};
37
44
  const userId = typeof params.user_id === "string" ? params.user_id : undefined;
38
45
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@customclaw/composio",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "description": "Composio Tool Router plugin for OpenClaw — access 1000+ third-party integrations",
6
6
  "main": "dist/index.js",