@composio/core 0.29.0 → 0.30.0

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 (70) hide show
  1. package/README.md +23 -0
  2. package/dist/{CustomTool-Bd1KdWvo.mjs → CustomTool-9Vlb4XaS.mjs} +4 -7
  3. package/dist/{CustomTool-CMW-d2ZN.d.mts → CustomTool-Dzk3iqfP.d.mts} +2 -4
  4. package/dist/FileModifierErrors-WrqokuIF.mjs +199 -0
  5. package/dist/{FileToolModifier.utils.neutral-DWFpnsj2.mjs → FileToolModifier.utils.neutral-BQP85ZJj.mjs} +1 -2
  6. package/dist/{SsrfErrors-DiQldIdC.mjs → SsrfErrors-BSVMW915.mjs} +49 -26
  7. package/dist/{Telemetry-D2PJwXKx.mjs → Telemetry-a7SOQXcg.mjs} +6 -10
  8. package/dist/{composio-D5UV5HXN.d.mts → composio-DaokW5sV.d.mts} +229 -284
  9. package/dist/{customTool.types-B9fs34dv.d.mts → customTool.types-CpJbzxT6.d.mts} +182 -245
  10. package/dist/docs/error-consistency.md +3 -3
  11. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +1 -0
  12. package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +6 -11
  13. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +1 -1
  14. package/dist/docs/reference/sdk-reference/typescript/index.mdx +1 -1
  15. package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +1 -1
  16. package/dist/{errors-BK6Xc7Ia.mjs → errors-xC13uvaA.mjs} +56 -139
  17. package/dist/experimental/index.d.mts +16 -2
  18. package/dist/experimental/index.mjs +1 -1
  19. package/dist/{fileUtils.node-ILI1IjnZ.mjs → fileUtils.node-CAwIbWYH.mjs} +6 -8
  20. package/dist/{files.types-DeMC_mAW.d.mts → files.types-Dg6HcEzs.d.mts} +0 -2
  21. package/dist/index.d.mts +40 -75
  22. package/dist/index.mjs +281 -243
  23. package/dist/{cancellation-BoJjs34Y.mjs → jsonSchema-Cc4EtHRw.mjs} +5 -22
  24. package/dist/models/Files.node.d.mts +32 -13
  25. package/dist/models/Files.node.mjs +36 -19
  26. package/dist/models/Files.workerd.d.mts +8 -3
  27. package/dist/models/Files.workerd.mjs +1 -2
  28. package/dist/platform/node.d.mts +2 -4
  29. package/dist/platform/node.mjs +15 -16
  30. package/dist/platform/workerd.d.mts +2 -4
  31. package/dist/platform/workerd.mjs +1 -2
  32. package/dist/requestOptions.types-DWrTcbss.d.mts +38 -0
  33. package/dist/rolldown-runtime-ad2WFvuA.mjs +17 -0
  34. package/dist/{sensitiveFileUploadPaths-BaEORC7-.mjs → sensitiveFileUploadPaths-CSyJ3Ku8.mjs} +22 -12
  35. package/dist/{ssrfGuard.node-BZ270bcu.mjs → ssrfGuard.node-CdIkwqVu.mjs} +3 -5
  36. package/dist/{types-CaP2SytR.d.mts → types-DQdUb7OG.d.mts} +2 -4
  37. package/dist/{types-DuVZKrXO.d.mts → types-Ds6XbK1m.d.mts} +0 -2
  38. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +2 -4
  39. package/dist/utils/config-defaults/ConfigDefaults.node.mjs +1 -2
  40. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +2 -4
  41. package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +1 -2
  42. package/dist/utils/modifiers/FileToolModifier.node.d.mts +2 -4
  43. package/dist/utils/modifiers/FileToolModifier.node.mjs +7 -8
  44. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +2 -4
  45. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +2 -3
  46. package/dist/utils/ssrfGuard.node.d.mts +1 -3
  47. package/dist/utils/ssrfGuard.node.mjs +1 -1
  48. package/dist/utils/ssrfGuard.workerd.d.mts +1 -3
  49. package/dist/utils/ssrfGuard.workerd.mjs +2 -3
  50. package/docs/error-consistency.md +3 -3
  51. package/package.json +12 -13
  52. package/src/composio.ts +12 -0
  53. package/src/errors/ComposioError.ts +40 -16
  54. package/src/errors/ConnectedAccountsErrors.ts +2 -2
  55. package/src/errors/ToolErrors.ts +107 -30
  56. package/src/errors/apiErrorDetails.ts +40 -0
  57. package/src/models/ConnectionRequest.ts +12 -4
  58. package/src/models/CustomToolkits.ts +11 -17
  59. package/src/models/Experimental.ts +2 -7
  60. package/src/models/Files.node.ts +68 -37
  61. package/src/models/RemoteFile.ts +22 -16
  62. package/src/models/SessionContext.ts +6 -7
  63. package/src/models/ToolRouterSession.ts +16 -23
  64. package/src/models/Tools.ts +218 -20
  65. package/src/models/Triggers.ts +8 -2
  66. package/src/types/customToolkits.types.ts +4 -9
  67. package/src/utils/cancellation.ts +5 -1
  68. package/dist/FileModifierErrors-CdGSABoq.mjs +0 -97
  69. package/dist/rolldown-runtime-w6R9maHv.mjs +0 -18
  70. package/src/models/inlineCustomToolsPayload.ts +0 -17
@@ -1,5 +1,6 @@
1
1
  import ComposioClient, { APIError } from '@composio/client';
2
2
  import { FileToolModifier } from '#file_tool_modifier';
3
+ import { z } from 'zod/v3';
3
4
  import {
4
5
  Tool,
5
6
  ToolExecuteParams,
@@ -46,6 +47,7 @@ import {
46
47
  ComposioToolFetchRateLimitError,
47
48
  ComposioToolNotFoundError,
48
49
  ComposioProviderNotDefinedError,
50
+ ComposioToolSchemaInvalidError,
49
51
  ComposioToolVersionRequiredError,
50
52
  } from '../errors/ToolErrors';
51
53
  import { ValidationError } from '../errors/ValidationErrors';
@@ -53,6 +55,7 @@ import { telemetry } from '../telemetry/Telemetry';
53
55
  import type { ComposioConfig } from '../composio';
54
56
  import { getToolkitVersion } from '../utils/toolkitVersion';
55
57
  import { handleToolExecutionError } from '../errors/ToolErrors';
58
+ import { apiErrorSuggestedFixes, withApiErrorMessage } from '../errors/apiErrorDetails';
56
59
  import type { SessionExecuteParams } from '@composio/client/resources/tool-router/session';
57
60
  import { CONFIG_DEFAULTS } from '../utils/config-defaults';
58
61
  import { resolveEffectiveUploadAllowlist } from '../utils/fileDirs';
@@ -81,23 +84,121 @@ type RawToolParameters =
81
84
  | ToolRetrieveResponse['input_parameters']
82
85
  | ComposioToolListResponse['items'][0]['input_parameters'];
83
86
 
87
+ type JsonSchemaNode = Record<string, unknown>;
88
+
89
+ const isSchemaRecord = (value: unknown): value is JsonSchemaNode =>
90
+ typeof value === 'object' && value !== null && !Array.isArray(value);
91
+
92
+ /**
93
+ * Flatten a value for interpolation into a log line.
94
+ *
95
+ * The logger writes straight to the console sink, and the slug and the zod
96
+ * issue paths here are built from property names a remote toolkit controls. A
97
+ * name carrying a newline could otherwise forge or erase a line in the host's
98
+ * log, and an ANSI clear-line sequence could hide what came before it.
99
+ */
100
+ const sanitizeForLog = (value: string): string =>
101
+ // eslint-disable-next-line no-control-regex
102
+ value.replace(/[\u0000-\u001F\u007F-\u009F]/g, ' ');
103
+
104
+ /**
105
+ * Rewrite one JSON-Schema node into the strict subset `ParametersSchema`
106
+ * accepts, preserving its meaning:
107
+ *
108
+ * - boolean nodes (`items: true` / `items: false`) become `{}` / `{ not: {} }`
109
+ * — the strict subset's way to express "anything" and "nothing", so the
110
+ * meaning survives; booleans are still valid JSON Schema (draft-04 style)
111
+ * that MCP toolkits emit;
112
+ * - draft-04 boolean `exclusiveMinimum`/`exclusiveMaximum` (paired with
113
+ * `minimum`/`maximum`) become the numeric form draft-07+ uses;
114
+ *
115
+ * Children are rewritten recursively. `additionalProperties` legitimately
116
+ * accepts a boolean, so it is only recursed into when it is a schema.
117
+ */
118
+ function sanitizeJsonSchemaNode(node: unknown): unknown {
119
+ // Boolean JSON-Schema nodes (draft-04 style, still emitted by MCP toolkits):
120
+ // `true` accepts anything, which `{}` also expresses; `false` accepts
121
+ // nothing, which the strict subset (an object node) expresses as `not: {}`.
122
+ // Coercing `false` to `{}` would invert the schema's meaning.
123
+ if (typeof node === 'boolean') return node ? {} : { not: {} };
124
+ if (Array.isArray(node)) return node.map(sanitizeJsonSchemaNode);
125
+ if (!isSchemaRecord(node)) return node;
126
+
127
+ const schema: JsonSchemaNode = { ...node };
128
+
129
+ for (const [bound, limit] of [
130
+ ['exclusiveMinimum', 'minimum'],
131
+ ['exclusiveMaximum', 'maximum'],
132
+ ] as const) {
133
+ if (typeof schema[bound] !== 'boolean') continue;
134
+ if (schema[bound] && typeof schema[limit] === 'number') {
135
+ schema[bound] = schema[limit];
136
+ } else {
137
+ delete schema[bound];
138
+ }
139
+ }
140
+
141
+ for (const key of ['items', 'not', 'if', 'then', 'else', 'additionalProperties'] as const) {
142
+ const child = schema[key];
143
+ if (child === undefined) continue;
144
+ // Every keyword here takes a schema node except `additionalProperties`,
145
+ // which also accepts a boolean; the sanitizer coerces boolean nodes.
146
+ if (key === 'additionalProperties' && typeof child === 'boolean') continue;
147
+ schema[key] = sanitizeJsonSchemaNode(child);
148
+ }
149
+
150
+ for (const key of ['anyOf', 'oneOf', 'allOf'] as const) {
151
+ if (Array.isArray(schema[key])) {
152
+ schema[key] = sanitizeJsonSchemaNode(schema[key]);
153
+ }
154
+ }
155
+
156
+ for (const key of ['properties', 'patternProperties', '$defs', 'definitions'] as const) {
157
+ const children = schema[key];
158
+ if (!isSchemaRecord(children)) continue;
159
+ const mapped: JsonSchemaNode = {};
160
+ for (const [name, child] of Object.entries(children)) {
161
+ mapped[name] = sanitizeJsonSchemaNode(child);
162
+ }
163
+ schema[key] = mapped;
164
+ }
165
+
166
+ return schema;
167
+ }
168
+
84
169
  /**
85
170
  * Normalize a raw `input_parameters` / `output_parameters` payload returned by
86
171
  * the Composio API. Maps `null`, `undefined`, and empty `{}` — all of which
87
172
  * mean "no declared schema" — to `undefined` so the strict `ParametersSchema`
88
- * validator never sees them. Non-empty objects pass through unchanged and
89
- * remain subject to strict Zod validation.
173
+ * validator never sees them, and rewrites the valid-but-unusual JSON Schema
174
+ * shapes MCP toolkits ship (boolean nodes, draft-04 boolean bounds, a bare
175
+ * combinator root) into the strict subset.
90
176
  *
91
177
  * MCP-backed toolkits (granola_mcp, apify_mcp, tavily_mcp, …) have no
92
178
  * declared output schema and the API serializes that as `{}`, which would
93
179
  * otherwise trip `ParametersSchema`. See
94
- * https://github.com/ComposioHQ/composio/issues/3354.
180
+ * https://github.com/ComposioHQ/composio/issues/3354. The malformed-shape
181
+ * handling covers the toolkits listed in
182
+ * https://github.com/ComposioHQ/composio/issues/4757.
95
183
  */
96
184
  function normalizeRawToolParameters(
97
185
  params: RawToolParameters | null | undefined
98
186
  ): RawToolParameters | undefined {
99
187
  if (params == null || Object.keys(params).length === 0) return undefined;
100
- return params;
188
+ const sanitized = sanitizeJsonSchemaNode(params);
189
+ // A parameters root is a tool's named-argument object, so a bare combinator
190
+ // root (`oneOf`/`anyOf`/`allOf` with no `type`) still needs `type: "object"`
191
+ // to satisfy the strict schema.
192
+ if (
193
+ isSchemaRecord(sanitized) &&
194
+ sanitized.type === undefined &&
195
+ (Array.isArray(sanitized.anyOf) ||
196
+ Array.isArray(sanitized.oneOf) ||
197
+ Array.isArray(sanitized.allOf))
198
+ ) {
199
+ return { ...sanitized, type: 'object' } as RawToolParameters;
200
+ }
201
+ return sanitized as RawToolParameters;
101
202
  }
102
203
 
103
204
  /** How long `execute()` reuses a schema fetched for `latest`, which can change at any release. */
@@ -132,6 +233,9 @@ export class Tools<
132
233
  * Scoped per-instance so a fresh `Composio` starts with a clean slate.
133
234
  */
134
235
  private readonly warnedAutoUploadDisabledForTool = new Set<string>();
236
+ /** Tools whose parameters were dropped by `transformToolCases`; warn once each. */
237
+ private readonly warnedMalformedToolParametersSlugs = new Set<string>();
238
+
135
239
  /**
136
240
  * Schemas `execute()` already fetched, so repeated executions don't each spend a request.
137
241
  * Holds what `getRawComposioToolBySlug` returned with no `modifySchema`, so a caller's schema
@@ -178,21 +282,79 @@ export class Tools<
178
282
  * making them more consistent with JavaScript/TypeScript conventions.
179
283
  *
180
284
  * @param {ToolRetrieveResponse | ComposioToolListResponse['items'][0]} tool - The tool object to transform
181
- * @returns {Tool} The transformed tool with camelCase properties
285
+ * @returns {Tool} The transformed tool with camelCase properties, or
286
+ * `undefined` when its input schema is unrepairable and the tool is skipped
182
287
  *
183
288
  * @private
184
289
  */
185
290
  private transformToolCases(
186
291
  tool: ToolRetrieveResponse | ComposioToolListResponse['items'][0]
187
- ): Tool {
188
- return ToolSchema.parse({
292
+ ): Tool | undefined {
293
+ const candidate = {
189
294
  ...tool,
190
295
  inputParameters: normalizeRawToolParameters(tool.input_parameters),
191
296
  outputParameters: normalizeRawToolParameters(tool.output_parameters),
192
297
  availableVersions: tool.available_versions,
193
298
  isDeprecated: tool.deprecated?.is_deprecated ?? false,
194
299
  isNoAuth: tool.no_auth,
195
- });
300
+ };
301
+
302
+ const parsed = ToolSchema.safeParse(candidate);
303
+ if (parsed.success) return parsed.data;
304
+
305
+ // One malformed schema must not take down a whole toolkit's tool list
306
+ // (#4757). The output side degrades to "no schema"; the input side cannot,
307
+ // because providers build their call schema from it and a tool without one
308
+ // is not callable — @composio/langchain's wrapTool throws
309
+ // "Tool input parameters are not defined", so an unrepairable input schema
310
+ // would fail the provider's whole wrapTools pass one layer later. Such a
311
+ // tool is skipped instead, with the same warning. A failure outside the
312
+ // parameters is genuinely broken data and stays loud — including alongside
313
+ // a parameter failure, where skipping the tool would otherwise hide it.
314
+ const failingSides = new Set<'inputParameters' | 'outputParameters'>();
315
+ let hasNonParameterIssue = false;
316
+ for (const issue of parsed.error.issues) {
317
+ const root = issue.path[0];
318
+ if (root === 'inputParameters' || root === 'outputParameters') {
319
+ failingSides.add(root);
320
+ } else {
321
+ hasNonParameterIssue = true;
322
+ }
323
+ }
324
+ if (hasNonParameterIssue || failingSides.size === 0) throw parsed.error;
325
+
326
+ this.warnMalformedToolParameters(tool, parsed.error, [...failingSides]);
327
+ if (failingSides.has('inputParameters')) return undefined;
328
+ const degradedCandidate = { ...candidate };
329
+ for (const side of failingSides) {
330
+ degradedCandidate[side] = undefined;
331
+ }
332
+ const degraded = ToolSchema.safeParse(degradedCandidate);
333
+ if (degraded.success) return degraded.data;
334
+ throw parsed.error;
335
+ }
336
+
337
+ /**
338
+ * Warn once per tool that its declared parameters could not be parsed and
339
+ * were dropped, so a caller sees why a tool carries no schema instead of a
340
+ * bare TypeError from deep inside Zod.
341
+ */
342
+ private warnMalformedToolParameters(
343
+ tool: ToolRetrieveResponse | ComposioToolListResponse['items'][0],
344
+ error: z.ZodError,
345
+ droppedSides: Array<'inputParameters' | 'outputParameters'>
346
+ ): void {
347
+ const slug = String((tool as { slug?: unknown }).slug ?? '');
348
+ if (slug && this.warnedMalformedToolParametersSlugs.has(slug)) return;
349
+ if (slug) this.warnedMalformedToolParametersSlugs.add(slug);
350
+ const inputFailed = droppedSides.includes('inputParameters');
351
+ logger.warn(
352
+ `Tool "${sanitizeForLog(slug) || '(unknown slug)'}" has ${droppedSides.join(' and ')} that do not ` +
353
+ `match the expected schema, so the tool was ` +
354
+ `${inputFailed ? 'skipped' : 'returned without those parameters'}. ` +
355
+ `${inputFailed ? 'It cannot be offered without an input schema.' : 'The tool still executes, but LLM callers will not see those parameters.'} ` +
356
+ `Issues: ${error.issues.map(issue => `${sanitizeForLog(issue.path.join('.'))}: ${sanitizeForLog(issue.message)}`).join('; ')}`
357
+ );
196
358
  }
197
359
 
198
360
  /**
@@ -555,7 +717,9 @@ export class Tools<
555
717
  if (!tools) {
556
718
  return [];
557
719
  }
558
- const caseTransformedTools = tools.items.map(tool => this.transformToolCases(tool));
720
+ const caseTransformedTools = tools.items
721
+ .map(tool => this.transformToolCases(tool))
722
+ .filter((tool): tool is Tool => tool !== undefined);
559
723
 
560
724
  let modifiedTools = await this.applyDefaultSchemaModifiers(caseTransformedTools);
561
725
 
@@ -612,7 +776,11 @@ export class Tools<
612
776
  () => this.client.toolRouter.session.tools(sessionId, sessionToolsParams, requestOptions),
613
777
  requestOptions?.signal
614
778
  );
615
- tools.push(...response.items.map(tool => this.transformToolCases(tool)));
779
+ tools.push(
780
+ ...response.items
781
+ .map(tool => this.transformToolCases(tool))
782
+ .filter((tool): tool is Tool => tool !== undefined)
783
+ );
616
784
  cursor = response.next_cursor;
617
785
  } while (cursor);
618
786
 
@@ -709,7 +877,10 @@ export class Tools<
709
877
  }
710
878
  if (isRateLimitResponse(error)) {
711
879
  throw new ComposioToolFetchRateLimitError(
712
- `Rate limited while retrieving tool with slug ${slug}`,
880
+ withApiErrorMessage(
881
+ `Rate limited while retrieving tool with slug ${slug}`,
882
+ error.details
883
+ ),
713
884
  error,
714
885
  { slug }
715
886
  );
@@ -718,19 +889,44 @@ export class Tools<
718
889
  // malformed one). Anything else (401, 5xx, network) is not "not found",
719
890
  // so keep the client error reachable as `cause` under a generic error.
720
891
  if (error instanceof APIError && (error.status === 404 || error.status === 400)) {
721
- throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`, {
892
+ throw new ComposioToolNotFoundError(
893
+ withApiErrorMessage(`Tool with slug ${slug} not found`, error.details),
894
+ {
895
+ meta: { slug },
896
+ cause: error,
897
+ possibleFixes: apiErrorSuggestedFixes(error.details),
898
+ }
899
+ );
900
+ }
901
+ const details = error instanceof APIError ? error.details : undefined;
902
+ const originalMessage =
903
+ error instanceof APIError && error.status !== undefined
904
+ ? undefined
905
+ : error instanceof Error
906
+ ? error.message
907
+ : undefined;
908
+ throw new ComposioToolFetchError(
909
+ withApiErrorMessage(`Unable to retrieve tool with slug ${slug}`, details, originalMessage),
910
+ {
722
911
  meta: { slug },
723
912
  cause: error,
724
- });
725
- }
726
- throw new ComposioToolFetchError(`Unable to retrieve tool with slug ${slug}`, {
727
- meta: { slug },
728
- cause: error,
729
- });
913
+ possibleFixes: apiErrorSuggestedFixes(details),
914
+ }
915
+ );
730
916
  }
731
917
 
732
918
  // change the case of the tool to camel case and apply default modifiers
733
- let [modifiedTool] = await this.applyDefaultSchemaModifiers([this.transformToolCases(tool)]);
919
+ const transformedTool = this.transformToolCases(tool);
920
+ if (transformedTool === undefined) {
921
+ // The tool exists; its schema is what could not be parsed. Reporting that
922
+ // as TOOL_NOT_FOUND makes a caller that treats the code as "no such tool"
923
+ // hide a real one.
924
+ throw new ComposioToolSchemaInvalidError(
925
+ `Tool with slug ${slug} has an unusable input schema`,
926
+ { meta: { slug } }
927
+ );
928
+ }
929
+ let [modifiedTool] = await this.applyDefaultSchemaModifiers([transformedTool]);
734
930
  // apply local modifiers if they are provided
735
931
  if (options?.modifySchema) {
736
932
  const modifier = options.modifySchema;
@@ -1282,7 +1478,9 @@ export class Tools<
1282
1478
  withoutRetries(requestOptions)
1283
1479
  ),
1284
1480
  requestOptions?.signal
1285
- );
1481
+ ).catch((error: unknown) => {
1482
+ throw handleToolExecutionError(toolSlug, error as Error);
1483
+ });
1286
1484
 
1287
1485
  const { data, error, logId, resultType, instantCharge } = transformExecuteResponse(
1288
1486
  response,
@@ -451,12 +451,18 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
451
451
  filters: TriggerSubscribeParams,
452
452
  data: IncomingTriggerPayload
453
453
  ): boolean {
454
- // Check if toolkits filter is provided and matches
454
+ // Check if toolkits filter is provided and matches.
455
+ // Payloads don't carry the toolkit slug, so `data.toolkitSlug` is the trigger slug's
456
+ // first `_` segment, which is wrong for toolkits whose slug contains an underscore
457
+ // (`ONE_DRIVE_FILE_CREATED_TRIGGER` gives `ONE`). Trigger slugs start with
458
+ // `<TOOLKIT>_`, so a filter also matches on that prefix.
459
+ const toolkitSlug = data.toolkitSlug.toLowerCase();
460
+ const triggerSlug = data.triggerSlug.toLowerCase();
455
461
  if (
456
462
  filters.toolkits?.length &&
457
463
  !filters.toolkits
458
464
  .map(toolkit => toolkit.toLowerCase())
459
- .includes(data.toolkitSlug.toLowerCase())
465
+ .some(toolkit => toolkit === toolkitSlug || triggerSlug.startsWith(`${toolkit}_`))
460
466
  ) {
461
467
  logger.debug(
462
468
  'Trigger does not match toolkits filter',
@@ -8,7 +8,6 @@ export type CustomToolkitApiKeyField = z.infer<typeof CustomToolkitApiKeyFieldSc
8
8
 
9
9
  /**
10
10
  * How end users authenticate to a custom toolkit.
11
- * **Experimental — custom toolkits are in pilot; shape may change.**
12
11
  */
13
12
  export const CustomToolkitAuthSchemeSchema = z.discriminatedUnion('mode', [
14
13
  z.object({ mode: z.literal('NO_AUTH') }),
@@ -50,8 +49,7 @@ const CustomToolkitLogoFileSchema = z.object({
50
49
  export type CustomToolkitLogoFile = z.infer<typeof CustomToolkitLogoFileSchema>;
51
50
 
52
51
  /**
53
- * Params for `composio.experimental.customToolkits.create()`.
54
- * **Experimental — custom toolkits are in pilot; shape may change.**
52
+ * Params for `composio.customToolkits.create()`.
55
53
  */
56
54
  export const CustomToolkitCreateParamsSchema = z.object({
57
55
  /** Human-readable toolkit name. */
@@ -90,8 +88,7 @@ export const CustomToolkitCreateResponseSchema = z.object({
90
88
  export type CustomToolkitCreateResponse = z.infer<typeof CustomToolkitCreateResponseSchema>;
91
89
 
92
90
  /**
93
- * Params for `composio.experimental.customToolkits.update()`.
94
- * **Experimental — custom toolkits are in pilot; shape may change.**
91
+ * Params for `composio.customToolkits.update()`.
95
92
  */
96
93
  export const CustomToolkitUpdateParamsSchema = z
97
94
  .object({
@@ -117,8 +114,7 @@ export const CustomToolkitUpdateResponseSchema = z.object({
117
114
  export type CustomToolkitUpdateResponse = z.infer<typeof CustomToolkitUpdateResponseSchema>;
118
115
 
119
116
  /**
120
- * Params for `composio.experimental.customToolkits.upsert()`.
121
- * **Experimental — custom toolkits are in pilot; shape may change.**
117
+ * Params for `composio.customToolkits.upsert()`.
122
118
  *
123
119
  * @deprecated Use `CustomToolkitCreateParams` with `create()`.
124
120
  */
@@ -152,8 +148,7 @@ export const CustomToolkitUpsertResponseSchema = z.object({
152
148
  export type CustomToolkitUpsertResponse = z.infer<typeof CustomToolkitUpsertResponseSchema>;
153
149
 
154
150
  /**
155
- * Params for `composio.experimental.customToolkits.sync()`.
156
- * **Experimental — custom toolkits are in pilot; shape may change.**
151
+ * Params for `composio.customToolkits.sync()`.
157
152
  */
158
153
  export const CustomToolkitSyncParamsSchema = z.object({
159
154
  /** Connected account to use when fetching the remote tool definitions. */
@@ -8,7 +8,11 @@ export async function withCancellation<T>(
8
8
  try {
9
9
  return await call();
10
10
  } catch (error) {
11
- if (signal?.aborted && isRequestAbortError(error)) {
11
+ // A raw `fetch` rejects with the signal's reason, so an `AbortSignal.timeout()`
12
+ // surfaces as a `TimeoutError` (or a custom reason passed to `abort()`) that is
13
+ // not abort-shaped. Matching the reason itself still excludes an unrelated
14
+ // failure that merely coincides with a late abort.
15
+ if (signal?.aborted && (isRequestAbortError(error) || error === signal.reason)) {
12
16
  const underlyingMessage = error instanceof Error ? error.message : '';
13
17
  const message = underlyingMessage
14
18
  ? `Request was cancelled by the caller: ${underlyingMessage}`
@@ -1,97 +0,0 @@
1
- import { r as ComposioError } from "./SsrfErrors-DiQldIdC.mjs";
2
-
3
- //#region src/errors/FileModifierErrors.ts
4
- const FileModifierErrorCodes = {
5
- FILE_UPLOAD_FAILED: "FILE_UPLOAD_FAILED",
6
- SENSITIVE_FILE_PATH_BLOCKED: "SENSITIVE_FILE_PATH_BLOCKED",
7
- FILE_UPLOAD_ABORTED: "FILE_UPLOAD_ABORTED",
8
- FILE_UPLOAD_PATH_NOT_ALLOWED: "FILE_UPLOAD_PATH_NOT_ALLOWED",
9
- FILE_NOT_FOUND: "FILE_NOT_FOUND"
10
- };
11
- var ComposioFileUploadError = class extends ComposioError {
12
- constructor(message = "Failed to upload file", options = {}) {
13
- super(message, {
14
- ...options,
15
- code: options.code ?? FileModifierErrorCodes.FILE_UPLOAD_FAILED,
16
- possibleFixes: options.possibleFixes || ["Check if the file exists in the location provided"]
17
- });
18
- this.name = "ComposioFileUploadError";
19
- }
20
- };
21
- /**
22
- * Thrown when a local file path is refused before upload (sensitive directory or
23
- * credential-like file name). Subclass of {@link ComposioFileUploadError} so existing
24
- * `instanceof ComposioFileUploadError` handlers still apply.
25
- */
26
- var ComposioSensitiveFilePathBlockedError = class extends ComposioFileUploadError {
27
- constructor(message, options = {}) {
28
- super(message, {
29
- ...options,
30
- code: FileModifierErrorCodes.SENSITIVE_FILE_PATH_BLOCKED,
31
- possibleFixes: options.possibleFixes ?? [
32
- "Use a file outside ~/.ssh, ~/.aws, and other credential locations",
33
- "Set sensitiveFileUploadProtection: false only if you understand the risk",
34
- "Add path segments to block with fileUploadPathDenySegments"
35
- ]
36
- });
37
- this.name = "ComposioSensitiveFilePathBlockedError";
38
- }
39
- };
40
- /**
41
- * Thrown when a `beforeFileUpload` hook returns `false`.
42
- */
43
- var ComposioFileUploadAbortedError = class extends ComposioFileUploadError {
44
- constructor(message, options = {}) {
45
- super(message, {
46
- ...options,
47
- code: FileModifierErrorCodes.FILE_UPLOAD_ABORTED,
48
- possibleFixes: options.possibleFixes ?? ["Change beforeFileUpload to return a file path to upload, or allow the upload to proceed"]
49
- });
50
- this.name = "ComposioFileUploadAbortedError";
51
- }
52
- };
53
- /**
54
- * Thrown when automatic file upload during tool execution is attempted from a path
55
- * that is outside the configured {@link ComposioConfig.fileUploadDirs} allowlist.
56
- *
57
- * This only fires for auto-upload (enabled via
58
- * `dangerouslyAllowAutoUploadDownloadFiles: true`). Manual `composio.files.upload()`
59
- * calls are never subject to this check.
60
- */
61
- var ComposioFileUploadPathNotAllowedError = class extends ComposioFileUploadError {
62
- constructor(message, options = {}) {
63
- super(message, {
64
- ...options,
65
- code: FileModifierErrorCodes.FILE_UPLOAD_PATH_NOT_ALLOWED,
66
- possibleFixes: options.possibleFixes ?? [
67
- "Move the file under one of the directories in `fileUploadDirs`",
68
- "Stage the file under the default upload dir (`~/.composio/temp`)",
69
- "Add the containing directory to `fileUploadDirs` when constructing Composio",
70
- "Pass the file by URL or as a File/Blob object instead of a filesystem path"
71
- ]
72
- });
73
- this.name = "ComposioFileUploadPathNotAllowedError";
74
- }
75
- };
76
- /**
77
- * Thrown when a local file path passed for upload does not exist on disk.
78
- * Provides extra debugging context (resolved absolute path, cwd, allowlist state)
79
- * to help the caller distinguish between "typo" and "not-allowlisted" failures.
80
- */
81
- var ComposioFileNotFoundError = class extends ComposioFileUploadError {
82
- constructor(message, options = {}) {
83
- super(message, {
84
- ...options,
85
- code: FileModifierErrorCodes.FILE_NOT_FOUND,
86
- possibleFixes: options.possibleFixes ?? [
87
- "Double-check the path for typos",
88
- "Remember relative paths are resolved against process.cwd() at upload time",
89
- "Verify the file exists and the process has read permission"
90
- ]
91
- });
92
- this.name = "ComposioFileNotFoundError";
93
- }
94
- };
95
-
96
- //#endregion
97
- export { ComposioSensitiveFilePathBlockedError as a, ComposioFileUploadPathNotAllowedError as i, ComposioFileUploadAbortedError as n, FileModifierErrorCodes as o, ComposioFileUploadError as r, ComposioFileNotFoundError as t };
@@ -1,18 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __exportAll = (all, no_symbols) => {
4
- let target = {};
5
- for (var name in all) {
6
- __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- }
11
- if (!no_symbols) {
12
- __defProp(target, Symbol.toStringTag, { value: "Module" });
13
- }
14
- return target;
15
- };
16
-
17
- //#endregion
18
- export { __exportAll as t };
@@ -1,17 +0,0 @@
1
- import type {
2
- SessionExecuteParams,
3
- SessionSearchParams,
4
- } from '@composio/client/resources/tool-router/session';
5
- import type { InlineCustomToolsWirePayload } from '../types/customTool.types';
6
-
7
- type InlineCustomToolsExperimental =
8
- | NonNullable<SessionExecuteParams['experimental']>
9
- | NonNullable<SessionSearchParams['experimental']>;
10
-
11
- export function inlineCustomToolsExperimental<TExperimental extends InlineCustomToolsExperimental>(
12
- payload?: InlineCustomToolsWirePayload
13
- ): TExperimental | undefined {
14
- // Stainless generates endpoint-specific experimental types with the same custom
15
- // definition shape, so this helper centralizes the structural cast.
16
- return payload as TExperimental | undefined;
17
- }