44
tools: testTools,
45
} satisfies TestLiveInput['toolkitsData'];
46
47
-const testConfigProvider = ConfigProvider.fromMap(
48
- new Map([['COMPOSIO_USER_API_KEY', 'test_api_key']])
49
-).pipe(extendConfigProvider);
47
+const testConfigProvider = ConfigProvider.fromEnv({
48
+ env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
49
+}).pipe(extendConfigProvider);
50
51
const testLiveOptions = {
52
baseConfigProvider: testConfigProvider,
99
100
describe('CLI: composio search', () => {
101
layer(TestLive(testLiveOptions))('[Given] a blank query [Then] typed validation fails', it => {
102
- it.scoped('returns the structured missing-query error', () =>
102
+ it.effect('returns the structured missing-query error', () =>
103
Effect.gen(function* () {
104
const failure = yield* cli(['search', ' ']).pipe(Effect.flip);
105
expect(failure).toBeInstanceOf(ToolsSearchInputError);
112
});
113
114
layer(TestLive(testLiveOptions))('[Given] query "send" [Then] returns JSON by default', it => {
115
- it.scoped('returns JSON payload by default', () =>
115
+ it.effect('returns JSON payload by default', () =>
116
Effect.gen(function* () {
117
yield* cli(['search', 'send']);
118
const lines = yield* MockConsole.getLines({ stripAnsi: true });
136
);
137
});
138
139
- layer(TestLive(testLiveOptions))(
140
- '[Given] a remote custom tool schema [Then] search uses the Tool Router schema',
141
- it => {
142
- it.scoped('does not refetch custom tool schemas through the legacy tools endpoint', () =>
143
- Effect.gen(function* () {
144
- const customSlug = 'CUSTOM_DEEPWIKI_READ_WIKI_CONTENTS';
145
- const live = TestLive({
146
- ...testLiveOptions,
147
- toolRouter: {
148
- search: async (_sessionId, params) => ({
149
- success: true,
150
- error: null,
151
- results: [
152
- {
153
- index: 1,
154
- use_case: params.queries[0]?.use_case ?? '',
155
- primary_tool_slugs: [customSlug],
156
- related_tool_slugs: [],
157
- toolkits: ['CUSTOM_DEEPWIKI'],
158
- },
159
- ],
160
- tool_schemas: {
161
- [customSlug]: {
162
- tool_slug: customSlug,
163
- toolkit: 'CUSTOM_DEEPWIKI',
164
- description: 'Read wiki contents',
165
- hasFullSchema: true,
166
- input_schema: {
167
- type: 'object',
168
- properties: { repo: { type: 'string' } },
169
- required: ['repo'],
170
- },
171
- output_schema: { type: 'object', properties: {} },
172
- },
173
- },
174
- toolkit_connection_statuses: [],
175
- next_steps_guidance: [],
176
- session: {
177
- id: 'trs_test_session',
178
- generate_id: false,
179
- instructions: 'Reuse this session id for follow-up calls.',
180
- },
181
- time_info: {
182
- current_time_utc: '2026-01-01T00:00:00.000Z',
183
- current_time_utc_epoch_seconds: 1767225600,
184
- message: 'UTC time',
185
- },
186
- }),
139
+ const customSlug = 'CUSTOM_DEEPWIKI_READ_WIKI_CONTENTS';
140
+
141
+ layer(
142
+ TestLive({
143
+ ...testLiveOptions,
144
+ toolRouter: {
145
+ search: async (_sessionId, params) => ({
146
+ success: true,
147
+ error: null,
148
+ results: [
149
+ {
150
+ index: 1,
151
+ use_case: params.queries[0]?.use_case ?? '',
152
+ primary_tool_slugs: [customSlug],
153
+ related_tool_slugs: [],
154
+ toolkits: ['CUSTOM_DEEPWIKI'],
155
+ },
156
+ ],
157
+ tool_schemas: {
158
+ [customSlug]: {
159
+ tool_slug: customSlug,
160
+ toolkit: 'CUSTOM_DEEPWIKI',
161
+ description: 'Read wiki contents',
162
+ hasFullSchema: true,
163
+ input_schema: {
164
+ type: 'object',
165
+ properties: { repo: { type: 'string' } },
166
+ required: ['repo'],
167
+ },
168
+ output_schema: { type: 'object', properties: {} },
169
},
188
- });
170
+ },
171
+ toolkit_connection_statuses: [],
172
+ next_steps_guidance: [],
173
+ session: {
174
+ id: 'trs_test_session',
175
+ generate_id: false,
176
+ instructions: 'Reuse this session id for follow-up calls.',
177
+ },
178
+ time_info: {
179
+ current_time_utc: '2026-01-01T00:00:00.000Z',
180
+ current_time_utc_epoch_seconds: 1767225600,
181
+ message: 'UTC time',
182
+ },
183
+ }),
184
+ },
185
+ })
186
+ )('[Given] a remote custom tool schema [Then] search uses the Tool Router schema', it => {
187
+ it.effect('does not refetch custom tool schemas through the legacy tools endpoint', () =>
188
+ Effect.gen(function* () {
189
+ yield* cli(['search', 'read wiki contents']);
190
+ const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
191
190
- yield* cli(['search', 'read wiki contents']).pipe(Effect.provide(live));
191
- const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
192
+ expect(output).toContain(customSlug);
193
+ expect(output).toContain(`~/.composio/tool_definitions/${customSlug}.json`);
194
+ })
195
+ );
196
+ });
197
193
- expect(output).toContain(customSlug);
194
- expect(output).toContain(
195
- `~/.composio/tool_definitions/${customSlug}.json`
196
- );
197
- })
198
- );
199
- }
200
- );
198
+ let schemaRequestSlugs: unknown;
199
202
- layer(TestLive(testLiveOptions))(
203
- '[Given] a remote custom tool schema reference [Then] search resolves it with the Tool Router meta-tool',
204
- it => {
205
- it.scoped('does not use the legacy tools endpoint for schema references', () =>
206
- Effect.gen(function* () {
207
- const customSlug = 'CUSTOM_DEEPWIKI_READ_WIKI_CONTENTS';
208
- let schemaRequestSlugs: unknown;
209
- const live = TestLive({
210
- ...testLiveOptions,
211
- toolRouter: {
212
- search: async (_sessionId, params) => ({
213
- success: true,
214
- error: null,
215
- results: [
216
- {
217
- index: 1,
218
- use_case: params.queries[0]?.use_case ?? '',
219
- primary_tool_slugs: [customSlug],
220
- related_tool_slugs: [],
221
- toolkits: ['CUSTOM_DEEPWIKI'],
222
- },
223
- ],
224
- tool_schemas: {
225
- [customSlug]: {
226
- tool_slug: customSlug,
227
- toolkit: 'CUSTOM_DEEPWIKI',
228
- description: 'Read wiki contents',
229
- hasFullSchema: false,
230
- schemaRef: {
231
- tool: 'COMPOSIO_GET_TOOL_SCHEMAS',
232
- args: { tool_slugs: [customSlug] },
233
- },
200
+ layer(
201
+ TestLive({
202
+ ...testLiveOptions,
203
+ toolRouter: {
204
+ search: async (_sessionId, params) => ({
205
+ success: true,
206
+ error: null,
207
+ results: [
208
+ {
209
+ index: 1,
210
+ use_case: params.queries[0]?.use_case ?? '',
211
+ primary_tool_slugs: [customSlug],
212
+ related_tool_slugs: [],
213
+ toolkits: ['CUSTOM_DEEPWIKI'],
214
+ },
215
+ ],
216
+ tool_schemas: {
217
+ [customSlug]: {
218
+ tool_slug: customSlug,
219
+ toolkit: 'CUSTOM_DEEPWIKI',
220
+ description: 'Read wiki contents',
221
+ hasFullSchema: false,
222
+ schemaRef: {
223
+ tool: 'COMPOSIO_GET_TOOL_SCHEMAS',
224
+ args: { tool_slugs: [customSlug] },
225
+ },
226
+ },
227
+ },
228
+ toolkit_connection_statuses: [],
229
+ next_steps_guidance: [],
230
+ session: {
231
+ id: 'trs_test_session',
232
+ generate_id: false,
233
+ instructions: 'Reuse this session id for follow-up calls.',
234
+ },
235
+ time_info: {
236
+ current_time_utc: '2026-01-01T00:00:00.000Z',
237
+ current_time_utc_epoch_seconds: 1767225600,
238
+ message: 'UTC time',
239
+ },
240
+ }),
241
+ executeMeta: async (_sessionId, params) => {
242
+ schemaRequestSlugs = params.arguments?.tool_slugs;
243
+ return {
244
+ data: {
245
+ success: true,
246
+ tool_schemas: {
247
+ [customSlug]: {
248
+ tool_slug: customSlug,
249
+ toolkit: 'CUSTOM_DEEPWIKI',
250
+ description: 'Read wiki contents',
251
+ input_schema: {
252
+ type: 'object',
253
+ properties: { repo: { type: 'string' } },
254
+ required: ['repo'],
255
},
256
},
236
- toolkit_connection_statuses: [],
237
- next_steps_guidance: [],
238
- session: {
239
- id: 'trs_test_session',
240
- generate_id: false,
241
- instructions: 'Reuse this session id for follow-up calls.',
242
- },
243
- time_info: {
244
- current_time_utc: '2026-01-01T00:00:00.000Z',
245
- current_time_utc_epoch_seconds: 1767225600,
246
- message: 'UTC time',
247
- },
248
- }),
249
- executeMeta: async (_sessionId, params) => {
250
- schemaRequestSlugs = params.arguments?.tool_slugs;
251
- return {
252
- data: {
253
- success: true,
254
- tool_schemas: {
255
- [customSlug]: {
256
- tool_slug: customSlug,
257
- toolkit: 'CUSTOM_DEEPWIKI',
258
- description: 'Read wiki contents',
259
- input_schema: {
260
- type: 'object',
261
- properties: { repo: { type: 'string' } },
262
- required: ['repo'],
263
- },
264
- },
265
- },
266
- },
267
- error: null,
268
- log_id: 'log_test',
269
- };
257
},
258
},
272
- });
273
-
274
- yield* cli(['search', 'read wiki contents']).pipe(Effect.provide(live));
259
+ error: null,
260
+ log_id: 'log_test',
261
+ };
262
+ },
263
+ },
264
+ })
265
+ )(
266
+ '[Given] a remote custom tool schema reference [Then] search resolves it with the Tool Router meta-tool',
267
+ it => {
268
+ it.effect('does not use the legacy tools endpoint for schema references', () =>
269
+ Effect.gen(function* () {
270
+ yield* cli(['search', 'read wiki contents']);
271
const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
272
273
expect(output).toContain(customSlug);
274
expect(schemaRequestSlugs).toEqual([customSlug]);
279
- expect(output).toContain(
280
- `~/.composio/tool_definitions/${customSlug}.json`
281
- );
275
+ expect(output).toContain(`~/.composio/tool_definitions/${customSlug}.json`);
276
})
277
);
278
}
281
layer(TestLive(testLiveOptions))(
282
'[Given] multiple queries [Then] the CLI returns a batched JSON response',
283
it => {
290
- it.scoped('returns batched results in JSON', () =>
284
+ it.effect('returns batched results in JSON', () =>
285
Effect.gen(function* () {
286
yield* cli(['search', 'send', 'create issue']);
287
const lines = yield* MockConsole.getLines({ stripAnsi: true });
300
layer(TestLive(testLiveOptions))(
301
'[Given] query with no results [Then] shows not found message',
302
it => {
309
- it.scoped('shows empty json output', () =>
303
+ it.effect('shows empty json output', () =>
304
Effect.gen(function* () {
305
yield* cli(['search', 'nonexistent_query']);
306
const lines = yield* MockConsole.getLines({ stripAnsi: true });
315
layer(TestLive(testLiveOptions))(
316
'[Given] query "send" --toolkits "gmail" --human [Then] scopes to toolkit',
317
it => {
324
- it.scoped('scopes search to toolkit', () =>
318
+ it.effect('scopes search to toolkit', () =>
319
Effect.gen(function* () {
320
yield* cli(['search', 'send', '--toolkits', 'gmail', '--human']);
321
const lines = yield* MockConsole.getLines({ stripAnsi: true });
333
layer(TestLive(testLiveOptions))(
334
'[Given] search --human [Then] it stays human-readable and omits raw JSON',
335
it => {
342
- it.scoped('does not print raw JSON in human mode', () =>
336
+ it.effect('does not print raw JSON in human mode', () =>
337
Effect.gen(function* () {
338
yield* cli(['search', 'send', '--human']);
339
const lines = yield* MockConsole.getLines({ stripAnsi: true });
352
layer(TestLive(testLiveOptions))(
353
'[Given] search --json [Then] JSON output includes full tool-router payload and next steps',
354
it => {
361
- it.scoped('prints full search response with next steps for jq', () =>
355
+ it.effect('prints full search response with next steps for jq', () =>
356
Effect.gen(function* () {
357
yield* cli(['search', 'send', '--json']);
358
const lines = yield* MockConsole.getLines({ stripAnsi: true });
378
}
379
);
380
387
- layer(TestLive(testLiveOptions))(
381
+ layer(
382
+ TestLive({
383
+ ...testLiveOptions,
384
+ toolRouter: {
385
+ search: async (_sessionId, params) => ({
386
+ success: true,
387
+ error: null,
388
+ results: [
389
+ {
390
+ index: 1,
391
+ use_case: params.queries[0]?.use_case ?? '',
392
+ primary_tool_slugs: ['GMAIL_SEND_EMAIL'],
393
+ related_tool_slugs: [],
394
+ toolkits: ['gmail'],
395
+ reference_workbench_snippets: [{ description: 'snippet', code: 'print("hi")' }],
396
+ },
397
+ ],
398
+ tool_schemas: {
399
+ GMAIL_SEND_EMAIL: {
400
+ tool_slug: 'GMAIL_SEND_EMAIL',
401
+ toolkit: 'gmail',
402
+ description: 'Sends an email',
403
+ hasFullSchema: true,
404
+ input_schema: { type: 'object', properties: {} },
405
+ output_schema: { type: 'object', properties: {} },
406
+ },
407
+ },
408
+ toolkit_connection_statuses: [
409
+ {
410
+ toolkit: 'gmail',
411
+ description: 'gmail toolkit',
412
+ has_active_connection: false,
413
+ status_message: 'No active connection',
414
+ },
415
+ ],
416
+ next_steps_guidance: [],
417
+ session: {
418
+ id: 'trs_test_session',
419
+ generate_id: false,
420
+ instructions: 'Reuse this session id for follow-up calls.',
421
+ },
422
+ time_info: {
423
+ current_time_utc: '2026-01-01T00:00:00.000Z',
424
+ current_time_utc_epoch_seconds: 1767225600,
425
+ message: 'UTC time',
426
+ },
427
+ }),
428
+ },
429
+ })
430
+ )(
431
'[Given] search results with workbench snippets [Then] snippets are removed from JSON output',
432
it => {
390
- it.scoped('omits workbench snippets and emits schema/cache references', () =>
433
+ it.effect('omits workbench snippets and emits schema/cache references', () =>
434
Effect.gen(function* () {
392
- const live = TestLive({
393
- ...testLiveOptions,
394
- toolRouter: {
395
- search: async (_sessionId, params) => ({
396
- success: true,
397
- error: null,
398
- results: [
399
- {
400
- index: 1,
401
- use_case: params.queries[0]?.use_case ?? '',
402
- primary_tool_slugs: ['GMAIL_SEND_EMAIL'],
403
- related_tool_slugs: [],
404
- toolkits: ['gmail'],
405
- reference_workbench_snippets: [{ description: 'snippet', code: 'print("hi")' }],
406
- },
407
- ],
408
- tool_schemas: {
409
- GMAIL_SEND_EMAIL: {
410
- tool_slug: 'GMAIL_SEND_EMAIL',
411
- toolkit: 'gmail',
412
- description: 'Sends an email',
413
- hasFullSchema: true,
414
- input_schema: { type: 'object', properties: {} },
415
- output_schema: { type: 'object', properties: {} },
416
- },
417
- },
418
- toolkit_connection_statuses: [
419
- {
420
- toolkit: 'gmail',
421
- description: 'gmail toolkit',
422
- has_active_connection: false,
423
- status_message: 'No active connection',
424
- },
425
- ],
426
- next_steps_guidance: [],
427
- session: {
428
- id: 'trs_test_session',
429
- generate_id: false,
430
- instructions: 'Reuse this session id for follow-up calls.',
431
- },
432
- time_info: {
433
- current_time_utc: '2026-01-01T00:00:00.000Z',
434
- current_time_utc_epoch_seconds: 1767225600,
435
- message: 'UTC time',
436
- },
437
- }),
438
- },
439
- });
440
-
441
- yield* cli(['search', 'send']).pipe(Effect.provide(live));
435
+ yield* cli(['search', 'send']);
436
const lines = yield* MockConsole.getLines({ stripAnsi: true });
437
const output = lines.join('\n');
438
444
}
445
);
446
453
- layer(TestLive({ baseConfigProvider: testConfigProvider, fixture: 'global-test-user-id' }))(
447
+ layer(
448
+ TestLive({
449
+ baseConfigProvider: testConfigProvider,
450
+ fixture: 'global-test-user-id',
451
+ toolkitsData: {
452
+ tools: [
453
+ {
454
+ name: 'Send Email',
455
+ slug: 'GMAIL_SEND_EMAIL',
456
+ description: 'Sends an email',
457
+ tags: [],
458
+ available_versions: [],
459
+ input_parameters: {
460
+ type: 'object',
461
+ properties: {
462
+ to: { type: 'string' },
463
+ subject: { type: 'string' },
464
+ body: { type: 'string' },
465
+ },
466
+ required: ['to'],
467
+ },
468
+ output_parameters: { type: 'object', properties: {} },
469
+ },
470
+ ],
471
+ },
472
+ })
473
+ )(
474
'[Given] search with schema properties [Then] next steps have valid payload and lowercase link',
475
it => {
456
- it.scoped('next steps use valid payload from input_schema and lowercase toolkit', () =>
476
+ it.effect('next steps use valid payload from input_schema and lowercase toolkit', () =>
477
Effect.gen(function* () {
458
- const live = TestLive({
459
- baseConfigProvider: testConfigProvider,
460
- fixture: 'global-test-user-id',
461
- toolkitsData: {
462
- tools: [
463
- {
464
- name: 'Send Email',
465
- slug: 'GMAIL_SEND_EMAIL',
466
- description: 'Sends an email',
467
- tags: [],
468
- available_versions: [],
469
- input_parameters: {
470
- type: 'object',
471
- properties: {
472
- to: { type: 'string' },
473
- subject: { type: 'string' },
474
- body: { type: 'string' },
475
- },
476
- required: ['to'],
477
- },
478
- output_parameters: { type: 'object', properties: {} },
479
- },
480
- ],
481
- },
482
- });
483
-
484
- yield* cli(['search', 'send']).pipe(Effect.provide(live));
478
+ yield* cli(['search', 'send']);
479
const lines = yield* MockConsole.getLines({ stripAnsi: true });
480
const output = lines.join('\n');
481
const parsed = extractFirstJsonObject(output);
503
layer(TestLive(testLiveOptions))(
504
'[Given] search with empty schema [Then] next steps execute uses -d "{}"',
505
it => {
512
- it.scoped('next steps use -d "{}" when no schema properties', () =>
506
+ it.effect('next steps use -d "{}" when no schema properties', () =>
507
Effect.gen(function* () {
508
yield* cli(['search', 'send']);
509
const lines = yield* MockConsole.getLines({ stripAnsi: true });
523
}
524
);
525
532
- layer(TestLive(testLiveOptions))(
533
- '[Given] --toolkits filter [Then] it is passed to session create as enabled toolkits',
534
- it => {
535
- it.scoped('passes toolkit filter into tool router session', () =>
536
- Effect.gen(function* () {
537
- let createParams: SessionCreateParams | undefined;
538
- let searchParams: SessionSearchParams | undefined;
539
-
540
- const live = TestLive({
541
- baseConfigProvider: testConfigProvider,
542
- toolkitsData,
543
- fixture: 'global-test-user-id',
544
- toolRouter: {
545
- create: async params => {
546
- createParams = params;
547
- return {
548
- session_id: 'trs_test_session',
549
- config: {
550
- user_id: params.user_id,
551
- execute: {},
552
- search: {},
553
- preload: { tools: [] },
554
- },
555
- config_version: 1,
556
- mcp: { type: 'http', url: 'https://mcp.test.composio.dev' },
557
- tool_router_tools: ['COMPOSIO_SEARCH_TOOLS'],
558
- };
526
+ {
527
+ let createParams: SessionCreateParams | undefined;
528
+ let searchParams: SessionSearchParams | undefined;
529
+
530
+ layer(
531
+ TestLive({
532
+ baseConfigProvider: testConfigProvider,
533
+ toolkitsData,
534
+ fixture: 'global-test-user-id',
535
+ toolRouter: {
536
+ create: async params => {
537
+ createParams = params;
538
+ return {
539
+ session_id: 'trs_test_session',
540
+ config: {
541
+ user_id: params.user_id,
542
+ execute: {},
543
+ search: {},
544
+ preload: { tools: [] },
545
},
560
- search: async (_sessionId, params) => {
561
- searchParams = params;
562
- return {
563
- success: true,
564
- error: null,
565
- results: [
566
- {
567
- index: 1,
568
- use_case: params.queries[0]?.use_case ?? '',
569
- primary_tool_slugs: ['GMAIL_SEND_EMAIL'],
570
- related_tool_slugs: [],
571
- toolkits: ['gmail'],
572
- },
573
- ],
574
- tool_schemas: {
575
- GMAIL_SEND_EMAIL: {
576
- tool_slug: 'GMAIL_SEND_EMAIL',
577
- toolkit: 'gmail',
578
- description: 'Sends an email',
579
- hasFullSchema: true,
580
- input_schema: { type: 'object', properties: {} },
581
- output_schema: { type: 'object', properties: {} },
582
- },
583
- },
584
- toolkit_connection_statuses: [
585
- {
586
- toolkit: 'gmail',
587
- description: 'gmail toolkit',
588
- has_active_connection: false,
589
- status_message: 'No active connection',
590
- },
591
- ],
592
- next_steps_guidance: [],
593
- session: {
594
- id: 'trs_test_session',
595
- generate_id: false,
596
- instructions: 'Reuse this session id for follow-up calls.',
597
- },
598
- time_info: {
599
- current_time_utc: '2026-01-01T00:00:00.000Z',
600
- current_time_utc_epoch_seconds: 1767225600,
601
- message: 'UTC time',
602
- },
603
- };
546
+ config_version: 1,
547
+ mcp: { type: 'http', url: 'https://mcp.test.composio.dev' },
548
+ tool_router_tools: ['COMPOSIO_SEARCH_TOOLS'],
549
+ };
550
+ },
551
+ search: async (_sessionId, params) => {
552
+ searchParams = params;
553
+ return {
554
+ success: true,
555
+ error: null,
556
+ results: [
557
+ {
558
+ index: 1,
559
+ use_case: params.queries[0]?.use_case ?? '',
560
+ primary_tool_slugs: ['GMAIL_SEND_EMAIL'],
561
+ related_tool_slugs: [],
562
+ toolkits: ['gmail'],
563
+ },
564
+ ],
565
+ tool_schemas: {
566
+ GMAIL_SEND_EMAIL: {
567
+ tool_slug: 'GMAIL_SEND_EMAIL',
568
+ toolkit: 'gmail',
569
+ description: 'Sends an email',
570
+ hasFullSchema: true,
571
+ input_schema: { type: 'object', properties: {} },
572
+ output_schema: { type: 'object', properties: {} },
573
+ },
574
},
605
- },
606
- });
607
-
608
- yield* cli(['search', 'send', '--toolkits', 'gmail,outlook']).pipe(Effect.provide(live));
575
+ toolkit_connection_statuses: [
576
+ {
577
+ toolkit: 'gmail',
578
+ description: 'gmail toolkit',
579
+ has_active_connection: false,
580
+ status_message: 'No active connection',
581
+ },
582
+ ],
583
+ next_steps_guidance: [],
584
+ session: {
585
+ id: 'trs_test_session',
586
+ generate_id: false,
587
+ instructions: 'Reuse this session id for follow-up calls.',
588
+ },
589
+ time_info: {
590
+ current_time_utc: '2026-01-01T00:00:00.000Z',
591
+ current_time_utc_epoch_seconds: 1767225600,
592
+ message: 'UTC time',
593
+ },
594
+ };
595
+ },
596
+ },
597
+ })
598
+ )('[Given] --toolkits filter [Then] it is passed to session create as enabled toolkits', it => {
599
+ it.effect('passes toolkit filter into tool router session', () =>
600
+ Effect.gen(function* () {
601
+ yield* cli(['search', 'send', '--toolkits', 'gmail,outlook']);
602
603
expect(createParams?.toolkits).toEqual({ enable: ['gmail', 'outlook'] });
604
expect(createParams?.experimental).toBeUndefined();
605
expect(searchParams?.queries[0]?.use_case).toBe('send');
606
})
607
);
615
- }
616
- );
617
-
618
- layer(TestLive(testLiveOptions))(
619
- '[Given] local toolkit filter [Then] it is sent as a custom toolkit',
620
- it => {
621
- it.scoped('injects and forwards local custom toolkit payloads', () =>
622
- Effect.gen(function* () {
623
- let createParams: SessionCreateParams | undefined;
624
- let searchParams:
625
- | (SessionSearchParams & { experimental?: SessionCreateParams['experimental'] })
626
- | undefined;
608
+ });
609
+ }
610
628
- const live = TestLive({
629
- baseConfigProvider: testConfigProvider,
630
- toolkitsData,
631
- fixture: 'global-test-user-id',
632
- toolRouter: {
633
- create: async params => {
634
- createParams = params;
635
- return {
636
- session_id: 'trs_test_session',
637
- config: {
638
- user_id: params.user_id,
639
- execute: {},
640
- search: {},
641
- preload: { tools: [] },
642
- },
643
- config_version: 1,
644
- mcp: { type: 'http', url: 'https://mcp.test.composio.dev' },
645
- tool_router_tools: ['COMPOSIO_SEARCH_TOOLS'],
646
- };
611
+ {
612
+ let createParams: SessionCreateParams | undefined;
613
+ let searchParams:
614
+ (SessionSearchParams & { experimental?: SessionCreateParams['experimental'] }) | undefined;
615
+
616
+ layer(
617
+ TestLive({
618
+ baseConfigProvider: testConfigProvider,
619
+ toolkitsData,
620
+ fixture: 'global-test-user-id',
621
+ toolRouter: {
622
+ create: async params => {
623
+ createParams = params;
624
+ return {
625
+ session_id: 'trs_test_session',
626
+ config: {
627
+ user_id: params.user_id,
628
+ execute: {},
629
+ search: {},
630
+ preload: { tools: [] },
631
},
648
- search: async (_sessionId, params) => {
649
- searchParams = params;
650
- return {
651
- success: true,
652
- error: null,
653
- results: [
654
- {
655
- index: 1,
656
- use_case: params.queries[0]?.use_case ?? '',
657
- primary_tool_slugs: ['LOCAL_CHROME_DEVTOOLS_LIST_PAGES'],
658
- related_tool_slugs: [],
659
- toolkits: ['CHROME_DEVTOOLS'],
660
- },
661
- ],
662
- tool_schemas: {
663
- LOCAL_CHROME_DEVTOOLS_LIST_PAGES: {
664
- tool_slug: 'LOCAL_CHROME_DEVTOOLS_LIST_PAGES',
665
- toolkit: 'CHROME_DEVTOOLS',
666
- description: 'List local Chrome pages',
667
- hasFullSchema: true,
668
- input_schema: { type: 'object', properties: {} },
669
- output_schema: { type: 'object', properties: {} },
670
- },
671
- },
672
- toolkit_connection_statuses: [
673
- {
674
- toolkit: 'CHROME_DEVTOOLS',
675
- description: 'Chrome DevTools local toolkit',
676
- has_active_connection: true,
677
- status_message: 'Local toolkit available',
678
- },
679
- ],
680
- next_steps_guidance: [],
681
- session: {
682
- id: 'trs_test_session',
683
- generate_id: false,
684
- instructions: 'Reuse this session id for follow-up calls.',
685
- },
686
- time_info: {
687
- current_time_utc: '2026-01-01T00:00:00.000Z',
688
- current_time_utc_epoch_seconds: 1767225600,
689
- message: 'UTC time',
690
- },
691
- };
632
+ config_version: 1,
633
+ mcp: { type: 'http', url: 'https://mcp.test.composio.dev' },
634
+ tool_router_tools: ['COMPOSIO_SEARCH_TOOLS'],
635
+ };
636
+ },
637
+ search: async (_sessionId, params) => {
638
+ searchParams = params;
639
+ return {
640
+ success: true,
641
+ error: null,
642
+ results: [
643
+ {
644
+ index: 1,
645
+ use_case: params.queries[0]?.use_case ?? '',
646
+ primary_tool_slugs: ['LOCAL_CHROME_DEVTOOLS_LIST_PAGES'],
647
+ related_tool_slugs: [],
648
+ toolkits: ['CHROME_DEVTOOLS'],
649
+ },
650
+ ],
651
+ tool_schemas: {
652
+ LOCAL_CHROME_DEVTOOLS_LIST_PAGES: {
653
+ tool_slug: 'LOCAL_CHROME_DEVTOOLS_LIST_PAGES',
654
+ toolkit: 'CHROME_DEVTOOLS',
655
+ description: 'List local Chrome pages',
656
+ hasFullSchema: true,
657
+ input_schema: { type: 'object', properties: {} },
658
+ output_schema: { type: 'object', properties: {} },
659
+ },
660
},
693
- },
694
- });
695
-
696
- yield* cli(['search', 'browser page', '--toolkits', 'chrome_devtools']).pipe(
697
- Effect.provide(live)
698
- );
661
+ toolkit_connection_statuses: [
662
+ {
663
+ toolkit: 'CHROME_DEVTOOLS',
664
+ description: 'Chrome DevTools local toolkit',
665
+ has_active_connection: true,
666
+ status_message: 'Local toolkit available',
667
+ },
668
+ ],
669
+ next_steps_guidance: [],
670
+ session: {
671
+ id: 'trs_test_session',
672
+ generate_id: false,
673
+ instructions: 'Reuse this session id for follow-up calls.',
674
+ },
675
+ time_info: {
676
+ current_time_utc: '2026-01-01T00:00:00.000Z',
677
+ current_time_utc_epoch_seconds: 1767225600,
678
+ message: 'UTC time',
679
+ },
680
+ };
681
+ },
682
+ },
683
+ })
684
+ )('[Given] local toolkit filter [Then] it is sent as a custom toolkit', it => {
685
+ it.effect('injects and forwards local custom toolkit payloads', () =>
686
+ Effect.gen(function* () {
687
+ yield* cli(['search', 'browser page', '--toolkits', 'chrome_devtools']);
688
689
expect(createParams?.toolkits).toBeUndefined();
690
expect(createParams?.experimental?.custom_toolkits?.[0]?.slug).toBe('CHROME_DEVTOOLS');
691
expect(searchParams?.experimental?.custom_toolkits?.[0]?.slug).toBe('CHROME_DEVTOOLS');
692
})
693
);
705
- }
706
- );
707
-
708
- layer(TestLive(testLiveOptions))(
709
- '[Given] unknown local-style toolkit filter [Then] it is still sent as a remote toolkit',
710
- it => {
711
- it.scoped('does not inject experimental custom toolkits for unknown local-style names', () =>
712
- Effect.gen(function* () {
713
- let createParams: SessionCreateParams | undefined;
714
-
715
- const live = TestLive({
716
- baseConfigProvider: testConfigProvider,
717
- toolkitsData,
718
- fixture: 'global-test-user-id',
719
- toolRouter: {
720
- create: async params => {
721
- createParams = params;
722
- return {
723
- session_id: 'trs_test_session',
724
- config: {
725
- user_id: params.user_id,
726
- execute: {},
727
- search: {},
728
- preload: { tools: [] },
729
- },
730
- config_version: 1,
731
- mcp: { type: 'http', url: 'https://mcp.test.composio.dev' },
732
- tool_router_tools: ['COMPOSIO_SEARCH_TOOLS'],
733
- };
734
- },
735
- },
736
- });
737
-
738
- yield* cli(['search', 'inspect local app', '--toolkits', 'local_app']).pipe(
739
- Effect.provide(live)
740
- );
741
-
742
- expect(createParams?.toolkits).toEqual({ enable: ['local_app'] });
743
- expect(createParams?.experimental).toBeUndefined();
744
- })
745
- );
746
- }
747
- );
694
+ });
695
+ }
696
749
- layer(TestLive(testLiveOptions))(
750
- '[Given] multiple queries [Then] search passes all queries to the tool-router session',
751
- it => {
752
- it.scoped('passes batched queries without a parallel flag', () =>
753
- Effect.gen(function* () {
754
- let searchParams: SessionSearchParams | undefined;
755
-
756
- const live = TestLive({
757
- baseConfigProvider: testConfigProvider,
758
- toolkitsData,
759
- fixture: 'global-test-user-id',
760
- toolRouter: {
761
- search: async (_sessionId, params) => {
762
- searchParams = params;
763
- return {
764
- success: true,
765
- error: null,
766
- results: params.queries.map((query, index) => ({
767
- index: index + 1,
768
- use_case: query.use_case ?? '',
769
- primary_tool_slugs:
770
- query.use_case === 'create issue'
771
- ? ['GITHUB_CREATE_ISSUE']
772
- : ['GMAIL_SEND_EMAIL'],
773
- related_tool_slugs: [],
774
- toolkits: query.use_case === 'create issue' ? ['github'] : ['gmail'],
775
- })),
776
- tool_schemas: {
777
- GMAIL_SEND_EMAIL: {
778
- tool_slug: 'GMAIL_SEND_EMAIL',
779
- toolkit: 'gmail',
780
- description: 'Sends an email',
781
- hasFullSchema: true,
782
- input_schema: { type: 'object', properties: {} },
783
- output_schema: { type: 'object', properties: {} },
784
- },
785
- GITHUB_CREATE_ISSUE: {
786
- tool_slug: 'GITHUB_CREATE_ISSUE',
787
- toolkit: 'github',
788
- description: 'Creates a GitHub issue',
789
- hasFullSchema: true,
790
- input_schema: { type: 'object', properties: {} },
791
- output_schema: { type: 'object', properties: {} },
792
- },
793
- },
794
- toolkit_connection_statuses: [],
795
- next_steps_guidance: [],
796
- session: {
797
- id: 'trs_test_session',
798
- generate_id: false,
799
- instructions: 'Reuse this session id for follow-up calls.',
800
- },
801
- time_info: {
802
- current_time_utc: '2026-01-01T00:00:00.000Z',
803
- current_time_utc_epoch_seconds: 1767225600,
804
- message: 'UTC time',
805
- },
806
- };
697
+ {
698
+ let createParams: SessionCreateParams | undefined;
699
+
700
+ layer(
701
+ TestLive({
702
+ baseConfigProvider: testConfigProvider,
703
+ toolkitsData,
704
+ fixture: 'global-test-user-id',
705
+ toolRouter: {
706
+ create: async params => {
707
+ createParams = params;
708
+ return {
709
+ session_id: 'trs_test_session',
710
+ config: {
711
+ user_id: params.user_id,
712
+ execute: {},
713
+ search: {},
714
+ preload: { tools: [] },
715
},
808
- },
809
- });
810
-
811
- yield* cli(['search', 'send', 'create issue']).pipe(Effect.provide(live));
812
-
813
- expect(searchParams?.queries.map(query => query.use_case)).toEqual([
814
- 'send',
815
- 'create issue',
816
- ]);
817
- })
818
- );
819
- }
820
- );
716
+ config_version: 1,
717
+ mcp: { type: 'http', url: 'https://mcp.test.composio.dev' },
718
+ tool_router_tools: ['COMPOSIO_SEARCH_TOOLS'],
719
+ };
720
+ },
721
+ },
722
+ })
723
+ )(
724
+ '[Given] unknown local-style toolkit filter [Then] it is still sent as a remote toolkit',
725
+ it => {
726
+ it.effect(
727
+ 'does not inject experimental custom toolkits for unknown local-style names',
728
+ () =>
729
+ Effect.gen(function* () {
730
+ yield* cli(['search', 'inspect local app', '--toolkits', 'local_app']);
731
+
732
+ expect(createParams?.toolkits).toEqual({ enable: ['local_app'] });
733
+ expect(createParams?.experimental).toBeUndefined();
734
+ })
735
+ );
736
+ }
737
+ );
738
+ }
739
822
- layer(TestLive(testLiveOptions))(
823
- '[Given] search response with recommended plan [Then] it prints plan and execute hint',
824
- it => {
825
- it.scoped('prints plan and command hints', () =>
826
- Effect.gen(function* () {
827
- const live = TestLive({
828
- baseConfigProvider: testConfigProvider,
829
- toolkitsData,
830
- fixture: 'global-test-user-id',
831
- toolRouter: {
832
- search: async (_sessionId, params) => ({
833
- success: true,
834
- error: null,
835
- results: [
836
- {
837
- index: 1,
838
- use_case: params.queries[0]?.use_case ?? '',
839
- primary_tool_slugs: ['GMAIL_SEND_EMAIL'],
840
- related_tool_slugs: [],
841
- toolkits: ['gmail'],
842
- recommended_plan_steps: ['Collect recipient details', 'Execute send action'],
843
- },
844
- ],
845
- tool_schemas: {
846
- GMAIL_SEND_EMAIL: {
847
- tool_slug: 'GMAIL_SEND_EMAIL',
848
- toolkit: 'gmail',
849
- description: 'Sends an email',
850
- hasFullSchema: true,
851
- input_schema: { type: 'object', properties: {} },
852
- output_schema: { type: 'object', properties: {} },
853
- },
854
- },
855
- toolkit_connection_statuses: [
856
- {
857
- toolkit: 'gmail',
858
- description: 'gmail toolkit',
859
- has_active_connection: false,
860
- status_message: 'No active connection',
861
- },
862
- ],
863
- next_steps_guidance: ['Fallback guidance'],
864
- session: {
865
- id: 'trs_test_session',
866
- generate_id: false,
867
- instructions: 'Reuse this session id for follow-up calls.',
740
+ {
741
+ let searchParams: SessionSearchParams | undefined;
742
+
743
+ layer(
744
+ TestLive({
745
+ baseConfigProvider: testConfigProvider,
746
+ toolkitsData,
747
+ fixture: 'global-test-user-id',
748
+ toolRouter: {
749
+ search: async (_sessionId, params) => {
750
+ searchParams = params;
751
+ return {
752
+ success: true,
753
+ error: null,
754
+ results: params.queries.map((query, index) => ({
755
+ index: index + 1,
756
+ use_case: query.use_case ?? '',
757
+ primary_tool_slugs:
758
+ query.use_case === 'create issue'
759
+ ? ['GITHUB_CREATE_ISSUE']
760
+ : ['GMAIL_SEND_EMAIL'],
761
+ related_tool_slugs: [],
762
+ toolkits: query.use_case === 'create issue' ? ['github'] : ['gmail'],
763
+ })),
764
+ tool_schemas: {
765
+ GMAIL_SEND_EMAIL: {
766
+ tool_slug: 'GMAIL_SEND_EMAIL',
767
+ toolkit: 'gmail',
768
+ description: 'Sends an email',
769
+ hasFullSchema: true,
770
+ input_schema: { type: 'object', properties: {} },
771
+ output_schema: { type: 'object', properties: {} },
772
},
869
- time_info: {
870
- current_time_utc: '2026-01-01T00:00:00.000Z',
871
- current_time_utc_epoch_seconds: 1767225600,
872
- message: 'UTC time',
773
+ GITHUB_CREATE_ISSUE: {
774
+ tool_slug: 'GITHUB_CREATE_ISSUE',
775
+ toolkit: 'github',
776
+ description: 'Creates a GitHub issue',
777
+ hasFullSchema: true,
778
+ input_schema: { type: 'object', properties: {} },
779
+ output_schema: { type: 'object', properties: {} },
780
},
874
- }),
875
- },
876
- });
781
+ },
782
+ toolkit_connection_statuses: [],
783
+ next_steps_guidance: [],
784
+ session: {
785
+ id: 'trs_test_session',
786
+ generate_id: false,
787
+ instructions: 'Reuse this session id for follow-up calls.',
788
+ },
789
+ time_info: {
790
+ current_time_utc: '2026-01-01T00:00:00.000Z',
791
+ current_time_utc_epoch_seconds: 1767225600,
792
+ message: 'UTC time',
793
+ },
794
+ };
795
+ },
796
+ },
797
+ })
798
+ )(
799
+ '[Given] multiple queries [Then] search passes all queries to the tool-router session',
800
+ it => {
801
+ it.effect('passes batched queries without a parallel flag', () =>
802
+ Effect.gen(function* () {
803
+ yield* cli(['search', 'send', 'create issue']);
804
+
805
+ expect(searchParams?.queries.map(query => query.use_case)).toEqual([
806
+ 'send',
807
+ 'create issue',
808
+ ]);
809
+ })
810
+ );
811
+ }
812
+ );
813
+ }
814
878
- yield* cli(['search', 'send email', '--human']).pipe(Effect.provide(live));
879
- const lines = yield* MockConsole.getLines({ stripAnsi: true });
880
- const output = lines.join('\n');
815
+ layer(
816
+ TestLive({
817
+ baseConfigProvider: testConfigProvider,
818
+ toolkitsData,
819
+ fixture: 'global-test-user-id',
820
+ toolRouter: {
821
+ search: async (_sessionId, params) => ({
822
+ success: true,
823
+ error: null,
824
+ results: [
825
+ {
826
+ index: 1,
827
+ use_case: params.queries[0]?.use_case ?? '',
828
+ primary_tool_slugs: ['GMAIL_SEND_EMAIL'],
829
+ related_tool_slugs: [],
830
+ toolkits: ['gmail'],
831
+ recommended_plan_steps: ['Collect recipient details', 'Execute send action'],
832
+ },
833
+ ],
834
+ tool_schemas: {
835
+ GMAIL_SEND_EMAIL: {
836
+ tool_slug: 'GMAIL_SEND_EMAIL',
837
+ toolkit: 'gmail',
838
+ description: 'Sends an email',
839
+ hasFullSchema: true,
840
+ input_schema: { type: 'object', properties: {} },
841
+ output_schema: { type: 'object', properties: {} },
842
+ },
843
+ },
844
+ toolkit_connection_statuses: [
845
+ {
846
+ toolkit: 'gmail',
847
+ description: 'gmail toolkit',
848
+ has_active_connection: false,
849
+ status_message: 'No active connection',
850
+ },
851
+ ],
852
+ next_steps_guidance: ['Fallback guidance'],
853
+ session: {
854
+ id: 'trs_test_session',
855
+ generate_id: false,
856
+ instructions: 'Reuse this session id for follow-up calls.',
857
+ },
858
+ time_info: {
859
+ current_time_utc: '2026-01-01T00:00:00.000Z',
860
+ current_time_utc_epoch_seconds: 1767225600,
861
+ message: 'UTC time',
862
+ },
863
+ }),
864
+ },
865
+ })
866
+ )('[Given] search response with recommended plan [Then] it prints plan and execute hint', it => {
867
+ it.effect('prints plan and command hints', () =>
868
+ Effect.gen(function* () {
869
+ yield* cli(['search', 'send email', '--human']);
870
+ const lines = yield* MockConsole.getLines({ stripAnsi: true });
871
+ const output = lines.join('\n');
872
882
- expect(output).toContain('Plan:');
883
- expect(output).toContain('1. Collect recipient details');
884
- expect(output).toContain('Execute a tool:');
885
- expect(output).toContain(`composio execute "GMAIL_SEND_EMAIL" -d "{}"`);
886
- expect(output).toContain(`composio link <toolkit>`);
887
- })
888
- );
889
- }
890
- );
873
+ expect(output).toContain('Plan:');
874
+ expect(output).toContain('1. Collect recipient details');
875
+ expect(output).toContain('Execute a tool:');
876
+ expect(output).toContain(`composio execute "GMAIL_SEND_EMAIL" -d "{}"`);
877
+ expect(output).toContain(`composio link <toolkit>`);
878
+ })
879
+ );
880
+ });
881
882
layer(TestLive())('[Given] no API key [Then] warns user to login', it => {
893
- it.scoped('warns user to login', () =>
883
+ it.effect('warns user to login', () =>
884
Effect.gen(function* () {
885
yield* cli(['search', 'send', '--human']);
886
const lines = yield* MockConsole.getLines({ stripAnsi: true });
891
);
892
});
893
904
- layer(TestLive(testLiveOptions))(
905
- '[Given] consumer search [Then] it uses the resolved consumer user id',
906
- it => {
907
- it.scoped('uses consumer user id from the resolved project context', () =>
908
- Effect.gen(function* () {
909
- let createParams: SessionCreateParams | undefined;
910
- const live = TestLive({
911
- ...testLiveOptions,
912
- toolRouter: {
913
- create: async params => {
914
- createParams = params;
915
- return {
916
- session_id: 'trs_test_session',
917
- config: {
918
- user_id: params.user_id,
919
- execute: {},
920
- search: {},
921
- preload: { tools: [] },
922
- },
923
- config_version: 1,
924
- mcp: { type: 'http', url: 'https://mcp.test.composio.dev' },
925
- tool_router_tools: ['COMPOSIO_SEARCH_TOOLS'],
926
- };
894
+ {
895
+ let createParams: SessionCreateParams | undefined;
896
+
897
+ layer(
898
+ TestLive({
899
+ ...testLiveOptions,
900
+ toolRouter: {
901
+ create: async params => {
902
+ createParams = params;
903
+ return {
904
+ session_id: 'trs_test_session',
905
+ config: {
906
+ user_id: params.user_id,
907
+ execute: {},
908
+ search: {},
909
+ preload: { tools: [] },
910
},
928
- },
929
- });
930
-
931
- yield* cli(['search', 'send']).pipe(Effect.provide(live));
911
+ config_version: 1,
912
+ mcp: { type: 'http', url: 'https://mcp.test.composio.dev' },
913
+ tool_router_tools: ['COMPOSIO_SEARCH_TOOLS'],
914
+ };
915
+ },
916
+ },
917
+ })
918
+ )('[Given] consumer search [Then] it uses the resolved consumer user id', it => {
919
+ it.effect('uses consumer user id from the resolved project context', () =>
920
+ Effect.gen(function* () {
921
+ yield* cli(['search', 'send']);
922
923
expect(createParams?.user_id).toBe('consumer-user-org_test');
924
})
925
);
936
- }
937
- );
926
+ });
927
+ }
928
929
layer(
930
TestLive({
933
toolkitsData,
934
})
935
)('[Given] no explicit --user-id [Then] consumer search does not require one', it => {
946
- it.scoped('runs without printing global test user diagnostics', () =>
936
+ it.effect('runs without printing global test user diagnostics', () =>
937
Effect.gen(function* () {
938
yield* cli(['search', 'send']);
939
const lines = yield* MockConsole.getLines({ stripAnsi: true });
949
layer(TestLive(testLiveOptions))(
950
'[Given] composio search [Then] runs the root search flow',
951
it => {
962
- it.scoped('search returns matching tools', () =>
952
+ it.effect('search returns matching tools', () =>
953
Effect.gen(function* () {
954
yield* cli(['search', 'send', '--human']);
955
const lines = yield* MockConsole.getLines({ stripAnsi: true });