@customclaw/composio 0.0.3 → 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.
- package/dist/client.test.js +39 -0
- package/dist/tools/execute.js +9 -2
- package/package.json +1 -1
package/dist/client.test.js
CHANGED
|
@@ -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/tools/execute.js
CHANGED
|
@@ -31,8 +31,15 @@ export function createComposioExecuteTool(client, _config) {
|
|
|
31
31
|
details: { error: "tool_slug is required" },
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
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 {
|