@composio/core 0.8.1 → 0.9.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/{CustomTool-CzhY9iPX.d.cts → CustomTool-87USJ2u0.d.cts} +1 -1
- package/dist/{CustomTool-BaRzlwyV.d.mts → CustomTool-BNxqr6BI.d.mts} +1 -1
- package/dist/{CustomTool-CVwF_isu.mjs → CustomTool-DOE7hgw6.mjs} +232 -27
- package/dist/{CustomTool-DnCSEC6t.cjs → CustomTool-Dj4fNvsu.cjs} +279 -26
- package/dist/{composio-CwcLLO7C.d.mts → composio-BJW2NaoA.d.mts} +174 -144
- package/dist/{composio-B75SFMkx.d.cts → composio-DTntXzL-.d.cts} +174 -144
- package/dist/{customTool.types-BL_z-C_B.d.mts → customTool.types-B3HG185y.d.mts} +332 -30
- package/dist/{customTool.types-2DhEI1vs.d.cts → customTool.types-Bd8ylotX.d.cts} +332 -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 +492 -58
- package/dist/index.d.cts +80 -9
- package/dist/index.d.mts +80 -9
- package/dist/index.mjs +489 -61
- 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-DGrpnYFI.d.mts → types-BClz5lKM.d.mts} +2 -2
- package/dist/{types-CZkT1raQ.d.cts → types-jsOgjrWN.d.cts} +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
|
@@ -9,7 +9,8 @@ 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"
|
|
13
14
|
};
|
|
14
15
|
var ComposioConnectedAccountNotFoundError = class extends require_FileModifierErrors.ComposioError {
|
|
15
16
|
constructor(message = "Connected account not found", options = {}) {
|
|
@@ -41,6 +42,30 @@ var ComposioFailedToCreateConnectedAccountLink = class extends require_FileModif
|
|
|
41
42
|
this.name = "ComposioFailedToCreateConnectedAccountLink";
|
|
42
43
|
}
|
|
43
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Thrown by `composio.connectedAccounts.initiate()` when the legacy
|
|
47
|
+
* `POST /api/v3/connected_accounts` endpoint rejects a Composio-managed
|
|
48
|
+
* OAuth (OAuth1, OAuth2, DCR_OAUTH) auth-config request.
|
|
49
|
+
*
|
|
50
|
+
* The retiring path is being phased out — new orgs from 2026-05-08 and
|
|
51
|
+
* all remaining orgs from 2026-07-03. Migrate the call to
|
|
52
|
+
* `composio.connectedAccounts.link()`, which works for every redirectable
|
|
53
|
+
* scheme regardless of whether the auth config is Composio-managed or
|
|
54
|
+
* custom.
|
|
55
|
+
*
|
|
56
|
+
* See: https://docs.composio.dev/docs/changelog/2026/04/24
|
|
57
|
+
*/
|
|
58
|
+
var ComposioLegacyConnectedAccountsEndpointRetiredError = class extends require_FileModifierErrors.ComposioError {
|
|
59
|
+
constructor(message = "POST /api/v3/connected_accounts is no longer supported for Composio-managed OAuth auth configs. Use composio.connectedAccounts.link() instead.", options = {}) {
|
|
60
|
+
super(message, {
|
|
61
|
+
...options,
|
|
62
|
+
code: ConnectedAccountErrorCodes.LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED,
|
|
63
|
+
statusCode: 400,
|
|
64
|
+
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"]
|
|
65
|
+
});
|
|
66
|
+
this.name = "ComposioLegacyConnectedAccountsEndpointRetiredError";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
44
69
|
|
|
45
70
|
//#endregion
|
|
46
71
|
//#region src/errors/ToolErrors.ts
|
|
@@ -294,7 +319,8 @@ var ComposioToolkitFetchError = class extends require_FileModifierErrors.Composi
|
|
|
294
319
|
*/
|
|
295
320
|
const ValidationErrorCodes = {
|
|
296
321
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
297
|
-
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
|
|
322
|
+
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR",
|
|
323
|
+
JSON_SCHEMA_REF_RESOLUTION_ERROR: "JSON_SCHEMA_REF_RESOLUTION_ERROR"
|
|
298
324
|
};
|
|
299
325
|
var ValidationError = class extends require_FileModifierErrors.ComposioError {
|
|
300
326
|
constructor(message = "Input validation failed", options = {}) {
|
|
@@ -334,6 +360,19 @@ var JsonSchemaToZodError = class extends require_FileModifierErrors.ComposioErro
|
|
|
334
360
|
});
|
|
335
361
|
}
|
|
336
362
|
};
|
|
363
|
+
/**
|
|
364
|
+
* Thrown when a JSON Schema `$ref` pointer cannot be resolved against the
|
|
365
|
+
* document. Used by `dereferenceJsonSchema` to surface malformed pointers,
|
|
366
|
+
* missing `$defs`/`definitions` targets, or chains exceeding the depth cap.
|
|
367
|
+
*/
|
|
368
|
+
var JsonSchemaRefResolutionError = class extends require_FileModifierErrors.ComposioError {
|
|
369
|
+
constructor(message = "Failed to resolve JSON Schema $ref", options = {}) {
|
|
370
|
+
super(message, {
|
|
371
|
+
...options,
|
|
372
|
+
code: options.code || ValidationErrorCodes.JSON_SCHEMA_REF_RESOLUTION_ERROR
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
};
|
|
337
376
|
|
|
338
377
|
//#endregion
|
|
339
378
|
//#region src/errors/SDKErrors.ts
|
|
@@ -478,6 +517,10 @@ var RemoteFileDownloadError = class extends require_FileModifierErrors.ComposioE
|
|
|
478
517
|
}
|
|
479
518
|
};
|
|
480
519
|
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/lib/toolRouterConstants.ts
|
|
522
|
+
const PRELOAD_TOOLS_ALL = "all";
|
|
523
|
+
|
|
481
524
|
//#endregion
|
|
482
525
|
//#region src/types/customTool.types.ts
|
|
483
526
|
/**
|
|
@@ -494,7 +537,8 @@ const CustomToolSlugSchema = zod_v3.z.string().min(1, "slug is required").regex(
|
|
|
494
537
|
const CreateCustomToolBaseSchema = zod_v3.z.object({
|
|
495
538
|
name: zod_v3.z.string().min(1, "createCustomTool: name is required"),
|
|
496
539
|
description: zod_v3.z.string().min(1, "createCustomTool: description is required"),
|
|
497
|
-
extendsToolkit: zod_v3.z.string().optional()
|
|
540
|
+
extendsToolkit: zod_v3.z.string().optional(),
|
|
541
|
+
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
542
|
});
|
|
499
543
|
/**
|
|
500
544
|
* Zod schema for validating the string/scalar fields of createCustomToolkit() options.
|
|
@@ -502,7 +546,8 @@ const CreateCustomToolBaseSchema = zod_v3.z.object({
|
|
|
502
546
|
*/
|
|
503
547
|
const CreateCustomToolkitBaseSchema = zod_v3.z.object({
|
|
504
548
|
name: zod_v3.z.string().min(1, "createCustomToolkit: name is required"),
|
|
505
|
-
description: zod_v3.z.string().min(1, "createCustomToolkit: description is required")
|
|
549
|
+
description: zod_v3.z.string().min(1, "createCustomToolkit: description is required"),
|
|
550
|
+
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
551
|
});
|
|
507
552
|
|
|
508
553
|
//#endregion
|
|
@@ -616,6 +661,7 @@ function createCustomTool(slug, options) {
|
|
|
616
661
|
name: validated.name,
|
|
617
662
|
description: validated.description,
|
|
618
663
|
extendsToolkit: validated.extendsToolkit,
|
|
664
|
+
preload: validated.preload,
|
|
619
665
|
inputSchema,
|
|
620
666
|
outputSchema,
|
|
621
667
|
inputParams,
|
|
@@ -657,26 +703,103 @@ function createCustomToolkit(slug, options) {
|
|
|
657
703
|
slug: slugResult.data,
|
|
658
704
|
name: validated.name,
|
|
659
705
|
description: validated.description,
|
|
706
|
+
preload: validated.preload,
|
|
660
707
|
tools: options.tools
|
|
661
708
|
};
|
|
662
709
|
}
|
|
663
710
|
/**
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
|
|
711
|
+
* Build the final slug for a custom tool given its context.
|
|
712
|
+
* @internal
|
|
713
|
+
*/
|
|
714
|
+
function buildFinalSlug(toolSlug, toolkitSlug) {
|
|
715
|
+
const upper = toolSlug.toUpperCase();
|
|
716
|
+
return toolkitSlug ? `${LOCAL_TOOL_PREFIX}${toolkitSlug.toUpperCase()}_${upper}` : `${LOCAL_TOOL_PREFIX}${upper}`;
|
|
717
|
+
}
|
|
718
|
+
const qualifiedOriginalSlugKey = (toolkit, originalSlug) => `${toolkit?.toUpperCase() ?? ""}::${originalSlug.toUpperCase()}`;
|
|
719
|
+
const canShareOriginalSlug = (existing, next) => !!existing.toolkit && !!next.toolkit && existing.toolkit.toLowerCase() !== next.toolkit.toLowerCase();
|
|
720
|
+
const addOriginalSlugAlias = (params) => {
|
|
721
|
+
const originalSlugKey = params.originalSlug.toUpperCase();
|
|
722
|
+
if (params.ambiguousOriginalSlugs.has(originalSlugKey)) return;
|
|
723
|
+
const existing = params.byOriginalSlug.get(originalSlugKey);
|
|
724
|
+
if (!existing) {
|
|
725
|
+
params.byOriginalSlug.set(originalSlugKey, params.entry);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
if (existing.finalSlug.toUpperCase() === params.entry.finalSlug.toUpperCase()) return;
|
|
729
|
+
if (canShareOriginalSlug(existing, params.entry)) {
|
|
730
|
+
params.byOriginalSlug.delete(originalSlugKey);
|
|
731
|
+
params.ambiguousOriginalSlugs.add(originalSlugKey);
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
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}".`);
|
|
735
|
+
};
|
|
736
|
+
/**
|
|
737
|
+
* Build a CustomToolsMap from custom tools and toolkits.
|
|
738
|
+
* Used internally by ToolRouter.create() to construct the per-session routing map.
|
|
667
739
|
*
|
|
668
740
|
* @internal
|
|
669
|
-
* @param tools -
|
|
670
|
-
* @
|
|
741
|
+
* @param tools - Standalone custom tools
|
|
742
|
+
* @param toolkits - Custom toolkits containing grouped tools
|
|
743
|
+
* @returns Maps for O(1) lookup by both final and original slug
|
|
744
|
+
* @throws If duplicate slugs or cross-group collisions
|
|
671
745
|
*/
|
|
672
|
-
function
|
|
746
|
+
function buildCustomToolsMap(tools, toolkits) {
|
|
747
|
+
const byFinalSlug = /* @__PURE__ */ new Map();
|
|
748
|
+
const byOriginalSlug = /* @__PURE__ */ new Map();
|
|
749
|
+
const byToolkitAndOriginalSlug = /* @__PURE__ */ new Map();
|
|
750
|
+
const ambiguousOriginalSlugs = /* @__PURE__ */ new Set();
|
|
751
|
+
const addEntry = (handle, finalSlug, toolkit) => {
|
|
752
|
+
const originalSlug = handle.slug.toUpperCase();
|
|
753
|
+
const finalSlugKey = finalSlug.toUpperCase();
|
|
754
|
+
if (finalSlug.length > MAX_SLUG_LENGTH) throw new ValidationError(`Custom tool slug "${handle.slug}" produces final slug "${finalSlug}" which exceeds ${MAX_SLUG_LENGTH} characters.`);
|
|
755
|
+
if (byFinalSlug.has(finalSlugKey)) throw new ValidationError(`Custom tool slug collision: "${finalSlug}" is already registered.`);
|
|
756
|
+
const qualifiedKey = qualifiedOriginalSlugKey(toolkit, originalSlug);
|
|
757
|
+
if (byToolkitAndOriginalSlug.has(qualifiedKey)) throw new ValidationError(`Custom tool slug collision: original slug "${handle.slug}" is already registered for toolkit "${toolkit ?? "custom"}".`);
|
|
758
|
+
const entry = {
|
|
759
|
+
handle,
|
|
760
|
+
finalSlug,
|
|
761
|
+
toolkit
|
|
762
|
+
};
|
|
763
|
+
byFinalSlug.set(finalSlugKey, entry);
|
|
764
|
+
byToolkitAndOriginalSlug.set(qualifiedKey, entry);
|
|
765
|
+
addOriginalSlugAlias({
|
|
766
|
+
byOriginalSlug,
|
|
767
|
+
ambiguousOriginalSlugs,
|
|
768
|
+
originalSlug,
|
|
769
|
+
entry
|
|
770
|
+
});
|
|
771
|
+
};
|
|
772
|
+
for (const handle of tools) addEntry(handle, buildFinalSlug(handle.slug, handle.extendsToolkit), handle.extendsToolkit);
|
|
773
|
+
if (toolkits) for (const toolkit of toolkits) for (const handle of toolkit.tools) addEntry(handle, buildFinalSlug(handle.slug, toolkit.slug), toolkit.slug);
|
|
774
|
+
return {
|
|
775
|
+
byFinalSlug,
|
|
776
|
+
byOriginalSlug,
|
|
777
|
+
byToolkitAndOriginalSlug,
|
|
778
|
+
...ambiguousOriginalSlugs.size ? { ambiguousOriginalSlugs } : {},
|
|
779
|
+
toolkits,
|
|
780
|
+
tools: tools.length ? tools : void 0
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
function shouldSerializePreload(preload, inheritedPreload, defaultPreload) {
|
|
784
|
+
const inheritedOrDefault = inheritedPreload ?? defaultPreload;
|
|
785
|
+
if (preload !== void 0) return preload || inheritedOrDefault ? preload : void 0;
|
|
786
|
+
if (inheritedPreload !== void 0) return inheritedPreload || defaultPreload ? inheritedPreload : void 0;
|
|
787
|
+
return defaultPreload ? true : void 0;
|
|
788
|
+
}
|
|
789
|
+
function preloadWireProperty(preload, inheritedPreload, defaultPreload) {
|
|
790
|
+
const serializedPreload = shouldSerializePreload(preload, inheritedPreload, defaultPreload);
|
|
791
|
+
return serializedPreload === void 0 ? {} : { preload: serializedPreload };
|
|
792
|
+
}
|
|
793
|
+
function serializeCustomTools(tools, options = {}) {
|
|
794
|
+
const defaultPreload = options.defaultPreload ?? false;
|
|
673
795
|
return tools.map((handle) => ({
|
|
674
796
|
slug: handle.slug,
|
|
675
797
|
name: handle.name,
|
|
676
798
|
description: handle.description,
|
|
677
799
|
input_schema: handle.inputSchema,
|
|
678
800
|
...handle.outputSchema ? { output_schema: handle.outputSchema } : {},
|
|
679
|
-
...handle.extendsToolkit ? { extends_toolkit: handle.extendsToolkit } : {}
|
|
801
|
+
...handle.extendsToolkit ? { extends_toolkit: handle.extendsToolkit } : {},
|
|
802
|
+
...preloadWireProperty(handle.preload, void 0, defaultPreload)
|
|
680
803
|
}));
|
|
681
804
|
}
|
|
682
805
|
/**
|
|
@@ -686,17 +809,20 @@ function serializeCustomTools(tools) {
|
|
|
686
809
|
* @param toolkits - The custom toolkits to serialize
|
|
687
810
|
* @returns Array of CustomToolkitDefinition for the API payload
|
|
688
811
|
*/
|
|
689
|
-
function serializeCustomToolkits(toolkits) {
|
|
812
|
+
function serializeCustomToolkits(toolkits, options = {}) {
|
|
813
|
+
const defaultPreload = options.defaultPreload ?? false;
|
|
690
814
|
return toolkits.map((tk) => ({
|
|
691
815
|
slug: tk.slug,
|
|
692
816
|
name: tk.name,
|
|
693
817
|
description: tk.description,
|
|
818
|
+
...preloadWireProperty(tk.preload, void 0, defaultPreload),
|
|
694
819
|
tools: tk.tools.map((t) => ({
|
|
695
820
|
slug: t.slug,
|
|
696
821
|
name: t.name,
|
|
697
822
|
description: t.description,
|
|
698
823
|
input_schema: t.inputSchema,
|
|
699
|
-
...t.outputSchema ? { output_schema: t.outputSchema } : {}
|
|
824
|
+
...t.outputSchema ? { output_schema: t.outputSchema } : {},
|
|
825
|
+
...preloadWireProperty(t.preload, tk.preload, defaultPreload)
|
|
700
826
|
}))
|
|
701
827
|
}));
|
|
702
828
|
}
|
|
@@ -713,34 +839,113 @@ function serializeCustomToolkits(toolkits) {
|
|
|
713
839
|
function buildCustomToolsMapFromResponse(tools, toolkits, experimental) {
|
|
714
840
|
const byFinalSlug = /* @__PURE__ */ new Map();
|
|
715
841
|
const byOriginalSlug = /* @__PURE__ */ new Map();
|
|
842
|
+
const byToolkitAndOriginalSlug = /* @__PURE__ */ new Map();
|
|
843
|
+
const ambiguousOriginalSlugs = /* @__PURE__ */ new Set();
|
|
844
|
+
const handlesByQualifiedOriginalSlug = /* @__PURE__ */ new Map();
|
|
716
845
|
const handlesByOriginalSlug = /* @__PURE__ */ new Map();
|
|
717
|
-
|
|
718
|
-
handle
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
toolkit
|
|
724
|
-
|
|
846
|
+
const registerHandle = (handle, toolkit) => {
|
|
847
|
+
const originalSlug = handle.slug.toUpperCase();
|
|
848
|
+
const match = {
|
|
849
|
+
handle,
|
|
850
|
+
toolkit
|
|
851
|
+
};
|
|
852
|
+
handlesByQualifiedOriginalSlug.set(qualifiedOriginalSlugKey(toolkit, originalSlug), match);
|
|
853
|
+
const existing = handlesByOriginalSlug.get(originalSlug) ?? [];
|
|
854
|
+
existing.push(match);
|
|
855
|
+
handlesByOriginalSlug.set(originalSlug, existing);
|
|
856
|
+
};
|
|
857
|
+
for (const handle of tools) registerHandle(handle, handle.extendsToolkit);
|
|
858
|
+
if (toolkits) for (const tk of toolkits) for (const handle of tk.tools) registerHandle(handle, tk.slug);
|
|
859
|
+
const findHandle = (originalSlug, toolkit) => {
|
|
860
|
+
const originalSlugKey = originalSlug.toUpperCase();
|
|
861
|
+
const qualifiedMatch = handlesByQualifiedOriginalSlug.get(qualifiedOriginalSlugKey(toolkit, originalSlugKey));
|
|
862
|
+
if (qualifiedMatch) return qualifiedMatch;
|
|
863
|
+
const bareMatches = handlesByOriginalSlug.get(originalSlugKey) ?? [];
|
|
864
|
+
return bareMatches.length === 1 ? bareMatches[0] : void 0;
|
|
865
|
+
};
|
|
725
866
|
const addEntry = (finalSlug, originalSlug, toolkit) => {
|
|
726
|
-
const
|
|
867
|
+
const resolvedToolkit = toolkit ?? void 0;
|
|
868
|
+
const match = findHandle(originalSlug, resolvedToolkit);
|
|
727
869
|
if (!match) return;
|
|
870
|
+
const finalSlugKey = finalSlug.toUpperCase();
|
|
871
|
+
if (byFinalSlug.has(finalSlugKey)) throw new ValidationError(`Custom tool slug collision: "${finalSlug}" is already registered.`);
|
|
728
872
|
const entry = {
|
|
729
873
|
handle: match.handle,
|
|
730
874
|
finalSlug,
|
|
731
|
-
toolkit:
|
|
875
|
+
toolkit: resolvedToolkit ?? match.toolkit
|
|
732
876
|
};
|
|
733
|
-
byFinalSlug.set(
|
|
734
|
-
|
|
877
|
+
byFinalSlug.set(finalSlugKey, entry);
|
|
878
|
+
byToolkitAndOriginalSlug.set(qualifiedOriginalSlugKey(entry.toolkit, originalSlug), entry);
|
|
879
|
+
addOriginalSlugAlias({
|
|
880
|
+
byOriginalSlug,
|
|
881
|
+
ambiguousOriginalSlugs,
|
|
882
|
+
originalSlug,
|
|
883
|
+
entry
|
|
884
|
+
});
|
|
735
885
|
};
|
|
736
886
|
if (experimental?.custom_tools) for (const ct of experimental.custom_tools) addEntry(ct.slug, ct.original_slug, ct.extends_toolkit);
|
|
737
887
|
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
888
|
return {
|
|
739
889
|
byFinalSlug,
|
|
740
890
|
byOriginalSlug,
|
|
741
|
-
|
|
891
|
+
byToolkitAndOriginalSlug,
|
|
892
|
+
...ambiguousOriginalSlugs.size ? { ambiguousOriginalSlugs } : {},
|
|
893
|
+
toolkits,
|
|
894
|
+
tools: tools.length ? tools : void 0
|
|
742
895
|
};
|
|
743
896
|
}
|
|
897
|
+
/**
|
|
898
|
+
* Find a custom tool entry by final slug only.
|
|
899
|
+
*
|
|
900
|
+
* @internal
|
|
901
|
+
*/
|
|
902
|
+
function findCustomToolMapEntryByFinalSlug(customToolsMap, slug) {
|
|
903
|
+
return customToolsMap?.byFinalSlug.get(slug.toUpperCase());
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Find a custom toolkit tool entry by toolkit slug and original tool slug.
|
|
907
|
+
*
|
|
908
|
+
* @internal
|
|
909
|
+
*/
|
|
910
|
+
function findCustomToolMapEntryByToolkitAndOriginalSlug(customToolsMap, toolkit, slug) {
|
|
911
|
+
return customToolsMap?.byToolkitAndOriginalSlug?.get(qualifiedOriginalSlugKey(toolkit, slug));
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Reject legacy attempts to preload custom tools through top-level preload.tools.
|
|
915
|
+
*
|
|
916
|
+
* Custom tool direct exposure is controlled by CustomTool.preload /
|
|
917
|
+
* CustomToolkit.preload so it follows the current SDK-provided custom
|
|
918
|
+
* definitions instead of stale session config.
|
|
919
|
+
*
|
|
920
|
+
* @internal
|
|
921
|
+
*/
|
|
922
|
+
function assertNoCustomToolSlugsInPreload(preloadTools, customToolsMap) {
|
|
923
|
+
if (!preloadTools || preloadTools === PRELOAD_TOOLS_ALL) return;
|
|
924
|
+
const customPreloadSlugs = preloadTools.filter((slug) => {
|
|
925
|
+
const normalized = slug.toUpperCase();
|
|
926
|
+
return normalized.startsWith(LOCAL_TOOL_PREFIX) || customToolsMap?.byOriginalSlug.has(normalized) || customToolsMap?.ambiguousOriginalSlugs?.has(normalized) || customToolsMap?.byFinalSlug.has(normalized);
|
|
927
|
+
});
|
|
928
|
+
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.`);
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Resolve custom tools that the SDK should expose directly from session.tools().
|
|
932
|
+
*
|
|
933
|
+
* @internal
|
|
934
|
+
*/
|
|
935
|
+
function getPreloadedCustomToolSlugs(customToolsMap, defaultPreload = false) {
|
|
936
|
+
if (!customToolsMap) return [];
|
|
937
|
+
const seen = /* @__PURE__ */ new Set();
|
|
938
|
+
const customToolSlugs = [];
|
|
939
|
+
for (const entry of customToolsMap.byFinalSlug.values()) {
|
|
940
|
+
const toolkit = customToolsMap.toolkits?.find((tk) => entry.toolkit && tk.slug.toLowerCase() === entry.toolkit.toLowerCase());
|
|
941
|
+
if (!(entry.handle.preload ?? toolkit?.preload ?? defaultPreload)) continue;
|
|
942
|
+
const finalSlugKey = entry.finalSlug.toUpperCase();
|
|
943
|
+
if (seen.has(finalSlugKey)) continue;
|
|
944
|
+
seen.add(finalSlugKey);
|
|
945
|
+
customToolSlugs.push(entry.finalSlug);
|
|
946
|
+
}
|
|
947
|
+
return customToolSlugs;
|
|
948
|
+
}
|
|
744
949
|
|
|
745
950
|
//#endregion
|
|
746
951
|
Object.defineProperty(exports, 'AuthConfigErrorCodes', {
|
|
@@ -815,6 +1020,12 @@ Object.defineProperty(exports, 'ComposioInvalidModifierError', {
|
|
|
815
1020
|
return ComposioInvalidModifierError;
|
|
816
1021
|
}
|
|
817
1022
|
});
|
|
1023
|
+
Object.defineProperty(exports, 'ComposioLegacyConnectedAccountsEndpointRetiredError', {
|
|
1024
|
+
enumerable: true,
|
|
1025
|
+
get: function () {
|
|
1026
|
+
return ComposioLegacyConnectedAccountsEndpointRetiredError;
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
818
1029
|
Object.defineProperty(exports, 'ComposioMultipleConnectedAccountsError', {
|
|
819
1030
|
enumerable: true,
|
|
820
1031
|
get: function () {
|
|
@@ -923,12 +1134,24 @@ Object.defineProperty(exports, 'CustomToolSlugSchema', {
|
|
|
923
1134
|
return CustomToolSlugSchema;
|
|
924
1135
|
}
|
|
925
1136
|
});
|
|
1137
|
+
Object.defineProperty(exports, 'JsonSchemaRefResolutionError', {
|
|
1138
|
+
enumerable: true,
|
|
1139
|
+
get: function () {
|
|
1140
|
+
return JsonSchemaRefResolutionError;
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
926
1143
|
Object.defineProperty(exports, 'JsonSchemaToZodError', {
|
|
927
1144
|
enumerable: true,
|
|
928
1145
|
get: function () {
|
|
929
1146
|
return JsonSchemaToZodError;
|
|
930
1147
|
}
|
|
931
1148
|
});
|
|
1149
|
+
Object.defineProperty(exports, 'PRELOAD_TOOLS_ALL', {
|
|
1150
|
+
enumerable: true,
|
|
1151
|
+
get: function () {
|
|
1152
|
+
return PRELOAD_TOOLS_ALL;
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
932
1155
|
Object.defineProperty(exports, 'RemoteFileDownloadError', {
|
|
933
1156
|
enumerable: true,
|
|
934
1157
|
get: function () {
|
|
@@ -977,6 +1200,18 @@ Object.defineProperty(exports, 'ValidationErrorCodes', {
|
|
|
977
1200
|
return ValidationErrorCodes;
|
|
978
1201
|
}
|
|
979
1202
|
});
|
|
1203
|
+
Object.defineProperty(exports, 'assertNoCustomToolSlugsInPreload', {
|
|
1204
|
+
enumerable: true,
|
|
1205
|
+
get: function () {
|
|
1206
|
+
return assertNoCustomToolSlugsInPreload;
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
Object.defineProperty(exports, 'buildCustomToolsMap', {
|
|
1210
|
+
enumerable: true,
|
|
1211
|
+
get: function () {
|
|
1212
|
+
return buildCustomToolsMap;
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
980
1215
|
Object.defineProperty(exports, 'buildCustomToolsMapFromResponse', {
|
|
981
1216
|
enumerable: true,
|
|
982
1217
|
get: function () {
|
|
@@ -995,6 +1230,24 @@ Object.defineProperty(exports, 'createCustomToolkit', {
|
|
|
995
1230
|
return createCustomToolkit;
|
|
996
1231
|
}
|
|
997
1232
|
});
|
|
1233
|
+
Object.defineProperty(exports, 'findCustomToolMapEntryByFinalSlug', {
|
|
1234
|
+
enumerable: true,
|
|
1235
|
+
get: function () {
|
|
1236
|
+
return findCustomToolMapEntryByFinalSlug;
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
Object.defineProperty(exports, 'findCustomToolMapEntryByToolkitAndOriginalSlug', {
|
|
1240
|
+
enumerable: true,
|
|
1241
|
+
get: function () {
|
|
1242
|
+
return findCustomToolMapEntryByToolkitAndOriginalSlug;
|
|
1243
|
+
}
|
|
1244
|
+
});
|
|
1245
|
+
Object.defineProperty(exports, 'getPreloadedCustomToolSlugs', {
|
|
1246
|
+
enumerable: true,
|
|
1247
|
+
get: function () {
|
|
1248
|
+
return getPreloadedCustomToolSlugs;
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
998
1251
|
Object.defineProperty(exports, 'handleToolExecutionError', {
|
|
999
1252
|
enumerable: true,
|
|
1000
1253
|
get: function () {
|