@composio/core 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CustomTool-DfP4ldQl.d.mts → CustomTool-DyypijT6.d.mts} +2 -2
- package/dist/{Telemetry-41JkqpZ7.mjs → Telemetry-D2PJwXKx.mjs} +1 -1
- package/dist/{composio-BMDH-1Qj.d.mts → composio-CwHMpKXb.d.mts} +748 -70
- package/dist/{customTool.types-BoOELgJF.d.mts → customTool.types-DoItUHkO.d.mts} +780 -23
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +3 -3
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +5 -4
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +5 -1
- package/dist/experimental/index.d.mts +2 -2
- package/dist/{fileUtils.node-DNLhLg0W.mjs → fileUtils.node-ILI1IjnZ.mjs} +4 -3
- package/dist/index.d.mts +10 -10
- package/dist/index.mjs +420 -158
- package/dist/models/Files.node.mjs +2 -2
- package/dist/sensitiveFileUploadPaths-BaEORC7-.mjs +588 -0
- package/dist/{types-DHNV_T_z.d.mts → types-DWZWePfZ.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +7 -6
- package/src/lib/toolRouterParams.ts +33 -15
- package/src/lib/toolRouterSessionDelete.ts +1 -10
- package/src/models/ConnectedAccounts.ts +1 -1
- package/src/models/CustomTool.ts +1 -1
- package/src/models/CustomToolkits.ts +114 -8
- package/src/models/Experimental.ts +1 -1
- package/src/models/MCP.ts +1 -2
- package/src/models/SessionConfigs.ts +11 -3
- package/src/models/SessionContext.ts +6 -21
- package/src/models/ToolRouter.ts +5 -1
- package/src/models/ToolRouterSession.ts +21 -35
- package/src/models/Tools.ts +3 -3
- package/src/models/Triggers.ts +12 -5
- package/src/models/inlineCustomToolsPayload.ts +3 -3
- package/src/models/proxyParamsTransform.ts +1 -1
- package/src/types/customTool.types.ts +13 -5
- package/src/types/customToolkits.types.ts +89 -9
- package/src/types/sessionConfigs.types.ts +21 -7
- package/src/types/toolRouter.types.ts +169 -17
- package/src/types/triggers.types.ts +14 -0
- package/src/utils/fileUtils.node.ts +5 -2
- package/src/utils/mime.ts +347 -1
- package/src/utils/transformers/connectedAccounts.ts +2 -7
- package/src/utils/transformers/customToolkits.ts +78 -9
- package/src/utils/transformers/sessionConfigs.ts +3 -3
- package/src/utils/transformers/toolRouterResponseTransform.ts +71 -5
- package/src/utils/transformers/toolkits.ts +7 -13
- package/src/utils/transformers/triggers.ts +28 -18
- package/dist/sensitiveFileUploadPaths-BlLp-Yo2.mjs +0 -189
|
@@ -39,9 +39,9 @@ import {
|
|
|
39
39
|
type ToolRouterSessionDeleteResponse,
|
|
40
40
|
} from '../types/toolRouter.types';
|
|
41
41
|
import {
|
|
42
|
-
assertNotInputRequired,
|
|
43
42
|
transformSearchResponse,
|
|
44
43
|
transformExecuteResponse,
|
|
44
|
+
transformProxyExecuteResponse,
|
|
45
45
|
} from '../utils/transformers/toolRouterResponseTransform';
|
|
46
46
|
import { SessionMetaToolOptions } from '../types/modifiers.types';
|
|
47
47
|
import { ConnectionRequest } from '../types/connectionRequest.types';
|
|
@@ -79,7 +79,7 @@ import type {
|
|
|
79
79
|
SessionPatchParams,
|
|
80
80
|
SessionPatchResponse,
|
|
81
81
|
SessionSearchParams,
|
|
82
|
-
} from '@composio/client/resources/tool-router/session
|
|
82
|
+
} from '@composio/client/resources/tool-router/session';
|
|
83
83
|
import { SessionProxyExecuteParamsSchema } from '../types/toolRouter.types';
|
|
84
84
|
import { SessionContextImpl } from './SessionContext';
|
|
85
85
|
import {
|
|
@@ -484,7 +484,7 @@ export class ToolRouterSession<
|
|
|
484
484
|
...(opts.callbackUrl !== undefined && { callback_url: opts.callbackUrl }),
|
|
485
485
|
...(opts.alias !== undefined && { alias: opts.alias }),
|
|
486
486
|
...(experimentalWire !== undefined && {
|
|
487
|
-
experimental: experimentalWire as SessionLinkParams
|
|
487
|
+
experimental: experimentalWire as NonNullable<SessionLinkParams['experimental']>,
|
|
488
488
|
}),
|
|
489
489
|
};
|
|
490
490
|
|
|
@@ -667,9 +667,9 @@ export class ToolRouterSession<
|
|
|
667
667
|
},
|
|
668
668
|
requestOptions?: ComposioRequestOptions
|
|
669
669
|
): Promise<ToolRouterSessionSearchResponse> {
|
|
670
|
-
const experimental = inlineCustomToolsExperimental<
|
|
671
|
-
|
|
672
|
-
);
|
|
670
|
+
const experimental = inlineCustomToolsExperimental<
|
|
671
|
+
NonNullable<SessionSearchParams['experimental']>
|
|
672
|
+
>(this.inlineCustomToolsPayload);
|
|
673
673
|
const searchParams = {
|
|
674
674
|
queries: [{ use_case: params.query }],
|
|
675
675
|
...(params.toolkits?.length ? { toolkits: params.toolkits } : {}),
|
|
@@ -697,7 +697,7 @@ export class ToolRouterSession<
|
|
|
697
697
|
* @param options.account - Account identifier for direct app tool execution. Accepted on every project: in multi-account sessions it picks the account; on single-account projects it must match one of the session's active connections for the toolkit. Helper/meta tools either ignore this top-level field or define their own account-selection fields.
|
|
698
698
|
* @param options.inputResponses - Experimental. The user's answers to an earlier `ComposioToolInputRequiredError`, keyed by the IDs in its `inputRequests`. Repeat the same call with them.
|
|
699
699
|
* @param options.requestState - Experimental. The `requestState` of that error, sent back unchanged.
|
|
700
|
-
* @returns The tool execution result
|
|
700
|
+
* @returns The tool execution result. `resultType: 'blocked'` means a session hook blocked the call; `error` then holds the hook's message
|
|
701
701
|
* @throws {ComposioToolInputRequiredError} If the tool needs input from the user (for example an approval) before it can run
|
|
702
702
|
*/
|
|
703
703
|
async execute(
|
|
@@ -738,9 +738,9 @@ export class ToolRouterSession<
|
|
|
738
738
|
if (options?.account) {
|
|
739
739
|
executeParams.account = options.account;
|
|
740
740
|
}
|
|
741
|
-
const experimental = inlineCustomToolsExperimental<
|
|
742
|
-
|
|
743
|
-
);
|
|
741
|
+
const experimental = inlineCustomToolsExperimental<
|
|
742
|
+
NonNullable<SessionExecuteParams['experimental']>
|
|
743
|
+
>(this.inlineCustomToolsPayload);
|
|
744
744
|
if (experimental) {
|
|
745
745
|
executeParams.experimental = experimental;
|
|
746
746
|
}
|
|
@@ -790,9 +790,9 @@ export class ToolRouterSession<
|
|
|
790
790
|
arguments: arguments_ ?? {},
|
|
791
791
|
...inputResponseParams(options),
|
|
792
792
|
};
|
|
793
|
-
const experimental = inlineCustomToolsExperimental<
|
|
794
|
-
|
|
795
|
-
);
|
|
793
|
+
const experimental = inlineCustomToolsExperimental<
|
|
794
|
+
NonNullable<SessionExecuteMetaParams['experimental']>
|
|
795
|
+
>(this.inlineCustomToolsPayload);
|
|
796
796
|
if (experimental) {
|
|
797
797
|
executeMetaParams.experimental = experimental;
|
|
798
798
|
}
|
|
@@ -815,7 +815,7 @@ export class ToolRouterSession<
|
|
|
815
815
|
* The backend resolves the connected account from the toolkit within the session.
|
|
816
816
|
*
|
|
817
817
|
* @param params - Proxy request parameters (toolkit, endpoint, method, body, headers/query params)
|
|
818
|
-
* @returns The proxied API response with status, data,
|
|
818
|
+
* @returns The proxied API response with status, data and headers (`resultType: 'completed'`), or `resultType: 'blocked'` with the hook's message when a session hook blocked the request
|
|
819
819
|
* @throws {ComposioToolInputRequiredError} If the call needs input from the user before it can run
|
|
820
820
|
*/
|
|
821
821
|
async proxyExecute(
|
|
@@ -838,25 +838,10 @@ export class ToolRouterSession<
|
|
|
838
838
|
requestOptions?.signal
|
|
839
839
|
);
|
|
840
840
|
|
|
841
|
-
|
|
841
|
+
return transformProxyExecuteResponse(
|
|
842
842
|
response,
|
|
843
843
|
`${validated.data.method} proxy call for toolkit ${validated.data.toolkit}`
|
|
844
844
|
);
|
|
845
|
-
return {
|
|
846
|
-
status: response.status,
|
|
847
|
-
data: response.data,
|
|
848
|
-
headers: response.headers,
|
|
849
|
-
...(response.binary_data
|
|
850
|
-
? {
|
|
851
|
-
binaryData: {
|
|
852
|
-
contentType: response.binary_data.content_type,
|
|
853
|
-
size: response.binary_data.size,
|
|
854
|
-
url: response.binary_data.url,
|
|
855
|
-
expiresAt: response.binary_data.expires_at,
|
|
856
|
-
},
|
|
857
|
-
}
|
|
858
|
-
: {}),
|
|
859
|
-
};
|
|
860
845
|
}
|
|
861
846
|
|
|
862
847
|
/**
|
|
@@ -911,8 +896,9 @@ export class ToolRouterSession<
|
|
|
911
896
|
() =>
|
|
912
897
|
this.client.toolRouter.session.patch(
|
|
913
898
|
this.sessionId,
|
|
914
|
-
//
|
|
915
|
-
// the
|
|
899
|
+
// `expected_config_version` and the nullable policy blocks are not in
|
|
900
|
+
// the spec until ComposioHQ/platform#13157 lands; the body is
|
|
901
|
+
// serialized as-is.
|
|
916
902
|
body as SessionPatchParams,
|
|
917
903
|
{ ...requestOptions, maxRetries: 0 }
|
|
918
904
|
),
|
|
@@ -1025,9 +1011,9 @@ export class ToolRouterSession<
|
|
|
1025
1011
|
tool?: Tool
|
|
1026
1012
|
): Promise<ToolExecuteResponse> {
|
|
1027
1013
|
const body = { sessionId: this.sessionId, arguments: input };
|
|
1028
|
-
const experimental = inlineCustomToolsExperimental<
|
|
1029
|
-
|
|
1030
|
-
);
|
|
1014
|
+
const experimental = inlineCustomToolsExperimental<
|
|
1015
|
+
NonNullable<SessionExecuteParams['experimental']>
|
|
1016
|
+
>(this.inlineCustomToolsPayload);
|
|
1031
1017
|
if (experimental) {
|
|
1032
1018
|
return ToolsModel.executeSessionTool(toolSlug, body, modifiers, tool, { experimental });
|
|
1033
1019
|
}
|
package/src/models/Tools.ts
CHANGED
|
@@ -52,7 +52,7 @@ import { telemetry } from '../telemetry/Telemetry';
|
|
|
52
52
|
import type { ComposioConfig } from '../composio';
|
|
53
53
|
import { getToolkitVersion } from '../utils/toolkitVersion';
|
|
54
54
|
import { handleToolExecutionError } from '../errors/ToolErrors';
|
|
55
|
-
import type { SessionExecuteParams } from '@composio/client/resources/tool-router/session
|
|
55
|
+
import type { SessionExecuteParams } from '@composio/client/resources/tool-router/session';
|
|
56
56
|
import { CONFIG_DEFAULTS } from '../utils/config-defaults';
|
|
57
57
|
import { resolveEffectiveUploadAllowlist } from '../utils/fileDirs';
|
|
58
58
|
import {
|
|
@@ -72,7 +72,7 @@ import { ComposioRequestCancelledError } from '../errors/SDKErrors';
|
|
|
72
72
|
const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
|
|
73
73
|
|
|
74
74
|
type ToolRouterSessionExecuteOptions = {
|
|
75
|
-
experimental?: SessionExecuteParams
|
|
75
|
+
experimental?: NonNullable<SessionExecuteParams['experimental']>;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
type RawToolParameters =
|
|
@@ -1362,7 +1362,7 @@ export class Tools<
|
|
|
1362
1362
|
}
|
|
1363
1363
|
// convert the headers and query to the composio format
|
|
1364
1364
|
// { name: string, type: 'header' | 'query', value: string }
|
|
1365
|
-
const parameters: ComposioToolProxyParams
|
|
1365
|
+
const parameters: NonNullable<ComposioToolProxyParams['parameters']>[number][] = [];
|
|
1366
1366
|
const parameterTypes = {
|
|
1367
1367
|
header: 'header',
|
|
1368
1368
|
query: 'query',
|
package/src/models/Triggers.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import ComposioClient, { APIError } from '@composio/client';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type TriggerInstanceUpsertParams as ClientTriggerInstanceUpsertParams,
|
|
5
|
-
} from '@composio/client/resources/index';
|
|
2
|
+
import type { TriggerInstanceUpsertParams as ClientTriggerInstanceUpsertParams } from '@composio/client/resources/trigger-instances';
|
|
3
|
+
import { TriggersTypeRetrieveEnumResponse } from '@composio/client/resources/triggers-types';
|
|
6
4
|
import {
|
|
7
5
|
TriggerInstanceUpsertResponse,
|
|
8
6
|
TriggerInstanceUpsertParamsSchema,
|
|
@@ -238,10 +236,14 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
|
|
|
238
236
|
* Create a new trigger instance for a user
|
|
239
237
|
* If the connected account id is not provided, the first connected account for the user and toolkit will be used
|
|
240
238
|
*
|
|
239
|
+
* For a trigger that supports both webhook and polling, `body.type` picks one; omit it to let Composio choose.
|
|
240
|
+
* `body.pollingInterval` sets the minutes between polls and wins over `triggerConfig.interval`.
|
|
241
|
+
*
|
|
241
242
|
* @param {string} userId - The user id of the trigger instance
|
|
242
243
|
* @param {string} slug - The slug of the trigger instance
|
|
243
244
|
* @param {TriggerInstanceUpsertParams} body - The parameters to create the trigger instance
|
|
244
|
-
* @returns {Promise<TriggerInstanceUpsertResponse>} The
|
|
245
|
+
* @returns {Promise<TriggerInstanceUpsertResponse>} The trigger instance, with the type it uses, why it polls
|
|
246
|
+
* when it fell back from a webhook, and its polling interval
|
|
245
247
|
*/
|
|
246
248
|
async create(
|
|
247
249
|
userId: string,
|
|
@@ -288,6 +290,8 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
|
|
|
288
290
|
const upsertParams: ClientTriggerInstanceUpsertParams = {
|
|
289
291
|
connected_account_id: parsedBody.data.connectedAccountId,
|
|
290
292
|
trigger_config: parsedBody.data.triggerConfig,
|
|
293
|
+
type: parsedBody.data.type,
|
|
294
|
+
polling_interval: parsedBody.data.pollingInterval,
|
|
291
295
|
toolkit_versions: this.toolkitVersions,
|
|
292
296
|
user_id: userId,
|
|
293
297
|
};
|
|
@@ -298,6 +302,9 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
|
|
|
298
302
|
|
|
299
303
|
return {
|
|
300
304
|
triggerId: result.trigger_id,
|
|
305
|
+
type: result.type,
|
|
306
|
+
fallbackReason: result.fallback_reason,
|
|
307
|
+
pollingInterval: result.polling_interval,
|
|
301
308
|
};
|
|
302
309
|
}
|
|
303
310
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
SessionExecuteParams,
|
|
3
3
|
SessionSearchParams,
|
|
4
|
-
} from '@composio/client/resources/tool-router/session
|
|
4
|
+
} from '@composio/client/resources/tool-router/session';
|
|
5
5
|
import type { InlineCustomToolsWirePayload } from '../types/customTool.types';
|
|
6
6
|
|
|
7
7
|
type InlineCustomToolsExperimental =
|
|
8
|
-
| SessionExecuteParams
|
|
9
|
-
| SessionSearchParams
|
|
8
|
+
| NonNullable<SessionExecuteParams['experimental']>
|
|
9
|
+
| NonNullable<SessionSearchParams['experimental']>;
|
|
10
10
|
|
|
11
11
|
export function inlineCustomToolsExperimental<TExperimental extends InlineCustomToolsExperimental>(
|
|
12
12
|
payload?: InlineCustomToolsWirePayload
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* to the official @composio/client proxy execute params.
|
|
4
4
|
*/
|
|
5
5
|
import type { SessionProxyExecuteParams } from '../types/toolRouter.types';
|
|
6
|
-
import type { SessionProxyExecuteParams as ClientProxyExecuteParams } from '@composio/client/resources/tool-router/session
|
|
6
|
+
import type { SessionProxyExecuteParams as ClientProxyExecuteParams } from '@composio/client/resources/tool-router/session';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Transform SDK session proxy params to the official client request format.
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
import type {
|
|
9
9
|
SessionCreateParams,
|
|
10
10
|
SessionCreateResponse,
|
|
11
|
-
} from '@composio/client/resources/tool-router/session
|
|
11
|
+
} from '@composio/client/resources/tool-router/session';
|
|
12
12
|
|
|
13
13
|
export type AnyZodSchema = z.ZodType | z4.ZodType;
|
|
14
14
|
export type InferZodSchema<T extends AnyZodSchema> = T extends z.ZodType
|
|
@@ -142,7 +142,9 @@ export interface CustomTool {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/** Serialized tool definition sent to backend for search indexing. Uses official client type. */
|
|
145
|
-
export type CustomToolDefinition =
|
|
145
|
+
export type CustomToolDefinition = NonNullable<
|
|
146
|
+
NonNullable<SessionCreateParams['experimental']>['custom_tools']
|
|
147
|
+
>[number];
|
|
146
148
|
|
|
147
149
|
export type CustomToolWireDefinition = CustomToolDefinition;
|
|
148
150
|
|
|
@@ -188,7 +190,9 @@ export interface CustomToolkit {
|
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
/** Serialized toolkit definition sent to backend. Uses official client type. */
|
|
191
|
-
export type CustomToolkitDefinition =
|
|
193
|
+
export type CustomToolkitDefinition = NonNullable<
|
|
194
|
+
NonNullable<NonNullable<SessionCreateParams['experimental']>['custom_toolkits']>[number]
|
|
195
|
+
>;
|
|
192
196
|
|
|
193
197
|
export type CustomToolkitWireDefinition = CustomToolkitDefinition;
|
|
194
198
|
|
|
@@ -255,7 +259,11 @@ export interface RegisteredCustomToolkit {
|
|
|
255
259
|
// ────────────────────────────────────────────────────────────────
|
|
256
260
|
|
|
257
261
|
/** Custom tool as returned in the session create response (has prefixed slug + original_slug). */
|
|
258
|
-
export type CustomToolResponse =
|
|
262
|
+
export type CustomToolResponse = NonNullable<
|
|
263
|
+
NonNullable<SessionCreateResponse['experimental']>['custom_tools']
|
|
264
|
+
>[number];
|
|
259
265
|
|
|
260
266
|
/** Custom toolkit as returned in the session create response (has prefixed slugs + original_slugs). */
|
|
261
|
-
export type CustomToolkitResponse =
|
|
267
|
+
export type CustomToolkitResponse = NonNullable<
|
|
268
|
+
NonNullable<NonNullable<SessionCreateResponse['experimental']>['custom_toolkits']>[number]
|
|
269
|
+
>;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod/v3';
|
|
2
2
|
|
|
3
|
+
const CustomToolkitApiKeyFieldSchema = z.object({
|
|
4
|
+
displayName: z.string().min(1).max(100).optional(),
|
|
5
|
+
description: z.string().min(1).max(500).optional(),
|
|
6
|
+
});
|
|
7
|
+
export type CustomToolkitApiKeyField = z.infer<typeof CustomToolkitApiKeyFieldSchema>;
|
|
8
|
+
|
|
3
9
|
/**
|
|
4
10
|
* How end users authenticate to a custom toolkit.
|
|
5
11
|
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
@@ -15,10 +21,14 @@ export const CustomToolkitAuthSchemeSchema = z.discriminatedUnion('mode', [
|
|
|
15
21
|
*/
|
|
16
22
|
headers: z.record(z.string(), z.string()),
|
|
17
23
|
/** End-user copy for the API key input on the connect page. */
|
|
18
|
-
apiKeyField:
|
|
24
|
+
apiKeyField: CustomToolkitApiKeyFieldSchema.optional(),
|
|
25
|
+
/** Additional connect-page input used by `{{generic_id}}` in headers. */
|
|
26
|
+
additionalFields: z
|
|
19
27
|
.object({
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
genericId: z.object({
|
|
29
|
+
displayName: z.string().min(1).max(100),
|
|
30
|
+
description: z.string().min(1).max(500).optional(),
|
|
31
|
+
}),
|
|
22
32
|
})
|
|
23
33
|
.optional(),
|
|
24
34
|
}),
|
|
@@ -33,9 +43,84 @@ export const CustomToolkitAuthSchemeSchema = z.discriminatedUnion('mode', [
|
|
|
33
43
|
]);
|
|
34
44
|
export type CustomToolkitAuthScheme = z.infer<typeof CustomToolkitAuthSchemeSchema>;
|
|
35
45
|
|
|
46
|
+
const CustomToolkitLogoFileSchema = z.object({
|
|
47
|
+
content: z.string().min(1),
|
|
48
|
+
mimeType: z.enum(['image/png', 'image/jpeg']),
|
|
49
|
+
});
|
|
50
|
+
export type CustomToolkitLogoFile = z.infer<typeof CustomToolkitLogoFileSchema>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Params for `composio.experimental.customToolkits.create()`.
|
|
54
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
55
|
+
*/
|
|
56
|
+
export const CustomToolkitCreateParamsSchema = z.object({
|
|
57
|
+
/** Human-readable toolkit name. */
|
|
58
|
+
name: z.string().min(1).max(200),
|
|
59
|
+
/** The MCP server URL. Must use https. */
|
|
60
|
+
appUrl: z.string().url(),
|
|
61
|
+
/** Square PNG or JPEG logo (256-1024px, max 3MB), base64-encoded. Defaults to the MCP logo. */
|
|
62
|
+
logoFile: CustomToolkitLogoFileSchema.optional(),
|
|
63
|
+
/** At least one scheme. Cannot be changed after create. */
|
|
64
|
+
authSchemes: z.array(CustomToolkitAuthSchemeSchema).min(1),
|
|
65
|
+
/**
|
|
66
|
+
* `'all'` to share the toolkit with every user in the project, or a user ID
|
|
67
|
+
* to make it private to that user. Cannot be changed after create.
|
|
68
|
+
*/
|
|
69
|
+
userId: z.string().min(1),
|
|
70
|
+
/** Where to send the user after they connect. Used only for `connectLink`. */
|
|
71
|
+
callbackUrl: z.string().url().optional(),
|
|
72
|
+
});
|
|
73
|
+
export type CustomToolkitCreateParams = z.infer<typeof CustomToolkitCreateParamsSchema>;
|
|
74
|
+
|
|
75
|
+
export const CustomToolkitCreateResponseSchema = z.object({
|
|
76
|
+
/** Slug of the created toolkit. Store it to update, sync or delete the toolkit later. */
|
|
77
|
+
slug: z.string(),
|
|
78
|
+
/**
|
|
79
|
+
* Hosted connect page for a private toolkit's user. `null` for shared or
|
|
80
|
+
* no-auth toolkits, or if the link could not be created.
|
|
81
|
+
*/
|
|
82
|
+
connectLink: z
|
|
83
|
+
.object({
|
|
84
|
+
redirectUrl: z.string(),
|
|
85
|
+
expiresAt: z.string(),
|
|
86
|
+
connectedAccountId: z.string(),
|
|
87
|
+
})
|
|
88
|
+
.nullable(),
|
|
89
|
+
});
|
|
90
|
+
export type CustomToolkitCreateResponse = z.infer<typeof CustomToolkitCreateResponseSchema>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Params for `composio.experimental.customToolkits.update()`.
|
|
94
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
95
|
+
*/
|
|
96
|
+
export const CustomToolkitUpdateParamsSchema = z
|
|
97
|
+
.object({
|
|
98
|
+
name: z.string().min(1).max(200).optional(),
|
|
99
|
+
logoFile: CustomToolkitLogoFileSchema.optional(),
|
|
100
|
+
/** End-user copy for the API key input on the connect page. API_KEY toolkits only. */
|
|
101
|
+
apiKeyField: CustomToolkitApiKeyFieldSchema.optional(),
|
|
102
|
+
/**
|
|
103
|
+
* The user the toolkit is private to. Required to update a private toolkit
|
|
104
|
+
* when the project has 2FA enabled.
|
|
105
|
+
*/
|
|
106
|
+
userId: z.string().min(1).optional(),
|
|
107
|
+
})
|
|
108
|
+
.refine(
|
|
109
|
+
params => [params.name, params.logoFile, params.apiKeyField].some(value => value !== undefined),
|
|
110
|
+
{ message: 'Provide at least one of name, logoFile, apiKeyField' }
|
|
111
|
+
);
|
|
112
|
+
export type CustomToolkitUpdateParams = z.infer<typeof CustomToolkitUpdateParamsSchema>;
|
|
113
|
+
|
|
114
|
+
export const CustomToolkitUpdateResponseSchema = z.object({
|
|
115
|
+
success: z.literal(true),
|
|
116
|
+
});
|
|
117
|
+
export type CustomToolkitUpdateResponse = z.infer<typeof CustomToolkitUpdateResponseSchema>;
|
|
118
|
+
|
|
36
119
|
/**
|
|
37
120
|
* Params for `composio.experimental.customToolkits.upsert()`.
|
|
38
121
|
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
122
|
+
*
|
|
123
|
+
* @deprecated Use `CustomToolkitCreateParams` with `create()`.
|
|
39
124
|
*/
|
|
40
125
|
export const CustomToolkitUpsertParamsSchema = z.object({
|
|
41
126
|
/**
|
|
@@ -53,12 +138,7 @@ export const CustomToolkitUpsertParamsSchema = z.object({
|
|
|
53
138
|
/** The app URL. For an MCP app, the MCP server URL. */
|
|
54
139
|
appUrl: z.string().url(),
|
|
55
140
|
/** Square PNG or JPEG logo (256-1024px, max 3MB), base64-encoded. Defaults to the Composio logo. */
|
|
56
|
-
logoFile:
|
|
57
|
-
.object({
|
|
58
|
-
content: z.string().min(1),
|
|
59
|
-
mimeType: z.enum(['image/png', 'image/jpeg']),
|
|
60
|
-
})
|
|
61
|
-
.optional(),
|
|
141
|
+
logoFile: CustomToolkitLogoFileSchema.optional(),
|
|
62
142
|
/** At least one scheme. The schemes cannot change once the toolkit exists. */
|
|
63
143
|
authSchemes: z.array(CustomToolkitAuthSchemeSchema).min(1),
|
|
64
144
|
}),
|
|
@@ -6,7 +6,10 @@ import { ToolRouterTagsParamSchema } from './toolRouter.types';
|
|
|
6
6
|
* active configs only, 20 per page, at most 100.
|
|
7
7
|
*/
|
|
8
8
|
export const SessionConfigListParamsSchema = z.object({
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated The Composio API no longer accepts this field. It is ignored
|
|
11
|
+
* and `list()` logs a warning when it is set; filter `items` by name instead.
|
|
12
|
+
*/
|
|
10
13
|
search: z.string().optional(),
|
|
11
14
|
/** `true` returns only archived configs. Omitted returns active configs. */
|
|
12
15
|
archived: z.boolean().optional(),
|
|
@@ -43,25 +46,36 @@ export type SessionConfigListResponse = z.infer<typeof SessionConfigListResponse
|
|
|
43
46
|
const SessionConfigTagPolicySchema = z.object({
|
|
44
47
|
enable: z.array(ToolRouterTagsParamSchema.element).optional(),
|
|
45
48
|
disable: z.array(ToolRouterTagsParamSchema.element).optional(),
|
|
49
|
+
/** Tags whose tools need the user's approval before they run. */
|
|
50
|
+
require_approval: z.array(ToolRouterTagsParamSchema.element).optional(),
|
|
46
51
|
});
|
|
47
52
|
|
|
53
|
+
/** What in a policy entry needs the user's approval before it runs. */
|
|
54
|
+
const requireApproval = { require_approval: z.array(z.string()).optional() };
|
|
55
|
+
const ApprovalOnlyPolicySchema = z.object({ require_approval: z.array(z.string()) });
|
|
56
|
+
|
|
48
57
|
/**
|
|
49
58
|
* The access policy stored in a saved Session config, in the backend's
|
|
50
|
-
* `enable`/`disable` shape. Toolkit slug keys and tag names
|
|
51
|
-
* as the backend sends them.
|
|
59
|
+
* `enable`/`disable`/`require_approval` shape. Toolkit slug keys and tag names
|
|
60
|
+
* are kept exactly as the backend sends them.
|
|
52
61
|
*/
|
|
53
62
|
export const SessionConfigPolicySchema = z.object({
|
|
54
63
|
toolkits: z
|
|
55
|
-
.union([
|
|
64
|
+
.union([
|
|
65
|
+
z.object({ enable: z.array(z.string()), ...requireApproval }),
|
|
66
|
+
z.object({ disable: z.array(z.string()), ...requireApproval }),
|
|
67
|
+
ApprovalOnlyPolicySchema,
|
|
68
|
+
])
|
|
56
69
|
.optional(),
|
|
57
70
|
/** Per-toolkit tool policy, keyed by toolkit slug. */
|
|
58
71
|
tools: z
|
|
59
72
|
.record(
|
|
60
73
|
z.string(),
|
|
61
74
|
z.union([
|
|
62
|
-
z.object({ enable: z.array(z.string()) }),
|
|
63
|
-
z.object({ disable: z.array(z.string()) }),
|
|
64
|
-
z.object({ tags: SessionConfigTagPolicySchema }),
|
|
75
|
+
z.object({ enable: z.array(z.string()), ...requireApproval }),
|
|
76
|
+
z.object({ disable: z.array(z.string()), ...requireApproval }),
|
|
77
|
+
z.object({ tags: SessionConfigTagPolicySchema, ...requireApproval }),
|
|
78
|
+
ApprovalOnlyPolicySchema,
|
|
65
79
|
])
|
|
66
80
|
)
|
|
67
81
|
.optional(),
|