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): dump trigger types payload in "ts generate" and "py generate" output
jkomyno5b4697519821
diff --git a/ts/packages/cli/src/generation/create-toolkit-index.ts b/ts/packages/cli/src/generation/create-toolkit-index.tsindex ac4d53e41..628712661 100644--- a/ts/packages/cli/src/generation/create-toolkit-index.ts+++ b/ts/packages/cli/src/generation/create-toolkit-index.ts@@ -18,7 +18,7 @@ interface CreateToolkitIndexInput {export type ToolkitIndexData = Simplify<{slug: string;tools: Record<`${ToolkitName}_${string}`, string>;- triggerTypes: Record<`${ToolkitName}_${string}`, string>;+ triggerTypes: Record<`${ToolkitName}_${string}`, TriggerType>;}>;export type ToolkitIndex = Record<ToolkitName, ToolkitIndexData>;@@ -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.slug), triggerType.slug] as const+ triggerType => [stripPrefix(triggerType.slug), triggerType] as const);return [@@ -59,8 +59,7 @@ type GroupByToolkitOutput<T extends ToolkitName> = [{toolkit: Toolkit;tools: Array<`${Uppercase<T>}_${string}`>;- // triggerTypes: Array<TriggerTypeWithUppercaseSlug<T>>;- triggerTypes: TriggerTypes;+ triggerTypes: Array<TriggerTypeWithUppercaseSlug<T>>;},];@@ -79,10 +78,9 @@ const groupByToolkit ={toolkit,tools: tools.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>>,+ triggerTypes: triggerTypes.filter(triggerType =>+ startsWith(`${toolkitName}_`)(triggerType.slug)+ ) as Array<TriggerTypeWithUppercaseSlug<T & ToolkitName>>,},];};diff --git a/ts/packages/cli/src/generation/python/generate-toolkit-sources.ts b/ts/packages/cli/src/generation/python/generate-toolkit-sources.tsindex 2101d0201..667c4d782 100644--- a/ts/packages/cli/src/generation/python/generate-toolkit-sources.ts+++ b/ts/packages/cli/src/generation/python/generate-toolkit-sources.ts@@ -14,7 +14,20 @@* DELETE_CHANNEL_SUBSCRIPTION = "ABLY_DELETE_CHANNEL_SUBSCRIPTION"** class triggers:- * pass+ * NEW_GMAIL_MESSAGE = {+ * config: {+ * # ...+ * },+ * 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: {+ * # ...+ * },+ * slug: 'GMAIL_NEW_GMAIL_MESSAGE',+ * type: 'poll',+ * }* ```*/@@ -22,6 +35,68 @@ import { pipe, Record } from 'effect';import type { ToolkitName } from 'src/models/toolkits';import type { ToolkitIndex, ToolkitIndexData } from 'src/generation/create-toolkit-index';import type { SourceFile } from 'src/generation/types';+import type { TriggerType } from 'src/models/trigger-types';++/**+ * Converts a JavaScript value to Python dictionary/literal syntax+ */+function jsToPython(value: unknown, indent = 0): string {+ const spacePad = ' '.repeat(indent);++ if (value === null) {+ return 'None';+ }++ if (value === undefined) {+ return 'None';+ }++ if (typeof value === 'string') {+ // Escape quotes and return as Python string+ return JSON.stringify(value);+ }++ if (typeof value === 'number') {+ return value.toString();+ }++ if (typeof value === 'boolean') {+ return value ? 'True' : 'False';+ }++ if (Array.isArray(value)) {+ if (value.length === 0) {+ return '[]';+ }+ const items = value.map(item => jsToPython(item, indent + 2));+ return `[${items.join(', ')}]`;+ }++ if (typeof value === 'object' && value !== null) {+ const entries = Object.entries(value);+ if (entries.length === 0) {+ return '{}';+ }++ const formattedEntries = entries.map(([key, val]) => {+ const formattedKey = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key) ? key : JSON.stringify(key);+ const formattedValue = jsToPython(val, indent + 2);+ return `${spacePad} ${formattedKey}: ${formattedValue}`;+ });++ return `{\n${formattedEntries.join(',\n')}\n${spacePad}}`;+ }++ // Fallback for unknown types+ return JSON.stringify(value);+}++/**+ * Generates Python dictionary syntax for a trigger type object+ */+function generateTriggerTypePythonDict(triggerType: TriggerType, indent = 0): string {+ return jsToPython(triggerType, indent);+}/*** Generates a list of Python source files that should be written to disk by the caller.@@ -59,7 +134,10 @@ function generatePythonToolkitSource(banner: string) {if (Record.size(toolkit.triggerTypes) > 0) {return Object.entries(toolkit.triggerTypes)- .map(([triggerName, triggerValue]) => `${spacePad}${triggerName} = "${triggerValue}"`)+ .map(([triggerName, triggerValue]) => {+ const pythonDict = generateTriggerTypePythonDict(triggerValue, spacing);+ return `${spacePad}${triggerName} = ${pythonDict}`;+ }).join('\n');}diff --git a/ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts b/ts/packages/cli/src/generation/typescript/generate-toolkit-sources.tsindex adddf619c..c361966db 100644--- a/ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts+++ b/ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts@@ -28,6 +28,70 @@ import { pipe, Record } from 'effect';import type { ToolkitName } from 'src/models/toolkits';import type { ToolkitIndex, ToolkitIndexData } from 'src/generation/create-toolkit-index';import type { SourceFile } from 'src/generation/types';+import type { TriggerType } from 'src/models/trigger-types';++function jsValueToTsValue(value: unknown): ts.ValueBuilder {+ if (value === null) {+ return ts.namedValue('null');+ }++ if (value === undefined) {+ return ts.namedValue('undefined');+ }++ if (typeof value === 'string') {+ return ts.stringLiteral(value).asValue();+ }++ if (typeof value === 'number') {+ return ts.namedValue(value.toString());+ }++ if (typeof value === 'boolean') {+ return ts.namedValue(value.toString());+ }++ if (Array.isArray(value)) {+ const array = new ts.ArrayValue();+ for (const item of value) {+ array.add(jsValueToTsValue(item));+ }+ return array;+ }++ if (typeof value === 'object' && value !== null) {+ const objectValue = ts.objectValue();+ for (const [key, val] of Object.entries(value)) {+ objectValue.add(ts.propertyValue(key, jsValueToTsValue(val)));+ }+ return objectValue;+ }++ // Fallback for unknown types+ return ts.stringLiteral(JSON.stringify(value)).asValue();+}++/**+ * Generates a TypeScript object literal for a trigger type+ */+function generateTriggerTypeObjectValue(triggerType: TriggerType): ts.ValueBuilder {+ return ts+ .objectValue()+ .add(ts.propertyValue('slug', ts.stringLiteral(triggerType.slug).asValue()))+ .add(ts.propertyValue('name', ts.stringLiteral(triggerType.name).asValue()))+ .add(ts.propertyValue('description', ts.stringLiteral(triggerType.description).asValue()))+ .add(+ ts.propertyValue(+ 'instructions',+ triggerType.instructions+ ? ts.stringLiteral(triggerType.instructions).asValue()+ : ts.namedValue('undefined')+ )+ )+ .add(ts.propertyValue('config', jsValueToTsValue(triggerType.config)))+ .add(ts.propertyValue('payload', jsValueToTsValue(triggerType.payload)))+ .add(ts.propertyValue('type', ts.stringLiteral(triggerType.type).asValue()));+}/*** Generates a list of TypeScript source files that should be written to disk by the caller.@@ -77,7 +141,7 @@ function generateTypeScriptToolkitSource(_banner: string) {.objectValue().addMultiple(Object.entries(triggerTypes).map(([triggerTypeSlug, triggerType]) =>- ts.propertyValue(triggerTypeSlug, ts.stringLiteral(triggerType).asValue())+ ts.propertyValue(triggerTypeSlug, generateTriggerTypeObjectValue(triggerType)))))diff --git a/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts b/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.tsindex f129d0851..e9b0343ee 100644--- a/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts@@ -1,11 +1,12 @@import path from 'node:path';-import { describe, expect, layer, vi } from '@effect/vitest';+import { describe, expect, layer } from '@effect/vitest';import { Effect } from 'effect';import { FileSystem } from '@effect/platform';import { cli, TestLive } from 'test/__utils__';import { makeTestToolkits } from 'test/__utils__/models/toolkits';import { NodeProcess } from 'src/services/node-process';import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';+import { TestLiveInput } from 'test/__utils__/services/test-layer';describe('CLI: composio py generate', () => {const appClientData = {@@ -20,8 +21,9 @@ describe('CLI: composio py generate', () => {},]),tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],+ triggerTypesAsEnums: ['GMAIL_NEW_GMAIL_MESSAGE'],triggerTypes: [TRIGGER_TYPE_GMAIL],- };+ } satisfies TestLiveInput['toolkitsData'];layer(TestLive({@@ -106,22 +108,158 @@ describe('CLI: composio py generate', () => {const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.py'));expect(gmailSourceCode).toMatchInlineSnapshot(`- "# Auto-generated by Composio CLI. Do not modify manually..+ "# Auto-generated by Composio CLI. Do not modify manually..- class GMAIL:- """Map of Composio's GMAIL toolkit."""+ class GMAIL:+ """Map of Composio's GMAIL toolkit."""- slug: str = "gmail"+ slug: str = "gmail"- class tools:- CREATE_EMAIL_DRAFT = "GMAIL_CREATE_EMAIL_DRAFT"- DELETE_MESSAGE = "GMAIL_DELETE_MESSAGE"- FETCH_EMAILS = "GMAIL_FETCH_EMAILS"+ class tools:+ CREATE_EMAIL_DRAFT = "GMAIL_CREATE_EMAIL_DRAFT"+ DELETE_MESSAGE = "GMAIL_DELETE_MESSAGE"+ FETCH_EMAILS = "GMAIL_FETCH_EMAILS"- class triggers:- NEW_GMAIL_MESSAGE = "GMAIL_NEW_GMAIL_MESSAGE"- "- `);+ class triggers:+ NEW_GMAIL_MESSAGE = {+ 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: None,+ description: "The list of attachments in the message",+ title: "Attachment List"+ },+ message_id: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The message ID of the message",+ title: "Message ID"+ },+ message_text: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The text of the message",+ title: "Message Text"+ },+ message_timestamp: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The timestamp of the message",+ title: "Message Timestamp"+ },+ payload: {+ anyOf: [{+ type: "object"+ }, {+ type: "null"+ }],+ default: None,+ description: "The payload of the message",+ title: "Payload"+ },+ sender: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The sender of the message",+ title: "Sender"+ },+ subject: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The subject of the message",+ title: "Subject"+ },+ thread_id: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The thread ID of the message",+ title: "Thread ID"+ },+ to: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The recipient of the message",+ title: "To"+ }+ },+ title: "NewMessagePayload",+ type: "object"+ },+ slug: "GMAIL_NEW_GMAIL_MESSAGE",+ type: "poll"+ }+ "+ `);expect(slackSourceCode).toMatchInlineSnapshot(`"# Auto-generated by Composio CLI. Do not modify manually..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 aeb8e7830..abf5c7697 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@@ -61,22 +61,158 @@ describe('CLI: composio ts generate', () => {const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));expect(gmailSourceCode).toMatchInlineSnapshot(`- "/**- * Map of Composio's GMAIL toolkit.- */- export const GMAIL = {- slug: "gmail",- tools: {- CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",- },- triggerTypes: {- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",- },- }- "- `);+ "/**+ * Map of Composio's GMAIL toolkit.+ */+ export const GMAIL = {+ slug: "gmail",+ tools: {+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",+ },+ triggerTypes: {+ NEW_GMAIL_MESSAGE: {+ slug: "GMAIL_NEW_GMAIL_MESSAGE",+ name: "New Gmail Message Received Trigger",+ 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 ",+ 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",+ },+ 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",+ },+ type: "poll",+ },+ },+ }+ "+ `);expect(slackSourceCode).toMatchInlineSnapshot(`"/*** Map of Composio's SLACK toolkit.@@ -170,22 +306,158 @@ describe('CLI: composio ts generate', () => {const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));expect(gmailSourceCode).toMatchInlineSnapshot(`- "/**- * Map of Composio's GMAIL toolkit.- */- export const GMAIL = {- slug: "gmail",- tools: {- CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",- },- triggerTypes: {- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",- },- }- "- `);+ "/**+ * Map of Composio's GMAIL toolkit.+ */+ export const GMAIL = {+ slug: "gmail",+ tools: {+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",+ },+ triggerTypes: {+ NEW_GMAIL_MESSAGE: {+ slug: "GMAIL_NEW_GMAIL_MESSAGE",+ name: "New Gmail Message Received Trigger",+ 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 ",+ 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",+ },+ 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",+ },+ type: "poll",+ },+ },+ }+ "+ `);expect(slackSourceCode).toMatchInlineSnapshot(`"/*** Map of Composio's SLACK toolkit.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 36dc14c04..89c73f550 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@@ -90,7 +90,143 @@ describe('generatePythonToolkitSources', () => {FETCH_EMAILS = "GMAIL_FETCH_EMAILS"class triggers:- NEW_GMAIL_MESSAGE = "GMAIL_NEW_GMAIL_MESSAGE"+ NEW_GMAIL_MESSAGE = {+ 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: None,+ description: "The list of attachments in the message",+ title: "Attachment List"+ },+ message_id: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The message ID of the message",+ title: "Message ID"+ },+ message_text: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The text of the message",+ title: "Message Text"+ },+ message_timestamp: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The timestamp of the message",+ title: "Message Timestamp"+ },+ payload: {+ anyOf: [{+ type: "object"+ }, {+ type: "null"+ }],+ default: None,+ description: "The payload of the message",+ title: "Payload"+ },+ sender: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The sender of the message",+ title: "Sender"+ },+ subject: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The subject of the message",+ title: "Subject"+ },+ thread_id: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The thread ID of the message",+ title: "Thread ID"+ },+ to: {+ anyOf: [{+ type: "string"+ }, {+ type: "null"+ }],+ default: None,+ description: "The recipient of the message",+ title: "To"+ }+ },+ title: "NewMessagePayload",+ type: "object"+ },+ slug: "GMAIL_NEW_GMAIL_MESSAGE",+ type: "poll"+ }"`);diff --git a/ts/packages/cli/test/src/generation/toolkit-index.test.ts b/ts/packages/cli/test/src/generation/toolkit-index.test.tsindex e3faac078..adb4f2b3a 100644--- a/ts/packages/cli/test/src/generation/toolkit-index.test.ts+++ b/ts/packages/cli/test/src/generation/toolkit-index.test.ts@@ -76,7 +76,7 @@ describe('createToolkitIndex', () => {FETCH_EMAILS: 'GMAIL_FETCH_EMAILS',},triggerTypes: {- NEW_GMAIL_MESSAGE: 'GMAIL_NEW_GMAIL_MESSAGE',+ NEW_GMAIL_MESSAGE: TRIGGER_TYPE_GMAIL,},},SLACK: {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 85915d42c..1f0ad18b7 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@@ -87,7 +87,143 @@ describe('generateTypeScriptToolkitSources', () => {FETCH_EMAILS: "GMAIL_FETCH_EMAILS",},triggerTypes: {- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",+ NEW_GMAIL_MESSAGE: {+ slug: "GMAIL_NEW_GMAIL_MESSAGE",+ name: "New Gmail Message Received Trigger",+ 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 ",+ 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",+ },+ 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",+ },+ type: "poll",+ },},}"diff --git a/ts/packages/ts-builders/src/ArrayValue.ts b/ts/packages/ts-builders/src/ArrayValue.tsnew file mode 100644index 000000000..468c34322--- /dev/null+++ b/ts/packages/ts-builders/src/ArrayValue.ts@@ -0,0 +1,15 @@+import { ValueBuilder } from './ValueBuilder';+import type { Writer } from './Writer';++export class ArrayValue extends ValueBuilder {+ private items: ValueBuilder[] = [];++ add(item: ValueBuilder): this {+ this.items.push(item);+ return this;+ }++ write(writer: Writer): void {+ writer.write('[').writeJoined(', ', this.items).write(']');+ }+}diff --git a/ts/packages/ts-builders/src/index.ts b/ts/packages/ts-builders/src/index.tsindex e63abc255..92e4c4143 100644--- a/ts/packages/ts-builders/src/index.ts+++ b/ts/packages/ts-builders/src/index.ts@@ -1,5 +1,6 @@export * from './AnyDeclarationBuilder';export * from './ArraySpread';+export * from './ArrayValue';export * from './ArrayType';export * from './BasicBuilder';export * from './Class';