@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,478 @@
|
|
|
1
|
+
import { Composio as ComposioClient } from '@composio/client';
|
|
2
|
+
import { telemetry } from '../telemetry/Telemetry';
|
|
3
|
+
import {
|
|
4
|
+
MCPConfigCreationParams,
|
|
5
|
+
MCPConfigCreationParamsSchema,
|
|
6
|
+
MCPConfigCreateResponse,
|
|
7
|
+
MCPConfigResponseSchema,
|
|
8
|
+
MCPServerInstance,
|
|
9
|
+
MCPGetInstanceParams,
|
|
10
|
+
MCPGetInstanceParamsSchema,
|
|
11
|
+
MCPListResponse,
|
|
12
|
+
MCPListParams,
|
|
13
|
+
MCPListParamsSchema,
|
|
14
|
+
MCPListResponseSchema,
|
|
15
|
+
MCPItemSchema,
|
|
16
|
+
MCPItem,
|
|
17
|
+
MCPUpdateParams,
|
|
18
|
+
MCPUpdateParamsSchema,
|
|
19
|
+
} from '../types/mcp.experimental.types';
|
|
20
|
+
import { MCPServerInstanceSchema } from '../types/mcp.experimental.types';
|
|
21
|
+
import { ValidationError } from '../errors/ValidationErrors';
|
|
22
|
+
import { transform } from '../utils/transform';
|
|
23
|
+
import { McpUpdateResponse } from '@composio/client/resources.js';
|
|
24
|
+
import { McpRetrieveResponse } from '@composio/client/resources';
|
|
25
|
+
import { ComposioRequestOptions } from '../types/requestOptions.types';
|
|
26
|
+
import { withCancellation } from '../utils/cancellation';
|
|
27
|
+
|
|
28
|
+
function transformMCPItemResponse(response: McpUpdateResponse | McpRetrieveResponse): MCPItem {
|
|
29
|
+
return transform(response)
|
|
30
|
+
.with(MCPItemSchema)
|
|
31
|
+
.using(raw => ({
|
|
32
|
+
name: raw.name,
|
|
33
|
+
allowedTools: raw.allowed_tools,
|
|
34
|
+
id: raw.id,
|
|
35
|
+
authConfigIds: raw.auth_config_ids,
|
|
36
|
+
commands: raw.commands,
|
|
37
|
+
MCPUrl: raw.mcp_url,
|
|
38
|
+
toolkitIcons: raw.toolkit_icons,
|
|
39
|
+
serverInstanceCount: raw.server_instance_count,
|
|
40
|
+
toolkits: raw.toolkits,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* MCP (Model Control Protocol) class
|
|
45
|
+
* Handles MCP server operations.
|
|
46
|
+
* When `config.experimental.mcp` is enabled, this class augments the features of `composio.mcp`.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Use a session's MCP endpoint instead: `composio.create(userId, { mcp: true })`
|
|
49
|
+
* returns a session that exposes `session.mcp.url` / `session.mcp.headers`. MCP is now
|
|
50
|
+
* opt-in per session; the standalone `composio.mcp` server-management API is kept only for
|
|
51
|
+
* backwards compatibility. Prefer the session MCP endpoint; do not generate new code against
|
|
52
|
+
* `composio.mcp`. See https://docs.composio.dev/docs/sessions-via-mcp
|
|
53
|
+
*/
|
|
54
|
+
export class MCP {
|
|
55
|
+
client: ComposioClient;
|
|
56
|
+
|
|
57
|
+
constructor(client: ComposioClient) {
|
|
58
|
+
this.client = client;
|
|
59
|
+
telemetry.instrument(this, 'MCP');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Create a new MCP configuration.
|
|
64
|
+
* @param {Object} params - Parameters for creating the MCP configuration
|
|
65
|
+
* @param {Array} params.authConfig - Array of auth configurations with id and allowed tools
|
|
66
|
+
* @param {Object} params.options - Configuration options
|
|
67
|
+
* @param {string} params.options.name - Unique name for the MCP configuration
|
|
68
|
+
* @param {boolean} [params.options.manuallyManageConnections] - Whether to use chat-based authentication or manually connect accounts
|
|
69
|
+
* @returns {Promise<McpServerCreateResponse<T>>} Created server details with instance getter
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const server = await composio.mcpConfig.create("personal-mcp-server", {
|
|
74
|
+
* toolkits: ["github", "slack"],
|
|
75
|
+
* allowedTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"],
|
|
76
|
+
* manuallyManageConnections: false
|
|
77
|
+
* }
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* const server = await composio.mcpConfig.create("personal-mcp-server", {
|
|
81
|
+
* toolkits: [{ toolkit: "gmail", authConfigId: "ac_243434343" }],
|
|
82
|
+
* allowedTools: ["GMAIL_FETCH_EMAILS"],
|
|
83
|
+
* manuallyManageConnections: false
|
|
84
|
+
* }
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
async create(
|
|
89
|
+
name: string,
|
|
90
|
+
mcpConfig: MCPConfigCreationParams,
|
|
91
|
+
requestOptions?: ComposioRequestOptions
|
|
92
|
+
): Promise<MCPConfigCreateResponse> {
|
|
93
|
+
const config = MCPConfigCreationParamsSchema.safeParse(mcpConfig);
|
|
94
|
+
if (config.error) {
|
|
95
|
+
throw new ValidationError('Invalid parameters passed to create mcp config', {
|
|
96
|
+
cause: config.error,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const toolkits: string[] = [];
|
|
101
|
+
const auth_config_ids: string[] = [];
|
|
102
|
+
const custom_tools: string[] = config.data.allowedTools ?? [];
|
|
103
|
+
|
|
104
|
+
// extract all the toolkits, authconfigs, and allowed tools to separate slugs
|
|
105
|
+
config.data.toolkits.forEach(toolkit => {
|
|
106
|
+
if (typeof toolkit === 'string') {
|
|
107
|
+
toolkits.push(toolkit);
|
|
108
|
+
} else if (toolkit.toolkit) {
|
|
109
|
+
toolkits.push(toolkit.toolkit);
|
|
110
|
+
} else if (toolkit.authConfigId) {
|
|
111
|
+
auth_config_ids.push(toolkit.authConfigId);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const createBody = {
|
|
116
|
+
name,
|
|
117
|
+
toolkits,
|
|
118
|
+
auth_config_ids,
|
|
119
|
+
custom_tools,
|
|
120
|
+
// if manually manage account is set to true, disable composio account management tools
|
|
121
|
+
managed_auth_via_composio: config.data.manuallyManageConnections ? false : true,
|
|
122
|
+
};
|
|
123
|
+
const server = await withCancellation(
|
|
124
|
+
() => this.client.mcp.custom.create(createBody, requestOptions),
|
|
125
|
+
requestOptions?.signal
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const camelCaseServer = transform(server)
|
|
129
|
+
.with(MCPConfigResponseSchema)
|
|
130
|
+
.using(raw => ({
|
|
131
|
+
name: raw.name,
|
|
132
|
+
allowedTools: raw.allowed_tools,
|
|
133
|
+
id: raw.id,
|
|
134
|
+
authConfigIds: raw.auth_config_ids,
|
|
135
|
+
commands: raw.commands,
|
|
136
|
+
MCPUrl: raw.mcp_url,
|
|
137
|
+
}));
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
...camelCaseServer,
|
|
141
|
+
generate: async (userId: string): Promise<MCPServerInstance> => {
|
|
142
|
+
return await this.generate(userId, server.id, {
|
|
143
|
+
manuallyManageConnections: config.data.manuallyManageConnections,
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* List the MCP servers with optional filtering and pagination
|
|
151
|
+
* @param {Object} options - Filtering and pagination options
|
|
152
|
+
* @param {number} [options.page=1] - Page number for pagination (1-based)
|
|
153
|
+
* @param {number} [options.limit=10] - Maximum number of items to return per page
|
|
154
|
+
* @param {string[]} [options.toolkits=[]] - Array of toolkit names to filter by
|
|
155
|
+
* @param {string[]} [options.authConfigs=[]] - Array of auth configuration IDs to filter by
|
|
156
|
+
* @param {string} [options.name] - Filter by MCP server name (partial match)
|
|
157
|
+
* @returns {Promise<MCPListResponse>} Paginated list of MCP servers with metadata
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* // List all MCP servers
|
|
162
|
+
* const allServers = await composio.experimental.mcp.list({});
|
|
163
|
+
*
|
|
164
|
+
* // List with pagination
|
|
165
|
+
* const pagedServers = await composio.experimental.mcp.list({
|
|
166
|
+
* page: 2,
|
|
167
|
+
* limit: 5
|
|
168
|
+
* });
|
|
169
|
+
*
|
|
170
|
+
* // Filter by toolkit
|
|
171
|
+
* const githubServers = await composio.experimental.mcp.list({
|
|
172
|
+
* toolkits: ['github', 'slack']
|
|
173
|
+
* });
|
|
174
|
+
*
|
|
175
|
+
* // Filter by name
|
|
176
|
+
* const namedServers = await composio.experimental.mcp.list({
|
|
177
|
+
* name: 'personal'
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
async list(
|
|
182
|
+
options: MCPListParams,
|
|
183
|
+
requestOptions?: ComposioRequestOptions
|
|
184
|
+
): Promise<MCPListResponse> {
|
|
185
|
+
const { data: params, error } = MCPListParamsSchema.safeParse(options);
|
|
186
|
+
if (error) {
|
|
187
|
+
throw new ValidationError('Failed to validate list options', {
|
|
188
|
+
cause: error,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const listParams = {
|
|
193
|
+
page_no: params.page,
|
|
194
|
+
limit: params.limit,
|
|
195
|
+
toolkits: params.toolkits?.length > 0 ? params.toolkits.join(',') : undefined,
|
|
196
|
+
auth_config_ids: params.authConfigs?.length > 0 ? params.authConfigs.join(',') : undefined,
|
|
197
|
+
name: params.name,
|
|
198
|
+
};
|
|
199
|
+
const listResponse = await withCancellation(
|
|
200
|
+
() => this.client.mcp.list(listParams, requestOptions),
|
|
201
|
+
requestOptions?.signal
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const transformedListResponse = transform(listResponse)
|
|
205
|
+
.with(MCPListResponseSchema)
|
|
206
|
+
.using(raw => ({
|
|
207
|
+
currentPage: raw.current_page,
|
|
208
|
+
totalPages: raw.total_pages,
|
|
209
|
+
items: raw.items.map(item => ({
|
|
210
|
+
name: item.name,
|
|
211
|
+
allowedTools: item.allowed_tools,
|
|
212
|
+
id: item.id,
|
|
213
|
+
authConfigIds: item.auth_config_ids,
|
|
214
|
+
commands: item.commands,
|
|
215
|
+
MCPUrl: item.mcp_url,
|
|
216
|
+
toolkitIcons: item.toolkit_icons,
|
|
217
|
+
serverInstanceCount: item.server_instance_count,
|
|
218
|
+
toolkits: item.toolkits,
|
|
219
|
+
})),
|
|
220
|
+
}));
|
|
221
|
+
|
|
222
|
+
return transformedListResponse;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Retrieve detailed information about a specific MCP server by its ID
|
|
227
|
+
* @param {string} serverId - The unique identifier of the MCP server to retrieve
|
|
228
|
+
* @returns {Promise<MCPItem>} Complete MCP server details including configuration, tools, and metadata
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* // Get a specific MCP server by ID
|
|
233
|
+
* const server = await composio.experimental.mcp.get("mcp_12345");
|
|
234
|
+
*
|
|
235
|
+
* console.log(server.name); // "My Personal MCP Server"
|
|
236
|
+
* console.log(server.allowedTools); // ["GITHUB_CREATE_ISSUE", "SLACK_SEND_MESSAGE"]
|
|
237
|
+
* console.log(server.toolkits); // ["github", "slack"]
|
|
238
|
+
* console.log(server.serverInstanceCount); // 3
|
|
239
|
+
*
|
|
240
|
+
* // Access setup commands for different clients
|
|
241
|
+
* console.log(server.commands.claude); // Claude setup command
|
|
242
|
+
* console.log(server.commands.cursor); // Cursor setup command
|
|
243
|
+
* console.log(server.commands.windsurf); // Windsurf setup command
|
|
244
|
+
*
|
|
245
|
+
* // Use the MCP URL for direct connections
|
|
246
|
+
* const mcpUrl = server.MCPUrl;
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @throws {ValidationError} When the server ID is invalid or server not found
|
|
250
|
+
*/
|
|
251
|
+
async get(serverId: string, requestOptions?: ComposioRequestOptions): Promise<MCPItem> {
|
|
252
|
+
const response = await withCancellation(
|
|
253
|
+
() => this.client.mcp.retrieve(serverId, requestOptions),
|
|
254
|
+
requestOptions?.signal
|
|
255
|
+
);
|
|
256
|
+
return transformMCPItemResponse(response);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Delete an MCP server configuration permanently
|
|
261
|
+
* @param {string} serverId - The unique identifier of the MCP server to delete
|
|
262
|
+
* @returns {Promise<{id: string; deleted: boolean}>} Confirmation object with server ID and deletion status
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* // Delete an MCP server by ID
|
|
267
|
+
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
268
|
+
*
|
|
269
|
+
* if (result.deleted) {
|
|
270
|
+
* console.log(`Server ${result.id} has been successfully deleted`);
|
|
271
|
+
* } else {
|
|
272
|
+
* console.log(`Failed to delete server ${result.id}`);
|
|
273
|
+
* }
|
|
274
|
+
*
|
|
275
|
+
* // Example with error handling
|
|
276
|
+
* try {
|
|
277
|
+
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
278
|
+
* console.log("Deletion successful:", result);
|
|
279
|
+
* } catch (error) {
|
|
280
|
+
* console.error("Failed to delete MCP server:", error.message);
|
|
281
|
+
* }
|
|
282
|
+
*
|
|
283
|
+
* // Delete and verify from list
|
|
284
|
+
* await composio.experimental.mcp.delete("mcp_12345");
|
|
285
|
+
* const servers = await composio.experimental.mcp.list({});
|
|
286
|
+
* const serverExists = servers.items.some(server => server.id === "mcp_12345");
|
|
287
|
+
* console.log("Server still exists:", serverExists); // Should be false
|
|
288
|
+
* ```
|
|
289
|
+
*
|
|
290
|
+
* @throws {ValidationError} When the server ID is invalid or server not found
|
|
291
|
+
* @throws {Error} When the server cannot be deleted due to active connections or other constraints
|
|
292
|
+
*
|
|
293
|
+
* @warning This operation is irreversible. Once deleted, the MCP server configuration and all its associated data will be permanently removed.
|
|
294
|
+
*/
|
|
295
|
+
async delete(
|
|
296
|
+
serverId: string,
|
|
297
|
+
requestOptions?: ComposioRequestOptions
|
|
298
|
+
): Promise<{ id: string; deleted: boolean }> {
|
|
299
|
+
return withCancellation(
|
|
300
|
+
() => this.client.mcp.delete(serverId, requestOptions),
|
|
301
|
+
requestOptions?.signal
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Update an existing MCP server configuration with new settings
|
|
307
|
+
* @param {string} serverId - The unique identifier of the MCP server to update
|
|
308
|
+
* @param {Object} config - Update configuration parameters
|
|
309
|
+
* @param {string} [config.name] - New name for the MCP server
|
|
310
|
+
* @param {Array} [config.toolkits] - Updated toolkit configurations
|
|
311
|
+
* @param {string} [config.toolkits[].toolkit] - Toolkit identifier (e.g., "github", "slack")
|
|
312
|
+
* @param {string} [config.toolkits[].authConfigId] - Auth configuration ID for the toolkit
|
|
313
|
+
* @param {string[]} [config.toolkits[].allowedTools] - Specific tools to enable for this toolkit
|
|
314
|
+
* @param {boolean} [config.manuallyManageConnections] - Whether to manually manage account connections
|
|
315
|
+
* @returns {Promise<MCPItem>} Updated MCP server configuration with all details
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```typescript
|
|
319
|
+
* // Update server name only
|
|
320
|
+
* const updatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
321
|
+
* name: "My Updated MCP Server"
|
|
322
|
+
* });
|
|
323
|
+
*
|
|
324
|
+
* // Update toolkits and tools
|
|
325
|
+
* const serverWithNewTools = await composio.experimental.mcp.update("mcp_12345", {
|
|
326
|
+
* toolkits: [
|
|
327
|
+
* {
|
|
328
|
+
* toolkit: "github",
|
|
329
|
+
* authConfigId: "auth_abc123",
|
|
330
|
+
* allowedTools: ["GITHUB_CREATE_ISSUE", "GITHUB_LIST_REPOS"]
|
|
331
|
+
* },
|
|
332
|
+
* {
|
|
333
|
+
* toolkit: "slack",
|
|
334
|
+
* authConfigId: "auth_xyz789",
|
|
335
|
+
* allowedTools: ["SLACK_SEND_MESSAGE", "SLACK_LIST_CHANNELS"]
|
|
336
|
+
* }
|
|
337
|
+
* ]
|
|
338
|
+
* });
|
|
339
|
+
*
|
|
340
|
+
* // Update connection management setting
|
|
341
|
+
* const serverWithManualAuth = await composio.experimental.mcp.update("mcp_12345", {
|
|
342
|
+
* name: "Manual Auth Server",
|
|
343
|
+
* manuallyManageConnections: true
|
|
344
|
+
* });
|
|
345
|
+
*
|
|
346
|
+
* // Complete update example
|
|
347
|
+
* const fullyUpdatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
348
|
+
* name: "Production MCP Server",
|
|
349
|
+
* toolkits: [
|
|
350
|
+
* {
|
|
351
|
+
* toolkit: "gmail",
|
|
352
|
+
* authConfigId: "auth_gmail_prod",
|
|
353
|
+
* }
|
|
354
|
+
* ],
|
|
355
|
+
* allowedTools: ["GMAIL_SEND_EMAIL", "GMAIL_FETCH_EMAILS"]
|
|
356
|
+
* manuallyManageConnections: false
|
|
357
|
+
* });
|
|
358
|
+
*
|
|
359
|
+
* console.log("Updated server:", fullyUpdatedServer.name);
|
|
360
|
+
* console.log("New tools:", fullyUpdatedServer.allowedTools);
|
|
361
|
+
* ```
|
|
362
|
+
*
|
|
363
|
+
* @throws {ValidationError} When the update parameters are invalid or malformed
|
|
364
|
+
* @throws {Error} When the server ID doesn't exist or update fails
|
|
365
|
+
*
|
|
366
|
+
* @note Only provided fields will be updated. Omitted fields will retain their current values.
|
|
367
|
+
* @note When updating toolkits, the entire toolkit configuration is replaced, not merged.
|
|
368
|
+
*/
|
|
369
|
+
async update(
|
|
370
|
+
serverId: string,
|
|
371
|
+
config: MCPUpdateParams,
|
|
372
|
+
requestOptions?: ComposioRequestOptions
|
|
373
|
+
): Promise<MCPItem> {
|
|
374
|
+
const { data: params, error } = MCPUpdateParamsSchema.safeParse(config);
|
|
375
|
+
if (error) {
|
|
376
|
+
throw new ValidationError('Failed to validate update params', {
|
|
377
|
+
cause: error,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const toolkits: string[] = [];
|
|
382
|
+
const auth_config_ids: string[] = [];
|
|
383
|
+
const custom_tools: string[] | undefined = params.allowedTools ?? undefined;
|
|
384
|
+
|
|
385
|
+
// extract all the toolkits, authconfigs, and allowed tools to separate slugs
|
|
386
|
+
params.toolkits?.forEach(toolkit => {
|
|
387
|
+
if (typeof toolkit === 'string') {
|
|
388
|
+
toolkits.push(toolkit);
|
|
389
|
+
} else if (toolkit.toolkit) {
|
|
390
|
+
toolkits.push(toolkit.toolkit);
|
|
391
|
+
} else if (toolkit.authConfigId) {
|
|
392
|
+
auth_config_ids.push(toolkit.authConfigId);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
const updateBody = {
|
|
396
|
+
...{ name: params.name ?? undefined },
|
|
397
|
+
...(params.toolkits
|
|
398
|
+
? {
|
|
399
|
+
custom_tools: custom_tools,
|
|
400
|
+
toolkits: toolkits,
|
|
401
|
+
auth_config_ids: auth_config_ids,
|
|
402
|
+
}
|
|
403
|
+
: {}),
|
|
404
|
+
...{ managed_auth_via_composio: params.manuallyManageConnections ?? undefined },
|
|
405
|
+
};
|
|
406
|
+
const response = await withCancellation(
|
|
407
|
+
() => this.client.mcp.update(serverId, updateBody, requestOptions),
|
|
408
|
+
requestOptions?.signal
|
|
409
|
+
);
|
|
410
|
+
return transformMCPItemResponse(response);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Get server URLs for an existing MCP server.
|
|
415
|
+
* The response is wrapped according to the provider's specifications.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```typescript
|
|
419
|
+
* import { Composio } from "@composio/code";
|
|
420
|
+
*
|
|
421
|
+
* const composio = new Composio();
|
|
422
|
+
* const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>");
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* @param userId {string} external user id from your database for whom you want the server for
|
|
426
|
+
* @param mcpConfigId {string} config id of the MCPConfig for which you want to create a server for
|
|
427
|
+
* @param options {object} additional options
|
|
428
|
+
* @param options.isChatAuth {boolean} Authenticate the users via chat when they use the MCP Server
|
|
429
|
+
*/
|
|
430
|
+
async generate(
|
|
431
|
+
userId: string,
|
|
432
|
+
mcpConfigId: string,
|
|
433
|
+
options?: MCPGetInstanceParams,
|
|
434
|
+
requestOptions?: ComposioRequestOptions
|
|
435
|
+
): Promise<MCPServerInstance> {
|
|
436
|
+
const server = await withCancellation(
|
|
437
|
+
() => this.client.mcp.retrieve(mcpConfigId, requestOptions),
|
|
438
|
+
requestOptions?.signal
|
|
439
|
+
);
|
|
440
|
+
const params = MCPGetInstanceParamsSchema.safeParse(
|
|
441
|
+
options ?? { manuallyManageConnections: false }
|
|
442
|
+
);
|
|
443
|
+
if (params.error) {
|
|
444
|
+
throw new ValidationError('Invalid params passed for Get Instance Params', {
|
|
445
|
+
cause: params.error,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const urlBody = {
|
|
450
|
+
mcp_server_id: mcpConfigId,
|
|
451
|
+
user_ids: [userId],
|
|
452
|
+
managed_auth_by_composio: options?.manuallyManageConnections ? false : true,
|
|
453
|
+
};
|
|
454
|
+
const urlResponse = await withCancellation(
|
|
455
|
+
() => this.client.mcp.generate.url(urlBody, requestOptions),
|
|
456
|
+
requestOptions?.signal
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
const userIdsURL = urlResponse.user_ids_url[0];
|
|
460
|
+
const serverInstance = MCPServerInstanceSchema.safeParse({
|
|
461
|
+
id: server.id,
|
|
462
|
+
name: server.name,
|
|
463
|
+
type: 'streamable_http' as const,
|
|
464
|
+
url: userIdsURL,
|
|
465
|
+
userId: userId,
|
|
466
|
+
allowedTools: server.allowed_tools,
|
|
467
|
+
authConfigs: server.auth_config_ids,
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
if (serverInstance.error) {
|
|
471
|
+
throw new ValidationError('Failed to parse MCP server instance', {
|
|
472
|
+
cause: serverInstance.error,
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return serverInstance.data;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { platform } from '#platform';
|
|
2
|
+
import { COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME } from '../utils/constants';
|
|
3
|
+
|
|
4
|
+
function getParentDir(filePath: string): string {
|
|
5
|
+
const lastSep = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
|
|
6
|
+
if (lastSep <= 0) return '';
|
|
7
|
+
return filePath.slice(0, lastSep);
|
|
8
|
+
}
|
|
9
|
+
import { RemoteFileData, RemoteFileDataSchema } from '../types/ToolRouterSessionFilesMount.types';
|
|
10
|
+
import { RemoteFileDownloadError, ValidationError } from '../errors';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Represents a file stored in a tool router session's file mount.
|
|
14
|
+
* Provides methods to fetch, save, and work with the file content.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const remoteFile = await session.experimental.files.download('/output/report.pdf');
|
|
19
|
+
* const buffer = await remoteFile.buffer();
|
|
20
|
+
* await remoteFile.save('/tmp/report.pdf');
|
|
21
|
+
* const text = await remoteFile.text();
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Create from API response (snake_case)
|
|
27
|
+
* const remoteFile = RemoteFile.parse(apiResponse);
|
|
28
|
+
*
|
|
29
|
+
* // Or create from parsed data (camelCase)
|
|
30
|
+
* const remoteFile = new RemoteFile({
|
|
31
|
+
* expiresAt: '...',
|
|
32
|
+
* mountRelativePath: 'report.pdf',
|
|
33
|
+
* sandboxMountPrefix: '/mnt/files',
|
|
34
|
+
* downloadUrl: 'https://...',
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export class RemoteFile {
|
|
39
|
+
/** ISO 8601 timestamp when the download URL expires */
|
|
40
|
+
readonly expiresAt: string;
|
|
41
|
+
|
|
42
|
+
/** Relative path within the mount (e.g. "report.pdf") */
|
|
43
|
+
readonly mountRelativePath: string;
|
|
44
|
+
|
|
45
|
+
/** Absolute mount path inside the sandbox (e.g. /mnt/files) */
|
|
46
|
+
readonly sandboxMountPrefix: string;
|
|
47
|
+
|
|
48
|
+
/** Presigned URL for downloading the file */
|
|
49
|
+
readonly downloadUrl: string;
|
|
50
|
+
|
|
51
|
+
constructor(data: RemoteFileData) {
|
|
52
|
+
this.expiresAt = data.expiresAt;
|
|
53
|
+
this.mountRelativePath = data.mountRelativePath;
|
|
54
|
+
this.sandboxMountPrefix = data.sandboxMountPrefix;
|
|
55
|
+
this.downloadUrl = data.downloadUrl;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Parses an API response (snake_case) and returns a RemoteFile instance.
|
|
60
|
+
* @param data - Raw API response with snake_case keys
|
|
61
|
+
* @returns A RemoteFile instance
|
|
62
|
+
* @throws ValidationError if the response shape is invalid
|
|
63
|
+
*/
|
|
64
|
+
static parse(data: unknown): RemoteFile {
|
|
65
|
+
const parsed = RemoteFileDataSchema.safeParse(data);
|
|
66
|
+
if (!parsed.success) {
|
|
67
|
+
throw new ValidationError('Failed to parse remote file response', {
|
|
68
|
+
cause: parsed.error,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return new RemoteFile(parsed.data);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Filename extracted from the mount path (e.g. "report.pdf" from "output/report.pdf") */
|
|
75
|
+
get filename(): string {
|
|
76
|
+
return platform.basename(this.mountRelativePath);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Fetches the file content as a buffer.
|
|
81
|
+
* @returns The file content as a Uint8Array
|
|
82
|
+
* @throws RemoteFileDownloadError if the fetch fails
|
|
83
|
+
*/
|
|
84
|
+
async buffer(): Promise<Uint8Array> {
|
|
85
|
+
const response = await fetch(this.downloadUrl);
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
throw new RemoteFileDownloadError(
|
|
88
|
+
`Failed to download file: ${response.status} ${response.statusText}`,
|
|
89
|
+
{
|
|
90
|
+
statusCode: response.status,
|
|
91
|
+
statusText: response.statusText,
|
|
92
|
+
downloadUrl: this.downloadUrl,
|
|
93
|
+
mountRelativePath: this.mountRelativePath,
|
|
94
|
+
filename: this.filename,
|
|
95
|
+
cause: new Error(`HTTP ${response.status}: ${response.statusText}`),
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
100
|
+
return new Uint8Array(arrayBuffer);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Fetches the file content as UTF-8 text.
|
|
105
|
+
* @returns The file content as a string
|
|
106
|
+
* @throws Error if the fetch fails
|
|
107
|
+
*/
|
|
108
|
+
async text(): Promise<string> {
|
|
109
|
+
const buf = await this.buffer();
|
|
110
|
+
return new TextDecoder().decode(buf);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Fetches the file content as a Blob.
|
|
115
|
+
* @returns The file content as a Blob
|
|
116
|
+
* @throws RemoteFileDownloadError if the fetch fails
|
|
117
|
+
*/
|
|
118
|
+
async blob(): Promise<Blob> {
|
|
119
|
+
const response = await fetch(this.downloadUrl);
|
|
120
|
+
if (!response.ok) {
|
|
121
|
+
throw new RemoteFileDownloadError(
|
|
122
|
+
`Failed to download file: ${response.status} ${response.statusText}`,
|
|
123
|
+
{
|
|
124
|
+
statusCode: response.status,
|
|
125
|
+
statusText: response.statusText,
|
|
126
|
+
downloadUrl: this.downloadUrl,
|
|
127
|
+
mountRelativePath: this.mountRelativePath,
|
|
128
|
+
filename: this.filename,
|
|
129
|
+
cause: new Error(`HTTP ${response.status}: ${response.statusText}`),
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return response.blob();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Downloads and saves the file to the local filesystem.
|
|
138
|
+
* Requires a Node.js runtime with file system support (not available in Cloudflare Workers/Edge).
|
|
139
|
+
*
|
|
140
|
+
* @param path - Local path to save the file. If omitted, saves to the Composio temp directory using the filename from the mount path.
|
|
141
|
+
* @returns The absolute path where the file was saved
|
|
142
|
+
* @throws Error if file system is not supported or the save fails
|
|
143
|
+
*/
|
|
144
|
+
async save(path?: string): Promise<string> {
|
|
145
|
+
if (!platform.supportsFileSystem) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
'File system operations are not supported in this runtime (e.g. Cloudflare Workers). ' +
|
|
148
|
+
'Use buffer(), text(), or blob() to work with the file content in memory, or run in Node.js.'
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const content = await this.buffer();
|
|
153
|
+
const homeDir = platform.homedir();
|
|
154
|
+
if (!homeDir) {
|
|
155
|
+
throw new Error('Cannot determine save location: home directory is not available');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const savePath =
|
|
159
|
+
path ?? platform.joinPath(homeDir, COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME, this.filename);
|
|
160
|
+
|
|
161
|
+
const dir =
|
|
162
|
+
path != null
|
|
163
|
+
? getParentDir(savePath)
|
|
164
|
+
: platform.joinPath(homeDir, COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME);
|
|
165
|
+
if (dir && !platform.existsSync(dir)) {
|
|
166
|
+
platform.mkdirSync(dir);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
platform.writeFileSync(savePath, content);
|
|
170
|
+
return savePath;
|
|
171
|
+
}
|
|
172
|
+
}
|