Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/vast-showers-lose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@composio/cli': patch
---

- Execute: Default to empty object `{}` when no -d/--data or piped stdin provided
- Search CTA: Use `-d "{}"` for tools with no schema properties (shell-safe)
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ const resolveInput = (input: Option.Option<string>) =>
return piped.value;
}

return yield* Effect.fail(
new Error('Missing JSON input. Provide -d/--data or pipe JSON to stdin.')
);
// Default to empty object when no data provided (e.g. tools with no required args)
return '{}';
});

const parseArguments = (raw: string) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ export const toolsCmd$Search = Command.make(
firstSchema?.input_schema as Record<string, unknown>
);
const payloadJson = JSON.stringify(payload);
const dataArg = Object.keys(payload).length === 0 ? '-d "{}"' : `-d '${payloadJson}'`;
cta.push({
action: 'Execute a tool',
command: `composio execute "${firstSlug}" -d '${payloadJson}'`,
command: `composio execute "${firstSlug}" ${dataArg}`,
});
}
if (firstToolkit) {
Expand Down
28 changes: 14 additions & 14 deletions ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,22 +599,22 @@ describe('CLI: composio tools execute', () => {
TestLive({
baseConfigProvider: testConfigProvider,
stdin: { isTTY: true, data: '' },
toolsExecutor: {
respondWith: {
data: { executed: true },
error: null,
successful: true,
},
},
})
)('[Given] no -d and TTY stdin [Then] fails with missing input error', it => {
it.scoped('fails with missing input error', () =>
)('[Given] no -d and TTY stdin [Then] defaults to empty object and executes', it => {
it.scoped('defaults to {} when no data provided', () =>
Effect.gen(function* () {
const result = yield* cli([
'tools',
'execute',
'GMAIL_SEND_EMAIL',
'--user-id',
'default',
]).pipe(Effect.catchAll(e => Effect.succeed(e)));

expect(result).toBeDefined();
expect(result instanceof Error ? result.message : String(result)).toContain(
'Missing JSON input'
);
yield* cli(['tools', 'execute', 'GMAIL_SEND_EMAIL', '--user-id', 'default']);
const lines = yield* MockConsole.getLines({ stripAnsi: true });
const output = lines.join('\n');
expect(output).toContain('successful');
expect(output).toContain('executed');
})
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ describe('CLI: composio tools search', () => {
}
);

layer(TestLive(testLiveOptions))(
'[Given] search with empty schema [Then] CTA execute uses -d "{}"',
it => {
it.scoped('CTA uses -d "{}" when no schema properties', () =>
Effect.gen(function* () {
yield* cli(['tools', 'search', 'send']);
const lines = yield* MockConsole.getLines({ stripAnsi: true });
const output = lines.join('\n');

const ctaMatch = output.match(/"CTA":\s*\[([\s\S]*?)\]/);
expect(ctaMatch).toBeTruthy();
const ctaJson = `[${ctaMatch![1]}]`;
const cta = JSON.parse(ctaJson) as Array<{ action: string; command: string }>;

const executeCta = cta.find(c => c.action === 'Execute a tool');
expect(executeCta).toBeTruthy();
expect(executeCta!.command).toContain('-d "{}"');
})
);
}
);

layer(TestLive(testLiveOptions))(
'[Given] --toolkits filter [Then] it is passed to session create as enabled toolkits',
it => {
Expand Down
Loading