@composio/core 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CustomTool-BaRzlwyV.d.mts → CustomTool-BFkwL1aY.d.mts} +1 -1
- package/dist/{CustomTool-DnCSEC6t.cjs → CustomTool-Bkk0QYzw.cjs} +352 -26
- package/dist/{CustomTool-CVwF_isu.mjs → CustomTool-IIUhFtP8.mjs} +287 -27
- package/dist/{CustomTool-CzhY9iPX.d.cts → CustomTool-PSRHsd85.d.cts} +1 -1
- package/dist/{composio-B75SFMkx.d.cts → composio-BnLWW0B6.d.cts} +249 -166
- package/dist/{composio-CwcLLO7C.d.mts → composio-Dzlk0Wj4.d.mts} +249 -166
- package/dist/{customTool.types-2DhEI1vs.d.cts → customTool.types-BVgnEbR2.d.cts} +467 -30
- package/dist/{customTool.types-BL_z-C_B.d.mts → customTool.types-oV5boR1w.d.mts} +467 -30
- package/dist/experimental/index.cjs +1 -1
- package/dist/experimental/index.d.cts +2 -2
- package/dist/experimental/index.d.mts +3 -3
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.cjs +715 -72
- package/dist/index.d.cts +122 -9
- package/dist/index.d.mts +122 -9
- package/dist/index.mjs +704 -75
- package/dist/{tool.types-CNYy-lBq.d.mts → tool.types-CB_4JKhV.d.mts} +600 -37
- package/dist/{tool.types-BlXcjUs1.d.cts → tool.types-CwbAy9l_.d.cts} +600 -37
- package/dist/{types-CZkT1raQ.d.cts → types-4vkdo_RG.d.cts} +2 -2
- package/dist/{types-DGrpnYFI.d.mts → types-AcoPzTnm.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +4 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +4 -4
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as CustomTool,
|
|
1
|
+
import { a as CustomTool, h as CustomToolkit, i as CreateCustomToolkitParams, n as CreateCustomToolParams } from "./customTool.types-oV5boR1w.mjs";
|
|
2
2
|
import { z as z$1 } from "zod/v3";
|
|
3
3
|
import { SessionCreateResponse } from "@composio/client/resources/tool-router/session/session.mjs";
|
|
4
4
|
|
|
@@ -9,7 +9,11 @@ zod_to_json_schema = require_chunk.__toESM(zod_to_json_schema);
|
|
|
9
9
|
const ConnectedAccountErrorCodes = {
|
|
10
10
|
CONNECTED_ACCOUNT_NOT_FOUND: "CONNECTED_ACCOUNT_NOT_FOUND",
|
|
11
11
|
MULTIPLE_CONNECTED_ACCOUNTS: "MULTIPLE_CONNECTED_ACCOUNTS",
|
|
12
|
-
FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: "FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK"
|
|
12
|
+
FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: "FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK",
|
|
13
|
+
LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED: "LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED",
|
|
14
|
+
SHARED_ACCESS_DENIED: "SHARED_ACCESS_DENIED",
|
|
15
|
+
ACL_ONLY_FOR_SHARED: "ACL_ONLY_FOR_SHARED",
|
|
16
|
+
SHARED_CONNECTION_NOT_ACCESSIBLE: "SHARED_CONNECTION_NOT_ACCESSIBLE"
|
|
13
17
|
};
|
|
14
18
|
var ComposioConnectedAccountNotFoundError = class extends require_FileModifierErrors.ComposioError {
|
|
15
19
|
constructor(message = "Connected account not found", options = {}) {
|
|
@@ -41,6 +45,82 @@ var ComposioFailedToCreateConnectedAccountLink = class extends require_FileModif
|
|
|
41
45
|
this.name = "ComposioFailedToCreateConnectedAccountLink";
|
|
42
46
|
}
|
|
43
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Thrown when a tool execution attempts to use a SHARED connected account
|
|
50
|
+
* but the requesting `userId` is not allowed by the connection's ACL.
|
|
51
|
+
*
|
|
52
|
+
* Surfaces when a SHARED connection is reached directly (e.g. via
|
|
53
|
+
* `composio.tools.execute(slug, { connectedAccountId })`) without going
|
|
54
|
+
* through a tool-router session.
|
|
55
|
+
*/
|
|
56
|
+
var ComposioSharedAccessDeniedError = class extends require_FileModifierErrors.ComposioError {
|
|
57
|
+
constructor(message = "Access denied: this SHARED connected account is not available to the requesting user", options = {}) {
|
|
58
|
+
super(message, {
|
|
59
|
+
...options,
|
|
60
|
+
code: ConnectedAccountErrorCodes.SHARED_ACCESS_DENIED,
|
|
61
|
+
statusCode: 403,
|
|
62
|
+
possibleFixes: options.possibleFixes || ["Ask the connection's creator to grant access via composio.connectedAccounts.updateAcl() — set allowAllUsers, add the userId to allowedUserIds, or remove it from notAllowedUserIds."]
|
|
63
|
+
});
|
|
64
|
+
this.name = "ComposioSharedAccessDeniedError";
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Thrown when ACL fields (`allowAllUsers`, `allowedUserIds`,
|
|
69
|
+
* `notAllowedUserIds`) are sent on a `PRIVATE` connection — at create
|
|
70
|
+
* time or via PATCH. ACL is only meaningful for `SHARED` connections.
|
|
71
|
+
*/
|
|
72
|
+
var ComposioAclOnlyForSharedError = class extends require_FileModifierErrors.ComposioError {
|
|
73
|
+
constructor(message = "ACL fields are only valid on SHARED connected accounts", options = {}) {
|
|
74
|
+
super(message, {
|
|
75
|
+
...options,
|
|
76
|
+
code: ConnectedAccountErrorCodes.ACL_ONLY_FOR_SHARED,
|
|
77
|
+
statusCode: 400,
|
|
78
|
+
possibleFixes: options.possibleFixes || ["Use accountType: \"SHARED\", or omit ACL fields when creating/updating a PRIVATE connection."]
|
|
79
|
+
});
|
|
80
|
+
this.name = "ComposioAclOnlyForSharedError";
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Thrown by `toolRouter.session.create()` / `session.patch()` when the
|
|
85
|
+
* session's `userId` cannot use a pinned SHARED connection. Raised at
|
|
86
|
+
* session-create time so the session never enters a state that fails
|
|
87
|
+
* mid-execution.
|
|
88
|
+
*/
|
|
89
|
+
var ComposioSharedConnectionNotAccessibleError = class extends require_FileModifierErrors.ComposioError {
|
|
90
|
+
constructor(message = "A SHARED connected account pinned in the session config is not accessible to the session user", options = {}) {
|
|
91
|
+
super(message, {
|
|
92
|
+
...options,
|
|
93
|
+
code: ConnectedAccountErrorCodes.SHARED_CONNECTION_NOT_ACCESSIBLE,
|
|
94
|
+
statusCode: 400,
|
|
95
|
+
possibleFixes: options.possibleFixes || ["Grant the session user access via composio.connectedAccounts.updateAcl() on the pinned connection, or pin a different connection the user can use."]
|
|
96
|
+
});
|
|
97
|
+
this.name = "ComposioSharedConnectionNotAccessibleError";
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Thrown by `composio.connectedAccounts.initiate()` when the legacy
|
|
102
|
+
* `POST /api/v3/connected_accounts` endpoint rejects a Composio-managed
|
|
103
|
+
* OAuth (OAuth1, OAuth2, DCR_OAUTH) auth-config request.
|
|
104
|
+
*
|
|
105
|
+
* The retiring path is being phased out — new orgs from 2026-05-08 and
|
|
106
|
+
* all remaining orgs from 2026-07-03. Migrate the call to
|
|
107
|
+
* `composio.connectedAccounts.link()`, which works for every redirectable
|
|
108
|
+
* scheme regardless of whether the auth config is Composio-managed or
|
|
109
|
+
* custom.
|
|
110
|
+
*
|
|
111
|
+
* See: https://docs.composio.dev/docs/changelog/2026/04/24
|
|
112
|
+
*/
|
|
113
|
+
var ComposioLegacyConnectedAccountsEndpointRetiredError = class extends require_FileModifierErrors.ComposioError {
|
|
114
|
+
constructor(message = "POST /api/v3/connected_accounts is no longer supported for Composio-managed OAuth auth configs. Use composio.connectedAccounts.link() instead.", options = {}) {
|
|
115
|
+
super(message, {
|
|
116
|
+
...options,
|
|
117
|
+
code: ConnectedAccountErrorCodes.LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED,
|
|
118
|
+
statusCode: 400,
|
|
119
|
+
possibleFixes: options.possibleFixes || ["Replace `composio.connectedAccounts.initiate(userId, authConfigId, options)` with `composio.connectedAccounts.link(userId, authConfigId, options)`. The return shape (id, redirectUrl, waitForConnection()) is the same.", "Migration guide: https://docs.composio.dev/docs/changelog/2026/04/24"]
|
|
120
|
+
});
|
|
121
|
+
this.name = "ComposioLegacyConnectedAccountsEndpointRetiredError";
|
|
122
|
+
}
|
|
123
|
+
};
|
|
44
124
|
|
|
45
125
|
//#endregion
|
|
46
126
|
//#region src/errors/ToolErrors.ts
|
|
@@ -294,7 +374,8 @@ var ComposioToolkitFetchError = class extends require_FileModifierErrors.Composi
|
|
|
294
374
|
*/
|
|
295
375
|
const ValidationErrorCodes = {
|
|
296
376
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
297
|
-
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
|
|
377
|
+
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR",
|
|
378
|
+
JSON_SCHEMA_REF_RESOLUTION_ERROR: "JSON_SCHEMA_REF_RESOLUTION_ERROR"
|
|
298
379
|
};
|
|
299
380
|
var ValidationError = class extends require_FileModifierErrors.ComposioError {
|
|
300
381
|
constructor(message = "Input validation failed", options = {}) {
|
|
@@ -334,6 +415,19 @@ var JsonSchemaToZodError = class extends require_FileModifierErrors.ComposioErro
|
|
|
334
415
|
});
|
|
335
416
|
}
|
|
336
417
|
};
|
|
418
|
+
/**
|
|
419
|
+
* Thrown when a JSON Schema `$ref` pointer cannot be resolved against the
|
|
420
|
+
* document. Used by `dereferenceJsonSchema` to surface malformed pointers,
|
|
421
|
+
* missing `$defs`/`definitions` targets, or chains exceeding the depth cap.
|
|
422
|
+
*/
|
|
423
|
+
var JsonSchemaRefResolutionError = class extends require_FileModifierErrors.ComposioError {
|
|
424
|
+
constructor(message = "Failed to resolve JSON Schema $ref", options = {}) {
|
|
425
|
+
super(message, {
|
|
426
|
+
...options,
|
|
427
|
+
code: options.code || ValidationErrorCodes.JSON_SCHEMA_REF_RESOLUTION_ERROR
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
};
|
|
337
431
|
|
|
338
432
|
//#endregion
|
|
339
433
|
//#region src/errors/SDKErrors.ts
|
|
@@ -478,6 +572,10 @@ var RemoteFileDownloadError = class extends require_FileModifierErrors.ComposioE
|
|
|
478
572
|
}
|
|
479
573
|
};
|
|
480
574
|
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region src/lib/toolRouterConstants.ts
|
|
577
|
+
const PRELOAD_TOOLS_ALL = "all";
|
|
578
|
+
|
|
481
579
|
//#endregion
|
|
482
580
|
//#region src/types/customTool.types.ts
|
|
483
581
|
/**
|
|
@@ -494,7 +592,8 @@ const CustomToolSlugSchema = zod_v3.z.string().min(1, "slug is required").regex(
|
|
|
494
592
|
const CreateCustomToolBaseSchema = zod_v3.z.object({
|
|
495
593
|
name: zod_v3.z.string().min(1, "createCustomTool: name is required"),
|
|
496
594
|
description: zod_v3.z.string().min(1, "createCustomTool: description is required"),
|
|
497
|
-
extendsToolkit: zod_v3.z.string().optional()
|
|
595
|
+
extendsToolkit: zod_v3.z.string().optional(),
|
|
596
|
+
preload: zod_v3.z.boolean().optional().describe("When true, include this custom tool in session.tools() so it can be called without searching first.")
|
|
498
597
|
});
|
|
499
598
|
/**
|
|
500
599
|
* Zod schema for validating the string/scalar fields of createCustomToolkit() options.
|
|
@@ -502,7 +601,8 @@ const CreateCustomToolBaseSchema = zod_v3.z.object({
|
|
|
502
601
|
*/
|
|
503
602
|
const CreateCustomToolkitBaseSchema = zod_v3.z.object({
|
|
504
603
|
name: zod_v3.z.string().min(1, "createCustomToolkit: name is required"),
|
|
505
|
-
description: zod_v3.z.string().min(1, "createCustomToolkit: description is required")
|
|
604
|
+
description: zod_v3.z.string().min(1, "createCustomToolkit: description is required"),
|
|
605
|
+
preload: zod_v3.z.boolean().optional().describe("When true, include tools from this custom toolkit in session.tools(). Tool-level preload values override this default.")
|
|
506
606
|
});
|
|
507
607
|
|
|
508
608
|
//#endregion
|
|
@@ -616,6 +716,7 @@ function createCustomTool(slug, options) {
|
|
|
616
716
|
name: validated.name,
|
|
617
717
|
description: validated.description,
|
|
618
718
|
extendsToolkit: validated.extendsToolkit,
|
|
719
|
+
preload: validated.preload,
|
|
619
720
|
inputSchema,
|
|
620
721
|
outputSchema,
|
|
621
722
|
inputParams,
|
|
@@ -657,26 +758,103 @@ function createCustomToolkit(slug, options) {
|
|
|
657
758
|
slug: slugResult.data,
|
|
658
759
|
name: validated.name,
|
|
659
760
|
description: validated.description,
|
|
761
|
+
preload: validated.preload,
|
|
660
762
|
tools: options.tools
|
|
661
763
|
};
|
|
662
764
|
}
|
|
663
765
|
/**
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
|
|
766
|
+
* Build the final slug for a custom tool given its context.
|
|
767
|
+
* @internal
|
|
768
|
+
*/
|
|
769
|
+
function buildFinalSlug(toolSlug, toolkitSlug) {
|
|
770
|
+
const upper = toolSlug.toUpperCase();
|
|
771
|
+
return toolkitSlug ? `${LOCAL_TOOL_PREFIX}${toolkitSlug.toUpperCase()}_${upper}` : `${LOCAL_TOOL_PREFIX}${upper}`;
|
|
772
|
+
}
|
|
773
|
+
const qualifiedOriginalSlugKey = (toolkit, originalSlug) => `${toolkit?.toUpperCase() ?? ""}::${originalSlug.toUpperCase()}`;
|
|
774
|
+
const canShareOriginalSlug = (existing, next) => !!existing.toolkit && !!next.toolkit && existing.toolkit.toLowerCase() !== next.toolkit.toLowerCase();
|
|
775
|
+
const addOriginalSlugAlias = (params) => {
|
|
776
|
+
const originalSlugKey = params.originalSlug.toUpperCase();
|
|
777
|
+
if (params.ambiguousOriginalSlugs.has(originalSlugKey)) return;
|
|
778
|
+
const existing = params.byOriginalSlug.get(originalSlugKey);
|
|
779
|
+
if (!existing) {
|
|
780
|
+
params.byOriginalSlug.set(originalSlugKey, params.entry);
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
if (existing.finalSlug.toUpperCase() === params.entry.finalSlug.toUpperCase()) return;
|
|
784
|
+
if (canShareOriginalSlug(existing, params.entry)) {
|
|
785
|
+
params.byOriginalSlug.delete(originalSlugKey);
|
|
786
|
+
params.ambiguousOriginalSlugs.add(originalSlugKey);
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
throw new ValidationError(`Custom tool slug collision: original slug "${params.originalSlug}" maps to multiple final slugs. "${existing.finalSlug}" and "${params.entry.finalSlug}" both resolve from "${originalSlugKey}".`);
|
|
790
|
+
};
|
|
791
|
+
/**
|
|
792
|
+
* Build a CustomToolsMap from custom tools and toolkits.
|
|
793
|
+
* Used internally by ToolRouter.create() to construct the per-session routing map.
|
|
667
794
|
*
|
|
668
795
|
* @internal
|
|
669
|
-
* @param tools -
|
|
670
|
-
* @
|
|
796
|
+
* @param tools - Standalone custom tools
|
|
797
|
+
* @param toolkits - Custom toolkits containing grouped tools
|
|
798
|
+
* @returns Maps for O(1) lookup by both final and original slug
|
|
799
|
+
* @throws If duplicate slugs or cross-group collisions
|
|
671
800
|
*/
|
|
672
|
-
function
|
|
801
|
+
function buildCustomToolsMap(tools, toolkits) {
|
|
802
|
+
const byFinalSlug = /* @__PURE__ */ new Map();
|
|
803
|
+
const byOriginalSlug = /* @__PURE__ */ new Map();
|
|
804
|
+
const byToolkitAndOriginalSlug = /* @__PURE__ */ new Map();
|
|
805
|
+
const ambiguousOriginalSlugs = /* @__PURE__ */ new Set();
|
|
806
|
+
const addEntry = (handle, finalSlug, toolkit) => {
|
|
807
|
+
const originalSlug = handle.slug.toUpperCase();
|
|
808
|
+
const finalSlugKey = finalSlug.toUpperCase();
|
|
809
|
+
if (finalSlug.length > MAX_SLUG_LENGTH) throw new ValidationError(`Custom tool slug "${handle.slug}" produces final slug "${finalSlug}" which exceeds ${MAX_SLUG_LENGTH} characters.`);
|
|
810
|
+
if (byFinalSlug.has(finalSlugKey)) throw new ValidationError(`Custom tool slug collision: "${finalSlug}" is already registered.`);
|
|
811
|
+
const qualifiedKey = qualifiedOriginalSlugKey(toolkit, originalSlug);
|
|
812
|
+
if (byToolkitAndOriginalSlug.has(qualifiedKey)) throw new ValidationError(`Custom tool slug collision: original slug "${handle.slug}" is already registered for toolkit "${toolkit ?? "custom"}".`);
|
|
813
|
+
const entry = {
|
|
814
|
+
handle,
|
|
815
|
+
finalSlug,
|
|
816
|
+
toolkit
|
|
817
|
+
};
|
|
818
|
+
byFinalSlug.set(finalSlugKey, entry);
|
|
819
|
+
byToolkitAndOriginalSlug.set(qualifiedKey, entry);
|
|
820
|
+
addOriginalSlugAlias({
|
|
821
|
+
byOriginalSlug,
|
|
822
|
+
ambiguousOriginalSlugs,
|
|
823
|
+
originalSlug,
|
|
824
|
+
entry
|
|
825
|
+
});
|
|
826
|
+
};
|
|
827
|
+
for (const handle of tools) addEntry(handle, buildFinalSlug(handle.slug, handle.extendsToolkit), handle.extendsToolkit);
|
|
828
|
+
if (toolkits) for (const toolkit of toolkits) for (const handle of toolkit.tools) addEntry(handle, buildFinalSlug(handle.slug, toolkit.slug), toolkit.slug);
|
|
829
|
+
return {
|
|
830
|
+
byFinalSlug,
|
|
831
|
+
byOriginalSlug,
|
|
832
|
+
byToolkitAndOriginalSlug,
|
|
833
|
+
...ambiguousOriginalSlugs.size ? { ambiguousOriginalSlugs } : {},
|
|
834
|
+
toolkits,
|
|
835
|
+
tools: tools.length ? tools : void 0
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
function shouldSerializePreload(preload, inheritedPreload, defaultPreload) {
|
|
839
|
+
const inheritedOrDefault = inheritedPreload ?? defaultPreload;
|
|
840
|
+
if (preload !== void 0) return preload || inheritedOrDefault ? preload : void 0;
|
|
841
|
+
if (inheritedPreload !== void 0) return inheritedPreload || defaultPreload ? inheritedPreload : void 0;
|
|
842
|
+
return defaultPreload ? true : void 0;
|
|
843
|
+
}
|
|
844
|
+
function preloadWireProperty(preload, inheritedPreload, defaultPreload) {
|
|
845
|
+
const serializedPreload = shouldSerializePreload(preload, inheritedPreload, defaultPreload);
|
|
846
|
+
return serializedPreload === void 0 ? {} : { preload: serializedPreload };
|
|
847
|
+
}
|
|
848
|
+
function serializeCustomTools(tools, options = {}) {
|
|
849
|
+
const defaultPreload = options.defaultPreload ?? false;
|
|
673
850
|
return tools.map((handle) => ({
|
|
674
851
|
slug: handle.slug,
|
|
675
852
|
name: handle.name,
|
|
676
853
|
description: handle.description,
|
|
677
854
|
input_schema: handle.inputSchema,
|
|
678
855
|
...handle.outputSchema ? { output_schema: handle.outputSchema } : {},
|
|
679
|
-
...handle.extendsToolkit ? { extends_toolkit: handle.extendsToolkit } : {}
|
|
856
|
+
...handle.extendsToolkit ? { extends_toolkit: handle.extendsToolkit } : {},
|
|
857
|
+
...preloadWireProperty(handle.preload, void 0, defaultPreload)
|
|
680
858
|
}));
|
|
681
859
|
}
|
|
682
860
|
/**
|
|
@@ -686,17 +864,20 @@ function serializeCustomTools(tools) {
|
|
|
686
864
|
* @param toolkits - The custom toolkits to serialize
|
|
687
865
|
* @returns Array of CustomToolkitDefinition for the API payload
|
|
688
866
|
*/
|
|
689
|
-
function serializeCustomToolkits(toolkits) {
|
|
867
|
+
function serializeCustomToolkits(toolkits, options = {}) {
|
|
868
|
+
const defaultPreload = options.defaultPreload ?? false;
|
|
690
869
|
return toolkits.map((tk) => ({
|
|
691
870
|
slug: tk.slug,
|
|
692
871
|
name: tk.name,
|
|
693
872
|
description: tk.description,
|
|
873
|
+
...preloadWireProperty(tk.preload, void 0, defaultPreload),
|
|
694
874
|
tools: tk.tools.map((t) => ({
|
|
695
875
|
slug: t.slug,
|
|
696
876
|
name: t.name,
|
|
697
877
|
description: t.description,
|
|
698
878
|
input_schema: t.inputSchema,
|
|
699
|
-
...t.outputSchema ? { output_schema: t.outputSchema } : {}
|
|
879
|
+
...t.outputSchema ? { output_schema: t.outputSchema } : {},
|
|
880
|
+
...preloadWireProperty(t.preload, tk.preload, defaultPreload)
|
|
700
881
|
}))
|
|
701
882
|
}));
|
|
702
883
|
}
|
|
@@ -713,34 +894,113 @@ function serializeCustomToolkits(toolkits) {
|
|
|
713
894
|
function buildCustomToolsMapFromResponse(tools, toolkits, experimental) {
|
|
714
895
|
const byFinalSlug = /* @__PURE__ */ new Map();
|
|
715
896
|
const byOriginalSlug = /* @__PURE__ */ new Map();
|
|
897
|
+
const byToolkitAndOriginalSlug = /* @__PURE__ */ new Map();
|
|
898
|
+
const ambiguousOriginalSlugs = /* @__PURE__ */ new Set();
|
|
899
|
+
const handlesByQualifiedOriginalSlug = /* @__PURE__ */ new Map();
|
|
716
900
|
const handlesByOriginalSlug = /* @__PURE__ */ new Map();
|
|
717
|
-
|
|
718
|
-
handle
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
toolkit
|
|
724
|
-
|
|
901
|
+
const registerHandle = (handle, toolkit) => {
|
|
902
|
+
const originalSlug = handle.slug.toUpperCase();
|
|
903
|
+
const match = {
|
|
904
|
+
handle,
|
|
905
|
+
toolkit
|
|
906
|
+
};
|
|
907
|
+
handlesByQualifiedOriginalSlug.set(qualifiedOriginalSlugKey(toolkit, originalSlug), match);
|
|
908
|
+
const existing = handlesByOriginalSlug.get(originalSlug) ?? [];
|
|
909
|
+
existing.push(match);
|
|
910
|
+
handlesByOriginalSlug.set(originalSlug, existing);
|
|
911
|
+
};
|
|
912
|
+
for (const handle of tools) registerHandle(handle, handle.extendsToolkit);
|
|
913
|
+
if (toolkits) for (const tk of toolkits) for (const handle of tk.tools) registerHandle(handle, tk.slug);
|
|
914
|
+
const findHandle = (originalSlug, toolkit) => {
|
|
915
|
+
const originalSlugKey = originalSlug.toUpperCase();
|
|
916
|
+
const qualifiedMatch = handlesByQualifiedOriginalSlug.get(qualifiedOriginalSlugKey(toolkit, originalSlugKey));
|
|
917
|
+
if (qualifiedMatch) return qualifiedMatch;
|
|
918
|
+
const bareMatches = handlesByOriginalSlug.get(originalSlugKey) ?? [];
|
|
919
|
+
return bareMatches.length === 1 ? bareMatches[0] : void 0;
|
|
920
|
+
};
|
|
725
921
|
const addEntry = (finalSlug, originalSlug, toolkit) => {
|
|
726
|
-
const
|
|
922
|
+
const resolvedToolkit = toolkit ?? void 0;
|
|
923
|
+
const match = findHandle(originalSlug, resolvedToolkit);
|
|
727
924
|
if (!match) return;
|
|
925
|
+
const finalSlugKey = finalSlug.toUpperCase();
|
|
926
|
+
if (byFinalSlug.has(finalSlugKey)) throw new ValidationError(`Custom tool slug collision: "${finalSlug}" is already registered.`);
|
|
728
927
|
const entry = {
|
|
729
928
|
handle: match.handle,
|
|
730
929
|
finalSlug,
|
|
731
|
-
toolkit:
|
|
930
|
+
toolkit: resolvedToolkit ?? match.toolkit
|
|
732
931
|
};
|
|
733
|
-
byFinalSlug.set(
|
|
734
|
-
|
|
932
|
+
byFinalSlug.set(finalSlugKey, entry);
|
|
933
|
+
byToolkitAndOriginalSlug.set(qualifiedOriginalSlugKey(entry.toolkit, originalSlug), entry);
|
|
934
|
+
addOriginalSlugAlias({
|
|
935
|
+
byOriginalSlug,
|
|
936
|
+
ambiguousOriginalSlugs,
|
|
937
|
+
originalSlug,
|
|
938
|
+
entry
|
|
939
|
+
});
|
|
735
940
|
};
|
|
736
941
|
if (experimental?.custom_tools) for (const ct of experimental.custom_tools) addEntry(ct.slug, ct.original_slug, ct.extends_toolkit);
|
|
737
942
|
if (experimental?.custom_toolkits) for (const ctk of experimental.custom_toolkits) for (const ct of ctk.tools) addEntry(ct.slug, ct.original_slug, ctk.slug);
|
|
738
943
|
return {
|
|
739
944
|
byFinalSlug,
|
|
740
945
|
byOriginalSlug,
|
|
741
|
-
|
|
946
|
+
byToolkitAndOriginalSlug,
|
|
947
|
+
...ambiguousOriginalSlugs.size ? { ambiguousOriginalSlugs } : {},
|
|
948
|
+
toolkits,
|
|
949
|
+
tools: tools.length ? tools : void 0
|
|
742
950
|
};
|
|
743
951
|
}
|
|
952
|
+
/**
|
|
953
|
+
* Find a custom tool entry by final slug only.
|
|
954
|
+
*
|
|
955
|
+
* @internal
|
|
956
|
+
*/
|
|
957
|
+
function findCustomToolMapEntryByFinalSlug(customToolsMap, slug) {
|
|
958
|
+
return customToolsMap?.byFinalSlug.get(slug.toUpperCase());
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Find a custom toolkit tool entry by toolkit slug and original tool slug.
|
|
962
|
+
*
|
|
963
|
+
* @internal
|
|
964
|
+
*/
|
|
965
|
+
function findCustomToolMapEntryByToolkitAndOriginalSlug(customToolsMap, toolkit, slug) {
|
|
966
|
+
return customToolsMap?.byToolkitAndOriginalSlug?.get(qualifiedOriginalSlugKey(toolkit, slug));
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Reject legacy attempts to preload custom tools through top-level preload.tools.
|
|
970
|
+
*
|
|
971
|
+
* Custom tool direct exposure is controlled by CustomTool.preload /
|
|
972
|
+
* CustomToolkit.preload so it follows the current SDK-provided custom
|
|
973
|
+
* definitions instead of stale session config.
|
|
974
|
+
*
|
|
975
|
+
* @internal
|
|
976
|
+
*/
|
|
977
|
+
function assertNoCustomToolSlugsInPreload(preloadTools, customToolsMap) {
|
|
978
|
+
if (!preloadTools || preloadTools === PRELOAD_TOOLS_ALL) return;
|
|
979
|
+
const customPreloadSlugs = preloadTools.filter((slug) => {
|
|
980
|
+
const normalized = slug.toUpperCase();
|
|
981
|
+
return normalized.startsWith(LOCAL_TOOL_PREFIX) || customToolsMap?.byOriginalSlug.has(normalized) || customToolsMap?.ambiguousOriginalSlugs?.has(normalized) || customToolsMap?.byFinalSlug.has(normalized);
|
|
982
|
+
});
|
|
983
|
+
if (customPreloadSlugs.length) throw new ValidationError(`Custom tool slugs are not supported in preload.tools: ${customPreloadSlugs.join(", ")}. Set preload: true on the SDK custom tool or custom toolkit definition instead.`);
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Resolve custom tools that the SDK should expose directly from session.tools().
|
|
987
|
+
*
|
|
988
|
+
* @internal
|
|
989
|
+
*/
|
|
990
|
+
function getPreloadedCustomToolSlugs(customToolsMap, defaultPreload = false) {
|
|
991
|
+
if (!customToolsMap) return [];
|
|
992
|
+
const seen = /* @__PURE__ */ new Set();
|
|
993
|
+
const customToolSlugs = [];
|
|
994
|
+
for (const entry of customToolsMap.byFinalSlug.values()) {
|
|
995
|
+
const toolkit = customToolsMap.toolkits?.find((tk) => entry.toolkit && tk.slug.toLowerCase() === entry.toolkit.toLowerCase());
|
|
996
|
+
if (!(entry.handle.preload ?? toolkit?.preload ?? defaultPreload)) continue;
|
|
997
|
+
const finalSlugKey = entry.finalSlug.toUpperCase();
|
|
998
|
+
if (seen.has(finalSlugKey)) continue;
|
|
999
|
+
seen.add(finalSlugKey);
|
|
1000
|
+
customToolSlugs.push(entry.finalSlug);
|
|
1001
|
+
}
|
|
1002
|
+
return customToolSlugs;
|
|
1003
|
+
}
|
|
744
1004
|
|
|
745
1005
|
//#endregion
|
|
746
1006
|
Object.defineProperty(exports, 'AuthConfigErrorCodes', {
|
|
@@ -749,6 +1009,12 @@ Object.defineProperty(exports, 'AuthConfigErrorCodes', {
|
|
|
749
1009
|
return AuthConfigErrorCodes;
|
|
750
1010
|
}
|
|
751
1011
|
});
|
|
1012
|
+
Object.defineProperty(exports, 'ComposioAclOnlyForSharedError', {
|
|
1013
|
+
enumerable: true,
|
|
1014
|
+
get: function () {
|
|
1015
|
+
return ComposioAclOnlyForSharedError;
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
752
1018
|
Object.defineProperty(exports, 'ComposioAuthConfigNotFoundError', {
|
|
753
1019
|
enumerable: true,
|
|
754
1020
|
get: function () {
|
|
@@ -815,6 +1081,12 @@ Object.defineProperty(exports, 'ComposioInvalidModifierError', {
|
|
|
815
1081
|
return ComposioInvalidModifierError;
|
|
816
1082
|
}
|
|
817
1083
|
});
|
|
1084
|
+
Object.defineProperty(exports, 'ComposioLegacyConnectedAccountsEndpointRetiredError', {
|
|
1085
|
+
enumerable: true,
|
|
1086
|
+
get: function () {
|
|
1087
|
+
return ComposioLegacyConnectedAccountsEndpointRetiredError;
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
818
1090
|
Object.defineProperty(exports, 'ComposioMultipleConnectedAccountsError', {
|
|
819
1091
|
enumerable: true,
|
|
820
1092
|
get: function () {
|
|
@@ -833,6 +1105,18 @@ Object.defineProperty(exports, 'ComposioProviderNotDefinedError', {
|
|
|
833
1105
|
return ComposioProviderNotDefinedError;
|
|
834
1106
|
}
|
|
835
1107
|
});
|
|
1108
|
+
Object.defineProperty(exports, 'ComposioSharedAccessDeniedError', {
|
|
1109
|
+
enumerable: true,
|
|
1110
|
+
get: function () {
|
|
1111
|
+
return ComposioSharedAccessDeniedError;
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1114
|
+
Object.defineProperty(exports, 'ComposioSharedConnectionNotAccessibleError', {
|
|
1115
|
+
enumerable: true,
|
|
1116
|
+
get: function () {
|
|
1117
|
+
return ComposioSharedConnectionNotAccessibleError;
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
836
1120
|
Object.defineProperty(exports, 'ComposioToolExecutionError', {
|
|
837
1121
|
enumerable: true,
|
|
838
1122
|
get: function () {
|
|
@@ -923,12 +1207,24 @@ Object.defineProperty(exports, 'CustomToolSlugSchema', {
|
|
|
923
1207
|
return CustomToolSlugSchema;
|
|
924
1208
|
}
|
|
925
1209
|
});
|
|
1210
|
+
Object.defineProperty(exports, 'JsonSchemaRefResolutionError', {
|
|
1211
|
+
enumerable: true,
|
|
1212
|
+
get: function () {
|
|
1213
|
+
return JsonSchemaRefResolutionError;
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
926
1216
|
Object.defineProperty(exports, 'JsonSchemaToZodError', {
|
|
927
1217
|
enumerable: true,
|
|
928
1218
|
get: function () {
|
|
929
1219
|
return JsonSchemaToZodError;
|
|
930
1220
|
}
|
|
931
1221
|
});
|
|
1222
|
+
Object.defineProperty(exports, 'PRELOAD_TOOLS_ALL', {
|
|
1223
|
+
enumerable: true,
|
|
1224
|
+
get: function () {
|
|
1225
|
+
return PRELOAD_TOOLS_ALL;
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
932
1228
|
Object.defineProperty(exports, 'RemoteFileDownloadError', {
|
|
933
1229
|
enumerable: true,
|
|
934
1230
|
get: function () {
|
|
@@ -977,6 +1273,18 @@ Object.defineProperty(exports, 'ValidationErrorCodes', {
|
|
|
977
1273
|
return ValidationErrorCodes;
|
|
978
1274
|
}
|
|
979
1275
|
});
|
|
1276
|
+
Object.defineProperty(exports, 'assertNoCustomToolSlugsInPreload', {
|
|
1277
|
+
enumerable: true,
|
|
1278
|
+
get: function () {
|
|
1279
|
+
return assertNoCustomToolSlugsInPreload;
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
Object.defineProperty(exports, 'buildCustomToolsMap', {
|
|
1283
|
+
enumerable: true,
|
|
1284
|
+
get: function () {
|
|
1285
|
+
return buildCustomToolsMap;
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
980
1288
|
Object.defineProperty(exports, 'buildCustomToolsMapFromResponse', {
|
|
981
1289
|
enumerable: true,
|
|
982
1290
|
get: function () {
|
|
@@ -995,6 +1303,24 @@ Object.defineProperty(exports, 'createCustomToolkit', {
|
|
|
995
1303
|
return createCustomToolkit;
|
|
996
1304
|
}
|
|
997
1305
|
});
|
|
1306
|
+
Object.defineProperty(exports, 'findCustomToolMapEntryByFinalSlug', {
|
|
1307
|
+
enumerable: true,
|
|
1308
|
+
get: function () {
|
|
1309
|
+
return findCustomToolMapEntryByFinalSlug;
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
Object.defineProperty(exports, 'findCustomToolMapEntryByToolkitAndOriginalSlug', {
|
|
1313
|
+
enumerable: true,
|
|
1314
|
+
get: function () {
|
|
1315
|
+
return findCustomToolMapEntryByToolkitAndOriginalSlug;
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
Object.defineProperty(exports, 'getPreloadedCustomToolSlugs', {
|
|
1319
|
+
enumerable: true,
|
|
1320
|
+
get: function () {
|
|
1321
|
+
return getPreloadedCustomToolSlugs;
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
998
1324
|
Object.defineProperty(exports, 'handleToolExecutionError', {
|
|
999
1325
|
enumerable: true,
|
|
1000
1326
|
get: function () {
|