@composio/core 1.0.0-beta.0 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/{CustomTool-l-j5HtEf.mjs → CustomTool-CM-roKk7.mjs} +16 -6
  2. package/dist/{CustomTool-CwpeQhz2.d.mts → CustomTool-yMQjEyMz.d.mts} +1 -1
  3. package/dist/{FileModifierErrors-B8V8_3VE.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
  4. package/dist/{FileToolModifier.utils.neutral-D_YkHwZP.mjs → FileToolModifier.utils.neutral-DWFpnsj2.mjs} +4 -2
  5. package/dist/{SsrfErrors-DNJt57GL.mjs → SsrfErrors-DiQldIdC.mjs} +154 -19
  6. package/dist/{Telemetry-DK1uAWnD.mjs → Telemetry-JRJJYS4I.mjs} +28 -44
  7. package/dist/cancellation-BEpFk2S8.mjs +706 -0
  8. package/dist/{composio-XjF7EMEe.d.mts → composio-BVNJTVYa.d.mts} +2450 -119
  9. package/dist/{customTool.types-DpJbYY5m.d.mts → customTool.types-CY5SXFfF.d.mts} +143 -28
  10. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +1 -1
  11. package/dist/docs/reference/sdk-reference/typescript/session.mdx +4 -3
  12. package/dist/{errors-BcEUHZbq.mjs → errors-CvZjP9CH.mjs} +42 -4
  13. package/dist/experimental/index.d.mts +2 -2
  14. package/dist/experimental/index.mjs +1 -1
  15. package/dist/{fileUtils.node-BwpUOF0s.mjs → fileUtils.node-HQsywtTj.mjs} +11 -9
  16. package/dist/index.d.mts +393 -142
  17. package/dist/index.mjs +1945 -171
  18. package/dist/models/Files.node.d.mts +2 -3
  19. package/dist/models/Files.node.mjs +2 -2
  20. package/dist/models/Files.workerd.d.mts +2 -3
  21. package/dist/platform/node.d.mts +2 -3
  22. package/dist/platform/workerd.d.mts +2 -3
  23. package/dist/{sensitiveFileUploadPaths-B0w8dqpv.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +10 -7
  24. package/dist/{ssrfGuard.node-DlxO8uzr.mjs → ssrfGuard.node-BK50mYTq.mjs} +187 -24
  25. package/dist/{types-C9kJAurw.d.mts → types-CqGfjlZg.d.mts} +2 -2
  26. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +3 -4
  27. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +3 -4
  28. package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -4
  29. package/dist/utils/modifiers/FileToolModifier.node.mjs +6 -6
  30. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -4
  31. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
  32. package/dist/utils/ssrfGuard.node.d.mts +7 -7
  33. package/dist/utils/ssrfGuard.node.mjs +1 -1
  34. package/dist/utils/ssrfGuard.workerd.d.mts +3 -4
  35. package/dist/utils/ssrfGuard.workerd.mjs +2 -2
  36. package/package.json +25 -7
  37. package/src/composio.ts +86 -2
  38. package/src/errors/ConnectedAccountsErrors.ts +47 -0
  39. package/src/errors/ToolErrors.ts +1 -0
  40. package/src/errors/ValidationErrors.ts +2 -0
  41. package/src/index.ts +21 -0
  42. package/src/models/ConnectedAccounts.ts +118 -2
  43. package/src/models/CustomTool.ts +41 -6
  44. package/src/models/CustomToolkits.ts +169 -0
  45. package/src/models/Experimental.ts +27 -0
  46. package/src/models/Keyring.ts +65 -0
  47. package/src/models/Logs.ts +101 -0
  48. package/src/models/RemoteFile.ts +54 -36
  49. package/src/models/ToolRouterSession.ts +60 -4
  50. package/src/models/Toolkits.ts +180 -0
  51. package/src/models/Tools.ts +3 -1
  52. package/src/models/Triggers.ts +17 -87
  53. package/src/models/Usage.ts +119 -0
  54. package/src/models/Webhooks.ts +520 -0
  55. package/src/services/telemetry/TelemetryService.ts +27 -12
  56. package/src/telemetry/redact.ts +133 -6
  57. package/src/types/authConfigs.types.ts +2 -0
  58. package/src/types/connectedAccounts.types.ts +54 -0
  59. package/src/types/customToolkits.types.ts +102 -0
  60. package/src/types/keyring.types.ts +32 -0
  61. package/src/types/logs.types.ts +108 -0
  62. package/src/types/toolRouter.types.ts +49 -1
  63. package/src/types/toolkit.types.ts +131 -0
  64. package/src/types/usage.types.ts +81 -0
  65. package/src/types/webhooks.types.ts +143 -0
  66. package/src/utils/constants.ts +1 -5
  67. package/src/utils/fileUtils.node.ts +10 -2
  68. package/src/utils/jsonSchema.ts +509 -28
  69. package/src/utils/logger.ts +45 -13
  70. package/src/utils/pinnedDispatcher.node.ts +109 -13
  71. package/src/utils/sdk.ts +1 -1
  72. package/src/utils/ssrfGuard.node.ts +124 -21
  73. package/src/utils/ssrfGuard.workerd.ts +5 -1
  74. package/src/utils/transformers/connectedAccounts.ts +37 -2
  75. package/src/utils/transformers/customToolkits.ts +98 -0
  76. package/src/utils/transformers/keyring.ts +24 -0
  77. package/src/utils/transformers/logs.ts +85 -0
  78. package/src/utils/transformers/toolkits.ts +100 -1
  79. package/src/utils/transformers/triggers.ts +2 -2
  80. package/src/utils/transformers/usage.ts +77 -0
  81. package/src/utils/transformers/webhooks.ts +139 -0
  82. package/dist/cancellation-C-qy8rcj.mjs +0 -364
@@ -18,6 +18,14 @@ export type ToolkitMangedByEnum = z.infer<typeof ToolkitMangedByEnumSchema>;
18
18
  export type ToolkitSortByEnum = z.infer<typeof ToolkitSortByEnumSchema>;
19
19
  export type ToolkitListParams = z.infer<typeof ToolkitsListParamsSchema>;
20
20
 
21
+ /**
22
+ * Toolkit getMany params — the slugs to fetch plus the same filters `list`
23
+ * accepts.
24
+ */
25
+ export const ToolkitGetManySlugsSchema = z.array(z.string().min(1)).min(1);
26
+ export const ToolkitsGetManyParamsSchema = ToolkitsListParamsSchema;
27
+ export type ToolkitGetManyParams = z.infer<typeof ToolkitsGetManyParamsSchema>;
28
+
21
29
  /**
22
30
  * Toolkits response
23
31
  */
@@ -121,6 +129,129 @@ export type ToolkitRetrieveCategoriesResponse = z.infer<
121
129
  typeof ToolkitRetrieveCategoriesResponseSchema
122
130
  >;
123
131
 
132
+ /**
133
+ * Toolkit changelog response
134
+ */
135
+ export const ToolkitVersionChangelogSchema = z.object({
136
+ version: z.string(),
137
+ changelog: z.string(),
138
+ });
139
+ export const ToolkitChangelogItemSchema = z.object({
140
+ slug: z.string(),
141
+ name: z.string(),
142
+ displayName: z.string(),
143
+ /** Most recent versions first; the API returns up to the last 10 per toolkit. */
144
+ versions: z.array(ToolkitVersionChangelogSchema),
145
+ });
146
+ export const ToolkitChangelogResponseSchema = z.object({
147
+ items: z.array(ToolkitChangelogItemSchema),
148
+ });
149
+
150
+ export type ToolkitVersionChangelog = z.infer<typeof ToolkitVersionChangelogSchema>;
151
+ export type ToolkitChangelogItem = z.infer<typeof ToolkitChangelogItemSchema>;
152
+ export type ToolkitChangelogResponse = z.infer<typeof ToolkitChangelogResponseSchema>;
153
+
154
+ /**
155
+ * Params for `composio.toolkits.recommendScopes()`.
156
+ * **Experimental — shape may change in future releases.**
157
+ */
158
+ export const ToolkitRecommendScopesParamsSchema = z.object({
159
+ /** Tool slugs to cover. Pass `[]` to cover every tool in the toolkit. */
160
+ tools: z.array(z.string()),
161
+ /** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
162
+ authScheme: AuthSchemeEnum.optional(),
163
+ /** Toolkit version to compute from. The API defaults to the latest published version. */
164
+ toolkitVersion: z.string().min(1).optional(),
165
+ /**
166
+ * Context the scopes will be granted in, as dimension → selected value,
167
+ * for example `{ account_type: 'Google Workspace' }`. Discover the
168
+ * dimensions with `composio.toolkits.listGrantContexts()`.
169
+ */
170
+ grantContext: z.record(z.string(), z.string()).optional(),
171
+ /** Scopes the recommendation must include, whether or not the tools need them. */
172
+ include: z.array(z.string()).optional(),
173
+ /** Scopes the recommendation must not include; the API picks documented alternatives or fails. */
174
+ exclude: z.array(z.string()).optional(),
175
+ /** Scopes your OAuth app can request. The recommendation never goes outside this list. */
176
+ availableScopes: z.array(z.string()).optional(),
177
+ });
178
+ export type ToolkitRecommendScopesParams = z.infer<typeof ToolkitRecommendScopesParamsSchema>;
179
+
180
+ export const ToolkitConditionalScopeSchema = z.object({
181
+ /** The scope needed only when the `when` guard matches. */
182
+ scope: z.string(),
183
+ /** Input field name → qualifying values. Any value matches within a field; all fields must match. */
184
+ when: z.record(z.string(), z.array(z.string())),
185
+ /** Tool slugs that need this scope under the guard. */
186
+ for: z.array(z.string()),
187
+ });
188
+ export type ToolkitConditionalScope = z.infer<typeof ToolkitConditionalScopeSchema>;
189
+
190
+ /**
191
+ * Response of `composio.toolkits.recommendScopes()`.
192
+ * **Experimental — shape may change in future releases.**
193
+ */
194
+ export const ToolkitRecommendScopesResponseSchema = z.object({
195
+ /** Auth scheme the recommendation was computed under. */
196
+ authScheme: z.string(),
197
+ /** Concrete toolkit version the answer was computed from; pass it back as `toolkitVersion` to pin. */
198
+ toolkitVersion: z.string(),
199
+ /** The effective grant context: the toolkit default overlaid with your overrides. */
200
+ grantContext: z.record(z.string(), z.string()),
201
+ scopes: z.object({
202
+ /** Narrowest documented option per requirement. */
203
+ leastPrivilege: z.array(z.string()),
204
+ /** Smallest scope set covering all requirements. */
205
+ fewest: z.array(z.string()),
206
+ /**
207
+ * Scopes needed only for particular call-time inputs. Both lists above
208
+ * already include them, so a caller that knows its inputs may drop the rest.
209
+ */
210
+ conditional: z.array(ToolkitConditionalScopeSchema),
211
+ }),
212
+ });
213
+ export type ToolkitRecommendScopesResponse = z.infer<typeof ToolkitRecommendScopesResponseSchema>;
214
+
215
+ /**
216
+ * Params for `composio.toolkits.listGrantContexts()`.
217
+ * **Experimental — shape may change in future releases.**
218
+ */
219
+ export const ToolkitListGrantContextsParamsSchema = z.object({
220
+ /** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
221
+ authScheme: AuthSchemeEnum.optional(),
222
+ /** Toolkit version to read the scope catalog from. The API defaults to the latest published version. */
223
+ toolkitVersion: z.string().min(1).optional(),
224
+ });
225
+ export type ToolkitListGrantContextsParams = z.infer<typeof ToolkitListGrantContextsParamsSchema>;
226
+
227
+ export const ToolkitGrantContextDimensionSchema = z.object({
228
+ /** Dimension name to use as a `grantContext` key. */
229
+ dimension: z.string(),
230
+ /** What the dimension means and when to pass it. */
231
+ description: z.string(),
232
+ /** Values the dimension can take. */
233
+ values: z.array(z.string()),
234
+ });
235
+ export type ToolkitGrantContextDimension = z.infer<typeof ToolkitGrantContextDimensionSchema>;
236
+
237
+ /**
238
+ * Response of `composio.toolkits.listGrantContexts()`.
239
+ * **Experimental — shape may change in future releases.**
240
+ */
241
+ export const ToolkitListGrantContextsResponseSchema = z.object({
242
+ /** Auth scheme whose scope catalog the dimensions were read from. */
243
+ authScheme: z.string(),
244
+ /** Concrete toolkit version the answer was computed from. */
245
+ toolkitVersion: z.string(),
246
+ /** Dimensions the toolkit accepts in `grantContext`; empty when no scope depends on one. */
247
+ grantContextDimensions: z.array(ToolkitGrantContextDimensionSchema),
248
+ /** The grant context assumed when you pass none. */
249
+ defaultGrantContext: z.record(z.string(), z.string()),
250
+ });
251
+ export type ToolkitListGrantContextsResponse = z.infer<
252
+ typeof ToolkitListGrantContextsResponseSchema
253
+ >;
254
+
124
255
  export const ToolkitAuthFieldsResponseSchema = z.array(
125
256
  ToolkitAuthFieldSchema.extend({
126
257
  required: z.boolean().optional(),
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod/v3';
2
+
3
+ /**
4
+ * Filters shared by the usage summary and breakdown queries.
5
+ * **Experimental — shape may change in future releases.**
6
+ */
7
+ export const UsageFiltersSchema = z.object({
8
+ /** Only count events for these external end-user IDs (OR logic). */
9
+ userId: z.array(z.string()).nullable().optional(),
10
+ /** Only count events for these session IDs (OR logic). */
11
+ sessionId: z.array(z.string()).nullable().optional(),
12
+ });
13
+ export type UsageFilters = z.infer<typeof UsageFiltersSchema>;
14
+
15
+ /**
16
+ * Params for `composio.experimental.usage.summary()`.
17
+ * **Experimental — shape may change in future releases.**
18
+ */
19
+ export const UsageSummaryParamsSchema = z.object({
20
+ /** Inclusive range start (Unix epoch milliseconds). Defaults to 30 days before `to`. */
21
+ from: z.number().optional(),
22
+ /** Exclusive range end (Unix epoch milliseconds). Defaults to now. */
23
+ to: z.number().optional(),
24
+ /** Restrict to these metering entity types. Omit for all types. */
25
+ entityTypes: z.array(z.string()).optional(),
26
+ filters: UsageFiltersSchema.optional(),
27
+ });
28
+ export type UsageSummaryParams = z.infer<typeof UsageSummaryParamsSchema>;
29
+
30
+ export const UsageOrderBySchema = z.enum(['key', 'total_quantity', 'event_count']);
31
+ export const UsageOrderDirectionSchema = z.enum(['asc', 'desc']);
32
+
33
+ /**
34
+ * Params for `composio.experimental.usage.breakdown()`.
35
+ * **Experimental — shape may change in future releases.**
36
+ */
37
+ export const UsageBreakdownParamsSchema = z.object({
38
+ /** Inclusive range start (Unix epoch milliseconds). Defaults to 30 days before `to`. */
39
+ from: z.number().optional(),
40
+ /** Exclusive range end (Unix epoch milliseconds). Defaults to now. */
41
+ to: z.number().optional(),
42
+ /** Dimension to group by. Defaults to `tool_slug` for tool_calls and `user_id` for sessions. */
43
+ groupBy: z.string().optional(),
44
+ /** Field to order groups by. Defaults to `total_quantity`. */
45
+ orderBy: UsageOrderBySchema.optional(),
46
+ /** Sort direction. Defaults to `desc`. */
47
+ orderDirection: UsageOrderDirectionSchema.optional(),
48
+ /** Maximum number of groups to return. Defaults to 100, max 1000. */
49
+ limit: z.number().optional(),
50
+ filters: UsageFiltersSchema.optional(),
51
+ });
52
+ export type UsageBreakdownParams = z.infer<typeof UsageBreakdownParamsSchema>;
53
+
54
+ export const UsageEntitySummarySchema = z.object({
55
+ unit: z.string(),
56
+ totalQuantity: z.string(),
57
+ eventCount: z.number(),
58
+ });
59
+ export type UsageEntitySummary = z.infer<typeof UsageEntitySummarySchema>;
60
+
61
+ export const UsageSummaryResponseSchema = z.object({
62
+ /** Aggregates keyed by metering entity type (e.g. `tool_calls`, `sessions`). */
63
+ entities: z.record(z.string(), UsageEntitySummarySchema),
64
+ });
65
+ export type UsageSummaryResponse = z.infer<typeof UsageSummaryResponseSchema>;
66
+
67
+ export const UsageBreakdownGroupSchema = z.object({
68
+ key: z.string(),
69
+ totalQuantity: z.string(),
70
+ eventCount: z.number(),
71
+ });
72
+ export type UsageBreakdownGroup = z.infer<typeof UsageBreakdownGroupSchema>;
73
+
74
+ export const UsageBreakdownResponseSchema = z.object({
75
+ entityType: z.string(),
76
+ unit: z.string(),
77
+ totalQuantity: z.string(),
78
+ eventCount: z.number(),
79
+ groups: z.array(UsageBreakdownGroupSchema),
80
+ });
81
+ export type UsageBreakdownResponse = z.infer<typeof UsageBreakdownResponseSchema>;
@@ -0,0 +1,143 @@
1
+ import { z } from 'zod/v3';
2
+ import { SetWebhookSubscriptionParamsSchema } from './triggers.types';
3
+
4
+ /**
5
+ * Webhook payload versions accepted by the webhook subscription endpoints.
6
+ */
7
+ export const WebhookVersionSchema = z.enum(['V1', 'V2', 'V3']);
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // Webhook subscriptions
11
+ // ---------------------------------------------------------------------------
12
+
13
+ /**
14
+ * A project webhook subscription in the SDK's camelCase shape. The signing
15
+ * `secret` is returned by the API on every subscription read/write.
16
+ */
17
+ export const WebhookSubscriptionSchema = z.object({
18
+ id: z.string(),
19
+ webhookUrl: z.string(),
20
+ version: WebhookVersionSchema,
21
+ enabledEvents: z.array(z.string()),
22
+ secret: z.string().optional(),
23
+ createdAt: z.string().optional(),
24
+ updatedAt: z.string().optional(),
25
+ });
26
+
27
+ export const WebhookSubscriptionListParamsSchema = z.object({
28
+ /** Number of items per page, max allowed is 50. */
29
+ limit: z.number().optional(),
30
+ /** Cursor for pagination, taken from a previous response's `nextCursor`. */
31
+ cursor: z.string().optional(),
32
+ });
33
+ export type WebhookSubscriptionListParams = z.infer<typeof WebhookSubscriptionListParamsSchema>;
34
+
35
+ export const WebhookSubscriptionListResponseSchema = z.object({
36
+ items: z.array(WebhookSubscriptionSchema),
37
+ nextCursor: z.string().nullable(),
38
+ totalPages: z.number(),
39
+ currentPage: z.number(),
40
+ totalItems: z.number(),
41
+ });
42
+ export type WebhookSubscriptionListResponse = z.infer<typeof WebhookSubscriptionListResponseSchema>;
43
+
44
+ /**
45
+ * Params for `composio.webhooks.subscriptions.set()`. Identical to the
46
+ * params accepted by `composio.triggers.setWebhookSubscription()`.
47
+ */
48
+ export const WebhookSubscriptionSetParamsSchema = SetWebhookSubscriptionParamsSchema;
49
+ export type WebhookSubscriptionSetParams = z.infer<typeof WebhookSubscriptionSetParamsSchema>;
50
+
51
+ export const WebhookSubscriptionUpdateParamsSchema = z.object({
52
+ /** HTTPS URL to receive webhook events. */
53
+ webhookUrl: z.string().min(1).optional(),
54
+ /** Event types to subscribe to. */
55
+ enabledEvents: z.array(z.string()).min(1).optional(),
56
+ /** Webhook payload version. */
57
+ version: WebhookVersionSchema.optional(),
58
+ });
59
+ export type WebhookSubscriptionUpdateParams = z.infer<typeof WebhookSubscriptionUpdateParamsSchema>;
60
+
61
+ export const WebhookSubscriptionDeleteResponseSchema = z.object({
62
+ success: z.boolean(),
63
+ });
64
+ export type WebhookSubscriptionDeleteResponse = z.infer<
65
+ typeof WebhookSubscriptionDeleteResponseSchema
66
+ >;
67
+
68
+ export const WebhookSubscriptionRotateSecretResponseSchema = z.object({
69
+ id: z.string(),
70
+ /** The new signing secret. Store it — the previous secret stops validating. */
71
+ secret: z.string(),
72
+ });
73
+ export type WebhookSubscriptionRotateSecretResponse = z.infer<
74
+ typeof WebhookSubscriptionRotateSecretResponseSchema
75
+ >;
76
+
77
+ export const WebhookSubscriptionEventTypeSchema = z.object({
78
+ eventType: z.string(),
79
+ description: z.string(),
80
+ supportedVersions: z.array(WebhookVersionSchema),
81
+ });
82
+ export type WebhookSubscriptionEventType = z.infer<typeof WebhookSubscriptionEventTypeSchema>;
83
+
84
+ export const WebhookSubscriptionEventTypesResponseSchema = z.object({
85
+ items: z.array(WebhookSubscriptionEventTypeSchema),
86
+ });
87
+ export type WebhookSubscriptionEventTypesResponse = z.infer<
88
+ typeof WebhookSubscriptionEventTypesResponseSchema
89
+ >;
90
+
91
+ // ---------------------------------------------------------------------------
92
+ // Webhook endpoints (per toolkit + OAuth app inbound ingress URLs)
93
+ // ---------------------------------------------------------------------------
94
+
95
+ export const WebhookEndpointListParamsSchema = z.object({
96
+ /** Only return endpoints for this toolkit slug. */
97
+ toolkitSlug: z.string().optional(),
98
+ });
99
+ export type WebhookEndpointListParams = z.infer<typeof WebhookEndpointListParamsSchema>;
100
+
101
+ export const WebhookEndpointListItemSchema = z.object({
102
+ id: z.string(),
103
+ toolkitSlug: z.string(),
104
+ clientId: z.string().nullable(),
105
+ });
106
+ export type WebhookEndpointListItem = z.infer<typeof WebhookEndpointListItemSchema>;
107
+
108
+ export const WebhookEndpointListResponseSchema = z.object({
109
+ items: z.array(WebhookEndpointListItemSchema),
110
+ });
111
+ export type WebhookEndpointListResponse = z.infer<typeof WebhookEndpointListResponseSchema>;
112
+
113
+ export const WebhookEndpointSchema = z.object({
114
+ id: z.string(),
115
+ toolkitSlug: z.string(),
116
+ clientId: z.string().nullable(),
117
+ /** The inbound URL to register with the third-party provider. */
118
+ webhookUrl: z.string(),
119
+ /** Configured setup fields with secret values masked. */
120
+ data: z.record(z.string(), z.string()).nullable(),
121
+ createdAt: z.string(),
122
+ });
123
+ export type WebhookEndpoint = z.infer<typeof WebhookEndpointSchema>;
124
+
125
+ export const WebhookEndpointCreateParamsSchema = z.object({
126
+ /** Toolkit identifier (e.g. `slack`, `discord`). */
127
+ toolkitSlug: z.string().min(1),
128
+ /** OAuth app client ID — identifies which app this endpoint is for. */
129
+ clientId: z.string().min(1),
130
+ });
131
+ export type WebhookEndpointCreateParams = z.infer<typeof WebhookEndpointCreateParamsSchema>;
132
+
133
+ export const WebhookEndpointReplaceParamsSchema = z.object({
134
+ /** Key-value pairs for ALL required setup fields of the toolkit. */
135
+ data: z.record(z.string(), z.string()),
136
+ });
137
+ export type WebhookEndpointReplaceParams = z.infer<typeof WebhookEndpointReplaceParamsSchema>;
138
+
139
+ export const WebhookEndpointUpdateParamsSchema = z.object({
140
+ /** Key-value pairs to merge into the setup fields. Omitted fields are preserved. */
141
+ data: z.record(z.string(), z.string()),
142
+ });
143
+ export type WebhookEndpointUpdateParams = z.infer<typeof WebhookEndpointUpdateParamsSchema>;
@@ -11,11 +11,7 @@ export const TELEMETRY_URL = 'https://app.composio.dev';
11
11
  export const CLIENT_PUSHER_KEY = getEnvVariable('CLIENT_PUSHER_KEY') || 'ff9f18c208855d77a152';
12
12
 
13
13
  export const COMPOSIO_LOG_LEVEL = getEnvVariable('COMPOSIO_LOG_LEVEL') as
14
- | 'debug'
15
- | 'info'
16
- | 'warn'
17
- | 'error'
18
- | undefined;
14
+ 'silent' | 'debug' | 'info' | 'warn' | 'error' | undefined;
19
15
 
20
16
  export const IS_DEVELOPMENT_OR_CI = getEnvVariable('DEVELOPMENT') || getEnvVariable('CI') || false;
21
17
 
@@ -340,6 +340,7 @@ export const downloadFileFromS3 = async ({
340
340
  mimeType,
341
341
  fileDownloadDir,
342
342
  signal,
343
+ maxDownloadBytes,
343
344
  }: {
344
345
  toolSlug: string;
345
346
  s3Url: string;
@@ -350,6 +351,11 @@ export const downloadFileFromS3 = async ({
350
351
  */
351
352
  fileDownloadDir?: string;
352
353
  signal?: AbortSignal;
354
+ /**
355
+ * Maximum number of bytes to read from the response before rejecting.
356
+ * Defaults to {@link MAX_URL_UPLOAD_SIZE_BYTES} (100 MiB).
357
+ */
358
+ maxDownloadBytes?: number;
353
359
  }): Promise<FileDownloadData> => {
354
360
  // SSRF guard: `s3Url` is a field of the tool-execution response, so it is no
355
361
  // more trusted than a user-supplied URL — and the bytes it returns are
@@ -358,11 +364,13 @@ export const downloadFileFromS3 = async ({
358
364
  if (!response.ok) {
359
365
  throw new Error(`Failed to download file: ${response.statusText}`);
360
366
  }
361
- const data = await response.arrayBuffer();
367
+ // The response is attacker-influencable and streamed to disk, so the body is
368
+ // read through the shared size guard rather than buffered wholesale.
369
+ const data = await readResponseBodyWithLimit(response, maxDownloadBytes);
362
370
 
363
371
  const extension = getExtensionFromMimeType(mimeType);
364
372
  const fileName = generateTimestampedFilename(extension, `${toolSlug}_`);
365
- const filePath = saveFile(fileName, new Uint8Array(data), {
373
+ const filePath = saveFile(fileName, data, {
366
374
  isTempFile: fileDownloadDir === undefined,
367
375
  outputDir: fileDownloadDir,
368
376
  });