@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.
- package/dist/{CustomTool-l-j5HtEf.mjs → CustomTool-CM-roKk7.mjs} +16 -6
- package/dist/{CustomTool-CwpeQhz2.d.mts → CustomTool-yMQjEyMz.d.mts} +1 -1
- package/dist/{FileModifierErrors-B8V8_3VE.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
- package/dist/{FileToolModifier.utils.neutral-D_YkHwZP.mjs → FileToolModifier.utils.neutral-DWFpnsj2.mjs} +4 -2
- package/dist/{SsrfErrors-DNJt57GL.mjs → SsrfErrors-DiQldIdC.mjs} +154 -19
- package/dist/{Telemetry-DK1uAWnD.mjs → Telemetry-JRJJYS4I.mjs} +28 -44
- package/dist/cancellation-BEpFk2S8.mjs +706 -0
- package/dist/{composio-XjF7EMEe.d.mts → composio-BVNJTVYa.d.mts} +2450 -119
- package/dist/{customTool.types-DpJbYY5m.d.mts → customTool.types-CY5SXFfF.d.mts} +143 -28
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +1 -1
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +4 -3
- package/dist/{errors-BcEUHZbq.mjs → errors-CvZjP9CH.mjs} +42 -4
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-BwpUOF0s.mjs → fileUtils.node-HQsywtTj.mjs} +11 -9
- package/dist/index.d.mts +393 -142
- package/dist/index.mjs +1945 -171
- package/dist/models/Files.node.d.mts +2 -3
- package/dist/models/Files.node.mjs +2 -2
- package/dist/models/Files.workerd.d.mts +2 -3
- package/dist/platform/node.d.mts +2 -3
- package/dist/platform/workerd.d.mts +2 -3
- package/dist/{sensitiveFileUploadPaths-B0w8dqpv.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +10 -7
- package/dist/{ssrfGuard.node-DlxO8uzr.mjs → ssrfGuard.node-BK50mYTq.mjs} +187 -24
- package/dist/{types-C9kJAurw.d.mts → types-CqGfjlZg.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +3 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.mjs +6 -6
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/dist/utils/ssrfGuard.node.d.mts +7 -7
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.d.mts +3 -4
- package/dist/utils/ssrfGuard.workerd.mjs +2 -2
- package/package.json +25 -7
- package/src/composio.ts +86 -2
- package/src/errors/ConnectedAccountsErrors.ts +47 -0
- package/src/errors/ToolErrors.ts +1 -0
- package/src/errors/ValidationErrors.ts +2 -0
- package/src/index.ts +21 -0
- package/src/models/ConnectedAccounts.ts +118 -2
- package/src/models/CustomTool.ts +41 -6
- package/src/models/CustomToolkits.ts +169 -0
- package/src/models/Experimental.ts +27 -0
- package/src/models/Keyring.ts +65 -0
- package/src/models/Logs.ts +101 -0
- package/src/models/RemoteFile.ts +54 -36
- package/src/models/ToolRouterSession.ts +60 -4
- package/src/models/Toolkits.ts +180 -0
- package/src/models/Tools.ts +3 -1
- package/src/models/Triggers.ts +17 -87
- package/src/models/Usage.ts +119 -0
- package/src/models/Webhooks.ts +520 -0
- package/src/services/telemetry/TelemetryService.ts +27 -12
- package/src/telemetry/redact.ts +133 -6
- package/src/types/authConfigs.types.ts +2 -0
- package/src/types/connectedAccounts.types.ts +54 -0
- package/src/types/customToolkits.types.ts +102 -0
- package/src/types/keyring.types.ts +32 -0
- package/src/types/logs.types.ts +108 -0
- package/src/types/toolRouter.types.ts +49 -1
- package/src/types/toolkit.types.ts +131 -0
- package/src/types/usage.types.ts +81 -0
- package/src/types/webhooks.types.ts +143 -0
- package/src/utils/constants.ts +1 -5
- package/src/utils/fileUtils.node.ts +10 -2
- package/src/utils/jsonSchema.ts +509 -28
- package/src/utils/logger.ts +45 -13
- package/src/utils/pinnedDispatcher.node.ts +109 -13
- package/src/utils/sdk.ts +1 -1
- package/src/utils/ssrfGuard.node.ts +124 -21
- package/src/utils/ssrfGuard.workerd.ts +5 -1
- package/src/utils/transformers/connectedAccounts.ts +37 -2
- package/src/utils/transformers/customToolkits.ts +98 -0
- package/src/utils/transformers/keyring.ts +24 -0
- package/src/utils/transformers/logs.ts +85 -0
- package/src/utils/transformers/toolkits.ts +100 -1
- package/src/utils/transformers/triggers.ts +2 -2
- package/src/utils/transformers/usage.ts +77 -0
- package/src/utils/transformers/webhooks.ts +139 -0
- package/dist/cancellation-C-qy8rcj.mjs +0 -364
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+
import { i as logger } from "./SsrfErrors-DiQldIdC.mjs";
|
|
2
|
+
import { f as ComposioRequestCancelledError, g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError, m as isRequestAbortError } from "./errors-CvZjP9CH.mjs";
|
|
3
|
+
import { o as isPlainObject } from "./FileToolModifier.utils.neutral-DWFpnsj2.mjs";
|
|
4
|
+
import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
|
|
5
|
+
|
|
6
|
+
//#region src/utils/jsonSchema.ts
|
|
7
|
+
const MAX_REF_CHAIN_DEPTH = 100;
|
|
8
|
+
const MAX_NODE_DEPTH = 512;
|
|
9
|
+
const CYCLE_BREAK_SENTINEL = {
|
|
10
|
+
type: "object",
|
|
11
|
+
additionalProperties: true
|
|
12
|
+
};
|
|
13
|
+
/** Keywords whose value is a single subschema. */
|
|
14
|
+
const SCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
|
|
15
|
+
"additionalItems",
|
|
16
|
+
"additionalProperties",
|
|
17
|
+
"contains",
|
|
18
|
+
"contentSchema",
|
|
19
|
+
"else",
|
|
20
|
+
"if",
|
|
21
|
+
"not",
|
|
22
|
+
"propertyNames",
|
|
23
|
+
"then",
|
|
24
|
+
"unevaluatedItems",
|
|
25
|
+
"unevaluatedProperties"
|
|
26
|
+
]);
|
|
27
|
+
/** Keywords whose value is an array of subschemas. */
|
|
28
|
+
const SCHEMA_ARRAY_KEYWORDS = /* @__PURE__ */ new Set([
|
|
29
|
+
"allOf",
|
|
30
|
+
"anyOf",
|
|
31
|
+
"oneOf",
|
|
32
|
+
"prefixItems"
|
|
33
|
+
]);
|
|
34
|
+
/** Keywords whose value is a map from name to subschema. */
|
|
35
|
+
const SCHEMA_MAP_KEYWORDS = /* @__PURE__ */ new Set([
|
|
36
|
+
"$defs",
|
|
37
|
+
"definitions",
|
|
38
|
+
"dependentSchemas",
|
|
39
|
+
"patternProperties",
|
|
40
|
+
"properties"
|
|
41
|
+
]);
|
|
42
|
+
/** Keywords whose values are instance data, never subschemas. */
|
|
43
|
+
const INSTANCE_VALUE_KEYWORDS = /* @__PURE__ */ new Set([
|
|
44
|
+
"const",
|
|
45
|
+
"default",
|
|
46
|
+
"enum",
|
|
47
|
+
"examples"
|
|
48
|
+
]);
|
|
49
|
+
/**
|
|
50
|
+
* In-band hint attached to the cycle-break sentinel when lenient mode
|
|
51
|
+
* substitutes it for a dangling `$ref`. Makes the degradation visible to
|
|
52
|
+
* LLMs that read the wrapped tool's schema — without it the LLM sees a
|
|
53
|
+
* useless permissive object and no prose context. Wording is intentionally
|
|
54
|
+
* context-neutral ("Schema shape", not "Output shape") because the helper
|
|
55
|
+
* is used for both `inputParameters` and `outputParameters`. Overridden
|
|
56
|
+
* when the caller's `$ref` node carries its own `description` sibling
|
|
57
|
+
* (Draft 2020-12 sibling-keyword semantics).
|
|
58
|
+
*/
|
|
59
|
+
const UNRESOLVED_REF_DESCRIPTION = "Schema shape unresolved at the source — validate loosely. See https://github.com/ComposioHQ/composio/issues/3307.";
|
|
60
|
+
const POLLUTING_KEYS = /* @__PURE__ */ new Set([
|
|
61
|
+
"__proto__",
|
|
62
|
+
"constructor",
|
|
63
|
+
"prototype"
|
|
64
|
+
]);
|
|
65
|
+
const REF_RESOLUTION_FIXES = ["Ensure the $ref pointer matches a path in $defs or definitions", "External $ref pointers (http://, https://, file://, …) are not resolved by the SDK"];
|
|
66
|
+
const decodePointerSegment = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
67
|
+
const tryStep = (cursor, segment) => {
|
|
68
|
+
if (cursor === null || typeof cursor !== "object") return {
|
|
69
|
+
kind: "unresolved",
|
|
70
|
+
reason: "missing-target",
|
|
71
|
+
failedAt: segment
|
|
72
|
+
};
|
|
73
|
+
if (Array.isArray(cursor)) {
|
|
74
|
+
const i = Number(segment);
|
|
75
|
+
if (!Number.isInteger(i) || i < 0 || i >= cursor.length) return {
|
|
76
|
+
kind: "unresolved",
|
|
77
|
+
reason: "missing-target",
|
|
78
|
+
failedAt: segment
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
kind: "ok",
|
|
82
|
+
value: cursor[i]
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const obj = cursor;
|
|
86
|
+
if (!Object.prototype.hasOwnProperty.call(obj, segment)) return {
|
|
87
|
+
kind: "unresolved",
|
|
88
|
+
reason: "missing-target",
|
|
89
|
+
failedAt: segment
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
kind: "ok",
|
|
93
|
+
value: obj[segment]
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
const tryResolvePointer = (root, pointer) => {
|
|
97
|
+
if (pointer === "#" || pointer === "") return {
|
|
98
|
+
kind: "ok",
|
|
99
|
+
value: root
|
|
100
|
+
};
|
|
101
|
+
if (!pointer.startsWith("#/")) return {
|
|
102
|
+
kind: "unresolved",
|
|
103
|
+
reason: "malformed-pointer"
|
|
104
|
+
};
|
|
105
|
+
const segments = pointer.slice(2).split("/").map(decodePointerSegment);
|
|
106
|
+
let cursor = root;
|
|
107
|
+
for (const seg of segments) {
|
|
108
|
+
const step = tryStep(cursor, seg);
|
|
109
|
+
if (step.kind === "unresolved") return step;
|
|
110
|
+
cursor = step.value;
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
kind: "ok",
|
|
114
|
+
value: cursor
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
const throwResolutionError = (pointer, result) => {
|
|
118
|
+
if (result.reason === "malformed-pointer") throw new JsonSchemaRefResolutionError(`Unsupported $ref pointer: ${pointer}`, {
|
|
119
|
+
meta: { ref: pointer },
|
|
120
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
121
|
+
});
|
|
122
|
+
throw new JsonSchemaRefResolutionError(`Cannot resolve $ref ${pointer}`, {
|
|
123
|
+
meta: {
|
|
124
|
+
ref: pointer,
|
|
125
|
+
...result.failedAt !== void 0 ? { failedAt: result.failedAt } : {}
|
|
126
|
+
},
|
|
127
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Inlines internal JSON Schema `$ref` pointers (`#/$defs/...` and legacy
|
|
132
|
+
* `#/definitions/...`) so the returned schema can be safely handed to
|
|
133
|
+
* consumers that don't tolerate unresolved references (e.g. AJV in
|
|
134
|
+
* `@mastra/schema-compat`). External (`http://`, `https://`, …) refs are
|
|
135
|
+
* left untouched. Cycles are broken with `{ type: 'object',
|
|
136
|
+
* additionalProperties: true }`. The input is never mutated.
|
|
137
|
+
*
|
|
138
|
+
* By default, unresolved internal refs throw `JsonSchemaRefResolutionError`.
|
|
139
|
+
* Pass `{ onUnresolved: 'sentinel' }` to replace the offending node with the
|
|
140
|
+
* cycle-break sentinel instead — appropriate for schemas sourced from an
|
|
141
|
+
* upstream service the caller cannot edit (the Composio API ships some
|
|
142
|
+
* `outputParameters` with a `$ref` into `#/$defs/...` but never declares
|
|
143
|
+
* `$defs`; see https://github.com/ComposioHQ/composio/issues/3307).
|
|
144
|
+
*
|
|
145
|
+
* @throws {JsonSchemaRefResolutionError} on malformed pointers, missing
|
|
146
|
+
* targets (strict mode only), or chains past the depth cap (both modes).
|
|
147
|
+
*/
|
|
148
|
+
function dereferenceJsonSchema(schema, options) {
|
|
149
|
+
if (!isPlainObject(schema)) return schema;
|
|
150
|
+
const strategy = options?.onUnresolved ?? "throw";
|
|
151
|
+
const onReplace = options?.onReplace;
|
|
152
|
+
const root = schema;
|
|
153
|
+
const visiting = /* @__PURE__ */ new WeakSet();
|
|
154
|
+
const cloneChildren = (obj, visitedRefs, chainDepth, nodeDepth) => Object.fromEntries(Object.entries(obj).filter(([k]) => !POLLUTING_KEYS.has(k)).map(([k, v]) => [k, walk(v, visitedRefs, chainDepth, nodeDepth + 1)]));
|
|
155
|
+
function walk(node, visitedRefs, chainDepth, nodeDepth) {
|
|
156
|
+
if (nodeDepth >= MAX_NODE_DEPTH) throw new JsonSchemaRefResolutionError(`JSON Schema node depth exceeded cap (${MAX_NODE_DEPTH})`, { possibleFixes: REF_RESOLUTION_FIXES });
|
|
157
|
+
if (Array.isArray(node)) {
|
|
158
|
+
if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };
|
|
159
|
+
visiting.add(node);
|
|
160
|
+
try {
|
|
161
|
+
return node.map((item) => walk(item, visitedRefs, chainDepth, nodeDepth + 1));
|
|
162
|
+
} finally {
|
|
163
|
+
visiting.delete(node);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (!isPlainObject(node)) return node;
|
|
167
|
+
if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };
|
|
168
|
+
visiting.add(node);
|
|
169
|
+
try {
|
|
170
|
+
const ref = typeof node.$ref === "string" ? node.$ref : null;
|
|
171
|
+
if (ref === null || !ref.startsWith("#")) {
|
|
172
|
+
if (ref !== null) logger.warn(`Leaving external $ref untouched: ${ref}`);
|
|
173
|
+
return cloneChildren(node, visitedRefs, chainDepth, nodeDepth);
|
|
174
|
+
}
|
|
175
|
+
if (chainDepth >= MAX_REF_CHAIN_DEPTH) throw new JsonSchemaRefResolutionError(`JSON Schema $ref chain exceeded depth cap (${MAX_REF_CHAIN_DEPTH}): ${ref}`, {
|
|
176
|
+
meta: { ref },
|
|
177
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
178
|
+
});
|
|
179
|
+
if (visitedRefs.has(ref)) return { ...CYCLE_BREAK_SENTINEL };
|
|
180
|
+
const result = tryResolvePointer(root, ref);
|
|
181
|
+
let target;
|
|
182
|
+
if (result.kind === "ok") target = result.value;
|
|
183
|
+
else if (strategy === "sentinel") {
|
|
184
|
+
onReplace?.(ref, result.reason);
|
|
185
|
+
target = {
|
|
186
|
+
...CYCLE_BREAK_SENTINEL,
|
|
187
|
+
description: UNRESOLVED_REF_DESCRIPTION
|
|
188
|
+
};
|
|
189
|
+
} else throwResolutionError(ref, result);
|
|
190
|
+
const nextRefs = new Set(visitedRefs).add(ref);
|
|
191
|
+
const resolved = walk(target, nextRefs, chainDepth + 1, nodeDepth + 1);
|
|
192
|
+
const siblings = { ...node };
|
|
193
|
+
delete siblings.$ref;
|
|
194
|
+
if (Object.keys(siblings).length === 0 || !isPlainObject(resolved)) return resolved;
|
|
195
|
+
return {
|
|
196
|
+
...resolved,
|
|
197
|
+
...cloneChildren(siblings, visitedRefs, chainDepth, nodeDepth)
|
|
198
|
+
};
|
|
199
|
+
} finally {
|
|
200
|
+
visiting.delete(node);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const out = walk(root, /* @__PURE__ */ new Set(), 0, 0);
|
|
204
|
+
if (isPlainObject(out)) {
|
|
205
|
+
delete out.$defs;
|
|
206
|
+
delete out.definitions;
|
|
207
|
+
}
|
|
208
|
+
return out;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Returns a deep-cloned JSON Schema in which every node that carries a
|
|
212
|
+
* `properties` keyword also carries `type: "object"` when it has no explicit
|
|
213
|
+
* `type`. OpenAI tolerates the omission, but Google Gemini enforces OpenAPI
|
|
214
|
+
* 3.0 strictly and rejects function declarations whose nested objects are
|
|
215
|
+
* missing the `type` (see https://github.com/ComposioHQ/composio/issues/4022).
|
|
216
|
+
*
|
|
217
|
+
* The function follows JSON Schema's schema-bearing keywords while keeping
|
|
218
|
+
* property maps and instance values as containers. Nodes that already declare
|
|
219
|
+
* a `type` are left untouched.
|
|
220
|
+
*/
|
|
221
|
+
function ensureObjectTypeOnProperties(schema) {
|
|
222
|
+
function walk(value, mode, depth = 0) {
|
|
223
|
+
if (depth > MAX_NODE_DEPTH) throw new RangeError(`JSON Schema exceeds maximum nesting depth of ${MAX_NODE_DEPTH}`);
|
|
224
|
+
if (Array.isArray(value)) {
|
|
225
|
+
const itemMode = mode === "schema-array" ? "schema" : "value";
|
|
226
|
+
return value.map((item) => walk(item, itemMode, depth + 1));
|
|
227
|
+
}
|
|
228
|
+
if (!isPlainObject(value)) return value;
|
|
229
|
+
const clone = {};
|
|
230
|
+
for (const [key, child] of Object.entries(value)) {
|
|
231
|
+
let childMode = "value";
|
|
232
|
+
if (mode === "schema-map") childMode = "schema";
|
|
233
|
+
else if (mode === "dependencies-map") childMode = Array.isArray(child) ? "value" : "schema";
|
|
234
|
+
else if (mode === "schema") {
|
|
235
|
+
if (SCHEMA_MAP_KEYWORDS.has(key)) childMode = "schema-map";
|
|
236
|
+
else if (SCHEMA_ARRAY_KEYWORDS.has(key) || key === "items" && Array.isArray(child)) childMode = "schema-array";
|
|
237
|
+
else if (SCHEMA_KEYWORDS.has(key) || key === "items") childMode = "schema";
|
|
238
|
+
else if (key === "dependencies") childMode = "dependencies-map";
|
|
239
|
+
}
|
|
240
|
+
Object.defineProperty(clone, key, {
|
|
241
|
+
configurable: true,
|
|
242
|
+
enumerable: true,
|
|
243
|
+
value: walk(child, childMode, depth + 1),
|
|
244
|
+
writable: true
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
if (mode === "schema" && clone.properties !== void 0 && clone.type === void 0) clone.type = "object";
|
|
248
|
+
return clone;
|
|
249
|
+
}
|
|
250
|
+
return walk(schema, "schema");
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Returns a deep-cloned JSON Schema whose `required` arrays contain each entry
|
|
254
|
+
* at most once. Duplicate entries are invalid in JSON Schema 2020-12 but do
|
|
255
|
+
* not change the schema's meaning, so preserving the first occurrence is safe.
|
|
256
|
+
*
|
|
257
|
+
* Tool schemas originate both from the Composio API and direct provider calls.
|
|
258
|
+
* Keeping this normalization provider-agnostic lets every SDK provider receive
|
|
259
|
+
* canonical API schemas, while providers that further transform a schema can
|
|
260
|
+
* reapply it at their own emission boundary.
|
|
261
|
+
*/
|
|
262
|
+
function deduplicateJsonSchemaRequiredArrays(schema) {
|
|
263
|
+
const seenSchemaValues = /* @__PURE__ */ new WeakMap();
|
|
264
|
+
const seenInstanceValues = /* @__PURE__ */ new WeakMap();
|
|
265
|
+
function walk(value, isSchema, depth = 0) {
|
|
266
|
+
if (depth > MAX_NODE_DEPTH) throw new RangeError(`JSON Schema exceeds maximum nesting depth of ${MAX_NODE_DEPTH}`);
|
|
267
|
+
const seen = isSchema ? seenSchemaValues : seenInstanceValues;
|
|
268
|
+
if (Array.isArray(value)) {
|
|
269
|
+
const existing = seen.get(value);
|
|
270
|
+
if (existing) return existing;
|
|
271
|
+
const clone = [];
|
|
272
|
+
seen.set(value, clone);
|
|
273
|
+
for (const item of value) clone.push(walk(item, isSchema, depth + 1));
|
|
274
|
+
return clone;
|
|
275
|
+
}
|
|
276
|
+
if (!isPlainObject(value)) return value;
|
|
277
|
+
const existing = seen.get(value);
|
|
278
|
+
if (existing) return existing;
|
|
279
|
+
const clone = {};
|
|
280
|
+
seen.set(value, clone);
|
|
281
|
+
for (const [key, child] of Object.entries(value)) Object.defineProperty(clone, key, {
|
|
282
|
+
configurable: true,
|
|
283
|
+
enumerable: true,
|
|
284
|
+
value: isSchema && key === "required" && Array.isArray(child) ? [...new Set(walk(child, false, depth + 1))] : walk(child, isSchema && !INSTANCE_VALUE_KEYWORDS.has(key), depth + 1),
|
|
285
|
+
writable: true
|
|
286
|
+
});
|
|
287
|
+
return clone;
|
|
288
|
+
}
|
|
289
|
+
return walk(schema, true);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Removes all non-required properties from the schema
|
|
293
|
+
*
|
|
294
|
+
* if no items are required, the schema is returned as is
|
|
295
|
+
* @param schema - The JSON schema to remove non-required properties from
|
|
296
|
+
* @returns The JSON schema with all non-required properties removed
|
|
297
|
+
*/
|
|
298
|
+
const removeNonRequiredProperties = (schema) => {
|
|
299
|
+
if (schema && schema.type === "object" && schema.required?.length) schema.properties = Object.fromEntries(Object.entries(schema.properties || {}).filter(([key]) => schema.required.includes(key)));
|
|
300
|
+
schema.additionalProperties = false;
|
|
301
|
+
return schema;
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Convert a JSON schema to a Zod schema
|
|
305
|
+
* @param jsonSchema - The JSON schema to convert
|
|
306
|
+
* @param strict - Eliminates all non-required properties from the schema
|
|
307
|
+
* @returns The Zod schema
|
|
308
|
+
*
|
|
309
|
+
* @throws {JsonSchemaToZodError} If the JSON schema is invalid
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```ts
|
|
313
|
+
* const zodSchema = jsonSchemaToZodSchema({
|
|
314
|
+
* type: 'object',
|
|
315
|
+
* properties: {
|
|
316
|
+
* name: { type: 'string' },
|
|
317
|
+
* },
|
|
318
|
+
* });
|
|
319
|
+
*
|
|
320
|
+
* console.log(zodSchema);
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```ts
|
|
325
|
+
* const zodSchema = jsonSchemaToZodSchema({
|
|
326
|
+
* type: 'object',
|
|
327
|
+
* properties: {
|
|
328
|
+
* name: { type: 'string' },
|
|
329
|
+
* age: { type: 'number' },
|
|
330
|
+
* },
|
|
331
|
+
* required: ['name'],
|
|
332
|
+
* }, { strict: true });
|
|
333
|
+
*
|
|
334
|
+
* console.log(zodSchema);
|
|
335
|
+
*
|
|
336
|
+
* // Output:
|
|
337
|
+
* // z.object({
|
|
338
|
+
* // name: z.string(),
|
|
339
|
+
* // })
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
function jsonSchemaToZodSchema(jsonSchema, { strict } = { strict: false }) {
|
|
343
|
+
try {
|
|
344
|
+
let schema = jsonSchema;
|
|
345
|
+
if (strict && schema) schema = removeNonRequiredProperties(schema);
|
|
346
|
+
return jsonSchemaToZod(schema);
|
|
347
|
+
} catch (error) {
|
|
348
|
+
const detail = error instanceof Error ? `: ${error.message}` : "";
|
|
349
|
+
throw new JsonSchemaToZodError(`Failed to convert JSON Schema to Zod Schema${detail}`, { cause: error });
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const MAX_STRICT_CHANGES = 50;
|
|
353
|
+
/** Annotation-only keywords OpenAI structured outputs rejects; safe to strip. */
|
|
354
|
+
const STRICT_STRIP_KEYWORDS = /* @__PURE__ */ new Set(["examples", "default"]);
|
|
355
|
+
/** Keywords OpenAI structured outputs reject and that have no lossless rewrite. */
|
|
356
|
+
const STRICT_UNSUPPORTED_KEYWORDS = [
|
|
357
|
+
"allOf",
|
|
358
|
+
"prefixItems",
|
|
359
|
+
"additionalItems",
|
|
360
|
+
"contains",
|
|
361
|
+
"dependencies",
|
|
362
|
+
"dependentSchemas",
|
|
363
|
+
"else",
|
|
364
|
+
"if",
|
|
365
|
+
"not",
|
|
366
|
+
"propertyNames",
|
|
367
|
+
"then",
|
|
368
|
+
"unevaluatedItems",
|
|
369
|
+
"unevaluatedProperties"
|
|
370
|
+
];
|
|
371
|
+
/** Whether a `type` value declares exactly the object type. */
|
|
372
|
+
const isObjectType = (type) => type === "object" || Array.isArray(type) && type.length === 1 && type[0] === "object";
|
|
373
|
+
const joinPath = (parent, key) => parent ? `${parent}.${key}` : key;
|
|
374
|
+
/**
|
|
375
|
+
* Sets an own property regardless of its name: a plain assignment to a key
|
|
376
|
+
* such as `__proto__` would set the prototype instead of storing the value.
|
|
377
|
+
*/
|
|
378
|
+
function setOwn(target, key, value) {
|
|
379
|
+
Object.defineProperty(target, key, {
|
|
380
|
+
configurable: true,
|
|
381
|
+
enumerable: true,
|
|
382
|
+
value,
|
|
383
|
+
writable: true
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Widens a property schema so that `null` is an accepted value, without
|
|
388
|
+
* placing `type` beside `anyOf` (the API rejects that combination).
|
|
389
|
+
*/
|
|
390
|
+
function widenToNullable(node) {
|
|
391
|
+
if (Array.isArray(node.anyOf)) return node.anyOf.some((branch) => isPlainObject(branch) && branch.type === "null") ? node : {
|
|
392
|
+
...node,
|
|
393
|
+
anyOf: [...node.anyOf, { type: "null" }]
|
|
394
|
+
};
|
|
395
|
+
if (typeof node.type === "string") return node.type === "null" ? node : {
|
|
396
|
+
...node,
|
|
397
|
+
type: [node.type, "null"]
|
|
398
|
+
};
|
|
399
|
+
if (Array.isArray(node.type)) return node.type.includes("null") ? node : {
|
|
400
|
+
...node,
|
|
401
|
+
type: [...node.type, "null"]
|
|
402
|
+
};
|
|
403
|
+
if (Array.isArray(node.enum) && node.enum.includes(null) || node.const === null) return node;
|
|
404
|
+
const { description, title, ...rest } = node;
|
|
405
|
+
if (Object.keys(rest).length === 0) return node;
|
|
406
|
+
return {
|
|
407
|
+
...description !== void 0 ? { description } : {},
|
|
408
|
+
...title !== void 0 ? { title } : {},
|
|
409
|
+
anyOf: [rest, { type: "null" }]
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Follows local `$ref` pointers from `node` until a concrete schema node is
|
|
414
|
+
* reached. Unresolvable or over-long chains return the last node seen.
|
|
415
|
+
*/
|
|
416
|
+
function resolveLocalRefs(node, root) {
|
|
417
|
+
let current = node;
|
|
418
|
+
for (let hops = 0; hops < MAX_REF_CHAIN_DEPTH; hops++) {
|
|
419
|
+
if (!isPlainObject(current) || typeof current.$ref !== "string") return current;
|
|
420
|
+
const resolution = tryResolvePointer(root, current.$ref);
|
|
421
|
+
if (resolution.kind === "unresolved") return current;
|
|
422
|
+
current = resolution.value;
|
|
423
|
+
}
|
|
424
|
+
return current;
|
|
425
|
+
}
|
|
426
|
+
/** Whether a schema node accepts `null` as an instance. */
|
|
427
|
+
function schemaAcceptsNull(schema, root) {
|
|
428
|
+
const node = resolveLocalRefs(schema, root);
|
|
429
|
+
if (!isPlainObject(node)) return true;
|
|
430
|
+
if (typeof node.type === "string") return node.type === "null";
|
|
431
|
+
if (Array.isArray(node.type)) return node.type.includes("null");
|
|
432
|
+
if (Array.isArray(node.enum)) return node.enum.includes(null);
|
|
433
|
+
if ("const" in node) return node.const === null;
|
|
434
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
435
|
+
const branches = node[keyword];
|
|
436
|
+
if (Array.isArray(branches)) return branches.some((branch) => schemaAcceptsNull(branch, root));
|
|
437
|
+
}
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Normalizes a tool parameter schema for OpenAI structured outputs
|
|
442
|
+
* (`strict: true`) at every depth, following the contract OpenAI documents:
|
|
443
|
+
*
|
|
444
|
+
* - every object lists all of its properties in `required` and sets
|
|
445
|
+
* `additionalProperties: false`;
|
|
446
|
+
* - properties that were optional stay available and are widened to accept
|
|
447
|
+
* `null` (`type: ['string', 'null']`, or an extra `anyOf` branch) — the
|
|
448
|
+
* documented way to emulate optional fields. Nothing is dropped, so the
|
|
449
|
+
* model keeps every parameter it could pass before. A `null` the model
|
|
450
|
+
* sends for such a property means "omitted"; the strict providers drop it
|
|
451
|
+
* before executing the tool (see {@link omitNullToolArguments});
|
|
452
|
+
* - `type` arrays are kept as-is (the API accepts them); `oneOf` becomes
|
|
453
|
+
* `anyOf`; `default` and `examples` are stripped;
|
|
454
|
+
* - local `$ref`s into `$defs`/`definitions` are kept (the API supports
|
|
455
|
+
* them, including recursion) and the definitions themselves are
|
|
456
|
+
* normalized; an optional `$ref` property is widened with an `anyOf`
|
|
457
|
+
* null branch;
|
|
458
|
+
* - constructs strict mode cannot express — objects that accept arbitrary
|
|
459
|
+
* keys (schema-valued or `true` `additionalProperties`, `patternProperties`,
|
|
460
|
+
* property-less free-form objects), boolean subschemas, `allOf`,
|
|
461
|
+
* `prefixItems`, tuple-form `items`, conditional and dependency keywords,
|
|
462
|
+
* external or dangling `$ref`s, and a non-object root — are reported in
|
|
463
|
+
* `unsupported` rather than rewritten into something narrower. Callers send
|
|
464
|
+
* such a tool without strict mode.
|
|
465
|
+
*
|
|
466
|
+
* The input is never mutated. Every rewrite is recorded in `changes` (capped
|
|
467
|
+
* at 50 entries; `totalChanges` carries the real count), and `required`
|
|
468
|
+
* arrays are de-duplicated at the end.
|
|
469
|
+
*/
|
|
470
|
+
function toStrictJsonSchema(schema) {
|
|
471
|
+
const changes = [];
|
|
472
|
+
const unsupported = [];
|
|
473
|
+
let totalChanges = 0;
|
|
474
|
+
const recordChange = (change) => {
|
|
475
|
+
totalChanges += 1;
|
|
476
|
+
if (changes.length < MAX_STRICT_CHANGES) changes.push(change);
|
|
477
|
+
};
|
|
478
|
+
const root = isPlainObject(schema) ? schema : {};
|
|
479
|
+
function walkChildren(node, mode, depth, path) {
|
|
480
|
+
const clone = {};
|
|
481
|
+
for (const [key, child] of Object.entries(node)) {
|
|
482
|
+
let childMode = "value";
|
|
483
|
+
if (mode === "schema-map") childMode = "schema";
|
|
484
|
+
else if (mode === "schema" && !INSTANCE_VALUE_KEYWORDS.has(key)) {
|
|
485
|
+
if (SCHEMA_MAP_KEYWORDS.has(key)) childMode = "schema-map";
|
|
486
|
+
else if (SCHEMA_ARRAY_KEYWORDS.has(key) || key === "items" && Array.isArray(child)) childMode = "schema-array";
|
|
487
|
+
else if (SCHEMA_KEYWORDS.has(key) || key === "items") childMode = "schema";
|
|
488
|
+
}
|
|
489
|
+
if (childMode === "schema-map" && isPlainObject(child)) {
|
|
490
|
+
const mapClone = {};
|
|
491
|
+
for (const [name, subSchema] of Object.entries(child)) setOwn(mapClone, name, walk(subSchema, "schema", depth + 1, joinPath(joinPath(path, key), name)));
|
|
492
|
+
setOwn(clone, key, mapClone);
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
setOwn(clone, key, walk(child, childMode, depth + 1, joinPath(path, key)));
|
|
496
|
+
}
|
|
497
|
+
return clone;
|
|
498
|
+
}
|
|
499
|
+
function walk(value, mode, depth, path) {
|
|
500
|
+
if (depth > MAX_NODE_DEPTH) throw new RangeError(`JSON Schema exceeds maximum nesting depth of ${MAX_NODE_DEPTH}`);
|
|
501
|
+
if (Array.isArray(value)) {
|
|
502
|
+
const itemMode = mode === "schema-array" ? "schema" : "value";
|
|
503
|
+
return value.map((item, index) => walk(item, itemMode, depth + 1, `${path}[${index}]`));
|
|
504
|
+
}
|
|
505
|
+
if (!isPlainObject(value) || mode === "value") return value;
|
|
506
|
+
const node = {};
|
|
507
|
+
for (const [key, child] of Object.entries(value)) {
|
|
508
|
+
if (STRICT_STRIP_KEYWORDS.has(key)) {
|
|
509
|
+
recordChange({
|
|
510
|
+
path,
|
|
511
|
+
reason: "unsupported-keyword-stripped",
|
|
512
|
+
detail: `keyword "${key}" removed`
|
|
513
|
+
});
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
setOwn(node, key, child);
|
|
517
|
+
}
|
|
518
|
+
if (Array.isArray(node.oneOf) && node.anyOf === void 0) {
|
|
519
|
+
node.anyOf = node.oneOf;
|
|
520
|
+
delete node.oneOf;
|
|
521
|
+
recordChange({
|
|
522
|
+
path,
|
|
523
|
+
reason: "one-of-converted",
|
|
524
|
+
detail: "oneOf became anyOf"
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
for (const keyword of STRICT_UNSUPPORTED_KEYWORDS) if (node[keyword] !== void 0) unsupported.push({
|
|
528
|
+
path,
|
|
529
|
+
keyword,
|
|
530
|
+
detail: `"${keyword}" has no strict-mode equivalent`
|
|
531
|
+
});
|
|
532
|
+
if (node.oneOf !== void 0) unsupported.push({
|
|
533
|
+
path,
|
|
534
|
+
keyword: "oneOf",
|
|
535
|
+
detail: "oneOf beside anyOf cannot be merged"
|
|
536
|
+
});
|
|
537
|
+
if (Array.isArray(node.items)) unsupported.push({
|
|
538
|
+
path,
|
|
539
|
+
keyword: "items",
|
|
540
|
+
detail: "tuple-form items has no strict-mode equivalent"
|
|
541
|
+
});
|
|
542
|
+
else if (typeof node.items === "boolean") unsupported.push({
|
|
543
|
+
path,
|
|
544
|
+
keyword: "items",
|
|
545
|
+
detail: "boolean subschema"
|
|
546
|
+
});
|
|
547
|
+
if (node.properties !== void 0 && !isPlainObject(node.properties)) unsupported.push({
|
|
548
|
+
path,
|
|
549
|
+
keyword: "properties",
|
|
550
|
+
detail: "properties is not an object"
|
|
551
|
+
});
|
|
552
|
+
const out = walkChildren(node, mode, depth, path);
|
|
553
|
+
if (typeof node.$ref === "string") {
|
|
554
|
+
if ((node.$ref === "#" || node.$ref.startsWith("#/") ? tryResolvePointer(root, node.$ref) : {
|
|
555
|
+
kind: "unresolved",
|
|
556
|
+
reason: "malformed-pointer"
|
|
557
|
+
}).kind === "unresolved") unsupported.push({
|
|
558
|
+
path,
|
|
559
|
+
keyword: "$ref",
|
|
560
|
+
detail: `unresolved $ref "${node.$ref}"`
|
|
561
|
+
});
|
|
562
|
+
return out;
|
|
563
|
+
}
|
|
564
|
+
if (!(out.type === "object" || Array.isArray(out.type) && out.type.includes("object")) && !isPlainObject(out.properties)) return out;
|
|
565
|
+
if (out.properties !== void 0 && !isPlainObject(out.properties)) return out;
|
|
566
|
+
const properties = {};
|
|
567
|
+
if (isPlainObject(out.properties)) for (const [name, propertySchema] of Object.entries(out.properties)) setOwn(properties, name, propertySchema);
|
|
568
|
+
const declaredRequired = new Set(Array.isArray(out.required) ? out.required.filter((entry) => typeof entry === "string") : []);
|
|
569
|
+
for (const [name, propertySchema] of Object.entries(properties)) {
|
|
570
|
+
if (typeof propertySchema === "boolean") {
|
|
571
|
+
unsupported.push({
|
|
572
|
+
path: joinPath(path, `properties.${name}`),
|
|
573
|
+
keyword: "properties",
|
|
574
|
+
detail: "boolean subschema"
|
|
575
|
+
});
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
if (declaredRequired.has(name) || !isPlainObject(propertySchema)) continue;
|
|
579
|
+
setOwn(properties, name, widenToNullable(propertySchema));
|
|
580
|
+
recordChange({
|
|
581
|
+
path: joinPath(path, `properties.${name}`),
|
|
582
|
+
reason: "optional-property-nullable",
|
|
583
|
+
detail: `property "${name}" is now required and accepts null`
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
const acceptsDynamicKeys = out.additionalProperties === true || isPlainObject(out.additionalProperties);
|
|
587
|
+
if (acceptsDynamicKeys) unsupported.push({
|
|
588
|
+
path,
|
|
589
|
+
keyword: "additionalProperties",
|
|
590
|
+
detail: "object accepts arbitrary keys"
|
|
591
|
+
});
|
|
592
|
+
else if (out.patternProperties !== void 0) unsupported.push({
|
|
593
|
+
path,
|
|
594
|
+
keyword: "patternProperties",
|
|
595
|
+
detail: "object accepts pattern-matched keys"
|
|
596
|
+
});
|
|
597
|
+
else if (Object.keys(properties).length === 0 && out.additionalProperties === void 0) unsupported.push({
|
|
598
|
+
path,
|
|
599
|
+
keyword: "properties",
|
|
600
|
+
detail: "free-form object accepts arbitrary keys"
|
|
601
|
+
});
|
|
602
|
+
return {
|
|
603
|
+
...out,
|
|
604
|
+
...out.type === void 0 ? { type: "object" } : {},
|
|
605
|
+
properties,
|
|
606
|
+
required: Object.keys(properties),
|
|
607
|
+
...acceptsDynamicKeys ? {} : { additionalProperties: false }
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
const normalized = walk(root, "schema", 0, "");
|
|
611
|
+
if (!isPlainObject(normalized) || !isObjectType(normalized.type)) unsupported.push({
|
|
612
|
+
path: "",
|
|
613
|
+
keyword: "type",
|
|
614
|
+
detail: "root must be a non-nullable object"
|
|
615
|
+
});
|
|
616
|
+
return {
|
|
617
|
+
schema: deduplicateJsonSchemaRequiredArrays(normalized),
|
|
618
|
+
source: root,
|
|
619
|
+
changes,
|
|
620
|
+
totalChanges,
|
|
621
|
+
unsupported
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Drops `null`-valued arguments that the tool's own schema does not accept,
|
|
626
|
+
* recursively through nested objects and arrays.
|
|
627
|
+
*
|
|
628
|
+
* Strict structured outputs cannot express optional parameters, so
|
|
629
|
+
* {@link toStrictJsonSchema} makes every parameter required and nullable. The
|
|
630
|
+
* model then sends `null` for a parameter it would otherwise have omitted;
|
|
631
|
+
* forwarding that `null` to the tool would fail validation against the tool's
|
|
632
|
+
* real schema, so it is treated as "omitted". A `null` the original schema
|
|
633
|
+
* accepts (a nullable field, an explicit "clear this value") is kept.
|
|
634
|
+
*
|
|
635
|
+
* @param args - Normalized tool arguments.
|
|
636
|
+
* @param schema - The dereferenced tool parameter schema the arguments were
|
|
637
|
+
* produced for (`StrictJsonSchemaResult.source`).
|
|
638
|
+
* @returns A new object; the input is not mutated.
|
|
639
|
+
*/
|
|
640
|
+
function omitNullToolArguments(args, schema) {
|
|
641
|
+
const root = isPlainObject(schema) ? schema : {};
|
|
642
|
+
return omitNulls(args, root, root, 0);
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Picks the composition branch that describes a value's shape: the first
|
|
646
|
+
* branch with `properties` for an object, the first with `items` for an
|
|
647
|
+
* array. Nodes without a composition are returned as they are.
|
|
648
|
+
*/
|
|
649
|
+
function selectBranchFor(schema, value, root) {
|
|
650
|
+
const resolved = resolveLocalRefs(schema, root);
|
|
651
|
+
if (!isPlainObject(resolved)) return void 0;
|
|
652
|
+
const wanted = Array.isArray(value) ? "items" : "properties";
|
|
653
|
+
const find = (node, depth) => {
|
|
654
|
+
const candidate = resolveLocalRefs(node, root);
|
|
655
|
+
if (!isPlainObject(candidate) || depth > MAX_NODE_DEPTH) return void 0;
|
|
656
|
+
if (candidate[wanted] !== void 0) return candidate;
|
|
657
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
658
|
+
const branches = candidate[keyword];
|
|
659
|
+
if (!Array.isArray(branches)) continue;
|
|
660
|
+
for (const branch of branches) {
|
|
661
|
+
const found = find(branch, depth + 1);
|
|
662
|
+
if (found) return found;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
return find(resolved, 0) ?? resolved;
|
|
667
|
+
}
|
|
668
|
+
function omitNulls(value, schema, root, depth) {
|
|
669
|
+
if (depth > MAX_NODE_DEPTH) throw new RangeError(`Tool arguments exceed maximum nesting depth of ${MAX_NODE_DEPTH}`);
|
|
670
|
+
const node = selectBranchFor(schema, value, root);
|
|
671
|
+
if (Array.isArray(value)) {
|
|
672
|
+
const items = node && isPlainObject(node.items) ? node.items : void 0;
|
|
673
|
+
return value.map((item) => omitNulls(item, items, root, depth + 1));
|
|
674
|
+
}
|
|
675
|
+
if (!isPlainObject(value)) return value;
|
|
676
|
+
const properties = node && isPlainObject(node.properties) ? node.properties : {};
|
|
677
|
+
const clone = {};
|
|
678
|
+
for (const [key, child] of Object.entries(value)) {
|
|
679
|
+
const propertySchema = Object.prototype.hasOwnProperty.call(properties, key) ? properties[key] : void 0;
|
|
680
|
+
if (child === null) {
|
|
681
|
+
if (propertySchema === void 0 || schemaAcceptsNull(propertySchema, root)) setOwn(clone, key, child);
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
setOwn(clone, key, omitNulls(child, propertySchema, root, depth + 1));
|
|
685
|
+
}
|
|
686
|
+
return clone;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region src/utils/cancellation.ts
|
|
691
|
+
/** @internal */
|
|
692
|
+
async function withCancellation(call, signal) {
|
|
693
|
+
try {
|
|
694
|
+
return await call();
|
|
695
|
+
} catch (error) {
|
|
696
|
+
if (signal?.aborted && isRequestAbortError(error)) {
|
|
697
|
+
const underlyingMessage = error instanceof Error ? error.message : "";
|
|
698
|
+
const message = underlyingMessage ? `Request was cancelled by the caller: ${underlyingMessage}` : "Request was cancelled by the caller";
|
|
699
|
+
throw new ComposioRequestCancelledError(message, { cause: error instanceof Error ? error : void 0 });
|
|
700
|
+
}
|
|
701
|
+
throw error;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
//#endregion
|
|
706
|
+
export { jsonSchemaToZodSchema as a, toStrictJsonSchema as c, ensureObjectTypeOnProperties as i, deduplicateJsonSchemaRequiredArrays as n, omitNullToolArguments as o, dereferenceJsonSchema as r, removeNonRequiredProperties as s, withCancellation as t };
|