@composio/core 0.11.0 → 0.13.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-BBnsv9kS.d.mts +29425 -0
- package/dist/{BaseProvider-CVbQxTNa.d.cts → BaseProvider-Brb3o86-.d.mts} +91 -44
- package/dist/CustomTool-D9qwyMrv.mjs +468 -0
- package/dist/{CustomTool-C-IUByoU.d.cts → CustomTool-Dmi6ti3I.d.mts} +2 -4
- package/dist/{CustomTool-CChQSp44.d.mts → CustomTool-DrJpOhY2.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-DHIKRdeG.d.mts} +641 -380
- package/dist/{composio-BlASKqjQ.d.mts → composio-vMwhASRc.d.mts} +1390 -1129
- package/dist/{customTool.types-QtkAZQma.d.cts → customTool.types-CKH2R2ia.d.mts} +487 -189
- package/dist/{customTool.types-DLIORcYN.d.mts → customTool.types-DXin7Cfc.d.mts} +924 -626
- package/dist/docs/error-consistency.md +97 -0
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +306 -0
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +205 -0
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +488 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +94 -0
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +67 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +304 -0
- package/dist/docs/reference/sdk-reference/typescript/meta.json +17 -0
- package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +107 -0
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +163 -0
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +229 -0
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +131 -0
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +169 -0
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +453 -0
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +434 -0
- package/dist/{CustomTool-D5s-aADw.mjs → errors-DSIlYfl5.mjs} +72 -459
- 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 +1708 -2400
- package/dist/index.mjs +2632 -2006
- package/dist/jsonSchema-CFKdONpP.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-D4Id3wXA.d.mts} +2 -3
- package/dist/{types-DRG5qLxI.d.cts → types-qTbYYBJw.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/docs/error-consistency.md +97 -0
- package/package.json +40 -88
- package/src/composio.ts +509 -0
- package/src/errors/AuthConfigErrors.ts +23 -0
- package/src/errors/ComposioError.ts +408 -0
- package/src/errors/ConnectedAccountsErrors.ts +158 -0
- package/src/errors/ConnectionRequestErrors.ts +32 -0
- package/src/errors/FileModifierErrors.ts +100 -0
- package/src/errors/PusherErrors.ts +28 -0
- package/src/errors/RemoteFileErrors.ts +62 -0
- package/src/errors/SDKErrors.ts +92 -0
- package/src/errors/ToolErrors.ts +244 -0
- package/src/errors/ToolkitErrors.ts +39 -0
- package/src/errors/TriggerErrors.ts +120 -0
- package/src/errors/ValidationErrors.ts +99 -0
- package/src/errors/index.ts +41 -0
- package/src/experimental/index.ts +28 -0
- package/src/index.ts +64 -0
- package/src/lib/toolRouterConstants.ts +1 -0
- package/src/lib/toolRouterParams.ts +306 -0
- package/src/models/AuthConfigs.ts +398 -0
- package/src/models/AuthScheme.ts +206 -0
- package/src/models/ConnectedAccounts.ts +735 -0
- package/src/models/ConnectionRequest.ts +150 -0
- package/src/models/CustomTool.ts +676 -0
- package/src/models/Experimental.ts +202 -0
- package/src/models/Files.node.ts +93 -0
- package/src/models/Files.workerd.ts +49 -0
- package/src/models/MCP.ts +478 -0
- package/src/models/RemoteFile.ts +172 -0
- package/src/models/SessionContext.ts +147 -0
- package/src/models/Sessions.ts +21 -0
- package/src/models/ToolRouter.ts +391 -0
- package/src/models/ToolRouterSession.ts +827 -0
- package/src/models/ToolRouterSessionFileMount.ts +389 -0
- package/src/models/Toolkits.ts +412 -0
- package/src/models/Tools.ts +1260 -0
- package/src/models/Triggers.ts +1381 -0
- package/src/models/customToolExecution.ts +118 -0
- package/src/models/inlineCustomToolsPayload.ts +17 -0
- package/src/models/proxyParamsTransform.ts +26 -0
- package/src/provider/BaseProvider.ts +138 -0
- package/src/provider/ComposioProvider.ts +29 -0
- package/src/provider/OpenAIProvider.ts +547 -0
- package/src/services/internal/InternalService.ts +50 -0
- package/src/services/internal/InternalService.types.ts +14 -0
- package/src/services/pusher/Pusher.ts +230 -0
- package/src/services/telemetry/TelemetryService.ts +48 -0
- package/src/services/telemetry/TelemetryService.types.ts +67 -0
- package/src/telemetry/BatchProcessor.ts +77 -0
- package/src/telemetry/README.md +123 -0
- package/src/telemetry/Telemetry.ts +356 -0
- package/src/types/ToolRouterSessionFilesMount.types.ts +96 -0
- package/src/types/authConfigs.types.ts +174 -0
- package/src/types/composio.types.ts +1 -0
- package/src/types/connectedAccountAuthStates.types.ts +852 -0
- package/src/types/connectedAccounts.types.ts +395 -0
- package/src/types/connectionRequest.types.ts +16 -0
- package/src/types/customTool.types.ts +261 -0
- package/{dist/files.types-lo4zZd87.d.cts → src/types/files.types.ts} +3 -5
- package/src/types/mcp.experimental.types.ts +163 -0
- package/src/types/mcp.types.ts +362 -0
- package/src/types/modifiers.types.ts +663 -0
- package/src/types/org.types.ts +0 -0
- package/src/types/provider.types.ts +41 -0
- package/src/types/pusher.types.ts +18 -0
- package/src/types/requestOptions.types.ts +62 -0
- package/src/types/telemetry.types.ts +89 -0
- package/src/types/tool.types.ts +408 -0
- package/src/types/toolRouter.types.ts +761 -0
- package/src/types/toolkit.types.ts +130 -0
- package/src/types/triggers.types.ts +401 -0
- package/src/types/webhookEvents.types.ts +219 -0
- package/src/utils/buffer.ts +30 -0
- package/src/utils/cancellation.ts +22 -0
- package/src/utils/config-defaults/ConfigDefaults.node.ts +7 -0
- package/src/utils/config-defaults/ConfigDefaults.workerd.ts +10 -0
- package/src/utils/config-defaults/index.ts +1 -0
- package/src/utils/config-defaults/types.ts +14 -0
- package/src/utils/constants.ts +22 -0
- package/src/utils/crypto.ts +34 -0
- package/src/utils/env.ts +34 -0
- package/src/utils/fileDirs.ts +81 -0
- package/src/utils/fileUtils.node.ts +458 -0
- package/src/utils/json-schema.ts +1 -0
- package/src/utils/jsonSchema.ts +355 -0
- package/src/utils/logger.ts +99 -0
- package/src/utils/mime.ts +75 -0
- package/src/utils/modifiers/FileToolModifier.node.ts +477 -0
- package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +132 -0
- package/src/utils/modifiers/FileToolModifier.workerd.ts +51 -0
- package/src/utils/pagination.ts +73 -0
- package/src/utils/pusher.ts +286 -0
- package/src/utils/schemaPropertyKeys.ts +433 -0
- package/src/utils/sdk.ts +110 -0
- package/src/utils/sensitiveFileUploadPaths.node.ts +105 -0
- package/src/utils/session.ts +114 -0
- package/src/utils/toolArguments.ts +73 -0
- package/src/utils/toolkitVersion.ts +26 -0
- package/src/utils/transform.ts +42 -0
- package/src/utils/transformers/authConfigs.ts +107 -0
- package/src/utils/transformers/connectedAccounts.ts +119 -0
- package/src/utils/transformers/mcp.ts +164 -0
- package/src/utils/transformers/toolRouterResponseTransform.ts +160 -0
- package/src/utils/transformers/toolkits.ts +100 -0
- package/src/utils/transformers/triggers.ts +118 -0
- package/src/utils/uploadDirAllowlist.node.ts +178 -0
- package/src/utils/uuid.ts +7 -0
- package/src/utils/version.ts +58 -0
- package/src/utils/zodSchema.ts +90 -0
- package/dist/BaseProvider-BvHvJLXc.d.mts +0 -29378
- 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/experimental/index.cjs +0 -5
- package/dist/experimental/index.d.cts +0 -3
- package/dist/fileUtils.node-DtnSRMWa.cjs +0 -462
- 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-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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface PusherClient {
|
|
2
|
+
subscribe: (channelName: string) => PusherChannel;
|
|
3
|
+
unsubscribe: (channelName: string) => void;
|
|
4
|
+
bind: (event: string, callback: (data: Record<string, unknown>) => void) => void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface PusherChannel {
|
|
8
|
+
subscribe: (channelName: string) => unknown;
|
|
9
|
+
unsubscribe: (channelName: string) => void;
|
|
10
|
+
bind: (event: string, callback: (data: Record<string, unknown>) => void) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type TChunkedTriggerData = {
|
|
14
|
+
id: string;
|
|
15
|
+
index: number;
|
|
16
|
+
chunk: string;
|
|
17
|
+
final: boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type ComposioClient from '@composio/client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Per-request transport options for cancelling an SDK call.
|
|
5
|
+
*
|
|
6
|
+
* For `tools.get` and `tools.execute`, pass `signal` directly in the
|
|
7
|
+
* options bag (3rd argument) alongside any modifiers or provider options.
|
|
8
|
+
* For other methods (e.g. `toolkits.get`, `authConfigs.list`), pass as a
|
|
9
|
+
* trailing argument. Forwarded to the underlying `@composio/client` request.
|
|
10
|
+
*
|
|
11
|
+
* If the underlying request is aborted via this signal, the SDK throws a
|
|
12
|
+
* {@link ComposioRequestCancelledError} so callers can `instanceof`-detect
|
|
13
|
+
* cancellation without unwrapping nested causes.
|
|
14
|
+
*
|
|
15
|
+
* @example Timeout after 5 seconds
|
|
16
|
+
* ```typescript
|
|
17
|
+
* await composio.tools.execute(
|
|
18
|
+
* 'HACKERNEWS_GET_FRONTPAGE',
|
|
19
|
+
* { userId: 'default', arguments: {} },
|
|
20
|
+
* { signal: AbortSignal.timeout(5_000) }
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example Combine signal with modifiers
|
|
25
|
+
* ```typescript
|
|
26
|
+
* await composio.tools.execute('TOOL', body, {
|
|
27
|
+
* signal: AbortSignal.timeout(10_000),
|
|
28
|
+
* beforeExecute: ({ params }) => params,
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export type ComposioRequestOptions = {
|
|
33
|
+
/**
|
|
34
|
+
* An `AbortSignal` used to cancel the in-flight HTTP request. When the
|
|
35
|
+
* signal aborts, the underlying fetch is aborted and the SDK throws a
|
|
36
|
+
* {@link ComposioRequestCancelledError} (subclass of {@link ComposioError}).
|
|
37
|
+
*/
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The `@composio/client` per-request transport options, reached via a public
|
|
43
|
+
* method whose only parameter is that type (`tools.retrieveEnum`). The
|
|
44
|
+
* `internal/*` subpath that declares `RequestOptions` is not in the package's
|
|
45
|
+
* `exports`, so we derive it structurally instead of deep-importing it.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
type ClientRequestOptions = NonNullable<Parameters<ComposioClient['tools']['retrieveEnum']>[0]>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Compile-time guards: {@link ComposioRequestOptions} is forwarded verbatim to
|
|
52
|
+
* every `@composio/client` call, so it MUST stay a structural subset of the
|
|
53
|
+
* client's request options. These constraints fail the build (TS2344) if a
|
|
54
|
+
* field here is typed incompatibly with the client's same-named field, or if a
|
|
55
|
+
* key is added that the client doesn't have — forcing the divergence to be
|
|
56
|
+
* reconciled rather than discovered at runtime.
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
type AssertValuesAssignable<_T extends ClientRequestOptions> = void;
|
|
60
|
+
type AssertKeysSubset<_K extends keyof ClientRequestOptions> = void;
|
|
61
|
+
type _RequestOptionsValuesStayCompatible = AssertValuesAssignable<ComposioRequestOptions>;
|
|
62
|
+
type _RequestOptionsKeysStaySubset = AssertKeysSubset<keyof ComposioRequestOptions>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export const TELEMETRY_EVENTS = {
|
|
2
|
+
SDK_INITIALIZED: 'SDK_INITIALIZED',
|
|
3
|
+
SDK_METHOD_INVOKED: 'SDK_METHOD_INVOKED',
|
|
4
|
+
SDK_METHOD_ERROR: 'SDK_METHOD_ERROR',
|
|
5
|
+
CLI_INVOKED: 'CLI_INVOKED',
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
export type TelemetryEvent = (typeof TELEMETRY_EVENTS)[keyof typeof TELEMETRY_EVENTS];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Metadata for the telemetry.
|
|
12
|
+
*/
|
|
13
|
+
export type TelemetryMetadata = {
|
|
14
|
+
/**
|
|
15
|
+
* The API key of the SDK.
|
|
16
|
+
* @example 'sk-1234567890'
|
|
17
|
+
*/
|
|
18
|
+
apiKey: string;
|
|
19
|
+
/**
|
|
20
|
+
* The base URL of the SDK.
|
|
21
|
+
* @example 'https://api.composio.dev'
|
|
22
|
+
*/
|
|
23
|
+
baseUrl: string;
|
|
24
|
+
/**
|
|
25
|
+
* The version of the SDK.
|
|
26
|
+
* @example '1.0.0'
|
|
27
|
+
*/
|
|
28
|
+
version: string;
|
|
29
|
+
/**
|
|
30
|
+
* The host service name of the SDK where the SDK is running.
|
|
31
|
+
* @example 'mcp', 'apollo' etc
|
|
32
|
+
*/
|
|
33
|
+
host?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the SDK is agentic.
|
|
36
|
+
* @example true, false
|
|
37
|
+
*/
|
|
38
|
+
isAgentic: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The provider of the SDK.
|
|
41
|
+
* @example 'openai', 'anthropic', 'google', 'azure', 'composio'
|
|
42
|
+
*/
|
|
43
|
+
provider?: string;
|
|
44
|
+
isBrowser?: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type TelemetryPayloadParams = {
|
|
48
|
+
eventName: TelemetryEvent;
|
|
49
|
+
data: Record<string, unknown>;
|
|
50
|
+
};
|
|
51
|
+
export type TelemetryPayload = TelemetryPayloadParams & {
|
|
52
|
+
sdk_meta: TelemetryMetadata;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type TelemetryErrorPayloadParams = {
|
|
56
|
+
error_id: string;
|
|
57
|
+
error_message: string;
|
|
58
|
+
original_error: unknown;
|
|
59
|
+
error_code?: string | undefined;
|
|
60
|
+
possible_fix?: string | undefined;
|
|
61
|
+
description?: string;
|
|
62
|
+
current_stack?: string[];
|
|
63
|
+
};
|
|
64
|
+
export type TelemetryErrorPayload = TelemetryErrorPayloadParams & {
|
|
65
|
+
sdk_meta: TelemetryMetadata;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type AcceptableJSONValue =
|
|
69
|
+
| Record<string, unknown>
|
|
70
|
+
| Array<Record<string, unknown>>
|
|
71
|
+
| string
|
|
72
|
+
| number
|
|
73
|
+
| boolean
|
|
74
|
+
| null
|
|
75
|
+
| undefined;
|
|
76
|
+
|
|
77
|
+
export const TELEMETRY_TYPES = {
|
|
78
|
+
SDK_USAGE: 'SDK_USAGE',
|
|
79
|
+
SDK_ERROR: 'SDK_ERROR',
|
|
80
|
+
} as const;
|
|
81
|
+
|
|
82
|
+
export type TelemetryType = (typeof TELEMETRY_TYPES)[keyof typeof TELEMETRY_TYPES];
|
|
83
|
+
|
|
84
|
+
export interface TelemetryTransportParams {
|
|
85
|
+
url: string;
|
|
86
|
+
method: string;
|
|
87
|
+
headers: Record<string, string>;
|
|
88
|
+
data: AcceptableJSONValue;
|
|
89
|
+
}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
import { CustomConnectionDataSchema } from './connectedAccountAuthStates.types';
|
|
3
|
+
import { TransformToolSchemaModifier } from './modifiers.types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Toolkit is the collection of tools,
|
|
7
|
+
* A toolkit can be thought of as an app which provides a set of tools/actions/triggers.
|
|
8
|
+
*
|
|
9
|
+
* eg. Google Toolkit, which provides tools like Google Search, Google Maps, Google Translate, etc.
|
|
10
|
+
*/
|
|
11
|
+
export const ToolkitSchema = z.object({
|
|
12
|
+
slug: z.string().describe('The slug of the toolkit'),
|
|
13
|
+
name: z.string().describe('The name of the toolkit'),
|
|
14
|
+
logo: z.string().describe('The logo of the toolkit').optional(),
|
|
15
|
+
});
|
|
16
|
+
export type Toolkit = z.infer<typeof ToolkitSchema>;
|
|
17
|
+
|
|
18
|
+
// JSON Schema primitive types
|
|
19
|
+
const JSONSchemaType = z.enum([
|
|
20
|
+
'string',
|
|
21
|
+
'number',
|
|
22
|
+
'integer',
|
|
23
|
+
'boolean',
|
|
24
|
+
'object',
|
|
25
|
+
'array',
|
|
26
|
+
'null',
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
// JSON Schema property definition
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
export const JSONSchemaPropertySchema: z.ZodType<any> = z.object({
|
|
32
|
+
type: z.union([JSONSchemaType, z.array(JSONSchemaType)]).optional(),
|
|
33
|
+
description: z.string().optional(),
|
|
34
|
+
anyOf: z.lazy(() => z.array(JSONSchemaPropertySchema)).optional(),
|
|
35
|
+
oneOf: z.lazy(() => z.array(JSONSchemaPropertySchema)).optional(),
|
|
36
|
+
allOf: z.lazy(() => z.array(JSONSchemaPropertySchema)).optional(),
|
|
37
|
+
not: z.lazy(() => JSONSchemaPropertySchema).optional(),
|
|
38
|
+
title: z.string().optional(),
|
|
39
|
+
default: z.any().optional(),
|
|
40
|
+
nullable: z.boolean().optional(),
|
|
41
|
+
properties: z.lazy(() => z.record(z.string(), JSONSchemaPropertySchema)).optional(),
|
|
42
|
+
required: z.array(z.string()).optional(),
|
|
43
|
+
file_uploadable: z.boolean().optional(),
|
|
44
|
+
file_downloadable: z.boolean().optional(),
|
|
45
|
+
items: z
|
|
46
|
+
.lazy(() => z.union([JSONSchemaPropertySchema, z.array(JSONSchemaPropertySchema)]))
|
|
47
|
+
.optional(),
|
|
48
|
+
enum: z.array(z.any()).optional(),
|
|
49
|
+
const: z.any().optional(),
|
|
50
|
+
minimum: z.number().optional(),
|
|
51
|
+
maximum: z.number().optional(),
|
|
52
|
+
exclusiveMinimum: z.number().optional(),
|
|
53
|
+
exclusiveMaximum: z.number().optional(),
|
|
54
|
+
multipleOf: z.number().optional(),
|
|
55
|
+
minLength: z.number().optional(),
|
|
56
|
+
maxLength: z.number().optional(),
|
|
57
|
+
pattern: z.string().optional(),
|
|
58
|
+
format: z.string().optional(),
|
|
59
|
+
minItems: z.number().optional(),
|
|
60
|
+
maxItems: z.number().optional(),
|
|
61
|
+
uniqueItems: z.boolean().optional(),
|
|
62
|
+
minProperties: z.number().optional(),
|
|
63
|
+
maxProperties: z.number().optional(),
|
|
64
|
+
patternProperties: z.lazy(() => z.record(z.string(), JSONSchemaPropertySchema)).optional(),
|
|
65
|
+
additionalProperties: z.union([z.boolean(), z.lazy(() => JSONSchemaPropertySchema)]).optional(),
|
|
66
|
+
examples: z.array(z.any()).optional(),
|
|
67
|
+
readOnly: z.boolean().optional(),
|
|
68
|
+
writeOnly: z.boolean().optional(),
|
|
69
|
+
if: z.lazy(() => JSONSchemaPropertySchema).optional(),
|
|
70
|
+
then: z.lazy(() => JSONSchemaPropertySchema).optional(),
|
|
71
|
+
else: z.lazy(() => JSONSchemaPropertySchema).optional(),
|
|
72
|
+
$ref: z.string().optional(),
|
|
73
|
+
definitions: z
|
|
74
|
+
.record(
|
|
75
|
+
z.string(),
|
|
76
|
+
z.lazy(() => JSONSchemaPropertySchema)
|
|
77
|
+
)
|
|
78
|
+
.optional(),
|
|
79
|
+
$defs: z
|
|
80
|
+
.record(
|
|
81
|
+
z.string(),
|
|
82
|
+
z.lazy(() => JSONSchemaPropertySchema)
|
|
83
|
+
)
|
|
84
|
+
.optional(),
|
|
85
|
+
});
|
|
86
|
+
export type JSONSchemaProperty = z.infer<typeof JSONSchemaPropertySchema>;
|
|
87
|
+
|
|
88
|
+
// Schema for parameters (input/output)
|
|
89
|
+
const ParametersSchema = z.object({
|
|
90
|
+
type: z.literal('object'),
|
|
91
|
+
anyOf: z.array(JSONSchemaPropertySchema).optional(),
|
|
92
|
+
oneOf: z.array(JSONSchemaPropertySchema).optional(),
|
|
93
|
+
allOf: z.array(JSONSchemaPropertySchema).optional(),
|
|
94
|
+
not: JSONSchemaPropertySchema.optional(),
|
|
95
|
+
properties: z.record(z.string(), JSONSchemaPropertySchema),
|
|
96
|
+
required: z.array(z.string()).optional(),
|
|
97
|
+
title: z.string().optional(),
|
|
98
|
+
default: z.any().optional(),
|
|
99
|
+
nullable: z.boolean().optional(),
|
|
100
|
+
description: z.string().optional(),
|
|
101
|
+
additionalProperties: z.boolean().default(false).optional(),
|
|
102
|
+
// Definition blocks targeted by `$ref` pointers. The Composio API ships
|
|
103
|
+
// these at the parameters root (e.g. `data` → `$ref` → `#/$defs/...`), but
|
|
104
|
+
// because `z.object` strips unknown keys they were being dropped on parse —
|
|
105
|
+
// leaving every nested `$ref` dangling and unresolvable downstream
|
|
106
|
+
// (providers, file modifiers). `JSONSchemaPropertySchema` already accepts
|
|
107
|
+
// both keywords; the parameters root must too.
|
|
108
|
+
$defs: z
|
|
109
|
+
.record(
|
|
110
|
+
z.string(),
|
|
111
|
+
z.lazy(() => JSONSchemaPropertySchema)
|
|
112
|
+
)
|
|
113
|
+
.optional(),
|
|
114
|
+
definitions: z
|
|
115
|
+
.record(
|
|
116
|
+
z.string(),
|
|
117
|
+
z.lazy(() => JSONSchemaPropertySchema)
|
|
118
|
+
)
|
|
119
|
+
.optional(),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Tool is a single action that can be performed by a toolkit.
|
|
124
|
+
* Tool is simlar to an action that an app can perform.
|
|
125
|
+
*
|
|
126
|
+
* eg. Google Search, Google Maps, Google Translate, etc.
|
|
127
|
+
*/
|
|
128
|
+
export const ToolSchema = z.object({
|
|
129
|
+
slug: z.string().describe('The slug of the tool. eg. "GOOGLE_SEARCH"'),
|
|
130
|
+
name: z.string().describe(`The name of the tool. eg. "Google Search"`),
|
|
131
|
+
description: z.string().optional().describe('The description of the tool'),
|
|
132
|
+
inputParameters: ParametersSchema.optional().describe('The input parameters of the tool'),
|
|
133
|
+
outputParameters: ParametersSchema.optional().describe('The output parameters of the tool'),
|
|
134
|
+
tags: z.array(z.string()).describe('The tags of the tool. eg: Important').default([]).optional(),
|
|
135
|
+
toolkit: ToolkitSchema.describe('The toolkit of the tool').optional(),
|
|
136
|
+
version: z.string().describe('The version of the tool, e.g. "20250909_00"').optional(),
|
|
137
|
+
isDeprecated: z.boolean().describe('Whether the tool is deprecated').optional(),
|
|
138
|
+
availableVersions: z
|
|
139
|
+
.array(z.string())
|
|
140
|
+
.describe('Available versions of the tool.')
|
|
141
|
+
.default([])
|
|
142
|
+
.optional(),
|
|
143
|
+
scopes: z.array(z.string()).describe('The scopes of the tool. eg: ["task:add"]').optional(),
|
|
144
|
+
isNoAuth: z.boolean().describe('Do the tool support no auth?').optional(),
|
|
145
|
+
});
|
|
146
|
+
export type Tool = z.infer<typeof ToolSchema>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* ToolListResponse Schema
|
|
150
|
+
*/
|
|
151
|
+
export const ToolListResponseSchema = z.object({
|
|
152
|
+
items: z.array(ToolSchema),
|
|
153
|
+
nextCursor: z.string().nullable().optional(),
|
|
154
|
+
totalPages: z.number(),
|
|
155
|
+
});
|
|
156
|
+
export type ToolListResponse = z.infer<typeof ToolListResponseSchema>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Plain SDK level Tool List
|
|
160
|
+
*/
|
|
161
|
+
export type ToolList = Array<Tool>;
|
|
162
|
+
|
|
163
|
+
export const ToolkitLatestVersionSchema = z.literal('latest');
|
|
164
|
+
/**
|
|
165
|
+
* latest toolkit version param
|
|
166
|
+
*/
|
|
167
|
+
export type ToolkitLatestVersion = z.infer<typeof ToolkitLatestVersionSchema>;
|
|
168
|
+
|
|
169
|
+
export const ToolkitVersionSchema = z.union([ToolkitLatestVersionSchema, z.string()]);
|
|
170
|
+
/**
|
|
171
|
+
* Versioning a tool based on it's toolkit version, either 'latest' or actual tool version as string '20250902_00'
|
|
172
|
+
* @example
|
|
173
|
+
* 'latest'
|
|
174
|
+
* '20250902_00'
|
|
175
|
+
*/
|
|
176
|
+
export type ToolkitVersion = z.infer<typeof ToolkitVersionSchema>;
|
|
177
|
+
|
|
178
|
+
export const ToolkitVersionsSchema = z.record(z.string(), ToolkitVersionSchema);
|
|
179
|
+
/**
|
|
180
|
+
* Versioning multiple toolkits
|
|
181
|
+
* @example
|
|
182
|
+
* { 'github': 'latest', 'slack': '20250902_00' }
|
|
183
|
+
*/
|
|
184
|
+
export type ToolkitVersions = Record<string, ToolkitVersion>;
|
|
185
|
+
|
|
186
|
+
export const ToolkitVersionParamSchema = z
|
|
187
|
+
.union([ToolkitVersionsSchema, ToolkitLatestVersionSchema, z.undefined()])
|
|
188
|
+
.describe('The versioning of the toolkits. eg: { "github": "latest", "slack": "20250902_00" }');
|
|
189
|
+
/**
|
|
190
|
+
* Versioning a tool based on it's toolkit version
|
|
191
|
+
* @example
|
|
192
|
+
* ```json
|
|
193
|
+
* { 'github': 'latest', 'slack': '20250902_00' }
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export type ToolkitVersionParam = z.infer<typeof ToolkitVersionParamSchema>;
|
|
197
|
+
|
|
198
|
+
export const ToolListParamsSchema = z.object({
|
|
199
|
+
tools: z.array(z.string()).optional(),
|
|
200
|
+
toolkits: z.array(z.string()).optional(),
|
|
201
|
+
scopes: z.array(z.string()).optional(),
|
|
202
|
+
tags: z.array(z.string()).optional(),
|
|
203
|
+
limit: z.number().optional(),
|
|
204
|
+
search: z.string().optional(),
|
|
205
|
+
authConfigIds: z.array(z.string()).optional(),
|
|
206
|
+
important: z.boolean().optional(),
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
type BaseParams = {
|
|
210
|
+
limit?: number;
|
|
211
|
+
search?: string;
|
|
212
|
+
scopes?: string[];
|
|
213
|
+
tags?: string[];
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// tools only
|
|
217
|
+
type ToolsOnlyParams = {
|
|
218
|
+
tools: string[];
|
|
219
|
+
toolkits?: never;
|
|
220
|
+
scopes?: never;
|
|
221
|
+
search?: never;
|
|
222
|
+
tags?: never;
|
|
223
|
+
};
|
|
224
|
+
// toolkits only
|
|
225
|
+
type ToolkitsOnlyParams = {
|
|
226
|
+
toolkits: string[];
|
|
227
|
+
tools?: never;
|
|
228
|
+
scopes?: never;
|
|
229
|
+
important?: boolean;
|
|
230
|
+
} & Pick<BaseParams, 'limit' | 'search' | 'tags'>;
|
|
231
|
+
|
|
232
|
+
// toolkit + scopes (single toolkit only)
|
|
233
|
+
type ToolkitScopeOnlyParams = {
|
|
234
|
+
toolkits: [string];
|
|
235
|
+
tools?: never;
|
|
236
|
+
scopes: string[];
|
|
237
|
+
important?: boolean;
|
|
238
|
+
} & Pick<BaseParams, 'limit' | 'search' | 'tags'>;
|
|
239
|
+
|
|
240
|
+
// tags only
|
|
241
|
+
type TagsOnlyParams = {
|
|
242
|
+
toolkits?: string[];
|
|
243
|
+
tags: string[];
|
|
244
|
+
tools?: never;
|
|
245
|
+
search?: never;
|
|
246
|
+
} & Pick<BaseParams, 'limit'>;
|
|
247
|
+
|
|
248
|
+
// search only
|
|
249
|
+
type SearchOnlyParams = {
|
|
250
|
+
search: string;
|
|
251
|
+
tools?: never;
|
|
252
|
+
toolkits?: never;
|
|
253
|
+
scopes?: never;
|
|
254
|
+
limit?: never;
|
|
255
|
+
tags?: never;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// tools by auth config ids only
|
|
259
|
+
type AuthConfigIdsOnlyParams = {
|
|
260
|
+
authConfigIds: string[];
|
|
261
|
+
tools?: never;
|
|
262
|
+
toolkits?: never;
|
|
263
|
+
} & Pick<BaseParams, 'limit' | 'search' | 'tags'>;
|
|
264
|
+
/**
|
|
265
|
+
* ToolListParams is the parameters for the list of tools.
|
|
266
|
+
* You must provide either tools or toolkits, but not both.
|
|
267
|
+
*/
|
|
268
|
+
export type ToolListParams =
|
|
269
|
+
| ToolsOnlyParams
|
|
270
|
+
| ToolkitsOnlyParams
|
|
271
|
+
| ToolkitScopeOnlyParams
|
|
272
|
+
| SearchOnlyParams
|
|
273
|
+
| TagsOnlyParams
|
|
274
|
+
| AuthConfigIdsOnlyParams;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* CustomAuthParams is the parameters for the custom authentication.
|
|
278
|
+
*/
|
|
279
|
+
export const CustomAuthParamsSchema = z.object({
|
|
280
|
+
baseURL: z.string().optional(),
|
|
281
|
+
body: z.record(z.string(), z.unknown()).optional(),
|
|
282
|
+
parameters: z.array(
|
|
283
|
+
z.object({
|
|
284
|
+
in: z.enum(['query', 'header']),
|
|
285
|
+
name: z.string(),
|
|
286
|
+
value: z.union([z.string(), z.number()]),
|
|
287
|
+
})
|
|
288
|
+
),
|
|
289
|
+
});
|
|
290
|
+
export type CustomAuthParams = z.infer<typeof CustomAuthParamsSchema>;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Parameters for tool execution.
|
|
294
|
+
*
|
|
295
|
+
* @property {boolean} [allowTracing] - Enable tracing for this tool execution
|
|
296
|
+
* @property {string} [connectedAccountId] - The connected account ID to use for authenticated tools
|
|
297
|
+
* @property {CustomAuthParams} [customAuthParams] - Custom authentication parameters
|
|
298
|
+
* @property {CustomConnectionData} [customConnectionData] - Custom connection data (takes priority over customAuthParams)
|
|
299
|
+
* @property {Record<string, unknown>} [arguments] - The arguments to pass to the tool
|
|
300
|
+
* @property {string} [userId] - The user ID to execute the tool for (required for no-auth apps)
|
|
301
|
+
* @property {string} [version] - The specific version of the tool to execute (e.g., "20250909_00" or "latest")
|
|
302
|
+
* @property {boolean} [dangerouslySkipVersionCheck] - Skip version validation when using "latest" version.
|
|
303
|
+
* **Warning:** This may cause unexpected behavior when new toolkit versions are released.
|
|
304
|
+
* Only use this if you understand the risks. Recommended alternatives:
|
|
305
|
+
* - Specify a concrete version in the `version` parameter
|
|
306
|
+
* - Configure toolkit versions at SDK initialization level
|
|
307
|
+
* - Set toolkit version via environment variable (COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_SLUG>)
|
|
308
|
+
* @property {string} [text] - Additional text input for the tool
|
|
309
|
+
*
|
|
310
|
+
* @example Recommended: Execute with a specific version
|
|
311
|
+
* ```typescript
|
|
312
|
+
* const params: ToolExecuteParams = {
|
|
313
|
+
* userId: 'default',
|
|
314
|
+
* version: '20250909_00',
|
|
315
|
+
* arguments: { owner: 'composio', repo: 'sdk' }
|
|
316
|
+
* };
|
|
317
|
+
* ```
|
|
318
|
+
*
|
|
319
|
+
* @example With dangerouslySkipVersionCheck (use with caution)
|
|
320
|
+
* ```typescript
|
|
321
|
+
* const params: ToolExecuteParams = {
|
|
322
|
+
* userId: 'default',
|
|
323
|
+
* dangerouslySkipVersionCheck: true,
|
|
324
|
+
* arguments: { userId: 'pg' }
|
|
325
|
+
* };
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
export const ToolExecuteParamsSchema = z.object({
|
|
329
|
+
allowTracing: z.boolean().optional(),
|
|
330
|
+
connectedAccountId: z.string().optional(),
|
|
331
|
+
customAuthParams: CustomAuthParamsSchema.optional(),
|
|
332
|
+
customConnectionData: CustomConnectionDataSchema.optional(),
|
|
333
|
+
arguments: z.record(z.string(), z.unknown()).optional(),
|
|
334
|
+
userId: z.string().optional(),
|
|
335
|
+
version: z.union([z.literal('latest'), z.string()]).optional(),
|
|
336
|
+
dangerouslySkipVersionCheck: z.boolean().optional(),
|
|
337
|
+
text: z.string().optional(),
|
|
338
|
+
});
|
|
339
|
+
export type ToolExecuteParams = z.infer<typeof ToolExecuteParamsSchema>;
|
|
340
|
+
|
|
341
|
+
export const ToolExecuteMetaParamsSchema = z.object({
|
|
342
|
+
sessionId: z.string(),
|
|
343
|
+
arguments: z.record(z.string(), z.unknown()).optional(),
|
|
344
|
+
});
|
|
345
|
+
export type ToolExecuteMetaParams = z.infer<typeof ToolExecuteMetaParamsSchema>;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* ToolResponse Schema
|
|
349
|
+
*/
|
|
350
|
+
export const ToolExecuteResponseSchema = z.object({
|
|
351
|
+
data: z.record(z.string(), z.unknown()),
|
|
352
|
+
error: z.string().nullable(),
|
|
353
|
+
successful: z.boolean(),
|
|
354
|
+
logId: z.string().optional(),
|
|
355
|
+
sessionInfo: z.unknown().optional(),
|
|
356
|
+
});
|
|
357
|
+
export type ToolExecuteResponse = z.infer<typeof ToolExecuteResponseSchema>;
|
|
358
|
+
|
|
359
|
+
export const ToolProxyParamsSchema = z.object({
|
|
360
|
+
endpoint: z.string(),
|
|
361
|
+
method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']),
|
|
362
|
+
body: z.unknown().optional(),
|
|
363
|
+
parameters: z
|
|
364
|
+
.array(
|
|
365
|
+
z.object({
|
|
366
|
+
in: z.enum(['query', 'header']),
|
|
367
|
+
name: z.string(),
|
|
368
|
+
value: z.union([z.string(), z.number()]),
|
|
369
|
+
})
|
|
370
|
+
)
|
|
371
|
+
.optional(),
|
|
372
|
+
connectedAccountId: z.string().optional(),
|
|
373
|
+
/**
|
|
374
|
+
* @deprecated
|
|
375
|
+
*/
|
|
376
|
+
customConnectionData: CustomConnectionDataSchema.describe(
|
|
377
|
+
'DEPRECATED: This field is deprecated and will be removed in the future.'
|
|
378
|
+
).optional(),
|
|
379
|
+
});
|
|
380
|
+
export type ToolProxyParams = z.infer<typeof ToolProxyParamsSchema>;
|
|
381
|
+
|
|
382
|
+
export type SchemaModifierOptions = {
|
|
383
|
+
modifySchema: TransformToolSchemaModifier;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Options for retrieving tools from Composio API
|
|
388
|
+
*/
|
|
389
|
+
export type ToolRetrievalOptions = {
|
|
390
|
+
/**
|
|
391
|
+
* Optional function to transform the tool schema after retrieval
|
|
392
|
+
*/
|
|
393
|
+
modifySchema?: TransformToolSchemaModifier;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Override the toolkit version for tool retrieval.
|
|
397
|
+
* Takes precedence over SDK-level toolkitVersions.
|
|
398
|
+
*
|
|
399
|
+
* @example Override with specific version
|
|
400
|
+
* ```typescript
|
|
401
|
+
* const tool = await tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE', {
|
|
402
|
+
* version: '20250909_00'
|
|
403
|
+
* });
|
|
404
|
+
* ```
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
version?: ToolkitVersion;
|
|
408
|
+
};
|