Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 22:00 UTC
feat(cli): dump trigger types payload in "ts generate" and "py generate" output
jkomyno committed
Jul 29, 2025 at 01:11 UTC
5b4697519821fd431c65cb9698f19895fa373634
10 files changed
+898
-60
ts/packages/cli/src/generation/create-toolkit-index.ts
+6
-8
@@ -18,7 +18,7 @@ interface CreateToolkitIndexInput {
18
export type ToolkitIndexData = Simplify<{
19
slug: string;
20
tools: Record<`${ToolkitName}_${string}`, string>;
21
- triggerTypes: Record<`${ToolkitName}_${string}`, string>;
21
+ triggerTypes: Record<`${ToolkitName}_${string}`, TriggerType>;
22
}>;
23
24
export type ToolkitIndex = Record<ToolkitName, ToolkitIndexData>;
@@ -39,7 +39,7 @@ export function createToolkitIndex(input: CreateToolkitIndexInput): Simplify<Too
39
const { slug } = value.toolkit;
40
const tools = value.tools.map(tool => [stripPrefix(tool), tool] as const);
41
const triggerTypes = value.triggerTypes.map(
42
- triggerType => [stripPrefix(triggerType.slug), triggerType.slug] as const
42
+ triggerType => [stripPrefix(triggerType.slug), triggerType] as const
43
);
44
45
return [
@@ -59,8 +59,7 @@ type GroupByToolkitOutput<T extends ToolkitName> = [
59
{
60
toolkit: Toolkit;
61
tools: Array<`${Uppercase<T>}_${string}`>;
62
- // triggerTypes: Array<TriggerTypeWithUppercaseSlug<T>>;
63
- triggerTypes: TriggerTypes;
62
+ triggerTypes: Array<TriggerTypeWithUppercaseSlug<T>>;
63
},
64
];
65
@@ -79,10 +78,9 @@ const groupByToolkit =
78
{
79
toolkit,
80
tools: tools.filter(startsWith(`${toolkitName}_`)),
82
- triggerTypes: triggerTypes.filter(triggerType => {
83
- console.log('Checking trigger type slug', triggerType?.slug);
84
- return startsWith(`${toolkitName}_`)(triggerType.slug);
85
- }), // as Array<TriggerTypeWithUppercaseSlug<T & ToolkitName>>,
81
+ triggerTypes: triggerTypes.filter(triggerType =>
82
+ startsWith(`${toolkitName}_`)(triggerType.slug)
83
+ ) as Array<TriggerTypeWithUppercaseSlug<T & ToolkitName>>,
84
},
85
];
86
};
ts/packages/cli/src/generation/python/generate-toolkit-sources.ts
+80
-2
@@ -14,7 +14,20 @@
14
* DELETE_CHANNEL_SUBSCRIPTION = "ABLY_DELETE_CHANNEL_SUBSCRIPTION"
15
*
16
* class triggers:
17
- * pass
17
+ * NEW_GMAIL_MESSAGE = {
18
+ * config: {
19
+ * # ...
20
+ * },
21
+ * description: "Triggers when a new message is received in Gmail.",
22
+ * instructions:
23
+ * "\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 ",
24
+ * name: "New Gmail Message Received Trigger",
25
+ * payload: {
26
+ * # ...
27
+ * },
28
+ * slug: 'GMAIL_NEW_GMAIL_MESSAGE',
29
+ * type: 'poll',
30
+ * }
31
* ```
32
*/
33
@@ -22,6 +35,68 @@ import { pipe, Record } from 'effect';
35
import type { ToolkitName } from 'src/models/toolkits';
36
import type { ToolkitIndex, ToolkitIndexData } from 'src/generation/create-toolkit-index';
37
import type { SourceFile } from 'src/generation/types';
38
+import type { TriggerType } from 'src/models/trigger-types';
39
+
40
+/**
41
+ * Converts a JavaScript value to Python dictionary/literal syntax
42
+ */
43
+function jsToPython(value: unknown, indent = 0): string {
44
+ const spacePad = ' '.repeat(indent);
45
+
46
+ if (value === null) {
47
+ return 'None';
48
+ }
49
+
50
+ if (value === undefined) {
51
+ return 'None';
52
+ }
53
+
54
+ if (typeof value === 'string') {
55
+ // Escape quotes and return as Python string
56
+ return JSON.stringify(value);
57
+ }
58
+
59
+ if (typeof value === 'number') {
60
+ return value.toString();
61
+ }
62
+
63
+ if (typeof value === 'boolean') {
64
+ return value ? 'True' : 'False';
65
+ }
66
+
67
+ if (Array.isArray(value)) {
68
+ if (value.length === 0) {
69
+ return '[]';
70
+ }
71
+ const items = value.map(item => jsToPython(item, indent + 2));
72
+ return `[${items.join(', ')}]`;
73
+ }
74
+
75
+ if (typeof value === 'object' && value !== null) {
76
+ const entries = Object.entries(value);
77
+ if (entries.length === 0) {
78
+ return '{}';
79
+ }
80
+
81
+ const formattedEntries = entries.map(([key, val]) => {
82
+ const formattedKey = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key) ? key : JSON.stringify(key);
83
+ const formattedValue = jsToPython(val, indent + 2);
84
+ return `${spacePad} ${formattedKey}: ${formattedValue}`;
85
+ });
86
+
87
+ return `{\n${formattedEntries.join(',\n')}\n${spacePad}}`;
88
+ }
89
+
90
+ // Fallback for unknown types
91
+ return JSON.stringify(value);
92
+}
93
+
94
+/**
95
+ * Generates Python dictionary syntax for a trigger type object
96
+ */
97
+function generateTriggerTypePythonDict(triggerType: TriggerType, indent = 0): string {
98
+ return jsToPython(triggerType, indent);
99
+}
100
101
/**
102
* Generates a list of Python source files that should be written to disk by the caller.
@@ -59,7 +134,10 @@ function generatePythonToolkitSource(banner: string) {
134
135
if (Record.size(toolkit.triggerTypes) > 0) {
136
return Object.entries(toolkit.triggerTypes)
62
- .map(([triggerName, triggerValue]) => `${spacePad}${triggerName} = "${triggerValue}"`)
137
+ .map(([triggerName, triggerValue]) => {
138
+ const pythonDict = generateTriggerTypePythonDict(triggerValue, spacing);
139
+ return `${spacePad}${triggerName} = ${pythonDict}`;
140
+ })
141
.join('\n');
142
}
143
ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts
+65
-1
@@ -28,6 +28,70 @@ import { pipe, Record } from 'effect';
28
import type { ToolkitName } from 'src/models/toolkits';
29
import type { ToolkitIndex, ToolkitIndexData } from 'src/generation/create-toolkit-index';
30
import type { SourceFile } from 'src/generation/types';
31
+import type { TriggerType } from 'src/models/trigger-types';
32
+
33
+function jsValueToTsValue(value: unknown): ts.ValueBuilder {
34
+ if (value === null) {
35
+ return ts.namedValue('null');
36
+ }
37
+
38
+ if (value === undefined) {
39
+ return ts.namedValue('undefined');
40
+ }
41
+
42
+ if (typeof value === 'string') {
43
+ return ts.stringLiteral(value).asValue();
44
+ }
45
+
46
+ if (typeof value === 'number') {
47
+ return ts.namedValue(value.toString());
48
+ }
49
+
50
+ if (typeof value === 'boolean') {
51
+ return ts.namedValue(value.toString());
52
+ }
53
+
54
+ if (Array.isArray(value)) {
55
+ const array = new ts.ArrayValue();
56
+ for (const item of value) {
57
+ array.add(jsValueToTsValue(item));
58
+ }
59
+ return array;
60
+ }
61
+
62
+ if (typeof value === 'object' && value !== null) {
63
+ const objectValue = ts.objectValue();
64
+ for (const [key, val] of Object.entries(value)) {
65
+ objectValue.add(ts.propertyValue(key, jsValueToTsValue(val)));
66
+ }
67
+ return objectValue;
68
+ }
69
+
70
+ // Fallback for unknown types
71
+ return ts.stringLiteral(JSON.stringify(value)).asValue();
72
+}
73
+
74
+/**
75
+ * Generates a TypeScript object literal for a trigger type
76
+ */
77
+function generateTriggerTypeObjectValue(triggerType: TriggerType): ts.ValueBuilder {
78
+ return ts
79
+ .objectValue()
80
+ .add(ts.propertyValue('slug', ts.stringLiteral(triggerType.slug).asValue()))
81
+ .add(ts.propertyValue('name', ts.stringLiteral(triggerType.name).asValue()))
82
+ .add(ts.propertyValue('description', ts.stringLiteral(triggerType.description).asValue()))
83
+ .add(
84
+ ts.propertyValue(
85
+ 'instructions',
86
+ triggerType.instructions
87
+ ? ts.stringLiteral(triggerType.instructions).asValue()
88
+ : ts.namedValue('undefined')
89
+ )
90
+ )
91
+ .add(ts.propertyValue('config', jsValueToTsValue(triggerType.config)))
92
+ .add(ts.propertyValue('payload', jsValueToTsValue(triggerType.payload)))
93
+ .add(ts.propertyValue('type', ts.stringLiteral(triggerType.type).asValue()));
94
+}
95
96
/**
97
* Generates a list of TypeScript source files that should be written to disk by the caller.
@@ -77,7 +141,7 @@ function generateTypeScriptToolkitSource(_banner: string) {
141
.objectValue()
142
.addMultiple(
143
Object.entries(triggerTypes).map(([triggerTypeSlug, triggerType]) =>
80
- ts.propertyValue(triggerTypeSlug, ts.stringLiteral(triggerType).asValue())
144
+ ts.propertyValue(triggerTypeSlug, generateTriggerTypeObjectValue(triggerType))
145
)
146
)
147
)
ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts
+152
-14
@@ -1,11 +1,12 @@
1
import path from 'node:path';
2
-import { describe, expect, layer, vi } from '@effect/vitest';
2
+import { describe, expect, layer } from '@effect/vitest';
3
import { Effect } from 'effect';
4
import { FileSystem } from '@effect/platform';
5
import { cli, TestLive } from 'test/__utils__';
6
import { makeTestToolkits } from 'test/__utils__/models/toolkits';
7
import { NodeProcess } from 'src/services/node-process';
8
import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';
9
+import { TestLiveInput } from 'test/__utils__/services/test-layer';
10
11
describe('CLI: composio py generate', () => {
12
const appClientData = {
@@ -20,8 +21,9 @@ describe('CLI: composio py generate', () => {
21
},
22
]),
23
tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
24
+ triggerTypesAsEnums: ['GMAIL_NEW_GMAIL_MESSAGE'],
25
triggerTypes: [TRIGGER_TYPE_GMAIL],
24
- };
26
+ } satisfies TestLiveInput['toolkitsData'];
27
28
layer(
29
TestLive({
@@ -106,22 +108,158 @@ describe('CLI: composio py generate', () => {
108
const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.py'));
109
110
expect(gmailSourceCode).toMatchInlineSnapshot(`
109
- "# Auto-generated by Composio CLI. Do not modify manually..
111
+ "# Auto-generated by Composio CLI. Do not modify manually..
112
111
- class GMAIL:
112
- """Map of Composio's GMAIL toolkit."""
113
+ class GMAIL:
114
+ """Map of Composio's GMAIL toolkit."""
115
114
- slug: str = "gmail"
116
+ slug: str = "gmail"
117
116
- class tools:
117
- CREATE_EMAIL_DRAFT = "GMAIL_CREATE_EMAIL_DRAFT"
118
- DELETE_MESSAGE = "GMAIL_DELETE_MESSAGE"
119
- FETCH_EMAILS = "GMAIL_FETCH_EMAILS"
118
+ class tools:
119
+ CREATE_EMAIL_DRAFT = "GMAIL_CREATE_EMAIL_DRAFT"
120
+ DELETE_MESSAGE = "GMAIL_DELETE_MESSAGE"
121
+ FETCH_EMAILS = "GMAIL_FETCH_EMAILS"
122
121
- class triggers:
122
- NEW_GMAIL_MESSAGE = "GMAIL_NEW_GMAIL_MESSAGE"
123
- "
124
- `);
123
+ class triggers:
124
+ NEW_GMAIL_MESSAGE = {
125
+ config: {
126
+ properties: {
127
+ interval: {
128
+ default: 1,
129
+ description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
130
+ title: "Interval",
131
+ type: "number"
132
+ },
133
+ labelIds: {
134
+ default: "INBOX",
135
+ 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.",
136
+ examples: ["INBOX", "UNREAD", "STARRED"],
137
+ title: "Labelids",
138
+ type: "string"
139
+ },
140
+ query: {
141
+ default: "",
142
+ 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@domain.com), labels (label:inbox), status (is:unread), attachments (has:attachment), dates (after:2023/1/1), and more. If specified, this takes precedence over labelIds.",
143
+ examples: ["label:inbox OR label:sent", "from:example@gmail.com is:unread", "has:attachment after:2023/1/1", "is:important is:unread"],
144
+ title: "Query",
145
+ type: "string"
146
+ },
147
+ userId: {
148
+ default: "me",
149
+ description: "The user's email address or 'me' for the authenticated user.",
150
+ examples: ["me"],
151
+ title: "Userid",
152
+ type: "string"
153
+ }
154
+ },
155
+ title: "NewMessageConfig",
156
+ type: "object"
157
+ },
158
+ description: "Triggers when a new message is received in Gmail.",
159
+ 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 ",
160
+ name: "New Gmail Message Received Trigger",
161
+ payload: {
162
+ properties: {
163
+ attachment_list: {
164
+ anyOf: [{
165
+ items: {},
166
+ type: "array"
167
+ }, {
168
+ type: "null"
169
+ }],
170
+ default: None,
171
+ description: "The list of attachments in the message",
172
+ title: "Attachment List"
173
+ },
174
+ message_id: {
175
+ anyOf: [{
176
+ type: "string"
177
+ }, {
178
+ type: "null"
179
+ }],
180
+ default: None,
181
+ description: "The message ID of the message",
182
+ title: "Message ID"
183
+ },
184
+ message_text: {
185
+ anyOf: [{
186
+ type: "string"
187
+ }, {
188
+ type: "null"
189
+ }],
190
+ default: None,
191
+ description: "The text of the message",
192
+ title: "Message Text"
193
+ },
194
+ message_timestamp: {
195
+ anyOf: [{
196
+ type: "string"
197
+ }, {
198
+ type: "null"
199
+ }],
200
+ default: None,
201
+ description: "The timestamp of the message",
202
+ title: "Message Timestamp"
203
+ },
204
+ payload: {
205
+ anyOf: [{
206
+ type: "object"
207
+ }, {
208
+ type: "null"
209
+ }],
210
+ default: None,
211
+ description: "The payload of the message",
212
+ title: "Payload"
213
+ },
214
+ sender: {
215
+ anyOf: [{
216
+ type: "string"
217
+ }, {
218
+ type: "null"
219
+ }],
220
+ default: None,
221
+ description: "The sender of the message",
222
+ title: "Sender"
223
+ },
224
+ subject: {
225
+ anyOf: [{
226
+ type: "string"
227
+ }, {
228
+ type: "null"
229
+ }],
230
+ default: None,
231
+ description: "The subject of the message",
232
+ title: "Subject"
233
+ },
234
+ thread_id: {
235
+ anyOf: [{
236
+ type: "string"
237
+ }, {
238
+ type: "null"
239
+ }],
240
+ default: None,
241
+ description: "The thread ID of the message",
242
+ title: "Thread ID"
243
+ },
244
+ to: {
245
+ anyOf: [{
246
+ type: "string"
247
+ }, {
248
+ type: "null"
249
+ }],
250
+ default: None,
251
+ description: "The recipient of the message",
252
+ title: "To"
253
+ }
254
+ },
255
+ title: "NewMessagePayload",
256
+ type: "object"
257
+ },
258
+ slug: "GMAIL_NEW_GMAIL_MESSAGE",
259
+ type: "poll"
260
+ }
261
+ "
262
+ `);
263
expect(slackSourceCode).toMatchInlineSnapshot(`
264
"# Auto-generated by Composio CLI. Do not modify manually..
265
ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
+304
-32
@@ -61,22 +61,158 @@ describe('CLI: composio ts generate', () => {
61
const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
62
63
expect(gmailSourceCode).toMatchInlineSnapshot(`
64
- "/**
65
- * Map of Composio's GMAIL toolkit.
66
- */
67
- export const GMAIL = {
68
- slug: "gmail",
69
- tools: {
70
- CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
71
- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
72
- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
73
- },
74
- triggerTypes: {
75
- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
76
- },
77
- }
78
- "
79
- `);
64
+ "/**
65
+ * Map of Composio's GMAIL toolkit.
66
+ */
67
+ export const GMAIL = {
68
+ slug: "gmail",
69
+ tools: {
70
+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
71
+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
72
+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
73
+ },
74
+ triggerTypes: {
75
+ NEW_GMAIL_MESSAGE: {
76
+ slug: "GMAIL_NEW_GMAIL_MESSAGE",
77
+ name: "New Gmail Message Received Trigger",
78
+ description: "Triggers when a new message is received in Gmail.",
79
+ 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 ",
80
+ config: {
81
+ properties: {
82
+ interval: {
83
+ default: 1,
84
+ description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
85
+ title: "Interval",
86
+ type: "number",
87
+ },
88
+ labelIds: {
89
+ default: "INBOX",
90
+ 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.",
91
+ examples: ["INBOX", "UNREAD", "STARRED"],
92
+ title: "Labelids",
93
+ type: "string",
94
+ },
95
+ query: {
96
+ default: "",
97
+ 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@domain.com), labels (label:inbox), status (is:unread), attachments (has:attachment), dates (after:2023/1/1), and more. If specified, this takes precedence over labelIds.",
98
+ examples: ["label:inbox OR label:sent", "from:example@gmail.com is:unread", "has:attachment after:2023/1/1", "is:important is:unread"],
99
+ title: "Query",
100
+ type: "string",
101
+ },
102
+ userId: {
103
+ default: "me",
104
+ description: "The user's email address or 'me' for the authenticated user.",
105
+ examples: ["me"],
106
+ title: "Userid",
107
+ type: "string",
108
+ },
109
+ },
110
+ title: "NewMessageConfig",
111
+ type: "object",
112
+ },
113
+ payload: {
114
+ properties: {
115
+ attachment_list: {
116
+ anyOf: [{
117
+ items: {},
118
+ type: "array",
119
+ }, {
120
+ type: "null",
121
+ }],
122
+ default: null,
123
+ description: "The list of attachments in the message",
124
+ title: "Attachment List",
125
+ },
126
+ message_id: {
127
+ anyOf: [{
128
+ type: "string",
129
+ }, {
130
+ type: "null",
131
+ }],
132
+ default: null,
133
+ description: "The message ID of the message",
134
+ title: "Message ID",
135
+ },
136
+ message_text: {
137
+ anyOf: [{
138
+ type: "string",
139
+ }, {
140
+ type: "null",
141
+ }],
142
+ default: null,
143
+ description: "The text of the message",
144
+ title: "Message Text",
145
+ },
146
+ message_timestamp: {
147
+ anyOf: [{
148
+ type: "string",
149
+ }, {
150
+ type: "null",
151
+ }],
152
+ default: null,
153
+ description: "The timestamp of the message",
154
+ title: "Message Timestamp",
155
+ },
156
+ payload: {
157
+ anyOf: [{
158
+ type: "object",
159
+ }, {
160
+ type: "null",
161
+ }],
162
+ default: null,
163
+ description: "The payload of the message",
164
+ title: "Payload",
165
+ },
166
+ sender: {
167
+ anyOf: [{
168
+ type: "string",
169
+ }, {
170
+ type: "null",
171
+ }],
172
+ default: null,
173
+ description: "The sender of the message",
174
+ title: "Sender",
175
+ },
176
+ subject: {
177
+ anyOf: [{
178
+ type: "string",
179
+ }, {
180
+ type: "null",
181
+ }],
182
+ default: null,
183
+ description: "The subject of the message",
184
+ title: "Subject",
185
+ },
186
+ thread_id: {
187
+ anyOf: [{
188
+ type: "string",
189
+ }, {
190
+ type: "null",
191
+ }],
192
+ default: null,
193
+ description: "The thread ID of the message",
194
+ title: "Thread ID",
195
+ },
196
+ to: {
197
+ anyOf: [{
198
+ type: "string",
199
+ }, {
200
+ type: "null",
201
+ }],
202
+ default: null,
203
+ description: "The recipient of the message",
204
+ title: "To",
205
+ },
206
+ },
207
+ title: "NewMessagePayload",
208
+ type: "object",
209
+ },
210
+ type: "poll",
211
+ },
212
+ },
213
+ }
214
+ "
215
+ `);
216
expect(slackSourceCode).toMatchInlineSnapshot(`
217
"/**
218
* Map of Composio's SLACK toolkit.
@@ -170,22 +306,158 @@ describe('CLI: composio ts generate', () => {
306
const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
307
308
expect(gmailSourceCode).toMatchInlineSnapshot(`
173
- "/**
174
- * Map of Composio's GMAIL toolkit.
175
- */
176
- export const GMAIL = {
177
- slug: "gmail",
178
- tools: {
179
- CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
180
- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
181
- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
182
- },
183
- triggerTypes: {
184
- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
185
- },
186
- }
187
- "
188
- `);
309
+ "/**
310
+ * Map of Composio's GMAIL toolkit.
311
+ */
312
+ export const GMAIL = {
313
+ slug: "gmail",
314
+ tools: {
315
+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
316
+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
317
+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
318
+ },
319
+ triggerTypes: {
320
+ NEW_GMAIL_MESSAGE: {
321
+ slug: "GMAIL_NEW_GMAIL_MESSAGE",
322
+ name: "New Gmail Message Received Trigger",
323
+ description: "Triggers when a new message is received in Gmail.",
324
+ 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 ",
325
+ config: {
326
+ properties: {
327
+ interval: {
328
+ default: 1,
329
+ description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
330
+ title: "Interval",
331
+ type: "number",
332
+ },
333
+ labelIds: {
334
+ default: "INBOX",
335
+ 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.",
336
+ examples: ["INBOX", "UNREAD", "STARRED"],
337
+ title: "Labelids",
338
+ type: "string",
339
+ },
340
+ query: {
341
+ default: "",
342
+ 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@domain.com), labels (label:inbox), status (is:unread), attachments (has:attachment), dates (after:2023/1/1), and more. If specified, this takes precedence over labelIds.",
343
+ examples: ["label:inbox OR label:sent", "from:example@gmail.com is:unread", "has:attachment after:2023/1/1", "is:important is:unread"],
344
+ title: "Query",
345
+ type: "string",
346
+ },
347
+ userId: {
348
+ default: "me",
349
+ description: "The user's email address or 'me' for the authenticated user.",
350
+ examples: ["me"],
351
+ title: "Userid",
352
+ type: "string",
353
+ },
354
+ },
355
+ title: "NewMessageConfig",
356
+ type: "object",
357
+ },
358
+ payload: {
359
+ properties: {
360
+ attachment_list: {
361
+ anyOf: [{
362
+ items: {},
363
+ type: "array",
364
+ }, {
365
+ type: "null",
366
+ }],
367
+ default: null,
368
+ description: "The list of attachments in the message",
369
+ title: "Attachment List",
370
+ },
371
+ message_id: {
372
+ anyOf: [{
373
+ type: "string",
374
+ }, {
375
+ type: "null",
376
+ }],
377
+ default: null,
378
+ description: "The message ID of the message",
379
+ title: "Message ID",
380
+ },
381
+ message_text: {
382
+ anyOf: [{
383
+ type: "string",
384
+ }, {
385
+ type: "null",
386
+ }],
387
+ default: null,
388
+ description: "The text of the message",
389
+ title: "Message Text",
390
+ },
391
+ message_timestamp: {
392
+ anyOf: [{
393
+ type: "string",
394
+ }, {
395
+ type: "null",
396
+ }],
397
+ default: null,
398
+ description: "The timestamp of the message",
399
+ title: "Message Timestamp",
400
+ },
401
+ payload: {
402
+ anyOf: [{
403
+ type: "object",
404
+ }, {
405
+ type: "null",
406
+ }],
407
+ default: null,
408
+ description: "The payload of the message",
409
+ title: "Payload",
410
+ },
411
+ sender: {
412
+ anyOf: [{
413
+ type: "string",
414
+ }, {
415
+ type: "null",
416
+ }],
417
+ default: null,
418
+ description: "The sender of the message",
419
+ title: "Sender",
420
+ },
421
+ subject: {
422
+ anyOf: [{
423
+ type: "string",
424
+ }, {
425
+ type: "null",
426
+ }],
427
+ default: null,
428
+ description: "The subject of the message",
429
+ title: "Subject",
430
+ },
431
+ thread_id: {
432
+ anyOf: [{
433
+ type: "string",
434
+ }, {
435
+ type: "null",
436
+ }],
437
+ default: null,
438
+ description: "The thread ID of the message",
439
+ title: "Thread ID",
440
+ },
441
+ to: {
442
+ anyOf: [{
443
+ type: "string",
444
+ }, {
445
+ type: "null",
446
+ }],
447
+ default: null,
448
+ description: "The recipient of the message",
449
+ title: "To",
450
+ },
451
+ },
452
+ title: "NewMessagePayload",
453
+ type: "object",
454
+ },
455
+ type: "poll",
456
+ },
457
+ },
458
+ }
459
+ "
460
+ `);
461
expect(slackSourceCode).toMatchInlineSnapshot(`
462
"/**
463
* Map of Composio's SLACK toolkit.
ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts
+137
-1
@@ -90,7 +90,143 @@ describe('generatePythonToolkitSources', () => {
90
FETCH_EMAILS = "GMAIL_FETCH_EMAILS"
91
92
class triggers:
93
- NEW_GMAIL_MESSAGE = "GMAIL_NEW_GMAIL_MESSAGE"
93
+ NEW_GMAIL_MESSAGE = {
94
+ config: {
95
+ properties: {
96
+ interval: {
97
+ default: 1,
98
+ description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
99
+ title: "Interval",
100
+ type: "number"
101
+ },
102
+ labelIds: {
103
+ default: "INBOX",
104
+ 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.",
105
+ examples: ["INBOX", "UNREAD", "STARRED"],
106
+ title: "Labelids",
107
+ type: "string"
108
+ },
109
+ query: {
110
+ default: "",
111
+ 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@domain.com), labels (label:inbox), status (is:unread), attachments (has:attachment), dates (after:2023/1/1), and more. If specified, this takes precedence over labelIds.",
112
+ examples: ["label:inbox OR label:sent", "from:example@gmail.com is:unread", "has:attachment after:2023/1/1", "is:important is:unread"],
113
+ title: "Query",
114
+ type: "string"
115
+ },
116
+ userId: {
117
+ default: "me",
118
+ description: "The user's email address or 'me' for the authenticated user.",
119
+ examples: ["me"],
120
+ title: "Userid",
121
+ type: "string"
122
+ }
123
+ },
124
+ title: "NewMessageConfig",
125
+ type: "object"
126
+ },
127
+ description: "Triggers when a new message is received in Gmail.",
128
+ 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 ",
129
+ name: "New Gmail Message Received Trigger",
130
+ payload: {
131
+ properties: {
132
+ attachment_list: {
133
+ anyOf: [{
134
+ items: {},
135
+ type: "array"
136
+ }, {
137
+ type: "null"
138
+ }],
139
+ default: None,
140
+ description: "The list of attachments in the message",
141
+ title: "Attachment List"
142
+ },
143
+ message_id: {
144
+ anyOf: [{
145
+ type: "string"
146
+ }, {
147
+ type: "null"
148
+ }],
149
+ default: None,
150
+ description: "The message ID of the message",
151
+ title: "Message ID"
152
+ },
153
+ message_text: {
154
+ anyOf: [{
155
+ type: "string"
156
+ }, {
157
+ type: "null"
158
+ }],
159
+ default: None,
160
+ description: "The text of the message",
161
+ title: "Message Text"
162
+ },
163
+ message_timestamp: {
164
+ anyOf: [{
165
+ type: "string"
166
+ }, {
167
+ type: "null"
168
+ }],
169
+ default: None,
170
+ description: "The timestamp of the message",
171
+ title: "Message Timestamp"
172
+ },
173
+ payload: {
174
+ anyOf: [{
175
+ type: "object"
176
+ }, {
177
+ type: "null"
178
+ }],
179
+ default: None,
180
+ description: "The payload of the message",
181
+ title: "Payload"
182
+ },
183
+ sender: {
184
+ anyOf: [{
185
+ type: "string"
186
+ }, {
187
+ type: "null"
188
+ }],
189
+ default: None,
190
+ description: "The sender of the message",
191
+ title: "Sender"
192
+ },
193
+ subject: {
194
+ anyOf: [{
195
+ type: "string"
196
+ }, {
197
+ type: "null"
198
+ }],
199
+ default: None,
200
+ description: "The subject of the message",
201
+ title: "Subject"
202
+ },
203
+ thread_id: {
204
+ anyOf: [{
205
+ type: "string"
206
+ }, {
207
+ type: "null"
208
+ }],
209
+ default: None,
210
+ description: "The thread ID of the message",
211
+ title: "Thread ID"
212
+ },
213
+ to: {
214
+ anyOf: [{
215
+ type: "string"
216
+ }, {
217
+ type: "null"
218
+ }],
219
+ default: None,
220
+ description: "The recipient of the message",
221
+ title: "To"
222
+ }
223
+ },
224
+ title: "NewMessagePayload",
225
+ type: "object"
226
+ },
227
+ slug: "GMAIL_NEW_GMAIL_MESSAGE",
228
+ type: "poll"
229
+ }
230
"
231
`);
232
ts/packages/cli/test/src/generation/toolkit-index.test.ts
+1
-1
@@ -76,7 +76,7 @@ describe('createToolkitIndex', () => {
76
FETCH_EMAILS: 'GMAIL_FETCH_EMAILS',
77
},
78
triggerTypes: {
79
- NEW_GMAIL_MESSAGE: 'GMAIL_NEW_GMAIL_MESSAGE',
79
+ NEW_GMAIL_MESSAGE: TRIGGER_TYPE_GMAIL,
80
},
81
},
82
SLACK: {
ts/packages/cli/test/src/generation/typescript/generate-toolkit-source.test.ts
+137
-1
@@ -87,7 +87,143 @@ describe('generateTypeScriptToolkitSources', () => {
87
FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
88
},
89
triggerTypes: {
90
- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
90
+ NEW_GMAIL_MESSAGE: {
91
+ slug: "GMAIL_NEW_GMAIL_MESSAGE",
92
+ name: "New Gmail Message Received Trigger",
93
+ description: "Triggers when a new message is received in Gmail.",
94
+ 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 ",
95
+ config: {
96
+ properties: {
97
+ interval: {
98
+ default: 1,
99
+ description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
100
+ title: "Interval",
101
+ type: "number",
102
+ },
103
+ labelIds: {
104
+ default: "INBOX",
105
+ 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.",
106
+ examples: ["INBOX", "UNREAD", "STARRED"],
107
+ title: "Labelids",
108
+ type: "string",
109
+ },
110
+ query: {
111
+ default: "",
112
+ 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@domain.com), labels (label:inbox), status (is:unread), attachments (has:attachment), dates (after:2023/1/1), and more. If specified, this takes precedence over labelIds.",
113
+ examples: ["label:inbox OR label:sent", "from:example@gmail.com is:unread", "has:attachment after:2023/1/1", "is:important is:unread"],
114
+ title: "Query",
115
+ type: "string",
116
+ },
117
+ userId: {
118
+ default: "me",
119
+ description: "The user's email address or 'me' for the authenticated user.",
120
+ examples: ["me"],
121
+ title: "Userid",
122
+ type: "string",
123
+ },
124
+ },
125
+ title: "NewMessageConfig",
126
+ type: "object",
127
+ },
128
+ payload: {
129
+ properties: {
130
+ attachment_list: {
131
+ anyOf: [{
132
+ items: {},
133
+ type: "array",
134
+ }, {
135
+ type: "null",
136
+ }],
137
+ default: null,
138
+ description: "The list of attachments in the message",
139
+ title: "Attachment List",
140
+ },
141
+ message_id: {
142
+ anyOf: [{
143
+ type: "string",
144
+ }, {
145
+ type: "null",
146
+ }],
147
+ default: null,
148
+ description: "The message ID of the message",
149
+ title: "Message ID",
150
+ },
151
+ message_text: {
152
+ anyOf: [{
153
+ type: "string",
154
+ }, {
155
+ type: "null",
156
+ }],
157
+ default: null,
158
+ description: "The text of the message",
159
+ title: "Message Text",
160
+ },
161
+ message_timestamp: {
162
+ anyOf: [{
163
+ type: "string",
164
+ }, {
165
+ type: "null",
166
+ }],
167
+ default: null,
168
+ description: "The timestamp of the message",
169
+ title: "Message Timestamp",
170
+ },
171
+ payload: {
172
+ anyOf: [{
173
+ type: "object",
174
+ }, {
175
+ type: "null",
176
+ }],
177
+ default: null,
178
+ description: "The payload of the message",
179
+ title: "Payload",
180
+ },
181
+ sender: {
182
+ anyOf: [{
183
+ type: "string",
184
+ }, {
185
+ type: "null",
186
+ }],
187
+ default: null,
188
+ description: "The sender of the message",
189
+ title: "Sender",
190
+ },
191
+ subject: {
192
+ anyOf: [{
193
+ type: "string",
194
+ }, {
195
+ type: "null",
196
+ }],
197
+ default: null,
198
+ description: "The subject of the message",
199
+ title: "Subject",
200
+ },
201
+ thread_id: {
202
+ anyOf: [{
203
+ type: "string",
204
+ }, {
205
+ type: "null",
206
+ }],
207
+ default: null,
208
+ description: "The thread ID of the message",
209
+ title: "Thread ID",
210
+ },
211
+ to: {
212
+ anyOf: [{
213
+ type: "string",
214
+ }, {
215
+ type: "null",
216
+ }],
217
+ default: null,
218
+ description: "The recipient of the message",
219
+ title: "To",
220
+ },
221
+ },
222
+ title: "NewMessagePayload",
223
+ type: "object",
224
+ },
225
+ type: "poll",
226
+ },
227
},
228
}
229
"
ts/packages/ts-builders/src/ArrayValue.ts
new
+15
@@ -0,0 +1,15 @@
1
+import { ValueBuilder } from './ValueBuilder';
2
+import type { Writer } from './Writer';
3
+
4
+export class ArrayValue extends ValueBuilder {
5
+ private items: ValueBuilder[] = [];
6
+
7
+ add(item: ValueBuilder): this {
8
+ this.items.push(item);
9
+ return this;
10
+ }
11
+
12
+ write(writer: Writer): void {
13
+ writer.write('[').writeJoined(', ', this.items).write(']');
14
+ }
15
+}
ts/packages/ts-builders/src/index.ts
+1
@@ -1,5 +1,6 @@
1
export * from './AnyDeclarationBuilder';
2
export * from './ArraySpread';
3
+export * from './ArrayValue';
4
export * from './ArrayType';
5
export * from './BasicBuilder';
6
export * from './Class';