@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.
Files changed (193) hide show
  1. package/dist/BaseProvider-BBnsv9kS.d.mts +29425 -0
  2. package/dist/{BaseProvider-CVbQxTNa.d.cts → BaseProvider-Brb3o86-.d.mts} +91 -44
  3. package/dist/CustomTool-D9qwyMrv.mjs +468 -0
  4. package/dist/{CustomTool-C-IUByoU.d.cts → CustomTool-Dmi6ti3I.d.mts} +2 -4
  5. package/dist/{CustomTool-CChQSp44.d.mts → CustomTool-DrJpOhY2.d.mts} +2 -4
  6. package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
  7. package/dist/{Telemetry-DQax33Gh.mjs → Telemetry-DhGI_J4G.mjs} +15 -15
  8. package/dist/{composio-pcA13w87.d.cts → composio-DHIKRdeG.d.mts} +641 -380
  9. package/dist/{composio-BlASKqjQ.d.mts → composio-vMwhASRc.d.mts} +1390 -1129
  10. package/dist/{customTool.types-QtkAZQma.d.cts → customTool.types-CKH2R2ia.d.mts} +487 -189
  11. package/dist/{customTool.types-DLIORcYN.d.mts → customTool.types-DXin7Cfc.d.mts} +924 -626
  12. package/dist/docs/error-consistency.md +97 -0
  13. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +306 -0
  14. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +205 -0
  15. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +488 -0
  16. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +94 -0
  17. package/dist/docs/reference/sdk-reference/typescript/index.mdx +67 -0
  18. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +304 -0
  19. package/dist/docs/reference/sdk-reference/typescript/meta.json +17 -0
  20. package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +107 -0
  21. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +163 -0
  22. package/dist/docs/reference/sdk-reference/typescript/session.mdx +229 -0
  23. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +131 -0
  24. package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +169 -0
  25. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +453 -0
  26. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +434 -0
  27. package/dist/{CustomTool-D5s-aADw.mjs → errors-DSIlYfl5.mjs} +72 -459
  28. package/dist/experimental/index.d.mts +2 -3
  29. package/dist/experimental/index.mjs +1 -3
  30. package/dist/{fileUtils.node-Dq7ebZPC.mjs → fileUtils.node-BiO1JQsJ.mjs} +26 -25
  31. package/dist/index.d.mts +1708 -2400
  32. package/dist/index.mjs +2632 -2006
  33. package/dist/jsonSchema-CFKdONpP.mjs +251 -0
  34. package/dist/models/Files.node.d.mts +1 -2
  35. package/dist/models/Files.node.mjs +3 -4
  36. package/dist/models/Files.workerd.d.mts +0 -1
  37. package/dist/platform/node.d.mts +1 -2
  38. package/dist/platform/workerd.d.mts +1 -2
  39. package/dist/{chunk-CWQeghP5.mjs → rolldown-runtime-w6R9maHv.mjs} +3 -5
  40. package/dist/{types-J2KCXP8R.d.mts → types-D4Id3wXA.d.mts} +2 -3
  41. package/dist/{types-DRG5qLxI.d.cts → types-qTbYYBJw.d.mts} +2 -3
  42. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -4
  43. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -4
  44. package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +3 -0
  45. package/dist/utils/json-schema.d.mts +2 -0
  46. package/dist/utils/json-schema.mjs +3 -0
  47. package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -1
  48. package/dist/utils/modifiers/FileToolModifier.node.mjs +44 -24
  49. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
  50. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
  51. package/docs/error-consistency.md +97 -0
  52. package/package.json +40 -88
  53. package/src/composio.ts +509 -0
  54. package/src/errors/AuthConfigErrors.ts +23 -0
  55. package/src/errors/ComposioError.ts +408 -0
  56. package/src/errors/ConnectedAccountsErrors.ts +158 -0
  57. package/src/errors/ConnectionRequestErrors.ts +32 -0
  58. package/src/errors/FileModifierErrors.ts +100 -0
  59. package/src/errors/PusherErrors.ts +28 -0
  60. package/src/errors/RemoteFileErrors.ts +62 -0
  61. package/src/errors/SDKErrors.ts +92 -0
  62. package/src/errors/ToolErrors.ts +244 -0
  63. package/src/errors/ToolkitErrors.ts +39 -0
  64. package/src/errors/TriggerErrors.ts +120 -0
  65. package/src/errors/ValidationErrors.ts +99 -0
  66. package/src/errors/index.ts +41 -0
  67. package/src/experimental/index.ts +28 -0
  68. package/src/index.ts +64 -0
  69. package/src/lib/toolRouterConstants.ts +1 -0
  70. package/src/lib/toolRouterParams.ts +306 -0
  71. package/src/models/AuthConfigs.ts +398 -0
  72. package/src/models/AuthScheme.ts +206 -0
  73. package/src/models/ConnectedAccounts.ts +735 -0
  74. package/src/models/ConnectionRequest.ts +150 -0
  75. package/src/models/CustomTool.ts +676 -0
  76. package/src/models/Experimental.ts +202 -0
  77. package/src/models/Files.node.ts +93 -0
  78. package/src/models/Files.workerd.ts +49 -0
  79. package/src/models/MCP.ts +478 -0
  80. package/src/models/RemoteFile.ts +172 -0
  81. package/src/models/SessionContext.ts +147 -0
  82. package/src/models/Sessions.ts +21 -0
  83. package/src/models/ToolRouter.ts +391 -0
  84. package/src/models/ToolRouterSession.ts +827 -0
  85. package/src/models/ToolRouterSessionFileMount.ts +389 -0
  86. package/src/models/Toolkits.ts +412 -0
  87. package/src/models/Tools.ts +1260 -0
  88. package/src/models/Triggers.ts +1381 -0
  89. package/src/models/customToolExecution.ts +118 -0
  90. package/src/models/inlineCustomToolsPayload.ts +17 -0
  91. package/src/models/proxyParamsTransform.ts +26 -0
  92. package/src/provider/BaseProvider.ts +138 -0
  93. package/src/provider/ComposioProvider.ts +29 -0
  94. package/src/provider/OpenAIProvider.ts +547 -0
  95. package/src/services/internal/InternalService.ts +50 -0
  96. package/src/services/internal/InternalService.types.ts +14 -0
  97. package/src/services/pusher/Pusher.ts +230 -0
  98. package/src/services/telemetry/TelemetryService.ts +48 -0
  99. package/src/services/telemetry/TelemetryService.types.ts +67 -0
  100. package/src/telemetry/BatchProcessor.ts +77 -0
  101. package/src/telemetry/README.md +123 -0
  102. package/src/telemetry/Telemetry.ts +356 -0
  103. package/src/types/ToolRouterSessionFilesMount.types.ts +96 -0
  104. package/src/types/authConfigs.types.ts +174 -0
  105. package/src/types/composio.types.ts +1 -0
  106. package/src/types/connectedAccountAuthStates.types.ts +852 -0
  107. package/src/types/connectedAccounts.types.ts +395 -0
  108. package/src/types/connectionRequest.types.ts +16 -0
  109. package/src/types/customTool.types.ts +261 -0
  110. package/{dist/files.types-lo4zZd87.d.cts → src/types/files.types.ts} +3 -5
  111. package/src/types/mcp.experimental.types.ts +163 -0
  112. package/src/types/mcp.types.ts +362 -0
  113. package/src/types/modifiers.types.ts +663 -0
  114. package/src/types/org.types.ts +0 -0
  115. package/src/types/provider.types.ts +41 -0
  116. package/src/types/pusher.types.ts +18 -0
  117. package/src/types/requestOptions.types.ts +62 -0
  118. package/src/types/telemetry.types.ts +89 -0
  119. package/src/types/tool.types.ts +408 -0
  120. package/src/types/toolRouter.types.ts +761 -0
  121. package/src/types/toolkit.types.ts +130 -0
  122. package/src/types/triggers.types.ts +401 -0
  123. package/src/types/webhookEvents.types.ts +219 -0
  124. package/src/utils/buffer.ts +30 -0
  125. package/src/utils/cancellation.ts +22 -0
  126. package/src/utils/config-defaults/ConfigDefaults.node.ts +7 -0
  127. package/src/utils/config-defaults/ConfigDefaults.workerd.ts +10 -0
  128. package/src/utils/config-defaults/index.ts +1 -0
  129. package/src/utils/config-defaults/types.ts +14 -0
  130. package/src/utils/constants.ts +22 -0
  131. package/src/utils/crypto.ts +34 -0
  132. package/src/utils/env.ts +34 -0
  133. package/src/utils/fileDirs.ts +81 -0
  134. package/src/utils/fileUtils.node.ts +458 -0
  135. package/src/utils/json-schema.ts +1 -0
  136. package/src/utils/jsonSchema.ts +355 -0
  137. package/src/utils/logger.ts +99 -0
  138. package/src/utils/mime.ts +75 -0
  139. package/src/utils/modifiers/FileToolModifier.node.ts +477 -0
  140. package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +132 -0
  141. package/src/utils/modifiers/FileToolModifier.workerd.ts +51 -0
  142. package/src/utils/pagination.ts +73 -0
  143. package/src/utils/pusher.ts +286 -0
  144. package/src/utils/schemaPropertyKeys.ts +433 -0
  145. package/src/utils/sdk.ts +110 -0
  146. package/src/utils/sensitiveFileUploadPaths.node.ts +105 -0
  147. package/src/utils/session.ts +114 -0
  148. package/src/utils/toolArguments.ts +73 -0
  149. package/src/utils/toolkitVersion.ts +26 -0
  150. package/src/utils/transform.ts +42 -0
  151. package/src/utils/transformers/authConfigs.ts +107 -0
  152. package/src/utils/transformers/connectedAccounts.ts +119 -0
  153. package/src/utils/transformers/mcp.ts +164 -0
  154. package/src/utils/transformers/toolRouterResponseTransform.ts +160 -0
  155. package/src/utils/transformers/toolkits.ts +100 -0
  156. package/src/utils/transformers/triggers.ts +118 -0
  157. package/src/utils/uploadDirAllowlist.node.ts +178 -0
  158. package/src/utils/uuid.ts +7 -0
  159. package/src/utils/version.ts +58 -0
  160. package/src/utils/zodSchema.ts +90 -0
  161. package/dist/BaseProvider-BvHvJLXc.d.mts +0 -29378
  162. package/dist/CustomTool-D3-NreIm.cjs +0 -1341
  163. package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
  164. package/dist/FileToolModifier.utils.neutral-DSBQs9-i.cjs +0 -96
  165. package/dist/Telemetry-BQ_pl5AK.cjs +0 -360
  166. package/dist/buffer-BjWptbNH.cjs +0 -63
  167. package/dist/chunk-CQwRTUmo.cjs +0 -53
  168. package/dist/experimental/index.cjs +0 -5
  169. package/dist/experimental/index.d.cts +0 -3
  170. package/dist/fileUtils.node-DtnSRMWa.cjs +0 -462
  171. package/dist/index.cjs +0 -8523
  172. package/dist/index.d.cts +0 -6065
  173. package/dist/models/Files.node.cjs +0 -55
  174. package/dist/models/Files.node.d.cts +0 -56
  175. package/dist/models/Files.workerd.cjs +0 -29
  176. package/dist/models/Files.workerd.d.cts +0 -13
  177. package/dist/platform/node.cjs +0 -55
  178. package/dist/platform/node.d.cts +0 -11
  179. package/dist/platform/workerd.cjs +0 -42
  180. package/dist/platform/workerd.d.cts +0 -12
  181. package/dist/types-pDNm1lYs.d.cts +0 -69
  182. package/dist/utils/config-defaults/ConfigDefaults.node.cjs +0 -10
  183. package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +0 -7
  184. package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +0 -10
  185. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +0 -7
  186. package/dist/utils/modifiers/FileToolModifier.node.cjs +0 -224
  187. package/dist/utils/modifiers/FileToolModifier.node.d.cts +0 -22
  188. package/dist/utils/modifiers/FileToolModifier.workerd.cjs +0 -27
  189. package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +0 -20
  190. /package/dist/{FileToolModifier.utils.neutral-BpSceNK8.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +0 -0
  191. /package/dist/{buffer-yOtEsT4J.mjs → buffer-PcbMMsgm.mjs} +0 -0
  192. /package/dist/{files.types-BXDWA_zS.d.mts → files.types-DeMC_mAW.d.mts} +0 -0
  193. /package/dist/{types-HpJQ8K9l.d.mts → types-DdoCRzLj.d.mts} +0 -0
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @fileoverview Standalone functions for custom tool lookup and execution.
3
+ * Extracted from ToolRouterSession for reuse in SessionContextImpl (sibling routing).
4
+ */
5
+ import type {
6
+ CustomToolsMap,
7
+ CustomToolsMapEntry,
8
+ SessionContext,
9
+ } from '../types/customTool.types';
10
+ import type { ToolExecuteResponse } from '../types/tool.types';
11
+ import { ValidationError } from '../errors';
12
+ import { ComposioRequestCancelledError, isRequestAbortError } from '../errors/SDKErrors';
13
+
14
+ /**
15
+ * Find a custom tool entry by slug.
16
+ * Checks both the final slug map (LOCAL_X — agent/LLM path) and original slug map (X — programmatic path).
17
+ */
18
+ export function findCustomTool(
19
+ map: CustomToolsMap | undefined,
20
+ slug: string
21
+ ): CustomToolsMapEntry | undefined {
22
+ if (!map) return undefined;
23
+ const upper = slug.toUpperCase();
24
+ const finalSlugMatch = map.byFinalSlug.get(upper);
25
+ if (finalSlugMatch) return finalSlugMatch;
26
+ if (map.ambiguousOriginalSlugs?.has(upper)) return undefined;
27
+ return map.byOriginalSlug.get(upper);
28
+ }
29
+
30
+ /**
31
+ * Reject ambiguous bare original slugs before falling through to backend execution.
32
+ * Agents receive final slugs (LOCAL_<TOOLKIT>_<TOOL>) from schemas, while bare original
33
+ * slugs are only a convenience for manual session.execute() calls when unique.
34
+ */
35
+ export function assertUnambiguousCustomToolSlug(
36
+ map: CustomToolsMap | undefined,
37
+ slug: string
38
+ ): void {
39
+ if (!map) return;
40
+ const upper = slug.toUpperCase();
41
+ if (!map.ambiguousOriginalSlugs?.has(upper)) return;
42
+
43
+ const finalSlugs = [...map.byFinalSlug.values()]
44
+ .filter(entry => entry.handle.slug.toUpperCase() === upper)
45
+ .map(entry => entry.finalSlug)
46
+ .sort();
47
+ const hint = finalSlugs.length ? ` Use one of: ${finalSlugs.join(', ')}.` : '';
48
+
49
+ throw new ValidationError(
50
+ `Ambiguous custom tool slug "${slug}". Multiple custom toolkit tools share this original slug; ` +
51
+ `manual session.execute() by original slug is only supported when the original slug is unique.` +
52
+ hint
53
+ );
54
+ }
55
+
56
+ /**
57
+ * Execute a custom tool in-process.
58
+ * Validates input via the Zod schema, calls the user's execute function,
59
+ * and wraps the result into the standard response format.
60
+ *
61
+ * Callers provide a pre-built SessionContext (which may include sibling routing).
62
+ */
63
+ export async function executeCustomTool(
64
+ entry: CustomToolsMapEntry,
65
+ arguments_: Record<string, unknown>,
66
+ sessionContext: SessionContext,
67
+ options?: { signal?: AbortSignal }
68
+ ): Promise<ToolExecuteResponse> {
69
+ const { handle } = entry;
70
+
71
+ if (options?.signal?.aborted) {
72
+ throw new ComposioRequestCancelledError();
73
+ }
74
+
75
+ // Validate and transform input using the original Zod schema.
76
+ // This applies defaults, coercions, and transforms (e.g. z.string().default('all')).
77
+ const parsed = handle.inputParams.safeParse(arguments_);
78
+ if (!parsed.success) {
79
+ return {
80
+ data: {},
81
+ error: `Input validation failed: ${parsed.error.message}`,
82
+ successful: false,
83
+ };
84
+ }
85
+ if (options?.signal?.aborted) {
86
+ throw new ComposioRequestCancelledError();
87
+ }
88
+
89
+ try {
90
+ // Object.create preserves prototype methods (execute, proxyExecute) that spread would drop
91
+ const ctxWithSignal: SessionContext = options?.signal
92
+ ? Object.assign(Object.create(sessionContext as object) as SessionContext, {
93
+ signal: options.signal,
94
+ })
95
+ : sessionContext;
96
+ const data = await handle.execute(parsed.data, ctxWithSignal);
97
+ return {
98
+ data: data ?? {},
99
+ error: null,
100
+ successful: true,
101
+ };
102
+ } catch (err: unknown) {
103
+ if (err instanceof ComposioRequestCancelledError) {
104
+ throw err;
105
+ }
106
+ if (options?.signal?.aborted && isRequestAbortError(err)) {
107
+ throw new ComposioRequestCancelledError(undefined, {
108
+ cause: err instanceof Error ? err : undefined,
109
+ });
110
+ }
111
+ const message = err instanceof Error ? err.message : String(err);
112
+ return {
113
+ data: {},
114
+ error: message,
115
+ successful: false,
116
+ };
117
+ }
118
+ }
@@ -0,0 +1,17 @@
1
+ import type {
2
+ SessionExecuteParams,
3
+ SessionSearchParams,
4
+ } from '@composio/client/resources/tool-router/session/session.mjs';
5
+ import type { InlineCustomToolsWirePayload } from '../types/customTool.types';
6
+
7
+ type InlineCustomToolsExperimental =
8
+ | SessionExecuteParams.Experimental
9
+ | SessionSearchParams.Experimental;
10
+
11
+ export function inlineCustomToolsExperimental<TExperimental extends InlineCustomToolsExperimental>(
12
+ payload?: InlineCustomToolsWirePayload
13
+ ): TExperimental | undefined {
14
+ // Stainless generates endpoint-specific experimental types with the same custom
15
+ // definition shape, so this helper centralizes the structural cast.
16
+ return payload as TExperimental | undefined;
17
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @fileoverview Shared transform for converting SDK SessionProxyExecuteParams
3
+ * to the official @composio/client proxy execute params.
4
+ */
5
+ import type { SessionProxyExecuteParams } from '../types/toolRouter.types';
6
+ import type { SessionProxyExecuteParams as ClientProxyExecuteParams } from '@composio/client/resources/tool-router/session/session.mjs';
7
+
8
+ /**
9
+ * Transform SDK session proxy params to the official client request format.
10
+ * Converts SDK-facing `toolkit` → `toolkit_slug` and `parameters[].in` → `parameters[].type`.
11
+ */
12
+ export function transformProxyParams(params: SessionProxyExecuteParams): ClientProxyExecuteParams {
13
+ const parameters: ClientProxyExecuteParams['parameters'] = params.parameters?.map(p => ({
14
+ name: p.name,
15
+ type: p.in as 'header' | 'query',
16
+ value: p.value.toString(),
17
+ }));
18
+
19
+ return {
20
+ toolkit_slug: params.toolkit,
21
+ endpoint: params.endpoint,
22
+ method: params.method,
23
+ ...(params.body !== undefined ? { body: params.body } : {}),
24
+ ...(parameters?.length ? { parameters } : {}),
25
+ };
26
+ }
@@ -0,0 +1,138 @@
1
+ import { ComposioGlobalExecuteToolFnNotSetError } from '../errors/ToolErrors';
2
+ import { ExecuteToolModifiers } from '../types/modifiers.types';
3
+ import type { Tool, ToolExecuteParams, ToolExecuteResponse } from '../types/tool.types';
4
+ import { ExecuteToolFn, GlobalExecuteToolFn } from '../types/provider.types';
5
+ import { McpUrlResponse, McpServerGetResponse } from '../types/mcp.types';
6
+
7
+ /**
8
+ * @internal
9
+ * Base class for all providers.
10
+ * This class is not meant to be used directly, but rather to be extended by different provider implementations.
11
+ */
12
+ abstract class BaseProvider<TMcpResponse> {
13
+ /**
14
+ * @public
15
+ * The name of the provider.
16
+ * Used to identify the provider in the telemetry.
17
+ */
18
+ abstract readonly name: string;
19
+ /**
20
+ * @internal
21
+ * Whether the provider is agentic.
22
+ * This is set automatically set by the core SDK implementation for different provider types.
23
+ */
24
+ abstract readonly _isAgentic: boolean;
25
+ /**
26
+ * @internal
27
+ * The function to execute a tool.
28
+ * This is set automatically injected by the core SDK.
29
+ */
30
+ private _globalExecuteToolFn!: GlobalExecuteToolFn;
31
+ /**
32
+ * @internal
33
+ * Set the function to execute a tool.
34
+ * This is set automatically and injected by the core SDK.
35
+ */
36
+ _setExecuteToolFn(executeToolFn: GlobalExecuteToolFn): void {
37
+ this._globalExecuteToolFn = executeToolFn;
38
+ }
39
+
40
+ /**
41
+ * @public
42
+ * Global function to execute a tool.
43
+ * This function is used by providers to implement helper functions to execute tools.
44
+ * This is a 1:1 mapping of the `execute` method in the `Tools` class.
45
+ * @param {string} toolSlug - The slug of the tool to execute.
46
+ * @param {ToolExecuteParams} body - The body of the tool execution.
47
+ * @param {ExecuteToolModifiers} modifers - The modifiers of the tool execution.
48
+ * @returns {Promise<string>} The result of the tool execution.
49
+ */
50
+ executeTool(
51
+ toolSlug: string,
52
+ body: ToolExecuteParams,
53
+ modifers?: ExecuteToolModifiers
54
+ ): Promise<ToolExecuteResponse> {
55
+ if (!this._globalExecuteToolFn) {
56
+ throw new ComposioGlobalExecuteToolFnNotSetError('executeToolFn is not set');
57
+ }
58
+
59
+ // For provider controlled execution, always skip version check.
60
+ return this._globalExecuteToolFn(toolSlug, body, modifers);
61
+ }
62
+
63
+ /**
64
+ * @public
65
+ * @deprecated: Will be removed in a future version, once the `experimental.mcp` flag is stabilized. Use `wrapMcpServers` instead.
66
+ * Optional method to transform MCP URL response into provider-specific format.
67
+ * Providers can override this method to define custom transformation logic
68
+ * for MCP server responses.
69
+ *
70
+ * @param data - The MCP URL response data
71
+
72
+ * @returns Transformed response in provider-specific format, or undefined to use default transformation
73
+ */
74
+ wrapMcpServerResponse?(data: McpUrlResponse): TMcpResponse;
75
+ }
76
+
77
+ /**
78
+ * @public
79
+ * Base class for all non-agentic providers.
80
+ * This class is not meant to be used directly, but rather to be extended by concrete provider implementations.
81
+ */
82
+ export abstract class BaseNonAgenticProvider<
83
+ TToolCollection,
84
+ TTool,
85
+ TMcpResponse = McpServerGetResponse,
86
+ > extends BaseProvider<TMcpResponse> {
87
+ override readonly _isAgentic = false;
88
+
89
+ /**
90
+ * Wrap a tool in the provider specific format.
91
+ * @param tool - The tool to wrap.
92
+ * @returns The wrapped tool.
93
+ */
94
+ abstract wrapTool(tool: Tool): TTool;
95
+ /**
96
+ * Wrap a list of tools in the provider specific format.
97
+ * @param tools - The tools to wrap.
98
+ * @returns The wrapped tools.
99
+ */
100
+ abstract wrapTools(tools: Tool[]): TToolCollection;
101
+ }
102
+
103
+ /**
104
+ * @public
105
+ * Base class for all agentic providers.
106
+ * This class is not meant to be used directly, but rather to be extended by concrete provider implementations.
107
+ */
108
+ export abstract class BaseAgenticProvider<
109
+ TToolCollection,
110
+ TTool,
111
+ TMcpResponse,
112
+ > extends BaseProvider<TMcpResponse> {
113
+ override readonly _isAgentic = true;
114
+
115
+ /**
116
+ * Wrap a tool in the provider specific format.
117
+ * @param tool - The tool to wrap.
118
+ * @param executeTool - The function to execute the tool.
119
+ * @returns The wrapped tool.
120
+ */
121
+ abstract wrapTool(tool: Tool, executeTool: ExecuteToolFn): TTool;
122
+ /**
123
+ * Wrap a list of tools in the provider specific format.
124
+ * @param tools - The tools to wrap.
125
+ * @param executeTool - The function to execute the tool.
126
+ * @returns The wrapped tools.
127
+ */
128
+ abstract wrapTools(tools: Tool[], executeTool: ExecuteToolFn): TToolCollection;
129
+ }
130
+
131
+ /**
132
+ * @internal
133
+ * Base type for all providers.
134
+ * This type is used to infer the type of the provider from the provider implementation.
135
+ */
136
+ export type BaseComposioProvider<TToolCollection, TTool, TMcpResponse = McpServerGetResponse> =
137
+ | BaseNonAgenticProvider<TToolCollection, TTool, TMcpResponse>
138
+ | BaseAgenticProvider<TToolCollection, TTool, TMcpResponse>;
@@ -0,0 +1,29 @@
1
+ import { McpServerGetResponse } from '../types/mcp.types';
2
+ import { Tool } from '../types/tool.types';
3
+ import { BaseNonAgenticProvider } from './BaseProvider';
4
+
5
+ /**
6
+ * This is a default provider implementation for Composio.
7
+ * This class is used as a default provider for Composio, if the user does not provide a provider.
8
+ *
9
+ * This class shouldn't be used directly or to be extended.
10
+ */
11
+
12
+ interface CustomTool {
13
+ name: string;
14
+ }
15
+ export class ComposioProvider extends BaseNonAgenticProvider<Array<CustomTool>, CustomTool> {
16
+ readonly name = 'ComposioProvider';
17
+
18
+ constructor() {
19
+ super();
20
+ }
21
+
22
+ wrapTool = (tool: Tool): CustomTool => {
23
+ return tool as CustomTool;
24
+ };
25
+
26
+ wrapTools(tools: Tool[]): CustomTool[] {
27
+ return tools.map(tool => this.wrapTool(tool));
28
+ }
29
+ }