Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 04:30 UTC
feat(cli): default to empty object when no -d provided, use -d "{}" in search CTA for empty schemas
Made-with: Cursor
haxzie committed
Mar 6, 2026 at 11:48 UTC
68c6e502b8bb3dc85e59e6a9b3fe63634162ff1a
5 files changed
+46
-18
.changeset/vast-showers-lose.md
new
+6
@@ -0,0 +1,6 @@
1
+---
2
+'@composio/cli': patch
3
+---
4
+
5
+- Execute: Default to empty object `{}` when no -d/--data or piped stdin provided
6
+- Search CTA: Use `-d "{}"` for tools with no schema properties (shell-safe)
ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
+2
-3
@@ -63,9 +63,8 @@ const resolveInput = (input: Option.Option<string>) =>
63
return piped.value;
64
}
65
66
- return yield* Effect.fail(
67
- new Error('Missing JSON input. Provide -d/--data or pipe JSON to stdin.')
68
- );
66
+ // Default to empty object when no data provided (e.g. tools with no required args)
67
+ return '{}';
68
});
69
70
const parseArguments = (raw: string) =>
ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts
+2
-1
@@ -185,9 +185,10 @@ export const toolsCmd$Search = Command.make(
185
firstSchema?.input_schema as Record<string, unknown>
186
);
187
const payloadJson = JSON.stringify(payload);
188
+ const dataArg = Object.keys(payload).length === 0 ? '-d "{}"' : `-d '${payloadJson}'`;
189
cta.push({
190
action: 'Execute a tool',
190
- command: `composio execute "${firstSlug}" -d '${payloadJson}'`,
191
+ command: `composio execute "${firstSlug}" ${dataArg}`,
192
});
193
}
194
if (firstToolkit) {
ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
+14
-14
@@ -599,22 +599,22 @@ describe('CLI: composio tools execute', () => {
599
TestLive({
600
baseConfigProvider: testConfigProvider,
601
stdin: { isTTY: true, data: '' },
602
+ toolsExecutor: {
603
+ respondWith: {
604
+ data: { executed: true },
605
+ error: null,
606
+ successful: true,
607
+ },
608
+ },
609
})
603
- )('[Given] no -d and TTY stdin [Then] fails with missing input error', it => {
604
- it.scoped('fails with missing input error', () =>
610
+ )('[Given] no -d and TTY stdin [Then] defaults to empty object and executes', it => {
611
+ it.scoped('defaults to {} when no data provided', () =>
612
Effect.gen(function* () {
606
- const result = yield* cli([
607
- 'tools',
608
- 'execute',
609
- 'GMAIL_SEND_EMAIL',
610
- '--user-id',
611
- 'default',
612
- ]).pipe(Effect.catchAll(e => Effect.succeed(e)));
613
-
614
- expect(result).toBeDefined();
615
- expect(result instanceof Error ? result.message : String(result)).toContain(
616
- 'Missing JSON input'
617
- );
613
+ yield* cli(['tools', 'execute', 'GMAIL_SEND_EMAIL', '--user-id', 'default']);
614
+ const lines = yield* MockConsole.getLines({ stripAnsi: true });
615
+ const output = lines.join('\n');
616
+ expect(output).toContain('successful');
617
+ expect(output).toContain('executed');
618
})
619
);
620
});
ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts
+22
@@ -179,6 +179,28 @@ describe('CLI: composio tools search', () => {
179
}
180
);
181
182
+ layer(TestLive(testLiveOptions))(
183
+ '[Given] search with empty schema [Then] CTA execute uses -d "{}"',
184
+ it => {
185
+ it.scoped('CTA uses -d "{}" when no schema properties', () =>
186
+ Effect.gen(function* () {
187
+ yield* cli(['tools', 'search', 'send']);
188
+ const lines = yield* MockConsole.getLines({ stripAnsi: true });
189
+ const output = lines.join('\n');
190
+
191
+ const ctaMatch = output.match(/"CTA":\s*\[([\s\S]*?)\]/);
192
+ expect(ctaMatch).toBeTruthy();
193
+ const ctaJson = `[${ctaMatch![1]}]`;
194
+ const cta = JSON.parse(ctaJson) as Array<{ action: string; command: string }>;
195
+
196
+ const executeCta = cta.find(c => c.action === 'Execute a tool');
197
+ expect(executeCta).toBeTruthy();
198
+ expect(executeCta!.command).toContain('-d "{}"');
199
+ })
200
+ );
201
+ }
202
+ );
203
+
204
layer(TestLive(testLiveOptions))(
205
'[Given] --toolkits filter [Then] it is passed to session create as enabled toolkits',
206
it => {