@composio/core 0.10.0 → 0.12.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.
- package/dist/{tool.types-CwbAy9l_.d.cts → BaseProvider-BBnsv9kS.d.mts} +23683 -23635
- package/dist/CustomTool-DEB4BQPl.mjs +468 -0
- package/dist/{CustomTool-aber890o.d.cts → CustomTool-DH18rVQu.d.mts} +2 -4
- package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
- package/dist/{FileToolModifier.utils.neutral-B7P7wn-b.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +1 -7
- package/dist/{Telemetry-kgWlkavX.mjs → Telemetry-DhGI_J4G.mjs} +48 -23
- package/dist/{composio-CSMCZZgj.d.cts → composio-CHnEggnv.d.mts} +433 -435
- package/dist/{customTool.types-BzEWHa0w.d.cts → customTool.types-DpIdOJjL.d.mts} +177 -236
- package/dist/{CustomTool-D7-1S2at.mjs → errors-D5f4pfvI.mjs} +132 -519
- package/dist/experimental/index.d.mts +2 -3
- package/dist/experimental/index.mjs +1 -3
- package/dist/{fileUtils.node-Dq7ebZPC.mjs → fileUtils.node-BiO1JQsJ.mjs} +26 -25
- package/dist/index.d.mts +2034 -2356
- package/dist/index.mjs +2546 -2335
- package/dist/jsonSchema-daqF3S3d.mjs +251 -0
- package/dist/models/Files.node.d.mts +1 -2
- package/dist/models/Files.node.mjs +3 -4
- package/dist/models/Files.workerd.d.mts +0 -1
- package/dist/platform/node.d.mts +1 -2
- package/dist/platform/workerd.d.mts +1 -2
- package/dist/{chunk-CWQeghP5.mjs → rolldown-runtime-w6R9maHv.mjs} +3 -5
- package/dist/{types-DE7O6Z6S.d.cts → types-CaI5Z4PA.d.mts} +2 -3
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +3 -0
- package/dist/utils/json-schema.d.mts +2 -0
- package/dist/utils/json-schema.mjs +3 -0
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +81 -44
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/package.json +48 -88
- package/dist/CustomTool-CQ_YjABZ.cjs +0 -1341
- package/dist/CustomTool-DJUGNOer.d.mts +0 -76
- package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
- package/dist/FileToolModifier.utils.neutral-Dfwqgimk.cjs +0 -102
- package/dist/Telemetry-Dm-0sewu.cjs +0 -335
- package/dist/buffer-BjWptbNH.cjs +0 -63
- package/dist/chunk-CQwRTUmo.cjs +0 -53
- package/dist/composio-DRl6WCI9.d.mts +0 -5484
- package/dist/customTool.types-CMOMgxoM.d.mts +0 -2513
- package/dist/experimental/index.cjs +0 -5
- package/dist/experimental/index.d.cts +0 -3
- package/dist/fileUtils.node-DtnSRMWa.cjs +0 -462
- package/dist/files.types-lo4zZd87.d.cts +0 -17
- package/dist/index.cjs +0 -8637
- package/dist/index.d.cts +0 -5672
- package/dist/models/Files.node.cjs +0 -55
- package/dist/models/Files.node.d.cts +0 -56
- package/dist/models/Files.workerd.cjs +0 -29
- package/dist/models/Files.workerd.d.cts +0 -13
- package/dist/platform/node.cjs +0 -55
- package/dist/platform/node.d.cts +0 -11
- package/dist/platform/workerd.cjs +0 -42
- package/dist/platform/workerd.d.cts +0 -12
- package/dist/tool.types-CB_4JKhV.d.mts +0 -29377
- package/dist/types-BTOPdg4d.d.mts +0 -13
- package/dist/types-pDNm1lYs.d.cts +0 -69
- package/dist/utils/config-defaults/ConfigDefaults.node.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +0 -7
- package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +0 -7
- package/dist/utils/modifiers/FileToolModifier.node.cjs +0 -207
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +0 -22
- package/dist/utils/modifiers/FileToolModifier.workerd.cjs +0 -27
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +0 -20
- /package/dist/{buffer-yOtEsT4J.mjs → buffer-PcbMMsgm.mjs} +0 -0
- /package/dist/{files.types-BXDWA_zS.d.mts → files.types-DeMC_mAW.d.mts} +0 -0
- /package/dist/{types-HpJQ8K9l.d.mts → types-DdoCRzLj.d.mts} +0 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { c as logger } from "./FileModifierErrors-3fSwIWoa.mjs";
|
|
2
|
+
import { C as JsonSchemaRefResolutionError, S as isRequestAbortError, b as ComposioRequestCancelledError, w as JsonSchemaToZodError } from "./errors-D5f4pfvI.mjs";
|
|
3
|
+
import { t as isPlainObject } from "./FileToolModifier.utils.neutral-B5rT711M.mjs";
|
|
4
|
+
import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
|
|
5
|
+
|
|
6
|
+
//#region src/utils/cancellation.ts
|
|
7
|
+
/** @internal */
|
|
8
|
+
async function withCancellation(call, signal) {
|
|
9
|
+
try {
|
|
10
|
+
return await call();
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if (signal?.aborted && isRequestAbortError(error)) {
|
|
13
|
+
const underlyingMessage = error instanceof Error ? error.message : "";
|
|
14
|
+
throw new ComposioRequestCancelledError(underlyingMessage ? `Request was cancelled by the caller: ${underlyingMessage}` : "Request was cancelled by the caller", { cause: error instanceof Error ? error : void 0 });
|
|
15
|
+
}
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/utils/jsonSchema.ts
|
|
22
|
+
const MAX_REF_CHAIN_DEPTH = 100;
|
|
23
|
+
const MAX_NODE_DEPTH = 512;
|
|
24
|
+
const CYCLE_BREAK_SENTINEL = {
|
|
25
|
+
type: "object",
|
|
26
|
+
additionalProperties: true
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* In-band hint attached to the cycle-break sentinel when lenient mode
|
|
30
|
+
* substitutes it for a dangling `$ref`. Makes the degradation visible to
|
|
31
|
+
* LLMs that read the wrapped tool's schema — without it the LLM sees a
|
|
32
|
+
* useless permissive object and no prose context. Wording is intentionally
|
|
33
|
+
* context-neutral ("Schema shape", not "Output shape") because the helper
|
|
34
|
+
* is used for both `inputParameters` and `outputParameters`. Overridden
|
|
35
|
+
* when the caller's `$ref` node carries its own `description` sibling
|
|
36
|
+
* (Draft 2020-12 sibling-keyword semantics).
|
|
37
|
+
*/
|
|
38
|
+
const UNRESOLVED_REF_DESCRIPTION = "Schema shape unresolved at the source — validate loosely. See https://github.com/ComposioHQ/composio/issues/3307.";
|
|
39
|
+
const POLLUTING_KEYS = new Set([
|
|
40
|
+
"__proto__",
|
|
41
|
+
"constructor",
|
|
42
|
+
"prototype"
|
|
43
|
+
]);
|
|
44
|
+
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"];
|
|
45
|
+
const decodePointerSegment = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
46
|
+
const tryStep = (cursor, segment) => {
|
|
47
|
+
if (cursor === null || typeof cursor !== "object") return {
|
|
48
|
+
kind: "unresolved",
|
|
49
|
+
reason: "missing-target",
|
|
50
|
+
failedAt: segment
|
|
51
|
+
};
|
|
52
|
+
if (Array.isArray(cursor)) {
|
|
53
|
+
const i = Number(segment);
|
|
54
|
+
if (!Number.isInteger(i) || i < 0 || i >= cursor.length) return {
|
|
55
|
+
kind: "unresolved",
|
|
56
|
+
reason: "missing-target",
|
|
57
|
+
failedAt: segment
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
kind: "ok",
|
|
61
|
+
value: cursor[i]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const obj = cursor;
|
|
65
|
+
if (!Object.prototype.hasOwnProperty.call(obj, segment)) return {
|
|
66
|
+
kind: "unresolved",
|
|
67
|
+
reason: "missing-target",
|
|
68
|
+
failedAt: segment
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
kind: "ok",
|
|
72
|
+
value: obj[segment]
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const tryResolvePointer = (root, pointer) => {
|
|
76
|
+
if (pointer === "#" || pointer === "") return {
|
|
77
|
+
kind: "ok",
|
|
78
|
+
value: root
|
|
79
|
+
};
|
|
80
|
+
if (!pointer.startsWith("#/")) return {
|
|
81
|
+
kind: "unresolved",
|
|
82
|
+
reason: "malformed-pointer"
|
|
83
|
+
};
|
|
84
|
+
const segments = pointer.slice(2).split("/").map(decodePointerSegment);
|
|
85
|
+
let cursor = root;
|
|
86
|
+
for (const seg of segments) {
|
|
87
|
+
const step = tryStep(cursor, seg);
|
|
88
|
+
if (step.kind === "unresolved") return step;
|
|
89
|
+
cursor = step.value;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
kind: "ok",
|
|
93
|
+
value: cursor
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
const throwResolutionError = (pointer, result) => {
|
|
97
|
+
if (result.reason === "malformed-pointer") throw new JsonSchemaRefResolutionError(`Unsupported $ref pointer: ${pointer}`, {
|
|
98
|
+
meta: { ref: pointer },
|
|
99
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
100
|
+
});
|
|
101
|
+
throw new JsonSchemaRefResolutionError(`Cannot resolve $ref ${pointer}`, {
|
|
102
|
+
meta: {
|
|
103
|
+
ref: pointer,
|
|
104
|
+
...result.failedAt !== void 0 ? { failedAt: result.failedAt } : {}
|
|
105
|
+
},
|
|
106
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Inlines internal JSON Schema `$ref` pointers (`#/$defs/...` and legacy
|
|
111
|
+
* `#/definitions/...`) so the returned schema can be safely handed to
|
|
112
|
+
* consumers that don't tolerate unresolved references (e.g. AJV in
|
|
113
|
+
* `@mastra/schema-compat`). External (`http://`, `https://`, …) refs are
|
|
114
|
+
* left untouched. Cycles are broken with `{ type: 'object',
|
|
115
|
+
* additionalProperties: true }`. The input is never mutated.
|
|
116
|
+
*
|
|
117
|
+
* By default, unresolved internal refs throw `JsonSchemaRefResolutionError`.
|
|
118
|
+
* Pass `{ onUnresolved: 'sentinel' }` to replace the offending node with the
|
|
119
|
+
* cycle-break sentinel instead — appropriate for schemas sourced from an
|
|
120
|
+
* upstream service the caller cannot edit (the Composio API ships some
|
|
121
|
+
* `outputParameters` with a `$ref` into `#/$defs/...` but never declares
|
|
122
|
+
* `$defs`; see https://github.com/ComposioHQ/composio/issues/3307).
|
|
123
|
+
*
|
|
124
|
+
* @throws {JsonSchemaRefResolutionError} on malformed pointers, missing
|
|
125
|
+
* targets (strict mode only), or chains past the depth cap (both modes).
|
|
126
|
+
*/
|
|
127
|
+
function dereferenceJsonSchema(schema, options) {
|
|
128
|
+
if (!isPlainObject(schema)) return schema;
|
|
129
|
+
const strategy = options?.onUnresolved ?? "throw";
|
|
130
|
+
const onReplace = options?.onReplace;
|
|
131
|
+
const root = schema;
|
|
132
|
+
const visiting = /* @__PURE__ */ new WeakSet();
|
|
133
|
+
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)]));
|
|
134
|
+
function walk(node, visitedRefs, chainDepth, nodeDepth) {
|
|
135
|
+
if (nodeDepth >= MAX_NODE_DEPTH) throw new JsonSchemaRefResolutionError(`JSON Schema node depth exceeded cap (${MAX_NODE_DEPTH})`, { possibleFixes: REF_RESOLUTION_FIXES });
|
|
136
|
+
if (Array.isArray(node)) {
|
|
137
|
+
if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };
|
|
138
|
+
visiting.add(node);
|
|
139
|
+
try {
|
|
140
|
+
return node.map((item) => walk(item, visitedRefs, chainDepth, nodeDepth + 1));
|
|
141
|
+
} finally {
|
|
142
|
+
visiting.delete(node);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (!isPlainObject(node)) return node;
|
|
146
|
+
if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };
|
|
147
|
+
visiting.add(node);
|
|
148
|
+
try {
|
|
149
|
+
const ref = typeof node.$ref === "string" ? node.$ref : null;
|
|
150
|
+
if (ref === null || !ref.startsWith("#")) {
|
|
151
|
+
if (ref !== null) logger.warn(`Leaving external $ref untouched: ${ref}`);
|
|
152
|
+
return cloneChildren(node, visitedRefs, chainDepth, nodeDepth);
|
|
153
|
+
}
|
|
154
|
+
if (chainDepth >= MAX_REF_CHAIN_DEPTH) throw new JsonSchemaRefResolutionError(`JSON Schema $ref chain exceeded depth cap (${MAX_REF_CHAIN_DEPTH}): ${ref}`, {
|
|
155
|
+
meta: { ref },
|
|
156
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
157
|
+
});
|
|
158
|
+
if (visitedRefs.has(ref)) return { ...CYCLE_BREAK_SENTINEL };
|
|
159
|
+
const result = tryResolvePointer(root, ref);
|
|
160
|
+
let target;
|
|
161
|
+
if (result.kind === "ok") target = result.value;
|
|
162
|
+
else if (strategy === "sentinel") {
|
|
163
|
+
onReplace?.(ref, result.reason);
|
|
164
|
+
target = {
|
|
165
|
+
...CYCLE_BREAK_SENTINEL,
|
|
166
|
+
description: UNRESOLVED_REF_DESCRIPTION
|
|
167
|
+
};
|
|
168
|
+
} else throwResolutionError(ref, result);
|
|
169
|
+
const nextRefs = new Set(visitedRefs).add(ref);
|
|
170
|
+
const resolved = walk(target, nextRefs, chainDepth + 1, nodeDepth + 1);
|
|
171
|
+
const siblings = { ...node };
|
|
172
|
+
delete siblings.$ref;
|
|
173
|
+
if (Object.keys(siblings).length === 0 || !isPlainObject(resolved)) return resolved;
|
|
174
|
+
return {
|
|
175
|
+
...resolved,
|
|
176
|
+
...cloneChildren(siblings, visitedRefs, chainDepth, nodeDepth)
|
|
177
|
+
};
|
|
178
|
+
} finally {
|
|
179
|
+
visiting.delete(node);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const out = walk(root, /* @__PURE__ */ new Set(), 0, 0);
|
|
183
|
+
if (isPlainObject(out)) {
|
|
184
|
+
delete out.$defs;
|
|
185
|
+
delete out.definitions;
|
|
186
|
+
}
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Removes all non-required properties from the schema
|
|
191
|
+
*
|
|
192
|
+
* if no items are required, the schema is returned as is
|
|
193
|
+
* @param schema - The JSON schema to remove non-required properties from
|
|
194
|
+
* @returns The JSON schema with all non-required properties removed
|
|
195
|
+
*/
|
|
196
|
+
const removeNonRequiredProperties = (schema) => {
|
|
197
|
+
if (schema && schema.type === "object" && schema.required?.length) schema.properties = Object.fromEntries(Object.entries(schema.properties || {}).filter(([key]) => schema.required.includes(key)));
|
|
198
|
+
schema.additionalProperties = false;
|
|
199
|
+
return schema;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Convert a JSON schema to a Zod schema
|
|
203
|
+
* @param jsonSchema - The JSON schema to convert
|
|
204
|
+
* @param strict - Eliminates all non-required properties from the schema
|
|
205
|
+
* @returns The Zod schema
|
|
206
|
+
*
|
|
207
|
+
* @throws {JsonSchemaToZodError} If the JSON schema is invalid
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* const zodSchema = jsonSchemaToZodSchema({
|
|
212
|
+
* type: 'object',
|
|
213
|
+
* properties: {
|
|
214
|
+
* name: { type: 'string' },
|
|
215
|
+
* },
|
|
216
|
+
* });
|
|
217
|
+
*
|
|
218
|
+
* console.log(zodSchema);
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const zodSchema = jsonSchemaToZodSchema({
|
|
224
|
+
* type: 'object',
|
|
225
|
+
* properties: {
|
|
226
|
+
* name: { type: 'string' },
|
|
227
|
+
* age: { type: 'number' },
|
|
228
|
+
* },
|
|
229
|
+
* required: ['name'],
|
|
230
|
+
* }, { strict: true });
|
|
231
|
+
*
|
|
232
|
+
* console.log(zodSchema);
|
|
233
|
+
*
|
|
234
|
+
* // Output:
|
|
235
|
+
* // z.object({
|
|
236
|
+
* // name: z.string(),
|
|
237
|
+
* // })
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
function jsonSchemaToZodSchema(jsonSchema, { strict } = { strict: false }) {
|
|
241
|
+
try {
|
|
242
|
+
let schema = jsonSchema;
|
|
243
|
+
if (strict && schema) schema = removeNonRequiredProperties(schema);
|
|
244
|
+
return jsonSchemaToZod(schema);
|
|
245
|
+
} catch (error) {
|
|
246
|
+
throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", { cause: error });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
//#endregion
|
|
251
|
+
export { withCancellation as i, jsonSchemaToZodSchema as n, removeNonRequiredProperties as r, dereferenceJsonSchema as t };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { n as FileUploadData, t as FileDownloadData } from "../files.types-
|
|
1
|
+
import { n as FileUploadData, t as FileDownloadData } from "../files.types-DeMC_mAW.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
|
|
4
4
|
//#region src/models/Files.node.d.ts
|
|
5
|
-
|
|
6
5
|
declare class Files {
|
|
7
6
|
private readonly client;
|
|
8
7
|
private readonly fileOptions;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import { t as telemetry } from "../Telemetry-kgWlkavX.mjs";
|
|
4
|
-
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-Dq7ebZPC.mjs";
|
|
1
|
+
import { t as telemetry } from "../Telemetry-DhGI_J4G.mjs";
|
|
2
|
+
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-BiO1JQsJ.mjs";
|
|
5
3
|
|
|
6
4
|
//#region src/models/Files.node.ts
|
|
7
5
|
var Files = class {
|
|
6
|
+
client;
|
|
8
7
|
fileOptions;
|
|
9
8
|
constructor(client, fileOptions = {}) {
|
|
10
9
|
this.client = client;
|
package/dist/platform/node.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as Platform } from "../types-
|
|
1
|
+
import { t as Platform } from "../types-DdoCRzLj.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/platform/node.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Node.js platform implementation.
|
|
7
6
|
* Provides full file system and OS operations using Node.js built-in modules.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as Platform } from "../types-
|
|
1
|
+
import { t as Platform } from "../types-DdoCRzLj.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/platform/workerd.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Cloudflare Workers / Edge runtime platform implementation.
|
|
7
6
|
* Provides stub implementations for file system operations that are unavailable in edge runtimes.
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//#region rolldown:runtime
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
4
2
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __exportAll = (all,
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
6
4
|
let target = {};
|
|
7
5
|
for (var name in all) {
|
|
8
6
|
__defProp(target, name, {
|
|
@@ -10,7 +8,7 @@ var __exportAll = (all, symbols) => {
|
|
|
10
8
|
enumerable: true
|
|
11
9
|
});
|
|
12
10
|
}
|
|
13
|
-
if (
|
|
11
|
+
if (!no_symbols) {
|
|
14
12
|
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
13
|
}
|
|
16
14
|
return target;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as ComposioConfig } from "./composio-
|
|
1
|
+
import { n as BaseComposioProvider } from "./BaseProvider-BBnsv9kS.mjs";
|
|
2
|
+
import { n as ComposioConfig } from "./composio-CHnEggnv.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/config-defaults/types.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Configuration defaults for Composio.
|
|
8
7
|
* These are the required fields that must have default values.
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import "../../customTool.types-CMOMgxoM.mjs";
|
|
3
|
-
import "../../composio-DRl6WCI9.mjs";
|
|
4
|
-
import { t as ConfigDefaults } from "../../types-BTOPdg4d.mjs";
|
|
1
|
+
import { t as ConfigDefaults } from "../../types-CaI5Z4PA.mjs";
|
|
5
2
|
|
|
6
3
|
//#region src/utils/config-defaults/ConfigDefaults.node.d.ts
|
|
7
4
|
declare const CONFIG_DEFAULTS: ConfigDefaults;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import "../../customTool.types-CMOMgxoM.mjs";
|
|
3
|
-
import "../../composio-DRl6WCI9.mjs";
|
|
4
|
-
import { t as ConfigDefaults } from "../../types-BTOPdg4d.mjs";
|
|
1
|
+
import { t as ConfigDefaults } from "../../types-CaI5Z4PA.mjs";
|
|
5
2
|
|
|
6
3
|
//#region src/utils/config-defaults/ConfigDefaults.workerd.d.ts
|
|
7
4
|
declare const CONFIG_DEFAULTS: ConfigDefaults;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
//#region src/utils/config-defaults/ConfigDefaults.workerd.ts
|
|
2
2
|
const CONFIG_DEFAULTS = {
|
|
3
|
+
/**
|
|
4
|
+
* We don't support auto-uploading/download files in Cloudflare Workers yet.
|
|
5
|
+
*/
|
|
3
6
|
dangerouslyAllowAutoUploadDownloadFiles: false,
|
|
4
7
|
allowTracking: true,
|
|
5
8
|
toolkitVersions: "latest"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { gn as Tool, xn as ToolExecuteResponse, yn as ToolExecuteParams } from "../../BaseProvider-BBnsv9kS.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/modifiers/FileToolModifier.node.d.ts
|
|
@@ -11,11 +11,13 @@ declare class FileToolModifier {
|
|
|
11
11
|
toolSlug: string;
|
|
12
12
|
toolkitSlug?: string;
|
|
13
13
|
params: ToolExecuteParams;
|
|
14
|
+
signal?: AbortSignal;
|
|
14
15
|
}): Promise<ToolExecuteParams>;
|
|
15
16
|
fileDownloadModifier(tool: Tool, options: {
|
|
16
17
|
toolSlug: string;
|
|
17
18
|
toolkitSlug: string;
|
|
18
19
|
result: ToolExecuteResponse;
|
|
20
|
+
signal?: AbortSignal;
|
|
19
21
|
}): Promise<ToolExecuteResponse>;
|
|
20
22
|
}
|
|
21
23
|
//#endregion
|
|
@@ -1,10 +1,53 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import {
|
|
3
|
-
import { i as transformProperties, n as
|
|
4
|
-
import {
|
|
1
|
+
import { a as ComposioSensitiveFilePathBlockedError, c as logger, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "../../FileModifierErrors-3fSwIWoa.mjs";
|
|
2
|
+
import { b as ComposioRequestCancelledError } from "../../errors-D5f4pfvI.mjs";
|
|
3
|
+
import { i as transformProperties, n as schemaHasFileProperty, t as isPlainObject } from "../../FileToolModifier.utils.neutral-B5rT711M.mjs";
|
|
4
|
+
import { i as withCancellation, t as dereferenceJsonSchema } from "../../jsonSchema-daqF3S3d.mjs";
|
|
5
|
+
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../../fileUtils.node-BiO1JQsJ.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/utils/modifiers/FileToolModifier.node.ts
|
|
7
8
|
/**
|
|
9
|
+
* Inlines internal `$ref` pointers so the file walkers below can see the
|
|
10
|
+
* `file_uploadable` / `file_downloadable` flags that live behind a
|
|
11
|
+
* `$ref`/`$defs` indirection (e.g. `GMAIL_GET_ATTACHMENT`). The walkers only
|
|
12
|
+
* recurse `properties`/`anyOf`/`oneOf`/`allOf`/`items` and never dereference,
|
|
13
|
+
* so without this a flagged field reachable only through a `$ref` is silently
|
|
14
|
+
* missed — the file is never staged/downloaded. `'sentinel'` mode keeps tools
|
|
15
|
+
* whose schema omits the `$defs` target working (see
|
|
16
|
+
* https://github.com/ComposioHQ/composio/issues/3307) instead of throwing.
|
|
17
|
+
*/
|
|
18
|
+
const resolveFileSchema = (schema) => schema ? dereferenceJsonSchema(schema, { onUnresolved: "sentinel" }) : schema;
|
|
19
|
+
const getSchemaVariants = (schema) => [
|
|
20
|
+
...schema?.anyOf ?? [],
|
|
21
|
+
...schema?.oneOf ?? [],
|
|
22
|
+
...schema?.allOf ?? []
|
|
23
|
+
];
|
|
24
|
+
const jsonSchemaTypeMatchesValue = (schema, value) => {
|
|
25
|
+
const schemaType = schema.type;
|
|
26
|
+
if (Array.isArray(schemaType)) return schemaType.some((type) => jsonSchemaTypeMatchesValue({
|
|
27
|
+
...schema,
|
|
28
|
+
type
|
|
29
|
+
}, value));
|
|
30
|
+
if (schemaType === void 0) {
|
|
31
|
+
if (schema.properties) return isPlainObject(value);
|
|
32
|
+
if (schema.items) return Array.isArray(value);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
switch (schemaType) {
|
|
36
|
+
case "array": return Array.isArray(value);
|
|
37
|
+
case "object": return isPlainObject(value);
|
|
38
|
+
case "string": return typeof value === "string";
|
|
39
|
+
case "integer": return Number.isInteger(value);
|
|
40
|
+
case "number": return typeof value === "number";
|
|
41
|
+
case "boolean": return typeof value === "boolean";
|
|
42
|
+
case "null": return value === null;
|
|
43
|
+
default: return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const findSchemaVariantWithFileProperty = (schema, property, value) => {
|
|
47
|
+
const candidates = getSchemaVariants(schema).filter((variant) => schemaHasFileProperty(variant, property));
|
|
48
|
+
return candidates.find((candidate) => jsonSchemaTypeMatchesValue(candidate, value)) ?? candidates[0];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
8
51
|
* Recursively walks a runtime value and its matching JSON-Schema node,
|
|
9
52
|
* uploading any string path whose schema node has `file_uploadable: true`.
|
|
10
53
|
* The function returns a **new** value with all substitutions applied;
|
|
@@ -26,14 +69,15 @@ const hydrateFiles = async (value, schema, ctx) => {
|
|
|
26
69
|
};
|
|
27
70
|
if (typeof value === "string") {
|
|
28
71
|
const pathOrUrl = await runBeforeFileUpload(value, value.startsWith("http") ? "url" : "path");
|
|
29
|
-
|
|
72
|
+
logger.debug(`Uploading file "${pathOrUrl}"`);
|
|
30
73
|
return getFileDataAfterUploadingToS3(pathOrUrl, {
|
|
31
74
|
toolSlug: ctx.toolSlug,
|
|
32
75
|
toolkitSlug: ctx.toolkitSlug,
|
|
33
76
|
client: ctx.client,
|
|
34
77
|
sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
|
|
35
78
|
fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,
|
|
36
|
-
fileUploadAllowlist: ctx.fileUploadAllowlist
|
|
79
|
+
fileUploadAllowlist: ctx.fileUploadAllowlist,
|
|
80
|
+
signal: ctx.signal
|
|
37
81
|
});
|
|
38
82
|
}
|
|
39
83
|
if (ctx.beforeFileUpload) {
|
|
@@ -45,35 +89,30 @@ const hydrateFiles = async (value, schema, ctx) => {
|
|
|
45
89
|
});
|
|
46
90
|
if (out === false) throw new ComposioFileUploadAbortedError("File upload was aborted because beforeFileUpload returned false.");
|
|
47
91
|
if (typeof out === "string" && out !== value.name) {
|
|
48
|
-
|
|
92
|
+
logger.debug(`Uploading file from path "${out}" (replaced File: ${value.name})`);
|
|
49
93
|
return getFileDataAfterUploadingToS3(out, {
|
|
50
94
|
toolSlug: ctx.toolSlug,
|
|
51
95
|
toolkitSlug: ctx.toolkitSlug,
|
|
52
96
|
client: ctx.client,
|
|
53
97
|
sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
|
|
54
98
|
fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,
|
|
55
|
-
fileUploadAllowlist: ctx.fileUploadAllowlist
|
|
99
|
+
fileUploadAllowlist: ctx.fileUploadAllowlist,
|
|
100
|
+
signal: ctx.signal
|
|
56
101
|
});
|
|
57
102
|
}
|
|
58
103
|
}
|
|
59
|
-
|
|
104
|
+
logger.debug(`Uploading file "${value.name}"`);
|
|
60
105
|
return getFileDataAfterUploadingToS3(value, {
|
|
61
106
|
toolSlug: ctx.toolSlug,
|
|
62
107
|
toolkitSlug: ctx.toolkitSlug,
|
|
63
108
|
client: ctx.client,
|
|
64
109
|
sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
|
|
65
|
-
fileUploadPathDenySegments: ctx.fileUploadPathDenySegments
|
|
110
|
+
fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,
|
|
111
|
+
signal: ctx.signal
|
|
66
112
|
});
|
|
67
113
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
...schema?.oneOf ?? [],
|
|
71
|
-
...schema?.allOf ?? []
|
|
72
|
-
];
|
|
73
|
-
if (schemaVariants.length > 0) {
|
|
74
|
-
const firstUploadableVariant = schemaVariants.find(schemaHasFileUploadable);
|
|
75
|
-
if (firstUploadableVariant) return hydrateFiles(value, firstUploadableVariant, ctx);
|
|
76
|
-
}
|
|
114
|
+
const uploadableVariant = findSchemaVariantWithFileProperty(schema, "file_uploadable", value);
|
|
115
|
+
if (uploadableVariant) return hydrateFiles(value, uploadableVariant, ctx);
|
|
77
116
|
if (schema?.type === "object" && schema.properties && isPlainObject(value)) {
|
|
78
117
|
const transformed = {};
|
|
79
118
|
for (const [k, v] of Object.entries(value)) transformed[k] = await hydrateFiles(v, schema.properties[k], ctx);
|
|
@@ -91,14 +130,15 @@ const hydrateFiles = async (value, schema, ctx) => {
|
|
|
91
130
|
const downloadS3File = async (value, ctx) => {
|
|
92
131
|
const { s3url, mimetype } = value;
|
|
93
132
|
try {
|
|
94
|
-
|
|
133
|
+
logger.debug(`Downloading from S3: ${s3url}`);
|
|
95
134
|
const dl = await downloadFileFromS3({
|
|
96
135
|
toolSlug: ctx.toolSlug,
|
|
97
136
|
s3Url: s3url,
|
|
98
137
|
mimeType: mimetype ?? "application/octet-stream",
|
|
99
|
-
fileDownloadDir: ctx.fileDownloadDir
|
|
138
|
+
fileDownloadDir: ctx.fileDownloadDir,
|
|
139
|
+
signal: ctx.signal
|
|
100
140
|
});
|
|
101
|
-
|
|
141
|
+
logger.debug(`Downloaded → ${dl.filePath}`);
|
|
102
142
|
return {
|
|
103
143
|
uri: dl.filePath,
|
|
104
144
|
file_downloaded: dl.filePath ? true : false,
|
|
@@ -106,7 +146,7 @@ const downloadS3File = async (value, ctx) => {
|
|
|
106
146
|
mimeType: dl.mimeType
|
|
107
147
|
};
|
|
108
148
|
} catch (err) {
|
|
109
|
-
|
|
149
|
+
logger.error(`Download failed: ${s3url}`, { cause: err });
|
|
110
150
|
return {
|
|
111
151
|
uri: "",
|
|
112
152
|
file_downloaded: false,
|
|
@@ -131,17 +171,10 @@ const downloadS3File = async (value, ctx) => {
|
|
|
131
171
|
const hydrateDownloads = async (value, schema, ctx) => {
|
|
132
172
|
if (isPlainObject(value) && typeof value.s3url === "string") return downloadS3File(value, ctx);
|
|
133
173
|
if (schema?.file_downloadable && isPlainObject(value) && typeof value.s3url === "string") return downloadS3File(value, ctx);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
];
|
|
139
|
-
if (schemaVariants.length > 0) {
|
|
140
|
-
const downloadableVariants = schemaVariants.filter(schemaHasFileDownloadable);
|
|
141
|
-
let result = value;
|
|
142
|
-
for (const variant of downloadableVariants) result = await hydrateDownloads(result, variant, ctx);
|
|
143
|
-
if (downloadableVariants.length === 0) return hydrateDownloads(value, void 0, ctx);
|
|
144
|
-
return result;
|
|
174
|
+
if (getSchemaVariants(schema).length > 0) {
|
|
175
|
+
const downloadableVariant = findSchemaVariantWithFileProperty(schema, "file_downloadable", value);
|
|
176
|
+
if (downloadableVariant) return hydrateDownloads(value, downloadableVariant, ctx);
|
|
177
|
+
return hydrateDownloads(value, void 0, ctx);
|
|
145
178
|
}
|
|
146
179
|
if (isPlainObject(value)) {
|
|
147
180
|
const pairs = await Promise.all(Object.entries(value).map(async ([k, v]) => [k, await hydrateDownloads(v, schema?.properties?.[k], ctx)]));
|
|
@@ -162,40 +195,44 @@ var FileToolModifier = class {
|
|
|
162
195
|
}
|
|
163
196
|
async modifyToolSchema(schema) {
|
|
164
197
|
if (!schema.inputParameters?.properties) return schema;
|
|
165
|
-
const
|
|
198
|
+
const inputParameters = resolveFileSchema(schema.inputParameters);
|
|
199
|
+
const properties = transformProperties(inputParameters.properties);
|
|
166
200
|
return {
|
|
167
201
|
...schema,
|
|
168
202
|
inputParameters: {
|
|
169
|
-
...
|
|
203
|
+
...inputParameters,
|
|
204
|
+
type: "object",
|
|
170
205
|
properties
|
|
171
206
|
}
|
|
172
207
|
};
|
|
173
208
|
}
|
|
174
209
|
async fileUploadModifier(tool, options) {
|
|
175
|
-
const { params, toolSlug, toolkitSlug = "unknown" } = options;
|
|
210
|
+
const { params, toolSlug, toolkitSlug = "unknown", signal } = options;
|
|
176
211
|
const { arguments: args } = params;
|
|
177
212
|
if (!args || typeof args !== "object") return params;
|
|
178
213
|
try {
|
|
179
|
-
const newArgs = await hydrateFiles(args, tool.inputParameters, {
|
|
214
|
+
const newArgs = await withCancellation(() => hydrateFiles(args, resolveFileSchema(tool.inputParameters), {
|
|
180
215
|
toolSlug,
|
|
181
216
|
toolkitSlug,
|
|
182
217
|
client: this.client,
|
|
183
|
-
...this.fileUploadPathOptions
|
|
184
|
-
|
|
218
|
+
...this.fileUploadPathOptions,
|
|
219
|
+
signal
|
|
220
|
+
}), signal);
|
|
185
221
|
return {
|
|
186
222
|
...params,
|
|
187
223
|
arguments: newArgs
|
|
188
224
|
};
|
|
189
225
|
} catch (error) {
|
|
190
|
-
if (error instanceof ComposioSensitiveFilePathBlockedError || error instanceof ComposioFileUploadAbortedError || error instanceof ComposioFileUploadPathNotAllowedError || error instanceof ComposioFileNotFoundError) throw error;
|
|
226
|
+
if (error instanceof ComposioRequestCancelledError || error instanceof ComposioSensitiveFilePathBlockedError || error instanceof ComposioFileUploadAbortedError || error instanceof ComposioFileUploadPathNotAllowedError || error instanceof ComposioFileNotFoundError) throw error;
|
|
191
227
|
throw new ComposioFileUploadError("Failed to upload file", { cause: error });
|
|
192
228
|
}
|
|
193
229
|
}
|
|
194
230
|
async fileDownloadModifier(tool, options) {
|
|
195
|
-
const { result, toolSlug } = options;
|
|
196
|
-
const dataWithDownloads = await hydrateDownloads(result.data, tool.outputParameters, {
|
|
231
|
+
const { result, toolSlug, signal } = options;
|
|
232
|
+
const dataWithDownloads = await hydrateDownloads(result.data, resolveFileSchema(tool.outputParameters), {
|
|
197
233
|
toolSlug,
|
|
198
|
-
fileDownloadDir: this.fileUploadPathOptions.fileDownloadDir
|
|
234
|
+
fileDownloadDir: this.fileUploadPathOptions.fileDownloadDir,
|
|
235
|
+
signal
|
|
199
236
|
});
|
|
200
237
|
return {
|
|
201
238
|
...result,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { gn as Tool, xn as ToolExecuteResponse, yn as ToolExecuteParams } from "../../BaseProvider-BBnsv9kS.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/modifiers/FileToolModifier.workerd.d.ts
|
|
@@ -9,11 +9,13 @@ declare class FileToolModifier {
|
|
|
9
9
|
toolSlug: string;
|
|
10
10
|
toolkitSlug?: string;
|
|
11
11
|
params: ToolExecuteParams;
|
|
12
|
+
signal?: AbortSignal;
|
|
12
13
|
}): Promise<ToolExecuteParams>;
|
|
13
14
|
fileDownloadModifier(_tool: Tool, _options: {
|
|
14
15
|
toolSlug: string;
|
|
15
16
|
toolkitSlug: string;
|
|
16
17
|
result: ToolExecuteResponse;
|
|
18
|
+
signal?: AbortSignal;
|
|
17
19
|
}): Promise<ToolExecuteResponse>;
|
|
18
20
|
}
|
|
19
21
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as transformProperties } from "../../FileToolModifier.utils.neutral-
|
|
1
|
+
import { i as transformProperties } from "../../FileToolModifier.utils.neutral-B5rT711M.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/modifiers/FileToolModifier.workerd.ts
|
|
4
4
|
const UNSUPPORTED_MESSAGE = "File upload/download modifiers are not available on edge runtimes yet. Please set `dangerouslyAllowAutoUploadDownloadFiles: false` (or unset it; it defaults to false) or run Composio in another JS runtime (Node.js / Bun).";
|