@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
|
@@ -7,7 +7,11 @@ import * as zodToJsonSchema from "zod-to-json-schema";
|
|
|
7
7
|
const ConnectedAccountErrorCodes = {
|
|
8
8
|
CONNECTED_ACCOUNT_NOT_FOUND: "CONNECTED_ACCOUNT_NOT_FOUND",
|
|
9
9
|
MULTIPLE_CONNECTED_ACCOUNTS: "MULTIPLE_CONNECTED_ACCOUNTS",
|
|
10
|
-
FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: "FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK"
|
|
10
|
+
FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: "FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK",
|
|
11
|
+
LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED: "LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED",
|
|
12
|
+
SHARED_ACCESS_DENIED: "SHARED_ACCESS_DENIED",
|
|
13
|
+
ACL_ONLY_FOR_SHARED: "ACL_ONLY_FOR_SHARED",
|
|
14
|
+
SHARED_CONNECTION_NOT_ACCESSIBLE: "SHARED_CONNECTION_NOT_ACCESSIBLE"
|
|
11
15
|
};
|
|
12
16
|
var ComposioConnectedAccountNotFoundError = class extends ComposioError$1 {
|
|
13
17
|
constructor(message = "Connected account not found", options = {}) {
|
|
@@ -39,6 +43,82 @@ var ComposioFailedToCreateConnectedAccountLink = class extends ComposioError$1 {
|
|
|
39
43
|
this.name = "ComposioFailedToCreateConnectedAccountLink";
|
|
40
44
|
}
|
|
41
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Thrown when a tool execution attempts to use a SHARED connected account
|
|
48
|
+
* but the requesting `userId` is not allowed by the connection's ACL.
|
|
49
|
+
*
|
|
50
|
+
* Surfaces when a SHARED connection is reached directly (e.g. via
|
|
51
|
+
* `composio.tools.execute(slug, { connectedAccountId })`) without going
|
|
52
|
+
* through a tool-router session.
|
|
53
|
+
*/
|
|
54
|
+
var ComposioSharedAccessDeniedError = class extends ComposioError$1 {
|
|
55
|
+
constructor(message = "Access denied: this SHARED connected account is not available to the requesting user", options = {}) {
|
|
56
|
+
super(message, {
|
|
57
|
+
...options,
|
|
58
|
+
code: ConnectedAccountErrorCodes.SHARED_ACCESS_DENIED,
|
|
59
|
+
statusCode: 403,
|
|
60
|
+
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."]
|
|
61
|
+
});
|
|
62
|
+
this.name = "ComposioSharedAccessDeniedError";
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Thrown when ACL fields (`allowAllUsers`, `allowedUserIds`,
|
|
67
|
+
* `notAllowedUserIds`) are sent on a `PRIVATE` connection — at create
|
|
68
|
+
* time or via PATCH. ACL is only meaningful for `SHARED` connections.
|
|
69
|
+
*/
|
|
70
|
+
var ComposioAclOnlyForSharedError = class extends ComposioError$1 {
|
|
71
|
+
constructor(message = "ACL fields are only valid on SHARED connected accounts", options = {}) {
|
|
72
|
+
super(message, {
|
|
73
|
+
...options,
|
|
74
|
+
code: ConnectedAccountErrorCodes.ACL_ONLY_FOR_SHARED,
|
|
75
|
+
statusCode: 400,
|
|
76
|
+
possibleFixes: options.possibleFixes || ["Use accountType: \"SHARED\", or omit ACL fields when creating/updating a PRIVATE connection."]
|
|
77
|
+
});
|
|
78
|
+
this.name = "ComposioAclOnlyForSharedError";
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Thrown by `toolRouter.session.create()` / `session.patch()` when the
|
|
83
|
+
* session's `userId` cannot use a pinned SHARED connection. Raised at
|
|
84
|
+
* session-create time so the session never enters a state that fails
|
|
85
|
+
* mid-execution.
|
|
86
|
+
*/
|
|
87
|
+
var ComposioSharedConnectionNotAccessibleError = class extends ComposioError$1 {
|
|
88
|
+
constructor(message = "A SHARED connected account pinned in the session config is not accessible to the session user", options = {}) {
|
|
89
|
+
super(message, {
|
|
90
|
+
...options,
|
|
91
|
+
code: ConnectedAccountErrorCodes.SHARED_CONNECTION_NOT_ACCESSIBLE,
|
|
92
|
+
statusCode: 400,
|
|
93
|
+
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."]
|
|
94
|
+
});
|
|
95
|
+
this.name = "ComposioSharedConnectionNotAccessibleError";
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Thrown by `composio.connectedAccounts.initiate()` when the legacy
|
|
100
|
+
* `POST /api/v3/connected_accounts` endpoint rejects a Composio-managed
|
|
101
|
+
* OAuth (OAuth1, OAuth2, DCR_OAUTH) auth-config request.
|
|
102
|
+
*
|
|
103
|
+
* The retiring path is being phased out — new orgs from 2026-05-08 and
|
|
104
|
+
* all remaining orgs from 2026-07-03. Migrate the call to
|
|
105
|
+
* `composio.connectedAccounts.link()`, which works for every redirectable
|
|
106
|
+
* scheme regardless of whether the auth config is Composio-managed or
|
|
107
|
+
* custom.
|
|
108
|
+
*
|
|
109
|
+
* See: https://docs.composio.dev/docs/changelog/2026/04/24
|
|
110
|
+
*/
|
|
111
|
+
var ComposioLegacyConnectedAccountsEndpointRetiredError = class extends ComposioError$1 {
|
|
112
|
+
constructor(message = "POST /api/v3/connected_accounts is no longer supported for Composio-managed OAuth auth configs. Use composio.connectedAccounts.link() instead.", options = {}) {
|
|
113
|
+
super(message, {
|
|
114
|
+
...options,
|
|
115
|
+
code: ConnectedAccountErrorCodes.LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED,
|
|
116
|
+
statusCode: 400,
|
|
117
|
+
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"]
|
|
118
|
+
});
|
|
119
|
+
this.name = "ComposioLegacyConnectedAccountsEndpointRetiredError";
|
|
120
|
+
}
|
|
121
|
+
};
|
|
42
122
|
|
|
43
123
|
//#endregion
|
|
44
124
|
//#region src/errors/ToolErrors.ts
|
|
@@ -292,7 +372,8 @@ var ComposioToolkitFetchError = class extends ComposioError$1 {
|
|
|
292
372
|
*/
|
|
293
373
|
const ValidationErrorCodes = {
|
|
294
374
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
295
|
-
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
|
|
375
|
+
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR",
|
|
376
|
+
JSON_SCHEMA_REF_RESOLUTION_ERROR: "JSON_SCHEMA_REF_RESOLUTION_ERROR"
|
|
296
377
|
};
|
|
297
378
|
var ValidationError = class extends ComposioError$1 {
|
|
298
379
|
constructor(message = "Input validation failed", options = {}) {
|
|
@@ -332,6 +413,19 @@ var JsonSchemaToZodError = class extends ComposioError$1 {
|
|
|
332
413
|
});
|
|
333
414
|
}
|
|
334
415
|
};
|
|
416
|
+
/**
|
|
417
|
+
* Thrown when a JSON Schema `$ref` pointer cannot be resolved against the
|
|
418
|
+
* document. Used by `dereferenceJsonSchema` to surface malformed pointers,
|
|
419
|
+
* missing `$defs`/`definitions` targets, or chains exceeding the depth cap.
|
|
420
|
+
*/
|
|
421
|
+
var JsonSchemaRefResolutionError = class extends ComposioError$1 {
|
|
422
|
+
constructor(message = "Failed to resolve JSON Schema $ref", options = {}) {
|
|
423
|
+
super(message, {
|
|
424
|
+
...options,
|
|
425
|
+
code: options.code || ValidationErrorCodes.JSON_SCHEMA_REF_RESOLUTION_ERROR
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
};
|
|
335
429
|
|
|
336
430
|
//#endregion
|
|
337
431
|
//#region src/errors/SDKErrors.ts
|
|
@@ -476,6 +570,10 @@ var RemoteFileDownloadError = class extends ComposioError$1 {
|
|
|
476
570
|
}
|
|
477
571
|
};
|
|
478
572
|
|
|
573
|
+
//#endregion
|
|
574
|
+
//#region src/lib/toolRouterConstants.ts
|
|
575
|
+
const PRELOAD_TOOLS_ALL = "all";
|
|
576
|
+
|
|
479
577
|
//#endregion
|
|
480
578
|
//#region src/types/customTool.types.ts
|
|
481
579
|
/**
|
|
@@ -492,7 +590,8 @@ const CustomToolSlugSchema = z$1.string().min(1, "slug is required").regex(/^[A-
|
|
|
492
590
|
const CreateCustomToolBaseSchema = z$1.object({
|
|
493
591
|
name: z$1.string().min(1, "createCustomTool: name is required"),
|
|
494
592
|
description: z$1.string().min(1, "createCustomTool: description is required"),
|
|
495
|
-
extendsToolkit: z$1.string().optional()
|
|
593
|
+
extendsToolkit: z$1.string().optional(),
|
|
594
|
+
preload: z$1.boolean().optional().describe("When true, include this custom tool in session.tools() so it can be called without searching first.")
|
|
496
595
|
});
|
|
497
596
|
/**
|
|
498
597
|
* Zod schema for validating the string/scalar fields of createCustomToolkit() options.
|
|
@@ -500,7 +599,8 @@ const CreateCustomToolBaseSchema = z$1.object({
|
|
|
500
599
|
*/
|
|
501
600
|
const CreateCustomToolkitBaseSchema = z$1.object({
|
|
502
601
|
name: z$1.string().min(1, "createCustomToolkit: name is required"),
|
|
503
|
-
description: z$1.string().min(1, "createCustomToolkit: description is required")
|
|
602
|
+
description: z$1.string().min(1, "createCustomToolkit: description is required"),
|
|
603
|
+
preload: z$1.boolean().optional().describe("When true, include tools from this custom toolkit in session.tools(). Tool-level preload values override this default.")
|
|
504
604
|
});
|
|
505
605
|
|
|
506
606
|
//#endregion
|
|
@@ -614,6 +714,7 @@ function createCustomTool(slug, options) {
|
|
|
614
714
|
name: validated.name,
|
|
615
715
|
description: validated.description,
|
|
616
716
|
extendsToolkit: validated.extendsToolkit,
|
|
717
|
+
preload: validated.preload,
|
|
617
718
|
inputSchema,
|
|
618
719
|
outputSchema,
|
|
619
720
|
inputParams,
|
|
@@ -655,26 +756,103 @@ function createCustomToolkit(slug, options) {
|
|
|
655
756
|
slug: slugResult.data,
|
|
656
757
|
name: validated.name,
|
|
657
758
|
description: validated.description,
|
|
759
|
+
preload: validated.preload,
|
|
658
760
|
tools: options.tools
|
|
659
761
|
};
|
|
660
762
|
}
|
|
661
763
|
/**
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
|
|
764
|
+
* Build the final slug for a custom tool given its context.
|
|
765
|
+
* @internal
|
|
766
|
+
*/
|
|
767
|
+
function buildFinalSlug(toolSlug, toolkitSlug) {
|
|
768
|
+
const upper = toolSlug.toUpperCase();
|
|
769
|
+
return toolkitSlug ? `${LOCAL_TOOL_PREFIX}${toolkitSlug.toUpperCase()}_${upper}` : `${LOCAL_TOOL_PREFIX}${upper}`;
|
|
770
|
+
}
|
|
771
|
+
const qualifiedOriginalSlugKey = (toolkit, originalSlug) => `${toolkit?.toUpperCase() ?? ""}::${originalSlug.toUpperCase()}`;
|
|
772
|
+
const canShareOriginalSlug = (existing, next) => !!existing.toolkit && !!next.toolkit && existing.toolkit.toLowerCase() !== next.toolkit.toLowerCase();
|
|
773
|
+
const addOriginalSlugAlias = (params) => {
|
|
774
|
+
const originalSlugKey = params.originalSlug.toUpperCase();
|
|
775
|
+
if (params.ambiguousOriginalSlugs.has(originalSlugKey)) return;
|
|
776
|
+
const existing = params.byOriginalSlug.get(originalSlugKey);
|
|
777
|
+
if (!existing) {
|
|
778
|
+
params.byOriginalSlug.set(originalSlugKey, params.entry);
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
if (existing.finalSlug.toUpperCase() === params.entry.finalSlug.toUpperCase()) return;
|
|
782
|
+
if (canShareOriginalSlug(existing, params.entry)) {
|
|
783
|
+
params.byOriginalSlug.delete(originalSlugKey);
|
|
784
|
+
params.ambiguousOriginalSlugs.add(originalSlugKey);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
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}".`);
|
|
788
|
+
};
|
|
789
|
+
/**
|
|
790
|
+
* Build a CustomToolsMap from custom tools and toolkits.
|
|
791
|
+
* Used internally by ToolRouter.create() to construct the per-session routing map.
|
|
665
792
|
*
|
|
666
793
|
* @internal
|
|
667
|
-
* @param tools -
|
|
668
|
-
* @
|
|
794
|
+
* @param tools - Standalone custom tools
|
|
795
|
+
* @param toolkits - Custom toolkits containing grouped tools
|
|
796
|
+
* @returns Maps for O(1) lookup by both final and original slug
|
|
797
|
+
* @throws If duplicate slugs or cross-group collisions
|
|
669
798
|
*/
|
|
670
|
-
function
|
|
799
|
+
function buildCustomToolsMap(tools, toolkits) {
|
|
800
|
+
const byFinalSlug = /* @__PURE__ */ new Map();
|
|
801
|
+
const byOriginalSlug = /* @__PURE__ */ new Map();
|
|
802
|
+
const byToolkitAndOriginalSlug = /* @__PURE__ */ new Map();
|
|
803
|
+
const ambiguousOriginalSlugs = /* @__PURE__ */ new Set();
|
|
804
|
+
const addEntry = (handle, finalSlug, toolkit) => {
|
|
805
|
+
const originalSlug = handle.slug.toUpperCase();
|
|
806
|
+
const finalSlugKey = finalSlug.toUpperCase();
|
|
807
|
+
if (finalSlug.length > MAX_SLUG_LENGTH) throw new ValidationError(`Custom tool slug "${handle.slug}" produces final slug "${finalSlug}" which exceeds ${MAX_SLUG_LENGTH} characters.`);
|
|
808
|
+
if (byFinalSlug.has(finalSlugKey)) throw new ValidationError(`Custom tool slug collision: "${finalSlug}" is already registered.`);
|
|
809
|
+
const qualifiedKey = qualifiedOriginalSlugKey(toolkit, originalSlug);
|
|
810
|
+
if (byToolkitAndOriginalSlug.has(qualifiedKey)) throw new ValidationError(`Custom tool slug collision: original slug "${handle.slug}" is already registered for toolkit "${toolkit ?? "custom"}".`);
|
|
811
|
+
const entry = {
|
|
812
|
+
handle,
|
|
813
|
+
finalSlug,
|
|
814
|
+
toolkit
|
|
815
|
+
};
|
|
816
|
+
byFinalSlug.set(finalSlugKey, entry);
|
|
817
|
+
byToolkitAndOriginalSlug.set(qualifiedKey, entry);
|
|
818
|
+
addOriginalSlugAlias({
|
|
819
|
+
byOriginalSlug,
|
|
820
|
+
ambiguousOriginalSlugs,
|
|
821
|
+
originalSlug,
|
|
822
|
+
entry
|
|
823
|
+
});
|
|
824
|
+
};
|
|
825
|
+
for (const handle of tools) addEntry(handle, buildFinalSlug(handle.slug, handle.extendsToolkit), handle.extendsToolkit);
|
|
826
|
+
if (toolkits) for (const toolkit of toolkits) for (const handle of toolkit.tools) addEntry(handle, buildFinalSlug(handle.slug, toolkit.slug), toolkit.slug);
|
|
827
|
+
return {
|
|
828
|
+
byFinalSlug,
|
|
829
|
+
byOriginalSlug,
|
|
830
|
+
byToolkitAndOriginalSlug,
|
|
831
|
+
...ambiguousOriginalSlugs.size ? { ambiguousOriginalSlugs } : {},
|
|
832
|
+
toolkits,
|
|
833
|
+
tools: tools.length ? tools : void 0
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
function shouldSerializePreload(preload, inheritedPreload, defaultPreload) {
|
|
837
|
+
const inheritedOrDefault = inheritedPreload ?? defaultPreload;
|
|
838
|
+
if (preload !== void 0) return preload || inheritedOrDefault ? preload : void 0;
|
|
839
|
+
if (inheritedPreload !== void 0) return inheritedPreload || defaultPreload ? inheritedPreload : void 0;
|
|
840
|
+
return defaultPreload ? true : void 0;
|
|
841
|
+
}
|
|
842
|
+
function preloadWireProperty(preload, inheritedPreload, defaultPreload) {
|
|
843
|
+
const serializedPreload = shouldSerializePreload(preload, inheritedPreload, defaultPreload);
|
|
844
|
+
return serializedPreload === void 0 ? {} : { preload: serializedPreload };
|
|
845
|
+
}
|
|
846
|
+
function serializeCustomTools(tools, options = {}) {
|
|
847
|
+
const defaultPreload = options.defaultPreload ?? false;
|
|
671
848
|
return tools.map((handle) => ({
|
|
672
849
|
slug: handle.slug,
|
|
673
850
|
name: handle.name,
|
|
674
851
|
description: handle.description,
|
|
675
852
|
input_schema: handle.inputSchema,
|
|
676
853
|
...handle.outputSchema ? { output_schema: handle.outputSchema } : {},
|
|
677
|
-
...handle.extendsToolkit ? { extends_toolkit: handle.extendsToolkit } : {}
|
|
854
|
+
...handle.extendsToolkit ? { extends_toolkit: handle.extendsToolkit } : {},
|
|
855
|
+
...preloadWireProperty(handle.preload, void 0, defaultPreload)
|
|
678
856
|
}));
|
|
679
857
|
}
|
|
680
858
|
/**
|
|
@@ -684,17 +862,20 @@ function serializeCustomTools(tools) {
|
|
|
684
862
|
* @param toolkits - The custom toolkits to serialize
|
|
685
863
|
* @returns Array of CustomToolkitDefinition for the API payload
|
|
686
864
|
*/
|
|
687
|
-
function serializeCustomToolkits(toolkits) {
|
|
865
|
+
function serializeCustomToolkits(toolkits, options = {}) {
|
|
866
|
+
const defaultPreload = options.defaultPreload ?? false;
|
|
688
867
|
return toolkits.map((tk) => ({
|
|
689
868
|
slug: tk.slug,
|
|
690
869
|
name: tk.name,
|
|
691
870
|
description: tk.description,
|
|
871
|
+
...preloadWireProperty(tk.preload, void 0, defaultPreload),
|
|
692
872
|
tools: tk.tools.map((t) => ({
|
|
693
873
|
slug: t.slug,
|
|
694
874
|
name: t.name,
|
|
695
875
|
description: t.description,
|
|
696
876
|
input_schema: t.inputSchema,
|
|
697
|
-
...t.outputSchema ? { output_schema: t.outputSchema } : {}
|
|
877
|
+
...t.outputSchema ? { output_schema: t.outputSchema } : {},
|
|
878
|
+
...preloadWireProperty(t.preload, tk.preload, defaultPreload)
|
|
698
879
|
}))
|
|
699
880
|
}));
|
|
700
881
|
}
|
|
@@ -711,34 +892,113 @@ function serializeCustomToolkits(toolkits) {
|
|
|
711
892
|
function buildCustomToolsMapFromResponse(tools, toolkits, experimental) {
|
|
712
893
|
const byFinalSlug = /* @__PURE__ */ new Map();
|
|
713
894
|
const byOriginalSlug = /* @__PURE__ */ new Map();
|
|
895
|
+
const byToolkitAndOriginalSlug = /* @__PURE__ */ new Map();
|
|
896
|
+
const ambiguousOriginalSlugs = /* @__PURE__ */ new Set();
|
|
897
|
+
const handlesByQualifiedOriginalSlug = /* @__PURE__ */ new Map();
|
|
714
898
|
const handlesByOriginalSlug = /* @__PURE__ */ new Map();
|
|
715
|
-
|
|
716
|
-
handle
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
toolkit
|
|
722
|
-
|
|
899
|
+
const registerHandle = (handle, toolkit) => {
|
|
900
|
+
const originalSlug = handle.slug.toUpperCase();
|
|
901
|
+
const match = {
|
|
902
|
+
handle,
|
|
903
|
+
toolkit
|
|
904
|
+
};
|
|
905
|
+
handlesByQualifiedOriginalSlug.set(qualifiedOriginalSlugKey(toolkit, originalSlug), match);
|
|
906
|
+
const existing = handlesByOriginalSlug.get(originalSlug) ?? [];
|
|
907
|
+
existing.push(match);
|
|
908
|
+
handlesByOriginalSlug.set(originalSlug, existing);
|
|
909
|
+
};
|
|
910
|
+
for (const handle of tools) registerHandle(handle, handle.extendsToolkit);
|
|
911
|
+
if (toolkits) for (const tk of toolkits) for (const handle of tk.tools) registerHandle(handle, tk.slug);
|
|
912
|
+
const findHandle = (originalSlug, toolkit) => {
|
|
913
|
+
const originalSlugKey = originalSlug.toUpperCase();
|
|
914
|
+
const qualifiedMatch = handlesByQualifiedOriginalSlug.get(qualifiedOriginalSlugKey(toolkit, originalSlugKey));
|
|
915
|
+
if (qualifiedMatch) return qualifiedMatch;
|
|
916
|
+
const bareMatches = handlesByOriginalSlug.get(originalSlugKey) ?? [];
|
|
917
|
+
return bareMatches.length === 1 ? bareMatches[0] : void 0;
|
|
918
|
+
};
|
|
723
919
|
const addEntry = (finalSlug, originalSlug, toolkit) => {
|
|
724
|
-
const
|
|
920
|
+
const resolvedToolkit = toolkit ?? void 0;
|
|
921
|
+
const match = findHandle(originalSlug, resolvedToolkit);
|
|
725
922
|
if (!match) return;
|
|
923
|
+
const finalSlugKey = finalSlug.toUpperCase();
|
|
924
|
+
if (byFinalSlug.has(finalSlugKey)) throw new ValidationError(`Custom tool slug collision: "${finalSlug}" is already registered.`);
|
|
726
925
|
const entry = {
|
|
727
926
|
handle: match.handle,
|
|
728
927
|
finalSlug,
|
|
729
|
-
toolkit:
|
|
928
|
+
toolkit: resolvedToolkit ?? match.toolkit
|
|
730
929
|
};
|
|
731
|
-
byFinalSlug.set(
|
|
732
|
-
|
|
930
|
+
byFinalSlug.set(finalSlugKey, entry);
|
|
931
|
+
byToolkitAndOriginalSlug.set(qualifiedOriginalSlugKey(entry.toolkit, originalSlug), entry);
|
|
932
|
+
addOriginalSlugAlias({
|
|
933
|
+
byOriginalSlug,
|
|
934
|
+
ambiguousOriginalSlugs,
|
|
935
|
+
originalSlug,
|
|
936
|
+
entry
|
|
937
|
+
});
|
|
733
938
|
};
|
|
734
939
|
if (experimental?.custom_tools) for (const ct of experimental.custom_tools) addEntry(ct.slug, ct.original_slug, ct.extends_toolkit);
|
|
735
940
|
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);
|
|
736
941
|
return {
|
|
737
942
|
byFinalSlug,
|
|
738
943
|
byOriginalSlug,
|
|
739
|
-
|
|
944
|
+
byToolkitAndOriginalSlug,
|
|
945
|
+
...ambiguousOriginalSlugs.size ? { ambiguousOriginalSlugs } : {},
|
|
946
|
+
toolkits,
|
|
947
|
+
tools: tools.length ? tools : void 0
|
|
740
948
|
};
|
|
741
949
|
}
|
|
950
|
+
/**
|
|
951
|
+
* Find a custom tool entry by final slug only.
|
|
952
|
+
*
|
|
953
|
+
* @internal
|
|
954
|
+
*/
|
|
955
|
+
function findCustomToolMapEntryByFinalSlug(customToolsMap, slug) {
|
|
956
|
+
return customToolsMap?.byFinalSlug.get(slug.toUpperCase());
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Find a custom toolkit tool entry by toolkit slug and original tool slug.
|
|
960
|
+
*
|
|
961
|
+
* @internal
|
|
962
|
+
*/
|
|
963
|
+
function findCustomToolMapEntryByToolkitAndOriginalSlug(customToolsMap, toolkit, slug) {
|
|
964
|
+
return customToolsMap?.byToolkitAndOriginalSlug?.get(qualifiedOriginalSlugKey(toolkit, slug));
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Reject legacy attempts to preload custom tools through top-level preload.tools.
|
|
968
|
+
*
|
|
969
|
+
* Custom tool direct exposure is controlled by CustomTool.preload /
|
|
970
|
+
* CustomToolkit.preload so it follows the current SDK-provided custom
|
|
971
|
+
* definitions instead of stale session config.
|
|
972
|
+
*
|
|
973
|
+
* @internal
|
|
974
|
+
*/
|
|
975
|
+
function assertNoCustomToolSlugsInPreload(preloadTools, customToolsMap) {
|
|
976
|
+
if (!preloadTools || preloadTools === PRELOAD_TOOLS_ALL) return;
|
|
977
|
+
const customPreloadSlugs = preloadTools.filter((slug) => {
|
|
978
|
+
const normalized = slug.toUpperCase();
|
|
979
|
+
return normalized.startsWith(LOCAL_TOOL_PREFIX) || customToolsMap?.byOriginalSlug.has(normalized) || customToolsMap?.ambiguousOriginalSlugs?.has(normalized) || customToolsMap?.byFinalSlug.has(normalized);
|
|
980
|
+
});
|
|
981
|
+
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.`);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Resolve custom tools that the SDK should expose directly from session.tools().
|
|
985
|
+
*
|
|
986
|
+
* @internal
|
|
987
|
+
*/
|
|
988
|
+
function getPreloadedCustomToolSlugs(customToolsMap, defaultPreload = false) {
|
|
989
|
+
if (!customToolsMap) return [];
|
|
990
|
+
const seen = /* @__PURE__ */ new Set();
|
|
991
|
+
const customToolSlugs = [];
|
|
992
|
+
for (const entry of customToolsMap.byFinalSlug.values()) {
|
|
993
|
+
const toolkit = customToolsMap.toolkits?.find((tk) => entry.toolkit && tk.slug.toLowerCase() === entry.toolkit.toLowerCase());
|
|
994
|
+
if (!(entry.handle.preload ?? toolkit?.preload ?? defaultPreload)) continue;
|
|
995
|
+
const finalSlugKey = entry.finalSlug.toUpperCase();
|
|
996
|
+
if (seen.has(finalSlugKey)) continue;
|
|
997
|
+
seen.add(finalSlugKey);
|
|
998
|
+
customToolSlugs.push(entry.finalSlug);
|
|
999
|
+
}
|
|
1000
|
+
return customToolSlugs;
|
|
1001
|
+
}
|
|
742
1002
|
|
|
743
1003
|
//#endregion
|
|
744
|
-
export {
|
|
1004
|
+
export { ComposioMultipleConnectedAccountsError as $, ValidationErrorCodes as A, ComposioGlobalExecuteToolFnNotSetError as B, ComposioWebhookSignatureVerificationError as C, JsonSchemaRefResolutionError as D, SDKErrorCodes as E, ConnectionRequestFailedError as F, ComposioToolNotFoundError as G, ComposioInvalidModifierError as H, ConnectionRequestTimeoutError as I, handleToolExecutionError as J, ComposioToolVersionRequiredError as K, AuthConfigErrorCodes as L, ComposioToolkitNotFoundError as M, ToolkitErrorCodes as N, JsonSchemaToZodError as O, ConnectionRequestErrorCodes as P, ComposioLegacyConnectedAccountsEndpointRetiredError as Q, ComposioAuthConfigNotFoundError as R, ComposioWebhookPayloadError as S, ComposioNoAPIKeyError as T, ComposioProviderNotDefinedError as U, ComposioInvalidExecuteFunctionError as V, ComposioToolExecutionError as W, ComposioConnectedAccountNotFoundError as X, ComposioAclOnlyForSharedError as Y, ComposioFailedToCreateConnectedAccountLink as Z, ComposioFailedToCreatePusherClientError as _, createCustomToolkit as a, ComposioFailedToUnsubscribeFromPusherChannelError as b, getPreloadedCustomToolSlugs as c, CreateCustomToolBaseSchema as d, ComposioSharedAccessDeniedError as et, CreateCustomToolkitBaseSchema as f, RemoteFileErrorCodes as g, RemoteFileDownloadError as h, createCustomTool as i, ComposioToolkitFetchError as j, ValidationError as k, serializeCustomToolkits as l, PRELOAD_TOOLS_ALL as m, buildCustomToolsMap as n, ConnectedAccountErrorCodes as nt, findCustomToolMapEntryByFinalSlug as o, CustomToolSlugSchema as p, ToolErrorCodes as q, buildCustomToolsMapFromResponse as r, findCustomToolMapEntryByToolkitAndOriginalSlug as s, assertNoCustomToolSlugsInPreload as t, ComposioSharedConnectionNotAccessibleError as tt, serializeCustomTools as u, ComposioFailedToGetSDKRealtimeCredentialsError as v, TriggerErrorCodes as w, ComposioTriggerTypeNotFoundError as x, ComposioFailedToSubscribeToPusherChannelError as y, ComposioCustomToolsNotInitializedError as z };
|
|
@@ -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-BVgnEbR2.cjs";
|
|
2
2
|
import { z } from "zod/v3";
|
|
3
3
|
import { SessionCreateResponse } from "@composio/client/resources/tool-router/session/session.mjs";
|
|
4
4
|
|