@composio/core 0.11.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/{BaseProvider-CVbQxTNa.d.cts → BaseProvider-BBnsv9kS.d.mts} +139 -92
- package/dist/CustomTool-DEB4BQPl.mjs +468 -0
- package/dist/{CustomTool-C-IUByoU.d.cts → CustomTool-DH18rVQu.d.mts} +2 -4
- package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
- package/dist/{Telemetry-DQax33Gh.mjs → Telemetry-DhGI_J4G.mjs} +15 -15
- package/dist/{composio-pcA13w87.d.cts → composio-CHnEggnv.d.mts} +394 -349
- package/dist/{customTool.types-QtkAZQma.d.cts → customTool.types-DpIdOJjL.d.mts} +171 -192
- package/dist/{CustomTool-D5s-aADw.mjs → errors-D5f4pfvI.mjs} +70 -457
- 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 +1685 -2400
- package/dist/index.mjs +2238 -1912
- 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-J2KCXP8R.d.mts → 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 +44 -24
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/package.json +39 -88
- package/dist/BaseProvider-BvHvJLXc.d.mts +0 -29378
- package/dist/CustomTool-CChQSp44.d.mts +0 -76
- package/dist/CustomTool-D3-NreIm.cjs +0 -1341
- package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
- package/dist/FileToolModifier.utils.neutral-DSBQs9-i.cjs +0 -96
- package/dist/Telemetry-BQ_pl5AK.cjs +0 -360
- package/dist/buffer-BjWptbNH.cjs +0 -63
- package/dist/chunk-CQwRTUmo.cjs +0 -53
- package/dist/composio-BlASKqjQ.d.mts +0 -5437
- package/dist/customTool.types-DLIORcYN.d.mts +0 -2475
- 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 -8523
- package/dist/index.d.cts +0 -6065
- 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/types-DRG5qLxI.d.cts +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 -224
- 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/{FileToolModifier.utils.neutral-BpSceNK8.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +0 -0
- /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-DQax33Gh.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 { n as BaseComposioProvider } from "./BaseProvider-
|
|
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-DLIORcYN.mjs";
|
|
3
|
-
import "../../composio-BlASKqjQ.mjs";
|
|
4
|
-
import { t as ConfigDefaults } from "../../types-J2KCXP8R.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-DLIORcYN.mjs";
|
|
3
|
-
import "../../composio-BlASKqjQ.mjs";
|
|
4
|
-
import { t as ConfigDefaults } from "../../types-J2KCXP8R.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 { gn as Tool, xn as ToolExecuteResponse, yn as ToolExecuteParams } from "../../BaseProvider-
|
|
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,9 +1,21 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import {
|
|
3
|
-
import { i as transformProperties, n as schemaHasFileProperty, t as isPlainObject } from "../../FileToolModifier.utils.neutral-
|
|
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
|
|
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;
|
|
7
19
|
const getSchemaVariants = (schema) => [
|
|
8
20
|
...schema?.anyOf ?? [],
|
|
9
21
|
...schema?.oneOf ?? [],
|
|
@@ -57,14 +69,15 @@ const hydrateFiles = async (value, schema, ctx) => {
|
|
|
57
69
|
};
|
|
58
70
|
if (typeof value === "string") {
|
|
59
71
|
const pathOrUrl = await runBeforeFileUpload(value, value.startsWith("http") ? "url" : "path");
|
|
60
|
-
|
|
72
|
+
logger.debug(`Uploading file "${pathOrUrl}"`);
|
|
61
73
|
return getFileDataAfterUploadingToS3(pathOrUrl, {
|
|
62
74
|
toolSlug: ctx.toolSlug,
|
|
63
75
|
toolkitSlug: ctx.toolkitSlug,
|
|
64
76
|
client: ctx.client,
|
|
65
77
|
sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
|
|
66
78
|
fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,
|
|
67
|
-
fileUploadAllowlist: ctx.fileUploadAllowlist
|
|
79
|
+
fileUploadAllowlist: ctx.fileUploadAllowlist,
|
|
80
|
+
signal: ctx.signal
|
|
68
81
|
});
|
|
69
82
|
}
|
|
70
83
|
if (ctx.beforeFileUpload) {
|
|
@@ -76,24 +89,26 @@ const hydrateFiles = async (value, schema, ctx) => {
|
|
|
76
89
|
});
|
|
77
90
|
if (out === false) throw new ComposioFileUploadAbortedError("File upload was aborted because beforeFileUpload returned false.");
|
|
78
91
|
if (typeof out === "string" && out !== value.name) {
|
|
79
|
-
|
|
92
|
+
logger.debug(`Uploading file from path "${out}" (replaced File: ${value.name})`);
|
|
80
93
|
return getFileDataAfterUploadingToS3(out, {
|
|
81
94
|
toolSlug: ctx.toolSlug,
|
|
82
95
|
toolkitSlug: ctx.toolkitSlug,
|
|
83
96
|
client: ctx.client,
|
|
84
97
|
sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
|
|
85
98
|
fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,
|
|
86
|
-
fileUploadAllowlist: ctx.fileUploadAllowlist
|
|
99
|
+
fileUploadAllowlist: ctx.fileUploadAllowlist,
|
|
100
|
+
signal: ctx.signal
|
|
87
101
|
});
|
|
88
102
|
}
|
|
89
103
|
}
|
|
90
|
-
|
|
104
|
+
logger.debug(`Uploading file "${value.name}"`);
|
|
91
105
|
return getFileDataAfterUploadingToS3(value, {
|
|
92
106
|
toolSlug: ctx.toolSlug,
|
|
93
107
|
toolkitSlug: ctx.toolkitSlug,
|
|
94
108
|
client: ctx.client,
|
|
95
109
|
sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
|
|
96
|
-
fileUploadPathDenySegments: ctx.fileUploadPathDenySegments
|
|
110
|
+
fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,
|
|
111
|
+
signal: ctx.signal
|
|
97
112
|
});
|
|
98
113
|
}
|
|
99
114
|
const uploadableVariant = findSchemaVariantWithFileProperty(schema, "file_uploadable", value);
|
|
@@ -115,14 +130,15 @@ const hydrateFiles = async (value, schema, ctx) => {
|
|
|
115
130
|
const downloadS3File = async (value, ctx) => {
|
|
116
131
|
const { s3url, mimetype } = value;
|
|
117
132
|
try {
|
|
118
|
-
|
|
133
|
+
logger.debug(`Downloading from S3: ${s3url}`);
|
|
119
134
|
const dl = await downloadFileFromS3({
|
|
120
135
|
toolSlug: ctx.toolSlug,
|
|
121
136
|
s3Url: s3url,
|
|
122
137
|
mimeType: mimetype ?? "application/octet-stream",
|
|
123
|
-
fileDownloadDir: ctx.fileDownloadDir
|
|
138
|
+
fileDownloadDir: ctx.fileDownloadDir,
|
|
139
|
+
signal: ctx.signal
|
|
124
140
|
});
|
|
125
|
-
|
|
141
|
+
logger.debug(`Downloaded → ${dl.filePath}`);
|
|
126
142
|
return {
|
|
127
143
|
uri: dl.filePath,
|
|
128
144
|
file_downloaded: dl.filePath ? true : false,
|
|
@@ -130,7 +146,7 @@ const downloadS3File = async (value, ctx) => {
|
|
|
130
146
|
mimeType: dl.mimeType
|
|
131
147
|
};
|
|
132
148
|
} catch (err) {
|
|
133
|
-
|
|
149
|
+
logger.error(`Download failed: ${s3url}`, { cause: err });
|
|
134
150
|
return {
|
|
135
151
|
uri: "",
|
|
136
152
|
file_downloaded: false,
|
|
@@ -179,40 +195,44 @@ var FileToolModifier = class {
|
|
|
179
195
|
}
|
|
180
196
|
async modifyToolSchema(schema) {
|
|
181
197
|
if (!schema.inputParameters?.properties) return schema;
|
|
182
|
-
const
|
|
198
|
+
const inputParameters = resolveFileSchema(schema.inputParameters);
|
|
199
|
+
const properties = transformProperties(inputParameters.properties);
|
|
183
200
|
return {
|
|
184
201
|
...schema,
|
|
185
202
|
inputParameters: {
|
|
186
|
-
...
|
|
203
|
+
...inputParameters,
|
|
204
|
+
type: "object",
|
|
187
205
|
properties
|
|
188
206
|
}
|
|
189
207
|
};
|
|
190
208
|
}
|
|
191
209
|
async fileUploadModifier(tool, options) {
|
|
192
|
-
const { params, toolSlug, toolkitSlug = "unknown" } = options;
|
|
210
|
+
const { params, toolSlug, toolkitSlug = "unknown", signal } = options;
|
|
193
211
|
const { arguments: args } = params;
|
|
194
212
|
if (!args || typeof args !== "object") return params;
|
|
195
213
|
try {
|
|
196
|
-
const newArgs = await hydrateFiles(args, tool.inputParameters, {
|
|
214
|
+
const newArgs = await withCancellation(() => hydrateFiles(args, resolveFileSchema(tool.inputParameters), {
|
|
197
215
|
toolSlug,
|
|
198
216
|
toolkitSlug,
|
|
199
217
|
client: this.client,
|
|
200
|
-
...this.fileUploadPathOptions
|
|
201
|
-
|
|
218
|
+
...this.fileUploadPathOptions,
|
|
219
|
+
signal
|
|
220
|
+
}), signal);
|
|
202
221
|
return {
|
|
203
222
|
...params,
|
|
204
223
|
arguments: newArgs
|
|
205
224
|
};
|
|
206
225
|
} catch (error) {
|
|
207
|
-
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;
|
|
208
227
|
throw new ComposioFileUploadError("Failed to upload file", { cause: error });
|
|
209
228
|
}
|
|
210
229
|
}
|
|
211
230
|
async fileDownloadModifier(tool, options) {
|
|
212
|
-
const { result, toolSlug } = options;
|
|
213
|
-
const dataWithDownloads = await hydrateDownloads(result.data, tool.outputParameters, {
|
|
231
|
+
const { result, toolSlug, signal } = options;
|
|
232
|
+
const dataWithDownloads = await hydrateDownloads(result.data, resolveFileSchema(tool.outputParameters), {
|
|
214
233
|
toolSlug,
|
|
215
|
-
fileDownloadDir: this.fileUploadPathOptions.fileDownloadDir
|
|
234
|
+
fileDownloadDir: this.fileUploadPathOptions.fileDownloadDir,
|
|
235
|
+
signal
|
|
216
236
|
});
|
|
217
237
|
return {
|
|
218
238
|
...result,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gn as Tool, xn as ToolExecuteResponse, yn as ToolExecuteParams } from "../../BaseProvider-
|
|
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).";
|