@devries-cameron20 / composio-1 / commits / e552d0c6e
Fork 0

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

fix(cli): match `--toolkits` for toolkit slugs with underscores (#5124)

This PR: - Refs #4947 (CLI side); the SDK halves are #4948 (TypeScript core) and #4954 (Python), which use the same rule - makes `composio dev triggers listen --toolkits one_drive` (and `launch_darkly`, `agent_mail`) match events instead of dropping all of them - matches a `--toolkits` entry when it equals the event's derived toolkit, or when the trigger slug starts with `<toolkit>_`, ignoring case - adds a patch entry to `ts/packages/cli/CHANGELOG.md` (the CLI is excluded from Changesets) ## Context Trigger payloads carry no toolkit slug, so `parseTriggerListenEvent` derives it from the trigger slug's first `_` segment: `ONE_DRIVE_FILE_CREATED_TRIGGER` becomes `ONE`, and `--toolkits one_drive` never matched. The prefix rule would let `--toolkits google` match a `GOOGLE_CALENDAR_*` trigger if both `google` and `google_calendar` were toolkits with triggers. No such pair exists: in `docs/public/data/toolkits.json` every trigger slug starts with its own toolkit's slug, and none starts with another toolkit's slug plus `_`. An earlier revision resolved the toolkit exactly through `ToolkitSlugCatalog`; it was reverted to keep the CLI on the same rule as the SDKs for a case that does not occur. `composio listen` and `composio dev listen` filter by trigger id only, so they never hit the bug. ## How Has This Been Tested? - `filter.test.ts`: `gmail` in either case, `one_drive` / `ONE_DRIVE`, `launch_darkly`, `agent_mail`, and `one_drive` not matching `ONE_DRIVEX_*`; the underscore cases fail on `next` - after merging `next`: CLI suite (223 files, 2900 passed, 1 skipped), root `pnpm typecheck`, `lint:effect` and oxlint on `ts/packages/cli`: clean

Alberto Schiabel committed Oct 28, 2026 at 20:39 UTC e552d0c6e29de4706f6d5c4ac75f7380691f6611
3 files changed +89 -4
ts/packages/cli/CHANGELOG.md
+7
@@ -49,6 +49,13 @@
49
50 ### Patch Changes
51
52 +- `composio dev triggers listen --toolkits` now matches toolkits whose slug
53 + contains an underscore, such as `one_drive`, `launch_darkly` and
54 + `agent_mail`. Events carry no toolkit slug, so the listener took the first
55 + `_` segment of the trigger slug (`ONE` for `ONE_DRIVE_FILE_CREATED_TRIGGER`)
56 + and dropped every event of those toolkits. A `--toolkits` entry now also
57 + matches when the trigger slug starts with `<toolkit>_`.
58 +
59 - `composio connections list`, `composio connections remove`, and
60 `composio listen` without a consumer user now print the message on stderr
61 and exit 1, like other expected errors. They used to print it under a `💥`
ts/packages/cli/src/commands/triggers/filter.ts
+15 -4
@@ -1,5 +1,19 @@
1 import type { TriggerListenEvent, TriggerListenFilters } from './types';
2
3 +/**
4 + * Payloads don't carry the toolkit slug, so `data.toolkitSlug` is the trigger slug's
5 + * first `_` segment, which is wrong for toolkits whose slug contains an underscore
6 + * (`ONE_DRIVE_FILE_CREATED_TRIGGER` gives `ONE`). Trigger slugs start with
7 + * `<TOOLKIT>_`, so a toolkit also matches on that prefix.
8 + */
9 +const matchesToolkit = (toolkit: string, data: TriggerListenEvent): boolean => {
10 + const filter = toolkit.toLowerCase();
11 + return (
12 + filter === data.toolkitSlug.toLowerCase() ||
13 + data.triggerSlug.toLowerCase().startsWith(`${filter}_`)
14 + );
15 +};
16 +
17 /**
18 * Check if a trigger event matches the provided filters.
19 * All string comparisons on `toolkits` and `triggerSlug` are case-insensitive.
@@ -8,10 +22,7 @@ export const matchesTriggerListenFilters = (
22 filters: TriggerListenFilters,
23 data: TriggerListenEvent
24 ): boolean => {
11 - if (
12 - filters.toolkits?.length &&
13 - !filters.toolkits.some(t => t.toLowerCase() === data.toolkitSlug.toLowerCase())
14 - ) {
25 + if (filters.toolkits?.length && !filters.toolkits.some(t => matchesToolkit(t, data))) {
26 return false;
27 }
28
ts/packages/cli/test/src/commands/triggers/filter.test.ts new
+67
@@ -0,0 +1,67 @@
1 +import { describe, expect, it } from '@effect/vitest';
2 +import { matchesTriggerListenFilters } from 'src/commands/triggers/filter';
3 +import type { TriggerListenEvent } from 'src/commands/triggers/types';
4 +
5 +// Mirrors `parseTriggerListenEvent`: payloads carry no toolkit slug, so the
6 +// toolkit is the trigger slug's first `_` segment.
7 +const eventFor = (triggerSlug: string): TriggerListenEvent => {
8 + const toolkitSlug = triggerSlug.split('_')[0]?.toUpperCase() ?? 'UNKNOWN';
9 + return {
10 + id: 'ti_abc',
11 + uuid: 'ti_abc',
12 + triggerSlug,
13 + toolkitSlug,
14 + userId: 'user-1',
15 + payload: {},
16 + originalPayload: {},
17 + metadata: {
18 + id: 'ti_abc',
19 + uuid: 'ti_abc',
20 + toolkitSlug,
21 + triggerSlug,
22 + triggerConfig: {},
23 + connectedAccount: {
24 + id: 'ca_abc',
25 + uuid: 'ca_abc',
26 + authConfigId: 'ac_abc',
27 + authConfigUUID: 'ac_abc',
28 + userId: 'user-1',
29 + status: 'ACTIVE',
30 + },
31 + },
32 + };
33 +};
34 +
35 +describe('matchesTriggerListenFilters', () => {
36 + describe('[Given] a --toolkits filter', () => {
37 + it('[Then] matches the toolkit derived from the trigger slug, case-insensitively', () => {
38 + const event = eventFor('GMAIL_NEW_GMAIL_MESSAGE');
39 +
40 + expect(matchesTriggerListenFilters({ toolkits: ['gmail'] }, event)).toBe(true);
41 + expect(matchesTriggerListenFilters({ toolkits: ['GMAIL'] }, event)).toBe(true);
42 + expect(matchesTriggerListenFilters({ toolkits: ['slack'] }, event)).toBe(false);
43 + });
44 +
45 + // `one_drive`, `launch_darkly` and `agent_mail` contain an underscore, so the
46 + // derived toolkit is `ONE`, not `ONE_DRIVE` (#4947).
47 + it.each([
48 + ['one_drive', 'ONE_DRIVE_FILE_CREATED_TRIGGER'],
49 + ['ONE_DRIVE', 'ONE_DRIVE_FILE_CREATED_TRIGGER'],
50 + ['launch_darkly', 'LAUNCH_DARKLY_FLAG_UPDATED'],
51 + ['agent_mail', 'AGENT_MAIL_MESSAGE_RECEIVED'],
52 + ])('[Then] matches %s, whose slug contains an underscore, on %s', (toolkit, triggerSlug) => {
53 + expect(matchesTriggerListenFilters({ toolkits: [toolkit] }, eventFor(triggerSlug))).toBe(
54 + true
55 + );
56 + });
57 +
58 + it('[Then] does not match a toolkit that only shares a prefix with the trigger slug', () => {
59 + expect(
60 + matchesTriggerListenFilters(
61 + { toolkits: ['one_drive'] },
62 + eventFor('ONE_DRIVEX_FILE_CREATED')
63 + )
64 + ).toBe(false);
65 + });
66 + });
67 +});