Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
feat(cli): use triggerTypes for createToolkitIndex in place of triggerTypesAsEnums, preserving the old enums-like output for now
jkomynoee7b9787af79
diff --git a/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts b/ts/packages/cli/src/commands/py/commands/py.generate.cmd.tsindex 98e898a5c..9e593cc07 100644--- a/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts+++ b/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts@@ -48,12 +48,16 @@ export function generatePythonTypeStubs({ outputOpt }: GetCmdParams<typeof _pyCm// Fetch data from Composio APIyield* Console.log('Fetching latest data from Composio API...');+ const triggerTypesAsEnums = yield* Effect.logDebug('Fetching trigger types...').pipe(+ Effect.flatMap(() => client.getTriggerTypesAsEnums())+ );+const [toolkits, tools, triggerTypes] = yield* Effect.all([Effect.logDebug('Fetching toolkits...').pipe(Effect.flatMap(() => client.getToolkits())),Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getTools())),- Effect.logDebug('Fetching trigger types...').pipe(- Effect.flatMap(() => client.getTriggerTypes())+ Effect.logDebug('Fetching trigger types payloads...').pipe(+ Effect.flatMap(() => client.getTriggerTypes(triggerTypesAsEnums.length))),],{ concurrency: 'unbounded' }diff --git a/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts b/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.tsindex 62714f1af..7985e1a21 100644--- a/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts+++ b/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts@@ -120,7 +120,7 @@ export function generateTypescriptTypeStubs({Effect.flatMap(() => client.getTriggerTypesAsEnums()));- const [toolkits, tools, _triggerTypes] = yield* Effect.all(+ const [toolkits, tools, triggerTypes] = yield* Effect.all([Effect.logDebug('Fetching toolkits...').pipe(Effect.flatMap(() => client.getToolkits())),Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getTools())),@@ -131,7 +131,7 @@ export function generateTypescriptTypeStubs({{ concurrency: 'unbounded' });- const index = createToolkitIndex({ toolkits, tools, triggerTypes: triggerTypesAsEnums });+ const index = createToolkitIndex({ toolkits, tools, triggerTypes });// Generate TypeScript sourcesconst sources = generateTypeScriptSources({diff --git a/ts/packages/cli/src/generation/create-toolkit-index.ts b/ts/packages/cli/src/generation/create-toolkit-index.tsindex e9b347f89..ac4d53e41 100644--- a/ts/packages/cli/src/generation/create-toolkit-index.ts+++ b/ts/packages/cli/src/generation/create-toolkit-index.ts@@ -2,7 +2,7 @@ import { pipe, String, Record } from 'effect';import type { Simplify } from 'effect/Types';import { Toolkit, Toolkits, ToolkitName } from 'src/models/toolkits';import { Tools } from 'src/models/tools';-import { TriggerTypesAsEnums } from 'src/models/trigger-types';+import { TriggerType, TriggerTypes } from 'src/models/trigger-types';const startsWith =<const P extends string>(prefix: P) =>@@ -10,9 +10,9 @@ const startsWith =str.startsWith(prefix);interface CreateToolkitIndexInput {- toolkits: Toolkits; // e.g., [ { slug: 'gmail', }]+ toolkits: Toolkits; // e.g., [ { slug: 'gmail', ... }]tools: Tools; // e.g., [ 'GMAIL_SEND_EMAIL' ]- triggerTypes: TriggerTypesAsEnums; // e.g., [ 'GMAIL_NEW_EMAIL' ]+ triggerTypes: TriggerTypes; // e.g., [ { slug: 'GMAIL_NEW_EMAIL', ... } ]}export type ToolkitIndexData = Simplify<{@@ -39,7 +39,7 @@ export function createToolkitIndex(input: CreateToolkitIndexInput): Simplify<Tooconst { slug } = value.toolkit;const tools = value.tools.map(tool => [stripPrefix(tool), tool] as const);const triggerTypes = value.triggerTypes.map(- triggerType => [stripPrefix(triggerType), triggerType] as const+ triggerType => [stripPrefix(triggerType.slug), triggerType.slug] as const);return [@@ -50,12 +50,17 @@ export function createToolkitIndex(input: CreateToolkitIndexInput): Simplify<Too);}+type TriggerTypeWithUppercaseSlug<T extends ToolkitName> = Omit<TriggerType, 'slug'> & {+ slug: `${Uppercase<T>}_${string}`;+};+type GroupByToolkitOutput<T extends ToolkitName> = [Uppercase<T>,{toolkit: Toolkit;tools: Array<`${Uppercase<T>}_${string}`>;- triggerTypes: Array<`${Uppercase<T>}_${string}`>;+ // triggerTypes: Array<TriggerTypeWithUppercaseSlug<T>>;+ triggerTypes: TriggerTypes;},];@@ -74,7 +79,10 @@ const groupByToolkit ={toolkit,tools: tools.filter(startsWith(`${toolkitName}_`)),- triggerTypes: triggerTypes.filter(startsWith(`${toolkitName}_`)),+ triggerTypes: triggerTypes.filter(triggerType => {+ console.log('Checking trigger type slug', triggerType?.slug);+ return startsWith(`${toolkitName}_`)(triggerType.slug);+ }), // as Array<TriggerTypeWithUppercaseSlug<T & ToolkitName>>,},];};diff --git a/ts/packages/cli/test/__mocks__/trigger-type-gmail.ts b/ts/packages/cli/test/__mocks__/trigger-type-gmail.tsnew file mode 100644index 000000000..5566d7de6--- /dev/null+++ b/ts/packages/cli/test/__mocks__/trigger-type-gmail.ts@@ -0,0 +1,174 @@+import type { TriggerType } from 'src/models/trigger-types';++export const TRIGGER_TYPE_GMAIL = {+ config: {+ properties: {+ interval: {+ default: 1,+ description: 'Periodic Interval to Check for Updates & Send a Trigger in Minutes',+ title: 'Interval',+ type: 'number',+ },+ labelIds: {+ default: 'INBOX',+ description:+ "Filter messages by a single label ID. Labels identify the status or category of messages. Supported labels include 'INBOX', 'SPAM', 'TRASH', 'UNREAD', 'STARRED', 'IMPORTANT', 'CATEGORY_PERSONAL', 'CATEGORY_SOCIAL', 'CATEGORY_PROMOTIONS', 'CATEGORY_UPDATES', and 'CATEGORY_FORUMS'. For complex label filtering, use the 'query' parameter instead.",+ examples: ['INBOX', 'UNREAD', 'STARRED'],+ title: 'Labelids',+ type: 'string',+ },+ query: {+ default: '',+ description:+ "Advanced Gmail search using the same syntax as Gmail's search box. Use 'AND' for messages that match all conditions, 'OR' for any condition. Search by sender (from:[email protected]), labels (label:inbox), status (is:unread), attachments (has:attachment), dates (after:2023/1/1), and more. If specified, this takes precedence over labelIds.",+ examples: [+ 'label:inbox OR label:sent',+ 'from:[email protected] is:unread',+ 'has:attachment after:2023/1/1',+ 'is:important is:unread',+ ],+ title: 'Query',+ type: 'string',+ },+ userId: {+ default: 'me',+ description: "The user's email address or 'me' for the authenticated user.",+ examples: ['me'],+ title: 'Userid',+ type: 'string',+ },+ },+ title: 'NewMessageConfig',+ type: 'object',+ },+ description: 'Triggers when a new message is received in Gmail.',+ instructions:+ "\n **Instructions for Setting Up the Trigger:**\n\n - Ensure that the Gmail API is enabled for your Google account.\n - Provide the user ID (usually 'me' for the authenticated user).\n - Optionally, provide label IDs to filter messages.\n ",+ name: 'New Gmail Message Received Trigger',+ payload: {+ properties: {+ attachment_list: {+ anyOf: [+ {+ items: {},+ type: 'array',+ },+ {+ type: 'null',+ },+ ],+ default: null,+ description: 'The list of attachments in the message',+ title: 'Attachment List',+ },+ message_id: {+ anyOf: [+ {+ type: 'string',+ },+ {+ type: 'null',+ },+ ],+ default: null,+ description: 'The message ID of the message',+ title: 'Message ID',+ },+ message_text: {+ anyOf: [+ {+ type: 'string',+ },+ {+ type: 'null',+ },+ ],+ default: null,+ description: 'The text of the message',+ title: 'Message Text',+ },+ message_timestamp: {+ anyOf: [+ {+ type: 'string',+ },+ {+ type: 'null',+ },+ ],+ default: null,+ description: 'The timestamp of the message',+ title: 'Message Timestamp',+ },+ payload: {+ anyOf: [+ {+ type: 'object',+ },+ {+ type: 'null',+ },+ ],+ default: null,+ description: 'The payload of the message',+ title: 'Payload',+ },+ sender: {+ anyOf: [+ {+ type: 'string',+ },+ {+ type: 'null',+ },+ ],+ default: null,+ description: 'The sender of the message',+ title: 'Sender',+ },+ subject: {+ anyOf: [+ {+ type: 'string',+ },+ {+ type: 'null',+ },+ ],+ default: null,+ description: 'The subject of the message',+ title: 'Subject',+ },+ thread_id: {+ anyOf: [+ {+ type: 'string',+ },+ {+ type: 'null',+ },+ ],+ default: null,+ description: 'The thread ID of the message',+ title: 'Thread ID',+ },+ to: {+ anyOf: [+ {+ type: 'string',+ },+ {+ type: 'null',+ },+ ],+ default: null,+ description: 'The recipient of the message',+ title: 'To',+ },+ },+ title: 'NewMessagePayload',+ type: 'object',+ },+ slug: 'GMAIL_NEW_GMAIL_MESSAGE',+ type: 'poll',+} satisfies TriggerType;diff --git a/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts b/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.tsindex bbab87232..aeb8e7830 100644--- a/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts@@ -3,7 +3,7 @@ import { describe, expect, layer } from '@effect/vitest';import { Effect } from 'effect';import { FileSystem } from '@effect/platform';import { cli, TestLive } from 'test/__utils__';-import { makeTestToolkit } from 'test/__utils__/models/toolkits';+import { makeTestToolkits } from 'test/__utils__/models/toolkits';import { NodeProcess } from 'src/services/node-process';import {assertTranspiledTypeScriptIsValid,@@ -11,195 +11,23 @@ import {} from 'test/__utils__/typescript-compiler';import { ComposioCorePkgNotFound } from 'src/effects/find-composio-core-generated';import type { TestLiveInput } from 'test/__utils__/services/test-layer';+import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';describe('CLI: composio ts generate', () => {- const TOOLKIT_GMAIL = makeTestToolkit({- name: 'Gmail',- slug: 'gmail',- });- const TOOLKIT_SLACK = makeTestToolkit({- name: 'Slack',- slug: 'slack',- });-const appClientData = {- toolkits: [TOOLKIT_GMAIL, TOOLKIT_SLACK],- tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],- triggerTypesAsEnums: ['GMAIL_NEW_GMAIL_MESSAGE'],- triggerTypes: [+ toolkits: makeTestToolkits([{- config: {- properties: {- interval: {- default: 1,- description: 'Periodic Interval to Check for Updates & Send a Trigger in Minutes',- title: 'Interval',- type: 'number',- },- labelIds: {- default: 'INBOX',- description:- "Filter messages by a single label ID. Labels identify the status or category of messages. Supported labels include 'INBOX', 'SPAM', 'TRASH', 'UNREAD', 'STARRED', 'IMPORTANT', 'CATEGORY_PERSONAL', 'CATEGORY_SOCIAL', 'CATEGORY_PROMOTIONS', 'CATEGORY_UPDATES', and 'CATEGORY_FORUMS'. For complex label filtering, use the 'query' parameter instead.",- examples: ['INBOX', 'UNREAD', 'STARRED'],- title: 'Labelids',- type: 'string',- },- query: {- default: '',- description:- "Advanced Gmail search using the same syntax as Gmail's search box. Use 'AND' for messages that match all conditions, 'OR' for any condition. Search by sender (from:[email protected]), labels (label:inbox), status (is:unread), attachments (has:attachment), dates (after:2023/1/1), and more. If specified, this takes precedence over labelIds.",- examples: [- 'label:inbox OR label:sent',- 'from:[email protected] is:unread',- 'has:attachment after:2023/1/1',- 'is:important is:unread',- ],- title: 'Query',- type: 'string',- },- userId: {- default: 'me',- description: "The user's email address or 'me' for the authenticated user.",- examples: ['me'],- title: 'Userid',- type: 'string',- },- },- title: 'NewMessageConfig',- type: 'object',- },- description: 'Triggers when a new message is received in Gmail.',- instructions:- "\n **Instructions for Setting Up the Trigger:**\n\n - Ensure that the Gmail API is enabled for your Google account.\n - Provide the user ID (usually 'me' for the authenticated user).\n - Optionally, provide label IDs to filter messages.\n ",- name: 'New Gmail Message Received Trigger',- payload: {- properties: {- attachment_list: {- anyOf: [- {- items: {},- type: 'array',- },- {- type: 'null',- },- ],- default: null,- description: 'The list of attachments in the message',- title: 'Attachment List',- },- message_id: {- anyOf: [- {- type: 'string',- },- {- type: 'null',- },- ],- default: null,- description: 'The message ID of the message',- title: 'Message ID',- },- message_text: {- anyOf: [- {- type: 'string',- },- {- type: 'null',- },- ],- default: null,- description: 'The text of the message',- title: 'Message Text',- },- message_timestamp: {- anyOf: [- {- type: 'string',- },- {- type: 'null',- },- ],- default: null,- description: 'The timestamp of the message',- title: 'Message Timestamp',- },- payload: {- anyOf: [- {- type: 'object',- },- {- type: 'null',- },- ],- default: null,- description: 'The payload of the message',- title: 'Payload',- },- sender: {- anyOf: [- {- type: 'string',- },- {- type: 'null',- },- ],- default: null,- description: 'The sender of the message',- title: 'Sender',- },- subject: {- anyOf: [- {- type: 'string',- },- {- type: 'null',- },- ],- default: null,- description: 'The subject of the message',- title: 'Subject',- },- thread_id: {- anyOf: [- {- type: 'string',- },- {- type: 'null',- },- ],- default: null,- description: 'The thread ID of the message',- title: 'Thread ID',- },- to: {- anyOf: [- {- type: 'string',- },- {- type: 'null',- },- ],- default: null,- description: 'The recipient of the message',- title: 'To',- },- },- title: 'NewMessagePayload',- type: 'object',- },- slug: 'GMAIL_NEW_GMAIL_MESSAGE',- type: 'poll',+ name: 'Gmail',+ slug: 'gmail',+ },+ {+ name: 'Slack',+ slug: 'slack',},- ],+ ]),+ tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],+ triggerTypesAsEnums: ['GMAIL_NEW_GMAIL_MESSAGE'],+ triggerTypes: [TRIGGER_TYPE_GMAIL],} satisfies TestLiveInput['toolkitsData'];describe('[Given] valid fetched app data', () => {diff --git a/ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts b/ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.tsindex f82715daa..36dc14c04 100644--- a/ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts+++ b/ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts@@ -3,6 +3,7 @@ import { generatePythonToolkitSources } from 'src/generation/python/generate-tooimport { createToolkitIndex } from 'src/generation/create-toolkit-index';import { BANNER } from 'src/generation/constants';import { makeTestToolkits } from 'test/__utils__/models/toolkits';+import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';describe('generatePythonToolkitSources', () => {it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array', () => {@@ -67,7 +68,7 @@ describe('generatePythonToolkitSources', () => {const index = createToolkitIndex({toolkits,tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],- triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],+ triggerTypes: [TRIGGER_TYPE_GMAIL],});const sources = generatePythonToolkitSources(BANNER)(index);diff --git a/ts/packages/cli/test/src/generation/toolkit-index.test.ts b/ts/packages/cli/test/src/generation/toolkit-index.test.tsindex ceb55a047..e3faac078 100644--- a/ts/packages/cli/test/src/generation/toolkit-index.test.ts+++ b/ts/packages/cli/test/src/generation/toolkit-index.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from 'vitest';import { createToolkitIndex } from 'src/generation/create-toolkit-index';import { makeTestToolkits } from 'test/__utils__/models/toolkits';+import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';describe('createToolkitIndex', () => {it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty index', () => {@@ -58,7 +59,7 @@ describe('createToolkitIndex', () => {]);const tools = ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'];- const triggerTypes = ['GMAIL_NEW_GMAIL_MESSAGE'];+ const triggerTypes = [TRIGGER_TYPE_GMAIL];const index = createToolkitIndex({toolkits,diff --git a/ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts b/ts/packages/cli/test/src/generation/typescript/generate-index-source.test.tsindex 0256bb4c5..0823f1d36 100644--- a/ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts+++ b/ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts@@ -6,6 +6,7 @@ import {import { createToolkitIndex } from 'src/generation/create-toolkit-index';import { makeTestToolkits } from 'test/__utils__/models/toolkits';import { assertTypeScriptIsValid } from 'test/__utils__/typescript-compiler';+import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';describe('generateTypeScriptToolkitSources', () => {describe('with a single emitted file', () => {@@ -116,7 +117,7 @@ describe('generateTypeScriptToolkitSources', () => {const index = createToolkitIndex({toolkits,tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],- triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],+ triggerTypes: [TRIGGER_TYPE_GMAIL],});const source = generateIndexSource(params)(index);@@ -271,7 +272,7 @@ describe('generateTypeScriptToolkitSources', () => {const index = createToolkitIndex({toolkits,tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],- triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],+ triggerTypes: [TRIGGER_TYPE_GMAIL],});const source = generateIndexSource(params)(index);diff --git a/ts/packages/cli/test/src/generation/typescript/generate-toolkit-source.test.ts b/ts/packages/cli/test/src/generation/typescript/generate-toolkit-source.test.tsindex 02a478ddb..85915d42c 100644--- a/ts/packages/cli/test/src/generation/typescript/generate-toolkit-source.test.ts+++ b/ts/packages/cli/test/src/generation/typescript/generate-toolkit-source.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';import { generateTypeScriptToolkitSources } from 'src/generation/typescript/generate-toolkit-sources';import { createToolkitIndex } from 'src/generation/create-toolkit-index';import { makeTestToolkits } from 'test/__utils__/models/toolkits';+import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';describe('generateTypeScriptToolkitSources', () => {describe('with a single emitted file', () => {@@ -66,7 +67,7 @@ describe('generateTypeScriptToolkitSources', () => {const index = createToolkitIndex({toolkits,tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],- triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],+ triggerTypes: [TRIGGER_TYPE_GMAIL],});const sources = generateTypeScriptToolkitSources(banner)(index);diff --git a/ts/packages/cli/test/src/generation/typescript/generate.test.ts b/ts/packages/cli/test/src/generation/typescript/generate.test.tsindex 43abb103c..c0fd59931 100644--- a/ts/packages/cli/test/src/generation/typescript/generate.test.ts+++ b/ts/packages/cli/test/src/generation/typescript/generate.test.ts@@ -4,6 +4,7 @@ import { generateTypeScriptSources } from 'src/generation/typescript/generate';import { makeTestToolkits } from 'test/__utils__/models/toolkits';import path from 'path';import { assertTypeScriptIsValid } from 'test/__utils__/typescript-compiler';+import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';describe('generateTypeScriptSources', () => {describe('with multiple emitted files', () => {@@ -143,7 +144,7 @@ describe('generateTypeScriptSources', () => {const index = createToolkitIndex({toolkits,tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],- triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],+ triggerTypes: [TRIGGER_TYPE_GMAIL],});const sources = generateTypeScriptSources(params)(index);