@cloudbase/cloudbase-mcp 2.2.0 → 2.3.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/cli.cjs CHANGED
@@ -102,7 +102,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
102
102
  Object.defineProperty(exports, "__esModule", ({ value: true }));
103
103
  exports.CloudRunService = void 0;
104
104
  exports.codeToZip = codeToZip;
105
- exports.parseObjectToDiffConfigItem = parseObjectToDiffConfigItem;
106
105
  const archiver_1 = __importDefault(__webpack_require__(99133));
107
106
  const fs_extra_1 = __webpack_require__(21605);
108
107
  const path_1 = __importDefault(__webpack_require__(39902));
@@ -271,7 +270,7 @@ class CloudRunService {
271
270
  /**
272
271
  * 上传部署包
273
272
  */
274
- const zipFile = await codeToZip(targetPath, { installDependency: (serverConfig === null || serverConfig === void 0 ? void 0 : serverConfig.InstallDependency) !== undefined ? serverConfig.InstallDependency : true });
273
+ const zipFile = await codeToZip(targetPath, { installDependency: true });
275
274
  await (0, utils_1.upload)({
276
275
  url: uploadUrl,
277
276
  file: zipFile,
@@ -287,14 +286,8 @@ class CloudRunService {
287
286
  if (await this._checkFunctionExist(serverName)) {
288
287
  // 更新
289
288
  const serverDetail = await this.detail({ serverName });
290
- const _serverConfig = Object.assign(Object.assign(Object.assign({}, serverConfig), { OpenAccessTypes: ['OA', 'PUBLIC', 'MINIAPP'] }), ((serverDetail === null || serverDetail === void 0 ? void 0 : serverDetail.ServerConfig.Tag) === 'function:' ? { Port: 3000 } : {}) // 函数型不能指定端口,需要固定为3000
289
+ const _serverConfig = Object.assign(Object.assign(Object.assign({}, ((serverDetail === null || serverDetail === void 0 ? void 0 : serverDetail.ServerConfig) || {})), serverConfig), ((serverDetail === null || serverDetail === void 0 ? void 0 : serverDetail.ServerConfig.Tag) === 'function:' ? { Port: 3000 } : {}) // 函数型不能指定端口,需要固定为3000
291
290
  );
292
- if ((serverDetail === null || serverDetail === void 0 ? void 0 : serverDetail.ServerConfig.Tag) === 'function:') {
293
- deployInfo.BuildPacks = {
294
- LanguageVersion: '20.18',
295
- RepoLanguage: 'Node.js'
296
- };
297
- }
298
291
  deployInfo.ReleaseType = 'FULL';
299
292
  return this._upsertFunction(false, {
300
293
  name: serverName,
@@ -322,13 +315,7 @@ class CloudRunService {
322
315
  RepoLanguage: 'Node.js'
323
316
  };
324
317
  }
325
- const _serverConfig = Object.assign(Object.assign(Object.assign({ OpenAccessTypes: ['OA', 'PUBLIC', 'MINIAPP'],
326
- // Cpu: 0,
327
- // Mem: 0,
328
- MinNum: 0,
329
- // MaxNum: 0,
330
- // PolicyDetails: [],
331
- EnvParams: JSON.stringify({}), InitialDelaySeconds: 0, CustomLogs: '', HasDockerfile: true, CreateTime: '', EnvId: envConfig.EnvId, ServerName: serverName, Port: type === 'container' ? 80 : 3000, Dockerfile: 'Dockerfile', BuildDir: '' }, serverConfig), (type === 'function' ? { Port: 3000 } : {})), { Tag: type === 'container' ? '' : 'function:' });
318
+ const _serverConfig = Object.assign(Object.assign(Object.assign({ OpenAccessTypes: ['OA', 'PUBLIC'], Cpu: 0, Mem: 0, MinNum: 0, MaxNum: 0, PolicyDetails: [], EnvParams: JSON.stringify({}), InitialDelaySeconds: 0, CustomLogs: '', HasDockerfile: true, CreateTime: '', EnvId: envConfig.EnvId, ServerName: serverName, Port: type === 'container' ? 80 : 3000, Dockerfile: 'Dockerfile', BuildDir: '' }, serverConfig), (type === 'function' ? { Port: 3000 } : {})), { Tag: type === 'container' ? '' : 'function:' });
332
319
  return this._upsertFunction(true, {
333
320
  name: serverName,
334
321
  deployInfo,
@@ -362,12 +349,11 @@ class CloudRunService {
362
349
  _upsertFunction(isNew, data) {
363
350
  const { name, deployInfo, serverConfig } = data;
364
351
  const envConfig = this.environment.lazyEnvironmentConfig;
365
- const Items = parseObjectToDiffConfigItem(serverConfig);
366
352
  return this.tcbrService.request(isNew ? 'CreateCloudRunServer' : 'UpdateCloudRunServer', {
367
353
  EnvId: envConfig.EnvId,
368
354
  ServerName: name,
369
355
  DeployInfo: deployInfo,
370
- Items,
356
+ ServerConfig: serverConfig
371
357
  });
372
358
  }
373
359
  }
@@ -440,63 +426,6 @@ async function codeToZip(cwd, options) {
440
426
  await archive.finalize();
441
427
  return bufferPromise;
442
428
  }
443
- /**
444
- * 提交参数变化映射
445
- */
446
- const SUBMIT_DIFF_MAP = {
447
- Cpu: 'CpuSpecs',
448
- Mem: 'MemSpecs',
449
- OpenAccessTypes: 'AccessTypes',
450
- EnvParams: 'EnvParam',
451
- CustomLogs: 'LogPath'
452
- };
453
- /**
454
- * 将 object 参数转为 [{key:"Port", IntValue:80}] 的格式,并且剔除空字符串
455
- */
456
- function parseObjectToDiffConfigItem(data) {
457
- const kvs = Object.entries(data);
458
- const Items = [];
459
- kvs.forEach(([k, v]) => {
460
- const Key = SUBMIT_DIFF_MAP[k] || k;
461
- if ([
462
- 'CustomLogs',
463
- 'EnvParams',
464
- 'CreateTime',
465
- 'Dockerfile',
466
- 'BuildDir',
467
- 'LogType',
468
- 'LogSetId',
469
- 'LogTopicId',
470
- 'LogParseType',
471
- 'Tag',
472
- 'InternalAccess',
473
- 'InternalDomain',
474
- 'OperationMode',
475
- 'SessionAffinity'
476
- ].includes(k)) {
477
- !!v && Items.push({ Key, Value: v });
478
- }
479
- else if (['MinNum', 'MaxNum', 'InitialDelaySeconds', 'Port'].includes(k)) {
480
- Items.push({ Key, IntValue: v });
481
- }
482
- else if (['HasDockerfile'].includes(k)) {
483
- Items.push({ Key, BoolValue: v });
484
- }
485
- else if (['Cpu', 'Mem'].includes(k)) {
486
- Items.push({ Key, FloatValue: v });
487
- }
488
- else if (['OpenAccessTypes', 'EntryPoint', 'Cmd'].includes(k)) {
489
- Items.push({ Key, ArrayValue: v });
490
- }
491
- else if (['PolicyDetails'].includes(k)) {
492
- Items.push({ Key, PolicyDetails: v });
493
- }
494
- else if (['TimerScale'].includes(k)) {
495
- Items.push({ Key, TimerScale: v });
496
- }
497
- });
498
- return Items;
499
- }
500
429
 
501
430
 
502
431
  /***/ }),
@@ -48616,7 +48545,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
48616
48545
  exports.cloudBaseRequest = cloudBaseRequest;
48617
48546
  const auth_1 = __webpack_require__(23506);
48618
48547
  const http_request_1 = __webpack_require__(72088);
48619
- const SUPPORT_REGIONS = ['ap-shanghai', 'ap-guangzhou', 'ap-singapore'];
48548
+ const SUPPORT_REGIONS = ['ap-shanghai', 'ap-guangzhou'];
48620
48549
  async function cloudBaseRequest(options) {
48621
48550
  // const url = 'https://tcb-admin.tencentcloudapi.com/admin'
48622
48551
  const { config, params = {}, method = 'POST', headers = {} } = options;
@@ -48630,11 +48559,11 @@ async function cloudBaseRequest(options) {
48630
48559
  let internalRegionEndpoint = '';
48631
48560
  if (finalRegion) {
48632
48561
  if (SUPPORT_REGIONS.includes(finalRegion)) {
48633
- internetRegionEndpoint = `${envId}.${finalRegion}.tcb-api.tencentcloudapi.com`;
48634
- internalRegionEndpoint = `${envId}.internal.${finalRegion}.tcb-api.tencentcloudapi.com`;
48562
+ internetRegionEndpoint = `${finalRegion}.tcb-api.tencentcloudapi.com`;
48563
+ internalRegionEndpoint = `internal.${finalRegion}.tcb-api.tencentcloudapi.com`;
48635
48564
  }
48636
48565
  else {
48637
- console.warn('当前仅支持上海,广州,新加坡地域,其他地域默认解析到固定域名(上海地域)');
48566
+ console.warn('当前仅支持上海,广州地域,其他地域默认解析到固定域名(上海地域)');
48638
48567
  internetRegionEndpoint = `tcb-api.tencentcloudapi.com`;
48639
48568
  internalRegionEndpoint = `internal.tcb-api.tencentcloudapi.com`;
48640
48569
  }
@@ -90227,20 +90156,19 @@ class EnvService {
90227
90156
  });
90228
90157
  }
90229
90158
  getCos() {
90230
- const internalEndpoint = this.environment.cloudBaseContext.isInternalEndpoint();
90231
90159
  const { secretId, secretKey, token } = this.environment.getAuthConfig();
90232
90160
  const cosConfig = {
90233
90161
  SecretId: secretId,
90234
90162
  SecretKey: secretKey,
90235
90163
  SecurityToken: token,
90236
- Domain: internalEndpoint ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
90164
+ Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
90237
90165
  };
90238
90166
  if (constant_1.COS_SDK_PROTOCOL) {
90239
90167
  cosConfig.Protocol = (constant_1.COS_SDK_PROTOCOL.endsWith(':')
90240
90168
  ? constant_1.COS_SDK_PROTOCOL.toLowerCase()
90241
90169
  : constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':');
90242
90170
  }
90243
- if (internalEndpoint) {
90171
+ if (constant_1.USE_INTERNAL_ENDPOINT) {
90244
90172
  cosConfig.Protocol = 'http:';
90245
90173
  }
90246
90174
  return new cos_nodejs_sdk_v5_1.default(cosConfig);
@@ -135084,7 +135012,7 @@ class TelemetryReporter {
135084
135012
  const nodeVersion = process.version; // Node.js版本
135085
135013
  const arch = os_1.default.arch(); // 系统架构
135086
135014
  // 从构建时注入的版本号获取MCP版本信息
135087
- const mcpVersion = process.env.npm_package_version || "2.2.0" || 0;
135015
+ const mcpVersion = process.env.npm_package_version || "2.3.0" || 0;
135088
135016
  return {
135089
135017
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
135090
135018
  deviceId: this.deviceId,
@@ -179682,7 +179610,6 @@ exports.sleep = sleep;
179682
179610
  exports.upperCaseStringFisrt = upperCaseStringFisrt;
179683
179611
  exports.upperCaseObjKey = upperCaseObjKey;
179684
179612
  exports.fetchTemplates = fetchTemplates;
179685
- exports.successLog = successLog;
179686
179613
  const archiver_1 = __importDefault(__webpack_require__(99133));
179687
179614
  const crypto_1 = __importDefault(__webpack_require__(55511));
179688
179615
  const fs_extra_1 = __importDefault(__webpack_require__(21605));
@@ -179961,10 +179888,6 @@ const getCompleteTimeRange = (timeRange) => {
179961
179888
  };
179962
179889
  };
179963
179890
  exports.getCompleteTimeRange = getCompleteTimeRange;
179964
- function successLog(msg) {
179965
- // 空格,兼容中文字符编码长度问题
179966
- console.log(`${msg}`);
179967
- }
179968
179891
 
179969
179892
 
179970
179893
  /***/ }),
@@ -191293,25 +191216,20 @@ function callSuccessCallback(callback, result) {
191293
191216
  /***/ }),
191294
191217
 
191295
191218
  /***/ 65607:
191296
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
191219
+ /***/ ((__unused_webpack_module, exports) => {
191297
191220
 
191298
191221
  "use strict";
191299
191222
 
191300
191223
  Object.defineProperty(exports, "__esModule", ({ value: true }));
191301
191224
  exports.CloudBaseContext = void 0;
191302
- const constant_1 = __webpack_require__(40762);
191303
191225
  class CloudBaseContext {
191304
- constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined }) {
191226
+ constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '' }) {
191305
191227
  this.secretId = secretId;
191306
191228
  this.secretKey = secretKey;
191307
191229
  this.token = token;
191308
191230
  this.proxy = proxy;
191309
191231
  this.region = region;
191310
191232
  this.envType = envType;
191311
- this.useInternalEndpoint = useInternalEndpoint;
191312
- }
191313
- isInternalEndpoint() {
191314
- return this.useInternalEndpoint !== undefined ? this.useInternalEndpoint : constant_1.USE_INTERNAL_ENDPOINT;
191315
191233
  }
191316
191234
  }
191317
191235
  exports.CloudBaseContext = CloudBaseContext;
@@ -200838,7 +200756,7 @@ ${envIdSection}
200838
200756
  ## 环境信息
200839
200757
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
200840
200758
  - Node.js版本: ${process.version}
200841
- - MCP 版本:${process.env.npm_package_version || "2.2.0" || 0}
200759
+ - MCP 版本:${process.env.npm_package_version || "2.3.0" || 0}
200842
200760
  - 系统架构: ${os_1.default.arch()}
200843
200761
  - 时间: ${new Date().toISOString()}
200844
200762
  - 请求ID: ${requestId}
@@ -203730,7 +203648,6 @@ class StorageService {
203730
203648
  * 获取 COS 配置
203731
203649
  */
203732
203650
  getCos(parallel = 20) {
203733
- const internalEndpoint = this.environment.cloudBaseContext.isInternalEndpoint();
203734
203651
  const { secretId, secretKey, token, proxy } = this.environment.getAuthConfig();
203735
203652
  const cosProxy = process.env.TCB_COS_PROXY;
203736
203653
  const cosConfig = {
@@ -203739,14 +203656,14 @@ class StorageService {
203739
203656
  SecretKey: secretKey,
203740
203657
  Proxy: cosProxy || proxy,
203741
203658
  SecurityToken: token,
203742
- Domain: internalEndpoint ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
203659
+ Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
203743
203660
  };
203744
203661
  if (constant_1.COS_SDK_PROTOCOL) {
203745
203662
  cosConfig.Protocol = (constant_1.COS_SDK_PROTOCOL.endsWith(':')
203746
203663
  ? constant_1.COS_SDK_PROTOCOL.toLowerCase()
203747
203664
  : constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':');
203748
203665
  }
203749
- if (internalEndpoint) {
203666
+ if (constant_1.USE_INTERNAL_ENDPOINT) {
203750
203667
  cosConfig.Protocol = 'http:';
203751
203668
  }
203752
203669
  // COSSDK 默认开启 KeepAlive,这里提供关闭的方式
@@ -215177,12 +215094,15 @@ const IDE_TYPES = [
215177
215094
  "roocode", // RooCode AI编辑器
215178
215095
  "tongyi-lingma", // 通义灵码
215179
215096
  "trae", // Trae AI编辑器
215097
+ "qoder", // Qoder AI编辑器
215098
+ "antigravity", // Google Antigravity AI编辑器
215180
215099
  "vscode", // Visual Studio Code
215181
215100
  ];
215182
215101
  // IDE到文件的映射关系
215102
+ // 注意:以 "/" 结尾的路径表示目录,会包含该目录下的所有文件
215183
215103
  const IDE_FILE_MAPPINGS = {
215184
- cursor: [".cursor/rules/cloudbase-rules.mdc", ".cursor/mcp.json"],
215185
- windsurf: [".windsurf/rules/cloudbase-rules.md"],
215104
+ cursor: [".cursor/rules/", ".cursor/mcp.json"],
215105
+ windsurf: [".windsurf/rules/"],
215186
215106
  codebuddy: [".rules/cloudbase-rules.md", "CODEBUDDY.md", ".mcp.json"],
215187
215107
  "claude-code": [
215188
215108
  "CLAUDE.md",
@@ -215192,7 +215112,7 @@ const IDE_FILE_MAPPINGS = {
215192
215112
  ".claude/commands/spec.md",
215193
215113
  ".claude/commands/no_spec.md",
215194
215114
  ],
215195
- cline: [".clinerules/cloudbase-rules.mdc"],
215115
+ cline: [".clinerules/"],
215196
215116
  "gemini-cli": [".gemini/GEMINI.md", ".gemini/settings.json"],
215197
215117
  opencode: [".opencode.json"],
215198
215118
  "qwen-code": [".qwen/QWEN.md", ".qwen/settings.json"],
@@ -215206,7 +215126,9 @@ const IDE_FILE_MAPPINGS = {
215206
215126
  "github-copilot": [".github/copilot-instructions.md"],
215207
215127
  roocode: [".roo/rules/cloudbaase-rules.md", ".roo/mcp.json"],
215208
215128
  "tongyi-lingma": [".lingma/rules/cloudbaase-rules.md"],
215209
- trae: [".trae/rules/cloudbase-rules.md"],
215129
+ trae: [".trae/rules/"],
215130
+ qoder: [".qoder/rules/"],
215131
+ antigravity: [".agent/rules/"],
215210
215132
  vscode: [".vscode/mcp.json", ".vscode/settings.json"],
215211
215133
  };
215212
215134
  // 所有IDE配置文件的完整列表 - 通过IDE_FILE_MAPPINGS计算得出
@@ -215231,6 +215153,8 @@ const IDE_DESCRIPTIONS = {
215231
215153
  roocode: "RooCode AI编辑器",
215232
215154
  "tongyi-lingma": "通义灵码",
215233
215155
  trae: "Trae AI编辑器",
215156
+ qoder: "Qoder AI编辑器",
215157
+ antigravity: "Google Antigravity AI编辑器",
215234
215158
  vscode: "Visual Studio Code",
215235
215159
  };
215236
215160
  // INTEGRATION_IDE 环境变量值到 IDE 类型的映射
@@ -215252,6 +215176,8 @@ const INTEGRATION_IDE_MAPPING = {
215252
215176
  RooCode: "roocode",
215253
215177
  "Tongyi Lingma": "tongyi-lingma",
215254
215178
  Trae: "trae",
215179
+ Qoder: "qoder",
215180
+ Antigravity: "antigravity",
215255
215181
  VSCode: "vscode",
215256
215182
  };
215257
215183
  // 根据 INTEGRATION_IDE 环境变量获取默认 IDE 类型
@@ -215402,6 +215328,17 @@ function validateIDE(ide) {
215402
215328
  }
215403
215329
  return { valid: true };
215404
215330
  }
215331
+ // 检查文件是否匹配给定的路径(支持文件和目录)
215332
+ function matchesPath(file, pathPattern) {
215333
+ if (pathPattern.endsWith("/")) {
215334
+ // 目录路径:检查文件是否在该目录下
215335
+ return file.startsWith(pathPattern);
215336
+ }
215337
+ else {
215338
+ // 文件路径:精确匹配
215339
+ return file === pathPattern;
215340
+ }
215341
+ }
215405
215342
  // 文件过滤函数
215406
215343
  function filterFilesByIDE(files, ide) {
215407
215344
  if (ide === "all") {
@@ -215412,9 +215349,32 @@ function filterFilesByIDE(files, ide) {
215412
215349
  return files; // 如果找不到映射,返回所有文件
215413
215350
  }
215414
215351
  // 计算需要排除的IDE文件(除了当前IDE需要的文件)
215415
- const filesToExclude = ALL_IDE_FILES.filter((file) => !ideFiles.includes(file));
215352
+ const filesToExclude = [];
215353
+ // 遍历所有IDE文件,找出不属于当前IDE的文件
215354
+ for (const ideFile of ALL_IDE_FILES) {
215355
+ // 检查这个文件是否属于当前IDE需要的文件
215356
+ let isCurrentIDEFile = false;
215357
+ for (const currentIDEFile of ideFiles) {
215358
+ if (matchesPath(ideFile, currentIDEFile)) {
215359
+ isCurrentIDEFile = true;
215360
+ break;
215361
+ }
215362
+ }
215363
+ // 如果不属于当前IDE,加入排除列表
215364
+ if (!isCurrentIDEFile) {
215365
+ filesToExclude.push(ideFile);
215366
+ }
215367
+ }
215416
215368
  // 排除不需要的IDE配置文件,保留其他所有文件
215417
- return files.filter((file) => !filesToExclude.includes(file));
215369
+ return files.filter((file) => {
215370
+ // 检查文件是否应该被排除
215371
+ for (const excludePath of filesToExclude) {
215372
+ if (matchesPath(file, excludePath)) {
215373
+ return false; // 排除
215374
+ }
215375
+ }
215376
+ return true; // 保留
215377
+ });
215418
215378
  }
215419
215379
  // 创建过滤后的目录结构
215420
215380
  async function createFilteredDirectory(extractDir, filteredFiles, ide) {
@@ -215441,7 +215401,7 @@ function registerSetupTools(server) {
215441
215401
  title: "下载项目模板",
215442
215402
  description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
215443
215403
 
215444
- **CRITICAL**: This tool MUST be called FIRST when starting a new project.\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 ? "2.2.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
215404
+ **CRITICAL**: This tool MUST be called FIRST when starting a new project.\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- qoder: Qoder AI编辑器\n- antigravity: Google Antigravity AI编辑器\n- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.3.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
215445
215405
  inputSchema: {
215446
215406
  template: zod_1.z
215447
215407
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
@@ -226497,7 +226457,6 @@ class CloudService {
226497
226457
  this.cloudBaseContext = context;
226498
226458
  }
226499
226459
  get baseUrl() {
226500
- const internalEndpoint = this.cloudBaseContext.isInternalEndpoint();
226501
226460
  const tcb = process.env.TCB_BASE_URL || 'https://tcb.tencentcloudapi.com';
226502
226461
  const urlMap = {
226503
226462
  tcb,
@@ -226511,7 +226470,7 @@ class CloudService {
226511
226470
  const intranetUrlMap = Object.keys(urlMap).map((service) => ({
226512
226471
  [service]: `https://${service}.internal.tencentcloudapi.com`,
226513
226472
  })).reduce((acc, cur) => (Object.assign(Object.assign({}, acc), cur)), {});
226514
- if (internalEndpoint) {
226473
+ if (constant_1.USE_INTERNAL_ENDPOINT) {
226515
226474
  return intranetUrlMap[this.service];
226516
226475
  }
226517
226476
  if (urlMap[this.service]) {
@@ -270144,7 +270103,7 @@ class CloudBase {
270144
270103
  }
270145
270104
  constructor(config = {}) {
270146
270105
  this.cloudBaseConfig = {};
270147
- let { secretId, secretKey, token, envId, proxy, region, envType, useInternalEndpoint } = config;
270106
+ let { secretId, secretKey, token, envId, proxy, region, envType } = config;
270148
270107
  // config 中传入的 secretId secretkey 必须同时存在
270149
270108
  if ((secretId && !secretKey) || (!secretId && secretKey)) {
270150
270109
  throw new Error('secretId and secretKey must be a pair');
@@ -270156,8 +270115,7 @@ class CloudBase {
270156
270115
  envId,
270157
270116
  envType,
270158
270117
  proxy,
270159
- region,
270160
- useInternalEndpoint
270118
+ region
270161
270119
  };
270162
270120
  // 初始化 context
270163
270121
  this.context = new context_1.CloudBaseContext(this.cloudBaseConfig);
@@ -270212,9 +270170,6 @@ class CloudBase {
270212
270170
  getManagerConfig() {
270213
270171
  return this.cloudBaseConfig;
270214
270172
  }
270215
- get isInternalEndpoint() {
270216
- return this.context.isInternalEndpoint();
270217
- }
270218
270173
  }
270219
270174
  module.exports = CloudBase;
270220
270175
 
@@ -272293,7 +272248,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
272293
272248
  exports.FunctionService = void 0;
272294
272249
  const fs_1 = __importDefault(__webpack_require__(29021));
272295
272250
  const path_1 = __importDefault(__webpack_require__(39902));
272296
- const lodash_1 = __importDefault(__webpack_require__(2543));
272297
272251
  const packer_1 = __webpack_require__(5147);
272298
272252
  const error_1 = __webpack_require__(40430);
272299
272253
  const utils_1 = __webpack_require__(62358);
@@ -272540,96 +272494,20 @@ class FunctionService {
272540
272494
  });
272541
272495
  return data;
272542
272496
  }
272543
- /**
272544
- * 列出所有函数
272545
- * @param {IListFunctionOptions} options
272546
- * @returns {Promise<Record<string, string>[]>}
272547
- */
272548
- async listAllFunctions(options) {
272549
- const allFunctions = [];
272550
- let currentOffset = 0;
272551
- const pageSize = 20;
272552
- const { envId } = options;
272553
- while (true) {
272554
- try {
272555
- const res = await this.scfService.request('ListFunctions', {
272556
- Namespace: envId,
272557
- Limit: pageSize,
272558
- Offset: currentOffset
272559
- });
272560
- const { Functions = [], TotalCount } = res;
272561
- if (Functions.length === 0) {
272562
- break;
272563
- }
272564
- allFunctions.push(...Functions);
272565
- // 检查是否已获取所有函数
272566
- if (allFunctions.length >= TotalCount || Functions.length < pageSize) {
272567
- break;
272568
- }
272569
- currentOffset += pageSize;
272570
- }
272571
- catch (error) {
272572
- throw new error_1.CloudBaseError(`获取函数列表失败: ${error.message}`);
272573
- }
272574
- }
272575
- // 格式化数据
272576
- const data = [];
272577
- allFunctions.forEach(func => {
272578
- const { FunctionId, FunctionName, Runtime, AddTime, ModTime, Status } = func;
272579
- data.push({
272580
- FunctionId,
272581
- FunctionName,
272582
- Runtime,
272583
- AddTime,
272584
- ModTime,
272585
- Status
272586
- });
272587
- });
272588
- return data;
272589
- }
272590
272497
  /**
272591
272498
  * 删除云函数
272592
272499
  * @param {string} name 云函数名称
272593
272500
  * @param {string} qualifier 需要删除的版本号,不填默认删除函数下全部版本。
272594
272501
  * @returns {Promise<IResponseInfo>}
272595
272502
  */
272596
- async deleteFunction({ name }) {
272597
- var _a;
272503
+ async deleteFunction(name, qualifier) {
272598
272504
  const { namespace } = this.getFunctionConfig();
272599
- // 检测是否绑定了 API 网关
272600
- const accessService = this.environment.getAccessService();
272601
- const res = await accessService.getAccessList({
272602
- name
272603
- });
272604
- // 删除绑定的 API 网关
272605
- if (((_a = res === null || res === void 0 ? void 0 : res.APISet) === null || _a === void 0 ? void 0 : _a.length) > 0) {
272606
- await accessService.deleteAccess({
272607
- name
272608
- });
272609
- }
272610
- await this.scfService.request('DeleteFunction', {
272505
+ return this.scfService.request('DeleteFunction', {
272611
272506
  FunctionName: name,
272612
- Namespace: namespace
272507
+ Namespace: namespace,
272508
+ Qualifier: qualifier
272613
272509
  });
272614
272510
  }
272615
- /**
272616
- * 批量删除云函数
272617
- * @param {Object} options
272618
- * @param {string[]} options.names 云函数名称列表
272619
- * @returns {Promise<void>}
272620
- */
272621
- async batchDeleteFunctions({ names }) {
272622
- const promises = names.map(name => (async () => {
272623
- try {
272624
- await this.deleteFunction({ name });
272625
- (0, utils_1.successLog)(`[${name}] 函数删除成功!`);
272626
- }
272627
- catch (e) {
272628
- throw new error_1.CloudBaseError(e.message);
272629
- }
272630
- })());
272631
- await Promise.all(promises);
272632
- }
272633
272511
  /**
272634
272512
  * 获取云函数详细信息
272635
272513
  * @param {string} name 云函数名称
@@ -272664,35 +272542,13 @@ class FunctionService {
272664
272542
  }
272665
272543
  catch (e) {
272666
272544
  data.VpcConfig = {
272667
- vpc: 'VpcId',
272668
- subnet: 'SubnetId'
272545
+ vpc: '',
272546
+ subnet: ''
272669
272547
  };
272670
272548
  }
272671
272549
  }
272672
272550
  return data;
272673
272551
  }
272674
- /**
272675
- * 批量获取云函数详细信息
272676
- * @param {Object} options
272677
- * @param {string[]} options.names 云函数名称列表
272678
- * @param {string} options.envId 环境 ID
272679
- * @param {string} options.codeSecret
272680
- * @returns {Promise<IFunctionInfo[]>}
272681
- */
272682
- async batchGetFunctionsDetail({ names, envId, codeSecret }) {
272683
- const data = [];
272684
- const promises = names.map(name => (async () => {
272685
- try {
272686
- const info = await this.getFunctionDetail(name, codeSecret);
272687
- data.push(info);
272688
- }
272689
- catch (e) {
272690
- throw new error_1.CloudBaseError(`${name} 获取信息失败:${e.message}`);
272691
- }
272692
- })());
272693
- await Promise.all(promises);
272694
- return data;
272695
- }
272696
272552
  /**
272697
272553
  * 获取函数日志
272698
272554
  * @deprecated 请使用 getFunctionLogsV2 代替
@@ -272789,33 +272645,6 @@ class FunctionService {
272789
272645
  const res = await this.tcbService.request('GetFunctionLogDetail', params);
272790
272646
  return res;
272791
272647
  }
272792
- /**
272793
- * 获取函数的完整调用日志
272794
- * 该方法会自动完成两步操作:1. 获取日志请求ID列表。 2. 根据ID列表获取每条日志的详细内容。
272795
- * @param {IFunctionLogOptionsV2} options - 查询选项
272796
- * @returns {Promise<IFunctionLogDetailRes[]>} 返回包含完整日志详情的数组
272797
- */
272798
- async getCompleteFunctionLogs(options) {
272799
- // 调用 getFunctionLogsV2 获取日志请求ID列表
272800
- const { name } = options;
272801
- const logs = await this.getFunctionLogsV2(options);
272802
- // 如果没有日志,直接返回空数组
272803
- if (logs.LogList.length === 0) {
272804
- return [];
272805
- }
272806
- const detailPromises = logs.LogList.map(async (log) => {
272807
- // 对每一个日志ID,调用 getFunctionLogDetail
272808
- const res = await this.getFunctionLogDetail({
272809
- logRequestId: log.RequestId,
272810
- startTime: options.startTime,
272811
- endTime: options.endTime
272812
- });
272813
- return Object.assign(Object.assign({}, res), { RetCode: log.RetCode, FunctionName: name });
272814
- });
272815
- // 并发执行所有详情查询,等待它们全部完成
272816
- const detailedLogs = await Promise.all(detailPromises);
272817
- return detailedLogs;
272818
- }
272819
272648
  /**
272820
272649
  * 更新云函数配置
272821
272650
  * @param {ICloudFunction} func 云函数配置
@@ -272951,28 +272780,6 @@ class FunctionService {
272951
272780
  throw new error_1.CloudBaseError(`[${name}] 调用失败:\n${e.message}`);
272952
272781
  }
272953
272782
  }
272954
- /**
272955
- * 批量调用云函数
272956
- * @param {IFunctionBatchOptions} options
272957
- * @returns {Promise<IFunctionInvokeRes[]>}
272958
- */
272959
- async batchInvokeFunctions(options) {
272960
- const { functions, envId, log = false } = options;
272961
- const promises = functions.map(func => (async () => {
272962
- try {
272963
- const result = await this.invokeFunction(func.name, func.params);
272964
- if (log) {
272965
- (0, utils_1.successLog)(`[${func.name}] 调用成功\n响应结果:\n`);
272966
- console.log(result);
272967
- }
272968
- return result;
272969
- }
272970
- catch (e) {
272971
- throw new error_1.CloudBaseError(`${func.name} 函数调用失败:${e.message}`);
272972
- }
272973
- })());
272974
- return Promise.all(promises);
272975
- }
272976
272783
  /**
272977
272784
  * 复制云函数
272978
272785
  * @param {string} name 云函数名称
@@ -273015,34 +272822,12 @@ class FunctionService {
273015
272822
  TriggerDesc: item.config
273016
272823
  };
273017
272824
  });
273018
- try {
273019
- return await this.scfService.request('BatchCreateTrigger', {
273020
- FunctionName: name,
273021
- Namespace: namespace,
273022
- Triggers: JSON.stringify(parsedTriggers),
273023
- Count: parsedTriggers.length
273024
- });
273025
- }
273026
- catch (e) {
273027
- throw new error_1.CloudBaseError(`[${name}] 创建触发器失败:${e.message}`, {
273028
- action: e.action,
273029
- code: e.code
273030
- });
273031
- }
273032
- }
273033
- // 批量部署函数触发器
273034
- async batchCreateTriggers(options) {
273035
- const { functions, envId } = options;
273036
- const promises = functions.map(func => (async () => {
273037
- try {
273038
- await this.createFunctionTriggers(func.name, func.triggers);
273039
- (0, utils_1.successLog)(`[${func.name}] 创建云函数触发器成功!`);
273040
- }
273041
- catch (e) {
273042
- throw new error_1.CloudBaseError(e.message);
273043
- }
273044
- })());
273045
- await Promise.all(promises);
272825
+ return this.scfService.request('BatchCreateTrigger', {
272826
+ FunctionName: name,
272827
+ Namespace: namespace,
272828
+ Triggers: JSON.stringify(parsedTriggers),
272829
+ Count: parsedTriggers.length
272830
+ });
273046
272831
  }
273047
272832
  /**
273048
272833
  * 删除云函数触发器
@@ -273052,50 +272837,12 @@ class FunctionService {
273052
272837
  */
273053
272838
  async deleteFunctionTrigger(name, triggerName) {
273054
272839
  const { namespace } = this.getFunctionConfig();
273055
- try {
273056
- await this.scfService.request('DeleteTrigger', {
273057
- FunctionName: name,
273058
- Namespace: namespace,
273059
- TriggerName: triggerName,
273060
- Type: 'timer'
273061
- });
273062
- (0, utils_1.successLog)(`[${name}] 删除云函数触发器 ${triggerName} 成功!`);
273063
- }
273064
- catch (e) {
273065
- throw new error_1.CloudBaseError(`[${name}] 删除触发器失败:${e.message}`);
273066
- }
273067
- }
273068
- async batchDeleteTriggers(options) {
273069
- const { functions, envId } = options;
273070
- const promises = functions.map(func => (async () => {
273071
- try {
273072
- func.triggers.forEach(async (trigger) => {
273073
- await this.deleteFunctionTrigger(func.name, trigger.name);
273074
- });
273075
- }
273076
- catch (e) {
273077
- throw new error_1.CloudBaseError(e.message);
273078
- }
273079
- })());
273080
- await Promise.all(promises);
273081
- }
273082
- /**
273083
- * 下载云函数代码
273084
- * @param {IFunctionCodeOptions} options
273085
- * @returns {Promise<void>}
273086
- */
273087
- async downloadFunctionCode(options) {
273088
- const { destPath, envId, functionName, codeSecret } = options;
273089
- // 检验路径是否存在
273090
- (0, utils_1.checkFullAccess)(destPath, true);
273091
- // 获取下载链接
273092
- const { Url } = await this.scfService.request('GetFunctionAddress', {
273093
- FunctionName: functionName,
273094
- Namespace: envId,
273095
- CodeSecret: codeSecret
272840
+ return this.scfService.request('DeleteTrigger', {
272841
+ FunctionName: name,
272842
+ Namespace: namespace,
272843
+ TriggerName: triggerName,
272844
+ Type: 'timer'
273096
272845
  });
273097
- // 下载文件
273098
- return (0, utils_1.downloadAndExtractRemoteZip)(Url, destPath);
273099
272846
  }
273100
272847
  /**
273101
272848
  * 获取云函数代码下载 链接
@@ -273121,68 +272868,6 @@ class FunctionService {
273121
272868
  throw new error_1.CloudBaseError(`[${functionName}] 获取函数代码下载链接失败:\n${e.message}`);
273122
272869
  }
273123
272870
  }
273124
- // 函数绑定文件层
273125
- async attachLayer(options) {
273126
- const { envId, functionName, layerName, layerVersion, codeSecret } = options;
273127
- let { Layers = [] } = await this.getFunctionDetail(functionName, codeSecret);
273128
- Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
273129
- // 新加的文件层添加到最后
273130
- Layers.push({
273131
- LayerName: layerName,
273132
- LayerVersion: layerVersion
273133
- });
273134
- const res = await this.scfService.request('UpdateFunctionConfiguration', {
273135
- Layers,
273136
- Namespace: envId,
273137
- FunctionName: functionName
273138
- });
273139
- return res;
273140
- }
273141
- // 函数解绑文件层
273142
- async unAttachLayer(options) {
273143
- const { envId, functionName, layerName, layerVersion, codeSecret } = options;
273144
- let { Layers } = await this.getFunctionDetail(functionName, codeSecret);
273145
- Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
273146
- const index = Layers.findIndex(item => item.LayerName === layerName && item.LayerVersion === layerVersion);
273147
- if (index === -1) {
273148
- throw new error_1.CloudBaseError('层不存在');
273149
- }
273150
- // 删除指定的层
273151
- Layers.splice(index, 1);
273152
- const apiParams = {
273153
- Namespace: envId,
273154
- FunctionName: functionName,
273155
- Layers: Layers.length > 0 ? Layers : [{
273156
- LayerName: '',
273157
- LayerVersion: 0
273158
- }]
273159
- };
273160
- return this.scfService.request('UpdateFunctionConfiguration', apiParams);
273161
- }
273162
- // 更新云函数层
273163
- async updateFunctionLayer(options) {
273164
- const { envId, functionName, layers } = options;
273165
- return this.scfService.request('UpdateFunctionConfiguration', {
273166
- Layers: layers,
273167
- Namespace: envId,
273168
- FunctionName: functionName
273169
- });
273170
- }
273171
- // 下载文件层 ZIP 文件
273172
- async downloadLayer(options) {
273173
- const { name, version, destPath } = options;
273174
- const res = await this.scfService.request('GetLayerVersion', {
273175
- LayerName: name,
273176
- LayerVersion: version
273177
- });
273178
- const url = res === null || res === void 0 ? void 0 : res.Location;
273179
- const zipPath = path_1.default.join(destPath, `${name}-${version}.zip`);
273180
- if ((0, utils_1.checkFullAccess)(zipPath)) {
273181
- throw new error_1.CloudBaseError(`文件已存在:${zipPath}`);
273182
- }
273183
- // 下载文件
273184
- return (0, utils_1.downloadAndExtractRemoteZip)(url, destPath);
273185
- }
273186
272871
  // 创建文件层版本
273187
272872
  async createLayer(options) {
273188
272873
  const { env } = this.getFunctionConfig();
@@ -273255,7 +272940,7 @@ class FunctionService {
273255
272940
  Limit: limit,
273256
272941
  Offset: offset,
273257
272942
  SearchKey: searchKey,
273258
- // SearchSrc: `TCB_${env}`
272943
+ SearchSrc: `TCB_${env}`
273259
272944
  };
273260
272945
  if (runtime) {
273261
272946
  param.CompatibleRuntime = runtime;
@@ -273584,18 +273269,12 @@ __decorate([
273584
273269
  __decorate([
273585
273270
  (0, utils_1.preLazy)()
273586
273271
  ], FunctionService.prototype, "listFunctions", null);
273587
- __decorate([
273588
- (0, utils_1.preLazy)()
273589
- ], FunctionService.prototype, "listAllFunctions", null);
273590
273272
  __decorate([
273591
273273
  (0, utils_1.preLazy)()
273592
273274
  ], FunctionService.prototype, "deleteFunction", null);
273593
273275
  __decorate([
273594
273276
  (0, utils_1.preLazy)()
273595
273277
  ], FunctionService.prototype, "getFunctionDetail", null);
273596
- __decorate([
273597
- (0, utils_1.preLazy)()
273598
- ], FunctionService.prototype, "batchGetFunctionsDetail", null);
273599
273278
  __decorate([
273600
273279
  (0, utils_1.preLazy)()
273601
273280
  ], FunctionService.prototype, "getFunctionLogs", null);
@@ -273605,9 +273284,6 @@ __decorate([
273605
273284
  __decorate([
273606
273285
  (0, utils_1.preLazy)()
273607
273286
  ], FunctionService.prototype, "getFunctionLogDetail", null);
273608
- __decorate([
273609
- (0, utils_1.preLazy)()
273610
- ], FunctionService.prototype, "getCompleteFunctionLogs", null);
273611
273287
  __decorate([
273612
273288
  (0, utils_1.preLazy)()
273613
273289
  ], FunctionService.prototype, "updateFunctionConfig", null);
@@ -273617,9 +273293,6 @@ __decorate([
273617
273293
  __decorate([
273618
273294
  (0, utils_1.preLazy)()
273619
273295
  ], FunctionService.prototype, "invokeFunction", null);
273620
- __decorate([
273621
- (0, utils_1.preLazy)()
273622
- ], FunctionService.prototype, "batchInvokeFunctions", null);
273623
273296
  __decorate([
273624
273297
  (0, utils_1.preLazy)()
273625
273298
  ], FunctionService.prototype, "copyFunction", null);
@@ -273632,18 +273305,6 @@ __decorate([
273632
273305
  __decorate([
273633
273306
  (0, utils_1.preLazy)()
273634
273307
  ], FunctionService.prototype, "getFunctionDownloadUrl", null);
273635
- __decorate([
273636
- (0, utils_1.preLazy)()
273637
- ], FunctionService.prototype, "attachLayer", null);
273638
- __decorate([
273639
- (0, utils_1.preLazy)()
273640
- ], FunctionService.prototype, "unAttachLayer", null);
273641
- __decorate([
273642
- (0, utils_1.preLazy)()
273643
- ], FunctionService.prototype, "updateFunctionLayer", null);
273644
- __decorate([
273645
- (0, utils_1.preLazy)()
273646
- ], FunctionService.prototype, "downloadLayer", null);
273647
273308
  __decorate([
273648
273309
  (0, utils_1.preLazy)()
273649
273310
  ], FunctionService.prototype, "createLayer", null);