@composio/core 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BaseProvider-CVbQxTNa.d.cts → BaseProvider-BBnsv9kS.d.mts} +139 -92
- package/dist/CustomTool-DEB4BQPl.mjs +468 -0
- package/dist/{CustomTool-C-IUByoU.d.cts → CustomTool-DH18rVQu.d.mts} +2 -4
- package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
- package/dist/{Telemetry-DQax33Gh.mjs → Telemetry-DhGI_J4G.mjs} +15 -15
- package/dist/{composio-pcA13w87.d.cts → composio-CHnEggnv.d.mts} +394 -349
- package/dist/{customTool.types-QtkAZQma.d.cts → customTool.types-DpIdOJjL.d.mts} +171 -192
- package/dist/{CustomTool-D5s-aADw.mjs → errors-D5f4pfvI.mjs} +70 -457
- package/dist/experimental/index.d.mts +2 -3
- package/dist/experimental/index.mjs +1 -3
- package/dist/{fileUtils.node-Dq7ebZPC.mjs → fileUtils.node-BiO1JQsJ.mjs} +26 -25
- package/dist/index.d.mts +1685 -2400
- package/dist/index.mjs +2238 -1912
- package/dist/jsonSchema-daqF3S3d.mjs +251 -0
- package/dist/models/Files.node.d.mts +1 -2
- package/dist/models/Files.node.mjs +3 -4
- package/dist/models/Files.workerd.d.mts +0 -1
- package/dist/platform/node.d.mts +1 -2
- package/dist/platform/workerd.d.mts +1 -2
- package/dist/{chunk-CWQeghP5.mjs → rolldown-runtime-w6R9maHv.mjs} +3 -5
- package/dist/{types-J2KCXP8R.d.mts → types-CaI5Z4PA.d.mts} +2 -3
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +3 -0
- package/dist/utils/json-schema.d.mts +2 -0
- package/dist/utils/json-schema.mjs +3 -0
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +44 -24
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/package.json +39 -88
- package/dist/BaseProvider-BvHvJLXc.d.mts +0 -29378
- package/dist/CustomTool-CChQSp44.d.mts +0 -76
- package/dist/CustomTool-D3-NreIm.cjs +0 -1341
- package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
- package/dist/FileToolModifier.utils.neutral-DSBQs9-i.cjs +0 -96
- package/dist/Telemetry-BQ_pl5AK.cjs +0 -360
- package/dist/buffer-BjWptbNH.cjs +0 -63
- package/dist/chunk-CQwRTUmo.cjs +0 -53
- package/dist/composio-BlASKqjQ.d.mts +0 -5437
- package/dist/customTool.types-DLIORcYN.d.mts +0 -2475
- package/dist/experimental/index.cjs +0 -5
- package/dist/experimental/index.d.cts +0 -3
- package/dist/fileUtils.node-DtnSRMWa.cjs +0 -462
- package/dist/files.types-lo4zZd87.d.cts +0 -17
- package/dist/index.cjs +0 -8523
- package/dist/index.d.cts +0 -6065
- package/dist/models/Files.node.cjs +0 -55
- package/dist/models/Files.node.d.cts +0 -56
- package/dist/models/Files.workerd.cjs +0 -29
- package/dist/models/Files.workerd.d.cts +0 -13
- package/dist/platform/node.cjs +0 -55
- package/dist/platform/node.d.cts +0 -11
- package/dist/platform/workerd.cjs +0 -42
- package/dist/platform/workerd.d.cts +0 -12
- package/dist/types-DRG5qLxI.d.cts +0 -13
- package/dist/types-pDNm1lYs.d.cts +0 -69
- package/dist/utils/config-defaults/ConfigDefaults.node.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +0 -7
- package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +0 -7
- package/dist/utils/modifiers/FileToolModifier.node.cjs +0 -224
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +0 -22
- package/dist/utils/modifiers/FileToolModifier.workerd.cjs +0 -27
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +0 -20
- /package/dist/{FileToolModifier.utils.neutral-BpSceNK8.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +0 -0
- /package/dist/{buffer-yOtEsT4J.mjs → buffer-PcbMMsgm.mjs} +0 -0
- /package/dist/{files.types-BXDWA_zS.d.mts → files.types-DeMC_mAW.d.mts} +0 -0
- /package/dist/{types-HpJQ8K9l.d.mts → types-DdoCRzLj.d.mts} +0 -0
|
@@ -1,1341 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CQwRTUmo.cjs');
|
|
2
|
-
const require_FileModifierErrors = require('./FileModifierErrors-BYJBHiay.cjs');
|
|
3
|
-
let _composio_client = require("@composio/client");
|
|
4
|
-
let zod_v3 = require("zod/v3");
|
|
5
|
-
let zod_to_json_schema = require("zod-to-json-schema");
|
|
6
|
-
zod_to_json_schema = require_chunk.__toESM(zod_to_json_schema);
|
|
7
|
-
|
|
8
|
-
//#region src/errors/ConnectedAccountsErrors.ts
|
|
9
|
-
const ConnectedAccountErrorCodes = {
|
|
10
|
-
CONNECTED_ACCOUNT_NOT_FOUND: "CONNECTED_ACCOUNT_NOT_FOUND",
|
|
11
|
-
MULTIPLE_CONNECTED_ACCOUNTS: "MULTIPLE_CONNECTED_ACCOUNTS",
|
|
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"
|
|
17
|
-
};
|
|
18
|
-
var ComposioConnectedAccountNotFoundError = class extends require_FileModifierErrors.ComposioError {
|
|
19
|
-
constructor(message = "Connected account not found", options = {}) {
|
|
20
|
-
super(message, {
|
|
21
|
-
...options,
|
|
22
|
-
code: ConnectedAccountErrorCodes.CONNECTED_ACCOUNT_NOT_FOUND,
|
|
23
|
-
statusCode: 404,
|
|
24
|
-
possibleFixes: options.possibleFixes || ["Ensure the connected account exists and is active in your Composio dashboard"]
|
|
25
|
-
});
|
|
26
|
-
this.name = "ComposioConnectedAccountNotFoundError";
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var ComposioMultipleConnectedAccountsError = class extends require_FileModifierErrors.ComposioError {
|
|
30
|
-
constructor(message = "Multiple connected accounts found", options = {}) {
|
|
31
|
-
super(message, {
|
|
32
|
-
...options,
|
|
33
|
-
code: ConnectedAccountErrorCodes.MULTIPLE_CONNECTED_ACCOUNTS,
|
|
34
|
-
possibleFixes: options.possibleFixes || ["Use the allowMultiple flag to allow multiple connected accounts per user for an auth config"]
|
|
35
|
-
});
|
|
36
|
-
this.name = "ComposioMultipleConnectedAccountsError";
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var ComposioFailedToCreateConnectedAccountLink = class extends require_FileModifierErrors.ComposioError {
|
|
40
|
-
constructor(message = "Failed to create connected account link", options = {}) {
|
|
41
|
-
super(message, {
|
|
42
|
-
...options,
|
|
43
|
-
code: ConnectedAccountErrorCodes.FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK
|
|
44
|
-
});
|
|
45
|
-
this.name = "ComposioFailedToCreateConnectedAccountLink";
|
|
46
|
-
}
|
|
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.experimental.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.experimental.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
|
-
};
|
|
124
|
-
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region src/errors/ToolErrors.ts
|
|
127
|
-
const ToolErrorCodes = {
|
|
128
|
-
TOOLSET_NOT_DEFINED: "TOOLSET_NOT_DEFINED",
|
|
129
|
-
TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
|
|
130
|
-
INVALID_MODIFIER: "INVALID_MODIFIER",
|
|
131
|
-
TOOL_EXECUTION_ERROR: "TOOL_EXECUTION_ERROR",
|
|
132
|
-
INVALID_TOOL_ARGUMENTS: "INVALID_TOOL_ARGUMENTS",
|
|
133
|
-
INVALID_EXECUTE_FUNCTION: "INVALID_EXECUTE_FUNCTION",
|
|
134
|
-
GLOBAL_EXECUTE_TOOL_FN_NOT_SET: "GLOBAL_EXECUTE_TOOL_FN_NOT_SET",
|
|
135
|
-
TOOL_VERSION_REQUIRED: "TOOL_VERSION_REQUIRED"
|
|
136
|
-
};
|
|
137
|
-
var ComposioProviderNotDefinedError = class extends require_FileModifierErrors.ComposioError {
|
|
138
|
-
constructor(message = "Provider not defined", options = {}) {
|
|
139
|
-
super(message, {
|
|
140
|
-
...options,
|
|
141
|
-
code: ToolErrorCodes.TOOLSET_NOT_DEFINED,
|
|
142
|
-
possibleFixes: options.possibleFixes || ["Ensure that the provider is defined in the Composio project and passed into the tool instance"]
|
|
143
|
-
});
|
|
144
|
-
this.name = "ComposioProviderNotDefinedError";
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
var ComposioToolNotFoundError = class extends require_FileModifierErrors.ComposioError {
|
|
148
|
-
constructor(message = "Tool not found", options = {}) {
|
|
149
|
-
super(message, {
|
|
150
|
-
...options,
|
|
151
|
-
code: ToolErrorCodes.TOOL_NOT_FOUND,
|
|
152
|
-
possibleFixes: options.possibleFixes || ["Ensure the tool slug is correct and exists in the Composio project"]
|
|
153
|
-
});
|
|
154
|
-
this.name = "ComposioToolNotFoundError";
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
var ComposioInvalidModifierError = class extends require_FileModifierErrors.ComposioError {
|
|
158
|
-
constructor(message = "Invalid modifier", options = {}) {
|
|
159
|
-
super(message, {
|
|
160
|
-
...options,
|
|
161
|
-
code: ToolErrorCodes.INVALID_MODIFIER,
|
|
162
|
-
possibleFixes: options.possibleFixes || ["Ensure the modifier is a function and returns a valid result"]
|
|
163
|
-
});
|
|
164
|
-
this.name = "ComposioInvalidModifierError";
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
var ComposioToolExecutionError = class extends require_FileModifierErrors.ComposioError {
|
|
168
|
-
constructor(message = "Tool execution error", options = {}) {
|
|
169
|
-
super(message, {
|
|
170
|
-
...options,
|
|
171
|
-
code: options.code || ToolErrorCodes.TOOL_EXECUTION_ERROR,
|
|
172
|
-
cause: options.cause,
|
|
173
|
-
possibleFixes: options.possibleFixes || ["Ensure the tool is correctly configured and the input is valid", "Ensure the userId is correct and has an active connected account for the user in case of non NoAuth toolkits"]
|
|
174
|
-
});
|
|
175
|
-
this.name = "ComposioToolExecutionError";
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
var ComposioInvalidToolArgumentsError = class extends require_FileModifierErrors.ComposioError {
|
|
179
|
-
constructor(message = "Invalid tool arguments", options = {}) {
|
|
180
|
-
super(message, {
|
|
181
|
-
...options,
|
|
182
|
-
code: ToolErrorCodes.INVALID_TOOL_ARGUMENTS,
|
|
183
|
-
possibleFixes: options.possibleFixes || ["Tool arguments must be a JSON object (or a string that parses to one)", "If a model emitted the arguments as a string, ensure it is valid JSON"]
|
|
184
|
-
});
|
|
185
|
-
this.name = "ComposioInvalidToolArgumentsError";
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
var ComposioInvalidExecuteFunctionError = class extends require_FileModifierErrors.ComposioError {
|
|
189
|
-
constructor(message = "Invalid execute function", options = {}) {
|
|
190
|
-
super(message, {
|
|
191
|
-
...options,
|
|
192
|
-
code: ToolErrorCodes.INVALID_EXECUTE_FUNCTION,
|
|
193
|
-
possibleFixes: options.possibleFixes || ["Ensure the execute function is a valid function and returns a valid result"]
|
|
194
|
-
});
|
|
195
|
-
this.name = "ComposioInvalidExecuteFunctionError";
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
var ComposioGlobalExecuteToolFnNotSetError = class extends require_FileModifierErrors.ComposioError {
|
|
199
|
-
constructor(message = "Global execute tool function not set", options = {}) {
|
|
200
|
-
super(message, {
|
|
201
|
-
...options,
|
|
202
|
-
code: ToolErrorCodes.GLOBAL_EXECUTE_TOOL_FN_NOT_SET,
|
|
203
|
-
possibleFixes: options.possibleFixes || ["Ensure the global execute tool function is set in the provider"]
|
|
204
|
-
});
|
|
205
|
-
this.name = "ComposioGlobalExecuteToolFnNotSetError";
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
/**
|
|
209
|
-
* Error thrown when toolkit version is not specified for manual tool execution.
|
|
210
|
-
*
|
|
211
|
-
* This error is thrown when attempting to execute a tool manually (via `tools.execute()`)
|
|
212
|
-
* and the resolved version is "latest" without `dangerouslySkipVersionCheck` set to true.
|
|
213
|
-
*
|
|
214
|
-
* **Why this error exists:**
|
|
215
|
-
* Using "latest" version in manual execution can lead to unexpected behavior when new
|
|
216
|
-
* toolkit versions are released, potentially breaking your application. For production
|
|
217
|
-
* use, it's recommended to pin specific toolkit versions.
|
|
218
|
-
*
|
|
219
|
-
* **How to fix:**
|
|
220
|
-
* 1. Specify a concrete version in the execute call
|
|
221
|
-
* 2. Configure toolkit versions at SDK initialization
|
|
222
|
-
* 3. Set toolkit version via environment variable
|
|
223
|
-
* 4. Use dangerouslySkipVersionCheck (not recommended for production)
|
|
224
|
-
*
|
|
225
|
-
* @example ❌ This will throw ComposioToolVersionRequiredError if toolkitVersions is 'latest'
|
|
226
|
-
* ```typescript
|
|
227
|
-
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
228
|
-
* userId: 'default',
|
|
229
|
-
* arguments: { owner: 'composio' }
|
|
230
|
-
* });
|
|
231
|
-
* ```
|
|
232
|
-
*
|
|
233
|
-
* @example ✅ Fix 1: Pass specific version in execute call
|
|
234
|
-
* ```typescript
|
|
235
|
-
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
236
|
-
* userId: 'default',
|
|
237
|
-
* version: '20250909_00',
|
|
238
|
-
* arguments: { owner: 'composio' }
|
|
239
|
-
* });
|
|
240
|
-
* ```
|
|
241
|
-
*
|
|
242
|
-
* @example ✅ Fix 2: Configure toolkit versions at SDK level
|
|
243
|
-
* ```typescript
|
|
244
|
-
* const composio = new Composio({
|
|
245
|
-
* toolkitVersions: { github: '20250909_00' }
|
|
246
|
-
* });
|
|
247
|
-
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
248
|
-
* userId: 'default',
|
|
249
|
-
* arguments: { owner: 'composio' }
|
|
250
|
-
* });
|
|
251
|
-
* ```
|
|
252
|
-
*
|
|
253
|
-
* @example ✅ Fix 3: Use environment variable
|
|
254
|
-
* ```typescript
|
|
255
|
-
* // Set: COMPOSIO_TOOLKIT_VERSION_GITHUB=20250909_00
|
|
256
|
-
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
257
|
-
* userId: 'default',
|
|
258
|
-
* arguments: { owner: 'composio' }
|
|
259
|
-
* });
|
|
260
|
-
* ```
|
|
261
|
-
*
|
|
262
|
-
* @example ⚠️ Fix 4: Skip version check (not recommended for production)
|
|
263
|
-
* ```typescript
|
|
264
|
-
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
265
|
-
* userId: 'default',
|
|
266
|
-
* dangerouslySkipVersionCheck: true,
|
|
267
|
-
* arguments: { owner: 'composio' }
|
|
268
|
-
* });
|
|
269
|
-
* ```
|
|
270
|
-
*/
|
|
271
|
-
var ComposioToolVersionRequiredError = class extends require_FileModifierErrors.ComposioError {
|
|
272
|
-
constructor(message = "Toolkit version not specified. For manual execution of the tool please pass a specific toolkit version", options = {}) {
|
|
273
|
-
super(message, {
|
|
274
|
-
...options,
|
|
275
|
-
code: ToolErrorCodes.TOOL_VERSION_REQUIRED,
|
|
276
|
-
possibleFixes: options.possibleFixes || [
|
|
277
|
-
"Pass the toolkit version as a parameter to the execute function (\"latest\" is not supported in manual execution)",
|
|
278
|
-
"Set the toolkit versions in the Composio config (toolkitVersions: { <toolkit-slug>: \"<toolkit-version>\" })",
|
|
279
|
-
"Set the toolkit version in the environment variable (COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_SLUG>)",
|
|
280
|
-
"Set dangerouslySkipVersionCheck to true (this might cause unexpected behavior when new versions of the tools are released)"
|
|
281
|
-
]
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
const ERROR_CODE_HANDLERS = new Map([[1803, (msg) => new ComposioConnectedAccountNotFoundError(msg)]]);
|
|
286
|
-
const handleToolExecutionError = (tool, actualError) => {
|
|
287
|
-
if (actualError instanceof _composio_client.APIError && actualError.error) {
|
|
288
|
-
const errorBody = actualError.error;
|
|
289
|
-
const errorCode = errorBody?.error?.code;
|
|
290
|
-
const errorMessage = errorBody?.error?.message;
|
|
291
|
-
if (errorCode && ERROR_CODE_HANDLERS.has(errorCode)) return ERROR_CODE_HANDLERS.get(errorCode)(errorMessage || "An error occurred");
|
|
292
|
-
}
|
|
293
|
-
return new ComposioToolExecutionError(`Error executing the tool ${tool}`, {
|
|
294
|
-
cause: actualError,
|
|
295
|
-
possibleFixes: ["Ensure the tool slug is correct and the input arguments for the tool is valid"]
|
|
296
|
-
});
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
//#endregion
|
|
300
|
-
//#region src/errors/ValidationErrors.ts
|
|
301
|
-
/**
|
|
302
|
-
* Represents an input validation error using Zod.
|
|
303
|
-
*/
|
|
304
|
-
const ValidationErrorCodes = {
|
|
305
|
-
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
306
|
-
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR",
|
|
307
|
-
JSON_SCHEMA_REF_RESOLUTION_ERROR: "JSON_SCHEMA_REF_RESOLUTION_ERROR"
|
|
308
|
-
};
|
|
309
|
-
var ValidationError = class extends require_FileModifierErrors.ComposioError {
|
|
310
|
-
constructor(message = "Input validation failed", options = {}) {
|
|
311
|
-
const { cause: providedZodError, ...restOptions } = options;
|
|
312
|
-
let zodErrorInstance;
|
|
313
|
-
if (providedZodError instanceof zod_v3.ZodError) zodErrorInstance = providedZodError;
|
|
314
|
-
else zodErrorInstance = new zod_v3.ZodError([{
|
|
315
|
-
path: [],
|
|
316
|
-
message: "Invalid input",
|
|
317
|
-
code: "custom"
|
|
318
|
-
}]);
|
|
319
|
-
const issues = zodErrorInstance.issues.map((issue) => `[${issue.code}] ${issue.path.join(".")} - ${issue.message}`);
|
|
320
|
-
super(message, {
|
|
321
|
-
...restOptions,
|
|
322
|
-
code: options.code || ValidationErrorCodes.VALIDATION_ERROR,
|
|
323
|
-
possibleFixes: issues,
|
|
324
|
-
cause: zodErrorInstance
|
|
325
|
-
});
|
|
326
|
-
this.name = "ValidationError";
|
|
327
|
-
this.message = `${message}: ${this.generateUserFriendlyMessage()}`;
|
|
328
|
-
}
|
|
329
|
-
generateUserFriendlyMessage() {
|
|
330
|
-
if (this.cause instanceof zod_v3.ZodError && this.cause.issues.length > 0) {
|
|
331
|
-
const issue = this.cause.issues[0];
|
|
332
|
-
const param = issue.path.join(".") || "parameter";
|
|
333
|
-
if (issue.code === "invalid_type") return `The ${param} should be a ${issue.expected}, but you provided a ${issue.received}`;
|
|
334
|
-
return issue.message;
|
|
335
|
-
}
|
|
336
|
-
return "Please check your input parameters";
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
var JsonSchemaToZodError = class extends require_FileModifierErrors.ComposioError {
|
|
340
|
-
constructor(message = "Failed to convert JSON schema to Zod schema", options = {}) {
|
|
341
|
-
super(message, {
|
|
342
|
-
...options,
|
|
343
|
-
code: options.code || ValidationErrorCodes.JSON_SCHEMA_TO_ZOD_ERROR
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
/**
|
|
348
|
-
* Thrown when a JSON Schema `$ref` pointer cannot be resolved against the
|
|
349
|
-
* document. Used by `dereferenceJsonSchema` to surface malformed pointers,
|
|
350
|
-
* missing `$defs`/`definitions` targets, or chains exceeding the depth cap.
|
|
351
|
-
*/
|
|
352
|
-
var JsonSchemaRefResolutionError = class extends require_FileModifierErrors.ComposioError {
|
|
353
|
-
constructor(message = "Failed to resolve JSON Schema $ref", options = {}) {
|
|
354
|
-
super(message, {
|
|
355
|
-
...options,
|
|
356
|
-
code: options.code || ValidationErrorCodes.JSON_SCHEMA_REF_RESOLUTION_ERROR
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/errors/AuthConfigErrors.ts
|
|
363
|
-
const AuthConfigErrorCodes = { AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND" };
|
|
364
|
-
var ComposioAuthConfigNotFoundError = class extends require_FileModifierErrors.ComposioError {
|
|
365
|
-
constructor(message = "Auth config not found", options = {}) {
|
|
366
|
-
super(message, {
|
|
367
|
-
...options,
|
|
368
|
-
code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
|
|
369
|
-
possibleFixes: options.possibleFixes || [
|
|
370
|
-
"Check if the auth config exists",
|
|
371
|
-
"Check if the auth config id is correct",
|
|
372
|
-
"Check if the auth config is enabled"
|
|
373
|
-
]
|
|
374
|
-
});
|
|
375
|
-
this.name = "ComposioAuthConfigNotFoundError";
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
//#endregion
|
|
380
|
-
//#region src/errors/ConnectionRequestErrors.ts
|
|
381
|
-
const ConnectionRequestErrorCodes = {
|
|
382
|
-
CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
|
|
383
|
-
CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
|
|
384
|
-
};
|
|
385
|
-
var ConnectionRequestTimeoutError = class extends require_FileModifierErrors.ComposioError {
|
|
386
|
-
constructor(message = "Connection request timed out", options = {}) {
|
|
387
|
-
super(message, {
|
|
388
|
-
...options,
|
|
389
|
-
code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT
|
|
390
|
-
});
|
|
391
|
-
this.name = "ConnectionRequestTimeoutError";
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
var ConnectionRequestFailedError = class extends require_FileModifierErrors.ComposioError {
|
|
395
|
-
constructor(message = "Connection request failed", options = {}) {
|
|
396
|
-
super(message, {
|
|
397
|
-
...options,
|
|
398
|
-
code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED
|
|
399
|
-
});
|
|
400
|
-
this.name = "ConnectionRequestFailedError";
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
//#endregion
|
|
405
|
-
//#region src/errors/ToolkitErrors.ts
|
|
406
|
-
const ToolkitErrorCodes = { TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND" };
|
|
407
|
-
var ComposioToolkitNotFoundError = class extends require_FileModifierErrors.ComposioError {
|
|
408
|
-
constructor(message = "Toolkit not found", options = {}) {
|
|
409
|
-
super(message, {
|
|
410
|
-
...options,
|
|
411
|
-
code: "TOOLKIT_NOT_FOUND",
|
|
412
|
-
possibleFixes: options.possibleFixes || ["Ensure the toolkit is correctly configured and the slug is valid"]
|
|
413
|
-
});
|
|
414
|
-
this.name = "ComposioToolkitNotFoundError";
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
var ComposioToolkitFetchError = class extends require_FileModifierErrors.ComposioError {
|
|
418
|
-
constructor(message = "Failed to fetch toolkit", options = {}) {
|
|
419
|
-
super(message, {
|
|
420
|
-
...options,
|
|
421
|
-
code: "TOOLKIT_FETCH_ERROR",
|
|
422
|
-
possibleFixes: options.possibleFixes || [
|
|
423
|
-
"Ensure the toolkit slug is valid",
|
|
424
|
-
"Ensure you are using the correct API key",
|
|
425
|
-
"Ensure you are using the correct API endpoint / Base URL and it is working"
|
|
426
|
-
]
|
|
427
|
-
});
|
|
428
|
-
this.name = "ComposioToolkitFetchError";
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
//#endregion
|
|
433
|
-
//#region src/errors/SDKErrors.ts
|
|
434
|
-
const SDKErrorCodes = { NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED" };
|
|
435
|
-
var ComposioNoAPIKeyError = class extends require_FileModifierErrors.ComposioError {
|
|
436
|
-
constructor(message = "No Composio API key provided", options = {}) {
|
|
437
|
-
const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
|
|
438
|
-
super(message, {
|
|
439
|
-
...options,
|
|
440
|
-
code: SDKErrorCodes.NO_API_KEY_PROVIDED,
|
|
441
|
-
cause: options.cause || defaultCause,
|
|
442
|
-
possibleFixes: options.possibleFixes || [
|
|
443
|
-
"Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file",
|
|
444
|
-
"To get an API key, please sign up at https://composio.dev/signup",
|
|
445
|
-
"You can also use the Composio CLI to create a project and get an API key"
|
|
446
|
-
],
|
|
447
|
-
statusCode: 401
|
|
448
|
-
});
|
|
449
|
-
this.name = "ComposioNoAPIKeyError";
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/errors/TriggerErrors.ts
|
|
455
|
-
const TriggerErrorCodes = {
|
|
456
|
-
TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS: "TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS",
|
|
457
|
-
TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT: "TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT",
|
|
458
|
-
TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL: "TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL",
|
|
459
|
-
TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL: "TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL",
|
|
460
|
-
TRIGGER_TYPE_NOT_FOUND: "TRIGGER_TYPE_NOT_FOUND",
|
|
461
|
-
WEBHOOK_SIGNATURE_VERIFICATION_FAILED: "WEBHOOK_SIGNATURE_VERIFICATION_FAILED",
|
|
462
|
-
WEBHOOK_PAYLOAD_INVALID: "WEBHOOK_PAYLOAD_INVALID"
|
|
463
|
-
};
|
|
464
|
-
var ComposioFailedToGetSDKRealtimeCredentialsError = class extends require_FileModifierErrors.ComposioError {
|
|
465
|
-
constructor(message = "Failed to get SDK realtime credentials", options = {}) {
|
|
466
|
-
super(message, {
|
|
467
|
-
...options,
|
|
468
|
-
code: TriggerErrorCodes.TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS,
|
|
469
|
-
possibleFixes: options.possibleFixes || ["Please contact support."]
|
|
470
|
-
});
|
|
471
|
-
this.name = "ComposioFailedToGetSDKRealtimeCredentialsError";
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
var ComposioFailedToCreatePusherClientError = class extends require_FileModifierErrors.ComposioError {
|
|
475
|
-
constructor(message = "Failed to create Pusher client", options = {}) {
|
|
476
|
-
super(message, {
|
|
477
|
-
...options,
|
|
478
|
-
code: TriggerErrorCodes.TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT,
|
|
479
|
-
possibleFixes: options.possibleFixes || ["Please contact support."]
|
|
480
|
-
});
|
|
481
|
-
this.name = "ComposioFailedToCreatePusherClientError";
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
var ComposioFailedToSubscribeToPusherChannelError = class extends require_FileModifierErrors.ComposioError {
|
|
485
|
-
constructor(message = "Failed to subscribe to Pusher channel", options = {}) {
|
|
486
|
-
super(message, {
|
|
487
|
-
...options,
|
|
488
|
-
code: TriggerErrorCodes.TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL,
|
|
489
|
-
possibleFixes: options.possibleFixes || ["Please contact support."]
|
|
490
|
-
});
|
|
491
|
-
this.name = "ComposioFailedToSubscribeToPusherChannelError";
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
var ComposioFailedToUnsubscribeFromPusherChannelError = class extends require_FileModifierErrors.ComposioError {
|
|
495
|
-
constructor(message = "Failed to unsubscribe from Pusher channel", options = {}) {
|
|
496
|
-
super(message, {
|
|
497
|
-
...options,
|
|
498
|
-
code: TriggerErrorCodes.TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL,
|
|
499
|
-
possibleFixes: options.possibleFixes || ["Please contact support."]
|
|
500
|
-
});
|
|
501
|
-
this.name = "ComposioFailedToUnsubscribeFromPusherChannelError";
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
var ComposioTriggerTypeNotFoundError = class extends require_FileModifierErrors.ComposioError {
|
|
505
|
-
constructor(message = "Trigger type not found", options = {}) {
|
|
506
|
-
super(message, {
|
|
507
|
-
...options,
|
|
508
|
-
code: TriggerErrorCodes.TRIGGER_TYPE_NOT_FOUND,
|
|
509
|
-
statusCode: 404,
|
|
510
|
-
possibleFixes: options.possibleFixes || ["Please contact support."]
|
|
511
|
-
});
|
|
512
|
-
this.name = "ComposioTriggerTypeNotFoundError";
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
var ComposioWebhookSignatureVerificationError = class extends require_FileModifierErrors.ComposioError {
|
|
516
|
-
constructor(message = "Webhook signature verification failed", options = {}) {
|
|
517
|
-
super(message, {
|
|
518
|
-
...options,
|
|
519
|
-
code: TriggerErrorCodes.WEBHOOK_SIGNATURE_VERIFICATION_FAILED,
|
|
520
|
-
statusCode: 401,
|
|
521
|
-
possibleFixes: options.possibleFixes || [
|
|
522
|
-
"Verify that the webhook secret is correct.",
|
|
523
|
-
"Ensure the raw request body is passed without modifications.",
|
|
524
|
-
"Check that the signature header value is being passed correctly."
|
|
525
|
-
]
|
|
526
|
-
});
|
|
527
|
-
this.name = "ComposioWebhookSignatureVerificationError";
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
var ComposioWebhookPayloadError = class extends require_FileModifierErrors.ComposioError {
|
|
531
|
-
constructor(message = "Invalid webhook payload", options = {}) {
|
|
532
|
-
super(message, {
|
|
533
|
-
...options,
|
|
534
|
-
code: TriggerErrorCodes.WEBHOOK_PAYLOAD_INVALID,
|
|
535
|
-
statusCode: 400,
|
|
536
|
-
possibleFixes: options.possibleFixes || ["Ensure the webhook payload is valid JSON.", "Verify the payload structure matches the expected format."]
|
|
537
|
-
});
|
|
538
|
-
this.name = "ComposioWebhookPayloadError";
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
//#endregion
|
|
543
|
-
//#region src/errors/RemoteFileErrors.ts
|
|
544
|
-
const RemoteFileErrorCodes = { DOWNLOAD_FAILED: "REMOTE_FILE_DOWNLOAD_FAILED" };
|
|
545
|
-
/**
|
|
546
|
-
* Error thrown when fetching a remote file from a tool router session mount fails.
|
|
547
|
-
* Includes HTTP status, URL, and file path context for debugging.
|
|
548
|
-
*/
|
|
549
|
-
var RemoteFileDownloadError = class extends require_FileModifierErrors.ComposioError {
|
|
550
|
-
constructor(message = "Failed to download remote file", options = {}) {
|
|
551
|
-
const { statusCode, statusText, downloadUrl, mountRelativePath, filename, meta: optionsMeta, ...rest } = options;
|
|
552
|
-
const meta = {
|
|
553
|
-
...optionsMeta,
|
|
554
|
-
...statusCode !== void 0 && { statusCode },
|
|
555
|
-
...statusText && { statusText },
|
|
556
|
-
...downloadUrl && { downloadUrl },
|
|
557
|
-
...mountRelativePath && { mountRelativePath },
|
|
558
|
-
...filename && { filename }
|
|
559
|
-
};
|
|
560
|
-
super(message, {
|
|
561
|
-
...rest,
|
|
562
|
-
code: RemoteFileErrorCodes.DOWNLOAD_FAILED,
|
|
563
|
-
statusCode,
|
|
564
|
-
meta: Object.keys(meta).length > 0 ? meta : void 0,
|
|
565
|
-
possibleFixes: options.possibleFixes ?? [
|
|
566
|
-
"Verify the download URL has not expired (check expiresAt)",
|
|
567
|
-
"Ensure the file exists at the specified mount path",
|
|
568
|
-
"Retry the operation; presigned URLs may have transient failures"
|
|
569
|
-
]
|
|
570
|
-
});
|
|
571
|
-
this.name = "RemoteFileDownloadError";
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
|
|
575
|
-
//#endregion
|
|
576
|
-
//#region src/lib/toolRouterConstants.ts
|
|
577
|
-
const PRELOAD_TOOLS_ALL = "all";
|
|
578
|
-
|
|
579
|
-
//#endregion
|
|
580
|
-
//#region src/types/customTool.types.ts
|
|
581
|
-
/**
|
|
582
|
-
* Zod schema for validating a custom tool slug.
|
|
583
|
-
* Alphanumeric, underscores, and hyphens only. No `LOCAL_` or `COMPOSIO_` prefix.
|
|
584
|
-
* Length is validated contextually (standalone vs extension vs toolkit) at creation time.
|
|
585
|
-
*/
|
|
586
|
-
const CustomToolSlugSchema = zod_v3.z.string().min(1, "slug is required").regex(/^[A-Za-z0-9_-]+$/, "slug must only contain alphanumeric characters, underscores, and hyphens").refine((s) => !s.toUpperCase().startsWith("LOCAL_"), { message: "slug must not start with \"LOCAL_\" — this prefix is reserved for internal routing." }).refine((s) => !s.toUpperCase().startsWith("COMPOSIO_"), { message: "slug must not start with \"COMPOSIO_\" — this prefix is reserved for Composio meta tools." });
|
|
587
|
-
/**
|
|
588
|
-
* Zod schema for validating the string/scalar fields of createCustomTool() options.
|
|
589
|
-
* Slug is validated separately as the first argument.
|
|
590
|
-
* Used internally for validation — inputParams, outputParams, and execute are checked manually.
|
|
591
|
-
*/
|
|
592
|
-
const CreateCustomToolBaseSchema = zod_v3.z.object({
|
|
593
|
-
name: zod_v3.z.string().min(1, "createCustomTool: name is required"),
|
|
594
|
-
description: zod_v3.z.string().min(1, "createCustomTool: description is required"),
|
|
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.")
|
|
597
|
-
});
|
|
598
|
-
/**
|
|
599
|
-
* Zod schema for validating the string/scalar fields of createCustomToolkit() options.
|
|
600
|
-
* Slug is validated separately as the first argument.
|
|
601
|
-
*/
|
|
602
|
-
const CreateCustomToolkitBaseSchema = zod_v3.z.object({
|
|
603
|
-
name: zod_v3.z.string().min(1, "createCustomToolkit: name 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.")
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
//#endregion
|
|
609
|
-
//#region src/models/CustomTool.ts
|
|
610
|
-
/**
|
|
611
|
-
* @fileoverview Factory functions for creating custom tools and toolkits.
|
|
612
|
-
*
|
|
613
|
-
* Usage:
|
|
614
|
-
* ```typescript
|
|
615
|
-
* import { experimental_createTool, experimental_createToolkit } from '@composio/core';
|
|
616
|
-
*
|
|
617
|
-
* const grep = createCustomTool('GREP', {
|
|
618
|
-
* name: 'Grep Search',
|
|
619
|
-
* description: 'Search for patterns in files',
|
|
620
|
-
* inputParams: z.object({ pattern: z.string() }),
|
|
621
|
-
* execute: async (input) => ({ matches: [] }),
|
|
622
|
-
* });
|
|
623
|
-
*
|
|
624
|
-
* const devTools = createCustomToolkit('DEV_TOOLS', {
|
|
625
|
-
* name: 'Dev Tools',
|
|
626
|
-
* description: 'Local dev utilities',
|
|
627
|
-
* tools: [grep],
|
|
628
|
-
* });
|
|
629
|
-
* ```
|
|
630
|
-
*/
|
|
631
|
-
/** Prefix applied by the backend to local tool slugs for disambiguation. */
|
|
632
|
-
const LOCAL_TOOL_PREFIX = "LOCAL_";
|
|
633
|
-
/** Maximum allowed length for the final prefixed slug. */
|
|
634
|
-
const MAX_SLUG_LENGTH = 60;
|
|
635
|
-
/**
|
|
636
|
-
* Compute the final slug length for a tool given its context.
|
|
637
|
-
* Returns the expected length of LOCAL_[TOOLKIT_]SLUG.
|
|
638
|
-
*/
|
|
639
|
-
function computeFinalSlugLength(toolSlug, toolkitSlug) {
|
|
640
|
-
return 6 + (toolkitSlug ? toolkitSlug.length + 1 : 0) + toolSlug.length;
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Validate that the final slug won't exceed the max length.
|
|
644
|
-
* Called early in createCustomTool/createCustomToolkit for fast feedback.
|
|
645
|
-
*/
|
|
646
|
-
function validateSlugLength(toolSlug, toolkitSlug, context) {
|
|
647
|
-
const finalLength = computeFinalSlugLength(toolSlug, toolkitSlug);
|
|
648
|
-
if (finalLength > MAX_SLUG_LENGTH) {
|
|
649
|
-
const prefix = LOCAL_TOOL_PREFIX + (toolkitSlug ? `${toolkitSlug.toUpperCase()}_` : "");
|
|
650
|
-
throw new ValidationError(`${context}: slug "${toolSlug}" is too long. With prefix "${prefix}", the final slug would be ${finalLength} characters (max ${MAX_SLUG_LENGTH}). Shorten the slug to at most ${MAX_SLUG_LENGTH - prefix.length} characters.`);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Create a custom tool for use in tool router sessions.
|
|
655
|
-
*
|
|
656
|
-
* The returned object is a lightweight reference containing the tool's metadata
|
|
657
|
-
* and execute function. Pass it to `composio.create(userId, { experimental: { customTools: [...] } })`
|
|
658
|
-
* to bind it to a session.
|
|
659
|
-
*
|
|
660
|
-
* Just return the result data from `execute`, or throw an error.
|
|
661
|
-
* The SDK wraps it into the standard response format internally.
|
|
662
|
-
*
|
|
663
|
-
* **Slug naming:** The slug you provide is automatically prefixed with `LOCAL_` when
|
|
664
|
-
* exposed to the agent (e.g. `'GREP'` becomes `LOCAL_GREP`). If the tool is inside a
|
|
665
|
-
* custom toolkit, the toolkit slug is also included (e.g. `LOCAL_DEV_TOOLS_GREP`).
|
|
666
|
-
* The `LOCAL_` prefix is reserved and cannot be used in your slug.
|
|
667
|
-
*
|
|
668
|
-
* @param slug - Unique tool identifier (alphanumeric, underscores, hyphens; no LOCAL_ or COMPOSIO_ prefix)
|
|
669
|
-
* @param options - Tool definition including name, schema, and execute function
|
|
670
|
-
* @returns A CustomTool to pass to session creation
|
|
671
|
-
*
|
|
672
|
-
* @example Standalone tool (no auth)
|
|
673
|
-
* ```typescript
|
|
674
|
-
* const grep = createCustomTool('GREP', {
|
|
675
|
-
* name: 'Grep Search',
|
|
676
|
-
* description: 'Search for patterns in files',
|
|
677
|
-
* inputParams: z.object({ pattern: z.string(), path: z.string() }),
|
|
678
|
-
* execute: async (input) => ({ matches: [] }),
|
|
679
|
-
* });
|
|
680
|
-
* ```
|
|
681
|
-
*
|
|
682
|
-
* @example Tool extending a Composio toolkit (inherits auth)
|
|
683
|
-
* ```typescript
|
|
684
|
-
* const getImportant = createCustomTool('GET_IMPORTANT_EMAILS', {
|
|
685
|
-
* name: 'Get Important Emails',
|
|
686
|
-
* description: 'Fetch high-priority emails',
|
|
687
|
-
* extendsToolkit: 'gmail',
|
|
688
|
-
* inputParams: z.object({ limit: z.number().default(10) }),
|
|
689
|
-
* execute: async (input, ctx) => {
|
|
690
|
-
* // Same response shape as session.execute(): { data, error, logId }
|
|
691
|
-
* const result = await ctx.execute('GMAIL_SEARCH', { query: 'is:important' });
|
|
692
|
-
* return { emails: result.data };
|
|
693
|
-
* },
|
|
694
|
-
* });
|
|
695
|
-
* ```
|
|
696
|
-
*/
|
|
697
|
-
function createCustomTool(slug, options) {
|
|
698
|
-
const slugResult = CustomToolSlugSchema.safeParse(slug);
|
|
699
|
-
if (!slugResult.success) throw new ValidationError(`createCustomTool: ${slugResult.error.issues[0].message}`, { cause: slugResult.error });
|
|
700
|
-
const validated = CreateCustomToolBaseSchema.parse(options);
|
|
701
|
-
if (!options.inputParams) throw new ValidationError("createCustomTool: inputParams is required");
|
|
702
|
-
if (options.inputParams?._def?.typeName !== "ZodObject") throw new ValidationError("createCustomTool: inputParams must be a z.object() schema. Tool input parameters are always an object with named properties.");
|
|
703
|
-
if (typeof options.execute !== "function") throw new ValidationError("createCustomTool: execute must be a function");
|
|
704
|
-
validateSlugLength(slug, validated.extendsToolkit, "createCustomTool");
|
|
705
|
-
const { inputParams, execute } = options;
|
|
706
|
-
const paramsSchemaJson = zod_to_json_schema.default(inputParams, { name: "input" }).definitions.input;
|
|
707
|
-
const inputSchema = {
|
|
708
|
-
type: "object",
|
|
709
|
-
properties: paramsSchemaJson.properties,
|
|
710
|
-
...paramsSchemaJson.required ? { required: paramsSchemaJson.required } : {}
|
|
711
|
-
};
|
|
712
|
-
let outputSchema;
|
|
713
|
-
if (options.outputParams) outputSchema = zod_to_json_schema.default(options.outputParams, { name: "output" }).definitions.output;
|
|
714
|
-
return {
|
|
715
|
-
slug: slugResult.data,
|
|
716
|
-
name: validated.name,
|
|
717
|
-
description: validated.description,
|
|
718
|
-
extendsToolkit: validated.extendsToolkit,
|
|
719
|
-
preload: validated.preload,
|
|
720
|
-
inputSchema,
|
|
721
|
-
outputSchema,
|
|
722
|
-
inputParams,
|
|
723
|
-
execute
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* Create a custom toolkit that groups related tools.
|
|
728
|
-
*
|
|
729
|
-
* Tools passed here must NOT have `extendsToolkit` set — they inherit the toolkit identity instead.
|
|
730
|
-
*
|
|
731
|
-
* **Slug naming:** The toolkit slug becomes part of the final tool slug exposed to the agent.
|
|
732
|
-
* For example, a toolkit `'DEV_TOOLS'` with a tool `'GREP'` produces `LOCAL_DEV_TOOLS_GREP`.
|
|
733
|
-
* The `LOCAL_` prefix is reserved and cannot be used in your slug.
|
|
734
|
-
*
|
|
735
|
-
* @param slug - Unique toolkit identifier (alphanumeric, underscores, hyphens; no LOCAL_ or COMPOSIO_ prefix)
|
|
736
|
-
* @param options - Toolkit definition including name, description, and tools
|
|
737
|
-
* @returns A CustomToolkit to pass to session creation
|
|
738
|
-
*
|
|
739
|
-
* @example
|
|
740
|
-
* ```typescript
|
|
741
|
-
* const devTools = createCustomToolkit('DEV_TOOLS', {
|
|
742
|
-
* name: 'Dev Tools',
|
|
743
|
-
* description: 'Local dev utilities',
|
|
744
|
-
* tools: [grepTool, sedTool],
|
|
745
|
-
* });
|
|
746
|
-
* ```
|
|
747
|
-
*/
|
|
748
|
-
function createCustomToolkit(slug, options) {
|
|
749
|
-
const slugResult = CustomToolSlugSchema.safeParse(slug);
|
|
750
|
-
if (!slugResult.success) throw new ValidationError(`createCustomToolkit: ${slugResult.error.issues[0].message}`, { cause: slugResult.error });
|
|
751
|
-
const validated = CreateCustomToolkitBaseSchema.parse(options);
|
|
752
|
-
if (!options.tools?.length) throw new ValidationError("createCustomToolkit: at least one tool is required");
|
|
753
|
-
for (const tool of options.tools) {
|
|
754
|
-
if (tool.extendsToolkit) throw new ValidationError(`createCustomToolkit: tool "${tool.slug}" has extendsToolkit set. Tools in a custom toolkit must not use extendsToolkit — they inherit the toolkit identity instead.`);
|
|
755
|
-
validateSlugLength(tool.slug, slug, `createCustomToolkit("${slug}")`);
|
|
756
|
-
}
|
|
757
|
-
return {
|
|
758
|
-
slug: slugResult.data,
|
|
759
|
-
name: validated.name,
|
|
760
|
-
description: validated.description,
|
|
761
|
-
preload: validated.preload,
|
|
762
|
-
tools: options.tools
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
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.
|
|
794
|
-
*
|
|
795
|
-
* @internal
|
|
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
|
|
800
|
-
*/
|
|
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;
|
|
850
|
-
return tools.map((handle) => ({
|
|
851
|
-
slug: handle.slug,
|
|
852
|
-
name: handle.name,
|
|
853
|
-
description: handle.description,
|
|
854
|
-
input_schema: handle.inputSchema,
|
|
855
|
-
...handle.outputSchema ? { output_schema: handle.outputSchema } : {},
|
|
856
|
-
...handle.extendsToolkit ? { extends_toolkit: handle.extendsToolkit } : {},
|
|
857
|
-
...preloadWireProperty(handle.preload, void 0, defaultPreload)
|
|
858
|
-
}));
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* Serialize custom toolkits into the format expected by the backend session creation API.
|
|
862
|
-
*
|
|
863
|
-
* @internal
|
|
864
|
-
* @param toolkits - The custom toolkits to serialize
|
|
865
|
-
* @returns Array of CustomToolkitDefinition for the API payload
|
|
866
|
-
*/
|
|
867
|
-
function serializeCustomToolkits(toolkits, options = {}) {
|
|
868
|
-
const defaultPreload = options.defaultPreload ?? false;
|
|
869
|
-
return toolkits.map((tk) => ({
|
|
870
|
-
slug: tk.slug,
|
|
871
|
-
name: tk.name,
|
|
872
|
-
description: tk.description,
|
|
873
|
-
...preloadWireProperty(tk.preload, void 0, defaultPreload),
|
|
874
|
-
tools: tk.tools.map((t) => ({
|
|
875
|
-
slug: t.slug,
|
|
876
|
-
name: t.name,
|
|
877
|
-
description: t.description,
|
|
878
|
-
input_schema: t.inputSchema,
|
|
879
|
-
...t.outputSchema ? { output_schema: t.outputSchema } : {},
|
|
880
|
-
...preloadWireProperty(t.preload, tk.preload, defaultPreload)
|
|
881
|
-
}))
|
|
882
|
-
}));
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* Build a CustomToolsMap using the slug/original_slug mapping from the session create response.
|
|
886
|
-
* This uses the backend's authoritative prefixed slugs instead of computing them client-side.
|
|
887
|
-
*
|
|
888
|
-
* @internal
|
|
889
|
-
* @param tools - The original custom tools passed to session creation
|
|
890
|
-
* @param toolkits - The original custom toolkits passed to session creation
|
|
891
|
-
* @param experimental - The experimental section from the session create response
|
|
892
|
-
* @returns Maps for O(1) lookup by both final and original slug
|
|
893
|
-
*/
|
|
894
|
-
function buildCustomToolsMapFromResponse(tools, toolkits, experimental) {
|
|
895
|
-
const byFinalSlug = /* @__PURE__ */ new Map();
|
|
896
|
-
const byOriginalSlug = /* @__PURE__ */ new Map();
|
|
897
|
-
const byToolkitAndOriginalSlug = /* @__PURE__ */ new Map();
|
|
898
|
-
const ambiguousOriginalSlugs = /* @__PURE__ */ new Set();
|
|
899
|
-
const handlesByQualifiedOriginalSlug = /* @__PURE__ */ new Map();
|
|
900
|
-
const handlesByOriginalSlug = /* @__PURE__ */ new Map();
|
|
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
|
-
};
|
|
921
|
-
const addEntry = (finalSlug, originalSlug, toolkit) => {
|
|
922
|
-
const resolvedToolkit = toolkit ?? void 0;
|
|
923
|
-
const match = findHandle(originalSlug, resolvedToolkit);
|
|
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.`);
|
|
927
|
-
const entry = {
|
|
928
|
-
handle: match.handle,
|
|
929
|
-
finalSlug,
|
|
930
|
-
toolkit: resolvedToolkit ?? match.toolkit
|
|
931
|
-
};
|
|
932
|
-
byFinalSlug.set(finalSlugKey, entry);
|
|
933
|
-
byToolkitAndOriginalSlug.set(qualifiedOriginalSlugKey(entry.toolkit, originalSlug), entry);
|
|
934
|
-
addOriginalSlugAlias({
|
|
935
|
-
byOriginalSlug,
|
|
936
|
-
ambiguousOriginalSlugs,
|
|
937
|
-
originalSlug,
|
|
938
|
-
entry
|
|
939
|
-
});
|
|
940
|
-
};
|
|
941
|
-
if (experimental?.custom_tools) for (const ct of experimental.custom_tools) addEntry(ct.slug, ct.original_slug, ct.extends_toolkit);
|
|
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);
|
|
943
|
-
return {
|
|
944
|
-
byFinalSlug,
|
|
945
|
-
byOriginalSlug,
|
|
946
|
-
byToolkitAndOriginalSlug,
|
|
947
|
-
...ambiguousOriginalSlugs.size ? { ambiguousOriginalSlugs } : {},
|
|
948
|
-
toolkits,
|
|
949
|
-
tools: tools.length ? tools : void 0
|
|
950
|
-
};
|
|
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
|
-
}
|
|
1004
|
-
|
|
1005
|
-
//#endregion
|
|
1006
|
-
Object.defineProperty(exports, 'AuthConfigErrorCodes', {
|
|
1007
|
-
enumerable: true,
|
|
1008
|
-
get: function () {
|
|
1009
|
-
return AuthConfigErrorCodes;
|
|
1010
|
-
}
|
|
1011
|
-
});
|
|
1012
|
-
Object.defineProperty(exports, 'ComposioAclOnlyForSharedError', {
|
|
1013
|
-
enumerable: true,
|
|
1014
|
-
get: function () {
|
|
1015
|
-
return ComposioAclOnlyForSharedError;
|
|
1016
|
-
}
|
|
1017
|
-
});
|
|
1018
|
-
Object.defineProperty(exports, 'ComposioAuthConfigNotFoundError', {
|
|
1019
|
-
enumerable: true,
|
|
1020
|
-
get: function () {
|
|
1021
|
-
return ComposioAuthConfigNotFoundError;
|
|
1022
|
-
}
|
|
1023
|
-
});
|
|
1024
|
-
Object.defineProperty(exports, 'ComposioConnectedAccountNotFoundError', {
|
|
1025
|
-
enumerable: true,
|
|
1026
|
-
get: function () {
|
|
1027
|
-
return ComposioConnectedAccountNotFoundError;
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
Object.defineProperty(exports, 'ComposioFailedToCreateConnectedAccountLink', {
|
|
1031
|
-
enumerable: true,
|
|
1032
|
-
get: function () {
|
|
1033
|
-
return ComposioFailedToCreateConnectedAccountLink;
|
|
1034
|
-
}
|
|
1035
|
-
});
|
|
1036
|
-
Object.defineProperty(exports, 'ComposioFailedToCreatePusherClientError', {
|
|
1037
|
-
enumerable: true,
|
|
1038
|
-
get: function () {
|
|
1039
|
-
return ComposioFailedToCreatePusherClientError;
|
|
1040
|
-
}
|
|
1041
|
-
});
|
|
1042
|
-
Object.defineProperty(exports, 'ComposioFailedToGetSDKRealtimeCredentialsError', {
|
|
1043
|
-
enumerable: true,
|
|
1044
|
-
get: function () {
|
|
1045
|
-
return ComposioFailedToGetSDKRealtimeCredentialsError;
|
|
1046
|
-
}
|
|
1047
|
-
});
|
|
1048
|
-
Object.defineProperty(exports, 'ComposioFailedToSubscribeToPusherChannelError', {
|
|
1049
|
-
enumerable: true,
|
|
1050
|
-
get: function () {
|
|
1051
|
-
return ComposioFailedToSubscribeToPusherChannelError;
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
Object.defineProperty(exports, 'ComposioFailedToUnsubscribeFromPusherChannelError', {
|
|
1055
|
-
enumerable: true,
|
|
1056
|
-
get: function () {
|
|
1057
|
-
return ComposioFailedToUnsubscribeFromPusherChannelError;
|
|
1058
|
-
}
|
|
1059
|
-
});
|
|
1060
|
-
Object.defineProperty(exports, 'ComposioGlobalExecuteToolFnNotSetError', {
|
|
1061
|
-
enumerable: true,
|
|
1062
|
-
get: function () {
|
|
1063
|
-
return ComposioGlobalExecuteToolFnNotSetError;
|
|
1064
|
-
}
|
|
1065
|
-
});
|
|
1066
|
-
Object.defineProperty(exports, 'ComposioInvalidExecuteFunctionError', {
|
|
1067
|
-
enumerable: true,
|
|
1068
|
-
get: function () {
|
|
1069
|
-
return ComposioInvalidExecuteFunctionError;
|
|
1070
|
-
}
|
|
1071
|
-
});
|
|
1072
|
-
Object.defineProperty(exports, 'ComposioInvalidModifierError', {
|
|
1073
|
-
enumerable: true,
|
|
1074
|
-
get: function () {
|
|
1075
|
-
return ComposioInvalidModifierError;
|
|
1076
|
-
}
|
|
1077
|
-
});
|
|
1078
|
-
Object.defineProperty(exports, 'ComposioInvalidToolArgumentsError', {
|
|
1079
|
-
enumerable: true,
|
|
1080
|
-
get: function () {
|
|
1081
|
-
return ComposioInvalidToolArgumentsError;
|
|
1082
|
-
}
|
|
1083
|
-
});
|
|
1084
|
-
Object.defineProperty(exports, 'ComposioLegacyConnectedAccountsEndpointRetiredError', {
|
|
1085
|
-
enumerable: true,
|
|
1086
|
-
get: function () {
|
|
1087
|
-
return ComposioLegacyConnectedAccountsEndpointRetiredError;
|
|
1088
|
-
}
|
|
1089
|
-
});
|
|
1090
|
-
Object.defineProperty(exports, 'ComposioMultipleConnectedAccountsError', {
|
|
1091
|
-
enumerable: true,
|
|
1092
|
-
get: function () {
|
|
1093
|
-
return ComposioMultipleConnectedAccountsError;
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
Object.defineProperty(exports, 'ComposioNoAPIKeyError', {
|
|
1097
|
-
enumerable: true,
|
|
1098
|
-
get: function () {
|
|
1099
|
-
return ComposioNoAPIKeyError;
|
|
1100
|
-
}
|
|
1101
|
-
});
|
|
1102
|
-
Object.defineProperty(exports, 'ComposioProviderNotDefinedError', {
|
|
1103
|
-
enumerable: true,
|
|
1104
|
-
get: function () {
|
|
1105
|
-
return ComposioProviderNotDefinedError;
|
|
1106
|
-
}
|
|
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
|
-
});
|
|
1120
|
-
Object.defineProperty(exports, 'ComposioToolExecutionError', {
|
|
1121
|
-
enumerable: true,
|
|
1122
|
-
get: function () {
|
|
1123
|
-
return ComposioToolExecutionError;
|
|
1124
|
-
}
|
|
1125
|
-
});
|
|
1126
|
-
Object.defineProperty(exports, 'ComposioToolNotFoundError', {
|
|
1127
|
-
enumerable: true,
|
|
1128
|
-
get: function () {
|
|
1129
|
-
return ComposioToolNotFoundError;
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
Object.defineProperty(exports, 'ComposioToolVersionRequiredError', {
|
|
1133
|
-
enumerable: true,
|
|
1134
|
-
get: function () {
|
|
1135
|
-
return ComposioToolVersionRequiredError;
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
1138
|
-
Object.defineProperty(exports, 'ComposioToolkitFetchError', {
|
|
1139
|
-
enumerable: true,
|
|
1140
|
-
get: function () {
|
|
1141
|
-
return ComposioToolkitFetchError;
|
|
1142
|
-
}
|
|
1143
|
-
});
|
|
1144
|
-
Object.defineProperty(exports, 'ComposioToolkitNotFoundError', {
|
|
1145
|
-
enumerable: true,
|
|
1146
|
-
get: function () {
|
|
1147
|
-
return ComposioToolkitNotFoundError;
|
|
1148
|
-
}
|
|
1149
|
-
});
|
|
1150
|
-
Object.defineProperty(exports, 'ComposioTriggerTypeNotFoundError', {
|
|
1151
|
-
enumerable: true,
|
|
1152
|
-
get: function () {
|
|
1153
|
-
return ComposioTriggerTypeNotFoundError;
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
Object.defineProperty(exports, 'ComposioWebhookPayloadError', {
|
|
1157
|
-
enumerable: true,
|
|
1158
|
-
get: function () {
|
|
1159
|
-
return ComposioWebhookPayloadError;
|
|
1160
|
-
}
|
|
1161
|
-
});
|
|
1162
|
-
Object.defineProperty(exports, 'ComposioWebhookSignatureVerificationError', {
|
|
1163
|
-
enumerable: true,
|
|
1164
|
-
get: function () {
|
|
1165
|
-
return ComposioWebhookSignatureVerificationError;
|
|
1166
|
-
}
|
|
1167
|
-
});
|
|
1168
|
-
Object.defineProperty(exports, 'ConnectedAccountErrorCodes', {
|
|
1169
|
-
enumerable: true,
|
|
1170
|
-
get: function () {
|
|
1171
|
-
return ConnectedAccountErrorCodes;
|
|
1172
|
-
}
|
|
1173
|
-
});
|
|
1174
|
-
Object.defineProperty(exports, 'ConnectionRequestErrorCodes', {
|
|
1175
|
-
enumerable: true,
|
|
1176
|
-
get: function () {
|
|
1177
|
-
return ConnectionRequestErrorCodes;
|
|
1178
|
-
}
|
|
1179
|
-
});
|
|
1180
|
-
Object.defineProperty(exports, 'ConnectionRequestFailedError', {
|
|
1181
|
-
enumerable: true,
|
|
1182
|
-
get: function () {
|
|
1183
|
-
return ConnectionRequestFailedError;
|
|
1184
|
-
}
|
|
1185
|
-
});
|
|
1186
|
-
Object.defineProperty(exports, 'ConnectionRequestTimeoutError', {
|
|
1187
|
-
enumerable: true,
|
|
1188
|
-
get: function () {
|
|
1189
|
-
return ConnectionRequestTimeoutError;
|
|
1190
|
-
}
|
|
1191
|
-
});
|
|
1192
|
-
Object.defineProperty(exports, 'CreateCustomToolBaseSchema', {
|
|
1193
|
-
enumerable: true,
|
|
1194
|
-
get: function () {
|
|
1195
|
-
return CreateCustomToolBaseSchema;
|
|
1196
|
-
}
|
|
1197
|
-
});
|
|
1198
|
-
Object.defineProperty(exports, 'CreateCustomToolkitBaseSchema', {
|
|
1199
|
-
enumerable: true,
|
|
1200
|
-
get: function () {
|
|
1201
|
-
return CreateCustomToolkitBaseSchema;
|
|
1202
|
-
}
|
|
1203
|
-
});
|
|
1204
|
-
Object.defineProperty(exports, 'CustomToolSlugSchema', {
|
|
1205
|
-
enumerable: true,
|
|
1206
|
-
get: function () {
|
|
1207
|
-
return CustomToolSlugSchema;
|
|
1208
|
-
}
|
|
1209
|
-
});
|
|
1210
|
-
Object.defineProperty(exports, 'JsonSchemaRefResolutionError', {
|
|
1211
|
-
enumerable: true,
|
|
1212
|
-
get: function () {
|
|
1213
|
-
return JsonSchemaRefResolutionError;
|
|
1214
|
-
}
|
|
1215
|
-
});
|
|
1216
|
-
Object.defineProperty(exports, 'JsonSchemaToZodError', {
|
|
1217
|
-
enumerable: true,
|
|
1218
|
-
get: function () {
|
|
1219
|
-
return JsonSchemaToZodError;
|
|
1220
|
-
}
|
|
1221
|
-
});
|
|
1222
|
-
Object.defineProperty(exports, 'PRELOAD_TOOLS_ALL', {
|
|
1223
|
-
enumerable: true,
|
|
1224
|
-
get: function () {
|
|
1225
|
-
return PRELOAD_TOOLS_ALL;
|
|
1226
|
-
}
|
|
1227
|
-
});
|
|
1228
|
-
Object.defineProperty(exports, 'RemoteFileDownloadError', {
|
|
1229
|
-
enumerable: true,
|
|
1230
|
-
get: function () {
|
|
1231
|
-
return RemoteFileDownloadError;
|
|
1232
|
-
}
|
|
1233
|
-
});
|
|
1234
|
-
Object.defineProperty(exports, 'RemoteFileErrorCodes', {
|
|
1235
|
-
enumerable: true,
|
|
1236
|
-
get: function () {
|
|
1237
|
-
return RemoteFileErrorCodes;
|
|
1238
|
-
}
|
|
1239
|
-
});
|
|
1240
|
-
Object.defineProperty(exports, 'SDKErrorCodes', {
|
|
1241
|
-
enumerable: true,
|
|
1242
|
-
get: function () {
|
|
1243
|
-
return SDKErrorCodes;
|
|
1244
|
-
}
|
|
1245
|
-
});
|
|
1246
|
-
Object.defineProperty(exports, 'ToolErrorCodes', {
|
|
1247
|
-
enumerable: true,
|
|
1248
|
-
get: function () {
|
|
1249
|
-
return ToolErrorCodes;
|
|
1250
|
-
}
|
|
1251
|
-
});
|
|
1252
|
-
Object.defineProperty(exports, 'ToolkitErrorCodes', {
|
|
1253
|
-
enumerable: true,
|
|
1254
|
-
get: function () {
|
|
1255
|
-
return ToolkitErrorCodes;
|
|
1256
|
-
}
|
|
1257
|
-
});
|
|
1258
|
-
Object.defineProperty(exports, 'TriggerErrorCodes', {
|
|
1259
|
-
enumerable: true,
|
|
1260
|
-
get: function () {
|
|
1261
|
-
return TriggerErrorCodes;
|
|
1262
|
-
}
|
|
1263
|
-
});
|
|
1264
|
-
Object.defineProperty(exports, 'ValidationError', {
|
|
1265
|
-
enumerable: true,
|
|
1266
|
-
get: function () {
|
|
1267
|
-
return ValidationError;
|
|
1268
|
-
}
|
|
1269
|
-
});
|
|
1270
|
-
Object.defineProperty(exports, 'ValidationErrorCodes', {
|
|
1271
|
-
enumerable: true,
|
|
1272
|
-
get: function () {
|
|
1273
|
-
return ValidationErrorCodes;
|
|
1274
|
-
}
|
|
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
|
-
});
|
|
1288
|
-
Object.defineProperty(exports, 'buildCustomToolsMapFromResponse', {
|
|
1289
|
-
enumerable: true,
|
|
1290
|
-
get: function () {
|
|
1291
|
-
return buildCustomToolsMapFromResponse;
|
|
1292
|
-
}
|
|
1293
|
-
});
|
|
1294
|
-
Object.defineProperty(exports, 'createCustomTool', {
|
|
1295
|
-
enumerable: true,
|
|
1296
|
-
get: function () {
|
|
1297
|
-
return createCustomTool;
|
|
1298
|
-
}
|
|
1299
|
-
});
|
|
1300
|
-
Object.defineProperty(exports, 'createCustomToolkit', {
|
|
1301
|
-
enumerable: true,
|
|
1302
|
-
get: function () {
|
|
1303
|
-
return createCustomToolkit;
|
|
1304
|
-
}
|
|
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
|
-
});
|
|
1324
|
-
Object.defineProperty(exports, 'handleToolExecutionError', {
|
|
1325
|
-
enumerable: true,
|
|
1326
|
-
get: function () {
|
|
1327
|
-
return handleToolExecutionError;
|
|
1328
|
-
}
|
|
1329
|
-
});
|
|
1330
|
-
Object.defineProperty(exports, 'serializeCustomToolkits', {
|
|
1331
|
-
enumerable: true,
|
|
1332
|
-
get: function () {
|
|
1333
|
-
return serializeCustomToolkits;
|
|
1334
|
-
}
|
|
1335
|
-
});
|
|
1336
|
-
Object.defineProperty(exports, 'serializeCustomTools', {
|
|
1337
|
-
enumerable: true,
|
|
1338
|
-
get: function () {
|
|
1339
|
-
return serializeCustomTools;
|
|
1340
|
-
}
|
|
1341
|
-
});
|