@composio/core 0.14.0 → 0.15.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-lCxnjFKQ.d.mts → BaseProvider-BN2-Nktx.d.mts} +224 -180
- package/dist/{CustomTool-C_5NvBsX.mjs → CustomTool-l-j5HtEf.mjs} +1 -1
- package/dist/{CustomTool-CmokRT9q.d.mts → CustomTool-zjeDpZ91.d.mts} +1 -2
- package/dist/FileModifierErrors-B8V8_3VE.mjs +97 -0
- package/dist/{SsrfErrors-BQRozkeU.mjs → SsrfErrors-DNJt57GL.mjs} +5 -98
- package/dist/{Telemetry-llfvticE.mjs → Telemetry-DuGJSwUt.mjs} +3 -3
- package/dist/{cancellation-W65QRyj2.mjs → cancellation-BbJ-UQ__.mjs} +2 -2
- package/dist/{composio-6C8kHtqc.d.mts → composio-Bf8hnBBq.d.mts} +24 -21
- package/dist/{customTool.types-kFhNYuzh.d.mts → customTool.types-Bhom9a2R.d.mts} +73 -40
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +2 -0
- package/dist/{errors-B165yJUQ.mjs → errors-BcEUHZbq.mjs} +2 -1
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-iPFi2o4i.mjs → fileUtils.node-BQ0fWge3.mjs} +9 -154
- package/dist/index.d.mts +1585 -752
- package/dist/index.mjs +39 -20
- package/dist/models/Files.node.d.mts +2 -11
- package/dist/models/Files.node.mjs +2 -2
- package/dist/models/Files.workerd.d.mts +0 -1
- package/dist/platform/node.d.mts +1 -2
- package/dist/platform/node.mjs +24 -0
- package/dist/platform/workerd.d.mts +1 -2
- package/dist/platform/workerd.mjs +30 -3
- package/dist/{sensitiveFileUploadPaths-B1OLsd8F.mjs → sensitiveFileUploadPaths-BVEt0peg.mjs} +64 -9
- package/dist/{types-yCrveqAj.d.mts → types-CePuCfD-.d.mts} +2 -3
- package/dist/{types-DY1r-kN9.d.mts → types-D5A2wzBl.d.mts} +8 -0
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -2
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -2
- package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -4
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -2
- package/dist/utils/ssrfGuard.node.d.mts +22 -0
- package/dist/utils/ssrfGuard.node.mjs +153 -0
- package/dist/utils/ssrfGuard.workerd.d.mts +9 -0
- package/dist/utils/ssrfGuard.workerd.mjs +17 -0
- package/package.json +17 -11
- package/src/errors/SsrfErrors.ts +4 -3
- package/src/models/ToolRouterSessionFileMount.ts +10 -3
- package/src/platform/node.ts +40 -0
- package/src/platform/types.ts +9 -0
- package/src/platform/workerd.ts +35 -3
- package/src/telemetry/redact.ts +6 -1
- package/src/types/tool.types.ts +52 -8
- package/src/utils/fileUtils.node.ts +5 -2
- package/src/utils/modifiers/FileToolModifier.node.ts +3 -3
- package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +6 -4
- package/src/utils/readResponseBody.ts +63 -0
- package/src/utils/sdk.ts +2 -2
- package/src/utils/sensitiveFileUploadPaths.ts +12 -9
- package/src/utils/ssrfGuard.node.ts +12 -8
- package/src/utils/ssrfGuard.workerd.ts +19 -0
- package/src/utils/version.ts +21 -20
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { dt as ConnectionDataSchema, n as BaseComposioProvider, rn as SessionMetaToolOptions } from "./BaseProvider-
|
|
1
|
+
import { dt as ConnectionDataSchema, n as BaseComposioProvider, rn as SessionMetaToolOptions } from "./BaseProvider-BN2-Nktx.mjs";
|
|
2
2
|
import { Composio } from "@composio/client";
|
|
3
3
|
import z, { z as z$1 } from "zod/v3";
|
|
4
4
|
import { z as z$2 } from "zod/v4";
|
|
5
5
|
import { ConnectedAccountUpdateStatusParams as UpdateConnectedAccountParams } from "@composio/client/resources/connected-accounts";
|
|
6
6
|
import { SessionCreateParams, SessionCreateResponse } from "@composio/client/resources/tool-router/session/session.mjs";
|
|
7
|
-
|
|
8
7
|
//#region src/types/connectedAccounts.types.d.ts
|
|
9
8
|
/**
|
|
10
9
|
* Connected Account create parameters
|
|
@@ -221,7 +220,8 @@ declare const CreateConnectedAccountResponseSchema: z$1.ZodObject<{
|
|
|
221
220
|
}>;
|
|
222
221
|
type CreateConnectedAccountResponse = z$1.infer<typeof CreateConnectedAccountResponseSchema>;
|
|
223
222
|
declare const ConnectedAccountAuthConfigSchema: z$1.ZodObject<{
|
|
224
|
-
id: z$1.ZodString;
|
|
223
|
+
id: z$1.ZodString;
|
|
224
|
+
/** @deprecated Use `connectedAccount.state.authScheme` instead. */
|
|
225
225
|
authScheme: z$1.ZodOptional<z$1.ZodEnum<["OAUTH2", "OAUTH1", "API_KEY", "BASIC", "BILLCOM_AUTH", "BEARER_TOKEN", "GOOGLE_SERVICE_ACCOUNT", "NO_AUTH", "BASIC_WITH_JWT", "CALCOM_AUTH", "SERVICE_ACCOUNT", "SAML", "DCR_OAUTH", "S2S_OAUTH2"]>>;
|
|
226
226
|
isComposioManaged: z$1.ZodBoolean;
|
|
227
227
|
isDisabled: z$1.ZodBoolean;
|
|
@@ -241,8 +241,10 @@ declare const ConnectedAccountRetrieveResponseSchema: z$1.ZodType<{
|
|
|
241
241
|
id: string;
|
|
242
242
|
authConfig: z$1.infer<typeof ConnectedAccountAuthConfigSchema>;
|
|
243
243
|
wordId?: string | null;
|
|
244
|
-
alias?: string | null;
|
|
245
|
-
|
|
244
|
+
alias?: string | null;
|
|
245
|
+
/** @deprecated Use `connectedAccount.state` instead — `data` is a legacy raw credential field. */
|
|
246
|
+
data?: Record<string, unknown>;
|
|
247
|
+
/** @deprecated Use `connectedAccount.state` instead — `params` is a legacy raw credential field. */
|
|
246
248
|
params?: Record<string, unknown>;
|
|
247
249
|
status: ConnectedAccountStatusEnum;
|
|
248
250
|
statusReason: string | null;
|
|
@@ -301,8 +303,10 @@ declare const ConnectedAccountListResponseSchema: z$1.ZodObject<{
|
|
|
301
303
|
id: string;
|
|
302
304
|
authConfig: z$1.infer<typeof ConnectedAccountAuthConfigSchema>;
|
|
303
305
|
wordId?: string | null;
|
|
304
|
-
alias?: string | null;
|
|
305
|
-
|
|
306
|
+
alias?: string | null;
|
|
307
|
+
/** @deprecated Use `connectedAccount.state` instead — `data` is a legacy raw credential field. */
|
|
308
|
+
data?: Record<string, unknown>;
|
|
309
|
+
/** @deprecated Use `connectedAccount.state` instead — `params` is a legacy raw credential field. */
|
|
306
310
|
params?: Record<string, unknown>;
|
|
307
311
|
status: ConnectedAccountStatusEnum;
|
|
308
312
|
statusReason: string | null;
|
|
@@ -319,8 +323,10 @@ declare const ConnectedAccountListResponseSchema: z$1.ZodObject<{
|
|
|
319
323
|
id: string;
|
|
320
324
|
authConfig: z$1.infer<typeof ConnectedAccountAuthConfigSchema>;
|
|
321
325
|
wordId?: string | null;
|
|
322
|
-
alias?: string | null;
|
|
323
|
-
|
|
326
|
+
alias?: string | null;
|
|
327
|
+
/** @deprecated Use `connectedAccount.state` instead — `data` is a legacy raw credential field. */
|
|
328
|
+
data?: Record<string, unknown>;
|
|
329
|
+
/** @deprecated Use `connectedAccount.state` instead — `params` is a legacy raw credential field. */
|
|
324
330
|
params?: Record<string, unknown>;
|
|
325
331
|
status: ConnectedAccountStatusEnum;
|
|
326
332
|
statusReason: string | null;
|
|
@@ -341,8 +347,10 @@ declare const ConnectedAccountListResponseSchema: z$1.ZodObject<{
|
|
|
341
347
|
id: string;
|
|
342
348
|
authConfig: z$1.infer<typeof ConnectedAccountAuthConfigSchema>;
|
|
343
349
|
wordId?: string | null;
|
|
344
|
-
alias?: string | null;
|
|
345
|
-
|
|
350
|
+
alias?: string | null;
|
|
351
|
+
/** @deprecated Use `connectedAccount.state` instead — `data` is a legacy raw credential field. */
|
|
352
|
+
data?: Record<string, unknown>;
|
|
353
|
+
/** @deprecated Use `connectedAccount.state` instead — `params` is a legacy raw credential field. */
|
|
346
354
|
params?: Record<string, unknown>;
|
|
347
355
|
status: ConnectedAccountStatusEnum;
|
|
348
356
|
statusReason: string | null;
|
|
@@ -363,8 +371,10 @@ declare const ConnectedAccountListResponseSchema: z$1.ZodObject<{
|
|
|
363
371
|
id: string;
|
|
364
372
|
authConfig: z$1.infer<typeof ConnectedAccountAuthConfigSchema>;
|
|
365
373
|
wordId?: string | null;
|
|
366
|
-
alias?: string | null;
|
|
367
|
-
|
|
374
|
+
alias?: string | null;
|
|
375
|
+
/** @deprecated Use `connectedAccount.state` instead — `data` is a legacy raw credential field. */
|
|
376
|
+
data?: Record<string, unknown>;
|
|
377
|
+
/** @deprecated Use `connectedAccount.state` instead — `params` is a legacy raw credential field. */
|
|
368
378
|
params?: Record<string, unknown>;
|
|
369
379
|
status: ConnectedAccountStatusEnum;
|
|
370
380
|
statusReason: string | null;
|
|
@@ -590,8 +600,10 @@ type ComposioRequestOptions = {
|
|
|
590
600
|
//#region src/types/ToolRouterSessionFilesMount.types.d.ts
|
|
591
601
|
declare const ToolRouterSessionFilesMountListOptionsSchema: z.ZodObject<{
|
|
592
602
|
path: z.ZodOptional<z.ZodString>;
|
|
593
|
-
mountId: z.ZodDefault<z.ZodString>;
|
|
594
|
-
|
|
603
|
+
mountId: z.ZodDefault<z.ZodString>;
|
|
604
|
+
/** Pagination cursor from the previous response nextCursor field */
|
|
605
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
606
|
+
/** Maximum number of files to return per page (1-500) */
|
|
595
607
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
596
608
|
}, "strip", z.ZodTypeAny, {
|
|
597
609
|
mountId: string;
|
|
@@ -658,8 +670,10 @@ declare const FileListResponseSchema: z.ZodEffects<z.ZodObject<{
|
|
|
658
670
|
}>;
|
|
659
671
|
type FileListResponse = z.infer<typeof FileListResponseSchema>;
|
|
660
672
|
declare const ToolRouterSessionFilesMountUploadOptionsSchema: z.ZodObject<{
|
|
661
|
-
/** Remote path/filename on the mount. When passing a buffer, either mimetype or remotePath is required. */
|
|
662
|
-
|
|
673
|
+
/** Remote path/filename on the mount. When passing a buffer, either mimetype or remotePath is required. */
|
|
674
|
+
remotePath: z.ZodOptional<z.ZodString>;
|
|
675
|
+
mountId: z.ZodDefault<z.ZodString>;
|
|
676
|
+
/** MIME type. When passing a buffer, either mimetype or remotePath is required. Ignored when passing File (uses file.type). */
|
|
663
677
|
mimetype: z.ZodOptional<z.ZodString>;
|
|
664
678
|
}, "strip", z.ZodTypeAny, {
|
|
665
679
|
mountId: string;
|
|
@@ -854,6 +868,8 @@ declare class ToolRouterSessionFilesMount {
|
|
|
854
868
|
*
|
|
855
869
|
* Accepts a file path (local or URL), a native File object, or a raw buffer.
|
|
856
870
|
* The file is stored in the virtual filesystem associated with the tool router session.
|
|
871
|
+
* URL inputs require a Node.js or Bun runtime so the destination can be DNS-validated;
|
|
872
|
+
* edge runtimes must fetch the file themselves and pass a File or ArrayBuffer.
|
|
857
873
|
*
|
|
858
874
|
* @param input - File path (string), native File, or raw buffer (ArrayBuffer | Uint8Array).
|
|
859
875
|
* @param options - Optional configuration. When passing a buffer, remotePath is required.
|
|
@@ -1298,10 +1314,10 @@ declare const ToolRouterCreateSessionConfigSchema: z.ZodEffects<z.ZodEffects<z.Z
|
|
|
1298
1314
|
} | {
|
|
1299
1315
|
enable: string[];
|
|
1300
1316
|
} | undefined;
|
|
1317
|
+
authConfigs?: Record<string, string> | undefined;
|
|
1301
1318
|
preload?: {
|
|
1302
1319
|
tools?: string[] | "all" | undefined;
|
|
1303
1320
|
} | undefined;
|
|
1304
|
-
authConfigs?: Record<string, string> | undefined;
|
|
1305
1321
|
sessionPreset?: "direct_tools" | undefined;
|
|
1306
1322
|
mcp?: boolean | undefined;
|
|
1307
1323
|
connectedAccounts?: Record<string, string | string[]> | undefined;
|
|
@@ -1354,10 +1370,10 @@ declare const ToolRouterCreateSessionConfigSchema: z.ZodEffects<z.ZodEffects<z.Z
|
|
|
1354
1370
|
} | {
|
|
1355
1371
|
enable: string[];
|
|
1356
1372
|
} | undefined;
|
|
1373
|
+
authConfigs?: Record<string, string> | undefined;
|
|
1357
1374
|
preload?: {
|
|
1358
1375
|
tools?: string[] | "all" | undefined;
|
|
1359
1376
|
} | undefined;
|
|
1360
|
-
authConfigs?: Record<string, string> | undefined;
|
|
1361
1377
|
sessionPreset?: "direct_tools" | undefined;
|
|
1362
1378
|
mcp?: boolean | undefined;
|
|
1363
1379
|
connectedAccounts?: Record<string, string | string[]> | undefined;
|
|
@@ -1410,10 +1426,10 @@ declare const ToolRouterCreateSessionConfigSchema: z.ZodEffects<z.ZodEffects<z.Z
|
|
|
1410
1426
|
} | {
|
|
1411
1427
|
enable: string[];
|
|
1412
1428
|
} | undefined;
|
|
1429
|
+
authConfigs?: Record<string, string> | undefined;
|
|
1413
1430
|
preload?: {
|
|
1414
1431
|
tools?: string[] | "all" | undefined;
|
|
1415
1432
|
} | undefined;
|
|
1416
|
-
authConfigs?: Record<string, string> | undefined;
|
|
1417
1433
|
sessionPreset?: "direct_tools" | undefined;
|
|
1418
1434
|
mcp?: boolean | undefined;
|
|
1419
1435
|
connectedAccounts?: Record<string, string | string[]> | undefined;
|
|
@@ -1466,10 +1482,10 @@ declare const ToolRouterCreateSessionConfigSchema: z.ZodEffects<z.ZodEffects<z.Z
|
|
|
1466
1482
|
} | {
|
|
1467
1483
|
enable: string[];
|
|
1468
1484
|
} | undefined;
|
|
1485
|
+
authConfigs?: Record<string, string> | undefined;
|
|
1469
1486
|
preload?: {
|
|
1470
1487
|
tools?: string[] | "all" | undefined;
|
|
1471
1488
|
} | undefined;
|
|
1472
|
-
authConfigs?: Record<string, string> | undefined;
|
|
1473
1489
|
sessionPreset?: "direct_tools" | undefined;
|
|
1474
1490
|
mcp?: boolean | undefined;
|
|
1475
1491
|
connectedAccounts?: Record<string, string | string[]> | undefined;
|
|
@@ -1522,10 +1538,10 @@ declare const ToolRouterCreateSessionConfigSchema: z.ZodEffects<z.ZodEffects<z.Z
|
|
|
1522
1538
|
} | {
|
|
1523
1539
|
enable: string[];
|
|
1524
1540
|
} | undefined;
|
|
1541
|
+
authConfigs?: Record<string, string> | undefined;
|
|
1525
1542
|
preload?: {
|
|
1526
1543
|
tools?: string[] | "all" | undefined;
|
|
1527
1544
|
} | undefined;
|
|
1528
|
-
authConfigs?: Record<string, string> | undefined;
|
|
1529
1545
|
sessionPreset?: "direct_tools" | undefined;
|
|
1530
1546
|
mcp?: boolean | undefined;
|
|
1531
1547
|
connectedAccounts?: Record<string, string | string[]> | undefined;
|
|
@@ -2200,10 +2216,15 @@ interface ToolRouterSessionMetadata {
|
|
|
2200
2216
|
inlineCustomToolsPayload?: InlineCustomToolsWirePayload;
|
|
2201
2217
|
}
|
|
2202
2218
|
declare const SessionProxyExecuteParamsSchema: z.ZodObject<{
|
|
2203
|
-
/** The toolkit whose connected account to use for auth (e.g. 'gmail', 'github') */
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2219
|
+
/** The toolkit whose connected account to use for auth (e.g. 'gmail', 'github') */
|
|
2220
|
+
toolkit: z.ZodString;
|
|
2221
|
+
/** The API endpoint URL to call */
|
|
2222
|
+
endpoint: z.ZodString;
|
|
2223
|
+
/** HTTP method */
|
|
2224
|
+
method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>;
|
|
2225
|
+
/** Request body (for POST/PUT/PATCH) */
|
|
2226
|
+
body: z.ZodOptional<z.ZodUnknown>;
|
|
2227
|
+
/** Query params or headers to include */
|
|
2207
2228
|
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2208
2229
|
in: z.ZodEnum<["query", "header"]>;
|
|
2209
2230
|
name: z.ZodString;
|
|
@@ -2403,10 +2424,10 @@ declare const ToolRouterUpdateSessionConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2403
2424
|
} | {
|
|
2404
2425
|
enable: string[];
|
|
2405
2426
|
} | undefined;
|
|
2427
|
+
authConfigs?: Record<string, string> | undefined;
|
|
2406
2428
|
preload?: {
|
|
2407
2429
|
tools?: string[] | "all" | undefined;
|
|
2408
2430
|
} | undefined;
|
|
2409
|
-
authConfigs?: Record<string, string> | undefined;
|
|
2410
2431
|
connectedAccounts?: Record<string, string[]> | undefined;
|
|
2411
2432
|
manageConnections?: boolean | {
|
|
2412
2433
|
enable?: boolean | undefined;
|
|
@@ -2450,10 +2471,10 @@ declare const ToolRouterUpdateSessionConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2450
2471
|
} | {
|
|
2451
2472
|
enable: string[];
|
|
2452
2473
|
} | undefined;
|
|
2474
|
+
authConfigs?: Record<string, string> | undefined;
|
|
2453
2475
|
preload?: {
|
|
2454
2476
|
tools?: string[] | "all" | undefined;
|
|
2455
2477
|
} | undefined;
|
|
2456
|
-
authConfigs?: Record<string, string> | undefined;
|
|
2457
2478
|
connectedAccounts?: Record<string, string | string[]> | undefined;
|
|
2458
2479
|
manageConnections?: boolean | {
|
|
2459
2480
|
enable?: boolean | undefined;
|
|
@@ -2497,10 +2518,10 @@ declare const ToolRouterUpdateSessionConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2497
2518
|
} | {
|
|
2498
2519
|
enable: string[];
|
|
2499
2520
|
} | undefined;
|
|
2521
|
+
authConfigs?: Record<string, string> | undefined;
|
|
2500
2522
|
preload?: {
|
|
2501
2523
|
tools?: string[] | "all" | undefined;
|
|
2502
2524
|
} | undefined;
|
|
2503
|
-
authConfigs?: Record<string, string> | undefined;
|
|
2504
2525
|
connectedAccounts?: Record<string, string[]> | undefined;
|
|
2505
2526
|
manageConnections?: boolean | {
|
|
2506
2527
|
enable?: boolean | undefined;
|
|
@@ -2544,10 +2565,10 @@ declare const ToolRouterUpdateSessionConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2544
2565
|
} | {
|
|
2545
2566
|
enable: string[];
|
|
2546
2567
|
} | undefined;
|
|
2568
|
+
authConfigs?: Record<string, string> | undefined;
|
|
2547
2569
|
preload?: {
|
|
2548
2570
|
tools?: string[] | "all" | undefined;
|
|
2549
2571
|
} | undefined;
|
|
2550
|
-
authConfigs?: Record<string, string> | undefined;
|
|
2551
2572
|
connectedAccounts?: Record<string, string | string[]> | undefined;
|
|
2552
2573
|
manageConnections?: boolean | {
|
|
2553
2574
|
enable?: boolean | undefined;
|
|
@@ -2708,8 +2729,11 @@ declare const CreateCustomToolBaseSchema: z$1.ZodObject<{
|
|
|
2708
2729
|
}>;
|
|
2709
2730
|
/** Options for creating a custom tool via `createCustomTool()`. */
|
|
2710
2731
|
type CreateCustomToolParams<T extends AnyZodSchema> = z$1.infer<typeof CreateCustomToolBaseSchema> & {
|
|
2711
|
-
/** Zod schema for input parameters */
|
|
2712
|
-
|
|
2732
|
+
/** Zod schema for input parameters */
|
|
2733
|
+
inputParams: T;
|
|
2734
|
+
/** Optional Zod schema for output parameters (sent to backend for documentation) */
|
|
2735
|
+
outputParams?: AnyZodSchema;
|
|
2736
|
+
/** The function that executes the tool */
|
|
2713
2737
|
execute: CustomToolExecuteFn<T>;
|
|
2714
2738
|
};
|
|
2715
2739
|
/**
|
|
@@ -2761,7 +2785,8 @@ declare const CreateCustomToolkitBaseSchema: z$1.ZodObject<{
|
|
|
2761
2785
|
}>;
|
|
2762
2786
|
/** Options for creating a custom toolkit via `createCustomToolkit()`. */
|
|
2763
2787
|
type CreateCustomToolkitParams = z$1.infer<typeof CreateCustomToolkitBaseSchema> & {
|
|
2764
|
-
/** Tools to include in this toolkit. Must not have `extendsToolkit` set. */
|
|
2788
|
+
/** Tools to include in this toolkit. Must not have `extendsToolkit` set. */
|
|
2789
|
+
tools: CustomTool[];
|
|
2765
2790
|
};
|
|
2766
2791
|
/**
|
|
2767
2792
|
* Custom toolkit definition returned from `createCustomToolkit()`.
|
|
@@ -2787,17 +2812,25 @@ interface InlineCustomToolsWirePayload {
|
|
|
2787
2812
|
}
|
|
2788
2813
|
/** @internal Entry in the per-session custom tools routing map. */
|
|
2789
2814
|
type CustomToolsMapEntry = {
|
|
2790
|
-
handle: CustomTool;
|
|
2791
|
-
|
|
2815
|
+
handle: CustomTool;
|
|
2816
|
+
/** @internal The final slug assigned by the prefixing rules (e.g. LOCAL_GREP, LOCAL_GMAIL_GET_EMAILS) */
|
|
2817
|
+
finalSlug: string;
|
|
2818
|
+
/** Resolved toolkit — from extendsToolkit, parent custom toolkit, or undefined for standalone */
|
|
2792
2819
|
toolkit?: string;
|
|
2793
2820
|
};
|
|
2794
2821
|
/** @internal Lookup maps used by ToolRouterSession for routing custom tools. */
|
|
2795
2822
|
type CustomToolsMap = {
|
|
2796
|
-
/** Lookup by final slug (e.g. LOCAL_GET_USER_CONTEXT) — used for agent execution path */
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2823
|
+
/** Lookup by final slug (e.g. LOCAL_GET_USER_CONTEXT) — used for agent execution path */
|
|
2824
|
+
byFinalSlug: Map<string, CustomToolsMapEntry>;
|
|
2825
|
+
/** Lookup by unique original slug (e.g. GET_USER_CONTEXT) — used for programmatic session.execute() */
|
|
2826
|
+
byOriginalSlug: Map<string, CustomToolsMapEntry>;
|
|
2827
|
+
/** Lookup by resolved toolkit + original slug — used when multiple custom toolkits reuse tool names */
|
|
2828
|
+
byToolkitAndOriginalSlug?: Map<string, CustomToolsMapEntry>;
|
|
2829
|
+
/** Original slugs that appear in multiple toolkits and cannot be resolved safely without the final slug */
|
|
2830
|
+
ambiguousOriginalSlugs?: Set<string>;
|
|
2831
|
+
/** The original custom toolkits passed at session creation — used for session.customToolkits() */
|
|
2832
|
+
toolkits?: CustomToolkit[];
|
|
2833
|
+
/** The original standalone custom tools passed at session creation — kept for inline re-injection on later requests. */
|
|
2801
2834
|
tools?: CustomTool[];
|
|
2802
2835
|
};
|
|
2803
2836
|
/** A custom tool as registered in a session, with its final resolved slug. */
|
|
@@ -126,6 +126,8 @@ Uploads a file to the session's file mount.
|
|
|
126
126
|
|
|
127
127
|
Accepts a file path (local or URL), a native File object, or a raw buffer.
|
|
128
128
|
The file is stored in the virtual filesystem associated with the tool router session.
|
|
129
|
+
URL inputs require a Node.js or Bun runtime so the destination can be DNS-validated;
|
|
130
|
+
edge runtimes must fetch the file themselves and pass a File or ArrayBuffer.
|
|
129
131
|
|
|
130
132
|
```typescript
|
|
131
133
|
async upload(input: string | File | ArrayBuffer | Uint8Array, options?: ToolRouterSessionFilesMountUploadOptions): Promise<RemoteFile>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as ComposioError$1 } from "./SsrfErrors-DNJt57GL.mjs";
|
|
2
|
+
import "./FileModifierErrors-B8V8_3VE.mjs";
|
|
2
3
|
import { APIError, APIUserAbortError } from "@composio/client";
|
|
3
4
|
import { ZodError } from "zod/v3";
|
|
4
5
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as SessionContext, a as CreateCustomToolkitParams, c as CustomToolExecuteFn, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams } from "../customTool.types-
|
|
2
|
-
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-
|
|
1
|
+
import { S as SessionContext, a as CreateCustomToolkitParams, c as CustomToolExecuteFn, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams } from "../customTool.types-Bhom9a2R.mjs";
|
|
2
|
+
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-zjeDpZ91.mjs";
|
|
3
3
|
export { type CreateCustomToolParams, type CreateCustomToolkitParams, type CustomTool, type CustomToolExecuteFn, type CustomToolkit, type SessionContext, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as createCustomToolkit, i as createCustomTool } from "../CustomTool-
|
|
1
|
+
import { a as createCustomToolkit, i as createCustomTool } from "../CustomTool-l-j5HtEf.mjs";
|
|
2
2
|
|
|
3
3
|
export { createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as COMPOSIO_DIR, i as logger, u as TEMP_FILES_DIRECTORY_NAME } from "./SsrfErrors-DNJt57GL.mjs";
|
|
2
|
+
import { i as ComposioFileUploadPathNotAllowedError, t as ComposioFileNotFoundError } from "./FileModifierErrors-B8V8_3VE.mjs";
|
|
3
|
+
import { c as getRandomShortId, i as readResponseBodyWithLimit, n as assertSafeFileUploadPath, o as base64ToUint8Array, s as uint8ArrayToBase64 } from "./sensitiveFileUploadPaths-BVEt0peg.mjs";
|
|
4
|
+
import { ssrfSafeFetch } from "./utils/ssrfGuard.node.mjs";
|
|
3
5
|
import { platform } from "#platform";
|
|
4
6
|
import fs from "node:fs";
|
|
5
7
|
import * as path from "node:path";
|
|
6
8
|
import crypto from "node:crypto";
|
|
7
|
-
import { lookup } from "node:dns/promises";
|
|
8
|
-
import { isIP } from "node:net";
|
|
9
9
|
|
|
10
10
|
//#region src/utils/uploadDirAllowlist.node.ts
|
|
11
11
|
/**
|
|
@@ -151,153 +151,6 @@ function assertPathInsideUploadDirs(filePath, allowlist) {
|
|
|
151
151
|
} });
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/utils/ssrfGuard.node.ts
|
|
156
|
-
/**
|
|
157
|
-
* SSRF guard for user-supplied URL file inputs.
|
|
158
|
-
*
|
|
159
|
-
* `composio.files.upload(url)` and automatic file upload during tool execution
|
|
160
|
-
* fetch arbitrary user-provided URLs. Without a guard, a caller (or a tool
|
|
161
|
-
* argument produced by an LLM) can point the SDK at internal infrastructure —
|
|
162
|
-
* loopback, RFC1918 ranges, link-local cloud-metadata endpoints
|
|
163
|
-
* (`169.254.169.254`), or a public URL that 3xx-redirects into internal space —
|
|
164
|
-
* turning the SDK into a server-side request forgery probe.
|
|
165
|
-
*
|
|
166
|
-
* This module validates the *resolved* address (not just the hostname string,
|
|
167
|
-
* which defeats decimal/octal/hex IP obfuscation) before every fetch, and
|
|
168
|
-
* follows redirects manually so each hop is re-validated.
|
|
169
|
-
*
|
|
170
|
-
* Known residual: a DNS name could resolve to a public address here and rebind
|
|
171
|
-
* to an internal one before the underlying `fetch` connects (a TOCTOU / DNS
|
|
172
|
-
* rebinding window). Closing that fully requires pinning the validated IP at
|
|
173
|
-
* connect time (a custom dispatcher), which is out of scope for this guard.
|
|
174
|
-
*/
|
|
175
|
-
const MAX_REDIRECTS = 5;
|
|
176
|
-
const ipv4ToLong = (ip) => {
|
|
177
|
-
const [a, b, c, d] = ip.split(".").map(Number);
|
|
178
|
-
return (a << 24 >>> 0 | b << 16 | c << 8 | d) >>> 0;
|
|
179
|
-
};
|
|
180
|
-
const IPV4_BLOCKED_CIDRS = [
|
|
181
|
-
["0.0.0.0", 8],
|
|
182
|
-
["10.0.0.0", 8],
|
|
183
|
-
["100.64.0.0", 10],
|
|
184
|
-
["127.0.0.0", 8],
|
|
185
|
-
["169.254.0.0", 16],
|
|
186
|
-
["172.16.0.0", 12],
|
|
187
|
-
["192.0.0.0", 24],
|
|
188
|
-
["192.0.2.0", 24],
|
|
189
|
-
["192.168.0.0", 16],
|
|
190
|
-
["198.18.0.0", 15],
|
|
191
|
-
["198.51.100.0", 24],
|
|
192
|
-
["203.0.113.0", 24],
|
|
193
|
-
["224.0.0.0", 4],
|
|
194
|
-
["240.0.0.0", 4]
|
|
195
|
-
];
|
|
196
|
-
const isBlockedIpv4Long = (long) => IPV4_BLOCKED_CIDRS.some(([base, bits]) => {
|
|
197
|
-
const mask = bits === 0 ? 0 : 4294967295 << 32 - bits >>> 0;
|
|
198
|
-
return (long & mask) === (ipv4ToLong(base) & mask);
|
|
199
|
-
});
|
|
200
|
-
/**
|
|
201
|
-
* Expand an IPv6 string into its 8 16-bit groups, converting any trailing
|
|
202
|
-
* dotted-quad (e.g. `::ffff:1.2.3.4`) into hex groups first. Returns `null` when
|
|
203
|
-
* the input cannot be parsed.
|
|
204
|
-
*/
|
|
205
|
-
const expandIpv6 = (ip) => {
|
|
206
|
-
let addr = ip;
|
|
207
|
-
const v4Match = addr.match(/^(.*:)(\d+\.\d+\.\d+\.\d+)$/);
|
|
208
|
-
if (v4Match) {
|
|
209
|
-
const long = ipv4ToLong(v4Match[2]);
|
|
210
|
-
addr = `${v4Match[1]}${(long >>> 16 & 65535).toString(16)}:${(long & 65535).toString(16)}`;
|
|
211
|
-
}
|
|
212
|
-
const halves = addr.split("::");
|
|
213
|
-
if (halves.length > 2) return null;
|
|
214
|
-
const head = halves[0] ? halves[0].split(":") : [];
|
|
215
|
-
const tail = halves.length === 2 ? halves[1] ? halves[1].split(":") : [] : [];
|
|
216
|
-
let groups;
|
|
217
|
-
if (halves.length === 2) {
|
|
218
|
-
const missing = 8 - head.length - tail.length;
|
|
219
|
-
if (missing < 0) return null;
|
|
220
|
-
groups = [
|
|
221
|
-
...head,
|
|
222
|
-
...Array(missing).fill("0"),
|
|
223
|
-
...tail
|
|
224
|
-
];
|
|
225
|
-
} else groups = head;
|
|
226
|
-
if (groups.length !== 8) return null;
|
|
227
|
-
return groups.map((g) => parseInt(g || "0", 16));
|
|
228
|
-
};
|
|
229
|
-
const isBlockedIpv6 = (ip) => {
|
|
230
|
-
const h = expandIpv6(ip);
|
|
231
|
-
if (!h) return true;
|
|
232
|
-
if (h.every((x) => x === 0)) return true;
|
|
233
|
-
if (h.slice(0, 7).every((x) => x === 0) && h[7] === 1) return true;
|
|
234
|
-
const isMappedOrCompat = h[0] === 0 && h[1] === 0 && h[2] === 0 && h[3] === 0 && h[4] === 0 && (h[5] === 65535 || h[5] === 0);
|
|
235
|
-
const isNat64 = h[0] === 100 && h[1] === 65435 && h[2] === 0 && h[3] === 0 && h[4] === 0 && h[5] === 0;
|
|
236
|
-
if (isMappedOrCompat || isNat64) return isBlockedIpv4Long((h[6] << 16 >>> 0 | h[7]) >>> 0);
|
|
237
|
-
if ((h[0] & 65024) === 64512) return true;
|
|
238
|
-
if ((h[0] & 65472) === 65152) return true;
|
|
239
|
-
if ((h[0] & 65280) === 65280) return true;
|
|
240
|
-
return false;
|
|
241
|
-
};
|
|
242
|
-
/**
|
|
243
|
-
* True when `ip` is a private, loopback, link-local, or otherwise
|
|
244
|
-
* non-publicly-routable address. Fails closed (returns `true`) for anything that
|
|
245
|
-
* is not a valid IPv4/IPv6 literal.
|
|
246
|
-
*/
|
|
247
|
-
const isBlockedIp = (ip) => {
|
|
248
|
-
const family = isIP(ip);
|
|
249
|
-
if (family === 4) return isBlockedIpv4Long(ipv4ToLong(ip));
|
|
250
|
-
if (family === 6) return isBlockedIpv6(ip);
|
|
251
|
-
return true;
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
* Validate a single URL: it must be http(s), its host must resolve, and every
|
|
255
|
-
* resolved address must be publicly routable. Throws
|
|
256
|
-
* {@link ComposioBlockedInternalUrlError} otherwise.
|
|
257
|
-
*/
|
|
258
|
-
const assertSafeFetchTarget = async (rawUrl) => {
|
|
259
|
-
let url;
|
|
260
|
-
try {
|
|
261
|
-
url = new URL(rawUrl);
|
|
262
|
-
} catch {
|
|
263
|
-
throw new ComposioBlockedInternalUrlError("Refusing to fetch a malformed URL", { url: rawUrl });
|
|
264
|
-
}
|
|
265
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") throw new ComposioBlockedInternalUrlError(`Refusing to fetch a non-http(s) URL (scheme "${url.protocol}")`, { url: rawUrl });
|
|
266
|
-
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
267
|
-
let resolved;
|
|
268
|
-
try {
|
|
269
|
-
resolved = await lookup(host, {
|
|
270
|
-
all: true,
|
|
271
|
-
verbatim: true
|
|
272
|
-
});
|
|
273
|
-
} catch {
|
|
274
|
-
throw new ComposioBlockedInternalUrlError(`Could not resolve host "${host}"`, { url: rawUrl });
|
|
275
|
-
}
|
|
276
|
-
for (const { address } of resolved) if (isBlockedIp(address)) throw new ComposioBlockedInternalUrlError(`Refusing to fetch "${host}" — it resolves to a private, loopback, or link-local address`, {
|
|
277
|
-
url: rawUrl,
|
|
278
|
-
resolvedIp: address
|
|
279
|
-
});
|
|
280
|
-
};
|
|
281
|
-
/**
|
|
282
|
-
* Drop-in replacement for `fetch` that blocks SSRF. Validates the target before
|
|
283
|
-
* connecting and re-validates every redirect hop (redirects are followed
|
|
284
|
-
* manually up to {@link MAX_REDIRECTS}). Non-redirect responses are returned
|
|
285
|
-
* unchanged.
|
|
286
|
-
*/
|
|
287
|
-
const ssrfSafeFetch = async (rawUrl, init = {}, maxRedirects = MAX_REDIRECTS) => {
|
|
288
|
-
let currentUrl = rawUrl;
|
|
289
|
-
for (let hop = 0; hop <= maxRedirects; hop++) {
|
|
290
|
-
await assertSafeFetchTarget(currentUrl);
|
|
291
|
-
const response = await fetch(currentUrl, {
|
|
292
|
-
...init,
|
|
293
|
-
redirect: "manual"
|
|
294
|
-
});
|
|
295
|
-
if (!(response.status >= 300 && response.status < 400 && response.headers.has("location"))) return response;
|
|
296
|
-
currentUrl = new URL(response.headers.get("location"), currentUrl).toString();
|
|
297
|
-
}
|
|
298
|
-
throw new ComposioBlockedInternalUrlError(`Refusing to fetch: too many redirects (max ${maxRedirects})`, { url: rawUrl });
|
|
299
|
-
};
|
|
300
|
-
|
|
301
154
|
//#endregion
|
|
302
155
|
//#region src/utils/fileUtils.node.ts
|
|
303
156
|
/**
|
|
@@ -399,9 +252,11 @@ const readFileContent = async (filePath) => {
|
|
|
399
252
|
};
|
|
400
253
|
const readFileContentFromURL = async (path, signal) => {
|
|
401
254
|
const response = await ssrfSafeFetch(path, { signal });
|
|
402
|
-
if (!response.ok)
|
|
403
|
-
|
|
404
|
-
|
|
255
|
+
if (!response.ok) {
|
|
256
|
+
await response.body?.cancel().catch(() => void 0);
|
|
257
|
+
throw new Error(`Failed to fetch file: ${response.statusText}`);
|
|
258
|
+
}
|
|
259
|
+
const content = await readResponseBodyWithLimit(response);
|
|
405
260
|
const mimeType = response.headers.get("content-type") || "application/octet-stream";
|
|
406
261
|
const pathname = new URL(path).pathname;
|
|
407
262
|
let fileName = platform.basename(pathname);
|