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, 05:45 UTC
feat(cli): add logs commands for triggers and tools (#2742)
Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
Musthaq Ahamad committed
Feb 25, 2026 at 15:41 UTC
2648fcaa18208db602a7b7a74f286042c5983e17
15 files changed
+1252
-232
pnpm-lock.yaml
+21
-73
@@ -25,8 +25,8 @@ catalogs:
25
specifier: ^4.20250917.0
26
version: 4.20260218.0
27
'@composio/client':
28
- specifier: 0.1.0-alpha.57
29
- version: 0.1.0-alpha.57
28
+ specifier: 0.1.0-alpha.60
29
+ version: 0.1.0-alpha.60
30
'@effect/cli':
31
specifier: ^0.73.2
32
version: 0.73.2
@@ -680,16 +680,16 @@ importers:
680
version: link:../../packages/providers/llamaindex
681
'@llamaindex/openai':
682
specifier: ^0.4.20
683
- version: 0.4.22(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(ws@8.19.0)(zod@3.25.76)
683
+ version: 0.4.22(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(ws@8.19.0)(zod@4.3.6)
684
'@llamaindex/workflow':
685
specifier: ^1.1.24
686
- version: 1.1.24(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@3.25.76))(hono@4.11.9)(zod@3.25.76)
686
+ version: 1.1.24(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@4.3.6))(hono@4.11.9)(zod@4.3.6)
687
dotenv:
688
specifier: ^16.4.1
689
version: 16.6.1
690
llamaindex:
691
specifier: ^0.12.0
692
- version: 0.12.1(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@3.25.76))(hono@4.11.9)(tree-sitter@0.22.4)(web-tree-sitter@0.24.7)(zod@3.25.76)
692
+ version: 0.12.1(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@4.3.6))(hono@4.11.9)(tree-sitter@0.22.4)(web-tree-sitter@0.24.7)(zod@4.3.6)
693
devDependencies:
694
'@types/bun':
695
specifier: ^1.2.9
@@ -1019,7 +1019,7 @@ importers:
1019
version: 1.0.1
1020
'@composio/client':
1021
specifier: 'catalog:'
1022
- version: 0.1.0-alpha.57
1022
+ version: 0.1.0-alpha.60
1023
'@composio/core':
1024
specifier: workspace:*
1025
version: link:../core
@@ -1116,7 +1116,7 @@ importers:
1116
dependencies:
1117
'@composio/client':
1118
specifier: 'catalog:'
1119
- version: 0.1.0-alpha.57
1119
+ version: 0.1.0-alpha.60
1120
'@composio/json-schema-to-zod':
1121
specifier: workspace:*
1122
version: link:../json-schema-to-zod
@@ -1289,7 +1289,7 @@ importers:
1289
dependencies:
1290
llamaindex:
1291
specifier: ^0.12.0
1292
- version: 0.12.1(tree-sitter@0.22.4)(web-tree-sitter@0.24.7)(zod@4.3.6)
1292
+ version: 0.12.1(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@4.3.6))(hono@4.11.9)(tree-sitter@0.22.4)(web-tree-sitter@0.24.7)(zod@4.3.6)
1293
devDependencies:
1294
'@composio/core':
1295
specifier: workspace:*
@@ -1763,8 +1763,8 @@ packages:
1763
resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==}
1764
engines: {node: '>=0.1.90'}
1765
1766
- '@composio/client@0.1.0-alpha.57':
1767
- resolution: {integrity: sha512-XCTGa/zwfofRaJA33UcJ2SSx/F/cWnedTNhaDZeWYyIliSGZ1CLEnqzTA8ip01Y3YNFXoWugKPnT07FslXnvpg==}
1766
+ '@composio/client@0.1.0-alpha.60':
1767
+ resolution: {integrity: sha512-i1/S+GX7ATzdQK0UzoaPdWqP4lmn/sCWF4ojGdq26k+cyEiq3aWN4HZFKYBp1jmwD1Sxn02RX9iTL09YAPn3Rg==}
1768
1769
'@cspotcode/source-map-support@0.8.1':
1770
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
@@ -6856,7 +6856,7 @@ snapshots:
6856
'@colors/colors@1.5.0':
6857
optional: true
6858
6859
- '@composio/client@0.1.0-alpha.57': {}
6859
+ '@composio/client@0.1.0-alpha.60': {}
6860
6861
'@cspotcode/source-map-support@0.8.1':
6862
dependencies:
@@ -7551,43 +7551,26 @@ snapshots:
7551
tree-sitter: 0.22.4
7552
web-tree-sitter: 0.24.7
7553
7554
- '@llamaindex/openai@0.4.22(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(ws@8.19.0)(zod@3.25.76)':
7554
+ '@llamaindex/openai@0.4.22(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(ws@8.19.0)(zod@4.3.6)':
7555
dependencies:
7556
'@llamaindex/core': 0.6.22
7557
'@llamaindex/env': 0.1.30
7558
- openai: 5.23.2(ws@8.19.0)(zod@3.25.76)
7558
+ openai: 5.23.2(ws@8.19.0)(zod@4.3.6)
7559
transitivePeerDependencies:
7560
- ws
7561
- zod
7562
7563
- '@llamaindex/workflow-core@1.3.3(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@3.25.76))(hono@4.11.9)(zod@3.25.76)':
7563
+ '@llamaindex/workflow-core@1.3.3(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@4.3.6))(hono@4.11.9)(zod@4.3.6)':
7564
optionalDependencies:
7565
- '@modelcontextprotocol/sdk': 1.26.0(@cfworker/json-schema@4.1.1)(zod@3.25.76)
7565
+ '@modelcontextprotocol/sdk': 1.26.0(@cfworker/json-schema@4.1.1)(zod@4.3.6)
7566
hono: 4.11.9
7567
- zod: 3.25.76
7568
-
7569
- '@llamaindex/workflow-core@1.3.3(zod@4.3.6)':
7570
- optionalDependencies:
7567
zod: 4.3.6
7568
7573
- '@llamaindex/workflow@1.1.24(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@3.25.76))(hono@4.11.9)(zod@3.25.76)':
7569
+ '@llamaindex/workflow@1.1.24(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@4.3.6))(hono@4.11.9)(zod@4.3.6)':
7570
dependencies:
7571
'@llamaindex/core': 0.6.22
7572
'@llamaindex/env': 0.1.30
7577
- '@llamaindex/workflow-core': 1.3.3(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@3.25.76))(hono@4.11.9)(zod@3.25.76)
7578
- transitivePeerDependencies:
7579
- - '@modelcontextprotocol/sdk'
7580
- - hono
7581
- - next
7582
- - p-retry
7583
- - rxjs
7584
- - zod
7585
-
7586
- '@llamaindex/workflow@1.1.24(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(zod@4.3.6)':
7587
- dependencies:
7588
- '@llamaindex/core': 0.6.22
7589
- '@llamaindex/env': 0.1.30
7590
- '@llamaindex/workflow-core': 1.3.3(zod@4.3.6)
7573
+ '@llamaindex/workflow-core': 1.3.3(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@4.3.6))(hono@4.11.9)(zod@4.3.6)
7574
transitivePeerDependencies:
7575
- '@modelcontextprotocol/sdk'
7576
- hono
@@ -8572,14 +8555,6 @@ snapshots:
8555
optionalDependencies:
8556
vite: 7.3.1(@types/node@22.19.11)(tsx@4.21.0)(yaml@2.8.2)
8557
8575
- '@vitest/mocker@3.2.4(vite@7.3.1(@types/node@24.10.13)(tsx@4.21.0)(yaml@2.8.2))':
8576
- dependencies:
8577
- '@vitest/spy': 3.2.4
8578
- estree-walker: 3.0.3
8579
- magic-string: 0.30.21
8580
- optionalDependencies:
8581
- vite: 7.3.1(@types/node@24.10.13)(tsx@4.21.0)(yaml@2.8.2)
8582
-
8558
'@vitest/pretty-format@3.2.4':
8559
dependencies:
8560
tinyrainbow: 2.0.0
@@ -8609,7 +8584,7 @@ snapshots:
8584
sirv: 3.0.2
8585
tinyglobby: 0.2.15
8586
tinyrainbow: 2.0.0
8612
- vitest: 3.2.4(@types/node@24.10.13)(@vitest/ui@3.2.4)(tsx@4.21.0)(yaml@2.8.2)
8587
+ vitest: 3.2.4(@types/node@22.19.11)(@vitest/ui@3.2.4)(tsx@4.21.0)(yaml@2.8.2)
8588
8589
'@vitest/utils@3.2.4':
8590
dependencies:
@@ -9976,34 +9951,12 @@ snapshots:
9951
rfdc: 1.4.1
9952
wrap-ansi: 9.0.2
9953
9979
- llamaindex@0.12.1(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@3.25.76))(hono@4.11.9)(tree-sitter@0.22.4)(web-tree-sitter@0.24.7)(zod@3.25.76):
9954
+ llamaindex@0.12.1(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@4.3.6))(hono@4.11.9)(tree-sitter@0.22.4)(web-tree-sitter@0.24.7)(zod@4.3.6):
9955
dependencies:
9956
'@llamaindex/core': 0.6.22
9957
'@llamaindex/env': 0.1.30
9958
'@llamaindex/node-parser': 2.0.22(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(tree-sitter@0.22.4)(web-tree-sitter@0.24.7)
9984
- '@llamaindex/workflow': 1.1.24(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@3.25.76))(hono@4.11.9)(zod@3.25.76)
9985
- '@types/lodash': 4.17.23
9986
- '@types/node': 24.10.13
9987
- lodash: 4.17.23
9988
- magic-bytes.js: 1.13.0
9989
- transitivePeerDependencies:
9990
- - '@huggingface/transformers'
9991
- - '@modelcontextprotocol/sdk'
9992
- - gpt-tokenizer
9993
- - hono
9994
- - next
9995
- - p-retry
9996
- - rxjs
9997
- - tree-sitter
9998
- - web-tree-sitter
9999
- - zod
10000
-
10001
- llamaindex@0.12.1(tree-sitter@0.22.4)(web-tree-sitter@0.24.7)(zod@4.3.6):
10002
- dependencies:
10003
- '@llamaindex/core': 0.6.22
10004
- '@llamaindex/env': 0.1.30
10005
- '@llamaindex/node-parser': 2.0.22(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(tree-sitter@0.22.4)(web-tree-sitter@0.24.7)
10006
- '@llamaindex/workflow': 1.1.24(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(zod@4.3.6)
9959
+ '@llamaindex/workflow': 1.1.24(@llamaindex/core@0.6.22)(@llamaindex/env@0.1.30)(@modelcontextprotocol/sdk@1.26.0(@cfworker/json-schema@4.1.1)(zod@4.3.6))(hono@4.11.9)(zod@4.3.6)
9960
'@types/lodash': 4.17.23
9961
'@types/node': 24.10.13
9962
lodash: 4.17.23
@@ -10283,11 +10236,6 @@ snapshots:
10236
is-inside-container: 1.0.0
10237
wsl-utils: 0.1.0
10238
10286
- openai@5.23.2(ws@8.19.0)(zod@3.25.76):
10287
- optionalDependencies:
10288
- ws: 8.19.0
10289
- zod: 3.25.76
10290
-
10239
openai@5.23.2(ws@8.19.0)(zod@4.3.6):
10240
optionalDependencies:
10241
ws: 8.19.0
@@ -11385,7 +11333,7 @@ snapshots:
11333
dependencies:
11334
'@types/chai': 5.2.3
11335
'@vitest/expect': 3.2.4
11388
- '@vitest/mocker': 3.2.4(vite@7.3.1(@types/node@24.10.13)(tsx@4.21.0)(yaml@2.8.2))
11336
+ '@vitest/mocker': 3.2.4(vite@7.3.1(@types/node@22.19.11)(tsx@4.21.0)(yaml@2.8.2))
11337
'@vitest/pretty-format': 3.2.4
11338
'@vitest/runner': 3.2.4
11339
'@vitest/snapshot': 3.2.4
pnpm-workspace.yaml
+1
-1
@@ -20,7 +20,7 @@ catalog:
20
'@clack/prompts': '^1.0.1'
21
'@cloudflare/vitest-pool-workers': ^0.9.2
22
'@cloudflare/workers-types': ^4.20250917.0
23
- '@composio/client': 0.1.0-alpha.57
23
+ '@composio/client': 0.1.0-alpha.60
24
'@effect/cli': ^0.73.2
25
'@effect/eslint-plugin': ^0.3.2
26
'@effect/language-service': ^0.74.0
ts/packages/cli/src/commands/index.ts
+2
@@ -17,6 +17,7 @@ import { toolsCmd } from './tools/tools.cmd';
17
import { authConfigsCmd } from './auth-configs/auth-configs.cmd';
18
import { connectedAccountsCmd } from './connected-accounts/connected-accounts.cmd';
19
import { triggersCmd } from './triggers/triggers.cmd';
20
+import { logsCmd } from './logs-cmd/logs.cmd';
21
22
const $cmd = $defaultCmd.pipe(
23
Command.withSubcommands([
@@ -34,6 +35,7 @@ const $cmd = $defaultCmd.pipe(
35
authConfigsCmd,
36
connectedAccountsCmd,
37
triggersCmd,
38
+ logsCmd,
39
])
40
);
41
ts/packages/cli/src/commands/logs-cmd/commands/logs.tools.cmd.ts
new
+238
@@ -0,0 +1,238 @@
1
+import { Args, Command, Options } from '@effect/cli';
2
+import { Effect, Option } from 'effect';
3
+import { requireAuth } from 'src/effects/require-auth';
4
+import { TerminalUI } from 'src/services/terminal-ui';
5
+import { ComposioClientSingleton } from 'src/services/composio-clients';
6
+import { clampLimit } from 'src/ui/clamp-limit';
7
+import { parseCsv } from 'src/commands/triggers/parse-csv';
8
+import { formatToolLogInfo, formatToolLogsTable } from '../format';
9
+import { toSearchParam } from '../utils';
10
+
11
+type ToolLogFilterInput = {
12
+ tool?: string;
13
+ toolkit?: string;
14
+ connectedAccountId?: string;
15
+ authConfigId?: string;
16
+ status?: string;
17
+ userId?: string;
18
+ logId?: string;
19
+ toolRouterSessionId?: string;
20
+ sessionId?: string;
21
+};
22
+
23
+const toSearchParams = (value: string | undefined, field: string) =>
24
+ value === undefined ? [] : parseCsv(value).map(item => toSearchParam(field, item));
25
+
26
+export const buildToolLogShorthandSearchParams = (
27
+ filters: ToolLogFilterInput
28
+): Array<ReturnType<typeof toSearchParam>> => [
29
+ ...toSearchParams(filters.tool, 'action_key'),
30
+ ...toSearchParams(filters.toolkit, 'toolkit_key'),
31
+ ...toSearchParams(filters.connectedAccountId, 'connected_account_id'),
32
+ ...toSearchParams(filters.authConfigId, 'auth_config_id'),
33
+ ...toSearchParams(filters.status, 'execution_status'),
34
+ ...toSearchParams(filters.userId, 'user_id'),
35
+ ...toSearchParams(filters.logId, 'log_id'),
36
+ ...toSearchParams(filters.toolRouterSessionId, 'tool_router_session_id'),
37
+ ...toSearchParams(filters.sessionId, 'session_id'),
38
+];
39
+
40
+const cursor = Options.integer('cursor').pipe(
41
+ Options.optional,
42
+ Options.withDescription('Cursor for pagination')
43
+);
44
+
45
+const from = Options.integer('from').pipe(
46
+ Options.withDescription('Start timestamp (epoch milliseconds)'),
47
+ Options.optional
48
+);
49
+
50
+const to = Options.integer('to').pipe(
51
+ Options.withDescription('End timestamp (epoch milliseconds)'),
52
+ Options.optional
53
+);
54
+
55
+const limit = Options.integer('limit').pipe(
56
+ Options.withDefault(30),
57
+ Options.withDescription('Number of logs to fetch (1-1000)')
58
+);
59
+
60
+const caseSensitive = Options.boolean('case-sensitive').pipe(
61
+ Options.withDefault(false),
62
+ Options.withDescription('Whether search params are case-sensitive')
63
+);
64
+
65
+const toolkit = Options.text('toolkit').pipe(
66
+ Options.withDescription('Filter by toolkit key(s), comma-separated (e.g. "gmail,slack")'),
67
+ Options.optional
68
+);
69
+
70
+const tool = Options.text('tool').pipe(
71
+ Options.withDescription('Filter by tool key(s), comma-separated (e.g. "GMAIL_SEND_EMAIL")'),
72
+ Options.optional
73
+);
74
+
75
+const connectedAccountId = Options.text('connected-account-id').pipe(
76
+ Options.withDescription('Filter by connected account id(s), comma-separated'),
77
+ Options.optional
78
+);
79
+
80
+const authConfigId = Options.text('auth-config-id').pipe(
81
+ Options.withDescription('Filter by auth config id(s), comma-separated'),
82
+ Options.optional
83
+);
84
+
85
+const status = Options.text('status').pipe(
86
+ Options.withDescription('Filter by execution status value(s), comma-separated'),
87
+ Options.optional
88
+);
89
+
90
+const userId = Options.text('user-id').pipe(
91
+ Options.withDescription('Filter by user id(s), comma-separated'),
92
+ Options.optional
93
+);
94
+
95
+const logIdFilter = Options.text('log-id').pipe(
96
+ Options.withDescription('Filter by log id(s), comma-separated'),
97
+ Options.optional
98
+);
99
+
100
+const toolRouterSessionId = Options.text('tool-router-session-id').pipe(
101
+ Options.withDescription('Filter by tool router session id(s), comma-separated'),
102
+ Options.optional
103
+);
104
+
105
+const sessionId = Options.text('session-id').pipe(
106
+ Options.withDescription('Filter by session id(s), comma-separated'),
107
+ Options.optional
108
+);
109
+
110
+const logId = Args.text({ name: 'log_id' }).pipe(
111
+ Args.withDescription('Tool log ID'),
112
+ Args.optional
113
+);
114
+
115
+/**
116
+ * List tool execution logs with optional filters.
117
+ *
118
+ * @example
119
+ * ```bash
120
+ * composio logs tools --limit 50
121
+ * composio logs tools <log_id>
122
+ * composio logs tools --toolkit gmail --tool GMAIL_SEND_EMAIL
123
+ * composio logs tools --connected-account-id con_123 --user-id user_123
124
+ * composio logs tools --status success --auth-config-id ac_123
125
+ * composio logs tools --from 1735689600000 --to 1735776000000
126
+ * ```
127
+ */
128
+export const logsCmd$Tools = Command.make(
129
+ 'tools',
130
+ {
131
+ logId,
132
+ cursor,
133
+ from,
134
+ to,
135
+ limit,
136
+ caseSensitive,
137
+ toolkit,
138
+ tool,
139
+ connectedAccountId,
140
+ authConfigId,
141
+ status,
142
+ userId,
143
+ logIdFilter,
144
+ toolRouterSessionId,
145
+ sessionId,
146
+ },
147
+ ({
148
+ logId,
149
+ cursor,
150
+ from,
151
+ to,
152
+ limit,
153
+ caseSensitive,
154
+ toolkit,
155
+ tool,
156
+ connectedAccountId,
157
+ authConfigId,
158
+ status,
159
+ userId,
160
+ logIdFilter,
161
+ toolRouterSessionId,
162
+ sessionId,
163
+ }) =>
164
+ Effect.gen(function* () {
165
+ if (!(yield* requireAuth)) return;
166
+
167
+ const ui = yield* TerminalUI;
168
+ const clientSingleton = yield* ComposioClientSingleton;
169
+ const client = yield* clientSingleton.get();
170
+ const clampedLimit = clampLimit(limit);
171
+ const shorthandSearchParams = buildToolLogShorthandSearchParams({
172
+ tool: Option.getOrUndefined(tool),
173
+ toolkit: Option.getOrUndefined(toolkit),
174
+ connectedAccountId: Option.getOrUndefined(connectedAccountId),
175
+ authConfigId: Option.getOrUndefined(authConfigId),
176
+ status: Option.getOrUndefined(status),
177
+ userId: Option.getOrUndefined(userId),
178
+ logId: Option.getOrUndefined(logIdFilter),
179
+ toolRouterSessionId: Option.getOrUndefined(toolRouterSessionId),
180
+ sessionId: Option.getOrUndefined(sessionId),
181
+ });
182
+ const toolLogId = Option.getOrUndefined(logId);
183
+
184
+ if (toolLogId) {
185
+ const toolLog = yield* ui.withSpinner(
186
+ `Fetching tool log "${toolLogId}"...`,
187
+ Effect.tryPromise(() => client.logs.tools.retrieve(toolLogId))
188
+ );
189
+
190
+ yield* ui.log.info(
191
+ `${formatToolLogInfo(toolLog)}\n\nPayload:\n${JSON.stringify(toolLog.payloadReceived, null, 2)}\n\nResponse:\n${JSON.stringify(toolLog.response, null, 2)}`
192
+ );
193
+ yield* ui.output(JSON.stringify(toolLog, null, 2));
194
+ return;
195
+ }
196
+
197
+ const response = yield* ui.withSpinner(
198
+ 'Fetching tool logs...',
199
+ Effect.tryPromise(() =>
200
+ client.logs.tools.list({
201
+ cursor: Option.getOrUndefined(cursor) ?? null,
202
+ from: Option.getOrUndefined(from),
203
+ to: Option.getOrUndefined(to),
204
+ limit: clampedLimit,
205
+ case_sensitive: caseSensitive,
206
+ search_params: shorthandSearchParams.length > 0 ? shorthandSearchParams : undefined,
207
+ })
208
+ )
209
+ );
210
+
211
+ const logs = response.data ?? [];
212
+
213
+ if (logs.length === 0) {
214
+ yield* ui.log.warn('No tool logs found for the given filters.');
215
+ yield* ui.output(JSON.stringify(response, null, 2));
216
+ return;
217
+ }
218
+
219
+ yield* ui.log.info(
220
+ `Listing ${logs.length} tool log${logs.length === 1 ? '' : 's'}\n\n${formatToolLogsTable(logs)}`
221
+ );
222
+
223
+ const firstLogId = logs[0]?.id;
224
+ if (firstLogId) {
225
+ yield* ui.log.step(
226
+ `To view full details for a log:\n> composio logs tools "${firstLogId}"`
227
+ );
228
+ }
229
+
230
+ if (response.nextCursor !== null && response.nextCursor !== undefined) {
231
+ yield* ui.log.step(`Next cursor: ${response.nextCursor}`);
232
+ }
233
+
234
+ yield* ui.output(JSON.stringify(response, null, 2));
235
+ })
236
+).pipe(
237
+ Command.withDescription('List tool execution logs, or pass a log_id to fetch a specific log.')
238
+);
ts/packages/cli/src/commands/logs-cmd/commands/logs.triggers.cmd.ts
new
+253
@@ -0,0 +1,253 @@
1
+import { Args, Command, Options } from '@effect/cli';
2
+import { Effect, Option } from 'effect';
3
+import { requireAuth } from 'src/effects/require-auth';
4
+import { TerminalUI } from 'src/services/terminal-ui';
5
+import { ComposioClientSingleton } from 'src/services/composio-clients';
6
+import { clampLimit } from 'src/ui/clamp-limit';
7
+import { parseCsv } from 'src/commands/triggers/parse-csv';
8
+import { formatTriggerLogInfo, formatTriggerLogsTable } from '../format';
9
+import { toSearchParam } from '../utils';
10
+
11
+const cursor = Options.text('cursor').pipe(
12
+ Options.withDescription('Cursor for pagination'),
13
+ Options.optional
14
+);
15
+
16
+const userId = Options.text('user-id').pipe(
17
+ Options.withDescription('Filter by user id'),
18
+ Options.optional
19
+);
20
+
21
+const connectedAccountId = Options.text('connected-account-id').pipe(
22
+ Options.withDescription('Filter by connected account id'),
23
+ Options.optional
24
+);
25
+
26
+const trigger = Options.text('trigger').pipe(
27
+ Options.withDescription('Filter by trigger name'),
28
+ Options.optional
29
+);
30
+
31
+const triggerId = Options.text('trigger-id').pipe(
32
+ Options.withDescription('Filter by trigger id'),
33
+ Options.optional
34
+);
35
+
36
+const logIdFilter = Options.text('log-id').pipe(
37
+ Options.withDescription('Filter by log id'),
38
+ Options.optional
39
+);
40
+
41
+const logId = Args.text({ name: 'log_id' }).pipe(
42
+ Args.withDescription('Trigger log ID'),
43
+ Args.optional
44
+);
45
+
46
+const from = Options.integer('from').pipe(
47
+ Options.withDescription('Start timestamp (epoch milliseconds)'),
48
+ Options.optional
49
+);
50
+
51
+const to = Options.integer('to').pipe(
52
+ Options.withDescription('End timestamp (epoch milliseconds)'),
53
+ Options.optional
54
+);
55
+
56
+const limit = Options.integer('limit').pipe(
57
+ Options.withDefault(30),
58
+ Options.withDescription('Number of logs to fetch (1-1000)')
59
+);
60
+
61
+const time = Options.choice('time', ['5m', '30m', '6h', '1d', '1w', '1month', '1y'] as const).pipe(
62
+ Options.optional,
63
+ Options.withDescription('Show logs from a relative time window')
64
+);
65
+
66
+const search = Options.text('search').pipe(
67
+ Options.withDescription('Full-text search query'),
68
+ Options.optional
69
+);
70
+
71
+const includePayload = Options.boolean('include-payload').pipe(
72
+ Options.withDefault(false),
73
+ Options.withDescription('Include payload fields in response')
74
+);
75
+
76
+/**
77
+ * List trigger logs with optional filters.
78
+ *
79
+ * @example
80
+ * ```bash
81
+ * composio logs triggers <log_id>
82
+ * composio logs triggers --trigger GMAIL_NEW_GMAIL_MESSAGE
83
+ * composio logs triggers --trigger-id 77ac1dbf-6db0-4039-8dbe-e903b3f2057e
84
+ * composio logs triggers --connected-account-id ca_123 --user-id user_123
85
+ * composio logs triggers --log-id log_123
86
+ * ```
87
+ */
88
+export const logsCmd$Triggers = Command.make(
89
+ 'triggers',
90
+ {
91
+ logId,
92
+ cursor,
93
+ userId,
94
+ connectedAccountId,
95
+ trigger,
96
+ triggerId,
97
+ logIdFilter,
98
+ from,
99
+ to,
100
+ limit,
101
+ time,
102
+ search,
103
+ includePayload,
104
+ },
105
+ ({
106
+ logId,
107
+ cursor,
108
+ userId,
109
+ connectedAccountId,
110
+ trigger,
111
+ triggerId,
112
+ logIdFilter,
113
+ from,
114
+ to,
115
+ limit,
116
+ time,
117
+ search,
118
+ includePayload,
119
+ }) =>
120
+ Effect.gen(function* () {
121
+ if (!(yield* requireAuth)) return;
122
+
123
+ const ui = yield* TerminalUI;
124
+ const clientSingleton = yield* ComposioClientSingleton;
125
+ const client = yield* clientSingleton.get();
126
+ const clampedLimit = clampLimit(limit);
127
+ const shorthandSearchParams = [
128
+ ...(Option.isSome(trigger)
129
+ ? parseCsv(trigger.value).map(value => toSearchParam('trigger_name', value))
130
+ : []),
131
+ ...(Option.isSome(triggerId)
132
+ ? parseCsv(triggerId.value).map(value => toSearchParam('trigger_id', value))
133
+ : []),
134
+ ...(Option.isSome(userId)
135
+ ? parseCsv(userId.value).map(value => toSearchParam('user_id', value))
136
+ : []),
137
+ ...(Option.isSome(connectedAccountId)
138
+ ? parseCsv(connectedAccountId.value).map(value =>
139
+ toSearchParam('connected_account_id', value)
140
+ )
141
+ : []),
142
+ ...(Option.isSome(logIdFilter)
143
+ ? parseCsv(logIdFilter.value).map(value => toSearchParam('log_id', value))
144
+ : []),
145
+ ];
146
+ const triggerLogId = Option.getOrUndefined(logId);
147
+
148
+ if (triggerLogId) {
149
+ const triggerLog = yield* ui.withSpinner(
150
+ `Fetching trigger log "${triggerLogId}"...`,
151
+ Effect.tryPromise(() => client.logs.triggers.retrieve(triggerLogId))
152
+ );
153
+ const triggerLogData = triggerLog as unknown as Record<string, unknown>;
154
+ const normalizedLogData = getTriggerLogRecord(triggerLogData);
155
+ const payload = getTriggerPayload(normalizedLogData);
156
+ const response = getTriggerResponse(normalizedLogData);
157
+
158
+ yield* ui.log.info(
159
+ `${formatTriggerLogInfo(triggerLog)}\n\nPayload:\n${JSON.stringify(payload, null, 2)}\n\nResponse:\n${JSON.stringify(response, null, 2)}`
160
+ );
161
+ yield* ui.output(JSON.stringify(triggerLog, null, 2));
162
+ return;
163
+ }
164
+
165
+ const response = yield* ui.withSpinner(
166
+ 'Fetching trigger logs...',
167
+ Effect.tryPromise(() =>
168
+ client.logs.triggers.list({
169
+ cursor: Option.getOrUndefined(cursor),
170
+ from: Option.getOrUndefined(from),
171
+ to: Option.getOrUndefined(to),
172
+ limit: clampedLimit,
173
+ time: Option.getOrUndefined(time),
174
+ search: Option.getOrUndefined(search),
175
+ include_payload: includePayload,
176
+ search_params: shorthandSearchParams.length > 0 ? shorthandSearchParams : undefined,
177
+ })
178
+ )
179
+ );
180
+
181
+ const logs = response.data ?? [];
182
+
183
+ if (logs.length === 0) {
184
+ yield* ui.log.warn('No trigger logs found for the given filters.');
185
+ yield* ui.output(JSON.stringify(response, null, 2));
186
+ return;
187
+ }
188
+
189
+ yield* ui.log.info(
190
+ `Listing ${logs.length} trigger log${logs.length === 1 ? '' : 's'}\n\n${formatTriggerLogsTable(logs)}`
191
+ );
192
+
193
+ const firstLogId = logs[0]?.id;
194
+ if (firstLogId) {
195
+ yield* ui.log.step(
196
+ `To view full details for a log:\n> composio logs triggers "${firstLogId}"`
197
+ );
198
+ }
199
+
200
+ if (response.nextCursor) {
201
+ yield* ui.log.step(`Next cursor: ${response.nextCursor}`);
202
+ }
203
+
204
+ yield* ui.output(JSON.stringify(response, null, 2));
205
+ })
206
+).pipe(Command.withDescription('List trigger logs.'));
207
+
208
+export const getTriggerLogRecord = (record: Record<string, unknown>): Record<string, unknown> => {
209
+ const log = record.log;
210
+ if (log && typeof log === 'object') return log as Record<string, unknown>;
211
+ return record;
212
+};
213
+
214
+export const getTriggerPayload = (record: Record<string, unknown>): unknown => {
215
+ const meta = record.meta;
216
+ const metaRecord = meta && typeof meta === 'object' ? (meta as Record<string, unknown>) : {};
217
+ const rawPayload =
218
+ metaRecord.triggerProviderPayload ??
219
+ metaRecord.triggerClientPayload ??
220
+ record.payloadReceived ??
221
+ record.payload ??
222
+ null;
223
+
224
+ return parseMaybeJson(rawPayload);
225
+};
226
+
227
+export const getTriggerResponse = (record: Record<string, unknown>): unknown => {
228
+ const meta = record.meta;
229
+ const metaRecord = meta && typeof meta === 'object' ? (meta as Record<string, unknown>) : {};
230
+ const rawResponse =
231
+ metaRecord.triggerClientResponse ??
232
+ metaRecord.triggerProviderResponse ??
233
+ record.response ??
234
+ null;
235
+
236
+ return parseMaybeJson(rawResponse);
237
+};
238
+
239
+export const parseMaybeJson = (value: unknown): unknown => {
240
+ if (typeof value !== 'string') return value;
241
+ const trimmed = value.trim();
242
+ if (
243
+ (trimmed.startsWith('{') && trimmed.endsWith('}')) ||
244
+ (trimmed.startsWith('[') && trimmed.endsWith(']'))
245
+ ) {
246
+ try {
247
+ return JSON.parse(trimmed);
248
+ } catch {
249
+ return value;
250
+ }
251
+ }
252
+ return value;
253
+};
ts/packages/cli/src/commands/logs-cmd/format.ts
new
+268
@@ -0,0 +1,268 @@
1
+import type { Logs } from '@composio/client/resources/logs/logs';
2
+import { bold, gray, green, red } from 'src/ui/colors';
3
+import { truncate } from 'src/ui/truncate';
4
+
5
+type TriggerLog = Logs.TriggerListResponse.Data;
6
+type ToolLog = Logs.ToolListResponse.Data;
7
+type ToolLogDetailed = Logs.ToolRetrieveResponse;
8
+
9
+const TRIGGER_LOG_TABLE = {
10
+ createdAt: 24,
11
+ id: 18,
12
+ triggerId: 18,
13
+ app: 12,
14
+ triggerName: 28,
15
+ triggerUserId: 16,
16
+ connectedAccountId: 20,
17
+} as const;
18
+
19
+const TOOL_LOG_TABLE = {
20
+ createdAt: 24,
21
+ id: 18,
22
+ status: 8,
23
+ app: 12,
24
+ actionKey: 28,
25
+ executionMs: 12,
26
+ connectedAccountId: 20,
27
+} as const;
28
+
29
+export const formatTriggerLogsTable = (logs: ReadonlyArray<TriggerLog>): string => {
30
+ const header = [
31
+ bold('Created At'.padEnd(TRIGGER_LOG_TABLE.createdAt)),
32
+ bold('Log Id'.padEnd(TRIGGER_LOG_TABLE.id)),
33
+ bold('Trigger Id'.padEnd(TRIGGER_LOG_TABLE.triggerId)),
34
+ bold('Toolkit'.padEnd(TRIGGER_LOG_TABLE.app)),
35
+ bold('Trigger'.padEnd(TRIGGER_LOG_TABLE.triggerName)),
36
+ bold('User Id'.padEnd(TRIGGER_LOG_TABLE.triggerUserId)),
37
+ bold('Connected Account Id'),
38
+ ].join(' ');
39
+
40
+ const rows = logs.map(log => {
41
+ const createdAt = gray(
42
+ truncate(formatCreatedAt(log.createdAt), TRIGGER_LOG_TABLE.createdAt).padEnd(
43
+ TRIGGER_LOG_TABLE.createdAt
44
+ )
45
+ );
46
+ const id = (log.id ?? '-').padEnd(TRIGGER_LOG_TABLE.id);
47
+ const triggerId = truncate(getTriggerId(log), TRIGGER_LOG_TABLE.triggerId).padEnd(
48
+ TRIGGER_LOG_TABLE.triggerId
49
+ );
50
+ const app = truncate(log.appName ?? '-', TRIGGER_LOG_TABLE.app).padEnd(TRIGGER_LOG_TABLE.app);
51
+ const triggerName = truncate(getTriggerName(log), TRIGGER_LOG_TABLE.triggerName).padEnd(
52
+ TRIGGER_LOG_TABLE.triggerName
53
+ );
54
+ const triggerUserId = truncate(log.entityId ?? '-', TRIGGER_LOG_TABLE.triggerUserId).padEnd(
55
+ TRIGGER_LOG_TABLE.triggerUserId
56
+ );
57
+ const connectedAccountId = truncate(
58
+ log.connectionId ?? '-',
59
+ TRIGGER_LOG_TABLE.connectedAccountId
60
+ );
61
+
62
+ return [createdAt, id, triggerId, app, triggerName, triggerUserId, connectedAccountId].join(
63
+ ' '
64
+ );
65
+ });
66
+
67
+ return [header, ...rows].join('\n');
68
+};
69
+
70
+export const formatToolLogsTable = (logs: ReadonlyArray<ToolLog>): string => {
71
+ const header = [
72
+ bold('Created At'.padEnd(TOOL_LOG_TABLE.createdAt)),
73
+ bold('Log Id'.padEnd(TOOL_LOG_TABLE.id)),
74
+ bold('Status'.padEnd(TOOL_LOG_TABLE.status)),
75
+ bold('Toolkit'.padEnd(TOOL_LOG_TABLE.app)),
76
+ bold('Tool'.padEnd(TOOL_LOG_TABLE.actionKey)),
77
+ bold('Exec Time'.padEnd(TOOL_LOG_TABLE.executionMs)),
78
+ bold('Connected Account'),
79
+ ].join(' ');
80
+
81
+ const rows = logs.map(log => {
82
+ const createdAt = gray(
83
+ truncate(formatCreatedAt(log.createdAt), TOOL_LOG_TABLE.createdAt).padEnd(
84
+ TOOL_LOG_TABLE.createdAt
85
+ )
86
+ );
87
+ // Keep log ids untruncated for copy/paste workflows.
88
+ const id = (log.id ?? '-').padEnd(TOOL_LOG_TABLE.id);
89
+ const status = formatLogStatus(log.status, TOOL_LOG_TABLE.status);
90
+ const app = truncate(log.app?.name ?? '-', TOOL_LOG_TABLE.app).padEnd(TOOL_LOG_TABLE.app);
91
+ const actionKey = truncate(log.actionKey ?? '-', TOOL_LOG_TABLE.actionKey).padEnd(
92
+ TOOL_LOG_TABLE.actionKey
93
+ );
94
+ const executionMs = `${log.executionTime ?? 0}ms`.padEnd(TOOL_LOG_TABLE.executionMs);
95
+ const connectedAccountId = truncate(
96
+ valueOrDash(log.connectedAccountId),
97
+ TOOL_LOG_TABLE.connectedAccountId
98
+ );
99
+
100
+ return [createdAt, id, status, app, actionKey, executionMs, connectedAccountId].join(' ');
101
+ });
102
+
103
+ return [header, ...rows].join('\n');
104
+};
105
+
106
+const formatLogStatus = (status: string | null | undefined, width: number): string => {
107
+ const label = truncate(valueOrDash(status), width).padEnd(width);
108
+ const normalizedStatus = status?.trim().toLowerCase();
109
+
110
+ if (normalizedStatus === 'success') return green(label);
111
+ if (normalizedStatus === 'failure' || normalizedStatus === 'failed') return red(label);
112
+ return label;
113
+};
114
+
115
+const valueOrDash = (value: string | null | undefined): string => {
116
+ if (value == null) return '-';
117
+ const normalizedValue = value.trim();
118
+ return normalizedValue.length > 0 ? normalizedValue : '-';
119
+};
120
+
121
+const getTriggerId = (log: TriggerLog): string => {
122
+ const dynamicLog = log as unknown as Record<string, unknown>;
123
+ const dynamicMeta = (dynamicLog.meta ?? {}) as Record<string, unknown>;
124
+ const triggerId =
125
+ typeof dynamicMeta.triggerNanoId === 'string'
126
+ ? dynamicMeta.triggerNanoId
127
+ : typeof dynamicMeta.trigger_nano_id === 'string'
128
+ ? dynamicMeta.trigger_nano_id
129
+ : typeof dynamicMeta.triggerId === 'string'
130
+ ? dynamicMeta.triggerId
131
+ : typeof dynamicMeta.trigger_id === 'string'
132
+ ? dynamicMeta.trigger_id
133
+ : typeof dynamicLog.triggerNanoId === 'string'
134
+ ? dynamicLog.triggerNanoId
135
+ : typeof dynamicLog.trigger_nano_id === 'string'
136
+ ? dynamicLog.trigger_nano_id
137
+ : typeof dynamicLog.triggerId === 'string'
138
+ ? dynamicLog.triggerId
139
+ : typeof dynamicLog.trigger_id === 'string'
140
+ ? dynamicLog.trigger_id
141
+ : null;
142
+ return valueOrDash(triggerId);
143
+};
144
+
145
+const getTriggerName = (log: TriggerLog): string => {
146
+ const dynamicLog = log as unknown as Record<string, unknown>;
147
+ const dynamicMeta = (dynamicLog.meta ?? {}) as Record<string, unknown>;
148
+ const triggerName =
149
+ typeof dynamicMeta.triggerName === 'string'
150
+ ? dynamicMeta.triggerName
151
+ : typeof dynamicMeta.trigger_name === 'string'
152
+ ? dynamicMeta.trigger_name
153
+ : typeof dynamicLog.triggerName === 'string'
154
+ ? dynamicLog.triggerName
155
+ : typeof dynamicLog.trigger_name === 'string'
156
+ ? dynamicLog.trigger_name
157
+ : null;
158
+ return valueOrDash(triggerName);
159
+};
160
+
161
+const formatEpoch = (value: number): string => {
162
+ const date = new Date(value);
163
+ if (Number.isNaN(date.getTime())) return '-';
164
+ return date.toISOString();
165
+};
166
+
167
+const formatCreatedAt = (value: number | string | null | undefined): string => {
168
+ if (typeof value === 'number') return formatEpoch(value);
169
+ if (typeof value === 'string') return value;
170
+ return '-';
171
+};
172
+
173
+export const formatToolLogInfo = (toolLog: ToolLogDetailed): string => {
174
+ const lines: string[] = [];
175
+ lines.push(`${bold('logId:')} ${toolLog.actionLogId}`);
176
+ lines.push(`${bold('toolSlug:')} ${toolLog.actionId}`);
177
+ lines.push(`${bold('Status:')} ${toolLog.status}`);
178
+ lines.push(`${bold('toolkit:')} ${toolLog.app?.name ?? '-'}`);
179
+ lines.push(`${bold('Connection ID:')} ${toolLog.connection?.id ?? '-'}`);
180
+ lines.push(`${bold('Entity:')} ${toolLog.connection?.entity ?? '-'}`);
181
+ lines.push(`${bold('Start Time:')} ${formatCreatedAt(toolLog.startTime)}`);
182
+ lines.push(`${bold('End Time:')} ${formatCreatedAt(toolLog.endTime)}`);
183
+ lines.push(`${bold('Total Duration:')} ${toolLog.totalDuration}`);
184
+ lines.push(`${bold('Version:')} ${toolLog.version}`);
185
+ lines.push(`${bold('Steps:')} ${toolLog.steps?.length ?? 0}`);
186
+ return lines.join('\n');
187
+};
188
+
189
+export const formatTriggerLogInfo = (triggerLog: unknown): string => {
190
+ const rawLog = triggerLog as Record<string, unknown>;
191
+ const logCandidate = rawLog.log;
192
+ const log =
193
+ logCandidate && typeof logCandidate === 'object'
194
+ ? (logCandidate as Record<string, unknown>)
195
+ : rawLog;
196
+ const lines: string[] = [];
197
+
198
+ lines.push(`${bold('logId:')} ${valueOrDash(getRecordString(log, ['id', 'logId', 'log_id']))}`);
199
+ lines.push(
200
+ `${bold('triggerId:')} ${valueOrDash(getRecordString(log, ['triggerId', 'trigger_id']))}`
201
+ );
202
+ lines.push(
203
+ `${bold('triggerNanoId:')} ${valueOrDash(
204
+ getRecordString(log, ['triggerNanoId', 'trigger_nano_id'])
205
+ )}`
206
+ );
207
+ lines.push(
208
+ `${bold('trigger:')} ${valueOrDash(getRecordString(log, ['triggerName', 'trigger_name']))}`
209
+ );
210
+ lines.push(`${bold('Status:')} ${valueOrDash(getRecordString(log, ['status']))}`);
211
+ lines.push(
212
+ `${bold('toolkit:')} ${valueOrDash(getRecordString(log, ['appName', 'toolkit', 'toolkit_key']))}`
213
+ );
214
+ lines.push(
215
+ `${bold('Connection ID:')} ${valueOrDash(
216
+ getRecordString(log, ['connectionId', 'connection_id', 'connectedAccountId'])
217
+ )}`
218
+ );
219
+ lines.push(
220
+ `${bold('Entity:')} ${valueOrDash(getRecordString(log, ['entityId', 'entity_id', 'userId']))}`
221
+ );
222
+ lines.push(
223
+ `${bold('Created At:')} ${formatCreatedAt(
224
+ getRecordNumberOrString(log, ['createdAt', 'created_at'])
225
+ )}`
226
+ );
227
+
228
+ return lines.join('\n');
229
+};
230
+
231
+const getRecordString = (record: Record<string, unknown>, keys: ReadonlyArray<string>) => {
232
+ for (const key of keys) {
233
+ const value = record[key];
234
+ if (typeof value === 'string') return value;
235
+ }
236
+
237
+ const meta = record.meta;
238
+ if (meta && typeof meta === 'object') {
239
+ const metaRecord = meta as Record<string, unknown>;
240
+ for (const key of keys) {
241
+ const value = metaRecord[key];
242
+ if (typeof value === 'string') return value;
243
+ }
244
+ }
245
+
246
+ return null;
247
+};
248
+
249
+const getRecordNumberOrString = (
250
+ record: Record<string, unknown>,
251
+ keys: ReadonlyArray<string>
252
+): number | string | null => {
253
+ for (const key of keys) {
254
+ const value = record[key];
255
+ if (typeof value === 'number' || typeof value === 'string') return value;
256
+ }
257
+
258
+ const meta = record.meta;
259
+ if (meta && typeof meta === 'object') {
260
+ const metaRecord = meta as Record<string, unknown>;
261
+ for (const key of keys) {
262
+ const value = metaRecord[key];
263
+ if (typeof value === 'number' || typeof value === 'string') return value;
264
+ }
265
+ }
266
+
267
+ return null;
268
+};
ts/packages/cli/src/commands/logs-cmd/logs.cmd.ts
new
+16
@@ -0,0 +1,16 @@
1
+import { Command } from '@effect/cli';
2
+import { logsCmd$Tools } from './commands/logs.tools.cmd';
3
+import { logsCmd$Triggers } from './commands/logs.triggers.cmd';
4
+
5
+/**
6
+ * CLI entry point for logs commands.
7
+ *
8
+ * @example
9
+ * ```bash
10
+ * composio logs <command>
11
+ * ```
12
+ */
13
+export const logsCmd = Command.make('logs').pipe(
14
+ Command.withDescription('Inspect trigger and tool execution logs.'),
15
+ Command.withSubcommands([logsCmd$Triggers, logsCmd$Tools])
16
+);
ts/packages/cli/src/commands/logs-cmd/utils.ts
new
+11
@@ -0,0 +1,11 @@
1
+export type SearchParam = {
2
+ field?: string;
3
+ operation?: string;
4
+ value?: string;
5
+};
6
+
7
+export const toSearchParam = (field: string, value: string): SearchParam => ({
8
+ field,
9
+ operation: '==',
10
+ value,
11
+});
ts/packages/cli/test/__utils__/services/test-layer.ts
+17
-1
@@ -898,9 +898,9 @@ export const TestLayer = (input?: TestLiveInput) =>
898
NodeProcessTest,
899
UpgradeBinaryTest,
900
ComposioUserContextTest,
901
+ ComposioClientSingletonTest,
902
ComposioSessionRepositoryTest,
903
TriggersRealtimeTest,
903
- ComposioClientSingletonTest,
904
ComposioToolkitsRepositoryTest,
905
JsPackageManagerDetector.Default,
906
ProjectEnvironmentDetector.Default,
@@ -1083,6 +1083,22 @@ function breakSymlinksInNodeModules(
1083
return;
1084
}
1085
1086
+ // Some fixtures can contain node_modules as a symlink (often broken in temp copies).
1087
+ // Normalize it first so tests can safely create nested paths like node_modules/@scope/pkg.
1088
+ const nodeModulesLink = yield* fs.readLink(nodeModulesPath).pipe(
1089
+ Effect.map(() => true),
1090
+ Effect.catchAll(() => Effect.succeed(false))
1091
+ );
1092
+
1093
+ if (nodeModulesLink) {
1094
+ yield* fs
1095
+ .remove(nodeModulesPath, { recursive: true })
1096
+ .pipe(Effect.catchAll(() => Effect.void));
1097
+ yield* fs
1098
+ .makeDirectory(nodeModulesPath, { recursive: true })
1099
+ .pipe(Effect.catchAll(() => Effect.void));
1100
+ }
1101
+
1102
const isWindows = process.platform === 'win32';
1103
1104
if (isWindows) {
ts/packages/cli/test/src/commands/$default.cmd.test.ts
+1
-2
@@ -15,7 +15,7 @@ describe('CLI: composio', () => {
15
expect(result).toEqual(
16
ValidationError.commandMismatch(
17
HelpDoc.p(
18
- "Invalid subcommand for composio - use one of 'version', 'upgrade', 'whoami', 'login', 'logout', 'init', 'generate', 'py', 'ts', 'toolkits', 'tools', 'auth-configs', 'connected-accounts', 'triggers'"
18
+ "Invalid subcommand for composio - use one of 'version', 'upgrade', 'whoami', 'login', 'logout', 'init', 'generate', 'py', 'ts', 'toolkits', 'tools', 'auth-configs', 'connected-accounts', 'triggers', 'logs'"
19
)
20
)
21
);
@@ -30,7 +30,6 @@ describe('CLI: composio', () => {
30
yield* cli(args);
31
const lines = yield* MockConsole.getLines();
32
const output = lines.join('\n');
33
-
33
expect(yield* sanitize(output)).toMatchSnapshot();
34
})
35
);
ts/packages/cli/test/src/commands/__snapshots__/$default.cmd.test.ts.snap
+46
-40
@@ -25,92 +25,98 @@ Composio CLI - A tool for managing Python and TypeScript composio.dev projects.
25
26
[0;1mCOMMANDS[0m
27
28
- - version Display the current Composio CLI version.
28
+ - version Display the current Composio CLI version.
29
30
- - upgrade Upgrade your Composio CLI to the latest available version.
30
+ - upgrade Upgrade your Composio CLI to the latest available version.
31
32
- - whoami Display your account information.
32
+ - whoami Display your account information.
33
34
- - login [--no-browser] [--api-key text] [--org-id text] [--project-id text] Log in to the Composio SDK.
34
+ - login [--no-browser] [--api-key text] [--org-id text] [--project-id text] Log in to the Composio SDK.
35
36
- - logout Log out from the Composio SDK.
36
+ - logout Log out from the Composio SDK.
37
38
- - init [--org-id text] [--project-id text] [--no-browser] [--dry-run] [--force] [(-y, --yes)] [--no-skills] Initialize a Composio project in the current directory.
38
+ - init [--org-id text] [--project-id text] [--no-browser] [--dry-run] [--force] [(-y, --yes)] [--no-skills] Initialize a Composio project in the current directory.
39
40
- - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
40
+ - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
41
42
- - py Handle Python projects.
42
+ - py Handle Python projects.
43
44
- - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
44
+ - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
45
46
Environment Variables:
47
COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
48
Use "latest" or unset to use the latest version.
49
50
- - ts Handle TypeScript projects.
50
+ - ts Handle TypeScript projects.
51
52
- - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
52
+ - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
53
54
Environment Variables:
55
COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
56
Use "latest" or unset to use the latest version.
57
58
- - toolkits Discover and inspect Composio toolkits.
58
+ - toolkits Discover and inspect Composio toolkits.
59
60
- - toolkits list [--query text] [--limit integer] [--connected] [--user-id text] List available toolkits with connection status.
60
+ - toolkits list [--query text] [--limit integer] [--connected] [--user-id text] List available toolkits with connection status.
61
62
- - toolkits info [--user-id text] [<slug>] View details of a specific toolkit.
62
+ - toolkits info [--user-id text] [<slug>] View details of a specific toolkit.
63
64
- - toolkits search [--limit integer] <query> Search toolkits by use case.
64
+ - toolkits search [--limit integer] <query> Search toolkits by use case.
65
66
- - tools Discover and inspect Composio tools.
66
+ - tools Discover and inspect Composio tools.
67
68
- - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
68
+ - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
69
70
- - tools info [<slug>] View details of a specific tool.
70
+ - tools info [<slug>] View details of a specific tool.
71
72
- - tools search [--toolkits text] [--limit integer] <query> Search tools by use case.
72
+ - tools search [--toolkits text] [--limit integer] <query> Search tools by use case.
73
74
- - tools execute [(-d, --data text)] [--user-id text] <slug> Execute a tool by slug with JSON arguments.
74
+ - tools execute [(-d, --data text)] [--user-id text] <slug> Execute a tool by slug with JSON arguments.
75
76
- - auth-configs View and manage Composio auth configs.
76
+ - auth-configs View and manage Composio auth configs.
77
78
- - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.
78
+ - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.
79
80
- - auth-configs info [<id>] View details of a specific auth config.
80
+ - auth-configs info [<id>] View details of a specific auth config.
81
82
- - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.
82
+ - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.
83
84
- - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.
84
+ - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.
85
86
- - connected-accounts View and manage Composio connected accounts.
86
+ - connected-accounts View and manage Composio connected accounts.
87
88
- - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.
88
+ - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.
89
90
- - connected-accounts info [<id>] View details of a specific connected account.
90
+ - connected-accounts info [<id>] View details of a specific connected account.
91
92
- - connected-accounts whoami [<id>] Show the external account profile for a connected account.
92
+ - connected-accounts whoami [<id>] Show the external account profile for a connected account.
93
94
- - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.
94
+ - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.
95
96
- - connected-accounts link [--auth-config text] [--user-id text] [--no-browser] [<toolkit>] Link an external account via OAuth redirect.
96
+ - connected-accounts link [--auth-config text] [--user-id text] [--no-browser] [<toolkit>] Link an external account via OAuth redirect.
97
98
- - triggers Inspect and subscribe to trigger events.
98
+ - triggers Inspect and subscribe to trigger events.
99
100
- - triggers list [--toolkits text] [--limit integer] List available trigger types.
100
+ - triggers list [--toolkits text] [--limit integer] List available trigger types.
101
102
- - triggers info [<slug>] View details of a specific trigger type.
102
+ - triggers info [<slug>] View details of a specific trigger type.
103
104
- - 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.
104
+ - 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.
105
106
- - triggers status [--user-ids text] [--connected-account-ids text] [--toolkits text] [--trigger-ids text] [--trigger-names text] [--show-disabled] [--limit integer] Show active triggers with optional filters.
106
+ - triggers status [--user-ids text] [--connected-account-ids text] [--toolkits text] [--trigger-ids text] [--trigger-names text] [--show-disabled] [--limit integer] Show active triggers with optional filters.
107
108
- - triggers create [--connected-account-id text] [--trigger-config text] [<trigger-name>] Create a new trigger instance.
108
+ - triggers create [--connected-account-id text] [--trigger-config text] [<trigger-name>] Create a new trigger instance.
109
110
- - triggers enable [<id>] Enable a trigger instance.
110
+ - triggers enable [<id>] Enable a trigger instance.
111
112
- - triggers disable [<id>] Disable a trigger instance.
112
+ - triggers disable [<id>] Disable a trigger instance.
113
114
- - triggers delete [(-y, --yes)] [<id>] Delete a trigger instance.
114
+ - triggers delete [(-y, --yes)] [<id>] Delete a trigger instance.
115
+
116
+ - logs Inspect trigger and tool execution logs.
117
+
118
+ - logs triggers [--cursor text] [--user-id text] [--connected-account-id text] [--trigger text] [--trigger-id text] [--log-id text] [--from integer] [--to integer] [--limit integer] [--time 5m | 30m | 6h | 1d | 1w | 1month | 1y] [--search text] [--include-payload] [<log_id>] List trigger logs.
119
+
120
+ - logs tools [--cursor integer] [--from integer] [--to integer] [--limit integer] [--case-sensitive] [--toolkit text] [--tool text] [--connected-account-id text] [--auth-config-id text] [--status text] [--user-id text] [--log-id text] [--tool-router-session-id text] [--session-id text] [<log_id>] List tool execution logs, or pass a log_id to fetch a specific log.
121
"
122
`;
ts/packages/cli/test/src/commands/logs-cmd/format.test.ts
new
+218
@@ -0,0 +1,218 @@
1
+import type { Logs } from '@composio/client/resources/logs/logs';
2
+import { describe, expect, it } from 'vitest';
3
+import {
4
+ formatTriggerLogInfo,
5
+ formatToolLogInfo,
6
+ formatToolLogsTable,
7
+ formatTriggerLogsTable,
8
+} from 'src/commands/logs-cmd/format';
9
+import { green, red } from 'src/ui/colors';
10
+
11
+type TriggerLog = Logs.TriggerListResponse.Data;
12
+type ToolLog = Logs.ToolListResponse.Data;
13
+type ToolLogDetailed = Logs.ToolRetrieveResponse;
14
+
15
+const makeTriggerLog = (createdAt: TriggerLog['createdAt'] | number): TriggerLog =>
16
+ ({
17
+ id: 'trigger_log_1',
18
+ clientId: 'client_1',
19
+ type: 'trigger',
20
+ createdAt: createdAt as TriggerLog['createdAt'],
21
+ status: 'success',
22
+ appName: 'gmail',
23
+ meta: {
24
+ triggerId: 'trigger_123',
25
+ triggerNanoId: 'ti_123',
26
+ triggerName: 'NEW_GMAIL_MESSAGE',
27
+ },
28
+ entityId: 'entity_123',
29
+ connectionId: 'conn_123',
30
+ }) as unknown as TriggerLog;
31
+
32
+const makeToolLog = (
33
+ createdAt: ToolLog['createdAt'] | null,
34
+ overrides: {
35
+ status?: string;
36
+ connectedAccountId?: string | null;
37
+ } = {}
38
+): ToolLog =>
39
+ ({
40
+ id: 'tool_log_1',
41
+ createdAt,
42
+ status: overrides.status ?? 'success',
43
+ app: { name: 'gmail' },
44
+ actionKey: 'GMAIL_SEND_EMAIL',
45
+ executionTime: 20,
46
+ connectedAccountId:
47
+ overrides.connectedAccountId === undefined ? 'conn_123' : overrides.connectedAccountId,
48
+ }) as ToolLog;
49
+
50
+const makeToolLogDetailed = (
51
+ overrides: Partial<{ startTime: number | null; endTime: number | null }> = {}
52
+): ToolLogDetailed =>
53
+ ({
54
+ actionLogId: 'tool_log_1',
55
+ actionId: 'GMAIL_SEND_EMAIL',
56
+ status: 'success',
57
+ app: null,
58
+ connection: null,
59
+ startTime: overrides.startTime === undefined ? 0 : overrides.startTime,
60
+ endTime: overrides.endTime === undefined ? 0 : overrides.endTime,
61
+ totalDuration: '20ms',
62
+ version: '20260101_00',
63
+ steps: null,
64
+ }) as unknown as ToolLogDetailed;
65
+
66
+describe('formatTriggerLogsTable', () => {
67
+ it('[Given] createdAt is epoch number [Then] it formats without crashing', () => {
68
+ const output = formatTriggerLogsTable([makeTriggerLog(0)]);
69
+ expect(output).toContain('1970-01-01T00:00:00.000Z');
70
+ expect(output).toContain('ti_123');
71
+ expect(output).toContain('NEW_GMAIL_MESSAGE');
72
+ });
73
+
74
+ it('[Given] createdAt is string [Then] it preserves previous behavior', () => {
75
+ const output = formatTriggerLogsTable([makeTriggerLog('2026-02-24T12:34:56.000Z')]);
76
+ expect(output).toContain('2026-02-24T12:34:56.000Z');
77
+ });
78
+
79
+ it('[Given] rendering table [Then] it uses Trigger Id and Toolkit headers', () => {
80
+ const output = stripAnsi(formatTriggerLogsTable([makeTriggerLog(0)]));
81
+ const [headerLine] = output.split('\n');
82
+
83
+ expect(headerLine).toContain('Log Id');
84
+ expect(headerLine).toContain('Trigger Id');
85
+ expect(headerLine).toContain('Toolkit');
86
+ expect(headerLine).toContain('Trigger');
87
+ expect(headerLine).toContain('User Id');
88
+ expect(headerLine).toContain('Connected Account Id');
89
+ expect(headerLine).not.toContain('Status');
90
+ expect(headerLine).not.toContain('App');
91
+ });
92
+});
93
+
94
+describe('formatToolLogsTable', () => {
95
+ it('[Given] createdAt is null [Then] it renders dash instead of epoch zero', () => {
96
+ const output = formatToolLogsTable([makeToolLog(null)]);
97
+ expect(output).toContain('tool_log_1');
98
+ expect(output).not.toContain('1970-01-01T00:00:00.000Z');
99
+ });
100
+
101
+ it('[Given] rendering table [Then] it shows Created At before Log Id', () => {
102
+ const output = stripAnsi(formatToolLogsTable([makeToolLog(0)]));
103
+ const [headerLine] = output.split('\n');
104
+
105
+ expect(headerLine.indexOf('Created At')).toBeLessThan(headerLine.indexOf('Log Id'));
106
+ });
107
+
108
+ it('[Given] rendering table [Then] it uses Toolkit and Tool headers', () => {
109
+ const output = stripAnsi(formatToolLogsTable([makeToolLog(0)]));
110
+ const [headerLine] = output.split('\n');
111
+
112
+ expect(headerLine).toContain('Toolkit');
113
+ expect(headerLine).toContain('Tool');
114
+ expect(headerLine).not.toContain('App');
115
+ expect(headerLine).not.toContain('Action');
116
+ });
117
+
118
+ it('[Given] success and failure statuses [Then] it colors them green and red', () => {
119
+ const output = formatToolLogsTable([
120
+ makeToolLog(0, { status: 'success' }),
121
+ makeToolLog(0, { status: 'failed' }),
122
+ ]);
123
+
124
+ expect(output).toContain(green('success '.padEnd(8)));
125
+ expect(output).toContain(red('failed '.padEnd(8)));
126
+ });
127
+
128
+ it('[Given] null connected account [Then] it renders dash', () => {
129
+ const output = stripAnsi(formatToolLogsTable([makeToolLog(0, { connectedAccountId: null })]));
130
+ const [, rowLine] = output.split('\n');
131
+
132
+ expect(rowLine).toMatch(/\s-\s*$/);
133
+ });
134
+});
135
+
136
+const stripAnsi = (value: string): string => value.replace(/\u001B\[[0-9;]*m/g, '');
137
+
138
+describe('formatToolLogInfo', () => {
139
+ it('[Given] nullable app/connection/steps [Then] it renders fallback values', () => {
140
+ const output = formatToolLogInfo(makeToolLogDetailed());
141
+ const plain = output.replace(/\x1b\[[0-9;]*m/g, '');
142
+ expect(plain).toContain('toolkit: -');
143
+ expect(plain).toContain('Connection ID: -');
144
+ expect(plain).toContain('Entity: -');
145
+ expect(plain).toContain('Steps: 0');
146
+ });
147
+
148
+ it('[Given] null start/end time [Then] it renders dashes for timestamps', () => {
149
+ const output = formatToolLogInfo(makeToolLogDetailed({ startTime: null, endTime: null }));
150
+ const plain = output.replace(/\x1b\[[0-9;]*m/g, '');
151
+ expect(plain).toContain('Start Time: -');
152
+ expect(plain).toContain('End Time: -');
153
+ expect(plain).not.toContain('1970-01-01T00:00:00.000Z');
154
+ });
155
+});
156
+
157
+describe('formatTriggerLogInfo', () => {
158
+ it('[Given] trigger detailed log [Then] it renders key fields', () => {
159
+ const output = formatTriggerLogInfo({
160
+ id: 'trigger_log_1',
161
+ createdAt: 0,
162
+ status: 'success',
163
+ appName: 'gmail',
164
+ meta: {
165
+ triggerId: 'trigger_123',
166
+ triggerNanoId: 'ti_123',
167
+ triggerName: 'NEW_GMAIL_MESSAGE',
168
+ },
169
+ entityId: 'user_123',
170
+ connectionId: 'conn_123',
171
+ });
172
+
173
+ expect(output).toContain('logId:');
174
+ expect(output).toContain('trigger_log_1');
175
+ expect(output).toContain('triggerId:');
176
+ expect(output).toContain('trigger_123');
177
+ expect(output).toContain('triggerNanoId:');
178
+ expect(output).toContain('ti_123');
179
+ expect(output).toContain('trigger:');
180
+ expect(output).toContain('NEW_GMAIL_MESSAGE');
181
+ expect(output).toContain('toolkit:');
182
+ expect(output).toContain('gmail');
183
+ });
184
+
185
+ it('[Given] missing fields [Then] it renders fallback dashes', () => {
186
+ const output = formatTriggerLogInfo({});
187
+ const plain = output.replace(/\x1b\[[0-9;]*m/g, '');
188
+ expect(plain).toContain('logId: -');
189
+ expect(plain).toContain('triggerId: -');
190
+ expect(plain).toContain('triggerNanoId: -');
191
+ expect(plain).toContain('trigger: -');
192
+ expect(plain).toContain('Created At: -');
193
+ });
194
+
195
+ it('[Given] retrieve response wrapped under log [Then] it unwraps and renders values', () => {
196
+ const output = formatTriggerLogInfo({
197
+ log: {
198
+ id: 'log_QNzKGStH-ruD',
199
+ status: 'info',
200
+ appName: 'gmail',
201
+ createdAt: '2026-02-25T22:01:22.865Z',
202
+ entityId: 'pg-test-37ee710c-d5be-4775-91f2-a8e06b937d9b',
203
+ connectionId: 'ca_zkX9njO68E8A',
204
+ meta: {
205
+ triggerId: '77ac1dbf-6db0-4039-8dbe-e903b3f2057e',
206
+ triggerNanoId: 'ti_-nGUzD9N6JNf',
207
+ triggerName: 'GMAIL_NEW_GMAIL_MESSAGE',
208
+ },
209
+ },
210
+ });
211
+
212
+ expect(output).toContain('log_QNzKGStH-ruD');
213
+ expect(output).toContain('77ac1dbf-6db0-4039-8dbe-e903b3f2057e');
214
+ expect(output).toContain('ti_-nGUzD9N6JNf');
215
+ expect(output).toContain('GMAIL_NEW_GMAIL_MESSAGE');
216
+ expect(output).toContain('gmail');
217
+ });
218
+});
ts/packages/cli/test/src/commands/logs-cmd/logs.tools.cmd.test.ts
new
+54
@@ -0,0 +1,54 @@
1
+import { describe, expect, it } from 'vitest';
2
+import { buildToolLogShorthandSearchParams } from 'src/commands/logs-cmd/commands/logs.tools.cmd';
3
+
4
+describe('buildToolLogShorthandSearchParams', () => {
5
+ it('[Given] no filters [Then] returns empty search params', () => {
6
+ expect(buildToolLogShorthandSearchParams({})).toEqual([]);
7
+ });
8
+
9
+ it('[Given] all supported filters [Then] maps each one to the expected backend key', () => {
10
+ const output = buildToolLogShorthandSearchParams({
11
+ tool: 'GMAIL_SEND_EMAIL',
12
+ toolkit: 'gmail',
13
+ connectedAccountId: 'ca_123',
14
+ authConfigId: 'ac_123',
15
+ status: 'success',
16
+ userId: 'user_123',
17
+ logId: 'log_123',
18
+ toolRouterSessionId: 'trs_123',
19
+ sessionId: 'sess_123',
20
+ });
21
+
22
+ expect(output).toEqual([
23
+ { field: 'action_key', operation: '==', value: 'GMAIL_SEND_EMAIL' },
24
+ { field: 'toolkit_key', operation: '==', value: 'gmail' },
25
+ { field: 'connected_account_id', operation: '==', value: 'ca_123' },
26
+ { field: 'auth_config_id', operation: '==', value: 'ac_123' },
27
+ { field: 'execution_status', operation: '==', value: 'success' },
28
+ { field: 'user_id', operation: '==', value: 'user_123' },
29
+ { field: 'log_id', operation: '==', value: 'log_123' },
30
+ { field: 'tool_router_session_id', operation: '==', value: 'trs_123' },
31
+ { field: 'session_id', operation: '==', value: 'sess_123' },
32
+ ]);
33
+ });
34
+
35
+ it('[Given] comma-separated filter values [Then] expands each value into separate search params', () => {
36
+ const output = buildToolLogShorthandSearchParams({
37
+ tool: 'GMAIL_SEND_EMAIL,SLACK_SEND_MESSAGE',
38
+ toolkit: 'gmail,slack',
39
+ status: 'success,failed',
40
+ logId: 'log_1,log_2',
41
+ });
42
+
43
+ expect(output).toEqual([
44
+ { field: 'action_key', operation: '==', value: 'GMAIL_SEND_EMAIL' },
45
+ { field: 'action_key', operation: '==', value: 'SLACK_SEND_MESSAGE' },
46
+ { field: 'toolkit_key', operation: '==', value: 'gmail' },
47
+ { field: 'toolkit_key', operation: '==', value: 'slack' },
48
+ { field: 'execution_status', operation: '==', value: 'success' },
49
+ { field: 'execution_status', operation: '==', value: 'failed' },
50
+ { field: 'log_id', operation: '==', value: 'log_1' },
51
+ { field: 'log_id', operation: '==', value: 'log_2' },
52
+ ]);
53
+ });
54
+});
ts/packages/cli/test/src/commands/logs-cmd/logs.triggers.cmd.test.ts
new
+47
@@ -0,0 +1,47 @@
1
+import { describe, expect, it } from 'vitest';
2
+import {
3
+ getTriggerLogRecord,
4
+ getTriggerPayload,
5
+ getTriggerResponse,
6
+ parseMaybeJson,
7
+} from 'src/commands/logs-cmd/commands/logs.triggers.cmd';
8
+
9
+describe('logs triggers detail helpers', () => {
10
+ it('[Given] retrieve response wrapper [Then] unwraps nested log record', () => {
11
+ const wrapped = {
12
+ log: {
13
+ id: 'log_123',
14
+ meta: { triggerId: 'trigger_123' },
15
+ },
16
+ } as Record<string, unknown>;
17
+
18
+ expect(getTriggerLogRecord(wrapped)).toEqual({
19
+ id: 'log_123',
20
+ meta: { triggerId: 'trigger_123' },
21
+ });
22
+ });
23
+
24
+ it('[Given] trigger payload in meta JSON string [Then] parses it to object', () => {
25
+ const payload = getTriggerPayload({
26
+ meta: {
27
+ triggerProviderPayload: '{"foo":"bar","count":2}',
28
+ },
29
+ });
30
+
31
+ expect(payload).toEqual({ foo: 'bar', count: 2 });
32
+ });
33
+
34
+ it('[Given] trigger response in meta JSON string [Then] parses it to object', () => {
35
+ const response = getTriggerResponse({
36
+ meta: {
37
+ triggerClientResponse: '{"status":"CANCELED"}',
38
+ },
39
+ });
40
+
41
+ expect(response).toEqual({ status: 'CANCELED' });
42
+ });
43
+
44
+ it('[Given] non-JSON string [Then] parseMaybeJson returns original value', () => {
45
+ expect(parseMaybeJson('not-json')).toBe('not-json');
46
+ });
47
+});
ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
+59
-115
@@ -31,6 +31,59 @@ describe('CLI: composio ts generate', () => {
31
triggerTypesAsEnums: [...TRIGGER_TYPES_GMAIL.slice(0, 3).map(triggerType => triggerType.slug)],
32
} satisfies TestLiveInput['toolkitsData'];
33
34
+ const setupMockComposioCorePackage = ({
35
+ cwd,
36
+ fs,
37
+ withGenerated = false,
38
+ }: {
39
+ cwd: string;
40
+ fs: FileSystem.FileSystem;
41
+ withGenerated?: boolean;
42
+ }) =>
43
+ Effect.gen(function* () {
44
+ const nodeModulesRoot = path.join(cwd, 'node_modules');
45
+ const nodeModulesDir = path.join(nodeModulesRoot, '@composio', 'core');
46
+
47
+ // Some fixtures may carry broken node_modules links after copying; reset to a real directory.
48
+ yield* fs
49
+ .remove(nodeModulesRoot, { recursive: true })
50
+ .pipe(Effect.catchAll(() => Effect.void));
51
+ yield* fs.makeDirectory(nodeModulesDir, { recursive: true });
52
+
53
+ if (withGenerated) {
54
+ yield* fs.makeDirectory(path.join(nodeModulesDir, 'generated'), { recursive: true });
55
+ }
56
+
57
+ // Create a mock package.json to resolve @composio/core imports in transpilation paths.
58
+ yield* fs.writeFileString(
59
+ path.join(nodeModulesDir, 'package.json'),
60
+ JSON.stringify(
61
+ {
62
+ name: '@composio/core',
63
+ type: 'module',
64
+ exports: {
65
+ '.': {
66
+ types: './index.d.ts',
67
+ default: './index.js',
68
+ },
69
+ './generated': {
70
+ types: './generated/index.d.ts',
71
+ default: './generated/index.js',
72
+ },
73
+ },
74
+ },
75
+ null,
76
+ 2
77
+ )
78
+ );
79
+
80
+ yield* fs.writeFileString(
81
+ path.join(nodeModulesDir, 'index.d.ts'),
82
+ 'export type TriggerEvent<T> = { payload: T };'
83
+ );
84
+ yield* fs.writeFileString(path.join(nodeModulesDir, 'index.js'), 'export {};');
85
+ });
86
+
87
describe('[Given] valid fetched app data', () => {
88
layer(
89
TestLive({
@@ -47,43 +100,7 @@ describe('CLI: composio ts generate', () => {
100
const cwd = process.cwd;
101
const fs = yield* FileSystem.FileSystem;
102
50
- // Create the @composio/core/generated directory structure as if installed
51
- const nodeModulesDir = path.join(cwd, 'node_modules', '@composio', 'core');
52
- const generatedDir = path.join(nodeModulesDir, 'generated');
53
- yield* fs.makeDirectory(nodeModulesDir, { recursive: true });
54
- yield* fs.makeDirectory(generatedDir, { recursive: true });
55
-
56
- // Create a mock package.json to override the symlink resolution for ESM imports.
57
- // This is necessary because we're using symlinks in test-layer.ts to isolate the test environment.
58
- const corePackageJson = path.join(nodeModulesDir, 'package.json');
59
- yield* fs.writeFileString(
60
- corePackageJson,
61
- JSON.stringify(
62
- {
63
- name: '@composio/core',
64
- type: 'module',
65
- exports: {
66
- '.': {
67
- types: './index.d.ts',
68
- default: './index.js',
69
- },
70
- './generated': {
71
- types: './generated/index.d.ts',
72
- default: './generated/index.js',
73
- },
74
- },
75
- },
76
- null,
77
- 2
78
- )
79
- );
80
-
81
- // Create minimal type stubs for @composio/core root exports (needed for transpilation)
82
- yield* fs.writeFileString(
83
- path.join(nodeModulesDir, 'index.d.ts'),
84
- 'export type TriggerEvent<T> = { payload: T };'
85
- );
86
- yield* fs.writeFileString(path.join(nodeModulesDir, 'index.js'), 'export {};');
103
+ yield* setupMockComposioCorePackage({ cwd, fs, withGenerated: true });
104
105
const outputDir = path.join(cwd, 'node_modules', '@composio', 'core', 'generated');
106
const args = ['ts', 'generate'];
@@ -288,42 +305,7 @@ describe('CLI: composio ts generate', () => {
305
const cwd = process.cwd;
306
const fs = yield* FileSystem.FileSystem;
307
291
- // Create the @composio/core/generated directory structure as if installed
292
- const nodeModulesDir = path.join(cwd, 'node_modules', '@composio', 'core');
293
- const generatedDir = path.join(nodeModulesDir, 'generated');
294
- yield* fs.makeDirectory(nodeModulesDir, { recursive: true });
295
- yield* fs.makeDirectory(generatedDir, { recursive: true });
296
-
297
- // Create a mock package.json to override the symlink resolution for ESM imports
298
- const corePackageJson = path.join(nodeModulesDir, 'package.json');
299
- yield* fs.writeFileString(
300
- corePackageJson,
301
- JSON.stringify(
302
- {
303
- name: '@composio/core',
304
- type: 'module',
305
- exports: {
306
- '.': {
307
- types: './index.d.ts',
308
- default: './index.js',
309
- },
310
- './generated': {
311
- types: './generated/index.d.ts',
312
- default: './generated/index.js',
313
- },
314
- },
315
- },
316
- null,
317
- 2
318
- )
319
- );
320
-
321
- // Create minimal type stubs for @composio/core root exports (needed for transpilation)
322
- yield* fs.writeFileString(
323
- path.join(nodeModulesDir, 'index.d.ts'),
324
- 'export type TriggerEvent<T> = { payload: T };'
325
- );
326
- yield* fs.writeFileString(path.join(nodeModulesDir, 'index.js'), 'export {};');
308
+ yield* setupMockComposioCorePackage({ cwd, fs, withGenerated: true });
309
310
const outputDir = path.join(cwd, 'node_modules', '@composio', 'core', 'generated');
311
const args = ['ts', 'generate', '--type-tools'];
@@ -777,22 +759,7 @@ describe('CLI: composio ts generate', () => {
759
const fs = yield* FileSystem.FileSystem;
760
const outputDir = path.join(cwd, 'generated-compiled');
761
780
- // Create mock @composio/core for transpilation to resolve imports
781
- const nodeModulesDir = path.join(cwd, 'node_modules', '@composio', 'core');
782
- yield* fs.makeDirectory(nodeModulesDir, { recursive: true });
783
- yield* fs.writeFileString(
784
- path.join(nodeModulesDir, 'package.json'),
785
- JSON.stringify({
786
- name: '@composio/core',
787
- type: 'module',
788
- exports: { '.': { types: './index.d.ts', default: './index.js' } },
789
- })
790
- );
791
- yield* fs.writeFileString(
792
- path.join(nodeModulesDir, 'index.d.ts'),
793
- 'export type TriggerEvent<T> = { payload: T };'
794
- );
795
- yield* fs.writeFileString(path.join(nodeModulesDir, 'index.js'), 'export {};');
762
+ yield* setupMockComposioCorePackage({ cwd, fs });
763
764
const args = ['ts', 'generate', '--transpiled', '--output-dir', outputDir];
765
yield* cli(args);
@@ -825,33 +792,9 @@ describe('CLI: composio ts generate', () => {
792
const process = yield* NodeProcess;
793
const cwd = process.cwd;
794
const fs = yield* FileSystem.FileSystem;
795
+ const generatedDir = path.join(cwd, 'node_modules', '@composio', 'core', 'generated');
796
829
- // Set up @composio/core/generated directory
830
- const nodeModulesDir = path.join(cwd, 'node_modules', '@composio', 'core');
831
- const generatedDir = path.join(nodeModulesDir, 'generated');
832
- yield* fs.makeDirectory(nodeModulesDir, { recursive: true });
833
- yield* fs.makeDirectory(generatedDir, { recursive: true });
834
-
835
- // Create mock package.json and type stubs for transpilation
836
- yield* fs.writeFileString(
837
- path.join(nodeModulesDir, 'package.json'),
838
- JSON.stringify({
839
- name: '@composio/core',
840
- type: 'module',
841
- exports: {
842
- '.': { types: './index.d.ts', default: './index.js' },
843
- './generated': {
844
- types: './generated/index.d.ts',
845
- default: './generated/index.js',
846
- },
847
- },
848
- })
849
- );
850
- yield* fs.writeFileString(
851
- path.join(nodeModulesDir, 'index.d.ts'),
852
- 'export type TriggerEvent<T> = { payload: T };'
853
- );
854
- yield* fs.writeFileString(path.join(nodeModulesDir, 'index.js'), 'export {};');
797
+ yield* setupMockComposioCorePackage({ cwd, fs, withGenerated: true });
798
799
const args = ['ts', 'generate'];
800
yield* cli(args);
@@ -903,6 +846,7 @@ describe('CLI: composio ts generate', () => {
846
const process = yield* NodeProcess;
847
const cwd = process.cwd;
848
const fs = yield* FileSystem.FileSystem;
849
+ yield* setupMockComposioCorePackage({ cwd, fs });
850
851
// Run the command
852
const args = ['ts', 'generate', '--compact'];