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(core): match the triggers toolkit filter for underscore toolkit slugs (#4948)
## Summary `triggers.subscribe(fn, { toolkits: ['one_drive'] })` never calls `fn`. Realtime trigger payloads don't carry a toolkit slug, so `Triggers` derives one from the first `_` segment of the trigger slug: `ONE_DRIVE_FILE_CREATED_TRIGGER` becomes `ONE`. The `toolkits` filter then compares `one_drive` against `one` and drops the event. This hits every toolkit whose slug has an underscore and that ships triggers. In the toolkit data under `docs/public/data/toolkits.json` that is `one_drive` (9 triggers), `launch_darkly` (16) and `agent_mail` (1), so 26 of the 671 listed triggers. Every listed trigger slug starts with `<TOOLKIT>_`, which is what the fix relies on. Fixes #4947 Designated PR reviewer: @jkomyno ## Changes - `shouldSendTriggerAfterFilters`: a `toolkits` entry matches when it equals the derived `toolkitSlug` (unchanged) or when the trigger slug starts with `<toolkit>_`, case-insensitively. - Three tests in `test/models/triggers.test.ts`: `one_drive` matches a OneDrive V3 payload, `ONE_DRIVE` matches it too, and `one_drive` does not match a slug that only shares the prefix (`ONE_DRIVEX_...`). - Patch changeset for `@composio/core`. The derived `toolkitSlug` on the payload handed to the callback is still `ONE`. Fixing that needs the toolkit slug from the backend (it isn't in the V3 metadata), so I left it alone and only fixed the filter. The Python SDK has the same derivation (`_build_trigger_event_from_v3`) and its `toolkit` filter in `_filters_match` drops these events the same way. I kept this PR to TypeScript and can send the Python side as a follow-up if you want both. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactor/Chore - [ ] Documentation - [ ] Breaking change ## How Has This Been Tested? - With the new tests and without the fix: 2 failed, 61 passed in `test/models/triggers.test.ts` (`expected "vi.fn()" to be called 1 times, but got 0 times` for the two `one_drive` cases). - With the fix: 63 passed in `test/models/triggers.test.ts`. - `pnpm --filter @composio/core test`: 1912 passed, 2 expected fail. `test/providers/refContract.test.ts` fails to load in my checkout with and without this change because it scans `ts/packages/providers`, which I didn't have checked out. - `pnpm --filter @composio/core typecheck`: clean. - `oxlint` on the two touched files: no new warnings (the existing unused `ok` in `parseWebhookPayload` is unchanged). `prettier --check`: clean. - `node ts/scripts/validate-changesets.mjs`: passed. Node 24.19.0, pnpm 11.8.0. ## Checklist - [x] I have read the Code of Conduct and this PR adheres to it - [x] I have read and understand every line of this diff, including any LLM-generated code - [x] Any third-party docs links or promotional content follow the third-party links policy - [x] I ran linters/tests locally and they passed - [ ] I updated documentation as needed - [x] I added tests or explain why not applicable - [x] I added a changeset if this change affects published packages ## Additional context No docs change: the filter takes toolkit slugs, and this makes the three affected slugs behave like every other one.