@devries-cameron20 / composio-1 / commits / 72b3dcbd1
Fork 0

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

Add a `--table` view for `composio triggers listen` that prints incoming events as compact rows and suppresses verbose event cards, with tests and help snapshot updates. Co-authored-by: Cursor <cursoragent@cursor.com>

haxzie committed Feb 23, 2026 at 18:11 UTC 72b3dcbd187f23fa2278ef79409da0793de3c53b
3 files changed +122 -34
ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
+60 -3
@@ -44,6 +44,13 @@ const json = Options.boolean('json').pipe(
44 Options.withDescription('Show raw event payload as JSON in interactive mode')
45 );
46
47 +const table = Options.boolean('table').pipe(
48 + Options.withDefault(false),
49 + Options.withDescription(
50 + 'Show compact table rows: timestamp, trigger_id, trigger_slug, toolkit, user_id, connected_account_id'
51 + )
52 +);
53 +
54 const maxEvents = Options.integer('max-events').pipe(
55 Options.withDescription('Stop after receiving N matching events'),
56 Options.optional
@@ -120,6 +127,24 @@ const detectWebhookPayloadVersion = (eventData: Record<string, unknown>): 'V1' |
127 return 'V1';
128 };
129
130 +const TABLE_COLUMNS = [
131 + { key: 'timestamp', width: 25 },
132 + { key: 'trigger_id', width: 16 },
133 + { key: 'trigger_slug', width: 28 },
134 + { key: 'toolkit', width: 12 },
135 + { key: 'user_id', width: 24 },
136 + { key: 'connected_account_id', width: 24 },
137 +] as const;
138 +
139 +const formatTableCell = (value: string, width: number): string => {
140 + if (value.length <= width) return value.padEnd(width, ' ');
141 + if (width <= 1) return value.slice(0, width);
142 + return `${value.slice(0, width - 1)}…`;
143 +};
144 +
145 +const formatTableRow = (columns: ReadonlyArray<{ value: string; width: number }>): string =>
146 + columns.map(col => formatTableCell(col.value, col.width)).join(' | ');
147 +
148 export const triggersCmd$Listen = Command.make(
149 'listen',
150 {
@@ -129,6 +154,7 @@ export const triggersCmd$Listen = Command.make(
154 triggerSlug,
155 userId,
156 json,
157 + table,
158 maxEvents,
159 forward,
160 out,
@@ -140,6 +166,7 @@ export const triggersCmd$Listen = Command.make(
166 triggerSlug,
167 userId,
168 json,
169 + table,
170 maxEvents,
171 forward,
172 out,
@@ -184,6 +211,7 @@ export const triggersCmd$Listen = Command.make(
211 const maxEventsLimit = Option.getOrUndefined(maxEvents);
212 const stopWhenDone = yield* Deferred.make<void>();
213 let matchingEvents = 0;
214 + let tableHeaderPrinted = false;
215
216 yield* ui.intro('composio triggers listen');
217 if (forwardUrl) {
@@ -223,14 +251,43 @@ export const triggersCmd$Listen = Command.make(
251 }
252
253 matchingEvents += 1;
226 - yield* ui.note(formatTriggerListenSummary(parsed), `Event #${matchingEvents}`);
254 + if (table) {
255 + if (!tableHeaderPrinted) {
256 + yield* ui.log.message(
257 + formatTableRow(TABLE_COLUMNS.map(col => ({ value: col.key, width: col.width })))
258 + );
259 + tableHeaderPrinted = true;
260 + }
261 +
262 + const tableLine = formatTableRow([
263 + {
264 + value:
265 + typeof eventData.timestamp === 'string'
266 + ? eventData.timestamp
267 + : new Date().toISOString(),
268 + width: TABLE_COLUMNS[0].width,
269 + },
270 + { value: parsed.id, width: TABLE_COLUMNS[1].width },
271 + { value: parsed.triggerSlug, width: TABLE_COLUMNS[2].width },
272 + { value: parsed.toolkitSlug, width: TABLE_COLUMNS[3].width },
273 + { value: parsed.userId || '-', width: TABLE_COLUMNS[4].width },
274 + {
275 + value: parsed.metadata.connectedAccount.id || '-',
276 + width: TABLE_COLUMNS[5].width,
277 + },
278 + ]);
279
228 - if (json) {
280 + yield* ui.log.message(tableLine);
281 + yield* ui.output(tableLine);
282 + } else if (json) {
283 + yield* ui.note(formatTriggerListenSummary(parsed), `Event #${matchingEvents}`);
284 yield* ui.log.message(JSON.stringify(eventData, null, 2));
285 + yield* ui.output(JSON.stringify(eventData));
286 } else {
287 + yield* ui.note(formatTriggerListenSummary(parsed), `Event #${matchingEvents}`);
288 yield* ui.log.message(JSON.stringify(parsed.payload, null, 2));
289 + yield* ui.output(JSON.stringify(eventData));
290 }
233 - yield* ui.output(JSON.stringify(eventData));
291
292 const payloadForForwarding = JSON.stringify(eventData);
293 const logLine = `${payloadForForwarding}\n`;
ts/packages/cli/test/src/commands/$default.cmd.test.ts
+31 -31
@@ -56,75 +56,75 @@ describe('CLI: composio', () => {
56
57 COMMANDS
58
59 - - version Display the current Composio CLI version.
59 + - version Display the current Composio CLI version.
60
61 - - upgrade Upgrade your Composio CLI to the latest available version.
61 + - upgrade Upgrade your Composio CLI to the latest available version.
62
63 - - whoami Display your account information.
63 + - whoami Display your account information.
64
65 - - login [--no-browser] Log in to the Composio SDK.
65 + - login [--no-browser] Log in to the Composio SDK.
66
67 - - logout Log out from the Composio SDK.
67 + - logout Log out from the Composio SDK.
68
69 - - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
69 + - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
70
71 - - py Handle Python projects.
71 + - py Handle Python projects.
72
73 - - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
73 + - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
74
75 Environment Variables:
76 COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
77 Use "latest" or unset to use the latest version.
78
79 - - ts Handle TypeScript projects.
79 + - ts Handle TypeScript projects.
80
81 - - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
81 + - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
82
83 Environment Variables:
84 COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
85 Use "latest" or unset to use the latest version.
86
87 - - toolkits Discover and inspect Composio toolkits.
87 + - toolkits Discover and inspect Composio toolkits.
88
89 - - toolkits list [--query text] [--limit integer] List available toolkits.
89 + - toolkits list [--query text] [--limit integer] List available toolkits.
90
91 - - toolkits info [<slug>] View details of a specific toolkit.
91 + - toolkits info [<slug>] View details of a specific toolkit.
92
93 - - toolkits search [--limit integer] <query> Search toolkits by use case.
93 + - toolkits search [--limit integer] <query> Search toolkits by use case.
94
95 - - tools Discover and inspect Composio tools.
95 + - tools Discover and inspect Composio tools.
96
97 - - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
97 + - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
98
99 - - tools info [<slug>] View details of a specific tool.
99 + - tools info [<slug>] View details of a specific tool.
100
101 - - tools search [--toolkits text] [--limit integer] <query> Search tools by use case.
101 + - tools search [--toolkits text] [--limit integer] <query> Search tools by use case.
102
103 - - auth-configs View and manage Composio auth configs.
103 + - auth-configs View and manage Composio auth configs.
104
105 - - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.
105 + - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.
106
107 - - auth-configs info [<id>] View details of a specific auth config.
107 + - auth-configs info [<id>] View details of a specific auth config.
108
109 - - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.
109 + - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.
110
111 - - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.
111 + - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.
112
113 - - connected-accounts View and manage Composio connected accounts.
113 + - connected-accounts View and manage Composio connected accounts.
114
115 - - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.
115 + - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.
116
117 - - connected-accounts info [<id>] View details of a specific connected account.
117 + - connected-accounts info [<id>] View details of a specific connected account.
118
119 - - connected-accounts whoami [<id>] Show the external account profile for a connected account.
119 + - connected-accounts whoami [<id>] Show the external account profile for a connected account.
120
121 - - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.
121 + - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.
122
123 - - connected-accounts link --auth-config text [--user-id text] [--no-browser] Link an external account via OAuth redirect.
123 + - connected-accounts link --auth-config text [--user-id text] [--no-browser] Link an external account via OAuth redirect.
124
125 - - triggers Subscribe to realtime trigger events.
125 + - triggers Subscribe to realtime trigger events.
126
127 - - 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.
127 + - 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.
128 "
129 `);
130 })
ts/packages/cli/test/src/commands/triggers/triggers.listen.cmd.test.ts
+31
@@ -130,6 +130,37 @@ describe('CLI: composio triggers listen', () => {
130 );
131 });
132
133 + layer(
134 + TestLive({
135 + baseConfigProvider: testConfigProvider,
136 + realtimeData: {
137 + events: [mockV3TriggerEvent],
138 + },
139 + })
140 + )('[Given] --table [Then] prints compact table rows', it => {
141 + it.scoped('prints table header and event row', () =>
142 + Effect.gen(function* () {
143 + yield* cli(['triggers', 'listen', '--table', '--max-events', '1']);
144 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
145 + const output = lines.join('\n');
146 +
147 + expect(output).toContain('timestamp');
148 + expect(output).toContain('trigger_id');
149 + expect(output).toContain('trigger_slug');
150 + expect(output).toContain('toolkit');
151 + expect(output).toContain('user_id');
152 + expect(output).toContain('connected_account_id');
153 + expect(output).not.toContain('Event #1');
154 + expect(output).not.toContain('Trigger:');
155 + expect(output).toContain('trg_123');
156 + expect(output).toContain('GMAIL_NEW_GMAIL_MESSAGE');
157 + expect(output).toContain('GMAIL');
158 + expect(output).toContain('user_123');
159 + expect(output).toContain('con_123');
160 + })
161 + );
162 + });
163 +
164 layer(TestLive())('[Given] no API key [Then] warns user to login', it => {
165 it.scoped('warns user to login', () =>
166 Effect.gen(function* () {