Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat(cli): add compact table mode for triggers listen

haxzie72b3dcbd187f
diff --git a/ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts b/ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
index e945a2933..20aac8010 100644
--- a/ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
+++ b/ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
@@ -44,6 +44,13 @@ const json = Options.boolean('json').pipe(
Options.withDescription('Show raw event payload as JSON in interactive mode')
);
+const table = Options.boolean('table').pipe(
+ Options.withDefault(false),
+ Options.withDescription(
+ 'Show compact table rows: timestamp, trigger_id, trigger_slug, toolkit, user_id, connected_account_id'
+ )
+);
+
const maxEvents = Options.integer('max-events').pipe(
Options.withDescription('Stop after receiving N matching events'),
Options.optional
@@ -120,6 +127,24 @@ const detectWebhookPayloadVersion = (eventData: Record<string, unknown>): 'V1' |
return 'V1';
};
+const TABLE_COLUMNS = [
+ { key: 'timestamp', width: 25 },
+ { key: 'trigger_id', width: 16 },
+ { key: 'trigger_slug', width: 28 },
+ { key: 'toolkit', width: 12 },
+ { key: 'user_id', width: 24 },
+ { key: 'connected_account_id', width: 24 },
+] as const;
+
+const formatTableCell = (value: string, width: number): string => {
+ if (value.length <= width) return value.padEnd(width, ' ');
+ if (width <= 1) return value.slice(0, width);
+ return `${value.slice(0, width - 1)}…`;
+};
+
+const formatTableRow = (columns: ReadonlyArray<{ value: string; width: number }>): string =>
+ columns.map(col => formatTableCell(col.value, col.width)).join(' | ');
+
export const triggersCmd$Listen = Command.make(
'listen',
{
@@ -129,6 +154,7 @@ export const triggersCmd$Listen = Command.make(
triggerSlug,
userId,
json,
+ table,
maxEvents,
forward,
out,
@@ -140,6 +166,7 @@ export const triggersCmd$Listen = Command.make(
triggerSlug,
userId,
json,
+ table,
maxEvents,
forward,
out,
@@ -184,6 +211,7 @@ export const triggersCmd$Listen = Command.make(
const maxEventsLimit = Option.getOrUndefined(maxEvents);
const stopWhenDone = yield* Deferred.make<void>();
let matchingEvents = 0;
+ let tableHeaderPrinted = false;
yield* ui.intro('composio triggers listen');
if (forwardUrl) {
@@ -223,14 +251,43 @@ export const triggersCmd$Listen = Command.make(
}
matchingEvents += 1;
- yield* ui.note(formatTriggerListenSummary(parsed), `Event #${matchingEvents}`);
+ if (table) {
+ if (!tableHeaderPrinted) {
+ yield* ui.log.message(
+ formatTableRow(TABLE_COLUMNS.map(col => ({ value: col.key, width: col.width })))
+ );
+ tableHeaderPrinted = true;
+ }
+
+ const tableLine = formatTableRow([
+ {
+ value:
+ typeof eventData.timestamp === 'string'
+ ? eventData.timestamp
+ : new Date().toISOString(),
+ width: TABLE_COLUMNS[0].width,
+ },
+ { value: parsed.id, width: TABLE_COLUMNS[1].width },
+ { value: parsed.triggerSlug, width: TABLE_COLUMNS[2].width },
+ { value: parsed.toolkitSlug, width: TABLE_COLUMNS[3].width },
+ { value: parsed.userId || '-', width: TABLE_COLUMNS[4].width },
+ {
+ value: parsed.metadata.connectedAccount.id || '-',
+ width: TABLE_COLUMNS[5].width,
+ },
+ ]);
- if (json) {
+ yield* ui.log.message(tableLine);
+ yield* ui.output(tableLine);
+ } else if (json) {
+ yield* ui.note(formatTriggerListenSummary(parsed), `Event #${matchingEvents}`);
yield* ui.log.message(JSON.stringify(eventData, null, 2));
+ yield* ui.output(JSON.stringify(eventData));
} else {
+ yield* ui.note(formatTriggerListenSummary(parsed), `Event #${matchingEvents}`);
yield* ui.log.message(JSON.stringify(parsed.payload, null, 2));
+ yield* ui.output(JSON.stringify(eventData));
}
- yield* ui.output(JSON.stringify(eventData));
const payloadForForwarding = JSON.stringify(eventData);
const logLine = `${payloadForForwarding}\n`;
diff --git a/ts/packages/cli/test/src/commands/$default.cmd.test.ts b/ts/packages/cli/test/src/commands/$default.cmd.test.ts
index 2869fbb55..fb0fc5e43 100644
--- a/ts/packages/cli/test/src/commands/$default.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/$default.cmd.test.ts
@@ -56,75 +56,75 @@ describe('CLI: composio', () => {
COMMANDS
- - version Display the current Composio CLI version.
+ - version Display the current Composio CLI version.
- - upgrade Upgrade your Composio CLI to the latest available version.
+ - upgrade Upgrade your Composio CLI to the latest available version.
- - whoami Display your account information.
+ - whoami Display your account information.
- - login [--no-browser] Log in to the Composio SDK.
+ - login [--no-browser] Log in to the Composio SDK.
- - logout Log out from the Composio SDK.
+ - logout Log out from the Composio SDK.
- - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
+ - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
- - py Handle Python projects.
+ - py Handle Python projects.
- - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
+ - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
Environment Variables:
COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
Use "latest" or unset to use the latest version.
- - ts Handle TypeScript projects.
+ - ts Handle TypeScript projects.
- - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
+ - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
Environment Variables:
COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
Use "latest" or unset to use the latest version.
- - toolkits Discover and inspect Composio toolkits.
+ - toolkits Discover and inspect Composio toolkits.
- - toolkits list [--query text] [--limit integer] List available toolkits.
+ - toolkits list [--query text] [--limit integer] List available toolkits.
- - toolkits info [<slug>] View details of a specific toolkit.
+ - toolkits info [<slug>] View details of a specific toolkit.
- - toolkits search [--limit integer] <query> Search toolkits by use case.
+ - toolkits search [--limit integer] <query> Search toolkits by use case.
- - tools Discover and inspect Composio tools.
+ - tools Discover and inspect Composio tools.
- - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
+ - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
- - tools info [<slug>] View details of a specific tool.
+ - tools info [<slug>] View details of a specific tool.
- - tools search [--toolkits text] [--limit integer] <query> Search tools by use case.
+ - tools search [--toolkits text] [--limit integer] <query> Search tools by use case.
- - auth-configs View and manage Composio auth configs.
+ - auth-configs View and manage Composio auth configs.
- - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.
+ - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.
- - auth-configs info [<id>] View details of a specific auth config.
+ - auth-configs info [<id>] View details of a specific auth config.
- - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.
+ - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.
- - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.
+ - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.
- - connected-accounts View and manage Composio connected accounts.
+ - connected-accounts View and manage Composio connected accounts.
- - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.
+ - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.
- - connected-accounts info [<id>] View details of a specific connected account.
+ - connected-accounts info [<id>] View details of a specific connected account.
- - connected-accounts whoami [<id>] Show the external account profile for a connected account.
+ - connected-accounts whoami [<id>] Show the external account profile for a connected account.
- - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.
+ - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.
- - connected-accounts link --auth-config text [--user-id text] [--no-browser] Link an external account via OAuth redirect.
+ - connected-accounts link --auth-config text [--user-id text] [--no-browser] Link an external account via OAuth redirect.
- - triggers Subscribe to realtime trigger events.
+ - triggers Subscribe to realtime trigger events.
- - triggers listen [--toolkits text] [--trigger-id text] [--connected-account-id text] [--trigger-slug text] [--user-id text] [--json] [--max-events integer] [--forward text] [--out text] Listen to realtime trigger events for your project.
+ - triggers listen [--toolkits text] [--trigger-id text] [--connected-account-id text] [--trigger-slug text] [--user-id text] [--json] [--table] [--max-events integer] [--forward text] [--out text] Listen to realtime trigger events for your project.
"
`);
})
diff --git a/ts/packages/cli/test/src/commands/triggers/triggers.listen.cmd.test.ts b/ts/packages/cli/test/src/commands/triggers/triggers.listen.cmd.test.ts
index 10b774762..59b666aca 100644
--- a/ts/packages/cli/test/src/commands/triggers/triggers.listen.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/triggers/triggers.listen.cmd.test.ts
@@ -130,6 +130,37 @@ describe('CLI: composio triggers listen', () => {
);
});
+ layer(
+ TestLive({
+ baseConfigProvider: testConfigProvider,
+ realtimeData: {
+ events: [mockV3TriggerEvent],
+ },
+ })
+ )('[Given] --table [Then] prints compact table rows', it => {
+ it.scoped('prints table header and event row', () =>
+ Effect.gen(function* () {
+ yield* cli(['triggers', 'listen', '--table', '--max-events', '1']);
+ const lines = yield* MockConsole.getLines({ stripAnsi: true });
+ const output = lines.join('\n');
+
+ expect(output).toContain('timestamp');
+ expect(output).toContain('trigger_id');
+ expect(output).toContain('trigger_slug');
+ expect(output).toContain('toolkit');
+ expect(output).toContain('user_id');
+ expect(output).toContain('connected_account_id');
+ expect(output).not.toContain('Event #1');
+ expect(output).not.toContain('Trigger:');
+ expect(output).toContain('trg_123');
+ expect(output).toContain('GMAIL_NEW_GMAIL_MESSAGE');
+ expect(output).toContain('GMAIL');
+ expect(output).toContain('user_123');
+ expect(output).toContain('con_123');
+ })
+ );
+ });
+
layer(TestLive())('[Given] no API key [Then] warns user to login', it => {
it.scoped('warns user to login', () =>
Effect.gen(function* () {