@cloudbase/cli 2.9.3 → 2.9.5

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.
@@ -11675,12 +11675,13 @@ let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
11675
11675
  return __awaiter(this, void 0, void 0, function* () {
11676
11676
  const loading = (0, utils_1.loadingFactory)();
11677
11677
  loading.start('数据加载中...');
11678
- const layers = yield (0, function_1.listLayers)({
11678
+ const functionService = yield (0, function_1.getFunctionService)(envId);
11679
+ const listLayersRes = yield functionService.listLayers({
11679
11680
  offset: 0,
11680
11681
  limit: 200,
11681
- searchSrc: `TCB_${envId}`
11682
11682
  });
11683
11683
  loading.stop();
11684
+ const layers = listLayersRes.Layers || [];
11684
11685
  if (!layers.length) {
11685
11686
  throw new error_1.CloudBaseError('当前环境没有可用的文件层,请先创建文件层!');
11686
11687
  }
@@ -11690,10 +11691,11 @@ let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
11690
11691
  message: '选择文件层名称',
11691
11692
  choices: layers.map((item) => item.LayerName)
11692
11693
  });
11693
- let versions = yield (0, function_1.listLayerVersions)({
11694
+ let listLayerVersionsRes = yield functionService.listLayerVersions({
11694
11695
  name: layer
11695
11696
  });
11696
- versions = versions.map((item) => String(item.LayerVersion));
11697
+ const layerVersions = listLayerVersionsRes.LayerVersions || [];
11698
+ const versions = layerVersions.map((item) => String(item.LayerVersion));
11697
11699
  const { version } = yield (0, enquirer_1.prompt)({
11698
11700
  type: 'select',
11699
11701
  name: 'version',
@@ -11701,7 +11703,7 @@ let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
11701
11703
  choices: versions
11702
11704
  });
11703
11705
  loading.start('文件层删除中...');
11704
- yield (0, function_1.deleteLayer)({
11706
+ yield functionService.deleteLayerVersion({
11705
11707
  name: layer,
11706
11708
  version: Number(version)
11707
11709
  });
@@ -17486,7 +17488,7 @@ let PullCommand = class PullCommand extends common_1.Command {
17486
17488
  desc: '强制清理目标输出目录(慎用)'
17487
17489
  }
17488
17490
  ],
17489
- desc: '拉取项目模板\n\n支持的内置模板:\n miniprogram - 微信小程序 + CloudBase\n react - Web 应用 - React + CloudBase\n vue - Web 应用 - Vue + CloudBase\n uniapp - 跨端应用 - UniApp + CloudBase\n rules - AI 规则和配置\n\n支持的 Git 仓库:\n GitHub: https://github.com/user/repo\n Gitee: https://gitee.com/user/repo\n SSH: git@github.com:user/repo.git\n\n支持 Git 子目录:\n https://github.com/user/repo/tree/main/src/templates\n\n示例:\n tcb pull miniprogram\n tcb pull https://github.com/user/repo\n tcb pull https://github.com/user/repo/tree/main/examples --output ./my-project',
17491
+ desc: '拉取项目模板\n\n支持的内置模板:\n miniprogram - 微信小程序 + CloudBase\n react - Web 应用 - React + CloudBase\n vue - Web 应用 - Vue + CloudBase\n uniapp - 跨端应用 - UniApp + CloudBase\n rules - AI 规则和配置\n\n支持的 Git 仓库:\n GitHub: https://github.com/user/repo\n Gitee: https://gitee.com/user/repo\n CNB: https://cnb.cool/user/repo\n SSH: git@github.com:user/repo.git\n\n支持 Git 子目录:\n https://github.com/user/repo/tree/main/src/templates\n https://cnb.cool/user/repo/tree/main/examples\n\n示例:\n tcb pull miniprogram\n tcb pull https://github.com/user/repo\n tcb pull https://cnb.cool/user/repo\n tcb pull https://cnb.cool/user/repo/tree/main/examples --output ./my-project',
17490
17492
  requiredEnvId: false,
17491
17493
  withoutAuth: true
17492
17494
  };
@@ -17525,6 +17527,7 @@ let PullCommand = class PullCommand extends common_1.Command {
17525
17527
  log.info('\n🌐 支持的 Git 仓库格式:');
17526
17528
  log.info(' GitHub: https://github.com/user/repo');
17527
17529
  log.info(' Gitee: https://gitee.com/user/repo');
17530
+ log.info(' CNB: https://cnb.cool/user/repo');
17528
17531
  log.info(' SSH: git@github.com:user/repo.git');
17529
17532
  log.info('\n📁 支持 Git 子目录:');
17530
17533
  log.info(' https://github.com/user/repo/tree/main/src/templates');
@@ -42400,7 +42403,7 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
42400
42403
  /***/ ((module) => {
42401
42404
 
42402
42405
  "use strict";
42403
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.9.2","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"npm run build","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","out:prune":"bash build/scripts/prune-out.sh"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js","ccr":"bin/ccr.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^1.8.40","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.11","@cloudbase/lowcode-cli":"^0.22.2","@cloudbase/manager-node":"4.5.0","@cloudbase/toolbox":"^0.7.9","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","i":"^0.3.7","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","simple-git":"^3.28.0","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557"}');
42406
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.9.4","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"npm run build","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","out:prune":"bash build/scripts/prune-out.sh"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"ccr":"bin/ccr.js","cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^1.8.41","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.11","@cloudbase/lowcode-cli":"^0.22.2","@cloudbase/manager-node":"4.6.1","@cloudbase/toolbox":"^0.7.9","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","i":"^0.3.7","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","simple-git":"^3.28.0","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557"}');
42404
42407
 
42405
42408
  /***/ }),
42406
42409
 
@@ -42799,6 +42802,7 @@ const getArgs = () => {
42799
42802
  .help(false)
42800
42803
  .alias('e', 'envId')
42801
42804
  .alias('r', 'region')
42805
+ .alias('v', 'version')
42802
42806
  .argv;
42803
42807
  };
42804
42808
  exports.getArgs = getArgs;
@@ -67569,8 +67573,8 @@ class AISetupWizard {
67569
67573
  type: 'list',
67570
67574
  name: 'agent',
67571
67575
  message: `${message} ${const_1.LIST_HINT}`,
67572
- choices: [const_1.CLAUDE, const_1.QWEN, const_1.CODEX, const_1.CURSOR, const_1.AIDER, const_1.CODEBUDDY, ...(includeNone ? [const_1.NONE] : [])],
67573
- default: const_1.CLAUDE.value
67576
+ choices: [const_1.CODEBUDDY, const_1.CLAUDE, const_1.QWEN, const_1.CODEX, const_1.CURSOR, const_1.AIDER, ...(includeNone ? [const_1.NONE] : [])],
67577
+ default: const_1.CODEBUDDY.value
67574
67578
  }
67575
67579
  ]);
67576
67580
  return agent;
@@ -67646,6 +67650,10 @@ class AISetupWizard {
67646
67650
  name: 'DeepSeek - https://api.deepseek.com/anthropic',
67647
67651
  value: 'https://api.deepseek.com/anthropic'
67648
67652
  },
67653
+ {
67654
+ name: 'LongCat - https://api.longcat.chat/anthropic',
67655
+ value: 'https://api.longcat.chat/anthropic'
67656
+ },
67649
67657
  { name: '🛠️ 自定义 URL', value: 'custom' }
67650
67658
  ],
67651
67659
  default: 'https://api.moonshot.cn/anthropic'
@@ -67670,7 +67678,7 @@ class AISetupWizard {
67670
67678
  {
67671
67679
  type: 'password',
67672
67680
  name: 'apiKey',
67673
- message: 'Claude Auth Token:',
67681
+ message: 'Auth Token:',
67674
67682
  validate: (input) => input.length > 0 || '请输入有效的 Auth Token'
67675
67683
  }
67676
67684
  ]);
@@ -67687,6 +67695,9 @@ class AISetupWizard {
67687
67695
  else if (baseUrl === 'https://api.deepseek.com/anthropic') {
67688
67696
  defaultModel = 'deepseek-chat';
67689
67697
  }
67698
+ else if (baseUrl === 'https://api.longcat.chat/anthropic') {
67699
+ defaultModel = 'LongCat-Flash-Chat';
67700
+ }
67690
67701
  else {
67691
67702
  defaultModel = '';
67692
67703
  }
@@ -67745,7 +67756,7 @@ class AISetupWizard {
67745
67756
  {
67746
67757
  type: 'password',
67747
67758
  name: 'apiKey',
67748
- message: 'Qwen API Key:',
67759
+ message: 'API Key:',
67749
67760
  validate: (input) => input.length > 0 || '请输入有效的 API Key'
67750
67761
  },
67751
67762
  {
@@ -67801,6 +67812,10 @@ class AISetupWizard {
67801
67812
  name: '智谱 - https://open.bigmodel.cn/api/paas/v4',
67802
67813
  value: 'https://open.bigmodel.cn/api/paas/v4'
67803
67814
  },
67815
+ {
67816
+ name: 'LongCat - https://api.longcat.chat/openai',
67817
+ value: 'https://api.longcat.chat/openai'
67818
+ },
67804
67819
  { name: '🛠️ 自定义 URL', value: 'custom' }
67805
67820
  ],
67806
67821
  default: 'https://api.moonshot.cn/v1'
@@ -67880,6 +67895,10 @@ class AISetupWizard {
67880
67895
  name: '智谱 - https://open.bigmodel.cn/api/paas/v4',
67881
67896
  value: 'https://open.bigmodel.cn/api/paas/v4'
67882
67897
  },
67898
+ {
67899
+ name: 'LongCat - https://api.longcat.chat/openai',
67900
+ value: 'https://api.longcat.chat/openai'
67901
+ },
67883
67902
  { name: '🛠️ 自定义 URL', value: 'custom' }
67884
67903
  ],
67885
67904
  default: 'https://api.moonshot.cn/v1'
@@ -68028,11 +68047,11 @@ class AISetupWizard {
68028
68047
  message: `选择配置方式: ${const_1.LIST_HINT}`,
68029
68048
  choices: [
68030
68049
  {
68031
- name: '使用 Codebuddy Code CLI 内置鉴权方式(如 OAuth)',
68050
+ name: '使用 CodeBuddy 账号登录',
68032
68051
  value: 'none'
68033
68052
  },
68034
68053
  {
68035
- name: '配置 API KEY(用于无交互环境)',
68054
+ name: '配置 CodeBuddy API KEY(用于无交互环境)',
68036
68055
  value: 'custom'
68037
68056
  }
68038
68057
  ],
@@ -68044,8 +68063,8 @@ class AISetupWizard {
68044
68063
  {
68045
68064
  type: 'password',
68046
68065
  name: 'apiKey',
68047
- message: '请输入 Codebuddy API Key:',
68048
- validate: (input) => input.trim().length > 0 || 'API Key 不能为空'
68066
+ message: 'API Key:',
68067
+ validate: (input) => input.trim().length > 0 || '请输入有效的 API Key'
68049
68068
  }
68050
68069
  ]);
68051
68070
  yield this.aiConfigManager.updateCodebuddyConfig('custom', {
@@ -68055,7 +68074,7 @@ class AISetupWizard {
68055
68074
  else {
68056
68075
  yield this.aiConfigManager.updateCodebuddyConfig('none', {});
68057
68076
  }
68058
- log.info('✅ Codebuddy Code CLI 配置完成');
68077
+ log.info('✅ CodeBuddy Code 配置完成');
68059
68078
  log.info('💡 提示:首次使用时会自动打开浏览器进行 OAuth 身份验证');
68060
68079
  });
68061
68080
  }
@@ -107404,6 +107423,7 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
107404
107423
  return __awaiter(this, void 0, void 0, function* () {
107405
107424
  const { envId, config: { functions } } = ctx;
107406
107425
  const name = params === null || params === void 0 ? void 0 : params[0];
107426
+ const functionService = yield (0, function_1.getFunctionService)(envId);
107407
107427
  let isBatchCreateTrigger = false;
107408
107428
  if (!name) {
107409
107429
  const { isBatch } = yield inquirer_1.default.prompt({
@@ -107418,7 +107438,7 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
107418
107438
  }
107419
107439
  }
107420
107440
  if (isBatchCreateTrigger) {
107421
- return (0, function_1.batchCreateTriggers)({
107441
+ return functionService.batchCreateTriggers({
107422
107442
  envId,
107423
107443
  functions
107424
107444
  });
@@ -107431,11 +107451,7 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
107431
107451
  if (!triggers || !triggers.length) {
107432
107452
  throw new error_1.CloudBaseError('触发器配置不能为空');
107433
107453
  }
107434
- yield (0, function_1.createFunctionTriggers)({
107435
- envId,
107436
- functionName: name,
107437
- triggers
107438
- });
107454
+ yield functionService.createFunctionTriggers(name, triggers);
107439
107455
  (0, logger_1.successLog)(`[${name}] 创建云函数触发器成功!`);
107440
107456
  });
107441
107457
  }
@@ -134606,6 +134622,7 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
134606
134622
  const { envId, config: { functions } } = ctx;
134607
134623
  const name = params === null || params === void 0 ? void 0 : params[0];
134608
134624
  const triggerName = params === null || params === void 0 ? void 0 : params[1];
134625
+ const functionService = yield (0, function_1.getFunctionService)(envId);
134609
134626
  let isBatchDeleteTriggers;
134610
134627
  let isBatchDeleteFunctionTriggers = false;
134611
134628
  if (!name) {
@@ -134629,7 +134646,7 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
134629
134646
  }
134630
134647
  }
134631
134648
  if (isBatchDeleteTriggers) {
134632
- return (0, function_1.batchDeleteTriggers)({
134649
+ return functionService.batchDeleteTriggers({
134633
134650
  envId,
134634
134651
  functions
134635
134652
  });
@@ -134648,7 +134665,7 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
134648
134665
  }
134649
134666
  if (isBatchDeleteFunctionTriggers) {
134650
134667
  const func = functions.find((item) => item.name === name);
134651
- return (0, function_1.batchDeleteTriggers)({
134668
+ return functionService.batchDeleteTriggers({
134652
134669
  envId,
134653
134670
  functions: [func]
134654
134671
  });
@@ -134656,11 +134673,7 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
134656
134673
  if (!triggerName) {
134657
134674
  throw new error_1.CloudBaseError('触发器名称不能为空');
134658
134675
  }
134659
- yield (0, function_1.deleteFunctionTrigger)({
134660
- envId,
134661
- functionName: name,
134662
- triggerName
134663
- });
134676
+ yield functionService.deleteFunctionTrigger(name, triggerName);
134664
134677
  });
134665
134678
  }
134666
134679
  };
@@ -175263,13 +175276,14 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
175263
175276
  execute(envId, options) {
175264
175277
  return __awaiter(this, void 0, void 0, function* () {
175265
175278
  const { dest } = options;
175279
+ const functionService = yield (0, function_1.getFunctionService)(envId);
175266
175280
  const loading = (0, utils_1.loadingFactory)();
175267
175281
  loading.start('数据加载中...');
175268
- const layers = yield (0, function_1.listLayers)({
175282
+ const listLayersRes = yield functionService.listLayers({
175269
175283
  offset: 0,
175270
175284
  limit: 200,
175271
- searchSrc: `TCB_${envId}`
175272
175285
  });
175286
+ const layers = listLayersRes.Layers || [];
175273
175287
  loading.stop();
175274
175288
  if (!layers.length) {
175275
175289
  throw new error_1.CloudBaseError('当前环境没有可用的文件层,请先创建文件层!');
@@ -175280,10 +175294,11 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
175280
175294
  message: '选择文件层名称',
175281
175295
  choices: layers.map((item) => item.LayerName)
175282
175296
  });
175283
- let versions = yield (0, function_1.listLayerVersions)({
175297
+ let listLayerVersionsRes = yield functionService.listLayerVersions({
175284
175298
  name: layer
175285
175299
  });
175286
- versions = versions.map((item) => String(item.LayerVersion));
175300
+ const layerVersions = listLayerVersionsRes.LayerVersions || [];
175301
+ const versions = layerVersions.map((item) => String(item.LayerVersion));
175287
175302
  const { version } = yield (0, enquirer_1.prompt)({
175288
175303
  type: 'select',
175289
175304
  name: 'version',
@@ -175294,9 +175309,12 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
175294
175309
  if (!dest) {
175295
175310
  destPath = path_1.default.resolve(process.cwd(), 'layers');
175296
175311
  }
175312
+ else {
175313
+ destPath = path_1.default.resolve(dest);
175314
+ }
175297
175315
  loading.start('文件下载中...');
175298
175316
  yield fs_extra_1.default.ensureDir(destPath);
175299
- yield (0, function_1.downloadLayer)({
175317
+ yield functionService.downloadLayer({
175300
175318
  destPath,
175301
175319
  version: Number(version),
175302
175320
  name: layer
@@ -217365,7 +217383,7 @@ let SortFileLayer = class SortFileLayer extends common_1.Command {
217365
217383
  });
217366
217384
  sortLayers = sortLayers.map((item) => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
217367
217385
  loading.start('文件层排序中...');
217368
- yield (0, function_1.sortLayer)({
217386
+ yield functionService.updateFunctionLayer({
217369
217387
  envId,
217370
217388
  functionName: fnName,
217371
217389
  layers: sortLayers
@@ -229527,20 +229545,20 @@ let CreateFileLayer = class CreateFileLayer extends common_1.Command {
229527
229545
  const alias = params === null || params === void 0 ? void 0 : params[0];
229528
229546
  const { file } = options;
229529
229547
  const layerName = `${alias}_${envId}`;
229530
- const layers = yield (0, function_1.listLayers)({
229548
+ const listLayerRes = yield functionsService.listLayers({
229531
229549
  offset: 0,
229532
229550
  limit: 200
229533
229551
  });
229552
+ const layers = listLayerRes.Layers || [];
229534
229553
  if (layers.find(({ LayerName }) => LayerName === layerName)) {
229535
229554
  throw new toolbox_1.CloudBaseError(`层名称 ${layerName} 已被您的当前环境或其他环境占用,请换用别的名称`);
229536
229555
  }
229537
229556
  const filePath = path_1.default.resolve(file);
229538
- const runtimes = ['Nodejs12.16', 'Nodejs8.9', 'Php7', 'Java8'];
229557
+ const runtimes = ['Nodejs14.18', 'Nodejs12.16', 'Nodejs8.9', 'Php7', 'Java8'];
229539
229558
  const loading = (0, utils_1.loadingFactory)();
229540
229559
  loading.start('文件层创建中...');
229541
- yield (0, function_1.createLayer)({
229542
- envId,
229543
- layerName,
229560
+ yield functionsService.createLayer({
229561
+ name: layerName,
229544
229562
  runtimes,
229545
229563
  contentPath: filePath
229546
229564
  });
@@ -309000,6 +309018,248 @@ module.exports = {
309000
309018
  })));
309001
309019
 
309002
309020
 
309021
+ /***/ }),
309022
+
309023
+ /***/ 54698:
309024
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
309025
+
309026
+ "use strict";
309027
+
309028
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
309029
+ if (k2 === undefined) k2 = k;
309030
+ var desc = Object.getOwnPropertyDescriptor(m, k);
309031
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
309032
+ desc = { enumerable: true, get: function() { return m[k]; } };
309033
+ }
309034
+ Object.defineProperty(o, k2, desc);
309035
+ }) : (function(o, m, k, k2) {
309036
+ if (k2 === undefined) k2 = k;
309037
+ o[k2] = m[k];
309038
+ }));
309039
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
309040
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
309041
+ }) : function(o, v) {
309042
+ o["default"] = v;
309043
+ });
309044
+ var __importStar = (this && this.__importStar) || function (mod) {
309045
+ if (mod && mod.__esModule) return mod;
309046
+ var result = {};
309047
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
309048
+ __setModuleDefault(result, mod);
309049
+ return result;
309050
+ };
309051
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
309052
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
309053
+ return new (P || (P = Promise))(function (resolve, reject) {
309054
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
309055
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
309056
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
309057
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
309058
+ });
309059
+ };
309060
+ var __importDefault = (this && this.__importDefault) || function (mod) {
309061
+ return (mod && mod.__esModule) ? mod : { "default": mod };
309062
+ };
309063
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
309064
+ exports.MCPConfigModifier = void 0;
309065
+ const fs_extra_1 = __importDefault(__webpack_require__(21605));
309066
+ const path_1 = __importDefault(__webpack_require__(16928));
309067
+ const IDE_FILE_MAPPINGS = {
309068
+ cursor: [
309069
+ { path: '.cursor/rules/cloudbase-rules.mdc' },
309070
+ { path: '.cursor/mcp.json', isMcpConfig: true }
309071
+ ],
309072
+ windsurf: [{ path: '.windsurf/rules/cloudbase-rules.md' }],
309073
+ codebuddy: [{ path: '.rules/cloudbase-rules.md' }],
309074
+ 'claude-code': [{ path: 'CLAUDE.md' }, { path: '.mcp.json', isMcpConfig: true }],
309075
+ cline: [{ path: '.clinerules/cloudbase-rules.mdc' }],
309076
+ 'gemini-cli': [
309077
+ { path: '.gemini/GEMINI.md' },
309078
+ { path: '.gemini/settings.json', isMcpConfig: true }
309079
+ ],
309080
+ opencode: [{ path: '.opencode.json', isMcpConfig: true }],
309081
+ 'qwen-code': [{ path: '.qwen/QWEN.md' }, { path: '.qwen/settings.json', isMcpConfig: true }],
309082
+ 'baidu-comate': [
309083
+ { path: '.comate/rules/cloudbase-rules.mdr' },
309084
+ { path: '.comate/rules/cloudbaase-rules.mdr' },
309085
+ { path: '.comate/mcp.json', isMcpConfig: true }
309086
+ ],
309087
+ 'openai-codex-cli': [{ path: '.codex/config.toml', isMcpConfig: true }, { path: 'AGENTS.md' }],
309088
+ 'augment-code': [{ path: '.augment-guidelines' }],
309089
+ 'github-copilot': [{ path: '.github/copilot-instructions.md' }],
309090
+ roocode: [
309091
+ { path: '.roo/rules/cloudbaase-rules.md' },
309092
+ { path: '.roo/mcp.json', isMcpConfig: true }
309093
+ ],
309094
+ 'tongyi-lingma': [{ path: '.lingma/rules/cloudbaase-rules.md' }],
309095
+ trae: [{ path: '.trae/rules/cloudbase-rules.md' }],
309096
+ vscode: [{ path: '.vscode/mcp.json', isMcpConfig: true }, { path: '.vscode/settings.json' }],
309097
+ aider: [{ path: 'mcp.json', isMcpConfig: true }]
309098
+ };
309099
+ function inferConfigFormat(filePath) {
309100
+ return filePath.toLowerCase().endsWith('.toml') ? 'toml' : 'json';
309101
+ }
309102
+ class MCPConfigModifier {
309103
+ modifyMCPConfigs(extractDir, log) {
309104
+ return __awaiter(this, void 0, void 0, function* () {
309105
+ try {
309106
+ log.info('🔧 正在修改 MCP 配置文件...');
309107
+ for (const [ide, files] of Object.entries(IDE_FILE_MAPPINGS)) {
309108
+ for (const descriptor of files) {
309109
+ if (!descriptor.isMcpConfig)
309110
+ continue;
309111
+ const filePath = path_1.default.join(extractDir, descriptor.path);
309112
+ log.debug(`检查文件: ${filePath}`);
309113
+ if (yield fs_extra_1.default.pathExists(filePath)) {
309114
+ log.debug(`找到 MCP 配置文件: ${filePath}`);
309115
+ const format = inferConfigFormat(descriptor.path);
309116
+ if (format === 'json') {
309117
+ yield this.modifyMCPJsonFile(filePath, log);
309118
+ }
309119
+ else if (format === 'toml') {
309120
+ yield this.modifyMCPTomlFile(filePath, log);
309121
+ }
309122
+ }
309123
+ else {
309124
+ log.debug(`文件不存在: ${filePath}`);
309125
+ }
309126
+ }
309127
+ }
309128
+ log.info('✅ MCP 配置文件修改完成');
309129
+ }
309130
+ catch (error) {
309131
+ log.warn(`⚠️ MCP 配置文件修改失败: ${error.message}`);
309132
+ }
309133
+ });
309134
+ }
309135
+ modifyMCPJsonFile(filePath, log) {
309136
+ return __awaiter(this, void 0, void 0, function* () {
309137
+ try {
309138
+ const content = yield fs_extra_1.default.readFile(filePath, 'utf-8');
309139
+ const config = JSON.parse(content);
309140
+ log.debug(`读取配置文件 ${filePath}: ${JSON.stringify(config)}`);
309141
+ let modified = false;
309142
+ const modifyCommands = (obj) => {
309143
+ if (typeof obj !== 'object' || obj === null) {
309144
+ return obj;
309145
+ }
309146
+ if (Array.isArray(obj)) {
309147
+ return obj.map((item) => modifyCommands(item));
309148
+ }
309149
+ const result = Object.assign({}, obj);
309150
+ if (result.command === 'npx' && Array.isArray(result.args)) {
309151
+ const argsStr = result.args.join(' ');
309152
+ log.debug(`检查命令: command=${result.command}, args=${JSON.stringify(result.args)}`);
309153
+ if (argsStr.includes('npm-global-exec@latest') &&
309154
+ argsStr.includes('@cloudbase/cloudbase-mcp@latest')) {
309155
+ log.debug(`匹配到需要修改的命令: ${argsStr}`);
309156
+ result.command = 'cloudbase-mcp';
309157
+ result.args = [];
309158
+ result.env = {
309159
+ INTEGRATION_IDE: process.env.INTEGRATION_IDE || 'CloudBaseCLI'
309160
+ };
309161
+ modified = true;
309162
+ log.debug(`修改配置文件 ${filePath}: npx -> cloudbase-mcp`);
309163
+ }
309164
+ else {
309165
+ log.debug(`命令不匹配修改条件: ${argsStr}`);
309166
+ }
309167
+ }
309168
+ for (const [key, value] of Object.entries(result)) {
309169
+ result[key] = modifyCommands(value);
309170
+ }
309171
+ return result;
309172
+ };
309173
+ const modifiedConfig = modifyCommands(config);
309174
+ if (modified) {
309175
+ yield fs_extra_1.default.writeJson(filePath, modifiedConfig, { spaces: 2 });
309176
+ log.debug(`✅ 已修改 ${filePath}`);
309177
+ }
309178
+ else {
309179
+ log.debug(`⚠️ 配置文件 ${filePath} 未发生修改`);
309180
+ }
309181
+ }
309182
+ catch (error) {
309183
+ log.warn(`⚠️ 修改配置文件 ${filePath} 失败: ${error.message}`);
309184
+ }
309185
+ });
309186
+ }
309187
+ modifyMCPTomlFile(filePath, log) {
309188
+ return __awaiter(this, void 0, void 0, function* () {
309189
+ try {
309190
+ const content = yield fs_extra_1.default.readFile(filePath, 'utf-8');
309191
+ const toml = yield Promise.resolve().then(() => __importStar(__webpack_require__(1293)));
309192
+ const config = toml.parse(content);
309193
+ let modified = false;
309194
+ const modifyCommands = (obj) => {
309195
+ if (typeof obj !== 'object' || obj === null) {
309196
+ return obj;
309197
+ }
309198
+ if (Array.isArray(obj)) {
309199
+ return obj.map((item) => modifyCommands(item));
309200
+ }
309201
+ const result = Object.assign({}, obj);
309202
+ if (result.command === 'npx' && Array.isArray(result.args)) {
309203
+ const argsStr = result.args.join(' ');
309204
+ if (argsStr.includes('@cloudbase/cloudbase-mcp@latest')) {
309205
+ result.command = 'cloudbase-mcp';
309206
+ result.args = [];
309207
+ result.env = {
309208
+ INTEGRATION_IDE: process.env.INTEGRATION_IDE || 'CloudBaseCLI'
309209
+ };
309210
+ modified = true;
309211
+ log.debug(`修改配置文件 ${filePath}: npx -> cloudbase-mcp`);
309212
+ }
309213
+ }
309214
+ for (const [key, value] of Object.entries(result)) {
309215
+ result[key] = modifyCommands(value);
309216
+ }
309217
+ return result;
309218
+ };
309219
+ const modifiedConfig = modifyCommands(config);
309220
+ if (modified) {
309221
+ const tomlString = this.objectToToml(modifiedConfig);
309222
+ yield fs_extra_1.default.writeFile(filePath, tomlString, 'utf-8');
309223
+ log.debug(`✅ 已修改 ${filePath}`);
309224
+ }
309225
+ }
309226
+ catch (error) {
309227
+ log.warn(`⚠️ 修改配置文件 ${filePath} 失败: ${error.message}`);
309228
+ }
309229
+ });
309230
+ }
309231
+ objectToToml(obj, prefix = '') {
309232
+ const lines = [];
309233
+ for (const [key, value] of Object.entries(obj)) {
309234
+ const fullKey = prefix ? `${prefix}.${key}` : key;
309235
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
309236
+ lines.push(`[${fullKey}]`);
309237
+ lines.push(this.objectToToml(value, fullKey));
309238
+ }
309239
+ else if (Array.isArray(value)) {
309240
+ const arrayStr = value
309241
+ .map((item) => {
309242
+ if (typeof item === 'string') {
309243
+ return `"${item}"`;
309244
+ }
309245
+ return item;
309246
+ })
309247
+ .join(', ');
309248
+ lines.push(`${key} = [${arrayStr}]`);
309249
+ }
309250
+ else if (typeof value === 'string') {
309251
+ lines.push(`${key} = "${value}"`);
309252
+ }
309253
+ else {
309254
+ lines.push(`${key} = ${value}`);
309255
+ }
309256
+ }
309257
+ return lines.join('\n');
309258
+ }
309259
+ }
309260
+ exports.MCPConfigModifier = MCPConfigModifier;
309261
+
309262
+
309003
309263
  /***/ }),
309004
309264
 
309005
309265
  /***/ 54723:
@@ -385031,7 +385291,6 @@ const path_1 = __importDefault(__webpack_require__(16928));
385031
385291
  const unzipper_1 = __importDefault(__webpack_require__(50283));
385032
385292
  const constant_1 = __webpack_require__(40762);
385033
385293
  const http_request_1 = __webpack_require__(72088);
385034
- const log_symbols_1 = __importDefault(__webpack_require__(68329));
385035
385294
  __exportStar(__webpack_require__(23506), exports);
385036
385295
  __exportStar(__webpack_require__(81670), exports);
385037
385296
  __exportStar(__webpack_require__(12430), exports);
@@ -385304,7 +385563,7 @@ const getCompleteTimeRange = (timeRange) => {
385304
385563
  exports.getCompleteTimeRange = getCompleteTimeRange;
385305
385564
  function successLog(msg) {
385306
385565
  // 空格,兼容中文字符编码长度问题
385307
- console.log(`${log_symbols_1.default.success} ${msg}`);
385566
+ console.log(`${msg}`);
385308
385567
  }
385309
385568
 
385310
385569
 
@@ -467866,7 +468125,7 @@ exports.CURSOR = {
467866
468125
  })
467867
468126
  };
467868
468127
  exports.CODEBUDDY = {
467869
- name: 'Codebuddy Code CLI',
468128
+ name: 'CodeBuddy Code',
467870
468129
  value: 'codebuddy',
467871
468130
  configSchema: v3_1.default.discriminatedUnion('type', [
467872
468131
  v3_1.default.object({
@@ -467882,7 +468141,7 @@ exports.NONE = {
467882
468141
  name: '暂不配置',
467883
468142
  value: 'none'
467884
468143
  };
467885
- exports.AGENTS = [exports.CLAUDE, exports.QWEN, exports.CODEX, exports.AIDER, exports.CURSOR, exports.CODEBUDDY, exports.NONE];
468144
+ exports.AGENTS = [exports.CLAUDE, exports.CODEBUDDY, exports.QWEN, exports.CODEX, exports.AIDER, exports.CURSOR, exports.NONE];
467886
468145
  exports.CLOUDBASE_PROVIDERS = [
467887
468146
  {
467888
468147
  name: 'Kimi',
@@ -467896,6 +468155,12 @@ exports.CLOUDBASE_PROVIDERS = [
467896
468155
  models: ['deepseek-v3'],
467897
468156
  transformer: 'deepseek'
467898
468157
  },
468158
+ {
468159
+ name: 'LongCat',
468160
+ value: 'longcat',
468161
+ models: ['LongCat-Flash-Chat'],
468162
+ transformer: undefined
468163
+ },
467899
468164
  ];
467900
468165
  function getDefaultConfig(agent) {
467901
468166
  const agentConfig = exports.AGENTS.find((a) => a.value === agent);
@@ -467921,7 +468186,8 @@ function getAgentConfigValidator(agent) {
467921
468186
  exports.getAgentConfigValidator = getAgentConfigValidator;
467922
468187
  exports.BASE_URL_MODEL_MAPPING = {
467923
468188
  'https://api.moonshot.cn/v1': 'kimi-k2-0711-preview',
467924
- 'https://open.bigmodel.cn/api/paas/v4': 'glm-4.5'
468189
+ 'https://open.bigmodel.cn/api/paas/v4': 'glm-4.5',
468190
+ 'https://api.longcat.chat/openai': 'LongCat-Flash-Chat'
467925
468191
  };
467926
468192
  function getDefaultModelByBaseUrl(baseUrl) {
467927
468193
  return exports.BASE_URL_MODEL_MAPPING[baseUrl] || 'gpt-4';
@@ -469697,6 +469963,7 @@ const fs_extra_1 = __importDefault(__webpack_require__(21605));
469697
469963
  const path_1 = __importDefault(__webpack_require__(16928));
469698
469964
  const simple_git_1 = __webpack_require__(94662);
469699
469965
  const error_1 = __webpack_require__(66759);
469966
+ const mcp_config_modifier_1 = __webpack_require__(54698);
469700
469967
  const BUILTIN_TEMPLATES = {
469701
469968
  miniprogram: {
469702
469969
  url: 'https://static.cloudbase.net/cloudbase-examples/miniprogram-cloudbase-miniprogram-template.zip',
@@ -469722,6 +469989,7 @@ const BUILTIN_TEMPLATES = {
469722
469989
  class TemplateManager {
469723
469990
  constructor() {
469724
469991
  this.git = (0, simple_git_1.simpleGit)();
469992
+ this.mcpConfigModifier = new mcp_config_modifier_1.MCPConfigModifier();
469725
469993
  }
469726
469994
  pullTemplate(source, options = {}, log) {
469727
469995
  return __awaiter(this, void 0, void 0, function* () {
@@ -469755,7 +470023,8 @@ class TemplateManager {
469755
470023
  if (!source || typeof source !== 'string') {
469756
470024
  return false;
469757
470025
  }
469758
- return source.startsWith('http') || source.startsWith('git@') || source.includes('github.com') || source.includes('gitee.com');
470026
+ return source.startsWith('http') || source.startsWith('git@') ||
470027
+ source.includes('github.com') || source.includes('gitee.com') || source.includes('cnb.cool');
469759
470028
  }
469760
470029
  parseGitUrl(url) {
469761
470030
  const githubMatch = url.match(/https?:\/\/github\.com\/([^\/]+)\/([^\/]+)(?:\/tree\/([^\/]+)\/(.+))?/);
@@ -469778,10 +470047,23 @@ class TemplateManager {
469778
470047
  subpath: giteeMatch[4]
469779
470048
  };
469780
470049
  }
470050
+ const cnbMatch = url.match(/https?:\/\/cnb\.cool\/(.+?)(?:\/tree\/([^\/]+)\/(.+))?$/);
470051
+ if (cnbMatch) {
470052
+ const pathParts = cnbMatch[1].split('/').filter(p => p.length > 0);
470053
+ if (pathParts.length >= 2) {
470054
+ return {
470055
+ platform: 'cnb',
470056
+ owner: pathParts[0],
470057
+ repo: pathParts.slice(1).join('/'),
470058
+ branch: cnbMatch[2] || 'main',
470059
+ subpath: cnbMatch[3]
470060
+ };
470061
+ }
470062
+ }
469781
470063
  const sshMatch = url.match(/git@([^:]+):([^\/]+)\/([^\/]+)\.git/);
469782
470064
  if (sshMatch) {
469783
470065
  return {
469784
- platform: sshMatch[1] === 'github.com' ? 'github' : 'gitee',
470066
+ platform: sshMatch[1] === 'github.com' ? 'github' : (sshMatch[1] === 'cnb.cool' ? 'cnb' : 'gitee'),
469785
470067
  owner: sshMatch[2],
469786
470068
  repo: sshMatch[3],
469787
470069
  branch: 'main'
@@ -469796,6 +470078,9 @@ class TemplateManager {
469796
470078
  else if (gitInfo.platform === 'gitee') {
469797
470079
  return `https://gitee.com/${gitInfo.owner}/${gitInfo.repo}.git`;
469798
470080
  }
470081
+ else if (gitInfo.platform === 'cnb') {
470082
+ return `https://cnb.cool/${gitInfo.owner}/${gitInfo.repo}.git`;
470083
+ }
469799
470084
  throw new error_1.CloudBaseError(`不支持的 Git 平台: ${gitInfo.platform}`);
469800
470085
  }
469801
470086
  cloneWithSubpath(gitUrl, tempDir, gitInfo, log) {
@@ -469885,6 +470170,14 @@ class TemplateManager {
469885
470170
  yield this.copyFilesSkipExisting(tempDir, targetPath, log);
469886
470171
  }
469887
470172
  log.info(`✅ 模板复制完成`);
470173
+ try {
470174
+ log.debug('🔧 开始调用 MCP 配置修改器...');
470175
+ yield this.mcpConfigModifier.modifyMCPConfigs(targetPath, log);
470176
+ log.debug('✅ MCP 配置修改器调用完成');
470177
+ }
470178
+ catch (error) {
470179
+ log.warn(`⚠️ MCP 配置修改失败: ${error.message}`);
470180
+ }
469888
470181
  }
469889
470182
  catch (error) {
469890
470183
  throw new error_1.CloudBaseError(`复制模板失败: ${error.message}`, { original: error });
@@ -504786,9 +505079,9 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
504786
505079
  return __awaiter(this, void 0, void 0, function* () {
504787
505080
  const { codeSecret } = options;
504788
505081
  const fnName = params === null || params === void 0 ? void 0 : params[0];
505082
+ const functionService = yield (0, function_1.getFunctionService)(envId);
504789
505083
  const loading = (0, utils_1.loadingFactory)();
504790
505084
  loading.start('数据加载中...');
504791
- const functionService = yield (0, function_1.getFunctionService)(envId);
504792
505085
  const envFunctions = yield functionService.listAllFunctions({
504793
505086
  envId
504794
505087
  });
@@ -504796,33 +505089,34 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
504796
505089
  if (!exist) {
504797
505090
  throw new error_1.CloudBaseError(`当前环境不存在此函数 [${fnName}]`);
504798
505091
  }
504799
- let layers = yield (0, function_1.listLayers)({
505092
+ const listLayersRes = yield functionService.listLayers({
504800
505093
  offset: 0,
504801
505094
  limit: 200,
504802
- searchSrc: `TCB_${envId}`
504803
505095
  });
505096
+ const layers = listLayersRes.Layers || [];
504804
505097
  loading.stop();
504805
- layers = layers.map((item) => ({
505098
+ const newLayers = layers.map((item) => ({
504806
505099
  name: `[${LayerStatusMap[item.Status] || '异常'}] ${item.LayerName}`,
504807
505100
  value: item.LayerName
504808
505101
  }));
504809
- if (!layers.length) {
505102
+ if (!newLayers.length) {
504810
505103
  throw new error_1.CloudBaseError('没有可用的文件层,请先创建文件层!');
504811
505104
  }
504812
505105
  const { layer } = yield (0, enquirer_1.prompt)({
504813
505106
  type: 'select',
504814
505107
  name: 'layer',
504815
505108
  message: '选择文件层名称',
504816
- choices: layers,
505109
+ choices: newLayers,
504817
505110
  result(choices) {
504818
505111
  const keys = Object.values(this.map(choices));
504819
505112
  return keys[0];
504820
505113
  }
504821
505114
  });
504822
- let versions = yield (0, function_1.listLayerVersions)({
505115
+ let listLayerVersionsRes = yield functionService.listLayerVersions({
504823
505116
  name: layer
504824
505117
  });
504825
- versions = versions.map((item) => String(item.LayerVersion));
505118
+ let layerVersions = listLayerVersionsRes.LayerVersions || [];
505119
+ const versions = layerVersions.map((item) => String(item.LayerVersion));
504826
505120
  if (!versions.length) {
504827
505121
  throw new error_1.CloudBaseError('没有可用的文件层版本,请先创建文件层版本!');
504828
505122
  }
@@ -504833,7 +505127,7 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
504833
505127
  choices: versions
504834
505128
  });
504835
505129
  loading.start('文件层绑定中...');
504836
- yield (0, function_1.attachLayer)({
505130
+ yield functionService.attachLayer({
504837
505131
  envId,
504838
505132
  functionName: fnName,
504839
505133
  layerName: layer,
@@ -504897,7 +505191,7 @@ let UnAttachFileLayer = class UnAttachFileLayer extends common_1.Command {
504897
505191
  }
504898
505192
  });
504899
505193
  loading.start('文件层解绑中...');
504900
- yield (0, function_1.unAttachLayer)({
505194
+ yield functionService.unAttachLayer({
504901
505195
  envId,
504902
505196
  functionName: fnName,
504903
505197
  layerName: layer.LayerName,
@@ -575152,26 +575446,21 @@ let ListFileLayer = class ListFileLayer extends common_1.Command {
575152
575446
  const functionService = yield (0, function_1.getFunctionService)(envId);
575153
575447
  if (layer && typeof layer === 'string') {
575154
575448
  const layerName = `${layer}_${envId}`;
575155
- data = yield (0, function_1.listLayerVersions)({
575449
+ const listLayerVersionsRes = yield functionService.listLayerVersions({
575156
575450
  name: layerName
575157
575451
  });
575452
+ data = listLayerVersionsRes.LayerVersions || [];
575158
575453
  }
575159
575454
  else if (name && typeof name === 'string') {
575160
575455
  const res = yield functionService.getFunctionDetail(name, codeSecret);
575161
575456
  data = (res === null || res === void 0 ? void 0 : res.Layers) || [];
575162
575457
  }
575163
- else if (envId) {
575164
- data = yield (0, function_1.listLayers)({
575165
- offset: 0,
575166
- limit: 200,
575167
- searchSrc: `TCB_${envId}`
575168
- });
575169
- }
575170
575458
  else {
575171
- data = yield (0, function_1.listLayers)({
575459
+ const listLayersRes = yield functionService.listLayers({
575172
575460
  offset: 0,
575173
575461
  limit: 200
575174
575462
  });
575463
+ data = listLayersRes.Layers || [];
575175
575464
  }
575176
575465
  loading.stop();
575177
575466
  const head = ['优先级', '名称', '状态', '版本', '证书', '支持运行时', '创建时间'];
@@ -611803,20 +612092,26 @@ exports.TOOLKIT_CONFIGS = {
611803
612092
  rules: 'CLAUDE.md'
611804
612093
  },
611805
612094
  [const_1.CODEBUDDY.value]: {
611806
- config: '.env.local'
612095
+ config: '.env.local',
612096
+ mcp: '.mcp.json',
612097
+ rules: 'CODEBUDDY.md'
611807
612098
  },
611808
612099
  [const_1.QWEN.value]: {
611809
612100
  config: '.env.local',
612101
+ mcp: '.qwen/settings.json',
611810
612102
  rules: '.qwen/QWEN.md'
611811
612103
  },
611812
612104
  [const_1.CODEX.value]: {
611813
- config: '.env.local'
612105
+ config: '.env.local',
612106
+ mcp: '.codex/config.toml',
612107
+ rules: 'AGENTS.md'
611814
612108
  },
611815
612109
  [const_1.AIDER.value]: {
611816
- config: '.env.local'
612110
+ config: '.env.local',
611817
612111
  },
611818
612112
  [const_1.CURSOR.value]: {
611819
- config: '.cursor/mcp.json'
612113
+ config: '.cursor/mcp.json',
612114
+ rules: '.cursor/rules/cloudbase-rules.mdc'
611820
612115
  },
611821
612116
  };
611822
612117
  function createConfigParser() {
@@ -613693,6 +613988,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
613693
613988
  exports.FunctionService = void 0;
613694
613989
  const fs_1 = __importDefault(__webpack_require__(79896));
613695
613990
  const path_1 = __importDefault(__webpack_require__(16928));
613991
+ const lodash_1 = __importDefault(__webpack_require__(24924));
613696
613992
  const packer_1 = __webpack_require__(5147);
613697
613993
  const error_1 = __webpack_require__(40430);
613698
613994
  const utils_1 = __webpack_require__(62358);
@@ -614414,12 +614710,34 @@ class FunctionService {
614414
614710
  TriggerDesc: item.config
614415
614711
  };
614416
614712
  });
614417
- return this.scfService.request('BatchCreateTrigger', {
614418
- FunctionName: name,
614419
- Namespace: namespace,
614420
- Triggers: JSON.stringify(parsedTriggers),
614421
- Count: parsedTriggers.length
614422
- });
614713
+ try {
614714
+ return await this.scfService.request('BatchCreateTrigger', {
614715
+ FunctionName: name,
614716
+ Namespace: namespace,
614717
+ Triggers: JSON.stringify(parsedTriggers),
614718
+ Count: parsedTriggers.length
614719
+ });
614720
+ }
614721
+ catch (e) {
614722
+ throw new error_1.CloudBaseError(`[${name}] 创建触发器失败:${e.message}`, {
614723
+ action: e.action,
614724
+ code: e.code
614725
+ });
614726
+ }
614727
+ }
614728
+ // 批量部署函数触发器
614729
+ async batchCreateTriggers(options) {
614730
+ const { functions, envId } = options;
614731
+ const promises = functions.map(func => (async () => {
614732
+ try {
614733
+ await this.createFunctionTriggers(func.name, func.triggers);
614734
+ (0, utils_1.successLog)(`[${func.name}] 创建云函数触发器成功!`);
614735
+ }
614736
+ catch (e) {
614737
+ throw new error_1.CloudBaseError(e.message);
614738
+ }
614739
+ })());
614740
+ await Promise.all(promises);
614423
614741
  }
614424
614742
  /**
614425
614743
  * 删除云函数触发器
@@ -614429,12 +614747,32 @@ class FunctionService {
614429
614747
  */
614430
614748
  async deleteFunctionTrigger(name, triggerName) {
614431
614749
  const { namespace } = this.getFunctionConfig();
614432
- return this.scfService.request('DeleteTrigger', {
614433
- FunctionName: name,
614434
- Namespace: namespace,
614435
- TriggerName: triggerName,
614436
- Type: 'timer'
614437
- });
614750
+ try {
614751
+ await this.scfService.request('DeleteTrigger', {
614752
+ FunctionName: name,
614753
+ Namespace: namespace,
614754
+ TriggerName: triggerName,
614755
+ Type: 'timer'
614756
+ });
614757
+ (0, utils_1.successLog)(`[${name}] 删除云函数触发器 ${triggerName} 成功!`);
614758
+ }
614759
+ catch (e) {
614760
+ throw new error_1.CloudBaseError(`[${name}] 删除触发器失败:${e.message}`);
614761
+ }
614762
+ }
614763
+ async batchDeleteTriggers(options) {
614764
+ const { functions, envId } = options;
614765
+ const promises = functions.map(func => (async () => {
614766
+ try {
614767
+ func.triggers.forEach(async (trigger) => {
614768
+ await this.deleteFunctionTrigger(func.name, trigger.name);
614769
+ });
614770
+ }
614771
+ catch (e) {
614772
+ throw new error_1.CloudBaseError(e.message);
614773
+ }
614774
+ })());
614775
+ await Promise.all(promises);
614438
614776
  }
614439
614777
  /**
614440
614778
  * 下载云函数代码
@@ -614478,6 +614816,68 @@ class FunctionService {
614478
614816
  throw new error_1.CloudBaseError(`[${functionName}] 获取函数代码下载链接失败:\n${e.message}`);
614479
614817
  }
614480
614818
  }
614819
+ // 函数绑定文件层
614820
+ async attachLayer(options) {
614821
+ const { envId, functionName, layerName, layerVersion, codeSecret } = options;
614822
+ let { Layers = [] } = await this.getFunctionDetail(functionName, codeSecret);
614823
+ Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
614824
+ // 新加的文件层添加到最后
614825
+ Layers.push({
614826
+ LayerName: layerName,
614827
+ LayerVersion: layerVersion
614828
+ });
614829
+ const res = await this.scfService.request('UpdateFunctionConfiguration', {
614830
+ Layers,
614831
+ Namespace: envId,
614832
+ FunctionName: functionName
614833
+ });
614834
+ return res;
614835
+ }
614836
+ // 函数解绑文件层
614837
+ async unAttachLayer(options) {
614838
+ const { envId, functionName, layerName, layerVersion, codeSecret } = options;
614839
+ let { Layers } = await this.getFunctionDetail(functionName, codeSecret);
614840
+ Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
614841
+ const index = Layers.findIndex(item => item.LayerName === layerName && item.LayerVersion === layerVersion);
614842
+ if (index === -1) {
614843
+ throw new error_1.CloudBaseError('层不存在');
614844
+ }
614845
+ // 删除指定的层
614846
+ Layers.splice(index, 1);
614847
+ const apiParams = {
614848
+ Namespace: envId,
614849
+ FunctionName: functionName,
614850
+ Layers: Layers.length > 0 ? Layers : [{
614851
+ LayerName: '',
614852
+ LayerVersion: 0
614853
+ }]
614854
+ };
614855
+ return this.scfService.request('UpdateFunctionConfiguration', apiParams);
614856
+ }
614857
+ // 更新云函数层
614858
+ async updateFunctionLayer(options) {
614859
+ const { envId, functionName, layers } = options;
614860
+ return this.scfService.request('UpdateFunctionConfiguration', {
614861
+ Layers: layers,
614862
+ Namespace: envId,
614863
+ FunctionName: functionName
614864
+ });
614865
+ }
614866
+ // 下载文件层 ZIP 文件
614867
+ async downloadLayer(options) {
614868
+ const { name, version, destPath } = options;
614869
+ const res = await this.scfService.request('GetLayerVersion', {
614870
+ LayerName: name,
614871
+ LayerVersion: version
614872
+ });
614873
+ const url = res === null || res === void 0 ? void 0 : res.Location;
614874
+ const zipPath = path_1.default.join(destPath, `${name}-${version}.zip`);
614875
+ if ((0, utils_1.checkFullAccess)(zipPath)) {
614876
+ throw new error_1.CloudBaseError(`文件已存在:${zipPath}`);
614877
+ }
614878
+ // 下载文件
614879
+ return (0, utils_1.downloadAndExtractRemoteZip)(url, destPath);
614880
+ }
614481
614881
  // 创建文件层版本
614482
614882
  async createLayer(options) {
614483
614883
  const { env } = this.getFunctionConfig();
@@ -614550,7 +614950,7 @@ class FunctionService {
614550
614950
  Limit: limit,
614551
614951
  Offset: offset,
614552
614952
  SearchKey: searchKey,
614553
- SearchSrc: `TCB_${env}`
614953
+ // SearchSrc: `TCB_${env}`
614554
614954
  };
614555
614955
  if (runtime) {
614556
614956
  param.CompatibleRuntime = runtime;
@@ -614927,6 +615327,18 @@ __decorate([
614927
615327
  __decorate([
614928
615328
  (0, utils_1.preLazy)()
614929
615329
  ], FunctionService.prototype, "getFunctionDownloadUrl", null);
615330
+ __decorate([
615331
+ (0, utils_1.preLazy)()
615332
+ ], FunctionService.prototype, "attachLayer", null);
615333
+ __decorate([
615334
+ (0, utils_1.preLazy)()
615335
+ ], FunctionService.prototype, "unAttachLayer", null);
615336
+ __decorate([
615337
+ (0, utils_1.preLazy)()
615338
+ ], FunctionService.prototype, "updateFunctionLayer", null);
615339
+ __decorate([
615340
+ (0, utils_1.preLazy)()
615341
+ ], FunctionService.prototype, "downloadLayer", null);
614930
615342
  __decorate([
614931
615343
  (0, utils_1.preLazy)()
614932
615344
  ], FunctionService.prototype, "createLayer", null);