@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/index.cjs
CHANGED
|
@@ -1246,9 +1246,6 @@ function registerEnvTools(server) {
|
|
|
1246
1246
|
if (error) {
|
|
1247
1247
|
return { content: [{ type: "text", text: error }] };
|
|
1248
1248
|
}
|
|
1249
|
-
if (noEnvs) {
|
|
1250
|
-
return { content: [{ type: "text", text: "当前账户下暂无可用的云开发环境,请先在腾讯云控制台创建环境 https://tcb.cloud.tencent.com/dev?from=AIToolkit" }] };
|
|
1251
|
-
}
|
|
1252
1249
|
if (cancelled) {
|
|
1253
1250
|
return { content: [{ type: "text", text: "用户取消了登录" }] };
|
|
1254
1251
|
}
|
|
@@ -1326,12 +1323,12 @@ function registerEnvTools(server) {
|
|
|
1326
1323
|
switch (action) {
|
|
1327
1324
|
case "list":
|
|
1328
1325
|
try {
|
|
1329
|
-
const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId:
|
|
1326
|
+
const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId: true });
|
|
1330
1327
|
result = await cloudbaseList.env.listEnvs();
|
|
1331
1328
|
}
|
|
1332
1329
|
catch (error) {
|
|
1333
1330
|
(0, logger_js_1.debug)('获取环境列表时出错:', error);
|
|
1334
|
-
return { content: [{ type: "text", text: "
|
|
1331
|
+
return { content: [{ type: "text", text: "获取环境列表时出错: " + (error instanceof Error ? error.message : String(error)) }]
|
|
1335
1332
|
};
|
|
1336
1333
|
}
|
|
1337
1334
|
break;
|
|
@@ -22465,11 +22462,11 @@ exports.getEnvId = getEnvId;
|
|
|
22465
22462
|
exports.resetCloudBaseManagerCache = resetCloudBaseManagerCache;
|
|
22466
22463
|
exports.getCloudBaseManager = getCloudBaseManager;
|
|
22467
22464
|
exports.createCloudBaseManagerWithOptions = createCloudBaseManagerWithOptions;
|
|
22465
|
+
const manager_node_1 = __importDefault(__webpack_require__(95492));
|
|
22468
22466
|
const auth_js_1 = __webpack_require__(77291);
|
|
22469
22467
|
const interactive_js_1 = __webpack_require__(3461);
|
|
22470
|
-
const manager_node_1 = __importDefault(__webpack_require__(95492));
|
|
22471
22468
|
const logger_js_1 = __webpack_require__(13039);
|
|
22472
|
-
const ENV_ID_TIMEOUT =
|
|
22469
|
+
const ENV_ID_TIMEOUT = 60000000; // 60000 seconds
|
|
22473
22470
|
// 统一的环境ID管理类
|
|
22474
22471
|
class EnvironmentManager {
|
|
22475
22472
|
cachedEnvId = null;
|
|
@@ -22638,14 +22635,14 @@ exports.saveEnvIdToUserConfig = saveEnvIdToUserConfig;
|
|
|
22638
22635
|
exports.loadEnvIdFromUserConfig = loadEnvIdFromUserConfig;
|
|
22639
22636
|
exports.clearUserEnvId = clearUserEnvId;
|
|
22640
22637
|
exports.autoSetupEnvironmentId = autoSetupEnvironmentId;
|
|
22638
|
+
const promises_1 = __importDefault(__webpack_require__(79748));
|
|
22639
|
+
const os_1 = __importDefault(__webpack_require__(21820));
|
|
22640
|
+
const path_1 = __importDefault(__webpack_require__(39902));
|
|
22641
22641
|
const zod_1 = __webpack_require__(21614);
|
|
22642
|
-
const interactive_server_js_1 = __webpack_require__(92341);
|
|
22643
|
-
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
22644
22642
|
const auth_js_1 = __webpack_require__(77291);
|
|
22643
|
+
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
22644
|
+
const interactive_server_js_1 = __webpack_require__(92341);
|
|
22645
22645
|
const logger_js_1 = __webpack_require__(13039);
|
|
22646
|
-
const promises_1 = __importDefault(__webpack_require__(79748));
|
|
22647
|
-
const path_1 = __importDefault(__webpack_require__(39902));
|
|
22648
|
-
const os_1 = __importDefault(__webpack_require__(21820));
|
|
22649
22646
|
function registerInteractiveTools(server) {
|
|
22650
22647
|
// 统一的交互式对话工具 (cloud-incompatible)
|
|
22651
22648
|
server.registerTool("interactiveDialog", {
|
|
@@ -33812,58 +33809,9 @@ function downloadFile(url) {
|
|
|
33812
33809
|
});
|
|
33813
33810
|
}
|
|
33814
33811
|
function registerDownloadTools(server) {
|
|
33815
|
-
// downloadRemoteFile - 下载远程文件到临时目录 (cloud-incompatible)
|
|
33816
33812
|
server.registerTool("downloadRemoteFile", {
|
|
33817
|
-
title: "下载远程文件到临时目录",
|
|
33818
|
-
description: "下载远程文件到本地临时文件,返回一个系统的绝对路径。适用于需要临时处理文件的场景。",
|
|
33819
|
-
inputSchema: {
|
|
33820
|
-
url: zod_1.z.string().describe("远程文件的 URL 地址")
|
|
33821
|
-
},
|
|
33822
|
-
annotations: {
|
|
33823
|
-
readOnlyHint: false,
|
|
33824
|
-
destructiveHint: false,
|
|
33825
|
-
idempotentHint: false,
|
|
33826
|
-
openWorldHint: true,
|
|
33827
|
-
category: "download"
|
|
33828
|
-
}
|
|
33829
|
-
}, async ({ url }) => {
|
|
33830
|
-
try {
|
|
33831
|
-
const result = await downloadFile(url);
|
|
33832
|
-
return {
|
|
33833
|
-
content: [
|
|
33834
|
-
{
|
|
33835
|
-
type: "text",
|
|
33836
|
-
text: JSON.stringify({
|
|
33837
|
-
success: true,
|
|
33838
|
-
filePath: result.filePath,
|
|
33839
|
-
contentType: result.contentType,
|
|
33840
|
-
fileSize: result.fileSize,
|
|
33841
|
-
message: "文件下载成功到临时目录",
|
|
33842
|
-
note: "文件保存在临时目录中,请注意及时处理"
|
|
33843
|
-
}, null, 2)
|
|
33844
|
-
}
|
|
33845
|
-
]
|
|
33846
|
-
};
|
|
33847
|
-
}
|
|
33848
|
-
catch (error) {
|
|
33849
|
-
return {
|
|
33850
|
-
content: [
|
|
33851
|
-
{
|
|
33852
|
-
type: "text",
|
|
33853
|
-
text: JSON.stringify({
|
|
33854
|
-
success: false,
|
|
33855
|
-
error: error.message,
|
|
33856
|
-
message: "文件下载失败"
|
|
33857
|
-
}, null, 2)
|
|
33858
|
-
}
|
|
33859
|
-
]
|
|
33860
|
-
};
|
|
33861
|
-
}
|
|
33862
|
-
});
|
|
33863
|
-
// downloadRemoteFileToPath - 下载远程文件到指定路径 (cloud-incompatible)
|
|
33864
|
-
server.registerTool("downloadRemoteFileToPath", {
|
|
33865
33813
|
title: "下载远程文件到指定路径",
|
|
33866
|
-
description: "
|
|
33814
|
+
description: "下载远程文件到项目根目录下的指定相对路径。例如:小程序的 Tabbar 等素材图片,必须使用 **png** 格式,可以从 Unsplash、wikimedia【一般选用 500 大小即可、Pexels、Apple 官方 UI 等资源中选择来下载。",
|
|
33867
33815
|
inputSchema: {
|
|
33868
33816
|
url: zod_1.z.string().describe("远程文件的 URL 地址"),
|
|
33869
33817
|
relativePath: zod_1.z.string().describe("相对于项目根目录的路径,例如:'assets/images/logo.png' 或 'docs/api.md'。不允许使用 ../ 等路径遍历操作。")
|
|
@@ -97788,7 +97736,7 @@ function convertToJSONSchema(data) {
|
|
|
97788
97736
|
// 处理枚举类型
|
|
97789
97737
|
if (parsed.type.startsWith('x-enum')) {
|
|
97790
97738
|
schema.properties[parsed.name].type = 'string';
|
|
97791
|
-
schema.properties[parsed.name].format = 'enum';
|
|
97739
|
+
schema.properties[parsed.name].format = 'x-enum';
|
|
97792
97740
|
if (parsed.enumValues) {
|
|
97793
97741
|
schema.properties[parsed.name].enum = parsed.enumValues;
|
|
97794
97742
|
}
|
|
@@ -97975,7 +97923,6 @@ function getSpecialFormat(type) {
|
|
|
97975
97923
|
'x-location': 'x-location',
|
|
97976
97924
|
'x-area-code': 'x-area-code',
|
|
97977
97925
|
'x-file': 'x-file',
|
|
97978
|
-
'x-enum': 'enum',
|
|
97979
97926
|
};
|
|
97980
97927
|
// 只保留这些
|
|
97981
97928
|
return formatMap[type] || null;
|
|
@@ -101466,11 +101413,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
101466
101413
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
101467
101414
|
exports.CLOUDRUN_ACCESS_TYPES = exports.CLOUDRUN_SERVICE_TYPES = void 0;
|
|
101468
101415
|
exports.registerCloudRunTools = registerCloudRunTools;
|
|
101416
|
+
const child_process_1 = __webpack_require__(79646);
|
|
101417
|
+
const fs_1 = __importDefault(__webpack_require__(29021));
|
|
101418
|
+
const path_1 = __importDefault(__webpack_require__(39902));
|
|
101469
101419
|
const zod_1 = __webpack_require__(21614);
|
|
101470
101420
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
101471
|
-
const path_1 = __importDefault(__webpack_require__(39902));
|
|
101472
|
-
const fs_1 = __importDefault(__webpack_require__(29021));
|
|
101473
|
-
const child_process_1 = __webpack_require__(79646);
|
|
101474
101421
|
// CloudRun service types
|
|
101475
101422
|
exports.CLOUDRUN_SERVICE_TYPES = ['function', 'container'];
|
|
101476
101423
|
// CloudRun access types
|
|
@@ -101482,7 +101429,7 @@ const queryCloudRunInputSchema = {
|
|
|
101482
101429
|
pageSize: zod_1.z.number().min(1).max(100).optional().default(10).describe('分页大小,控制每页返回的服务数量。取值范围:1-100,默认值:10。建议根据网络性能和显示需求调整'),
|
|
101483
101430
|
pageNum: zod_1.z.number().min(1).optional().default(1).describe('页码,用于分页查询。从1开始,默认值:1。配合pageSize使用可实现分页浏览'),
|
|
101484
101431
|
serverName: zod_1.z.string().optional().describe('服务名称筛选条件,支持模糊匹配。例如:输入"test"可匹配"test-service"、"my-test-app"等服务名称。留空则查询所有服务'),
|
|
101485
|
-
serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function
|
|
101432
|
+
serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)'),
|
|
101486
101433
|
// Detail operation parameters
|
|
101487
101434
|
detailServerName: zod_1.z.string().optional().describe('要查询详细信息的服务名称。当action为detail时必需提供,必须是已存在的服务名称。可通过list操作获取可用的服务名称列表'),
|
|
101488
101435
|
};
|
|
@@ -101496,7 +101443,7 @@ const ManageCloudRunInputSchema = {
|
|
|
101496
101443
|
OpenAccessTypes: zod_1.z.array(zod_1.z.enum(exports.CLOUDRUN_ACCESS_TYPES)).optional().describe('公网访问类型配置,控制服务的访问权限:WEB=公网访问(默认,可通过HTTPS域名访问),VPC=私有网络访问(仅同VPC内可访问),PRIVATE=内网访问(仅云开发环境内可访问)。可配置多个类型'),
|
|
101497
101444
|
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)。影响服务性能和计费'),
|
|
101498
101445
|
Mem: zod_1.z.number().positive().optional().describe('内存规格配置,单位为GB。可选值:0.5、1、2、4、8、16等。注意:必须是CPU规格的2倍。影响服务性能和计费'),
|
|
101499
|
-
MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0
|
|
101446
|
+
MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0时始终保持指定数量的实例运行(确保快速响应但会增加成本)。建议设置为1以降低冷启动延迟,提升用户体验'),
|
|
101500
101447
|
MaxNum: zod_1.z.number().min(1).optional().describe('最大实例数配置,控制服务的最大运行实例数量。当请求量增加时,服务最多可以扩展到指定数量的实例,超过此数量后将拒绝新的请求。建议根据业务峰值设置'),
|
|
101501
101448
|
Port: zod_1.z.number().min(1).max(65535).optional().describe('服务监听端口配置。函数型服务固定为3000,容器型服务可自定义。服务代码必须监听此端口才能正常接收请求'),
|
|
101502
101449
|
EnvParams: zod_1.z.record(zod_1.z.string()).optional().describe('环境变量配置,用于传递配置信息给服务代码。格式为键值对,如{"DATABASE_URL":"mysql://..."}。敏感信息建议使用环境变量而非硬编码'),
|
|
@@ -101524,6 +101471,7 @@ const ManageCloudRunInputSchema = {
|
|
|
101524
101471
|
}).optional().describe('Agent配置项,仅在createAgent操作时使用'),
|
|
101525
101472
|
// Common parameters
|
|
101526
101473
|
force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,用于跳过确认提示。默认false(需要确认),设置为true时跳过所有确认步骤。删除操作时强烈建议设置为true以避免误操作'),
|
|
101474
|
+
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'),
|
|
101527
101475
|
};
|
|
101528
101476
|
/**
|
|
101529
101477
|
* Check if a project is an Agent project
|
|
@@ -101898,21 +101846,47 @@ for await (let x of res.textStream) {
|
|
|
101898
101846
|
if (!targetPath) {
|
|
101899
101847
|
throw new Error("targetPath is required for deploy operation");
|
|
101900
101848
|
}
|
|
101901
|
-
// Determine service type
|
|
101849
|
+
// Determine service type - use input.serverType if provided, otherwise auto-detect
|
|
101902
101850
|
let serverType;
|
|
101903
|
-
|
|
101904
|
-
|
|
101905
|
-
const details = await cloudrunService.detail({ serverName: input.serverName });
|
|
101906
|
-
serverType = details.BaseInfo?.ServerType || 'function';
|
|
101851
|
+
if (input.serverType) {
|
|
101852
|
+
serverType = input.serverType;
|
|
101907
101853
|
}
|
|
101908
|
-
|
|
101909
|
-
|
|
101910
|
-
|
|
101911
|
-
|
|
101912
|
-
serverType = 'container';
|
|
101854
|
+
else {
|
|
101855
|
+
try {
|
|
101856
|
+
// First try to get existing service details
|
|
101857
|
+
const details = await cloudrunService.detail({ serverName: input.serverName });
|
|
101858
|
+
serverType = details.BaseInfo?.ServerType || 'container';
|
|
101913
101859
|
}
|
|
101914
|
-
|
|
101915
|
-
|
|
101860
|
+
catch (e) {
|
|
101861
|
+
// If service doesn't exist, determine by project structure
|
|
101862
|
+
const dockerfilePath = path_1.default.join(targetPath, 'Dockerfile');
|
|
101863
|
+
if (fs_1.default.existsSync(dockerfilePath)) {
|
|
101864
|
+
serverType = 'container';
|
|
101865
|
+
}
|
|
101866
|
+
else {
|
|
101867
|
+
// Check if it's a Node.js function project (has package.json with specific structure)
|
|
101868
|
+
const packageJsonPath = path_1.default.join(targetPath, 'package.json');
|
|
101869
|
+
if (fs_1.default.existsSync(packageJsonPath)) {
|
|
101870
|
+
try {
|
|
101871
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
|
|
101872
|
+
// If it has function-specific dependencies or scripts, treat as function
|
|
101873
|
+
if (packageJson.dependencies?.['@cloudbase/aiagent-framework'] ||
|
|
101874
|
+
packageJson.scripts?.['dev']?.includes('cloudrun run')) {
|
|
101875
|
+
serverType = 'function';
|
|
101876
|
+
}
|
|
101877
|
+
else {
|
|
101878
|
+
serverType = 'container';
|
|
101879
|
+
}
|
|
101880
|
+
}
|
|
101881
|
+
catch (parseError) {
|
|
101882
|
+
serverType = 'container';
|
|
101883
|
+
}
|
|
101884
|
+
}
|
|
101885
|
+
else {
|
|
101886
|
+
// No package.json, default to container
|
|
101887
|
+
serverType = 'container';
|
|
101888
|
+
}
|
|
101889
|
+
}
|
|
101916
101890
|
}
|
|
101917
101891
|
}
|
|
101918
101892
|
const deployParams = {
|
|
@@ -121993,7 +121967,7 @@ class TelemetryReporter {
|
|
|
121993
121967
|
const nodeVersion = process.version; // Node.js版本
|
|
121994
121968
|
const arch = os_1.default.arch(); // 系统架构
|
|
121995
121969
|
// 从构建时注入的版本号获取MCP版本信息
|
|
121996
|
-
const mcpVersion = process.env.npm_package_version || "1.8.
|
|
121970
|
+
const mcpVersion = process.env.npm_package_version || "1.8.43" || 0;
|
|
121997
121971
|
return {
|
|
121998
121972
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
121999
121973
|
deviceId: this.deviceId,
|
|
@@ -179879,7 +179853,7 @@ ${envIdSection}
|
|
|
179879
179853
|
## 环境信息
|
|
179880
179854
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
179881
179855
|
- Node.js版本: ${process.version}
|
|
179882
|
-
- MCP 版本:${process.env.npm_package_version || "1.8.
|
|
179856
|
+
- MCP 版本:${process.env.npm_package_version || "1.8.43" || 0}
|
|
179883
179857
|
- 系统架构: ${os_1.default.arch()}
|
|
179884
179858
|
- 时间: ${new Date().toISOString()}
|
|
179885
179859
|
- 请求ID: ${requestId}
|
|
@@ -194905,7 +194879,7 @@ function registerSetupTools(server) {
|
|
|
194905
194879
|
// downloadTemplate - 下载项目模板 (cloud-incompatible)
|
|
194906
194880
|
server.registerTool("downloadTemplate", {
|
|
194907
194881
|
title: "下载项目模板",
|
|
194908
|
-
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.
|
|
194882
|
+
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)`,
|
|
194909
194883
|
inputSchema: {
|
|
194910
194884
|
template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
|
|
194911
194885
|
ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
|
|
@@ -196114,9 +196088,9 @@ async function getLoginState() {
|
|
|
196114
196088
|
}
|
|
196115
196089
|
const loginState = await auth.getLoginState();
|
|
196116
196090
|
if (!loginState) {
|
|
196117
|
-
(0, logger_js_1.debug)('loginByApiSecret');
|
|
196118
196091
|
await auth.loginByWebAuth({});
|
|
196119
196092
|
const loginState = await auth.getLoginState();
|
|
196093
|
+
(0, logger_js_1.debug)('loginByWebAuth', loginState);
|
|
196120
196094
|
return loginState;
|
|
196121
196095
|
}
|
|
196122
196096
|
else {
|
|
@@ -219574,7 +219548,11 @@ function shouldRegisterTool(toolName) {
|
|
|
219574
219548
|
'setupEnvironmentId',
|
|
219575
219549
|
'clearUserEnvId',
|
|
219576
219550
|
// Interactive tools - local server and file operations
|
|
219577
|
-
'interactiveDialog'
|
|
219551
|
+
'interactiveDialog',
|
|
219552
|
+
// CloudRun tools - local file operations
|
|
219553
|
+
'manageCloudRun',
|
|
219554
|
+
// Download tools - local file downloads
|
|
219555
|
+
'manageStorage',
|
|
219578
219556
|
];
|
|
219579
219557
|
const shouldRegister = !cloudIncompatibleTools.includes(toolName);
|
|
219580
219558
|
if (!shouldRegister) {
|
|
@@ -228458,8 +228436,8 @@ exports.resetInteractiveServer = resetInteractiveServer;
|
|
|
228458
228436
|
exports.getInteractiveServerSafe = getInteractiveServerSafe;
|
|
228459
228437
|
const express_1 = __importDefault(__webpack_require__(26083));
|
|
228460
228438
|
const http_1 = __importDefault(__webpack_require__(81630));
|
|
228461
|
-
const ws_1 = __webpack_require__(17699);
|
|
228462
228439
|
const open_1 = __importDefault(__webpack_require__(45368));
|
|
228440
|
+
const ws_1 = __webpack_require__(17699);
|
|
228463
228441
|
const logger_js_1 = __webpack_require__(13039);
|
|
228464
228442
|
// 动态导入 open 模块,兼容 ESM/CJS 环境
|
|
228465
228443
|
async function openUrl(url, options, server) {
|
|
@@ -229342,8 +229320,8 @@ class InteractiveServer {
|
|
|
229342
229320
|
</div>
|
|
229343
229321
|
|
|
229344
229322
|
<div class="content">
|
|
229345
|
-
<h1 class="content-title"
|
|
229346
|
-
<p class="content-subtitle"
|
|
229323
|
+
<h1 class="content-title">选择 CloudBase 环境</h1>
|
|
229324
|
+
<p class="content-subtitle">请选择您要使用的 CloudBase 环境</p>
|
|
229347
229325
|
|
|
229348
229326
|
<div class="env-list" id="envList">
|
|
229349
229327
|
${(envs || []).length > 0 ?
|
|
@@ -229360,8 +229338,8 @@ class InteractiveServer {
|
|
|
229360
229338
|
`).join('') :
|
|
229361
229339
|
`
|
|
229362
229340
|
<div class="empty-state">
|
|
229363
|
-
<h3 class="empty-title"
|
|
229364
|
-
<p class="empty-message"
|
|
229341
|
+
<h3 class="empty-title">暂无 CloudBase 环境</h3>
|
|
229342
|
+
<p class="empty-message">当前没有可用的 CloudBase 环境,请新建后重新在 AI 对话中重试</p>
|
|
229365
229343
|
<button class="btn btn-primary create-env-btn" onclick="createNewEnv()">
|
|
229366
229344
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
229367
229345
|
<path d="M12 5v14M5 12h14"/>
|
|
@@ -229399,7 +229377,7 @@ class InteractiveServer {
|
|
|
229399
229377
|
</svg>
|
|
229400
229378
|
</div>
|
|
229401
229379
|
<h2 class="success-title">环境配置成功!</h2>
|
|
229402
|
-
<p class="success-message"
|
|
229380
|
+
<p class="success-message">已成功选择 CloudBase 环境</p>
|
|
229403
229381
|
<div class="selected-env-info">
|
|
229404
229382
|
<span class="env-label">环境 ID:</span>
|
|
229405
229383
|
<span class="env-value" id="selectedEnvDisplay"></span>
|
|
@@ -237030,54 +237008,285 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
237030
237008
|
exports.registerStorageTools = registerStorageTools;
|
|
237031
237009
|
const zod_1 = __webpack_require__(21614);
|
|
237032
237010
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
237011
|
+
// Input schema for queryStorage tool
|
|
237012
|
+
const queryStorageInputSchema = {
|
|
237013
|
+
action: zod_1.z.enum(['list', 'info', 'url']).describe('查询操作类型:list=列出目录下的所有文件,info=获取指定文件的详细信息,url=获取文件的临时下载链接'),
|
|
237014
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt 或 files/(目录)'),
|
|
237015
|
+
maxAge: zod_1.z.number().min(1).max(86400).optional().default(3600).describe('临时链接有效期,单位为秒,取值范围:1-86400,默认值:3600(1小时)')
|
|
237016
|
+
};
|
|
237017
|
+
// Input schema for manageStorage tool
|
|
237018
|
+
const manageStorageInputSchema = {
|
|
237019
|
+
action: zod_1.z.enum(['upload', 'download', 'delete']).describe('管理操作类型:upload=上传文件或目录,download=下载文件或目录,delete=删除文件或目录'),
|
|
237020
|
+
localPath: zod_1.z.string().describe('本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt'),
|
|
237021
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt'),
|
|
237022
|
+
force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,删除操作时建议设置为true以确认删除,默认false'),
|
|
237023
|
+
isDirectory: zod_1.z.boolean().optional().default(false).describe('是否为目录操作,true=目录操作,false=文件操作,默认false')
|
|
237024
|
+
};
|
|
237033
237025
|
function registerStorageTools(server) {
|
|
237034
237026
|
// 获取 cloudBaseOptions,如果没有则为 undefined
|
|
237035
237027
|
const cloudBaseOptions = server.cloudBaseOptions;
|
|
237036
237028
|
// 创建闭包函数来获取 CloudBase Manager
|
|
237037
237029
|
const getManager = () => (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions });
|
|
237038
|
-
//
|
|
237039
|
-
server.registerTool("
|
|
237040
|
-
title: "
|
|
237041
|
-
description: "
|
|
237042
|
-
inputSchema:
|
|
237043
|
-
|
|
237044
|
-
|
|
237045
|
-
|
|
237030
|
+
// Tool 1: queryStorage - 查询存储信息(只读操作)
|
|
237031
|
+
server.registerTool("queryStorage", {
|
|
237032
|
+
title: "查询存储信息",
|
|
237033
|
+
description: "查询云存储信息,支持列出目录文件、获取文件信息、获取临时下载链接等只读操作。返回的文件信息包括文件名、大小、修改时间、下载链接等。",
|
|
237034
|
+
inputSchema: queryStorageInputSchema,
|
|
237035
|
+
annotations: {
|
|
237036
|
+
readOnlyHint: true,
|
|
237037
|
+
openWorldHint: true,
|
|
237038
|
+
category: "storage"
|
|
237039
|
+
}
|
|
237040
|
+
}, async (args) => {
|
|
237041
|
+
try {
|
|
237042
|
+
const input = args;
|
|
237043
|
+
const manager = await getManager();
|
|
237044
|
+
if (!manager) {
|
|
237045
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
237046
|
+
}
|
|
237047
|
+
const storageService = manager.storage;
|
|
237048
|
+
switch (input.action) {
|
|
237049
|
+
case 'list': {
|
|
237050
|
+
const result = await storageService.listDirectoryFiles(input.cloudPath);
|
|
237051
|
+
return {
|
|
237052
|
+
content: [
|
|
237053
|
+
{
|
|
237054
|
+
type: "text",
|
|
237055
|
+
text: JSON.stringify({
|
|
237056
|
+
success: true,
|
|
237057
|
+
data: {
|
|
237058
|
+
action: 'list',
|
|
237059
|
+
cloudPath: input.cloudPath,
|
|
237060
|
+
files: result || [],
|
|
237061
|
+
totalCount: result?.length || 0
|
|
237062
|
+
},
|
|
237063
|
+
message: `Successfully listed ${result?.length || 0} files in directory '${input.cloudPath}'`
|
|
237064
|
+
}, null, 2)
|
|
237065
|
+
}
|
|
237066
|
+
]
|
|
237067
|
+
};
|
|
237068
|
+
}
|
|
237069
|
+
case 'info': {
|
|
237070
|
+
const result = await storageService.getFileInfo(input.cloudPath);
|
|
237071
|
+
return {
|
|
237072
|
+
content: [
|
|
237073
|
+
{
|
|
237074
|
+
type: "text",
|
|
237075
|
+
text: JSON.stringify({
|
|
237076
|
+
success: true,
|
|
237077
|
+
data: {
|
|
237078
|
+
action: 'info',
|
|
237079
|
+
cloudPath: input.cloudPath,
|
|
237080
|
+
fileInfo: result
|
|
237081
|
+
},
|
|
237082
|
+
message: `Successfully retrieved file info for '${input.cloudPath}'`
|
|
237083
|
+
}, null, 2)
|
|
237084
|
+
}
|
|
237085
|
+
]
|
|
237086
|
+
};
|
|
237087
|
+
}
|
|
237088
|
+
case 'url': {
|
|
237089
|
+
const result = await storageService.getTemporaryUrl([{
|
|
237090
|
+
cloudPath: input.cloudPath,
|
|
237091
|
+
maxAge: input.maxAge || 3600
|
|
237092
|
+
}]);
|
|
237093
|
+
return {
|
|
237094
|
+
content: [
|
|
237095
|
+
{
|
|
237096
|
+
type: "text",
|
|
237097
|
+
text: JSON.stringify({
|
|
237098
|
+
success: true,
|
|
237099
|
+
data: {
|
|
237100
|
+
action: 'url',
|
|
237101
|
+
cloudPath: input.cloudPath,
|
|
237102
|
+
temporaryUrl: result[0]?.url || "",
|
|
237103
|
+
expireTime: `${input.maxAge || 3600}秒`,
|
|
237104
|
+
fileId: result[0]?.fileId || ""
|
|
237105
|
+
},
|
|
237106
|
+
message: `Successfully generated temporary URL for '${input.cloudPath}'`
|
|
237107
|
+
}, null, 2)
|
|
237108
|
+
}
|
|
237109
|
+
]
|
|
237110
|
+
};
|
|
237111
|
+
}
|
|
237112
|
+
default:
|
|
237113
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
237114
|
+
}
|
|
237115
|
+
}
|
|
237116
|
+
catch (error) {
|
|
237117
|
+
return {
|
|
237118
|
+
content: [
|
|
237119
|
+
{
|
|
237120
|
+
type: "text",
|
|
237121
|
+
text: JSON.stringify({
|
|
237122
|
+
success: false,
|
|
237123
|
+
error: error.message || 'Unknown error occurred',
|
|
237124
|
+
message: `Failed to query storage information. Please check your permissions and parameters.`
|
|
237125
|
+
}, null, 2)
|
|
237126
|
+
}
|
|
237127
|
+
]
|
|
237128
|
+
};
|
|
237129
|
+
}
|
|
237130
|
+
});
|
|
237131
|
+
// Tool 2: manageStorage - 管理存储文件(写操作)
|
|
237132
|
+
server.registerTool("manageStorage", {
|
|
237133
|
+
title: "管理存储文件",
|
|
237134
|
+
description: "管理云存储文件,支持上传文件/目录、下载文件/目录、删除文件/目录等操作。删除操作需要设置force=true进行确认,防止误删除重要文件。",
|
|
237135
|
+
inputSchema: manageStorageInputSchema,
|
|
237046
237136
|
annotations: {
|
|
237047
237137
|
readOnlyHint: false,
|
|
237048
|
-
destructiveHint:
|
|
237138
|
+
destructiveHint: true,
|
|
237049
237139
|
idempotentHint: false,
|
|
237050
237140
|
openWorldHint: true,
|
|
237051
237141
|
category: "storage"
|
|
237052
237142
|
}
|
|
237053
|
-
}, async (
|
|
237054
|
-
|
|
237055
|
-
|
|
237056
|
-
|
|
237057
|
-
|
|
237058
|
-
|
|
237059
|
-
onProgress: (progressData) => {
|
|
237060
|
-
console.log("Upload progress:", progressData);
|
|
237143
|
+
}, async (args) => {
|
|
237144
|
+
try {
|
|
237145
|
+
const input = args;
|
|
237146
|
+
const manager = await getManager();
|
|
237147
|
+
if (!manager) {
|
|
237148
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
237061
237149
|
}
|
|
237062
|
-
|
|
237063
|
-
|
|
237064
|
-
|
|
237065
|
-
|
|
237066
|
-
|
|
237067
|
-
|
|
237068
|
-
|
|
237069
|
-
|
|
237070
|
-
|
|
237071
|
-
|
|
237072
|
-
|
|
237073
|
-
|
|
237074
|
-
|
|
237075
|
-
|
|
237076
|
-
|
|
237077
|
-
|
|
237150
|
+
const storageService = manager.storage;
|
|
237151
|
+
switch (input.action) {
|
|
237152
|
+
case 'upload': {
|
|
237153
|
+
if (input.isDirectory) {
|
|
237154
|
+
// 上传目录
|
|
237155
|
+
await storageService.uploadDirectory({
|
|
237156
|
+
localPath: input.localPath,
|
|
237157
|
+
cloudPath: input.cloudPath,
|
|
237158
|
+
onProgress: (progressData) => {
|
|
237159
|
+
console.log("Upload directory progress:", progressData);
|
|
237160
|
+
}
|
|
237161
|
+
});
|
|
237162
|
+
}
|
|
237163
|
+
else {
|
|
237164
|
+
// 上传文件
|
|
237165
|
+
await storageService.uploadFile({
|
|
237166
|
+
localPath: input.localPath,
|
|
237167
|
+
cloudPath: input.cloudPath,
|
|
237168
|
+
onProgress: (progressData) => {
|
|
237169
|
+
console.log("Upload file progress:", progressData);
|
|
237170
|
+
}
|
|
237171
|
+
});
|
|
237172
|
+
}
|
|
237173
|
+
// 获取文件临时下载地址
|
|
237174
|
+
const fileUrls = await storageService.getTemporaryUrl([{
|
|
237175
|
+
cloudPath: input.cloudPath,
|
|
237176
|
+
maxAge: 3600 // 临时链接有效期1小时
|
|
237177
|
+
}]);
|
|
237178
|
+
return {
|
|
237179
|
+
content: [
|
|
237180
|
+
{
|
|
237181
|
+
type: "text",
|
|
237182
|
+
text: JSON.stringify({
|
|
237183
|
+
success: true,
|
|
237184
|
+
data: {
|
|
237185
|
+
action: 'upload',
|
|
237186
|
+
localPath: input.localPath,
|
|
237187
|
+
cloudPath: input.cloudPath,
|
|
237188
|
+
isDirectory: input.isDirectory,
|
|
237189
|
+
temporaryUrl: fileUrls[0]?.url || "",
|
|
237190
|
+
expireTime: "1小时"
|
|
237191
|
+
},
|
|
237192
|
+
message: `Successfully uploaded ${input.isDirectory ? 'directory' : 'file'} from '${input.localPath}' to '${input.cloudPath}'`
|
|
237193
|
+
}, null, 2)
|
|
237194
|
+
}
|
|
237195
|
+
]
|
|
237196
|
+
};
|
|
237078
237197
|
}
|
|
237079
|
-
|
|
237080
|
-
|
|
237198
|
+
case 'download': {
|
|
237199
|
+
if (input.isDirectory) {
|
|
237200
|
+
// 下载目录
|
|
237201
|
+
await storageService.downloadDirectory({
|
|
237202
|
+
cloudPath: input.cloudPath,
|
|
237203
|
+
localPath: input.localPath
|
|
237204
|
+
});
|
|
237205
|
+
}
|
|
237206
|
+
else {
|
|
237207
|
+
// 下载文件
|
|
237208
|
+
await storageService.downloadFile({
|
|
237209
|
+
cloudPath: input.cloudPath,
|
|
237210
|
+
localPath: input.localPath
|
|
237211
|
+
});
|
|
237212
|
+
}
|
|
237213
|
+
return {
|
|
237214
|
+
content: [
|
|
237215
|
+
{
|
|
237216
|
+
type: "text",
|
|
237217
|
+
text: JSON.stringify({
|
|
237218
|
+
success: true,
|
|
237219
|
+
data: {
|
|
237220
|
+
action: 'download',
|
|
237221
|
+
cloudPath: input.cloudPath,
|
|
237222
|
+
localPath: input.localPath,
|
|
237223
|
+
isDirectory: input.isDirectory
|
|
237224
|
+
},
|
|
237225
|
+
message: `Successfully downloaded ${input.isDirectory ? 'directory' : 'file'} from '${input.cloudPath}' to '${input.localPath}'`
|
|
237226
|
+
}, null, 2)
|
|
237227
|
+
}
|
|
237228
|
+
]
|
|
237229
|
+
};
|
|
237230
|
+
}
|
|
237231
|
+
case 'delete': {
|
|
237232
|
+
if (!input.force) {
|
|
237233
|
+
return {
|
|
237234
|
+
content: [
|
|
237235
|
+
{
|
|
237236
|
+
type: "text",
|
|
237237
|
+
text: JSON.stringify({
|
|
237238
|
+
success: false,
|
|
237239
|
+
error: "Delete operation requires confirmation",
|
|
237240
|
+
message: "Please set force: true to confirm deletion. This action cannot be undone."
|
|
237241
|
+
}, null, 2)
|
|
237242
|
+
}
|
|
237243
|
+
]
|
|
237244
|
+
};
|
|
237245
|
+
}
|
|
237246
|
+
if (input.isDirectory) {
|
|
237247
|
+
// 删除目录
|
|
237248
|
+
await storageService.deleteDirectory(input.cloudPath);
|
|
237249
|
+
}
|
|
237250
|
+
else {
|
|
237251
|
+
// 删除文件
|
|
237252
|
+
await storageService.deleteFile([input.cloudPath]);
|
|
237253
|
+
}
|
|
237254
|
+
return {
|
|
237255
|
+
content: [
|
|
237256
|
+
{
|
|
237257
|
+
type: "text",
|
|
237258
|
+
text: JSON.stringify({
|
|
237259
|
+
success: true,
|
|
237260
|
+
data: {
|
|
237261
|
+
action: 'delete',
|
|
237262
|
+
cloudPath: input.cloudPath,
|
|
237263
|
+
isDirectory: input.isDirectory,
|
|
237264
|
+
deleted: true
|
|
237265
|
+
},
|
|
237266
|
+
message: `Successfully deleted ${input.isDirectory ? 'directory' : 'file'} '${input.cloudPath}'`
|
|
237267
|
+
}, null, 2)
|
|
237268
|
+
}
|
|
237269
|
+
]
|
|
237270
|
+
};
|
|
237271
|
+
}
|
|
237272
|
+
default:
|
|
237273
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
237274
|
+
}
|
|
237275
|
+
}
|
|
237276
|
+
catch (error) {
|
|
237277
|
+
return {
|
|
237278
|
+
content: [
|
|
237279
|
+
{
|
|
237280
|
+
type: "text",
|
|
237281
|
+
text: JSON.stringify({
|
|
237282
|
+
success: false,
|
|
237283
|
+
error: error.message || 'Unknown error occurred',
|
|
237284
|
+
message: `Failed to manage storage. Please check your permissions and parameters.`
|
|
237285
|
+
}, null, 2)
|
|
237286
|
+
}
|
|
237287
|
+
]
|
|
237288
|
+
};
|
|
237289
|
+
}
|
|
237081
237290
|
});
|
|
237082
237291
|
}
|
|
237083
237292
|
|