@composio/core 0.12.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.
Files changed (144) hide show
  1. package/dist/BaseProvider-Brb3o86-.d.mts +29425 -0
  2. package/dist/{CustomTool-DEB4BQPl.mjs → CustomTool-D9qwyMrv.mjs} +1 -1
  3. package/dist/{CustomTool-DH18rVQu.d.mts → CustomTool-Dmi6ti3I.d.mts} +1 -1
  4. package/dist/CustomTool-DrJpOhY2.d.mts +74 -0
  5. package/dist/{composio-CHnEggnv.d.mts → composio-DHIKRdeG.d.mts} +253 -37
  6. package/dist/composio-vMwhASRc.d.mts +5698 -0
  7. package/dist/{customTool.types-DpIdOJjL.d.mts → customTool.types-CKH2R2ia.d.mts} +344 -25
  8. package/dist/customTool.types-DXin7Cfc.d.mts +2773 -0
  9. package/dist/docs/error-consistency.md +97 -0
  10. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +306 -0
  11. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +205 -0
  12. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +488 -0
  13. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +94 -0
  14. package/dist/docs/reference/sdk-reference/typescript/index.mdx +67 -0
  15. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +304 -0
  16. package/dist/docs/reference/sdk-reference/typescript/meta.json +17 -0
  17. package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +107 -0
  18. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +163 -0
  19. package/dist/docs/reference/sdk-reference/typescript/session.mdx +229 -0
  20. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +131 -0
  21. package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +169 -0
  22. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +453 -0
  23. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +434 -0
  24. package/dist/{errors-D5f4pfvI.mjs → errors-DSIlYfl5.mjs} +2 -2
  25. package/dist/experimental/index.d.mts +2 -2
  26. package/dist/experimental/index.mjs +1 -1
  27. package/dist/index.d.mts +27 -4
  28. package/dist/index.mjs +423 -123
  29. package/dist/{jsonSchema-daqF3S3d.mjs → jsonSchema-CFKdONpP.mjs} +1 -1
  30. package/dist/{types-CaI5Z4PA.d.mts → types-D4Id3wXA.d.mts} +1 -1
  31. package/dist/types-qTbYYBJw.d.mts +12 -0
  32. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
  33. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
  34. package/dist/utils/modifiers/FileToolModifier.node.mjs +2 -2
  35. package/docs/error-consistency.md +97 -0
  36. package/package.json +4 -3
  37. package/src/composio.ts +509 -0
  38. package/src/errors/AuthConfigErrors.ts +23 -0
  39. package/src/errors/ComposioError.ts +408 -0
  40. package/src/errors/ConnectedAccountsErrors.ts +158 -0
  41. package/src/errors/ConnectionRequestErrors.ts +32 -0
  42. package/src/errors/FileModifierErrors.ts +100 -0
  43. package/src/errors/PusherErrors.ts +28 -0
  44. package/src/errors/RemoteFileErrors.ts +62 -0
  45. package/src/errors/SDKErrors.ts +92 -0
  46. package/src/errors/ToolErrors.ts +244 -0
  47. package/src/errors/ToolkitErrors.ts +39 -0
  48. package/src/errors/TriggerErrors.ts +120 -0
  49. package/src/errors/ValidationErrors.ts +99 -0
  50. package/src/errors/index.ts +41 -0
  51. package/src/experimental/index.ts +28 -0
  52. package/src/index.ts +64 -0
  53. package/src/lib/toolRouterConstants.ts +1 -0
  54. package/src/lib/toolRouterParams.ts +306 -0
  55. package/src/models/AuthConfigs.ts +398 -0
  56. package/src/models/AuthScheme.ts +206 -0
  57. package/src/models/ConnectedAccounts.ts +735 -0
  58. package/src/models/ConnectionRequest.ts +150 -0
  59. package/src/models/CustomTool.ts +676 -0
  60. package/src/models/Experimental.ts +202 -0
  61. package/src/models/Files.node.ts +93 -0
  62. package/src/models/Files.workerd.ts +49 -0
  63. package/src/models/MCP.ts +478 -0
  64. package/src/models/RemoteFile.ts +172 -0
  65. package/src/models/SessionContext.ts +147 -0
  66. package/src/models/Sessions.ts +21 -0
  67. package/src/models/ToolRouter.ts +391 -0
  68. package/src/models/ToolRouterSession.ts +827 -0
  69. package/src/models/ToolRouterSessionFileMount.ts +389 -0
  70. package/src/models/Toolkits.ts +412 -0
  71. package/src/models/Tools.ts +1260 -0
  72. package/src/models/Triggers.ts +1381 -0
  73. package/src/models/customToolExecution.ts +118 -0
  74. package/src/models/inlineCustomToolsPayload.ts +17 -0
  75. package/src/models/proxyParamsTransform.ts +26 -0
  76. package/src/provider/BaseProvider.ts +138 -0
  77. package/src/provider/ComposioProvider.ts +29 -0
  78. package/src/provider/OpenAIProvider.ts +547 -0
  79. package/src/services/internal/InternalService.ts +50 -0
  80. package/src/services/internal/InternalService.types.ts +14 -0
  81. package/src/services/pusher/Pusher.ts +230 -0
  82. package/src/services/telemetry/TelemetryService.ts +48 -0
  83. package/src/services/telemetry/TelemetryService.types.ts +67 -0
  84. package/src/telemetry/BatchProcessor.ts +77 -0
  85. package/src/telemetry/README.md +123 -0
  86. package/src/telemetry/Telemetry.ts +356 -0
  87. package/src/types/ToolRouterSessionFilesMount.types.ts +96 -0
  88. package/src/types/authConfigs.types.ts +174 -0
  89. package/src/types/composio.types.ts +1 -0
  90. package/src/types/connectedAccountAuthStates.types.ts +852 -0
  91. package/src/types/connectedAccounts.types.ts +395 -0
  92. package/src/types/connectionRequest.types.ts +16 -0
  93. package/src/types/customTool.types.ts +261 -0
  94. package/src/types/files.types.ts +15 -0
  95. package/src/types/mcp.experimental.types.ts +163 -0
  96. package/src/types/mcp.types.ts +362 -0
  97. package/src/types/modifiers.types.ts +663 -0
  98. package/src/types/org.types.ts +0 -0
  99. package/src/types/provider.types.ts +41 -0
  100. package/src/types/pusher.types.ts +18 -0
  101. package/src/types/requestOptions.types.ts +62 -0
  102. package/src/types/telemetry.types.ts +89 -0
  103. package/src/types/tool.types.ts +408 -0
  104. package/src/types/toolRouter.types.ts +761 -0
  105. package/src/types/toolkit.types.ts +130 -0
  106. package/src/types/triggers.types.ts +401 -0
  107. package/src/types/webhookEvents.types.ts +219 -0
  108. package/src/utils/buffer.ts +30 -0
  109. package/src/utils/cancellation.ts +22 -0
  110. package/src/utils/config-defaults/ConfigDefaults.node.ts +7 -0
  111. package/src/utils/config-defaults/ConfigDefaults.workerd.ts +10 -0
  112. package/src/utils/config-defaults/index.ts +1 -0
  113. package/src/utils/config-defaults/types.ts +14 -0
  114. package/src/utils/constants.ts +22 -0
  115. package/src/utils/crypto.ts +34 -0
  116. package/src/utils/env.ts +34 -0
  117. package/src/utils/fileDirs.ts +81 -0
  118. package/src/utils/fileUtils.node.ts +458 -0
  119. package/src/utils/json-schema.ts +1 -0
  120. package/src/utils/jsonSchema.ts +355 -0
  121. package/src/utils/logger.ts +99 -0
  122. package/src/utils/mime.ts +75 -0
  123. package/src/utils/modifiers/FileToolModifier.node.ts +477 -0
  124. package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +132 -0
  125. package/src/utils/modifiers/FileToolModifier.workerd.ts +51 -0
  126. package/src/utils/pagination.ts +73 -0
  127. package/src/utils/pusher.ts +286 -0
  128. package/src/utils/schemaPropertyKeys.ts +433 -0
  129. package/src/utils/sdk.ts +110 -0
  130. package/src/utils/sensitiveFileUploadPaths.node.ts +105 -0
  131. package/src/utils/session.ts +114 -0
  132. package/src/utils/toolArguments.ts +73 -0
  133. package/src/utils/toolkitVersion.ts +26 -0
  134. package/src/utils/transform.ts +42 -0
  135. package/src/utils/transformers/authConfigs.ts +107 -0
  136. package/src/utils/transformers/connectedAccounts.ts +119 -0
  137. package/src/utils/transformers/mcp.ts +164 -0
  138. package/src/utils/transformers/toolRouterResponseTransform.ts +160 -0
  139. package/src/utils/transformers/toolkits.ts +100 -0
  140. package/src/utils/transformers/triggers.ts +118 -0
  141. package/src/utils/uploadDirAllowlist.node.ts +178 -0
  142. package/src/utils/uuid.ts +7 -0
  143. package/src/utils/version.ts +58 -0
  144. package/src/utils/zodSchema.ts +90 -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
+ };