@cloudbase/cloudbase-mcp 1.8.41 → 1.8.43
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/cli.cjs +336 -127
- package/dist/index.cjs +336 -127
- package/dist/index.js +335 -125
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1247,9 +1247,6 @@ function registerEnvTools(server) {
|
|
|
1247
1247
|
if (error) {
|
|
1248
1248
|
return { content: [{ type: "text", text: error }] };
|
|
1249
1249
|
}
|
|
1250
|
-
if (noEnvs) {
|
|
1251
|
-
return { content: [{ type: "text", text: "当前账户下暂无可用的云开发环境,请先在腾讯云控制台创建环境 https://tcb.cloud.tencent.com/dev?from=AIToolkit" }] };
|
|
1252
|
-
}
|
|
1253
1250
|
if (cancelled) {
|
|
1254
1251
|
return { content: [{ type: "text", text: "用户取消了登录" }] };
|
|
1255
1252
|
}
|
|
@@ -1327,12 +1324,12 @@ function registerEnvTools(server) {
|
|
|
1327
1324
|
switch (action) {
|
|
1328
1325
|
case "list":
|
|
1329
1326
|
try {
|
|
1330
|
-
const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId:
|
|
1327
|
+
const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId: true });
|
|
1331
1328
|
result = await cloudbaseList.env.listEnvs();
|
|
1332
1329
|
}
|
|
1333
1330
|
catch (error) {
|
|
1334
1331
|
(0, logger_js_1.debug)('获取环境列表时出错:', error);
|
|
1335
|
-
return { content: [{ type: "text", text: "
|
|
1332
|
+
return { content: [{ type: "text", text: "获取环境列表时出错: " + (error instanceof Error ? error.message : String(error)) }]
|
|
1336
1333
|
};
|
|
1337
1334
|
}
|
|
1338
1335
|
break;
|
|
@@ -22466,11 +22463,11 @@ exports.getEnvId = getEnvId;
|
|
|
22466
22463
|
exports.resetCloudBaseManagerCache = resetCloudBaseManagerCache;
|
|
22467
22464
|
exports.getCloudBaseManager = getCloudBaseManager;
|
|
22468
22465
|
exports.createCloudBaseManagerWithOptions = createCloudBaseManagerWithOptions;
|
|
22466
|
+
const manager_node_1 = __importDefault(__webpack_require__(95492));
|
|
22469
22467
|
const auth_js_1 = __webpack_require__(77291);
|
|
22470
22468
|
const interactive_js_1 = __webpack_require__(3461);
|
|
22471
|
-
const manager_node_1 = __importDefault(__webpack_require__(95492));
|
|
22472
22469
|
const logger_js_1 = __webpack_require__(13039);
|
|
22473
|
-
const ENV_ID_TIMEOUT =
|
|
22470
|
+
const ENV_ID_TIMEOUT = 60000000; // 60000 seconds
|
|
22474
22471
|
// 统一的环境ID管理类
|
|
22475
22472
|
class EnvironmentManager {
|
|
22476
22473
|
cachedEnvId = null;
|
|
@@ -22639,14 +22636,14 @@ exports.saveEnvIdToUserConfig = saveEnvIdToUserConfig;
|
|
|
22639
22636
|
exports.loadEnvIdFromUserConfig = loadEnvIdFromUserConfig;
|
|
22640
22637
|
exports.clearUserEnvId = clearUserEnvId;
|
|
22641
22638
|
exports.autoSetupEnvironmentId = autoSetupEnvironmentId;
|
|
22639
|
+
const promises_1 = __importDefault(__webpack_require__(79748));
|
|
22640
|
+
const os_1 = __importDefault(__webpack_require__(21820));
|
|
22641
|
+
const path_1 = __importDefault(__webpack_require__(39902));
|
|
22642
22642
|
const zod_1 = __webpack_require__(21614);
|
|
22643
|
-
const interactive_server_js_1 = __webpack_require__(92341);
|
|
22644
|
-
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
22645
22643
|
const auth_js_1 = __webpack_require__(77291);
|
|
22644
|
+
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
22645
|
+
const interactive_server_js_1 = __webpack_require__(92341);
|
|
22646
22646
|
const logger_js_1 = __webpack_require__(13039);
|
|
22647
|
-
const promises_1 = __importDefault(__webpack_require__(79748));
|
|
22648
|
-
const path_1 = __importDefault(__webpack_require__(39902));
|
|
22649
|
-
const os_1 = __importDefault(__webpack_require__(21820));
|
|
22650
22647
|
function registerInteractiveTools(server) {
|
|
22651
22648
|
// 统一的交互式对话工具 (cloud-incompatible)
|
|
22652
22649
|
server.registerTool("interactiveDialog", {
|
|
@@ -33813,58 +33810,9 @@ function downloadFile(url) {
|
|
|
33813
33810
|
});
|
|
33814
33811
|
}
|
|
33815
33812
|
function registerDownloadTools(server) {
|
|
33816
|
-
// downloadRemoteFile - 下载远程文件到临时目录 (cloud-incompatible)
|
|
33817
33813
|
server.registerTool("downloadRemoteFile", {
|
|
33818
|
-
title: "下载远程文件到临时目录",
|
|
33819
|
-
description: "下载远程文件到本地临时文件,返回一个系统的绝对路径。适用于需要临时处理文件的场景。",
|
|
33820
|
-
inputSchema: {
|
|
33821
|
-
url: zod_1.z.string().describe("远程文件的 URL 地址")
|
|
33822
|
-
},
|
|
33823
|
-
annotations: {
|
|
33824
|
-
readOnlyHint: false,
|
|
33825
|
-
destructiveHint: false,
|
|
33826
|
-
idempotentHint: false,
|
|
33827
|
-
openWorldHint: true,
|
|
33828
|
-
category: "download"
|
|
33829
|
-
}
|
|
33830
|
-
}, async ({ url }) => {
|
|
33831
|
-
try {
|
|
33832
|
-
const result = await downloadFile(url);
|
|
33833
|
-
return {
|
|
33834
|
-
content: [
|
|
33835
|
-
{
|
|
33836
|
-
type: "text",
|
|
33837
|
-
text: JSON.stringify({
|
|
33838
|
-
success: true,
|
|
33839
|
-
filePath: result.filePath,
|
|
33840
|
-
contentType: result.contentType,
|
|
33841
|
-
fileSize: result.fileSize,
|
|
33842
|
-
message: "文件下载成功到临时目录",
|
|
33843
|
-
note: "文件保存在临时目录中,请注意及时处理"
|
|
33844
|
-
}, null, 2)
|
|
33845
|
-
}
|
|
33846
|
-
]
|
|
33847
|
-
};
|
|
33848
|
-
}
|
|
33849
|
-
catch (error) {
|
|
33850
|
-
return {
|
|
33851
|
-
content: [
|
|
33852
|
-
{
|
|
33853
|
-
type: "text",
|
|
33854
|
-
text: JSON.stringify({
|
|
33855
|
-
success: false,
|
|
33856
|
-
error: error.message,
|
|
33857
|
-
message: "文件下载失败"
|
|
33858
|
-
}, null, 2)
|
|
33859
|
-
}
|
|
33860
|
-
]
|
|
33861
|
-
};
|
|
33862
|
-
}
|
|
33863
|
-
});
|
|
33864
|
-
// downloadRemoteFileToPath - 下载远程文件到指定路径 (cloud-incompatible)
|
|
33865
|
-
server.registerTool("downloadRemoteFileToPath", {
|
|
33866
33814
|
title: "下载远程文件到指定路径",
|
|
33867
|
-
description: "
|
|
33815
|
+
description: "下载远程文件到项目根目录下的指定相对路径。例如:小程序的 Tabbar 等素材图片,必须使用 **png** 格式,可以从 Unsplash、wikimedia【一般选用 500 大小即可、Pexels、Apple 官方 UI 等资源中选择来下载。",
|
|
33868
33816
|
inputSchema: {
|
|
33869
33817
|
url: zod_1.z.string().describe("远程文件的 URL 地址"),
|
|
33870
33818
|
relativePath: zod_1.z.string().describe("相对于项目根目录的路径,例如:'assets/images/logo.png' 或 'docs/api.md'。不允许使用 ../ 等路径遍历操作。")
|
|
@@ -97937,7 +97885,7 @@ function convertToJSONSchema(data) {
|
|
|
97937
97885
|
// 处理枚举类型
|
|
97938
97886
|
if (parsed.type.startsWith('x-enum')) {
|
|
97939
97887
|
schema.properties[parsed.name].type = 'string';
|
|
97940
|
-
schema.properties[parsed.name].format = 'enum';
|
|
97888
|
+
schema.properties[parsed.name].format = 'x-enum';
|
|
97941
97889
|
if (parsed.enumValues) {
|
|
97942
97890
|
schema.properties[parsed.name].enum = parsed.enumValues;
|
|
97943
97891
|
}
|
|
@@ -98124,7 +98072,6 @@ function getSpecialFormat(type) {
|
|
|
98124
98072
|
'x-location': 'x-location',
|
|
98125
98073
|
'x-area-code': 'x-area-code',
|
|
98126
98074
|
'x-file': 'x-file',
|
|
98127
|
-
'x-enum': 'enum',
|
|
98128
98075
|
};
|
|
98129
98076
|
// 只保留这些
|
|
98130
98077
|
return formatMap[type] || null;
|
|
@@ -101615,11 +101562,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
101615
101562
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
101616
101563
|
exports.CLOUDRUN_ACCESS_TYPES = exports.CLOUDRUN_SERVICE_TYPES = void 0;
|
|
101617
101564
|
exports.registerCloudRunTools = registerCloudRunTools;
|
|
101565
|
+
const child_process_1 = __webpack_require__(79646);
|
|
101566
|
+
const fs_1 = __importDefault(__webpack_require__(29021));
|
|
101567
|
+
const path_1 = __importDefault(__webpack_require__(39902));
|
|
101618
101568
|
const zod_1 = __webpack_require__(21614);
|
|
101619
101569
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
101620
|
-
const path_1 = __importDefault(__webpack_require__(39902));
|
|
101621
|
-
const fs_1 = __importDefault(__webpack_require__(29021));
|
|
101622
|
-
const child_process_1 = __webpack_require__(79646);
|
|
101623
101570
|
// CloudRun service types
|
|
101624
101571
|
exports.CLOUDRUN_SERVICE_TYPES = ['function', 'container'];
|
|
101625
101572
|
// CloudRun access types
|
|
@@ -101631,7 +101578,7 @@ const queryCloudRunInputSchema = {
|
|
|
101631
101578
|
pageSize: zod_1.z.number().min(1).max(100).optional().default(10).describe('分页大小,控制每页返回的服务数量。取值范围:1-100,默认值:10。建议根据网络性能和显示需求调整'),
|
|
101632
101579
|
pageNum: zod_1.z.number().min(1).optional().default(1).describe('页码,用于分页查询。从1开始,默认值:1。配合pageSize使用可实现分页浏览'),
|
|
101633
101580
|
serverName: zod_1.z.string().optional().describe('服务名称筛选条件,支持模糊匹配。例如:输入"test"可匹配"test-service"、"my-test-app"等服务名称。留空则查询所有服务'),
|
|
101634
|
-
serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function
|
|
101581
|
+
serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)'),
|
|
101635
101582
|
// Detail operation parameters
|
|
101636
101583
|
detailServerName: zod_1.z.string().optional().describe('要查询详细信息的服务名称。当action为detail时必需提供,必须是已存在的服务名称。可通过list操作获取可用的服务名称列表'),
|
|
101637
101584
|
};
|
|
@@ -101645,7 +101592,7 @@ const ManageCloudRunInputSchema = {
|
|
|
101645
101592
|
OpenAccessTypes: zod_1.z.array(zod_1.z.enum(exports.CLOUDRUN_ACCESS_TYPES)).optional().describe('公网访问类型配置,控制服务的访问权限:WEB=公网访问(默认,可通过HTTPS域名访问),VPC=私有网络访问(仅同VPC内可访问),PRIVATE=内网访问(仅云开发环境内可访问)。可配置多个类型'),
|
|
101646
101593
|
Cpu: zod_1.z.number().positive().optional().describe('CPU规格配置,单位为核。可选值:0.25、0.5、1、2、4、8等。注意:内存规格必须是CPU规格的2倍(如CPU=0.25时内存=0.5,CPU=1时内存=2)。影响服务性能和计费'),
|
|
101647
101594
|
Mem: zod_1.z.number().positive().optional().describe('内存规格配置,单位为GB。可选值:0.5、1、2、4、8、16等。注意:必须是CPU规格的2倍。影响服务性能和计费'),
|
|
101648
|
-
MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0
|
|
101595
|
+
MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0时始终保持指定数量的实例运行(确保快速响应但会增加成本)。建议设置为1以降低冷启动延迟,提升用户体验'),
|
|
101649
101596
|
MaxNum: zod_1.z.number().min(1).optional().describe('最大实例数配置,控制服务的最大运行实例数量。当请求量增加时,服务最多可以扩展到指定数量的实例,超过此数量后将拒绝新的请求。建议根据业务峰值设置'),
|
|
101650
101597
|
Port: zod_1.z.number().min(1).max(65535).optional().describe('服务监听端口配置。函数型服务固定为3000,容器型服务可自定义。服务代码必须监听此端口才能正常接收请求'),
|
|
101651
101598
|
EnvParams: zod_1.z.record(zod_1.z.string()).optional().describe('环境变量配置,用于传递配置信息给服务代码。格式为键值对,如{"DATABASE_URL":"mysql://..."}。敏感信息建议使用环境变量而非硬编码'),
|
|
@@ -101673,6 +101620,7 @@ const ManageCloudRunInputSchema = {
|
|
|
101673
101620
|
}).optional().describe('Agent配置项,仅在createAgent操作时使用'),
|
|
101674
101621
|
// Common parameters
|
|
101675
101622
|
force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,用于跳过确认提示。默认false(需要确认),设置为true时跳过所有确认步骤。删除操作时强烈建议设置为true以避免误操作'),
|
|
101623
|
+
serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型配置:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)。不提供时自动检测:1)现有服务类型 2)有Dockerfile→container 3)有@cloudbase/aiagent-framework依赖→function 4)其他情况→container'),
|
|
101676
101624
|
};
|
|
101677
101625
|
/**
|
|
101678
101626
|
* Check if a project is an Agent project
|
|
@@ -102047,21 +101995,47 @@ for await (let x of res.textStream) {
|
|
|
102047
101995
|
if (!targetPath) {
|
|
102048
101996
|
throw new Error("targetPath is required for deploy operation");
|
|
102049
101997
|
}
|
|
102050
|
-
// Determine service type
|
|
101998
|
+
// Determine service type - use input.serverType if provided, otherwise auto-detect
|
|
102051
101999
|
let serverType;
|
|
102052
|
-
|
|
102053
|
-
|
|
102054
|
-
const details = await cloudrunService.detail({ serverName: input.serverName });
|
|
102055
|
-
serverType = details.BaseInfo?.ServerType || 'function';
|
|
102000
|
+
if (input.serverType) {
|
|
102001
|
+
serverType = input.serverType;
|
|
102056
102002
|
}
|
|
102057
|
-
|
|
102058
|
-
|
|
102059
|
-
|
|
102060
|
-
|
|
102061
|
-
serverType = 'container';
|
|
102003
|
+
else {
|
|
102004
|
+
try {
|
|
102005
|
+
// First try to get existing service details
|
|
102006
|
+
const details = await cloudrunService.detail({ serverName: input.serverName });
|
|
102007
|
+
serverType = details.BaseInfo?.ServerType || 'container';
|
|
102062
102008
|
}
|
|
102063
|
-
|
|
102064
|
-
|
|
102009
|
+
catch (e) {
|
|
102010
|
+
// If service doesn't exist, determine by project structure
|
|
102011
|
+
const dockerfilePath = path_1.default.join(targetPath, 'Dockerfile');
|
|
102012
|
+
if (fs_1.default.existsSync(dockerfilePath)) {
|
|
102013
|
+
serverType = 'container';
|
|
102014
|
+
}
|
|
102015
|
+
else {
|
|
102016
|
+
// Check if it's a Node.js function project (has package.json with specific structure)
|
|
102017
|
+
const packageJsonPath = path_1.default.join(targetPath, 'package.json');
|
|
102018
|
+
if (fs_1.default.existsSync(packageJsonPath)) {
|
|
102019
|
+
try {
|
|
102020
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
|
|
102021
|
+
// If it has function-specific dependencies or scripts, treat as function
|
|
102022
|
+
if (packageJson.dependencies?.['@cloudbase/aiagent-framework'] ||
|
|
102023
|
+
packageJson.scripts?.['dev']?.includes('cloudrun run')) {
|
|
102024
|
+
serverType = 'function';
|
|
102025
|
+
}
|
|
102026
|
+
else {
|
|
102027
|
+
serverType = 'container';
|
|
102028
|
+
}
|
|
102029
|
+
}
|
|
102030
|
+
catch (parseError) {
|
|
102031
|
+
serverType = 'container';
|
|
102032
|
+
}
|
|
102033
|
+
}
|
|
102034
|
+
else {
|
|
102035
|
+
// No package.json, default to container
|
|
102036
|
+
serverType = 'container';
|
|
102037
|
+
}
|
|
102038
|
+
}
|
|
102065
102039
|
}
|
|
102066
102040
|
}
|
|
102067
102041
|
const deployParams = {
|
|
@@ -122142,7 +122116,7 @@ class TelemetryReporter {
|
|
|
122142
122116
|
const nodeVersion = process.version; // Node.js版本
|
|
122143
122117
|
const arch = os_1.default.arch(); // 系统架构
|
|
122144
122118
|
// 从构建时注入的版本号获取MCP版本信息
|
|
122145
|
-
const mcpVersion = process.env.npm_package_version || "1.8.
|
|
122119
|
+
const mcpVersion = process.env.npm_package_version || "1.8.43" || 0;
|
|
122146
122120
|
return {
|
|
122147
122121
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
122148
122122
|
deviceId: this.deviceId,
|
|
@@ -180028,7 +180002,7 @@ ${envIdSection}
|
|
|
180028
180002
|
## 环境信息
|
|
180029
180003
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
180030
180004
|
- Node.js版本: ${process.version}
|
|
180031
|
-
- MCP 版本:${process.env.npm_package_version || "1.8.
|
|
180005
|
+
- MCP 版本:${process.env.npm_package_version || "1.8.43" || 0}
|
|
180032
180006
|
- 系统架构: ${os_1.default.arch()}
|
|
180033
180007
|
- 时间: ${new Date().toISOString()}
|
|
180034
180008
|
- 请求ID: ${requestId}
|
|
@@ -195054,7 +195028,7 @@ function registerSetupTools(server) {
|
|
|
195054
195028
|
// downloadTemplate - 下载项目模板 (cloud-incompatible)
|
|
195055
195029
|
server.registerTool("downloadTemplate", {
|
|
195056
195030
|
title: "下载项目模板",
|
|
195057
|
-
description: `自动下载并部署CloudBase项目模板。\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置(默认)\n- cursor: Cursor AI编辑器\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.
|
|
195031
|
+
description: `自动下载并部署CloudBase项目模板。\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置(默认)\n- cursor: Cursor AI编辑器\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.43" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
195058
195032
|
inputSchema: {
|
|
195059
195033
|
template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
|
|
195060
195034
|
ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
|
|
@@ -196263,9 +196237,9 @@ async function getLoginState() {
|
|
|
196263
196237
|
}
|
|
196264
196238
|
const loginState = await auth.getLoginState();
|
|
196265
196239
|
if (!loginState) {
|
|
196266
|
-
(0, logger_js_1.debug)('loginByApiSecret');
|
|
196267
196240
|
await auth.loginByWebAuth({});
|
|
196268
196241
|
const loginState = await auth.getLoginState();
|
|
196242
|
+
(0, logger_js_1.debug)('loginByWebAuth', loginState);
|
|
196269
196243
|
return loginState;
|
|
196270
196244
|
}
|
|
196271
196245
|
else {
|
|
@@ -219678,7 +219652,11 @@ function shouldRegisterTool(toolName) {
|
|
|
219678
219652
|
'setupEnvironmentId',
|
|
219679
219653
|
'clearUserEnvId',
|
|
219680
219654
|
// Interactive tools - local server and file operations
|
|
219681
|
-
'interactiveDialog'
|
|
219655
|
+
'interactiveDialog',
|
|
219656
|
+
// CloudRun tools - local file operations
|
|
219657
|
+
'manageCloudRun',
|
|
219658
|
+
// Download tools - local file downloads
|
|
219659
|
+
'manageStorage',
|
|
219682
219660
|
];
|
|
219683
219661
|
const shouldRegister = !cloudIncompatibleTools.includes(toolName);
|
|
219684
219662
|
if (!shouldRegister) {
|
|
@@ -228562,8 +228540,8 @@ exports.resetInteractiveServer = resetInteractiveServer;
|
|
|
228562
228540
|
exports.getInteractiveServerSafe = getInteractiveServerSafe;
|
|
228563
228541
|
const express_1 = __importDefault(__webpack_require__(26083));
|
|
228564
228542
|
const http_1 = __importDefault(__webpack_require__(81630));
|
|
228565
|
-
const ws_1 = __webpack_require__(17699);
|
|
228566
228543
|
const open_1 = __importDefault(__webpack_require__(45368));
|
|
228544
|
+
const ws_1 = __webpack_require__(17699);
|
|
228567
228545
|
const logger_js_1 = __webpack_require__(13039);
|
|
228568
228546
|
// 动态导入 open 模块,兼容 ESM/CJS 环境
|
|
228569
228547
|
async function openUrl(url, options, server) {
|
|
@@ -229446,8 +229424,8 @@ class InteractiveServer {
|
|
|
229446
229424
|
</div>
|
|
229447
229425
|
|
|
229448
229426
|
<div class="content">
|
|
229449
|
-
<h1 class="content-title"
|
|
229450
|
-
<p class="content-subtitle"
|
|
229427
|
+
<h1 class="content-title">选择 CloudBase 环境</h1>
|
|
229428
|
+
<p class="content-subtitle">请选择您要使用的 CloudBase 环境</p>
|
|
229451
229429
|
|
|
229452
229430
|
<div class="env-list" id="envList">
|
|
229453
229431
|
${(envs || []).length > 0 ?
|
|
@@ -229464,8 +229442,8 @@ class InteractiveServer {
|
|
|
229464
229442
|
`).join('') :
|
|
229465
229443
|
`
|
|
229466
229444
|
<div class="empty-state">
|
|
229467
|
-
<h3 class="empty-title"
|
|
229468
|
-
<p class="empty-message"
|
|
229445
|
+
<h3 class="empty-title">暂无 CloudBase 环境</h3>
|
|
229446
|
+
<p class="empty-message">当前没有可用的 CloudBase 环境,请新建后重新在 AI 对话中重试</p>
|
|
229469
229447
|
<button class="btn btn-primary create-env-btn" onclick="createNewEnv()">
|
|
229470
229448
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
229471
229449
|
<path d="M12 5v14M5 12h14"/>
|
|
@@ -229503,7 +229481,7 @@ class InteractiveServer {
|
|
|
229503
229481
|
</svg>
|
|
229504
229482
|
</div>
|
|
229505
229483
|
<h2 class="success-title">环境配置成功!</h2>
|
|
229506
|
-
<p class="success-message"
|
|
229484
|
+
<p class="success-message">已成功选择 CloudBase 环境</p>
|
|
229507
229485
|
<div class="selected-env-info">
|
|
229508
229486
|
<span class="env-label">环境 ID:</span>
|
|
229509
229487
|
<span class="env-value" id="selectedEnvDisplay"></span>
|
|
@@ -237134,54 +237112,285 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
237134
237112
|
exports.registerStorageTools = registerStorageTools;
|
|
237135
237113
|
const zod_1 = __webpack_require__(21614);
|
|
237136
237114
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
237115
|
+
// Input schema for queryStorage tool
|
|
237116
|
+
const queryStorageInputSchema = {
|
|
237117
|
+
action: zod_1.z.enum(['list', 'info', 'url']).describe('查询操作类型:list=列出目录下的所有文件,info=获取指定文件的详细信息,url=获取文件的临时下载链接'),
|
|
237118
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt 或 files/(目录)'),
|
|
237119
|
+
maxAge: zod_1.z.number().min(1).max(86400).optional().default(3600).describe('临时链接有效期,单位为秒,取值范围:1-86400,默认值:3600(1小时)')
|
|
237120
|
+
};
|
|
237121
|
+
// Input schema for manageStorage tool
|
|
237122
|
+
const manageStorageInputSchema = {
|
|
237123
|
+
action: zod_1.z.enum(['upload', 'download', 'delete']).describe('管理操作类型:upload=上传文件或目录,download=下载文件或目录,delete=删除文件或目录'),
|
|
237124
|
+
localPath: zod_1.z.string().describe('本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt'),
|
|
237125
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt'),
|
|
237126
|
+
force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,删除操作时建议设置为true以确认删除,默认false'),
|
|
237127
|
+
isDirectory: zod_1.z.boolean().optional().default(false).describe('是否为目录操作,true=目录操作,false=文件操作,默认false')
|
|
237128
|
+
};
|
|
237137
237129
|
function registerStorageTools(server) {
|
|
237138
237130
|
// 获取 cloudBaseOptions,如果没有则为 undefined
|
|
237139
237131
|
const cloudBaseOptions = server.cloudBaseOptions;
|
|
237140
237132
|
// 创建闭包函数来获取 CloudBase Manager
|
|
237141
237133
|
const getManager = () => (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions });
|
|
237142
|
-
//
|
|
237143
|
-
server.registerTool("
|
|
237144
|
-
title: "
|
|
237145
|
-
description: "
|
|
237146
|
-
inputSchema:
|
|
237147
|
-
|
|
237148
|
-
|
|
237149
|
-
|
|
237134
|
+
// Tool 1: queryStorage - 查询存储信息(只读操作)
|
|
237135
|
+
server.registerTool("queryStorage", {
|
|
237136
|
+
title: "查询存储信息",
|
|
237137
|
+
description: "查询云存储信息,支持列出目录文件、获取文件信息、获取临时下载链接等只读操作。返回的文件信息包括文件名、大小、修改时间、下载链接等。",
|
|
237138
|
+
inputSchema: queryStorageInputSchema,
|
|
237139
|
+
annotations: {
|
|
237140
|
+
readOnlyHint: true,
|
|
237141
|
+
openWorldHint: true,
|
|
237142
|
+
category: "storage"
|
|
237143
|
+
}
|
|
237144
|
+
}, async (args) => {
|
|
237145
|
+
try {
|
|
237146
|
+
const input = args;
|
|
237147
|
+
const manager = await getManager();
|
|
237148
|
+
if (!manager) {
|
|
237149
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
237150
|
+
}
|
|
237151
|
+
const storageService = manager.storage;
|
|
237152
|
+
switch (input.action) {
|
|
237153
|
+
case 'list': {
|
|
237154
|
+
const result = await storageService.listDirectoryFiles(input.cloudPath);
|
|
237155
|
+
return {
|
|
237156
|
+
content: [
|
|
237157
|
+
{
|
|
237158
|
+
type: "text",
|
|
237159
|
+
text: JSON.stringify({
|
|
237160
|
+
success: true,
|
|
237161
|
+
data: {
|
|
237162
|
+
action: 'list',
|
|
237163
|
+
cloudPath: input.cloudPath,
|
|
237164
|
+
files: result || [],
|
|
237165
|
+
totalCount: result?.length || 0
|
|
237166
|
+
},
|
|
237167
|
+
message: `Successfully listed ${result?.length || 0} files in directory '${input.cloudPath}'`
|
|
237168
|
+
}, null, 2)
|
|
237169
|
+
}
|
|
237170
|
+
]
|
|
237171
|
+
};
|
|
237172
|
+
}
|
|
237173
|
+
case 'info': {
|
|
237174
|
+
const result = await storageService.getFileInfo(input.cloudPath);
|
|
237175
|
+
return {
|
|
237176
|
+
content: [
|
|
237177
|
+
{
|
|
237178
|
+
type: "text",
|
|
237179
|
+
text: JSON.stringify({
|
|
237180
|
+
success: true,
|
|
237181
|
+
data: {
|
|
237182
|
+
action: 'info',
|
|
237183
|
+
cloudPath: input.cloudPath,
|
|
237184
|
+
fileInfo: result
|
|
237185
|
+
},
|
|
237186
|
+
message: `Successfully retrieved file info for '${input.cloudPath}'`
|
|
237187
|
+
}, null, 2)
|
|
237188
|
+
}
|
|
237189
|
+
]
|
|
237190
|
+
};
|
|
237191
|
+
}
|
|
237192
|
+
case 'url': {
|
|
237193
|
+
const result = await storageService.getTemporaryUrl([{
|
|
237194
|
+
cloudPath: input.cloudPath,
|
|
237195
|
+
maxAge: input.maxAge || 3600
|
|
237196
|
+
}]);
|
|
237197
|
+
return {
|
|
237198
|
+
content: [
|
|
237199
|
+
{
|
|
237200
|
+
type: "text",
|
|
237201
|
+
text: JSON.stringify({
|
|
237202
|
+
success: true,
|
|
237203
|
+
data: {
|
|
237204
|
+
action: 'url',
|
|
237205
|
+
cloudPath: input.cloudPath,
|
|
237206
|
+
temporaryUrl: result[0]?.url || "",
|
|
237207
|
+
expireTime: `${input.maxAge || 3600}秒`,
|
|
237208
|
+
fileId: result[0]?.fileId || ""
|
|
237209
|
+
},
|
|
237210
|
+
message: `Successfully generated temporary URL for '${input.cloudPath}'`
|
|
237211
|
+
}, null, 2)
|
|
237212
|
+
}
|
|
237213
|
+
]
|
|
237214
|
+
};
|
|
237215
|
+
}
|
|
237216
|
+
default:
|
|
237217
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
237218
|
+
}
|
|
237219
|
+
}
|
|
237220
|
+
catch (error) {
|
|
237221
|
+
return {
|
|
237222
|
+
content: [
|
|
237223
|
+
{
|
|
237224
|
+
type: "text",
|
|
237225
|
+
text: JSON.stringify({
|
|
237226
|
+
success: false,
|
|
237227
|
+
error: error.message || 'Unknown error occurred',
|
|
237228
|
+
message: `Failed to query storage information. Please check your permissions and parameters.`
|
|
237229
|
+
}, null, 2)
|
|
237230
|
+
}
|
|
237231
|
+
]
|
|
237232
|
+
};
|
|
237233
|
+
}
|
|
237234
|
+
});
|
|
237235
|
+
// Tool 2: manageStorage - 管理存储文件(写操作)
|
|
237236
|
+
server.registerTool("manageStorage", {
|
|
237237
|
+
title: "管理存储文件",
|
|
237238
|
+
description: "管理云存储文件,支持上传文件/目录、下载文件/目录、删除文件/目录等操作。删除操作需要设置force=true进行确认,防止误删除重要文件。",
|
|
237239
|
+
inputSchema: manageStorageInputSchema,
|
|
237150
237240
|
annotations: {
|
|
237151
237241
|
readOnlyHint: false,
|
|
237152
|
-
destructiveHint:
|
|
237242
|
+
destructiveHint: true,
|
|
237153
237243
|
idempotentHint: false,
|
|
237154
237244
|
openWorldHint: true,
|
|
237155
237245
|
category: "storage"
|
|
237156
237246
|
}
|
|
237157
|
-
}, async (
|
|
237158
|
-
|
|
237159
|
-
|
|
237160
|
-
|
|
237161
|
-
|
|
237162
|
-
|
|
237163
|
-
onProgress: (progressData) => {
|
|
237164
|
-
console.log("Upload progress:", progressData);
|
|
237247
|
+
}, async (args) => {
|
|
237248
|
+
try {
|
|
237249
|
+
const input = args;
|
|
237250
|
+
const manager = await getManager();
|
|
237251
|
+
if (!manager) {
|
|
237252
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
237165
237253
|
}
|
|
237166
|
-
|
|
237167
|
-
|
|
237168
|
-
|
|
237169
|
-
|
|
237170
|
-
|
|
237171
|
-
|
|
237172
|
-
|
|
237173
|
-
|
|
237174
|
-
|
|
237175
|
-
|
|
237176
|
-
|
|
237177
|
-
|
|
237178
|
-
|
|
237179
|
-
|
|
237180
|
-
|
|
237181
|
-
|
|
237254
|
+
const storageService = manager.storage;
|
|
237255
|
+
switch (input.action) {
|
|
237256
|
+
case 'upload': {
|
|
237257
|
+
if (input.isDirectory) {
|
|
237258
|
+
// 上传目录
|
|
237259
|
+
await storageService.uploadDirectory({
|
|
237260
|
+
localPath: input.localPath,
|
|
237261
|
+
cloudPath: input.cloudPath,
|
|
237262
|
+
onProgress: (progressData) => {
|
|
237263
|
+
console.log("Upload directory progress:", progressData);
|
|
237264
|
+
}
|
|
237265
|
+
});
|
|
237266
|
+
}
|
|
237267
|
+
else {
|
|
237268
|
+
// 上传文件
|
|
237269
|
+
await storageService.uploadFile({
|
|
237270
|
+
localPath: input.localPath,
|
|
237271
|
+
cloudPath: input.cloudPath,
|
|
237272
|
+
onProgress: (progressData) => {
|
|
237273
|
+
console.log("Upload file progress:", progressData);
|
|
237274
|
+
}
|
|
237275
|
+
});
|
|
237276
|
+
}
|
|
237277
|
+
// 获取文件临时下载地址
|
|
237278
|
+
const fileUrls = await storageService.getTemporaryUrl([{
|
|
237279
|
+
cloudPath: input.cloudPath,
|
|
237280
|
+
maxAge: 3600 // 临时链接有效期1小时
|
|
237281
|
+
}]);
|
|
237282
|
+
return {
|
|
237283
|
+
content: [
|
|
237284
|
+
{
|
|
237285
|
+
type: "text",
|
|
237286
|
+
text: JSON.stringify({
|
|
237287
|
+
success: true,
|
|
237288
|
+
data: {
|
|
237289
|
+
action: 'upload',
|
|
237290
|
+
localPath: input.localPath,
|
|
237291
|
+
cloudPath: input.cloudPath,
|
|
237292
|
+
isDirectory: input.isDirectory,
|
|
237293
|
+
temporaryUrl: fileUrls[0]?.url || "",
|
|
237294
|
+
expireTime: "1小时"
|
|
237295
|
+
},
|
|
237296
|
+
message: `Successfully uploaded ${input.isDirectory ? 'directory' : 'file'} from '${input.localPath}' to '${input.cloudPath}'`
|
|
237297
|
+
}, null, 2)
|
|
237298
|
+
}
|
|
237299
|
+
]
|
|
237300
|
+
};
|
|
237182
237301
|
}
|
|
237183
|
-
|
|
237184
|
-
|
|
237302
|
+
case 'download': {
|
|
237303
|
+
if (input.isDirectory) {
|
|
237304
|
+
// 下载目录
|
|
237305
|
+
await storageService.downloadDirectory({
|
|
237306
|
+
cloudPath: input.cloudPath,
|
|
237307
|
+
localPath: input.localPath
|
|
237308
|
+
});
|
|
237309
|
+
}
|
|
237310
|
+
else {
|
|
237311
|
+
// 下载文件
|
|
237312
|
+
await storageService.downloadFile({
|
|
237313
|
+
cloudPath: input.cloudPath,
|
|
237314
|
+
localPath: input.localPath
|
|
237315
|
+
});
|
|
237316
|
+
}
|
|
237317
|
+
return {
|
|
237318
|
+
content: [
|
|
237319
|
+
{
|
|
237320
|
+
type: "text",
|
|
237321
|
+
text: JSON.stringify({
|
|
237322
|
+
success: true,
|
|
237323
|
+
data: {
|
|
237324
|
+
action: 'download',
|
|
237325
|
+
cloudPath: input.cloudPath,
|
|
237326
|
+
localPath: input.localPath,
|
|
237327
|
+
isDirectory: input.isDirectory
|
|
237328
|
+
},
|
|
237329
|
+
message: `Successfully downloaded ${input.isDirectory ? 'directory' : 'file'} from '${input.cloudPath}' to '${input.localPath}'`
|
|
237330
|
+
}, null, 2)
|
|
237331
|
+
}
|
|
237332
|
+
]
|
|
237333
|
+
};
|
|
237334
|
+
}
|
|
237335
|
+
case 'delete': {
|
|
237336
|
+
if (!input.force) {
|
|
237337
|
+
return {
|
|
237338
|
+
content: [
|
|
237339
|
+
{
|
|
237340
|
+
type: "text",
|
|
237341
|
+
text: JSON.stringify({
|
|
237342
|
+
success: false,
|
|
237343
|
+
error: "Delete operation requires confirmation",
|
|
237344
|
+
message: "Please set force: true to confirm deletion. This action cannot be undone."
|
|
237345
|
+
}, null, 2)
|
|
237346
|
+
}
|
|
237347
|
+
]
|
|
237348
|
+
};
|
|
237349
|
+
}
|
|
237350
|
+
if (input.isDirectory) {
|
|
237351
|
+
// 删除目录
|
|
237352
|
+
await storageService.deleteDirectory(input.cloudPath);
|
|
237353
|
+
}
|
|
237354
|
+
else {
|
|
237355
|
+
// 删除文件
|
|
237356
|
+
await storageService.deleteFile([input.cloudPath]);
|
|
237357
|
+
}
|
|
237358
|
+
return {
|
|
237359
|
+
content: [
|
|
237360
|
+
{
|
|
237361
|
+
type: "text",
|
|
237362
|
+
text: JSON.stringify({
|
|
237363
|
+
success: true,
|
|
237364
|
+
data: {
|
|
237365
|
+
action: 'delete',
|
|
237366
|
+
cloudPath: input.cloudPath,
|
|
237367
|
+
isDirectory: input.isDirectory,
|
|
237368
|
+
deleted: true
|
|
237369
|
+
},
|
|
237370
|
+
message: `Successfully deleted ${input.isDirectory ? 'directory' : 'file'} '${input.cloudPath}'`
|
|
237371
|
+
}, null, 2)
|
|
237372
|
+
}
|
|
237373
|
+
]
|
|
237374
|
+
};
|
|
237375
|
+
}
|
|
237376
|
+
default:
|
|
237377
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
237378
|
+
}
|
|
237379
|
+
}
|
|
237380
|
+
catch (error) {
|
|
237381
|
+
return {
|
|
237382
|
+
content: [
|
|
237383
|
+
{
|
|
237384
|
+
type: "text",
|
|
237385
|
+
text: JSON.stringify({
|
|
237386
|
+
success: false,
|
|
237387
|
+
error: error.message || 'Unknown error occurred',
|
|
237388
|
+
message: `Failed to manage storage. Please check your permissions and parameters.`
|
|
237389
|
+
}, null, 2)
|
|
237390
|
+
}
|
|
237391
|
+
]
|
|
237392
|
+
};
|
|
237393
|
+
}
|
|
237185
237394
|
});
|
|
237186
237395
|
}
|
|
237187
237396
|
|