@cloudbase/cloudbase-mcp 2.33.0 → 2.33.2

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/index.cjs CHANGED
@@ -2680,7 +2680,7 @@ function getHeaders(options) {
2680
2680
 
2681
2681
  /***/ },
2682
2682
 
2683
- /***/ 38680
2683
+ /***/ 58405
2684
2684
  (__unused_webpack_module, exports, __webpack_require__) {
2685
2685
 
2686
2686
  "use strict";
@@ -2693,7 +2693,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
2693
2693
  };
2694
2694
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2695
2695
  exports.AccessService = void 0;
2696
- const utils_1 = __webpack_require__(24263);
2696
+ const utils_1 = __webpack_require__(88208);
2697
2697
  /**
2698
2698
  * HTTP Service(CloudBaseGW)访问服务。
2699
2699
  * 注意:HTTP Service 模块自 v5.0.0 起已废弃,建议迁移到 EnvService 的域名与路由能力
@@ -2834,7 +2834,7 @@ __decorate([
2834
2834
 
2835
2835
  /***/ },
2836
2836
 
2837
- /***/ 33215
2837
+ /***/ 94540
2838
2838
  (__unused_webpack_module, exports, __webpack_require__) {
2839
2839
 
2840
2840
  "use strict";
@@ -2850,9 +2850,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
2850
2850
  };
2851
2851
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2852
2852
  exports.AgentService = void 0;
2853
- const cloudrun_1 = __webpack_require__(8044);
2854
- const type_1 = __webpack_require__(18490);
2855
- const utils_1 = __webpack_require__(24263);
2853
+ const cloudrun_1 = __webpack_require__(17569);
2854
+ const type_1 = __webpack_require__(94917);
2855
+ const utils_1 = __webpack_require__(88208);
2856
2856
  const path_1 = __importDefault(__webpack_require__(33873));
2857
2857
  /**
2858
2858
  * Agent 管理类
@@ -3499,7 +3499,7 @@ __decorate([
3499
3499
 
3500
3500
  /***/ },
3501
3501
 
3502
- /***/ 9537
3502
+ /***/ 1058
3503
3503
  (__unused_webpack_module, exports, __webpack_require__) {
3504
3504
 
3505
3505
  "use strict";
@@ -3512,7 +3512,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
3512
3512
  };
3513
3513
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3514
3514
  exports.AiModelService = void 0;
3515
- const utils_1 = __webpack_require__(24263);
3515
+ const utils_1 = __webpack_require__(88208);
3516
3516
  class AiModelService {
3517
3517
  constructor(environment) {
3518
3518
  this.environment = environment;
@@ -3608,14 +3608,14 @@ __decorate([
3608
3608
 
3609
3609
  /***/ },
3610
3610
 
3611
- /***/ 54913
3611
+ /***/ 44210
3612
3612
  (__unused_webpack_module, exports, __webpack_require__) {
3613
3613
 
3614
3614
  "use strict";
3615
3615
 
3616
3616
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3617
3617
  exports.BillingService = void 0;
3618
- const utils_1 = __webpack_require__(24263);
3618
+ const utils_1 = __webpack_require__(88208);
3619
3619
  class BillingService {
3620
3620
  constructor(context) {
3621
3621
  this.billService = new utils_1.CloudService(context, BillingService.billServiceVersion.service, BillingService.billServiceVersion.version);
@@ -3658,7 +3658,7 @@ BillingService.billServiceVersion = {
3658
3658
 
3659
3659
  /***/ },
3660
3660
 
3661
- /***/ 97538
3661
+ /***/ 42403
3662
3662
  (__unused_webpack_module, exports, __webpack_require__) {
3663
3663
 
3664
3664
  "use strict";
@@ -3691,10 +3691,10 @@ exports.CloudAppService = void 0;
3691
3691
  const fs_1 = __importDefault(__webpack_require__(29021));
3692
3692
  const os_1 = __importDefault(__webpack_require__(21820));
3693
3693
  const path_1 = __importDefault(__webpack_require__(33873));
3694
- const error_1 = __webpack_require__(18143);
3695
- const utils_1 = __webpack_require__(24263);
3696
- const http_request_1 = __webpack_require__(7355);
3697
- __exportStar(__webpack_require__(47167), exports);
3694
+ const error_1 = __webpack_require__(54884);
3695
+ const utils_1 = __webpack_require__(88208);
3696
+ const http_request_1 = __webpack_require__(2922);
3697
+ __exportStar(__webpack_require__(15746), exports);
3698
3698
  /**
3699
3699
  * CloudApp 统一部署服务
3700
3700
  * 提供 Web 应用的创建、查询、删除、版本管理等功能
@@ -3927,7 +3927,7 @@ __decorate([
3927
3927
 
3928
3928
  /***/ },
3929
3929
 
3930
- /***/ 47167
3930
+ /***/ 15746
3931
3931
  (__unused_webpack_module, exports) {
3932
3932
 
3933
3933
  "use strict";
@@ -3945,7 +3945,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
3945
3945
 
3946
3946
  /***/ },
3947
3947
 
3948
- /***/ 27851
3948
+ /***/ 56242
3949
3949
  (__unused_webpack_module, exports, __webpack_require__) {
3950
3950
 
3951
3951
  "use strict";
@@ -3958,7 +3958,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
3958
3958
  };
3959
3959
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3960
3960
  exports.CloudBaseRunService = void 0;
3961
- const utils_1 = __webpack_require__(24263);
3961
+ const utils_1 = __webpack_require__(88208);
3962
3962
  class CloudBaseRunService {
3963
3963
  constructor(environment) {
3964
3964
  this.environment = environment;
@@ -3989,7 +3989,7 @@ __decorate([
3989
3989
 
3990
3990
  /***/ },
3991
3991
 
3992
- /***/ 8044
3992
+ /***/ 17569
3993
3993
  (__unused_webpack_module, exports, __webpack_require__) {
3994
3994
 
3995
3995
  "use strict";
@@ -4010,8 +4010,8 @@ exports.parseObjectToDiffConfigItem = parseObjectToDiffConfigItem;
4010
4010
  const archiver_1 = __importDefault(__webpack_require__(7716));
4011
4011
  const fs_extra_1 = __webpack_require__(22732);
4012
4012
  const path_1 = __importDefault(__webpack_require__(33873));
4013
- const utils_1 = __webpack_require__(24263);
4014
- const type_1 = __webpack_require__(18490);
4013
+ const utils_1 = __webpack_require__(88208);
4014
+ const type_1 = __webpack_require__(94917);
4015
4015
  /**
4016
4016
  * 云托管服务管理类
4017
4017
  * 提供云托管服务的初始化、下载、列表查询和删除等功能
@@ -4693,7 +4693,7 @@ function parseObjectToDiffConfigItem(data) {
4693
4693
 
4694
4694
  /***/ },
4695
4695
 
4696
- /***/ 18490
4696
+ /***/ 94917
4697
4697
  (__unused_webpack_module, exports) {
4698
4698
 
4699
4699
  "use strict";
@@ -4726,15 +4726,15 @@ var ReleaseTypeEnum;
4726
4726
 
4727
4727
  /***/ },
4728
4728
 
4729
- /***/ 10443
4729
+ /***/ 73906
4730
4730
  (__unused_webpack_module, exports, __webpack_require__) {
4731
4731
 
4732
4732
  "use strict";
4733
4733
 
4734
4734
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4735
4735
  exports.CommonService = void 0;
4736
- const utils_1 = __webpack_require__(24263);
4737
- const error_1 = __webpack_require__(18143);
4736
+ const utils_1 = __webpack_require__(88208);
4737
+ const error_1 = __webpack_require__(54884);
4738
4738
  /**
4739
4739
  * 公共的云api调用方法 透传用户参数 无业务逻辑处理
4740
4740
  * @export
@@ -4773,7 +4773,7 @@ exports.CommonService = CommonService;
4773
4773
 
4774
4774
  /***/ },
4775
4775
 
4776
- /***/ 3017
4776
+ /***/ 41976
4777
4777
  (__unused_webpack_module, exports) {
4778
4778
 
4779
4779
  "use strict";
@@ -4855,14 +4855,14 @@ exports.SCF_TEMP_COS = {
4855
4855
 
4856
4856
  /***/ },
4857
4857
 
4858
- /***/ 91522
4858
+ /***/ 81073
4859
4859
  (__unused_webpack_module, exports, __webpack_require__) {
4860
4860
 
4861
4861
  "use strict";
4862
4862
 
4863
4863
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4864
4864
  exports.CloudBaseContext = void 0;
4865
- const constant_1 = __webpack_require__(3017);
4865
+ const constant_1 = __webpack_require__(41976);
4866
4866
  class CloudBaseContext {
4867
4867
  constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined, internalEndpointRegion = undefined, requestFn = undefined }) {
4868
4868
  this.secretId = secretId;
@@ -4887,7 +4887,7 @@ exports.CloudBaseContext = CloudBaseContext;
4887
4887
 
4888
4888
  /***/ },
4889
4889
 
4890
- /***/ 71863
4890
+ /***/ 44206
4891
4891
  (__unused_webpack_module, exports, __webpack_require__) {
4892
4892
 
4893
4893
  "use strict";
@@ -4904,8 +4904,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4904
4904
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4905
4905
  exports.DatabaseService = void 0;
4906
4906
  const path_1 = __importDefault(__webpack_require__(33873));
4907
- const error_1 = __webpack_require__(18143);
4908
- const utils_1 = __webpack_require__(24263);
4907
+ const error_1 = __webpack_require__(54884);
4908
+ const utils_1 = __webpack_require__(88208);
4909
4909
  function preLazy() {
4910
4910
  return function (target, propertyKey, descriptor) {
4911
4911
  let oldFunc = descriptor.value;
@@ -5466,7 +5466,7 @@ __decorate([
5466
5466
 
5467
5467
  /***/ },
5468
5468
 
5469
- /***/ 5636
5469
+ /***/ 9979
5470
5470
  (__unused_webpack_module, exports, __webpack_require__) {
5471
5471
 
5472
5472
  "use strict";
@@ -5478,7 +5478,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
5478
5478
  exports.DatabaseDeployer = void 0;
5479
5479
  const fs_1 = __importDefault(__webpack_require__(29021));
5480
5480
  const path_1 = __importDefault(__webpack_require__(33873));
5481
- const error_1 = __webpack_require__(18143);
5481
+ const error_1 = __webpack_require__(54884);
5482
5482
  /** migration 文件名正则:14位数字 + 下划线 + 小写字母下划线名称 + .sql */
5483
5483
  const MIGRATION_FILE_PATTERN = /^(\d{14})_([a-z_]+)\.sql$/;
5484
5484
  /** 轮询间隔(毫秒) */
@@ -5712,7 +5712,7 @@ exports.DatabaseDeployer = DatabaseDeployer;
5712
5712
 
5713
5713
  /***/ },
5714
5714
 
5715
- /***/ 83962
5715
+ /***/ 28385
5716
5716
  (__unused_webpack_module, exports, __webpack_require__) {
5717
5717
 
5718
5718
  "use strict";
@@ -5723,14 +5723,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5723
5723
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5724
5724
  exports.DeployOrchestrator = void 0;
5725
5725
  const path_1 = __importDefault(__webpack_require__(33873));
5726
- const error_1 = __webpack_require__(18143);
5727
- const DatabaseDeployer_1 = __webpack_require__(5636);
5728
- const FunctionDeployer_1 = __webpack_require__(21773);
5729
- const StaticDeployer_1 = __webpack_require__(1227);
5730
- const GatewayDeployer_1 = __webpack_require__(83463);
5731
- const StateStore_1 = __webpack_require__(13483);
5732
- const framework_1 = __webpack_require__(20789);
5733
- const parallel_1 = __webpack_require__(31504);
5726
+ const error_1 = __webpack_require__(54884);
5727
+ const DatabaseDeployer_1 = __webpack_require__(9979);
5728
+ const FunctionDeployer_1 = __webpack_require__(93210);
5729
+ const StaticDeployer_1 = __webpack_require__(19672);
5730
+ const GatewayDeployer_1 = __webpack_require__(6378);
5731
+ const config_guard_1 = __webpack_require__(74931);
5732
+ const parallel_1 = __webpack_require__(86693);
5734
5733
  /** 部署顺序(按依赖:database 最先,函数依赖新 Schema;gateway 最后,依赖函数/hosting) */
5735
5734
  const DEPLOY_ORDER = ['database', 'functions', 'app', 'hosting', 'gateway'];
5736
5735
  /**
@@ -5750,7 +5749,8 @@ class DeployOrchestrator {
5750
5749
  * 计算部署计划(dry-run 输出)
5751
5750
  */
5752
5751
  async deployPlan(options) {
5753
- return this.buildPlan(options.config, options);
5752
+ const config = this.normalizeFunctionConfigs(options.config, options.envId, options.cwd);
5753
+ return this.buildPlan(config, options);
5754
5754
  }
5755
5755
  /**
5756
5756
  * 执行部署
@@ -5763,7 +5763,8 @@ class DeployOrchestrator {
5763
5763
  */
5764
5764
  async deploy(options) {
5765
5765
  var _a, _b, _c, _d, _e, _f, _g, _h;
5766
- const { config, envId, dryRun, cwd = process.cwd(), log, concurrency = 5, continueOnError = false } = options;
5766
+ const { config: inputConfig, envId, dryRun, cwd = process.cwd(), log, concurrency = 5, continueOnError = false } = options;
5767
+ const config = this.normalizeFunctionConfigs(inputConfig, envId, cwd);
5767
5768
  // 1. 轻量 inline 守卫(validateProject 未接入时的兜底)
5768
5769
  this.guardConfig(config);
5769
5770
  const plan = await this.buildPlan(config, options);
@@ -5777,132 +5778,157 @@ class DeployOrchestrator {
5777
5778
  // gateway 段强制串行:executeStep 的 gateway 分支部署 config.gateway.routes 全部路由
5778
5779
  // (逐路由 plan item 仅用于展示 diff),并发执行会对同一批路由发起重复全量部署(竞态 create/modify 路由、bindCustomDomain)
5779
5780
  const globalLimit = Math.max(1, Math.min(Number(concurrency) || 1, 20));
5780
- try {
5781
- for (const segment of segments) {
5782
- // 段内并行度:gateway 段固定 1(全量部署语义);其余段用全局 concurrency
5783
- const limit = ((_b = segment[0]) === null || _b === void 0 ? void 0 : _b.type) === 'gateway' ? 1 : globalLimit;
5784
- // 段内预判定(顺序执行,保留交互/冲突中断语义)
5785
- const toExecute = [];
5786
- let segmentFailed = false;
5787
- let segmentDbFailed = false;
5788
- for (const item of segment) {
5789
- // skip:产物/配置未变更,静默跳过(不执行、不询问)
5790
- if (item.status === 'skip') {
5791
- (_c = log === null || log === void 0 ? void 0 : log.info) === null || _c === void 0 ? void 0 : _c.call(log, `[${item.type}] ${item.name}: ${item.action}`);
5792
- results.push({ type: item.type, name: item.name, ok: true, reason: 'skip' });
5793
- continue;
5794
- }
5795
- (_d = log === null || log === void 0 ? void 0 : log.info) === null || _d === void 0 ? void 0 : _d.call(log, `[${item.type}] ${item.name}: ${item.action}`);
5796
- // conflict:数据库迁移冲突 → 中断整个部署(后续资源可能依赖新 Schema)
5797
- if (item.status === 'conflict') {
5798
- const message = '检测到冲突,已中断部署';
5799
- (_e = log === null || log === void 0 ? void 0 : log.error) === null || _e === void 0 ? void 0 : _e.call(log, `[${item.type}] ${item.name} ${message}`);
5800
- results.push({ type: item.type, name: item.name, ok: false, error: message });
5801
- if (item.type === 'database') {
5802
- return { plan, results };
5803
- }
5804
- segmentFailed = true;
5805
- continue;
5806
- }
5807
- // 覆盖确认:仅函数已存在(update)时触发,对齐 tcb fn deploy 的 FunctionConflictChecker 语义
5808
- // yes=true 直接放行;注入 confirmUpdate 按回调决定;两者都无 → 保守跳过(no-confirm)
5809
- if (item.type === 'functions' && item.status === 'update') {
5810
- let confirmed = false;
5811
- if (options.yes) {
5812
- confirmed = true;
5813
- }
5814
- else if (options.confirmUpdate) {
5815
- confirmed = await options.confirmUpdate(item);
5816
- }
5817
- if (!confirmed) {
5818
- const reason = options.confirmUpdate
5819
- ? 'skipped-by-user'
5820
- : 'no-confirm';
5821
- (_f = log === null || log === void 0 ? void 0 : log.warn) === null || _f === void 0 ? void 0 : _f.call(log, `[${item.type}] ${item.name} 跳过覆盖更新(${reason})`);
5822
- results.push({ type: item.type, name: item.name, ok: false, reason });
5823
- continue;
5824
- }
5825
- }
5826
- toExecute.push(item);
5781
+ for (const segment of segments) {
5782
+ // 段内并行度:gateway 段固定 1(全量部署语义);其余段用全局 concurrency
5783
+ const limit = ((_b = segment[0]) === null || _b === void 0 ? void 0 : _b.type) === 'gateway' ? 1 : globalLimit;
5784
+ // 段内预判定(顺序执行,保留交互/冲突中断语义)
5785
+ const toExecute = [];
5786
+ let segmentFailed = false;
5787
+ let segmentDbFailed = false;
5788
+ for (const item of segment) {
5789
+ // skip:产物/配置未变更,静默跳过(不执行、不询问)
5790
+ if (item.status === 'skip') {
5791
+ (_c = log === null || log === void 0 ? void 0 : log.info) === null || _c === void 0 ? void 0 : _c.call(log, `[${item.type}] ${item.name}: ${item.action}`);
5792
+ results.push({ type: item.type, name: item.name, ok: true, reason: 'skip' });
5793
+ continue;
5827
5794
  }
5828
- if (toExecute.length === 0) {
5829
- // 段内无实际执行项:若本段已因 conflict 标记失败且 fail-fast,则中断
5830
- if (segmentFailed && !continueOnError) {
5795
+ (_d = log === null || log === void 0 ? void 0 : log.info) === null || _d === void 0 ? void 0 : _d.call(log, `[${item.type}] ${item.name}: ${item.action}`);
5796
+ // conflict:数据库迁移冲突 → 中断整个部署(后续资源可能依赖新 Schema)
5797
+ if (item.status === 'conflict') {
5798
+ const message = '检测到冲突,已中断部署';
5799
+ (_e = log === null || log === void 0 ? void 0 : log.error) === null || _e === void 0 ? void 0 : _e.call(log, `[${item.type}] ${item.name} ${message}`);
5800
+ results.push({ type: item.type, name: item.name, ok: false, error: message });
5801
+ if (item.type === 'database') {
5831
5802
  return { plan, results };
5832
5803
  }
5804
+ segmentFailed = true;
5833
5805
  continue;
5834
5806
  }
5835
- // 段内并行执行
5836
- const controller = new parallel_1.AsyncTaskParallelController(limit);
5837
- const tasks = toExecute.map((item) => async () => {
5838
- var _a, _b, _c, _d, _e;
5839
- try {
5840
- const stepResult = await this.executeStep({
5841
- item,
5842
- config,
5843
- envId,
5844
- cwd,
5845
- onProgress: options.onProgress
5846
- });
5847
- if (item.type === 'functions') {
5848
- results.push({
5849
- type: item.type,
5850
- name: item.name,
5851
- ok: true,
5852
- url: stepResult === null || stepResult === void 0 ? void 0 : stepResult.url,
5853
- detail: stepResult
5854
- });
5855
- }
5856
- else {
5857
- results.push({ type: item.type, name: item.name, ok: true, url: stepResult });
5858
- }
5859
- }
5860
- catch (e) {
5861
- const message = (e === null || e === void 0 ? void 0 : e.message) || String(e);
5862
- const requestId = (e === null || e === void 0 ? void 0 : e.requestId) ||
5863
- (e === null || e === void 0 ? void 0 : e.RequestId) ||
5864
- ((_a = e === null || e === void 0 ? void 0 : e.original) === null || _a === void 0 ? void 0 : _a.requestId) ||
5865
- ((_b = e === null || e === void 0 ? void 0 : e.original) === null || _b === void 0 ? void 0 : _b.RequestId) ||
5866
- ((_c = e === null || e === void 0 ? void 0 : e.response) === null || _c === void 0 ? void 0 : _c.requestId) ||
5867
- ((_d = e === null || e === void 0 ? void 0 : e.response) === null || _d === void 0 ? void 0 : _d.RequestId);
5868
- if (!(item.type === 'functions' && options.onProgress)) {
5869
- (_e = log === null || log === void 0 ? void 0 : log.error) === null || _e === void 0 ? void 0 : _e.call(log, `[${item.type}] ${item.name} 部署失败: ${message}`);
5870
- }
5871
- results.push(Object.assign(Object.assign(Object.assign({ type: item.type, name: item.name, ok: false, error: message }, ((e === null || e === void 0 ? void 0 : e.code) ? { errorCode: e.code } : {})), ((e === null || e === void 0 ? void 0 : e.failedStage) ? { failedStage: e.failedStage } : {})), (requestId ? { requestId } : {})));
5872
- segmentFailed = true;
5873
- if (item.type === 'database') {
5874
- segmentDbFailed = true;
5875
- }
5807
+ // 覆盖确认:仅函数已存在(update)时触发,对齐 tcb fn deploy 的 FunctionConflictChecker 语义
5808
+ // yes=true 直接放行;注入 confirmUpdate 按回调决定;两者都无 → 保守跳过(no-confirm)
5809
+ if (item.type === 'functions' && item.status === 'update') {
5810
+ let confirmed = false;
5811
+ if (options.yes) {
5812
+ confirmed = true;
5876
5813
  }
5877
- });
5878
- controller.loadTasks(tasks);
5879
- await controller.run();
5880
- // 段内失败中断决策
5881
- if (segmentFailed) {
5882
- if (segmentDbFailed) {
5883
- (_g = log === null || log === void 0 ? void 0 : log.error) === null || _g === void 0 ? void 0 : _g.call(log, '数据库迁移失败,中断部署');
5884
- return { plan, results };
5814
+ else if (options.confirmUpdate) {
5815
+ confirmed = await options.confirmUpdate(item);
5885
5816
  }
5886
- if (!continueOnError) {
5887
- return { plan, results };
5817
+ if (!confirmed) {
5818
+ const reason = options.confirmUpdate
5819
+ ? 'skipped-by-user'
5820
+ : 'no-confirm';
5821
+ (_f = log === null || log === void 0 ? void 0 : log.warn) === null || _f === void 0 ? void 0 : _f.call(log, `[${item.type}] ${item.name} 跳过覆盖更新(${reason})`);
5822
+ results.push({ type: item.type, name: item.name, ok: false, reason });
5823
+ continue;
5888
5824
  }
5889
5825
  }
5826
+ toExecute.push(item);
5890
5827
  }
5891
- }
5892
- finally {
5893
- // 无论部署全部成功还是 fail-fast 中断,都将已成功资源的状态快照落盘
5894
- // (失败资源保留旧快照,下次 diff 仍会检测到差异);快照写入失败不影响部署结果
5895
- if (!dryRun) {
5828
+ if (toExecute.length === 0) {
5829
+ // 段内无实际执行项:若本段已因 conflict 标记失败且 fail-fast,则中断
5830
+ if (segmentFailed && !continueOnError) {
5831
+ return { plan, results };
5832
+ }
5833
+ continue;
5834
+ }
5835
+ // 段内并行执行
5836
+ const controller = new parallel_1.AsyncTaskParallelController(limit);
5837
+ const tasks = toExecute.map((item) => async () => {
5838
+ var _a, _b, _c, _d, _e;
5896
5839
  try {
5897
- await this.persistState({ config, plan, results, cwd, envId: options.envId });
5840
+ const stepResult = await this.executeStep({
5841
+ item,
5842
+ config,
5843
+ envId,
5844
+ cwd,
5845
+ onProgress: options.onProgress
5846
+ });
5847
+ if (item.type === 'functions') {
5848
+ results.push({
5849
+ type: item.type,
5850
+ name: item.name,
5851
+ ok: true,
5852
+ url: stepResult === null || stepResult === void 0 ? void 0 : stepResult.url,
5853
+ detail: stepResult
5854
+ });
5855
+ }
5856
+ else {
5857
+ results.push({ type: item.type, name: item.name, ok: true, url: stepResult });
5858
+ }
5898
5859
  }
5899
5860
  catch (e) {
5900
- (_h = log === null || log === void 0 ? void 0 : log.warn) === null || _h === void 0 ? void 0 : _h.call(log, `状态快照写入失败:${(e === null || e === void 0 ? void 0 : e.message) || String(e)}`);
5861
+ const message = (e === null || e === void 0 ? void 0 : e.message) || String(e);
5862
+ const requestId = (e === null || e === void 0 ? void 0 : e.requestId) ||
5863
+ (e === null || e === void 0 ? void 0 : e.RequestId) ||
5864
+ ((_a = e === null || e === void 0 ? void 0 : e.original) === null || _a === void 0 ? void 0 : _a.requestId) ||
5865
+ ((_b = e === null || e === void 0 ? void 0 : e.original) === null || _b === void 0 ? void 0 : _b.RequestId) ||
5866
+ ((_c = e === null || e === void 0 ? void 0 : e.response) === null || _c === void 0 ? void 0 : _c.requestId) ||
5867
+ ((_d = e === null || e === void 0 ? void 0 : e.response) === null || _d === void 0 ? void 0 : _d.RequestId);
5868
+ if (!(item.type === 'functions' && options.onProgress)) {
5869
+ (_e = log === null || log === void 0 ? void 0 : log.error) === null || _e === void 0 ? void 0 : _e.call(log, `[${item.type}] ${item.name} 部署失败: ${message}`);
5870
+ }
5871
+ results.push(Object.assign(Object.assign(Object.assign({ type: item.type, name: item.name, ok: false, error: message }, ((e === null || e === void 0 ? void 0 : e.code) ? { errorCode: e.code } : {})), ((e === null || e === void 0 ? void 0 : e.failedStage) ? { failedStage: e.failedStage } : {})), (requestId ? { requestId } : {})));
5872
+ segmentFailed = true;
5873
+ if (item.type === 'database') {
5874
+ segmentDbFailed = true;
5875
+ }
5876
+ }
5877
+ });
5878
+ controller.loadTasks(tasks);
5879
+ await controller.run();
5880
+ // 段内失败中断决策
5881
+ if (segmentFailed) {
5882
+ if (segmentDbFailed) {
5883
+ (_g = log === null || log === void 0 ? void 0 : log.error) === null || _g === void 0 ? void 0 : _g.call(log, '数据库迁移失败,中断部署');
5884
+ return { plan, results };
5885
+ }
5886
+ if (!continueOnError) {
5887
+ (_h = log === null || log === void 0 ? void 0 : log.error) === null || _h === void 0 ? void 0 : _h.call(log, '存在资源部署失败,中断部署');
5888
+ return { plan, results };
5901
5889
  }
5902
5890
  }
5903
5891
  }
5904
5892
  return { plan, results };
5905
5893
  }
5894
+ /**
5895
+ * 归一化声明式函数配置:直接消费 cloudbaserc 的嵌套形状(imageConfig.build),
5896
+ * 不做字段平铺映射;非 HTTP 函数原样返回。
5897
+ */
5898
+ normalizeFunctionConfigs(config, envId, cwd = process.cwd()) {
5899
+ if (!Array.isArray(config === null || config === void 0 ? void 0 : config.functions)) {
5900
+ return config;
5901
+ }
5902
+ const functionRootPath = path_1.default.resolve(cwd, config.functionRoot || 'functions');
5903
+ return Object.assign(Object.assign({}, config), { functions: config.functions.map((func) => {
5904
+ var _a, _b;
5905
+ // 直接消费 cloudbaserc 的嵌套形状(imageConfig.build),不再做字段平铺映射。
5906
+ // 非镜像/构建策略由 prepareMinimalDeployConfig 内部识别并原样返回。
5907
+ if ((func === null || func === void 0 ? void 0 : func.type) !== 'HTTP') {
5908
+ return func;
5909
+ }
5910
+ const funcAny = func;
5911
+ const explicitCwd = (_b = (_a = funcAny.imageConfig) === null || _a === void 0 ? void 0 : _a.build) === null || _b === void 0 ? void 0 : _b.cwd;
5912
+ const dir = funcAny.dir;
5913
+ // 构建上下文根解析优先级:显式 build.cwd > dir > functionRoot/name。
5914
+ // 相对路径一律以部署传入的项目 cwd 为基准解析为绝对路径,避免 preflight
5915
+ // 与云端构建(builders/cloud.ts)以进程 CWD 兜底导致目录错位。
5916
+ const resolvedContextRoot = typeof explicitCwd === 'string' && explicitCwd.trim()
5917
+ ? path_1.default.resolve(cwd, explicitCwd)
5918
+ : typeof dir === 'string' && dir.trim()
5919
+ ? path_1.default.resolve(cwd, dir)
5920
+ : undefined;
5921
+ // 显式 build.cwd 归一为绝对路径写回,避免 applyMinimalDeployConfigDefaults
5922
+ // 因 build.cwd 已存在而保留原始相对值。
5923
+ const normalizedFunc = resolvedContextRoot && typeof explicitCwd === 'string' && explicitCwd.trim()
5924
+ ? Object.assign(Object.assign({}, funcAny), { imageConfig: Object.assign(Object.assign({}, funcAny.imageConfig), { build: Object.assign(Object.assign({}, funcAny.imageConfig.build), { cwd: resolvedContextRoot }) }) }) : func;
5925
+ return (0, config_guard_1.prepareMinimalDeployConfig)(normalizedFunc, {
5926
+ envId,
5927
+ functionPath: resolvedContextRoot,
5928
+ functionRootPath
5929
+ }).config;
5930
+ }) });
5931
+ }
5906
5932
  /**
5907
5933
  * 将扁平 plan 按「连续相同资源类型」切成有序 segments
5908
5934
  *
@@ -5930,91 +5956,19 @@ class DeployOrchestrator {
5930
5956
  }
5931
5957
  return segments;
5932
5958
  }
5933
- /**
5934
- * 部署成功后写回本地 state 快照
5935
- *
5936
- * - hosting:成功部署/未变更(skip)的项重算产物指纹;失败项保留旧快照
5937
- * - app:成功部署写 buildAppConfig 快照;skip 复用旧快照
5938
- * - gateway:保留旧快照(本轮不做路由级实时快照)
5939
- */
5940
- async persistState(options) {
5941
- var _a, _b, _c, _d, _e, _f;
5942
- const { config, plan, results, cwd, envId } = options;
5943
- const stateStore = new StateStore_1.StateStore({ cwd });
5944
- const prev = stateStore.read();
5945
- // hosting
5946
- const hostingEntries = [];
5947
- for (const h of config.hosting || []) {
5948
- const name = h.name || 'default';
5949
- const planItem = plan.find(p => p.type === 'hosting' && p.name === name);
5950
- const result = results.find(r => r.type === 'hosting' && r.name === name);
5951
- if (!result || !result.ok) {
5952
- // 未执行(fail-fast 中断,results 中无对应条目)或部署失败:
5953
- // 保留旧快照(下次 diff 仍会检测到差异)
5954
- const prevEntry = (_b = (_a = prev === null || prev === void 0 ? void 0 : prev.resources) === null || _a === void 0 ? void 0 : _a.hosting) === null || _b === void 0 ? void 0 : _b.find(s => s.name === name);
5955
- if (prevEntry) {
5956
- hostingEntries.push(prevEntry);
5957
- }
5958
- continue;
5959
- }
5960
- if ((planItem === null || planItem === void 0 ? void 0 : planItem.status) === 'skip') {
5961
- const prevEntry = (_d = (_c = prev === null || prev === void 0 ? void 0 : prev.resources) === null || _c === void 0 ? void 0 : _c.hosting) === null || _d === void 0 ? void 0 : _d.find(s => s.name === name);
5962
- if (prevEntry) {
5963
- hostingEntries.push(prevEntry);
5964
- continue;
5965
- }
5966
- }
5967
- // 成功部署:重算当前指纹(含 size,供下次 diff 做 size 预判)
5968
- // 注意:deployHosting 可能执行本地构建,产物已更新,必须独立重算而非复用 plan 指纹
5969
- const root = path_1.default.resolve(cwd, h.root || '.');
5970
- // outputDir 与 StaticDeployer.deployHosting 完全复用同一解析逻辑
5971
- const outputDir = (0, framework_1.resolveHostingOutputDir)(h, root);
5972
- try {
5973
- const files = await stateStore.computeHostingFingerprints(outputDir, h.ignore || []);
5974
- hostingEntries.push({ name, deployPath: h.deployPath, files });
5975
- }
5976
- catch (_g) {
5977
- // 目录缺失 / 文件数超限:不写入(下次 diff 走云端兜底或全量部署)
5978
- }
5979
- }
5980
- // app
5981
- let appEntry;
5982
- if (config.app) {
5983
- const appResult = results.find(r => r.type === 'app');
5984
- if (appResult === null || appResult === void 0 ? void 0 : appResult.ok) {
5985
- appEntry = stateStore.buildAppConfig(config.app);
5986
- }
5987
- else {
5988
- appEntry = (_e = prev === null || prev === void 0 ? void 0 : prev.resources) === null || _e === void 0 ? void 0 : _e.app;
5989
- }
5990
- }
5991
- const resources = {};
5992
- if (hostingEntries.length) {
5993
- resources.hosting = hostingEntries;
5994
- }
5995
- if (appEntry) {
5996
- resources.app = appEntry;
5997
- }
5998
- if ((_f = prev === null || prev === void 0 ? void 0 : prev.resources) === null || _f === void 0 ? void 0 : _f.gateway) {
5999
- resources.gateway = prev.resources.gateway;
6000
- }
6001
- if (Object.keys(resources).length) {
6002
- stateStore.write({ resources, envId });
6003
- }
6004
- }
6005
5959
  /**
6006
5960
  * 构建完整部署计划(按依赖顺序 + only/skip 过滤)
6007
5961
  *
6008
5962
  * 通过查询云端状态判定每个资源的动作:
6009
5963
  * - database:先按迁移文件做 preview,再聚合成单条资源级计划项(pending→create,存在 conflict→conflict,全部 applied→不出现在 plan)
6010
5964
  * - functions:ListFunctions 判断是否已存在 → create / update(不做本地 hash / 字段 diff)
6011
- * - app:describeAppInfo 判断是否已存在 → create / update;本地 state 配置一致 → skip
6012
- * - hosting:本地 state 指纹 diff → 一致 skip(不重新上传)/ 有差异 deploy(带文件级明细)
5965
+ * - app:describeAppInfo 判断是否已存在 → create / update
5966
+ * - hosting:直传覆盖(无存在性概念)
6013
5967
  * - gateway:planRoutes 对比云端路由 → create / update / skip(含变更字段明细)
6014
5968
  * 云端查询失败时降级为保守判定(全 create),不影响 dry-run 展示。
6015
5969
  */
6016
5970
  async buildPlan(config, options) {
6017
- const { only, skip, refresh } = options;
5971
+ const { only, skip } = options;
6018
5972
  const cwd = options.cwd || process.cwd();
6019
5973
  const envId = options.envId;
6020
5974
  const plan = [];
@@ -6025,14 +5979,7 @@ class DeployOrchestrator {
6025
5979
  return false;
6026
5980
  return true;
6027
5981
  };
6028
- // 本地 state 快照(diff 基准):--refresh 时忽略本地 skip 判定
6029
- const stateStore = new StateStore_1.StateStore({ cwd });
6030
- const rawState = refresh ? null : stateStore.read();
6031
- // 跨环境保护:快照记录的 envId 与目标环境不一致(或旧格式快照无 envId)时,
6032
- // 快照是其他环境部署后的指纹,不可作为 skip 依据 → 视为无快照,强制走全量部署,
6033
- // 避免切换环境后误判「产物未变更」导致新环境 COS 404
6034
- const state = rawState && rawState.envId === envId ? rawState : null;
6035
- const planCtx = { config, envId, stateStore, state, refresh, cwd };
5982
+ const planCtx = { config, envId, cwd };
6036
5983
  for (const type of DEPLOY_ORDER) {
6037
5984
  if (!isEnabled(type))
6038
5985
  continue;
@@ -6045,7 +5992,7 @@ class DeployOrchestrator {
6045
5992
  * 按资源类型构建计划(拆分自 buildPlan,控制圈复杂度)
6046
5993
  */
6047
5994
  async buildPlanForType(type, ctx) {
6048
- const { config, envId, stateStore, state, refresh, cwd } = ctx;
5995
+ const { config, envId, cwd } = ctx;
6049
5996
  if (type === 'database') {
6050
5997
  return this.buildDatabasePlan(config, cwd, envId);
6051
5998
  }
@@ -6083,10 +6030,10 @@ class DeployOrchestrator {
6083
6030
  });
6084
6031
  }
6085
6032
  if (type === 'app') {
6086
- return this.buildAppPlan({ config, envId, stateStore, state, refresh });
6033
+ return this.buildAppPlan({ config, envId });
6087
6034
  }
6088
6035
  if (type === 'hosting') {
6089
- return this.buildHostingPlans(config, ctx);
6036
+ return this.buildHostingPlans(config);
6090
6037
  }
6091
6038
  return this.buildGatewayPlans(config, envId);
6092
6039
  }
@@ -6143,100 +6090,51 @@ class DeployOrchestrator {
6143
6090
  return [];
6144
6091
  }
6145
6092
  /**
6146
- * app 计划:本地 state 配置一致 → skip;否则按云端存在性 → create / update
6093
+ * app 计划:按云端存在性 → create / update
6147
6094
  */
6148
6095
  async buildAppPlan(options) {
6149
- var _a;
6150
- const { config, envId, stateStore, state, refresh } = options;
6096
+ const { config, envId } = options;
6151
6097
  if (!config.app)
6152
6098
  return [];
6153
6099
  const name = config.app.serviceName || 'app';
6154
- // 本地 state 配置一致 → skip(真增量,不重复构建版本)
6155
- const appEntry = stateStore.buildAppConfig(config.app);
6156
- const stateApp = (_a = state === null || state === void 0 ? void 0 : state.resources) === null || _a === void 0 ? void 0 : _a.app;
6157
- const appUnchanged = !refresh &&
6158
- stateApp !== undefined &&
6159
- appEntry !== undefined &&
6160
- this.deepEqual(stateApp, appEntry);
6161
- if (appUnchanged) {
6162
- return [
6163
- {
6164
- type: 'app',
6165
- name,
6166
- status: 'skip',
6167
- action: `云应用 ${name} 配置未变更,跳过`
6168
- }
6169
- ];
6170
- }
6171
6100
  const appExists = await this.appExists(name);
6172
- const changes = this.appConfigChanges(stateApp, appEntry);
6173
6101
  return [
6174
- Object.assign({ type: 'app', name, status: appExists ? 'update' : 'create', action: appExists
6102
+ {
6103
+ type: 'app',
6104
+ name,
6105
+ status: appExists ? 'update' : 'create',
6106
+ action: appExists
6175
6107
  ? `覆盖更新云应用 ${name}`
6176
- : `新建云应用 ${name}` }, (changes.length ? { changes } : {}))
6108
+ : `新建云应用 ${name}`
6109
+ }
6177
6110
  ];
6178
6111
  }
6179
6112
  /**
6180
- * hosting 计划:本地 state 指纹 diff → 一致 skip / 有差异 deploy(带文件级明细)
6113
+ * hosting 计划:每次直传覆盖(无本地指纹 skip)
6181
6114
  */
6182
- async buildHostingPlans(config, ctx) {
6183
- var _a, _b;
6184
- const { stateStore, state, refresh, cwd } = ctx;
6115
+ buildHostingPlans(config) {
6185
6116
  const plans = [];
6186
6117
  for (const h of config.hosting || []) {
6187
6118
  const name = h.name || 'default';
6188
- const root = path_1.default.resolve(cwd, h.root || '.');
6189
- const buildCommand = (0, framework_1.resolveBuildCommand)(h, root);
6190
- // outputDir 与 StaticDeployer.deployHosting 完全复用同一解析逻辑
6191
- const outputDir = (0, framework_1.resolveHostingOutputDir)(h, root);
6192
- const stateHosting = (_b = (_a = state === null || state === void 0 ? void 0 : state.resources) === null || _a === void 0 ? void 0 : _a.hosting) === null || _b === void 0 ? void 0 : _b.find(s => s.name === name);
6193
- // 懒加载 diff:size 预判 + 按需 hash(目录缺失 / 文件数超限 → 保守部署)
6194
- let fileDiff = null;
6195
- try {
6196
- fileDiff = await stateStore.diffHostingFiles(outputDir, stateHosting === null || stateHosting === void 0 ? void 0 : stateHosting.files, {
6197
- ignore: h.ignore || []
6198
- });
6199
- }
6200
- catch (_c) {
6201
- fileDiff = null;
6202
- }
6203
- const unchanged = !refresh && fileDiff !== null && fileDiff.unchanged;
6204
- if (unchanged) {
6205
- plans.push({
6206
- type: 'hosting',
6207
- name,
6208
- status: 'skip',
6209
- action: `静态托管 ${name} 产物未变更,跳过`
6210
- });
6211
- continue;
6212
- }
6213
6119
  const hasBuild = !!h.buildCommand ||
6214
6120
  (!!h.framework && h.framework !== 'static' && h.framework !== 'custom');
6215
6121
  const details = [
6216
6122
  { label: '框架', value: h.framework || 'static' },
6217
6123
  {
6218
6124
  label: '构建',
6219
- value: hasBuild
6220
- ? `本地构建(${buildCommand || 'npm run build'})→ 上传 ${outputDir}`
6221
- : '无构建,直接上传'
6125
+ value: hasBuild ? '本地构建后上传' : '无构建,直接上传'
6222
6126
  },
6223
6127
  { label: '部署路径', value: h.deployPath || '/' }
6224
6128
  ];
6225
- if (fileDiff === null || fileDiff === void 0 ? void 0 : fileDiff.overLimit) {
6226
- details.push({ label: '指纹', value: '文件数超上限,降级为全量部署' });
6227
- }
6228
- plans.push(Object.assign({ type: 'hosting', name, status: 'deploy', action: hasBuild
6129
+ plans.push({
6130
+ type: 'hosting',
6131
+ name,
6132
+ status: 'deploy',
6133
+ action: hasBuild
6229
6134
  ? `本地构建后直传静态托管 ${name}`
6230
- : `直传覆盖静态托管 ${name}`, details }, (fileDiff && !fileDiff.overLimit
6231
- ? {
6232
- fileDiff: {
6233
- added: fileDiff.added,
6234
- modified: fileDiff.modified,
6235
- deleted: fileDiff.deleted,
6236
- totalChanged: fileDiff.totalChanged
6237
- }
6238
- }
6239
- : {})));
6135
+ : `直传覆盖静态托管 ${name}`,
6136
+ details
6137
+ });
6240
6138
  }
6241
6139
  return plans;
6242
6140
  }
@@ -6346,26 +6244,6 @@ class DeployOrchestrator {
6346
6244
  }
6347
6245
  }
6348
6246
  }
6349
- /** 深比较(JSON 快照语义):仅用于 app 配置快照等简单对象 */
6350
- deepEqual(a, b) {
6351
- return JSON.stringify(a) === JSON.stringify(b);
6352
- }
6353
- /** app 配置差异明细(from → to) */
6354
- appConfigChanges(prev, curr) {
6355
- const changes = [];
6356
- const keys = new Set([
6357
- ...Object.keys(prev || {}),
6358
- ...Object.keys(curr || {})
6359
- ]);
6360
- for (const key of keys) {
6361
- const from = prev === null || prev === void 0 ? void 0 : prev[key];
6362
- const to = curr === null || curr === void 0 ? void 0 : curr[key];
6363
- if (from !== to) {
6364
- changes.push({ field: String(key), from, to });
6365
- }
6366
- }
6367
- return changes;
6368
- }
6369
6247
  /**
6370
6248
  * 轻量 inline 守卫:配置合法 + 目录存在(validateProject 接线点)
6371
6249
  */
@@ -6383,7 +6261,7 @@ exports.DeployOrchestrator = DeployOrchestrator;
6383
6261
 
6384
6262
  /***/ },
6385
6263
 
6386
- /***/ 21773
6264
+ /***/ 93210
6387
6265
  (__unused_webpack_module, exports, __webpack_require__) {
6388
6266
 
6389
6267
  "use strict";
@@ -6403,23 +6281,23 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
6403
6281
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6404
6282
  };
6405
6283
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6406
- exports.IMAGE_PULL_GRANT_URL = exports.REQUIRED_IMAGE_PULL_POLICY = exports.SCF_PULL_IMAGE_ROLE = exports.isCamPermissionError = exports.runImagePullAuthPreflight = exports.runImageRemotePreflight = exports.runLocalPreflight = exports.createCloudBuildService = exports.buildImageOnCloud = exports.toCloudFunction = exports.createImageArtifactFromConfig = exports.createCodeArtifact = exports.toCurrentState = exports.createDeployPlan = exports.parseImageReference = exports.normalizeGatewayPath = exports.normalizeDeployConfig = exports.isCustomImageRuntime = exports.checkDeployConfig = exports.assertDeployConfig = exports.FunctionDeployer = void 0;
6407
- const error_1 = __webpack_require__(18143);
6408
- const artifact_1 = __webpack_require__(78146);
6409
- const config_guard_1 = __webpack_require__(69238);
6410
- const cam_preflight_1 = __webpack_require__(11903);
6411
- const cloud_1 = __webpack_require__(36114);
6412
- const cloud_build_service_1 = __webpack_require__(52244);
6413
- const docker_preflight_1 = __webpack_require__(30710);
6414
- const GatewayDeployer_1 = __webpack_require__(83463);
6415
- const domain_1 = __webpack_require__(83597);
6416
- const image_preflight_1 = __webpack_require__(56749);
6417
- const local_builder_1 = __webpack_require__(49515);
6418
- const enterprise_tcr_1 = __webpack_require__(26719);
6419
- const personal_tcr_1 = __webpack_require__(5380);
6420
- const planner_1 = __webpack_require__(28750);
6421
- const preflight_1 = __webpack_require__(61081);
6422
- const types_1 = __webpack_require__(22724);
6284
+ exports.IMAGE_PULL_GRANT_URL = exports.REQUIRED_IMAGE_PULL_POLICY = exports.SCF_PULL_IMAGE_ROLE = exports.isCamPermissionError = exports.runImagePullAuthPreflight = exports.runImageRemotePreflight = exports.runLocalPreflight = exports.createCloudBuildService = exports.buildImageOnCloud = exports.toCloudFunction = exports.createImageArtifactFromConfig = exports.createCodeArtifact = exports.toCurrentState = exports.createDeployPlan = exports.parseImageReference = exports.normalizeGatewayPath = exports.normalizeDeployConfig = exports.isCustomImageRuntime = exports.prepareMinimalDeployConfig = exports.getMissingDeployInputs = exports.applyMinimalDeployConfigDefaults = exports.checkDeployConfig = exports.assertDeployConfig = exports.FunctionDeployer = void 0;
6285
+ const error_1 = __webpack_require__(54884);
6286
+ const artifact_1 = __webpack_require__(84187);
6287
+ const config_guard_1 = __webpack_require__(74931);
6288
+ const cam_preflight_1 = __webpack_require__(68388);
6289
+ const cloud_1 = __webpack_require__(4295);
6290
+ const cloud_build_service_1 = __webpack_require__(43587);
6291
+ const docker_preflight_1 = __webpack_require__(48947);
6292
+ const GatewayDeployer_1 = __webpack_require__(6378);
6293
+ const domain_1 = __webpack_require__(43294);
6294
+ const image_preflight_1 = __webpack_require__(67650);
6295
+ const local_builder_1 = __webpack_require__(52948);
6296
+ const enterprise_tcr_1 = __webpack_require__(84638);
6297
+ const personal_tcr_1 = __webpack_require__(28541);
6298
+ const planner_1 = __webpack_require__(72325);
6299
+ const preflight_1 = __webpack_require__(69230);
6300
+ const types_1 = __webpack_require__(79345);
6423
6301
  /** OPA 用户策略 key */
6424
6302
  const AUTHZ_USER_REGO_KEY = 'authz.user.rego';
6425
6303
  /**
@@ -6484,7 +6362,12 @@ class FunctionDeployer {
6484
6362
  return;
6485
6363
  }
6486
6364
  const rule = this.buildPublicAccessRego(functionName);
6487
- const mergedRego = currentRego.trim() ? `${currentRego.trim()}\n\n${rule}` : rule;
6365
+ // 云端 Rego 校验器要求首条有效语句(注释不计)必须是 package 声明。
6366
+ // currentRego 非空时已含 package authz.user,直接追加规则体即可;
6367
+ // 为空(新环境首次配置)时需补齐 package 声明,否则触发 2:1: package expected。
6368
+ const mergedRego = currentRego.trim()
6369
+ ? `${currentRego.trim()}\n\n${rule}`
6370
+ : `package authz.user\n\n${rule}`;
6488
6371
  await permissionService.modifyEnvAuthzConfig({
6489
6372
  key: AUTHZ_USER_REGO_KEY,
6490
6373
  value: mergedRego
@@ -6565,6 +6448,24 @@ class FunctionDeployer {
6565
6448
  checkConfig(config) {
6566
6449
  return (0, config_guard_1.checkDeployConfig)(config);
6567
6450
  }
6451
+ /**
6452
+ * 计算最小化部署配置的默认值,不执行网络或云端变更。
6453
+ */
6454
+ applyMinimalConfigDefaults(config, context = {}) {
6455
+ return (0, config_guard_1.applyMinimalDeployConfigDefaults)(config, context);
6456
+ }
6457
+ /**
6458
+ * 返回最小化配置仍缺失的字段,不执行网络或云端变更。
6459
+ */
6460
+ getMissingConfigInputs(config, context = {}) {
6461
+ return (0, config_guard_1.getMissingDeployInputs)(config, context);
6462
+ }
6463
+ /**
6464
+ * 应用安全默认值并返回缺失字段,供 CLI/MCP 逐步收集用户输入。
6465
+ */
6466
+ prepareMinimalConfig(config, context = {}) {
6467
+ return (0, config_guard_1.prepareMinimalDeployConfig)(config, context);
6468
+ }
6568
6469
  /**
6569
6470
  * 生成部署计划
6570
6471
  *
@@ -6591,13 +6492,14 @@ class FunctionDeployer {
6591
6492
  * @param options 部署选项,dryRun 时只生成计划不做任何变更
6592
6493
  */
6593
6494
  async deployFunction(config, options = {}) {
6495
+ const deployConfig = config;
6594
6496
  const startTime = Date.now();
6595
6497
  const ctx = { steps: [], options };
6596
6498
  const warnings = [];
6597
- const report = (0, config_guard_1.checkDeployConfig)(config);
6499
+ const report = (0, config_guard_1.checkDeployConfig)(deployConfig);
6598
6500
  this.appendWarnings(warnings, report);
6599
6501
  const normalized = await this.runStep(ctx, 'validate', async () => {
6600
- return (0, config_guard_1.assertDeployConfig)(config);
6502
+ return (0, config_guard_1.assertDeployConfig)(deployConfig);
6601
6503
  });
6602
6504
  const plan = await this.runStep(ctx, 'plan', async () => {
6603
6505
  const current = await this.getCurrentFunction(normalized.name, normalized.codeSecret);
@@ -6687,7 +6589,7 @@ class FunctionDeployer {
6687
6589
  * 将既有声明式调用补齐为完整部署配置
6688
6590
  */
6689
6591
  withLegacyDeployContext(func, functionRootPath, functionPath) {
6690
- var _a, _b;
6592
+ var _a, _b, _c, _d, _e;
6691
6593
  const config = Object.assign({}, func);
6692
6594
  const strategy = this.resolveStrategy(config);
6693
6595
  if (functionPath) {
@@ -6705,16 +6607,14 @@ class FunctionDeployer {
6705
6607
  (effectiveFunctionRootPath
6706
6608
  ? `${effectiveFunctionRootPath}/${config.name}`
6707
6609
  : undefined);
6708
- if (buildCwd || ((_a = config.build) === null || _a === void 0 ? void 0 : _a.cwd)) {
6709
- config.build = Object.assign(Object.assign({}, (config.build || {})), { cwd: ((_b = config.build) === null || _b === void 0 ? void 0 : _b.cwd) || buildCwd });
6610
+ const existingCwd = (_b = (_a = config.imageConfig) === null || _a === void 0 ? void 0 : _a.build) === null || _b === void 0 ? void 0 : _b.cwd;
6611
+ if (buildCwd || existingCwd) {
6612
+ config.imageConfig = Object.assign(Object.assign({}, (config.imageConfig || {})), { build: Object.assign(Object.assign({}, (((_c = config.imageConfig) === null || _c === void 0 ? void 0 : _c.build) || {})), { cwd: existingCwd || buildCwd }) });
6710
6613
  }
6711
6614
  }
6712
- // 兼容旧声明式 imageUri 字段,统一转换到运行时 imageConfig 契约
6713
- if (strategy === 'image' && config.imageUri && !config.imageConfig) {
6714
- config.imageType = config.imageType || 'personal';
6715
- config.imageConfig = {
6716
- imageUri: config.imageUri
6717
- };
6615
+ // 兼容旧声明式顶层 imageUri 字段,统一收敛到 imageConfig 契约
6616
+ if (strategy === 'image' && config.imageUri && !((_d = config.imageConfig) === null || _d === void 0 ? void 0 : _d.imageUri)) {
6617
+ config.imageConfig = Object.assign(Object.assign({ imageType: ((_e = config.imageConfig) === null || _e === void 0 ? void 0 : _e.imageType) || 'personal' }, (config.imageConfig || {})), { imageUri: config.imageUri });
6718
6618
  delete config.imageUri;
6719
6619
  }
6720
6620
  return config;
@@ -6837,9 +6737,10 @@ class FunctionDeployer {
6837
6737
  }
6838
6738
  }
6839
6739
  async prepareEnterpriseBuildConfig(ctx, config) {
6840
- const repository = config.build.repository || '';
6841
- const hasPreparedTarget = Boolean((config.registryId || config.build.registryId) && repository.split('/').length >= 3);
6842
- if (config.imageType !== 'enterprise' || hasPreparedTarget) {
6740
+ const build = config.imageConfig.build;
6741
+ const repository = build.repository || '';
6742
+ const hasPreparedTarget = Boolean((config.imageConfig.registryId || build.registryId) && repository.split('/').length >= 3);
6743
+ if (config.imageConfig.imageType !== 'enterprise' || hasPreparedTarget) {
6843
6744
  return { config };
6844
6745
  }
6845
6746
  const prepared = await this.runLabeledStep(ctx, {
@@ -6855,13 +6756,14 @@ class FunctionDeployer {
6855
6756
  }
6856
6757
  async preparePersonalBuildConfig(ctx, config) {
6857
6758
  var _a, _b, _c;
6858
- if (config.imageType !== 'personal') {
6759
+ if (config.imageConfig.imageType !== 'personal') {
6859
6760
  return config;
6860
6761
  }
6861
6762
  const envId = this.resolveEnvironmentId();
6862
- const configuredNamespace = (_a = config.build.namespace) === null || _a === void 0 ? void 0 : _a.trim();
6863
- const hasConfiguredRepository = Boolean((_b = config.build.repository) === null || _b === void 0 ? void 0 : _b.trim());
6864
- const configuredRepository = ((_c = config.build.repository) === null || _c === void 0 ? void 0 : _c.trim()) || config.name;
6763
+ const build = config.imageConfig.build;
6764
+ const configuredNamespace = (_a = build.namespace) === null || _a === void 0 ? void 0 : _a.trim();
6765
+ const hasConfiguredRepository = Boolean((_b = build.repository) === null || _b === void 0 ? void 0 : _b.trim());
6766
+ const configuredRepository = ((_c = build.repository) === null || _c === void 0 ? void 0 : _c.trim()) || config.name;
6865
6767
  const parsedRepository = (0, config_guard_1.parseImageReference)(configuredRepository);
6866
6768
  if (!parsedRepository || parsedRepository.tag || parsedRepository.digest) {
6867
6769
  throw new error_1.CloudBaseError('个人版 TCR repository 不合法。', {
@@ -6874,7 +6776,7 @@ class FunctionDeployer {
6874
6776
  const namespace = configuredNamespace || repositoryNamespace || envId;
6875
6777
  const hasConfiguredNamespace = Boolean(configuredNamespace || repositoryNamespace);
6876
6778
  const registry = parsedRepository.registry || personal_tcr_1.DEFAULT_PERSONAL_TCR_REGISTRY;
6877
- const credential = config.build.registryCredential;
6779
+ const credential = build.registryCredential;
6878
6780
  if (!(credential === null || credential === void 0 ? void 0 : credential.username) || !credential.password) {
6879
6781
  throw new error_1.CloudBaseError('个人版 TCR 构建缺少推送凭证。', {
6880
6782
  code: types_1.FUNCTION_DEPLOY_ERROR.CLOUD_REGISTRY_CREDENTIAL_MISSING
@@ -6891,7 +6793,7 @@ class FunctionDeployer {
6891
6793
  })
6892
6794
  });
6893
6795
  const targetRepository = `${registry}/${namespace}/${repository}`;
6894
- const preparedConfig = Object.assign(Object.assign({}, config), { build: Object.assign(Object.assign({}, config.build), { namespace, repository: targetRepository, registryCredential: credential }) });
6796
+ const preparedConfig = Object.assign(Object.assign({}, config), { imageConfig: Object.assign(Object.assign({}, config.imageConfig), { build: Object.assign(Object.assign({}, build), { namespace, repository: targetRepository, registryCredential: credential }) }) });
6895
6797
  return preparedConfig;
6896
6798
  }
6897
6799
  /**
@@ -6909,9 +6811,9 @@ class FunctionDeployer {
6909
6811
  // 企业版登录凭证在触发 CloudApp 构建前换取,构建容器只消费 Secrets,
6910
6812
  // 不再自行签名调用 TCR API。
6911
6813
  const cloudRegistryId = ((_a = prepared.target) === null || _a === void 0 ? void 0 : _a.registryId) ||
6912
- cloudConfig.build.registryId ||
6913
- cloudConfig.registryId;
6914
- const enterpriseCredential = cloudConfig.imageType === 'enterprise' && cloudRegistryId
6814
+ cloudConfig.imageConfig.build.registryId ||
6815
+ cloudConfig.imageConfig.registryId;
6816
+ const enterpriseCredential = cloudConfig.imageConfig.imageType === 'enterprise' && cloudRegistryId
6915
6817
  ? await this.runLabeledStep(ctx, {
6916
6818
  stage: 'preflight',
6917
6819
  label: '获取企业版 TCR 临时登录凭证',
@@ -6949,7 +6851,7 @@ class FunctionDeployer {
6949
6851
  try {
6950
6852
  if (credential) {
6951
6853
  await this.runStep(ctx, 'login', async () => {
6952
- await (0, local_builder_1.loginDockerRegistry)(this.resolveRegistryFromRepository(localConfig.build.repository), credential, { deps: this.localBuilderDeps, commandOptions });
6854
+ await (0, local_builder_1.loginDockerRegistry)(this.resolveRegistryFromRepository(localConfig.imageConfig.build.repository), credential, { deps: this.localBuilderDeps, commandOptions });
6953
6855
  });
6954
6856
  }
6955
6857
  const buildResult = await this.runStep(ctx, 'build', async () => {
@@ -6966,14 +6868,14 @@ class FunctionDeployer {
6966
6868
  message: line
6967
6869
  }), { deps: this.localBuilderDeps, commandOptions });
6968
6870
  });
6969
- if (localConfig.imageType === 'personal') {
6871
+ if (localConfig.imageConfig.imageType === 'personal') {
6970
6872
  await this.runLabeledStep(ctx, {
6971
6873
  stage: 'push',
6972
6874
  label: '清理历史镜像标签',
6973
6875
  handler: () => this.personalTcrServiceFactory().cleanupTags({
6974
- namespace: localConfig.build.namespace,
6975
- repository: localConfig.build.repository,
6976
- retain: localConfig.build.retainedTags
6876
+ namespace: localConfig.imageConfig.build.namespace,
6877
+ repository: localConfig.imageConfig.build.repository,
6878
+ retain: localConfig.imageConfig.build.retainedTags
6977
6879
  })
6978
6880
  });
6979
6881
  }
@@ -6992,9 +6894,10 @@ class FunctionDeployer {
6992
6894
  }
6993
6895
  async resolveLocalRegistryCredential(config) {
6994
6896
  var _a, _b, _c;
6995
- const imageType = (_a = config.imageType) !== null && _a !== void 0 ? _a : (((_b = config.registryId) !== null && _b !== void 0 ? _b : config.build.registryId) ? 'enterprise' : 'personal');
6897
+ const build = config.imageConfig.build;
6898
+ const imageType = (_a = config.imageConfig.imageType) !== null && _a !== void 0 ? _a : (((_b = config.imageConfig.registryId) !== null && _b !== void 0 ? _b : build.registryId) ? 'enterprise' : 'personal');
6996
6899
  if (imageType === 'enterprise') {
6997
- const registryId = (_c = config.registryId) !== null && _c !== void 0 ? _c : config.build.registryId;
6900
+ const registryId = (_c = config.imageConfig.registryId) !== null && _c !== void 0 ? _c : build.registryId;
6998
6901
  if (!registryId) {
6999
6902
  throw new error_1.CloudBaseError('企业版 TCR local 构建缺少 registryId。', {
7000
6903
  code: types_1.FUNCTION_DEPLOY_ERROR.IMAGE_REGISTRY_ID_MISSING
@@ -7003,7 +6906,7 @@ class FunctionDeployer {
7003
6906
  const credential = await (0, enterprise_tcr_1.createEnterpriseTcrCredential)(this.tcrServiceFactory(), registryId);
7004
6907
  return { username: credential.username, secret: credential.token };
7005
6908
  }
7006
- const credential = config.build.registryCredential;
6909
+ const credential = build.registryCredential;
7007
6910
  if (!credential) {
7008
6911
  return undefined;
7009
6912
  }
@@ -7194,30 +7097,33 @@ class FunctionDeployer {
7194
7097
  }
7195
7098
  }
7196
7099
  exports.FunctionDeployer = FunctionDeployer;
7197
- __exportStar(__webpack_require__(22724), exports);
7198
- var config_guard_2 = __webpack_require__(69238);
7100
+ __exportStar(__webpack_require__(79345), exports);
7101
+ var config_guard_2 = __webpack_require__(74931);
7199
7102
  Object.defineProperty(exports, "assertDeployConfig", ({ enumerable: true, get: function () { return config_guard_2.assertDeployConfig; } }));
7200
7103
  Object.defineProperty(exports, "checkDeployConfig", ({ enumerable: true, get: function () { return config_guard_2.checkDeployConfig; } }));
7104
+ Object.defineProperty(exports, "applyMinimalDeployConfigDefaults", ({ enumerable: true, get: function () { return config_guard_2.applyMinimalDeployConfigDefaults; } }));
7105
+ Object.defineProperty(exports, "getMissingDeployInputs", ({ enumerable: true, get: function () { return config_guard_2.getMissingDeployInputs; } }));
7106
+ Object.defineProperty(exports, "prepareMinimalDeployConfig", ({ enumerable: true, get: function () { return config_guard_2.prepareMinimalDeployConfig; } }));
7201
7107
  Object.defineProperty(exports, "isCustomImageRuntime", ({ enumerable: true, get: function () { return config_guard_2.isCustomImageRuntime; } }));
7202
7108
  Object.defineProperty(exports, "normalizeDeployConfig", ({ enumerable: true, get: function () { return config_guard_2.normalizeDeployConfig; } }));
7203
7109
  Object.defineProperty(exports, "normalizeGatewayPath", ({ enumerable: true, get: function () { return config_guard_2.normalizeGatewayPath; } }));
7204
7110
  Object.defineProperty(exports, "parseImageReference", ({ enumerable: true, get: function () { return config_guard_2.parseImageReference; } }));
7205
- var planner_2 = __webpack_require__(28750);
7111
+ var planner_2 = __webpack_require__(72325);
7206
7112
  Object.defineProperty(exports, "createDeployPlan", ({ enumerable: true, get: function () { return planner_2.createDeployPlan; } }));
7207
7113
  Object.defineProperty(exports, "toCurrentState", ({ enumerable: true, get: function () { return planner_2.toCurrentState; } }));
7208
- var artifact_2 = __webpack_require__(78146);
7114
+ var artifact_2 = __webpack_require__(84187);
7209
7115
  Object.defineProperty(exports, "createCodeArtifact", ({ enumerable: true, get: function () { return artifact_2.createCodeArtifact; } }));
7210
7116
  Object.defineProperty(exports, "createImageArtifactFromConfig", ({ enumerable: true, get: function () { return artifact_2.createImageArtifactFromConfig; } }));
7211
7117
  Object.defineProperty(exports, "toCloudFunction", ({ enumerable: true, get: function () { return artifact_2.toCloudFunction; } }));
7212
- var cloud_2 = __webpack_require__(36114);
7118
+ var cloud_2 = __webpack_require__(4295);
7213
7119
  Object.defineProperty(exports, "buildImageOnCloud", ({ enumerable: true, get: function () { return cloud_2.buildImageOnCloud; } }));
7214
- var cloud_build_service_2 = __webpack_require__(52244);
7120
+ var cloud_build_service_2 = __webpack_require__(43587);
7215
7121
  Object.defineProperty(exports, "createCloudBuildService", ({ enumerable: true, get: function () { return cloud_build_service_2.createCloudBuildService; } }));
7216
- var preflight_2 = __webpack_require__(61081);
7122
+ var preflight_2 = __webpack_require__(69230);
7217
7123
  Object.defineProperty(exports, "runLocalPreflight", ({ enumerable: true, get: function () { return preflight_2.runLocalPreflight; } }));
7218
- var image_preflight_2 = __webpack_require__(56749);
7124
+ var image_preflight_2 = __webpack_require__(67650);
7219
7125
  Object.defineProperty(exports, "runImageRemotePreflight", ({ enumerable: true, get: function () { return image_preflight_2.runImageRemotePreflight; } }));
7220
- var cam_preflight_2 = __webpack_require__(11903);
7126
+ var cam_preflight_2 = __webpack_require__(68388);
7221
7127
  Object.defineProperty(exports, "runImagePullAuthPreflight", ({ enumerable: true, get: function () { return cam_preflight_2.runImagePullAuthPreflight; } }));
7222
7128
  Object.defineProperty(exports, "isCamPermissionError", ({ enumerable: true, get: function () { return cam_preflight_2.isCamPermissionError; } }));
7223
7129
  Object.defineProperty(exports, "SCF_PULL_IMAGE_ROLE", ({ enumerable: true, get: function () { return cam_preflight_2.SCF_PULL_IMAGE_ROLE; } }));
@@ -7227,16 +7133,16 @@ Object.defineProperty(exports, "IMAGE_PULL_GRANT_URL", ({ enumerable: true, get:
7227
7133
 
7228
7134
  /***/ },
7229
7135
 
7230
- /***/ 83463
7136
+ /***/ 6378
7231
7137
  (__unused_webpack_module, exports, __webpack_require__) {
7232
7138
 
7233
7139
  "use strict";
7234
7140
 
7235
7141
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7236
7142
  exports.GatewayDeployer = void 0;
7237
- const domain_1 = __webpack_require__(83597);
7238
- const error_1 = __webpack_require__(18143);
7239
- const utils_1 = __webpack_require__(24263);
7143
+ const domain_1 = __webpack_require__(43294);
7144
+ const error_1 = __webpack_require__(54884);
7145
+ const utils_1 = __webpack_require__(88208);
7240
7146
  /**
7241
7147
  * 网关声明式部署器
7242
7148
  * 支持 function:<name>(SCF 云函数)与 hosting:<name>(STATIC_STORE 静态托管)两种目标
@@ -7847,343 +7753,7 @@ exports.GatewayDeployer = GatewayDeployer;
7847
7753
 
7848
7754
  /***/ },
7849
7755
 
7850
- /***/ 13483
7851
- (__unused_webpack_module, exports, __webpack_require__) {
7852
-
7853
- "use strict";
7854
-
7855
- var __importDefault = (this && this.__importDefault) || function (mod) {
7856
- return (mod && mod.__esModule) ? mod : { "default": mod };
7857
- };
7858
- Object.defineProperty(exports, "__esModule", ({ value: true }));
7859
- exports.StateStore = exports.DEFAULT_HASH_LENGTH = exports.DEFAULT_MAX_HOSTING_FILES = exports.HostingFilesOverLimitError = void 0;
7860
- const fs_1 = __importDefault(__webpack_require__(29021));
7861
- const path_1 = __importDefault(__webpack_require__(33873));
7862
- const crypto_1 = __importDefault(__webpack_require__(55511));
7863
- const child_process_1 = __webpack_require__(79646);
7864
- const error_1 = __webpack_require__(18143);
7865
- /** hosting 指纹文件数超过上限时抛出(触发降级为全量部署) */
7866
- class HostingFilesOverLimitError extends Error {
7867
- constructor(fileCount, limit) {
7868
- super(`hosting 文件数 ${fileCount} 超过指纹上限 ${limit},跳过逐文件 diff,降级为全量部署`);
7869
- this.name = 'HostingFilesOverLimitError';
7870
- this.fileCount = fileCount;
7871
- this.limit = limit;
7872
- }
7873
- }
7874
- exports.HostingFilesOverLimitError = HostingFilesOverLimitError;
7875
- /** 默认强制忽略的目录/文件(不可被调用方关闭) */
7876
- const DEFAULT_IGNORE = ['.DS_Store', 'node_modules/'];
7877
- /** 默认指纹文件数上限(防快照膨胀与 I/O 失控) */
7878
- exports.DEFAULT_MAX_HOSTING_FILES = 50000;
7879
- /** 默认 hash 截断长度(16 位 hex = 64bit,碰撞概率可忽略;快照体积减半) */
7880
- exports.DEFAULT_HASH_LENGTH = 16;
7881
- /**
7882
- * 部署状态快照(StateStore)
7883
- *
7884
- * 职责:读写 `.cloudbase/state.json`(默认),为 dry-run 的 hosting/app diff 提供本地基准,
7885
- * 避免每次 diff 都拉取云端。
7886
- *
7887
- * 指纹算法:hosting = 产物目录逐文件内容 sha256(相对路径为 key)。
7888
- * 只存 hash 不存内容,体积 = O(文件数);app 快照不写入 envVariables(敏感过滤)。
7889
- */
7890
- class StateStore {
7891
- constructor(options = {}) {
7892
- this.cwd = options.cwd || process.cwd();
7893
- this.env = options.env;
7894
- this.stateFile = options.stateFile;
7895
- }
7896
- /**
7897
- * 计算 state 文件路径:
7898
- * - 自定义 stateFile 优先
7899
- * - 否则 {cwd}/.cloudbase/state.json(无 env)或 state.{env}.json(多环境隔离)
7900
- */
7901
- getFilePath() {
7902
- if (this.stateFile) {
7903
- return this.stateFile;
7904
- }
7905
- const base = this.env ? `state.${this.env}.json` : 'state.json';
7906
- return path_1.default.join(this.cwd, '.cloudbase', base);
7907
- }
7908
- /**
7909
- * 读取状态快照;文件不存在或 JSON 损坏返回 null(缺失降级,由调用方走云端兜底)
7910
- */
7911
- read() {
7912
- const filePath = this.getFilePath();
7913
- if (!fs_1.default.existsSync(filePath)) {
7914
- return null;
7915
- }
7916
- try {
7917
- return JSON.parse(fs_1.default.readFileSync(filePath, 'utf8'));
7918
- }
7919
- catch (_a) {
7920
- return null;
7921
- }
7922
- }
7923
- /**
7924
- * 写入状态快照(自动补 version/updatedAt/gitCommit,自动创建 .cloudbase 目录)
7925
- */
7926
- write(state) {
7927
- var _a;
7928
- const filePath = this.getFilePath();
7929
- fs_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
7930
- const full = {
7931
- version: 1,
7932
- updatedAt: new Date().toISOString(),
7933
- gitCommit: (_a = state.gitCommit) !== null && _a !== void 0 ? _a : this.resolveGitCommit(),
7934
- envId: state.envId,
7935
- resources: state.resources
7936
- };
7937
- fs_1.default.writeFileSync(filePath, JSON.stringify(full, null, 2), 'utf8');
7938
- }
7939
- /**
7940
- * 计算产物目录逐文件 sha256 指纹(仅 hash,兼容旧调用)
7941
- *
7942
- * @param projectPath 产物目录(hosting 的 outputDir / root)
7943
- * @param ignore 自定义忽略规则(追加到默认 node_modules / .DS_Store 之后)
7944
- * @param options 扫描选项(maxFiles / hashLength)
7945
- * @returns 相对路径(/ 分隔)→ 文件内容 sha256(默认截断 16 位)
7946
- */
7947
- async computeHostingFiles(projectPath, ignore = [], options = {}) {
7948
- const fingerprints = await this.computeHostingFingerprints(projectPath, ignore, options);
7949
- const result = {};
7950
- for (const [relPath, fp] of Object.entries(fingerprints)) {
7951
- result[relPath] = fp.hash;
7952
- }
7953
- return result;
7954
- }
7955
- /**
7956
- * 计算产物目录逐文件指纹(hash + size)
7957
- *
7958
- * - 强制忽略 node_modules / .DS_Store(与传入 ignore 合并,不可关闭)
7959
- * - hash 默认截断为 16 位 hex(hashLength 可调,64 = 完整 sha256)
7960
- * - 文件数超过 maxFiles 抛 HostingFilesOverLimitError(防快照膨胀与 I/O 失控)
7961
- *
7962
- * @param projectPath 产物目录(hosting 的 outputDir / root)
7963
- * @param ignore 自定义忽略规则
7964
- * @param options 扫描选项(maxFiles / hashLength)
7965
- * @returns 相对路径(/ 分隔)→ { hash, size }
7966
- */
7967
- async computeHostingFingerprints(projectPath, ignore = [], options = {}) {
7968
- if (!fs_1.default.existsSync(projectPath) || !fs_1.default.statSync(projectPath).isDirectory()) {
7969
- throw new error_1.CloudBaseError(`产物目录不存在或不是目录:${projectPath}`);
7970
- }
7971
- const { maxFiles = exports.DEFAULT_MAX_HOSTING_FILES, hashLength = exports.DEFAULT_HASH_LENGTH } = options;
7972
- const effectiveIgnore = this.mergeIgnore(ignore);
7973
- const files = {};
7974
- let count = 0;
7975
- const walk = (dir, rel) => {
7976
- for (const entry of fs_1.default.readdirSync(dir, { withFileTypes: true })) {
7977
- const entryPath = path_1.default.join(dir, entry.name);
7978
- const relPath = rel ? path_1.default.join(rel, entry.name) : entry.name;
7979
- if (entry.isDirectory()) {
7980
- if (this.isIgnored(relPath, effectiveIgnore)) {
7981
- continue;
7982
- }
7983
- walk(entryPath, relPath);
7984
- }
7985
- else if (entry.isFile() && !this.isIgnored(relPath, effectiveIgnore)) {
7986
- count++;
7987
- if (maxFiles > 0 && count > maxFiles) {
7988
- throw new HostingFilesOverLimitError(count, maxFiles);
7989
- }
7990
- const normalized = relPath.split(path_1.default.sep).join('/');
7991
- files[normalized] = {
7992
- hash: this.hashFile(entryPath, hashLength),
7993
- size: fs_1.default.statSync(entryPath).size
7994
- };
7995
- }
7996
- }
7997
- };
7998
- walk(projectPath, '');
7999
- return files;
8000
- }
8001
- /**
8002
- * 计算产物目录与快照的变更集(懒加载)
8003
- *
8004
- * 优化:先 stat 拿 size,size 与快照不同的文件直接判定变更(不读文件内容),
8005
- * 只有 size 相同(或旧快照 size 未知)的文件才读内容 hash 对比,
8006
- * 避免为未变文件做无谓的 I/O 与 hash。
8007
- * 文件数超过 maxFiles 时放弃 diff,返回 overLimit=true(调用方应降级为全量部署)。
8008
- *
8009
- * @param projectPath 产物目录(hosting 的 outputDir / root)
8010
- * @param previous 上次快照指纹(undefined = 首次部署,全部视为新增)
8011
- * @param options 选项(ignore / maxFiles / hashLength)
8012
- */
8013
- async diffHostingFiles(projectPath, previous, options = {}) {
8014
- if (!fs_1.default.existsSync(projectPath) || !fs_1.default.statSync(projectPath).isDirectory()) {
8015
- throw new error_1.CloudBaseError(`产物目录不存在或不是目录:${projectPath}`);
8016
- }
8017
- const { ignore = [], maxFiles = exports.DEFAULT_MAX_HOSTING_FILES, hashLength = exports.DEFAULT_HASH_LENGTH } = options;
8018
- const effectiveIgnore = this.mergeIgnore(ignore);
8019
- // 归一化快照:旧格式(string)size 未知 → -1,走 hash 对比而非 size 预判
8020
- let prev;
8021
- if (previous) {
8022
- prev = {};
8023
- for (const [k, v] of Object.entries(previous)) {
8024
- prev[k] = this.normalizeFileValue(v);
8025
- }
8026
- }
8027
- const localFiles = new Set();
8028
- const added = [];
8029
- const modified = [];
8030
- let count = 0;
8031
- let overLimit = false;
8032
- const walk = (dir, rel) => {
8033
- if (overLimit) {
8034
- return;
8035
- }
8036
- for (const entry of fs_1.default.readdirSync(dir, { withFileTypes: true })) {
8037
- const entryPath = path_1.default.join(dir, entry.name);
8038
- const relPath = rel ? path_1.default.join(rel, entry.name) : entry.name;
8039
- if (entry.isDirectory()) {
8040
- if (this.isIgnored(relPath, effectiveIgnore)) {
8041
- continue;
8042
- }
8043
- walk(entryPath, relPath);
8044
- }
8045
- else if (entry.isFile() && !this.isIgnored(relPath, effectiveIgnore)) {
8046
- count++;
8047
- if (maxFiles > 0 && count > maxFiles) {
8048
- overLimit = true;
8049
- return;
8050
- }
8051
- const normalized = relPath.split(path_1.default.sep).join('/');
8052
- localFiles.add(normalized);
8053
- const prevEntry = prev === null || prev === void 0 ? void 0 : prev[normalized];
8054
- if (!prevEntry) {
8055
- added.push(normalized);
8056
- }
8057
- else if (prevEntry.size !== -1 && prevEntry.size !== fs_1.default.statSync(entryPath).size) {
8058
- // size 变化 → 内容必变,无需读文件(懒加载核心)
8059
- modified.push(normalized);
8060
- }
8061
- else {
8062
- // size 相同或旧快照 size 未知 → 读内容 hash 确认
8063
- const hash = this.hashFile(entryPath, hashLength);
8064
- if (prevEntry.hash !== hash) {
8065
- modified.push(normalized);
8066
- }
8067
- }
8068
- }
8069
- }
8070
- };
8071
- walk(projectPath, '');
8072
- if (overLimit) {
8073
- return {
8074
- added: [],
8075
- modified: [],
8076
- deleted: [],
8077
- totalChanged: 0,
8078
- unchanged: false,
8079
- overLimit: true
8080
- };
8081
- }
8082
- const deleted = prev
8083
- ? Object.keys(prev).filter(k => !localFiles.has(k) && !this.isIgnored(k, effectiveIgnore))
8084
- : [];
8085
- const totalChanged = added.length + modified.length + deleted.length;
8086
- return { added, modified, deleted, totalChanged, unchanged: totalChanged === 0 };
8087
- }
8088
- /**
8089
- * 提取 app 配置快照(仅 diff 白名单字段)
8090
- * envVariables / ignore 等非 diff 字段与敏感信息不进入快照
8091
- */
8092
- buildAppConfig(config) {
8093
- if (!config || typeof config !== 'object') {
8094
- return undefined;
8095
- }
8096
- const entry = {};
8097
- if (config.serviceName !== undefined) {
8098
- entry.serviceName = config.serviceName;
8099
- }
8100
- if (config.installCommand !== undefined) {
8101
- entry.installCommand = config.installCommand;
8102
- }
8103
- if (config.buildCommand !== undefined) {
8104
- entry.buildCommand = config.buildCommand;
8105
- }
8106
- if (config.outputDir !== undefined) {
8107
- entry.outputDir = config.outputDir;
8108
- }
8109
- if (config.deployPath !== undefined) {
8110
- entry.deployPath = config.deployPath;
8111
- }
8112
- return entry;
8113
- }
8114
- hashFile(filePath, hashLength = exports.DEFAULT_HASH_LENGTH) {
8115
- const content = fs_1.default.readFileSync(filePath);
8116
- return crypto_1.default.createHash('sha256').update(content).digest('hex').slice(0, hashLength);
8117
- }
8118
- /** 合并默认忽略规则(node_modules / .DS_Store 不可被调用方关闭) */
8119
- mergeIgnore(ignore) {
8120
- return Array.from(new Set([...DEFAULT_IGNORE, ...(ignore || [])]));
8121
- }
8122
- /** 归一化快照指纹值:旧格式(纯 string = 仅 hash,size 未知用 -1 表示) */
8123
- normalizeFileValue(value) {
8124
- if (typeof value === 'string') {
8125
- return { hash: value, size: -1 };
8126
- }
8127
- return value;
8128
- }
8129
- /**
8130
- * 是否命中忽略规则:
8131
- * - 目录模式(结尾 /):匹配该目录及其下所有
8132
- * - glob(含 **):转换为正则匹配相对路径
8133
- * - 其余:精确/前缀匹配
8134
- */
8135
- isIgnored(relPath, ignore) {
8136
- const normalized = relPath.split(path_1.default.sep).join('/');
8137
- for (const pattern of ignore) {
8138
- if (this.matchPattern(normalized, pattern)) {
8139
- return true;
8140
- }
8141
- }
8142
- return false;
8143
- }
8144
- matchPattern(relPath, pattern) {
8145
- const p = pattern.trim();
8146
- if (!p) {
8147
- return false;
8148
- }
8149
- // 目录模式(结尾 /):匹配目录本身及下所有内容
8150
- if (p.endsWith('/')) {
8151
- const prefix = p.slice(0, -1);
8152
- return relPath === prefix || relPath.startsWith(prefix + '/');
8153
- }
8154
- // glob(含 **):把 ** 转成 .*,其余转义后整体匹配
8155
- if (p.includes('**')) {
8156
- const regexStr = '^' +
8157
- p.split('**').map(part => this.escapeRegExp(part)).join('.*') +
8158
- '$';
8159
- return new RegExp(regexStr).test(relPath);
8160
- }
8161
- // 精确匹配或前缀匹配(目录下的文件)
8162
- return relPath === p || relPath.startsWith(p + '/');
8163
- }
8164
- escapeRegExp(s) {
8165
- return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
8166
- }
8167
- /** 解析当前 git commit(非 git 仓库或失败返回 undefined,不阻断) */
8168
- resolveGitCommit() {
8169
- try {
8170
- const out = (0, child_process_1.execSync)('git rev-parse HEAD', {
8171
- cwd: this.cwd,
8172
- stdio: 'pipe'
8173
- });
8174
- return out.toString().trim() || undefined;
8175
- }
8176
- catch (_a) {
8177
- return undefined;
8178
- }
8179
- }
8180
- }
8181
- exports.StateStore = StateStore;
8182
-
8183
-
8184
- /***/ },
8185
-
8186
- /***/ 1227
7756
+ /***/ 19672
8187
7757
  (__unused_webpack_module, exports, __webpack_require__) {
8188
7758
 
8189
7759
  "use strict";
@@ -8195,8 +7765,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
8195
7765
  exports.StaticDeployer = void 0;
8196
7766
  const path_1 = __importDefault(__webpack_require__(33873));
8197
7767
  const child_process_1 = __webpack_require__(79646);
8198
- const error_1 = __webpack_require__(18143);
8199
- const framework_1 = __webpack_require__(20789);
7768
+ const error_1 = __webpack_require__(54884);
7769
+ const framework_1 = __webpack_require__(72980);
8200
7770
  /** 环境变量值统一转字符串(execSync env 要求 string) */
8201
7771
  function stringifyEnvValues(envVariables) {
8202
7772
  const result = {};
@@ -8433,7 +8003,7 @@ exports.StaticDeployer = StaticDeployer;
8433
8003
 
8434
8004
  /***/ },
8435
8005
 
8436
- /***/ 83597
8006
+ /***/ 43294
8437
8007
  (__unused_webpack_module, exports) {
8438
8008
 
8439
8009
  "use strict";
@@ -8482,7 +8052,7 @@ function getGatewayBaseUrl(environment, envId) {
8482
8052
 
8483
8053
  /***/ },
8484
8054
 
8485
- /***/ 20789
8055
+ /***/ 72980
8486
8056
  (__unused_webpack_module, exports, __webpack_require__) {
8487
8057
 
8488
8058
  "use strict";
@@ -8720,7 +8290,7 @@ function resolveHostingOutputDir(config, root, readPkgFile = defaultReadPkgFile)
8720
8290
 
8721
8291
  /***/ },
8722
8292
 
8723
- /***/ 78146
8293
+ /***/ 84187
8724
8294
  (__unused_webpack_module, exports, __webpack_require__) {
8725
8295
 
8726
8296
  "use strict";
@@ -8731,12 +8301,30 @@ exports.createImageArtifactFromConfig = createImageArtifactFromConfig;
8731
8301
  exports.createImageArtifactFromBuild = createImageArtifactFromBuild;
8732
8302
  exports.createImageArtifactFromCloudBuild = createImageArtifactFromCloudBuild;
8733
8303
  exports.toCloudFunction = toCloudFunction;
8734
- const types_1 = __webpack_require__(22724);
8304
+ const error_1 = __webpack_require__(54884);
8305
+ const types_1 = __webpack_require__(79345);
8735
8306
  /**
8736
- * 部署物构造与 SCF 参数映射
8307
+ * 解析构建类镜像部署物的 SCF RegistryId
8737
8308
  *
8738
- * 四种构建策略最终都产出统一的部署物,之后走同一条 SCF 创建或更新流程
8309
+ * 个人版镜像(personal,如个人版 CCR)不携带 registryId;企业版优先取
8310
+ * imageConfig.registryId,回退到构建配置 imageConfig.build.registryId。
8311
+ * 正常流程下企业版 registryId 已由 prepareEnterpriseTcrTarget 在构建前解析补齐,
8312
+ * 此处对缺失场景 fail-fast 并给出明确错误:避免产出缺少 RegistryId 的部署物,
8313
+ * 导致后续 SCF 拉取企业版镜像时失败且难以排查。
8739
8314
  */
8315
+ function resolveBuildRegistryId(imageConfig) {
8316
+ var _a, _b;
8317
+ if (imageConfig.imageType !== 'enterprise') {
8318
+ return undefined;
8319
+ }
8320
+ const registryId = (_a = imageConfig.registryId) !== null && _a !== void 0 ? _a : (_b = imageConfig.build) === null || _b === void 0 ? void 0 : _b.registryId;
8321
+ if (!registryId) {
8322
+ throw new error_1.CloudBaseError('企业版镜像缺少 TCR 实例 ID(registryId),无法生成镜像部署物。', {
8323
+ code: types_1.FUNCTION_DEPLOY_ERROR.IMAGE_REGISTRY_ID_MISSING
8324
+ });
8325
+ }
8326
+ return registryId;
8327
+ }
8740
8328
  /** 由本地代码来源构造代码类部署物 */
8741
8329
  function createCodeArtifact(config) {
8742
8330
  const functionRootPath = 'functionRootPath' in config ? config.functionRootPath : undefined;
@@ -8754,28 +8342,26 @@ function createCodeArtifact(config) {
8754
8342
  }
8755
8343
  /** 由已有镜像配置构造镜像类部署物 */
8756
8344
  function createImageArtifactFromConfig(config) {
8757
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
8345
+ var _a;
8758
8346
  const { imageConfig } = config;
8759
- // imageType/registryId 的契约位置在配置顶层(IHttpImageRuntimeCommon),
8760
- // 与 local/cloud 策略一致;imageConfig 内的同名字段仅作向后兼容兜底。
8347
+ // 直接读取 cloudbaserc 嵌套形状:镜像字段全部位于 imageConfig。
8761
8348
  // 个人版镜像(personal,如个人版 CCR)不应携带 registryId。
8762
- const configuredRegistryId = (_a = config.registryId) !== null && _a !== void 0 ? _a : imageConfig.registryId;
8763
- const imageType = (_c = (_b = config.imageType) !== null && _b !== void 0 ? _b : imageConfig.imageType) !== null && _c !== void 0 ? _c : (configuredRegistryId ? 'enterprise' : 'personal');
8764
- const registryId = imageType === 'enterprise' ? configuredRegistryId : undefined;
8349
+ const imageType = imageConfig.imageType;
8350
+ const registryId = imageType === 'enterprise' ? imageConfig.registryId : undefined;
8765
8351
  return {
8766
8352
  kind: 'image',
8767
8353
  deployMode: 'image',
8768
8354
  imageUri: imageConfig.imageUri,
8769
8355
  imageType,
8770
8356
  registryId,
8771
- imagePort: types_1.IMAGE_FUNCTION_PORT,
8357
+ imagePort: (_a = imageConfig.imagePort) !== null && _a !== void 0 ? _a : types_1.IMAGE_FUNCTION_PORT,
8772
8358
  effectiveStrategy: 'image',
8773
- entryPoint: (_d = imageConfig.entryPoint) !== null && _d !== void 0 ? _d : config.entryPoint,
8774
- command: (_e = imageConfig.command) !== null && _e !== void 0 ? _e : config.command,
8775
- args: (_f = imageConfig.args) !== null && _f !== void 0 ? _f : config.args,
8776
- commandList: (_g = imageConfig.commandList) !== null && _g !== void 0 ? _g : config.commandList,
8777
- argsList: (_h = imageConfig.argsList) !== null && _h !== void 0 ? _h : config.argsList,
8778
- containerImageAccelerate: (_j = imageConfig.containerImageAccelerate) !== null && _j !== void 0 ? _j : config.containerImageAccelerate
8359
+ entryPoint: imageConfig.entryPoint,
8360
+ command: imageConfig.command,
8361
+ args: imageConfig.args,
8362
+ commandList: imageConfig.commandList,
8363
+ argsList: imageConfig.argsList,
8364
+ containerImageAccelerate: imageConfig.containerImageAccelerate
8779
8365
  };
8780
8366
  }
8781
8367
  /**
@@ -8785,11 +8371,10 @@ function createImageArtifactFromConfig(config) {
8785
8371
  * 此处仅承载最终 imageUri/digest 与容器启动配置,之后复用镜像部署链。
8786
8372
  */
8787
8373
  function createImageArtifactFromBuild(config, build) {
8788
- var _a, _b, _c;
8789
- const imageType = (_a = config.imageType) !== null && _a !== void 0 ? _a : (((_b = config.registryId) !== null && _b !== void 0 ? _b : config.build.registryId) ? 'enterprise' : 'personal');
8790
- const registryId = imageType === 'enterprise'
8791
- ? (_c = config.registryId) !== null && _c !== void 0 ? _c : config.build.registryId
8792
- : undefined;
8374
+ var _a;
8375
+ const { imageConfig } = config;
8376
+ const imageType = imageConfig.imageType;
8377
+ const registryId = resolveBuildRegistryId(imageConfig);
8793
8378
  return {
8794
8379
  kind: 'image',
8795
8380
  deployMode: 'image',
@@ -8797,14 +8382,14 @@ function createImageArtifactFromBuild(config, build) {
8797
8382
  imageDigest: build.imageDigest,
8798
8383
  imageType,
8799
8384
  registryId,
8800
- imagePort: types_1.IMAGE_FUNCTION_PORT,
8385
+ imagePort: (_a = imageConfig.imagePort) !== null && _a !== void 0 ? _a : types_1.IMAGE_FUNCTION_PORT,
8801
8386
  effectiveStrategy: 'local',
8802
- entryPoint: config.entryPoint,
8803
- command: config.command,
8804
- args: config.args,
8805
- commandList: config.commandList,
8806
- argsList: config.argsList,
8807
- containerImageAccelerate: config.containerImageAccelerate
8387
+ entryPoint: imageConfig.entryPoint,
8388
+ command: imageConfig.command,
8389
+ args: imageConfig.args,
8390
+ commandList: imageConfig.commandList,
8391
+ argsList: imageConfig.argsList,
8392
+ containerImageAccelerate: imageConfig.containerImageAccelerate
8808
8393
  };
8809
8394
  }
8810
8395
  /**
@@ -8815,30 +8400,29 @@ function createImageArtifactFromBuild(config, build) {
8815
8400
  * effectiveStrategy 标记为 cloud,便于结果层如实回传实际生效的策略。
8816
8401
  */
8817
8402
  function createImageArtifactFromCloudBuild(config, build) {
8818
- var _a, _b;
8819
- const imageType = (_a = config.imageType) !== null && _a !== void 0 ? _a : (config.build.registryId ? 'enterprise' : 'personal');
8820
- const registryId = imageType === 'enterprise'
8821
- ? (_b = config.registryId) !== null && _b !== void 0 ? _b : config.build.registryId
8822
- : undefined;
8403
+ var _a;
8404
+ const { imageConfig } = config;
8405
+ const imageType = imageConfig.imageType;
8406
+ // 云端构建默认推送到个人版 TCR(CCR);企业版实例 ID 位于 imageConfig.build.registryId,
8407
+ // 需继续透传到 Stage B 的 SCF ImageConfig,避免构建成功后拉取镜像时丢失 RegistryId。
8408
+ const registryId = resolveBuildRegistryId(imageConfig);
8823
8409
  return {
8824
8410
  kind: 'image',
8825
8411
  deployMode: 'image',
8826
8412
  imageUri: build.imageUri,
8827
8413
  imageDigest: build.imageDigest,
8828
- // 云端构建默认推送到个人版 TCR(CCR);企业版实例 ID 位于 build.registryId,
8829
- // 需继续透传到 Stage B 的 SCF ImageConfig,避免构建成功后拉取镜像时丢失 RegistryId。
8830
8414
  imageType,
8831
8415
  registryId,
8832
- imagePort: types_1.IMAGE_FUNCTION_PORT,
8416
+ imagePort: (_a = imageConfig.imagePort) !== null && _a !== void 0 ? _a : types_1.IMAGE_FUNCTION_PORT,
8833
8417
  effectiveStrategy: 'cloud',
8834
8418
  buildId: build.buildId,
8835
8419
  logsUrl: build.logsUrl,
8836
- entryPoint: config.entryPoint,
8837
- command: config.command,
8838
- args: config.args,
8839
- commandList: config.commandList,
8840
- argsList: config.argsList,
8841
- containerImageAccelerate: config.containerImageAccelerate
8420
+ entryPoint: imageConfig.entryPoint,
8421
+ command: imageConfig.command,
8422
+ args: imageConfig.args,
8423
+ commandList: imageConfig.commandList,
8424
+ argsList: imageConfig.argsList,
8425
+ containerImageAccelerate: imageConfig.containerImageAccelerate
8842
8426
  };
8843
8427
  }
8844
8428
  /** 将构建产出的 tag 地址与 digest 合成为 SCF 支持的不可变镜像引用 */
@@ -8960,7 +8544,7 @@ function toCloudFunction(config, artifact) {
8960
8544
 
8961
8545
  /***/ },
8962
8546
 
8963
- /***/ 36114
8547
+ /***/ 4295
8964
8548
  (__unused_webpack_module, exports, __webpack_require__) {
8965
8549
 
8966
8550
  "use strict";
@@ -8972,8 +8556,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
8972
8556
  exports.buildImageOnCloud = buildImageOnCloud;
8973
8557
  const fs_1 = __importDefault(__webpack_require__(29021));
8974
8558
  const path_1 = __importDefault(__webpack_require__(33873));
8975
- const error_1 = __webpack_require__(18143);
8976
- const types_1 = __webpack_require__(22724);
8559
+ const error_1 = __webpack_require__(54884);
8560
+ const types_1 = __webpack_require__(79345);
8977
8561
  /**
8978
8562
  * 云端镜像构建(cloud 策略)
8979
8563
  *
@@ -9075,11 +8659,12 @@ function assertSafeBuildArgs(buildArgs) {
9075
8659
  /** 个人版 CCR 默认域名 */
9076
8660
  const DEFAULT_PERSONAL_REGISTRY = 'ccr.ccs.tencentyun.com';
9077
8661
  function resolveTarget(config) {
9078
- const build = config.build;
8662
+ const build = config.imageConfig.build;
8663
+ const imageType = config.imageConfig.imageType;
9079
8664
  const repository = (build.repository || config.name).trim();
9080
8665
  const rawRegistryId = build.registryId;
9081
8666
  const registryId = typeof rawRegistryId === 'string' ? rawRegistryId.trim() : rawRegistryId;
9082
- const isEnterprise = config.imageType === 'enterprise' || Boolean(registryId);
8667
+ const isEnterprise = imageType === 'enterprise' || Boolean(registryId);
9083
8668
  // CloudApp custom 构建与推送必须使用同一个平台版本 tag。
9084
8669
  // 若允许自定义 tag,build-image 会构建自定义 tag,而固定推送脚本会推
9085
8670
  // $CLOUDBASE_VERSION_NAME,最终必然找不到本地镜像。
@@ -9121,10 +8706,10 @@ function resolveTarget(config) {
9121
8706
  throw new error_1.CloudBaseError('cloud 策略缺少 TCR 命名空间,请配置 build.namespace 或在完整 repository 中声明', { code: types_1.FUNCTION_DEPLOY_ERROR.BUILD_REPOSITORY_INVALID });
9122
8707
  }
9123
8708
  assertSafeRegistryToken(namespace, 'TCR namespace');
9124
- if (config.imageType === 'personal' && registryId) {
8709
+ if (imageType === 'personal' && registryId) {
9125
8710
  throw new error_1.CloudBaseError('cloud 策略的 personal 镜像不能配置 build.registryId;请移除该字段或改用 enterprise', { code: types_1.FUNCTION_DEPLOY_ERROR.IMAGE_TYPE_INVALID });
9126
8711
  }
9127
- if (config.imageType === 'enterprise') {
8712
+ if (imageType === 'enterprise') {
9128
8713
  if (rawRegistryId === undefined || rawRegistryId === null) {
9129
8714
  throw new error_1.CloudBaseError('cloud 策略的企业版 TCR 未配置 build.registryId;如果当前没有企业版实例,请改用 imageType=personal', { code: types_1.FUNCTION_DEPLOY_ERROR.IMAGE_REGISTRY_ID_MISSING });
9130
8715
  }
@@ -9149,9 +8734,10 @@ function resolveTarget(config) {
9149
8734
  * CustomSteps 只包含 SDK 固定命令和经过白名单校验的 build arg key。
9150
8735
  */
9151
8736
  function resolveCloudBuildOptions(config) {
9152
- const dockerfile = config.build.dockerfile || types_1.DEFAULT_DOCKERFILE;
9153
- const platform = config.build.platform || types_1.DEFAULT_IMAGE_PLATFORM;
9154
- const buildArgs = config.build.buildArgs || {};
8737
+ const build = config.imageConfig.build;
8738
+ const dockerfile = build.dockerfile || types_1.DEFAULT_DOCKERFILE;
8739
+ const platform = build.platform || types_1.DEFAULT_IMAGE_PLATFORM;
8740
+ const buildArgs = build.buildArgs || {};
9155
8741
  assertSafeDockerfile(dockerfile);
9156
8742
  if (platform !== types_1.DEFAULT_IMAGE_PLATFORM) {
9157
8743
  throw new error_1.CloudBaseError(`当前仅支持构建 ${types_1.DEFAULT_IMAGE_PLATFORM} 镜像`, {
@@ -9163,7 +8749,7 @@ function resolveCloudBuildOptions(config) {
9163
8749
  dockerfile,
9164
8750
  platform,
9165
8751
  buildArgs,
9166
- forceBuild: config.build.forceBuild === true
8752
+ forceBuild: build.forceBuild === true
9167
8753
  };
9168
8754
  }
9169
8755
  /**
@@ -9236,9 +8822,9 @@ function buildRegistryCredentials(config, target, enterpriseCredential) {
9236
8822
  ]
9237
8823
  };
9238
8824
  }
9239
- const credential = config.build.registryCredential;
8825
+ const credential = config.imageConfig.build.registryCredential;
9240
8826
  if (!credential) {
9241
- throw new error_1.CloudBaseError('个人版 TCR 云端构建缺少 build.registryCredential;请在 cloudbaserc 中显式声明 ' +
8827
+ throw new error_1.CloudBaseError('个人版 TCR 云端构建缺少 imageConfig.build.registryCredential;请在 cloudbaserc 中显式声明 ' +
9242
8828
  'username/password,推荐分别使用 "{{env.TCB_TCR_USERNAME}}" 和 ' +
9243
8829
  '"{{env.TCB_TCR_PASSWORD}}"', { code: types_1.FUNCTION_DEPLOY_ERROR.CLOUD_REGISTRY_CREDENTIAL_MISSING });
9244
8830
  }
@@ -9262,7 +8848,7 @@ function buildRegistryCredentials(config, target, enterpriseCredential) {
9262
8848
  };
9263
8849
  }
9264
8850
  function resolveCloudBuildContext(config, dockerfile) {
9265
- const cwd = path_1.default.resolve(config.build.cwd || config.functionPath || process.cwd());
8851
+ const cwd = path_1.default.resolve(config.imageConfig.build.cwd || config.functionPath || process.cwd());
9266
8852
  const dockerfilePath = path_1.default.resolve(cwd, dockerfile);
9267
8853
  let stat = null;
9268
8854
  try {
@@ -9444,7 +9030,7 @@ async function pollUntilTerminal(params) {
9444
9030
 
9445
9031
  /***/ },
9446
9032
 
9447
- /***/ 11903
9033
+ /***/ 68388
9448
9034
  (__unused_webpack_module, exports, __webpack_require__) {
9449
9035
 
9450
9036
  "use strict";
@@ -9453,7 +9039,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
9453
9039
  exports.TCR_PUSH_GRANT_URL = exports.IMAGE_PULL_GRANT_URL = exports.REQUIRED_TCR_PUSH_POLICY = exports.TCB_PUSH_ENTERPRISE_IMAGE_ROLE = exports.REQUIRED_IMAGE_PULL_POLICY = exports.SCF_PULL_IMAGE_ROLE = void 0;
9454
9040
  exports.isCamPermissionError = isCamPermissionError;
9455
9041
  exports.runImagePullAuthPreflight = runImagePullAuthPreflight;
9456
- const types_1 = __webpack_require__(22724);
9042
+ const types_1 = __webpack_require__(79345);
9457
9043
  /**
9458
9044
  * 镜像仓库授权 Preflight(涉及 CAM,scope: cloud)
9459
9045
  *
@@ -9524,9 +9110,10 @@ function needsImagePullAuth(config) {
9524
9110
  }
9525
9111
  /** 只有企业版 cloud 策略需要 CloudApp 向企业版 TCR 推送镜像 */
9526
9112
  function needsEnterpriseTcrPushAuth(config) {
9113
+ var _a;
9527
9114
  return (config.type === 'HTTP' &&
9528
9115
  config.buildStrategy === 'cloud' &&
9529
- config.imageType === 'enterprise');
9116
+ ((_a = config.imageConfig) === null || _a === void 0 ? void 0 : _a.imageType) === 'enterprise');
9530
9117
  }
9531
9118
  function resolveRequirements(config) {
9532
9119
  const requirements = [];
@@ -9625,7 +9212,7 @@ async function runImagePullAuthPreflight(service, config, autoGrant = true) {
9625
9212
 
9626
9213
  /***/ },
9627
9214
 
9628
- /***/ 52244
9215
+ /***/ 43587
9629
9216
  (__unused_webpack_module, exports, __webpack_require__) {
9630
9217
 
9631
9218
  "use strict";
@@ -9638,10 +9225,10 @@ exports.createCloudBuildService = createCloudBuildService;
9638
9225
  const fs_1 = __importDefault(__webpack_require__(29021));
9639
9226
  const os_1 = __importDefault(__webpack_require__(21820));
9640
9227
  const path_1 = __importDefault(__webpack_require__(33873));
9641
- const error_1 = __webpack_require__(18143);
9642
- const utils_1 = __webpack_require__(24263);
9643
- const http_request_1 = __webpack_require__(7355);
9644
- const types_1 = __webpack_require__(22724);
9228
+ const error_1 = __webpack_require__(54884);
9229
+ const utils_1 = __webpack_require__(88208);
9230
+ const http_request_1 = __webpack_require__(2922);
9231
+ const types_1 = __webpack_require__(79345);
9645
9232
  /**
9646
9233
  * 基于 CloudAppService 的云端构建能力适配器
9647
9234
  *
@@ -9810,7 +9397,7 @@ function createCloudBuildService(cloudApp, options = {}) {
9810
9397
 
9811
9398
  /***/ },
9812
9399
 
9813
- /***/ 69238
9400
+ /***/ 74931
9814
9401
  (__unused_webpack_module, exports, __webpack_require__) {
9815
9402
 
9816
9403
  "use strict";
@@ -9822,12 +9409,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
9822
9409
  exports.parseImageReference = parseImageReference;
9823
9410
  exports.normalizeGatewayPath = normalizeGatewayPath;
9824
9411
  exports.isCustomImageRuntime = isCustomImageRuntime;
9412
+ exports.applyMinimalDeployConfigDefaults = applyMinimalDeployConfigDefaults;
9413
+ exports.getMissingDeployInputs = getMissingDeployInputs;
9414
+ exports.prepareMinimalDeployConfig = prepareMinimalDeployConfig;
9825
9415
  exports.normalizeDeployConfig = normalizeDeployConfig;
9826
9416
  exports.checkDeployConfig = checkDeployConfig;
9827
9417
  exports.assertDeployConfig = assertDeployConfig;
9828
9418
  const lodash_1 = __importDefault(__webpack_require__(35558));
9829
- const error_1 = __webpack_require__(18143);
9830
- const types_1 = __webpack_require__(22724);
9419
+ const error_1 = __webpack_require__(54884);
9420
+ const types_1 = __webpack_require__(79345);
9831
9421
  /**
9832
9422
  * 配置契约守卫
9833
9423
  *
@@ -9979,18 +9569,151 @@ function inferHttpBuildStrategy(config) {
9979
9569
  if (config === null || config === void 0 ? void 0 : config.buildStrategy) {
9980
9570
  return config.buildStrategy;
9981
9571
  }
9982
- if (config === null || config === void 0 ? void 0 : config.imageConfig) {
9983
- return 'image';
9984
- }
9985
- if (config === null || config === void 0 ? void 0 : config.build) {
9572
+ const imageConfig = config === null || config === void 0 ? void 0 : config.imageConfig;
9573
+ if (imageConfig === null || imageConfig === void 0 ? void 0 : imageConfig.build) {
9986
9574
  // 有构建上下文但未声明策略时,默认使用无需本地 Docker 的云端构建
9987
9575
  return 'cloud';
9988
9576
  }
9577
+ if (imageConfig === null || imageConfig === void 0 ? void 0 : imageConfig.imageUri) {
9578
+ return 'image';
9579
+ }
9989
9580
  if (isCustomImageRuntime(config === null || config === void 0 ? void 0 : config.runtime)) {
9990
9581
  return 'image';
9991
9582
  }
9992
9583
  return 'zip';
9993
9584
  }
9585
+ /**
9586
+ * 应用最小化镜像配置的可安全默认值,不执行 IO,不生成凭证。
9587
+ * 仅填充构建上下文、仓库名、namespace 和运行时固定值;用户凭证必须显式传入。
9588
+ *
9589
+ * 直接在 cloudbaserc 的嵌套形状上操作:镜像字段位于 imageConfig,构建目标位于
9590
+ * imageConfig.build,不再做字段平铺映射。
9591
+ */
9592
+ function applyMinimalDeployConfigDefaults(config, context = {}) {
9593
+ var _a, _b, _c, _d, _e, _f, _g;
9594
+ const result = lodash_1.default.cloneDeep(config);
9595
+ if ((result === null || result === void 0 ? void 0 : result.type) !== 'HTTP') {
9596
+ return result;
9597
+ }
9598
+ const strategy = inferHttpBuildStrategy(result);
9599
+ if (!['image', 'local', 'cloud'].includes(strategy)) {
9600
+ return result;
9601
+ }
9602
+ result.buildStrategy = strategy;
9603
+ const imageConfig = Object.assign({}, (result.imageConfig || {}));
9604
+ result.imageConfig = imageConfig;
9605
+ if (strategy === 'image') {
9606
+ if (imageConfig.imageUri === undefined && ((_a = context.defaults) === null || _a === void 0 ? void 0 : _a.imageUri) !== undefined) {
9607
+ imageConfig.imageUri = context.defaults.imageUri;
9608
+ }
9609
+ return result;
9610
+ }
9611
+ if (result.runtime === undefined) {
9612
+ result.runtime = types_1.CUSTOM_IMAGE_RUNTIME;
9613
+ }
9614
+ if (imageConfig.imagePort === undefined) {
9615
+ imageConfig.imagePort = types_1.IMAGE_FUNCTION_PORT;
9616
+ }
9617
+ const build = Object.assign({}, (imageConfig.build || {}));
9618
+ imageConfig.build = build;
9619
+ const functionPath = context.functionPath ||
9620
+ (context.functionRootPath && result.name ? `${context.functionRootPath}/${result.name}` : undefined);
9621
+ if (build.cwd === undefined && functionPath) {
9622
+ build.cwd = functionPath;
9623
+ }
9624
+ if (build.dockerfile === undefined) {
9625
+ build.dockerfile = types_1.DEFAULT_DOCKERFILE;
9626
+ }
9627
+ if (build.platform === undefined) {
9628
+ build.platform = types_1.DEFAULT_IMAGE_PLATFORM;
9629
+ }
9630
+ const defaultRepository = (_c = (_b = context.defaults) === null || _b === void 0 ? void 0 : _b.repository) !== null && _c !== void 0 ? _c : result.name;
9631
+ const defaultNamespace = (_e = (_d = context.defaults) === null || _d === void 0 ? void 0 : _d.namespace) !== null && _e !== void 0 ? _e : context.envId;
9632
+ if (build.repository === undefined && defaultRepository !== undefined) {
9633
+ build.repository = defaultRepository;
9634
+ }
9635
+ if (build.namespace === undefined && defaultNamespace !== undefined) {
9636
+ build.namespace = defaultNamespace;
9637
+ }
9638
+ if (imageConfig.registryId === undefined && ((_f = context.defaults) === null || _f === void 0 ? void 0 : _f.registryId) !== undefined) {
9639
+ imageConfig.registryId = context.defaults.registryId;
9640
+ }
9641
+ if (build.registryCredential === undefined && ((_g = context.defaults) === null || _g === void 0 ? void 0 : _g.registryCredential) !== undefined) {
9642
+ build.registryCredential = lodash_1.default.cloneDeep(context.defaults.registryCredential);
9643
+ }
9644
+ return result;
9645
+ }
9646
+ /**
9647
+ * 返回最小化部署在当前配置下仍缺失的输入字段;不执行网络、文件或凭证操作。
9648
+ */
9649
+ function getMissingDeployInputs(config, context = {}) {
9650
+ var _a, _b, _c;
9651
+ const normalized = lodash_1.default.cloneDeep(config);
9652
+ const missing = [];
9653
+ if ((normalized === null || normalized === void 0 ? void 0 : normalized.type) !== 'HTTP') {
9654
+ return missing;
9655
+ }
9656
+ const strategy = (_a = normalized.buildStrategy) !== null && _a !== void 0 ? _a : inferHttpBuildStrategy(normalized);
9657
+ if (!['image', 'local', 'cloud'].includes(strategy)) {
9658
+ return missing;
9659
+ }
9660
+ const imageConfig = normalized.imageConfig || {};
9661
+ if (strategy === 'image') {
9662
+ if (!imageConfig.imageUri) {
9663
+ missing.push({ name: 'imageUri', path: 'imageConfig.imageUri', required: true, reason: '已有镜像部署需要固定 tag 或 digest 的 imageUri' });
9664
+ }
9665
+ return missing;
9666
+ }
9667
+ const build = imageConfig.build || {};
9668
+ const imageType = imageConfig.imageType || (imageConfig.registryId || build.registryId ? 'enterprise' : 'personal');
9669
+ if (imageType === 'enterprise') {
9670
+ if (!imageConfig.registryId && !build.registryId) {
9671
+ missing.push({ name: 'registryId', path: 'imageConfig.registryId', required: true, reason: '企业版镜像构建需要指定 TCR 实例 ID' });
9672
+ }
9673
+ if (!build.repository) {
9674
+ missing.push({ name: 'repository', path: 'imageConfig.build.repository', required: true, reason: '企业版镜像构建需要目标仓库' });
9675
+ }
9676
+ return missing;
9677
+ }
9678
+ const namespace = build.namespace || context.envId;
9679
+ if (!namespace) {
9680
+ missing.push({ name: 'namespace', path: 'imageConfig.build.namespace', required: true, reason: '个人版镜像构建需要 namespace,且无法从 envId 推导' });
9681
+ }
9682
+ if (!((_b = build.registryCredential) === null || _b === void 0 ? void 0 : _b.username)) {
9683
+ missing.push({ name: 'registryCredential.username', path: 'imageConfig.build.registryCredential.username', required: true, reason: '个人版 TCR 构建需要推送用户名' });
9684
+ }
9685
+ if (!((_c = build.registryCredential) === null || _c === void 0 ? void 0 : _c.password)) {
9686
+ missing.push({ name: 'registryCredential.password', path: 'imageConfig.build.registryCredential.password', required: true, reason: '个人版 TCR 构建需要推送密码' });
9687
+ }
9688
+ return missing;
9689
+ }
9690
+ /**
9691
+ * 生成最小化配置准备结果:先应用安全默认值,再返回剩余缺失字段和默认值路径。
9692
+ */
9693
+ function prepareMinimalDeployConfig(config, context = {}) {
9694
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
9695
+ const prepared = applyMinimalDeployConfigDefaults(config, context);
9696
+ const missing = getMissingDeployInputs(prepared, { envId: context.envId });
9697
+ const original = lodash_1.default.cloneDeep(config);
9698
+ const preparedAny = prepared;
9699
+ const appliedDefaults = [];
9700
+ const candidates = [
9701
+ ['imageConfig.imageUri', (_a = original.imageConfig) === null || _a === void 0 ? void 0 : _a.imageUri, (_b = preparedAny.imageConfig) === null || _b === void 0 ? void 0 : _b.imageUri],
9702
+ ['imageConfig.build.cwd', (_d = (_c = original.imageConfig) === null || _c === void 0 ? void 0 : _c.build) === null || _d === void 0 ? void 0 : _d.cwd, (_f = (_e = preparedAny.imageConfig) === null || _e === void 0 ? void 0 : _e.build) === null || _f === void 0 ? void 0 : _f.cwd],
9703
+ ['imageConfig.build.dockerfile', (_h = (_g = original.imageConfig) === null || _g === void 0 ? void 0 : _g.build) === null || _h === void 0 ? void 0 : _h.dockerfile, (_k = (_j = preparedAny.imageConfig) === null || _j === void 0 ? void 0 : _j.build) === null || _k === void 0 ? void 0 : _k.dockerfile],
9704
+ ['imageConfig.build.platform', (_m = (_l = original.imageConfig) === null || _l === void 0 ? void 0 : _l.build) === null || _m === void 0 ? void 0 : _m.platform, (_p = (_o = preparedAny.imageConfig) === null || _o === void 0 ? void 0 : _o.build) === null || _p === void 0 ? void 0 : _p.platform],
9705
+ ['imageConfig.build.repository', (_r = (_q = original.imageConfig) === null || _q === void 0 ? void 0 : _q.build) === null || _r === void 0 ? void 0 : _r.repository, (_t = (_s = preparedAny.imageConfig) === null || _s === void 0 ? void 0 : _s.build) === null || _t === void 0 ? void 0 : _t.repository],
9706
+ ['imageConfig.build.namespace', (_v = (_u = original.imageConfig) === null || _u === void 0 ? void 0 : _u.build) === null || _v === void 0 ? void 0 : _v.namespace, (_x = (_w = preparedAny.imageConfig) === null || _w === void 0 ? void 0 : _w.build) === null || _x === void 0 ? void 0 : _x.namespace],
9707
+ ['imageConfig.registryId', (_y = original.imageConfig) === null || _y === void 0 ? void 0 : _y.registryId, (_z = preparedAny.imageConfig) === null || _z === void 0 ? void 0 : _z.registryId],
9708
+ ['imageConfig.build.registryCredential', (_1 = (_0 = original.imageConfig) === null || _0 === void 0 ? void 0 : _0.build) === null || _1 === void 0 ? void 0 : _1.registryCredential, (_3 = (_2 = preparedAny.imageConfig) === null || _2 === void 0 ? void 0 : _2.build) === null || _3 === void 0 ? void 0 : _3.registryCredential]
9709
+ ];
9710
+ candidates.forEach(([fieldPath, before, after]) => {
9711
+ if (before === undefined && after !== undefined) {
9712
+ appliedDefaults.push(fieldPath);
9713
+ }
9714
+ });
9715
+ return { config: prepared, missing, appliedDefaults };
9716
+ }
9994
9717
  /**
9995
9718
  * 规范化部署配置
9996
9719
  *
@@ -9998,7 +9721,7 @@ function inferHttpBuildStrategy(config) {
9998
9721
  * 以便 checkDeployConfig 汇总全部问题
9999
9722
  */
10000
9723
  function normalizeDeployConfig(config) {
10001
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
9724
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
10002
9725
  if (!config || typeof config !== 'object') {
10003
9726
  throw new error_1.CloudBaseError('部署配置必须是对象', {
10004
9727
  code: types_1.FUNCTION_DEPLOY_ERROR.CONFIG_INVALID
@@ -10026,20 +9749,20 @@ function normalizeDeployConfig(config) {
10026
9749
  // node_modules 必须随代码包上传,不能被 ignore 排除
10027
9750
  ignore: ignoreList.filter((item) => !/node_modules/.test(item)) });
10028
9751
  }
10029
- const normalizedImage = Object.assign(Object.assign({}, cloned), { type: 'HTTP', buildStrategy, runtime: types_1.CUSTOM_IMAGE_RUNTIME, imagePort: (_a = cloned.imagePort) !== null && _a !== void 0 ? _a : types_1.IMAGE_FUNCTION_PORT });
10030
- normalizedImage.imageType =
10031
- (_d = (_b = cloned.imageType) !== null && _b !== void 0 ? _b : (_c = cloned.imageConfig) === null || _c === void 0 ? void 0 : _c.imageType) !== null && _d !== void 0 ? _d : (((_g = (_e = cloned.registryId) !== null && _e !== void 0 ? _e : (_f = cloned.imageConfig) === null || _f === void 0 ? void 0 : _f.registryId) !== null && _g !== void 0 ? _g : (_h = cloned.build) === null || _h === void 0 ? void 0 : _h.registryId)
10032
- ? 'enterprise'
10033
- : 'personal');
9752
+ const imageConfig = Object.assign({}, (cloned.imageConfig || {}));
9753
+ const normalizedImage = Object.assign(Object.assign({}, cloned), { type: 'HTTP', buildStrategy, runtime: types_1.CUSTOM_IMAGE_RUNTIME, imageConfig });
9754
+ imageConfig.imagePort = (_a = imageConfig.imagePort) !== null && _a !== void 0 ? _a : types_1.IMAGE_FUNCTION_PORT;
9755
+ imageConfig.imageType =
9756
+ (_b = imageConfig.imageType) !== null && _b !== void 0 ? _b : (((_c = imageConfig.registryId) !== null && _c !== void 0 ? _c : (_d = imageConfig.build) === null || _d === void 0 ? void 0 : _d.registryId) ? 'enterprise' : 'personal');
10034
9757
  // 镜像函数由容器启动命令决定入口,不使用 handler 与云端装依赖
10035
9758
  delete normalizedImage.handler;
10036
9759
  delete normalizedImage.installDependency;
10037
9760
  if (buildStrategy === 'cloud' || buildStrategy === 'local') {
10038
- normalizedImage.build = Object.assign(Object.assign({}, (cloned.build || {})), { dockerfile: (_k = (_j = cloned.build) === null || _j === void 0 ? void 0 : _j.dockerfile) !== null && _k !== void 0 ? _k : types_1.DEFAULT_DOCKERFILE, platform: (_m = (_l = cloned.build) === null || _l === void 0 ? void 0 : _l.platform) !== null && _m !== void 0 ? _m : types_1.DEFAULT_IMAGE_PLATFORM });
9761
+ imageConfig.build = Object.assign(Object.assign({}, (imageConfig.build || {})), { dockerfile: (_f = (_e = imageConfig.build) === null || _e === void 0 ? void 0 : _e.dockerfile) !== null && _f !== void 0 ? _f : types_1.DEFAULT_DOCKERFILE, platform: (_h = (_g = imageConfig.build) === null || _g === void 0 ? void 0 : _g.platform) !== null && _h !== void 0 ? _h : types_1.DEFAULT_IMAGE_PLATFORM });
10039
9762
  }
10040
9763
  if (buildStrategy === 'local') {
10041
9764
  // 默认不静默改变构建环境
10042
- normalizedImage.localFallback = (_o = cloned.localFallback) !== null && _o !== void 0 ? _o : 'error';
9765
+ imageConfig.localFallback = (_j = imageConfig.localFallback) !== null && _j !== void 0 ? _j : 'error';
10043
9766
  }
10044
9767
  return normalizedImage;
10045
9768
  }
@@ -10150,10 +9873,11 @@ function checkHttpCommon(raw, checks) {
10150
9873
  }
10151
9874
  /** 校验镜像函数公共约束 */
10152
9875
  function checkImageRuntimeCommon(raw, checks) {
9876
+ var _a;
10153
9877
  if (raw.runtime !== undefined && !isCustomImageRuntime(raw.runtime)) {
10154
9878
  checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_RUNTIME_INVALID, `镜像部署要求 runtime 为 ${types_1.CUSTOM_IMAGE_RUNTIME}`, `当前为 ${raw.runtime},请移除 runtime 或设置为 ${types_1.CUSTOM_IMAGE_RUNTIME}`));
10155
9879
  }
10156
- if (raw.imagePort !== undefined && raw.imagePort !== types_1.IMAGE_FUNCTION_PORT) {
9880
+ if (((_a = raw.imageConfig) === null || _a === void 0 ? void 0 : _a.imagePort) !== undefined && raw.imageConfig.imagePort !== types_1.IMAGE_FUNCTION_PORT) {
10157
9881
  checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_PORT_INVALID, `镜像监听端口必须为 ${types_1.IMAGE_FUNCTION_PORT}`, `请让容器监听 ${types_1.IMAGE_FUNCTION_PORT} 端口`));
10158
9882
  }
10159
9883
  if (raw.handler !== undefined) {
@@ -10185,17 +9909,17 @@ function checkImageReference(imageConfig, checks) {
10185
9909
  }
10186
9910
  /**
10187
9911
  * 校验镜像类型与仓库 ID
10188
- * image 策略从 imageConfig.registryId(兼容顶层 registryId)读取;
10189
- * local/cloud 策略从 build.registryId 读取,imageType 仍位于镜像运行时公共配置顶层。
9912
+ * 直接读取 cloudbaserc 嵌套形状:imageType 位于 imageConfig.imageType;
9913
+ * registryId 位于 imageConfig.registryId(cloud/local 兼容 imageConfig.build.registryId)。
10190
9914
  */
10191
9915
  function checkImageIdentity(raw, checks) {
10192
- var _a, _b, _c, _d, _e;
9916
+ var _a;
10193
9917
  const imageConfig = raw === null || raw === void 0 ? void 0 : raw.imageConfig;
10194
- const buildRegistryId = (_a = raw === null || raw === void 0 ? void 0 : raw.build) === null || _a === void 0 ? void 0 : _a.registryId;
9918
+ const build = imageConfig === null || imageConfig === void 0 ? void 0 : imageConfig.build;
9919
+ const buildRegistryId = build === null || build === void 0 ? void 0 : build.registryId;
10195
9920
  const buildStrategy = raw === null || raw === void 0 ? void 0 : raw.buildStrategy;
10196
- const registryId = (_c = (_b = raw === null || raw === void 0 ? void 0 : raw.registryId) !== null && _b !== void 0 ? _b : imageConfig === null || imageConfig === void 0 ? void 0 : imageConfig.registryId) !== null && _c !== void 0 ? _c : buildRegistryId;
10197
- const explicitImageType = (_d = raw === null || raw === void 0 ? void 0 : raw.imageType) !== null && _d !== void 0 ? _d : imageConfig === null || imageConfig === void 0 ? void 0 : imageConfig.imageType;
10198
- const imageType = resolveBuildImageType(raw, (_e = raw === null || raw === void 0 ? void 0 : raw.build) !== null && _e !== void 0 ? _e : {});
9921
+ const registryId = (_a = imageConfig === null || imageConfig === void 0 ? void 0 : imageConfig.registryId) !== null && _a !== void 0 ? _a : buildRegistryId;
9922
+ const imageType = resolveBuildImageType(raw, build !== null && build !== void 0 ? build : {});
10199
9923
  if (imageType !== 'enterprise' && imageType !== 'personal') {
10200
9924
  checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_TYPE_INVALID, buildStrategy === 'cloud' || buildStrategy === 'local'
10201
9925
  ? `${buildStrategy} 策略必须显式声明镜像类型`
@@ -10204,25 +9928,25 @@ function checkImageIdentity(raw, checks) {
10204
9928
  }
10205
9929
  if (imageType === 'enterprise') {
10206
9930
  if (buildStrategy === 'image' && (registryId === undefined || registryId === null)) {
10207
- checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_REGISTRY_ID_MISSING, '企业版镜像未配置仓库实例 ID', '请配置 imageConfig.registryId 或顶层 registryId'));
9931
+ checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_REGISTRY_ID_MISSING, '企业版镜像未配置仓库实例 ID', '请配置 imageConfig.registryId'));
10208
9932
  }
10209
9933
  else if (registryId !== undefined && (typeof registryId !== 'string' || !registryId.trim())) {
10210
9934
  const registryField = buildStrategy === 'cloud' || buildStrategy === 'local'
10211
- ? 'build.registryId'
10212
- : 'registryId';
9935
+ ? 'imageConfig.build.registryId'
9936
+ : 'imageConfig.registryId';
10213
9937
  checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_REGISTRY_ID_INVALID, '企业版镜像仓库实例 ID 无效', `${registryField} 已声明但解析结果为空;若使用 {{env.*}},请检查对应环境变量已赋值为实际企业版 TCR 实例 ID`));
10214
9938
  }
10215
9939
  }
10216
9940
  else if (registryId !== undefined) {
10217
- checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_TYPE_INVALID, '个人版镜像不能配置企业版仓库实例 ID', '请移除 build.registryId,或将 imageType 设置为 enterprise'));
9941
+ checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_TYPE_INVALID, '个人版镜像不能配置企业版仓库实例 ID', '请移除 imageConfig.build.registryId,或将 imageConfig.imageType 设置为 enterprise'));
10218
9942
  }
10219
9943
  }
10220
9944
  /** 解析构建策略使用的镜像类型 */
10221
9945
  function resolveBuildImageType(raw, build) {
10222
- var _a, _b, _c, _d, _e, _f;
10223
- return (_c = (_a = raw.imageType) !== null && _a !== void 0 ? _a : (_b = raw.imageConfig) === null || _b === void 0 ? void 0 : _b.imageType) !== null && _c !== void 0 ? _c : (raw.buildStrategy === 'local' || raw.buildStrategy === 'cloud'
9946
+ var _a, _b, _c, _d;
9947
+ return (_b = (_a = raw.imageConfig) === null || _a === void 0 ? void 0 : _a.imageType) !== null && _b !== void 0 ? _b : (raw.buildStrategy === 'local' || raw.buildStrategy === 'cloud'
10224
9948
  ? 'enterprise'
10225
- : ((_f = (_d = raw.registryId) !== null && _d !== void 0 ? _d : (_e = raw.imageConfig) === null || _e === void 0 ? void 0 : _e.registryId) !== null && _f !== void 0 ? _f : build.registryId)
9949
+ : ((_d = (_c = raw.imageConfig) === null || _c === void 0 ? void 0 : _c.registryId) !== null && _d !== void 0 ? _d : build.registryId)
10226
9950
  ? 'enterprise'
10227
9951
  : 'personal');
10228
9952
  }
@@ -10263,9 +9987,9 @@ function checkBuildSource(build, checks) {
10263
9987
  }
10264
9988
  /** 判断当前构建策略是否要求完整仓库地址 */
10265
9989
  function requiresFullBuildRepository(raw, imageType) {
10266
- var _a;
9990
+ var _a, _b;
10267
9991
  return raw.buildStrategy === 'local' && imageType === 'personal' &&
10268
- ((_a = raw.build) === null || _a === void 0 ? void 0 : _a.repository) !== undefined;
9992
+ ((_b = (_a = raw.imageConfig) === null || _a === void 0 ? void 0 : _a.build) === null || _b === void 0 ? void 0 : _b.repository) !== undefined;
10269
9993
  }
10270
9994
  /** 添加仓库地址缺失或不完整的错误 */
10271
9995
  function addFullRepositoryError(raw, checks, missing) {
@@ -10362,6 +10086,12 @@ function checkBuildRegistry(raw, build, checks) {
10362
10086
  const imageType = resolveBuildImageType(raw, build);
10363
10087
  const registryCredential = build.registryCredential;
10364
10088
  if (imageType === 'personal') {
10089
+ if (build.namespace !== undefined &&
10090
+ (typeof build.namespace !== 'string' ||
10091
+ !build.namespace.trim() ||
10092
+ !IMAGE_REPOSITORY_PATTERN.test(build.namespace.trim()))) {
10093
+ checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.BUILD_REPOSITORY_INVALID, '个人版 TCR 命名空间未配置或不合法', 'build.namespace 必须为合法的个人版 TCR 命名空间;未声明时可由 envId 默认补齐'));
10094
+ }
10365
10095
  checkPersonalRegistryCredential(registryCredential, checks);
10366
10096
  return;
10367
10097
  }
@@ -10371,9 +10101,10 @@ function checkBuildRegistry(raw, build, checks) {
10371
10101
  }
10372
10102
  /** 校验镜像构建目标配置 */
10373
10103
  function checkBuildTarget(raw, checks) {
10374
- const build = raw.build;
10104
+ var _a, _b;
10105
+ const build = (_a = raw.imageConfig) === null || _a === void 0 ? void 0 : _a.build;
10375
10106
  if (!lodash_1.default.isPlainObject(build)) {
10376
- checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.BUILD_CONFIG_MISSING, '缺少镜像构建配置', '请配置 build,至少包含构建上下文与 Dockerfile 信息'));
10107
+ checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.BUILD_CONFIG_MISSING, '缺少镜像构建配置', '请配置 imageConfig.build,至少包含构建上下文与 Dockerfile 信息'));
10377
10108
  return;
10378
10109
  }
10379
10110
  checks.push(...checkBuildTag(raw, build));
@@ -10381,8 +10112,8 @@ function checkBuildTarget(raw, checks) {
10381
10112
  checkBuildRepository(raw, build, checks);
10382
10113
  checkBuildArgs(raw, build, checks);
10383
10114
  checkBuildRegistry(raw, build, checks);
10384
- if (raw.imageConfig !== undefined) {
10385
- checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_CONFIG_NOT_ALLOWED, `buildStrategy 为 ${raw.buildStrategy} 时不能指定 imageConfig`, '镜像地址将由构建结果决定,如需直接部署已有镜像请使用 buildStrategy: image'));
10115
+ if (((_b = raw.imageConfig) === null || _b === void 0 ? void 0 : _b.imageUri) !== undefined) {
10116
+ checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_CONFIG_NOT_ALLOWED, `buildStrategy 为 ${raw.buildStrategy} 时不能指定 imageConfig.imageUri`, '镜像地址将由构建结果决定,如需直接部署已有镜像请使用 buildStrategy: image'));
10386
10117
  }
10387
10118
  }
10388
10119
  /**
@@ -10390,6 +10121,7 @@ function checkBuildTarget(raw, checks) {
10390
10121
  * @returns 检查报告,包含全部问题而非仅第一个
10391
10122
  */
10392
10123
  function checkDeployConfig(config) {
10124
+ var _a;
10393
10125
  const checks = [];
10394
10126
  if (!config || typeof config !== 'object') {
10395
10127
  return {
@@ -10439,16 +10171,16 @@ function checkDeployConfig(config) {
10439
10171
  }
10440
10172
  else {
10441
10173
  checkImageReference(raw.imageConfig, checks);
10442
- // imageType 在顶层,registryId 允许顶层或 imageConfig,统一传 raw
10174
+ // imageType 与 registryId 位于 imageConfig,统一传 raw 由 checkImageIdentity 读取
10443
10175
  checkImageIdentity(raw, checks);
10444
- // 注:imagePort 定义在顶层,已由 checkImageRuntimeCommon 校验,此处不重复
10176
+ // 注:imagePort 位于 imageConfig,已由 checkImageRuntimeCommon 校验,此处不重复
10445
10177
  }
10446
10178
  }
10447
10179
  else {
10448
10180
  checkImageIdentity(raw, checks);
10449
10181
  checkBuildTarget(raw, checks);
10450
10182
  if (strategy === 'local') {
10451
- const fallback = raw.localFallback;
10183
+ const fallback = (_a = raw.imageConfig) === null || _a === void 0 ? void 0 : _a.localFallback;
10452
10184
  if (fallback !== undefined && fallback !== 'cloud' && fallback !== 'error') {
10453
10185
  checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.LOCAL_FALLBACK_INVALID, 'localFallback 取值不合法', "只能是 'cloud' 或 'error'"));
10454
10186
  }
@@ -10491,7 +10223,7 @@ function assertDeployConfig(config) {
10491
10223
 
10492
10224
  /***/ },
10493
10225
 
10494
- /***/ 30710
10226
+ /***/ 48947
10495
10227
  (__unused_webpack_module, exports, __webpack_require__) {
10496
10228
 
10497
10229
  "use strict";
@@ -10499,7 +10231,7 @@ function assertDeployConfig(config) {
10499
10231
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10500
10232
  exports.runDockerPreflight = runDockerPreflight;
10501
10233
  const child_process_1 = __webpack_require__(79646);
10502
- const types_1 = __webpack_require__(22724);
10234
+ const types_1 = __webpack_require__(79345);
10503
10235
  /**
10504
10236
  * Docker 本地能力 Preflight(local 策略,scope: local)
10505
10237
  *
@@ -10586,7 +10318,7 @@ async function runDockerPreflight(runner = defaultRunner) {
10586
10318
 
10587
10319
  /***/ },
10588
10320
 
10589
- /***/ 26719
10321
+ /***/ 84638
10590
10322
  (__unused_webpack_module, exports, __webpack_require__) {
10591
10323
 
10592
10324
  "use strict";
@@ -10595,9 +10327,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
10595
10327
  exports.prepareEnterpriseTcrTarget = prepareEnterpriseTcrTarget;
10596
10328
  exports.createEnterpriseTcrCredential = createEnterpriseTcrCredential;
10597
10329
  exports.createTcrApiService = createTcrApiService;
10598
- const error_1 = __webpack_require__(18143);
10599
- const types_1 = __webpack_require__(22724);
10600
- const config_guard_1 = __webpack_require__(69238);
10330
+ const error_1 = __webpack_require__(54884);
10331
+ const types_1 = __webpack_require__(79345);
10332
+ const config_guard_1 = __webpack_require__(74931);
10601
10333
  const TCR_API_VERSION = '2019-09-24';
10602
10334
  const NAMESPACE_PATTERN = /^[a-z0-9](?:[a-z0-9]|[._-](?![._-])){0,28}[a-z0-9]$/;
10603
10335
  function responseOf(result) {
@@ -10734,22 +10466,23 @@ async function ensureNamespace(service, registryId, namespace) {
10734
10466
  }
10735
10467
  async function prepareEnterpriseTcrTarget(config, options) {
10736
10468
  var _a;
10737
- const configuredRegistryId = (_a = config.registryId) !== null && _a !== void 0 ? _a : config.build.registryId;
10469
+ const build = config.imageConfig.build;
10470
+ const configuredRegistryId = (_a = config.imageConfig.registryId) !== null && _a !== void 0 ? _a : build.registryId;
10738
10471
  const explicitRegistryId = typeof configuredRegistryId === 'string' && configuredRegistryId.trim()
10739
10472
  ? configuredRegistryId.trim()
10740
10473
  : undefined;
10741
10474
  const resolvedRegistry = await resolveRegistry(options.service, options.region, explicitRegistryId);
10742
- const repositoryTarget = parseRepositoryTarget(config.build.repository || config.name);
10743
- const namespace = (config.build.namespace || repositoryTarget.namespace || options.envId).trim();
10475
+ const repositoryTarget = parseRepositoryTarget(build.repository || config.name);
10476
+ const namespace = (build.namespace || repositoryTarget.namespace || options.envId).trim();
10744
10477
  assertNamespace(namespace);
10745
- if (config.build.namespace && repositoryTarget.namespace && config.build.namespace !== repositoryTarget.namespace) {
10746
- throwTcrError('build.namespace 与 build.repository 中的命名空间不一致。', types_1.FUNCTION_DEPLOY_ERROR.BUILD_REPOSITORY_INVALID);
10478
+ if (build.namespace && repositoryTarget.namespace && build.namespace !== repositoryTarget.namespace) {
10479
+ throwTcrError('imageConfig.build.namespace 与 imageConfig.build.repository 中的命名空间不一致。', types_1.FUNCTION_DEPLOY_ERROR.BUILD_REPOSITORY_INVALID);
10747
10480
  }
10748
10481
  await ensureNamespace(options.service, resolvedRegistry.registryId, namespace);
10749
10482
  const registry = repositoryTarget.registry || resolvedRegistry.registry;
10750
10483
  const repository = repositoryTarget.repository || config.name;
10751
10484
  const imageRepository = `${registry}/${namespace}/${repository}`;
10752
- const preparedConfig = Object.assign(Object.assign({}, config), { imageType: 'enterprise', registryId: resolvedRegistry.registryId, build: Object.assign(Object.assign({}, config.build), { registryId: resolvedRegistry.registryId, namespace, repository: imageRepository }) });
10485
+ const preparedConfig = Object.assign(Object.assign({}, config), { imageConfig: Object.assign(Object.assign({}, config.imageConfig), { imageType: 'enterprise', registryId: resolvedRegistry.registryId, build: Object.assign(Object.assign({}, build), { registryId: resolvedRegistry.registryId, namespace, repository: imageRepository }) }) });
10753
10486
  return {
10754
10487
  config: preparedConfig,
10755
10488
  target: {
@@ -10788,7 +10521,7 @@ function createTcrApiService(environment) {
10788
10521
 
10789
10522
  /***/ },
10790
10523
 
10791
- /***/ 56749
10524
+ /***/ 67650
10792
10525
  (__unused_webpack_module, exports, __webpack_require__) {
10793
10526
 
10794
10527
  "use strict";
@@ -10796,8 +10529,8 @@ function createTcrApiService(environment) {
10796
10529
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10797
10530
  exports.runImageRemotePreflight = runImageRemotePreflight;
10798
10531
  const child_process_1 = __webpack_require__(79646);
10799
- const config_guard_1 = __webpack_require__(69238);
10800
- const types_1 = __webpack_require__(22724);
10532
+ const config_guard_1 = __webpack_require__(74931);
10533
+ const types_1 = __webpack_require__(79345);
10801
10534
  /**
10802
10535
  * 镜像远端校验 Preflight(有 IO,scope: cloud)
10803
10536
  *
@@ -10960,7 +10693,7 @@ async function runImageRemotePreflight(config, deployRegion, deps = defaultDeps)
10960
10693
 
10961
10694
  /***/ },
10962
10695
 
10963
- /***/ 32378
10696
+ /***/ 94285
10964
10697
  (__unused_webpack_module, exports, __webpack_require__) {
10965
10698
 
10966
10699
  "use strict";
@@ -10999,7 +10732,7 @@ async function resolveImageTag(options) {
10999
10732
 
11000
10733
  /***/ },
11001
10734
 
11002
- /***/ 49515
10735
+ /***/ 52948
11003
10736
  (__unused_webpack_module, exports, __webpack_require__) {
11004
10737
 
11005
10738
  "use strict";
@@ -11017,9 +10750,9 @@ const child_process_1 = __webpack_require__(79646);
11017
10750
  const fs_1 = __importDefault(__webpack_require__(29021));
11018
10751
  const os_1 = __importDefault(__webpack_require__(21820));
11019
10752
  const path_1 = __importDefault(__webpack_require__(33873));
11020
- const error_1 = __webpack_require__(18143);
11021
- const types_1 = __webpack_require__(22724);
11022
- const image_tag_1 = __webpack_require__(32378);
10753
+ const error_1 = __webpack_require__(54884);
10754
+ const types_1 = __webpack_require__(79345);
10755
+ const image_tag_1 = __webpack_require__(94285);
11023
10756
  /**
11024
10757
  * 本地镜像构建与推送(local 策略,个人版先行版)
11025
10758
  *
@@ -11066,18 +10799,19 @@ const defaultDeps = {
11066
10799
  };
11067
10800
  /** 解析构建上下文目录(绝对路径) */
11068
10801
  function resolveContext(config) {
11069
- const cwd = config.build.cwd || config.functionPath || process.cwd();
10802
+ const cwd = config.imageConfig.build.cwd || config.functionPath || process.cwd();
11070
10803
  return path_1.default.resolve(cwd);
11071
10804
  }
11072
10805
  /** 解析目标镜像完整引用 imageUri(repository 需为含域名与命名空间的完整仓库地址,个人版/企业版通用) */
11073
10806
  async function resolveImageUri(config, context) {
11074
- const repository = config.build.repository;
10807
+ const build = config.imageConfig.build;
10808
+ const repository = build.repository;
11075
10809
  if (typeof repository !== 'string' || !repository.trim()) {
11076
- throw new error_1.CloudBaseError('local 策略缺少目标镜像仓库地址 build.repository', {
10810
+ throw new error_1.CloudBaseError('local 策略缺少目标镜像仓库地址 imageConfig.build.repository', {
11077
10811
  code: types_1.FUNCTION_DEPLOY_ERROR.LOCAL_BUILD_REPOSITORY_MISSING
11078
10812
  });
11079
10813
  }
11080
- const tag = await (0, image_tag_1.resolveImageTag)({ explicitTag: config.build.tag, cwd: context });
10814
+ const tag = await (0, image_tag_1.resolveImageTag)({ explicitTag: build.tag, cwd: context });
11081
10815
  return `${repository.trim()}:${tag}`;
11082
10816
  }
11083
10817
  /** 从 buildx imagetools inspect 输出解析 digest */
@@ -11111,7 +10845,7 @@ async function buildLocalImage(config, onLog, options = {}) {
11111
10845
  code: types_1.FUNCTION_DEPLOY_ERROR.LOCAL_BUILD_CONTEXT_MISSING
11112
10846
  });
11113
10847
  }
11114
- const dockerfile = config.build.dockerfile || types_1.DEFAULT_DOCKERFILE;
10848
+ const dockerfile = config.imageConfig.build.dockerfile || types_1.DEFAULT_DOCKERFILE;
11115
10849
  const dockerfilePath = path_1.default.resolve(context, dockerfile);
11116
10850
  if (!deps.existsSync(dockerfilePath) || !deps.isFile(dockerfilePath)) {
11117
10851
  throw new error_1.CloudBaseError(`Dockerfile 不存在:${dockerfilePath}`, {
@@ -11119,7 +10853,7 @@ async function buildLocalImage(config, onLog, options = {}) {
11119
10853
  });
11120
10854
  }
11121
10855
  const imageUri = await resolveImageUri(config, context);
11122
- const platform = config.build.platform || types_1.DEFAULT_IMAGE_PLATFORM;
10856
+ const platform = config.imageConfig.build.platform || types_1.DEFAULT_IMAGE_PLATFORM;
11123
10857
  const args = [
11124
10858
  'buildx',
11125
10859
  'build',
@@ -11131,10 +10865,10 @@ async function buildLocalImage(config, onLog, options = {}) {
11131
10865
  imageUri,
11132
10866
  '--load'
11133
10867
  ];
11134
- if (config.build.forceBuild) {
10868
+ if (config.imageConfig.build.forceBuild) {
11135
10869
  args.push('--no-cache');
11136
10870
  }
11137
- const buildArgs = config.build.buildArgs || {};
10871
+ const buildArgs = config.imageConfig.build.buildArgs || {};
11138
10872
  for (const key of Object.keys(buildArgs)) {
11139
10873
  args.push('--build-arg', `${key}=${buildArgs[key]}`);
11140
10874
  }
@@ -11249,7 +10983,7 @@ function createTemporaryDockerConfig() {
11249
10983
  */
11250
10984
  async function buildAndPushImage(config, onLog, deps = defaultDeps) {
11251
10985
  const startedAt = Date.now();
11252
- const credential = config.build.registryCredential;
10986
+ const credential = config.imageConfig.build.registryCredential;
11253
10987
  const dockerConfig = credential ? createTemporaryDockerConfig() : undefined;
11254
10988
  const commandOptions = dockerConfig ? { env: dockerConfig.env } : undefined;
11255
10989
  try {
@@ -11281,7 +11015,7 @@ async function buildAndPushImage(config, onLog, deps = defaultDeps) {
11281
11015
 
11282
11016
  /***/ },
11283
11017
 
11284
- /***/ 5380
11018
+ /***/ 28541
11285
11019
  (__unused_webpack_module, exports, __webpack_require__) {
11286
11020
 
11287
11021
  "use strict";
@@ -11289,7 +11023,7 @@ async function buildAndPushImage(config, onLog, deps = defaultDeps) {
11289
11023
  Object.defineProperty(exports, "__esModule", ({ value: true }));
11290
11024
  exports.PersonalTcrService = exports.DEFAULT_PERSONAL_TCR_REGISTRY = void 0;
11291
11025
  exports.createPersonalTcrService = createPersonalTcrService;
11292
- const config_guard_1 = __webpack_require__(69238);
11026
+ const config_guard_1 = __webpack_require__(74931);
11293
11027
  const PERSONAL_TCR_VERSION = '2019-09-24';
11294
11028
  exports.DEFAULT_PERSONAL_TCR_REGISTRY = 'ccr.ccs.tencentyun.com';
11295
11029
  const DEFAULT_RETAINED_TAGS = 30;
@@ -11442,7 +11176,7 @@ function createPersonalTcrService(environment) {
11442
11176
 
11443
11177
  /***/ },
11444
11178
 
11445
- /***/ 28750
11179
+ /***/ 72325
11446
11180
  (__unused_webpack_module, exports, __webpack_require__) {
11447
11181
 
11448
11182
  "use strict";
@@ -11450,8 +11184,8 @@ function createPersonalTcrService(environment) {
11450
11184
  Object.defineProperty(exports, "__esModule", ({ value: true }));
11451
11185
  exports.toCurrentState = toCurrentState;
11452
11186
  exports.createDeployPlan = createDeployPlan;
11453
- const constant_1 = __webpack_require__(3017);
11454
- const config_guard_1 = __webpack_require__(69238);
11187
+ const constant_1 = __webpack_require__(41976);
11188
+ const config_guard_1 = __webpack_require__(74931);
11455
11189
  /**
11456
11190
  * 部署计划生成
11457
11191
  *
@@ -11728,7 +11462,7 @@ function createDeployPlan(config, current) {
11728
11462
 
11729
11463
  /***/ },
11730
11464
 
11731
- /***/ 61081
11465
+ /***/ 69230
11732
11466
  (__unused_webpack_module, exports, __webpack_require__) {
11733
11467
 
11734
11468
  "use strict";
@@ -11740,8 +11474,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
11740
11474
  exports.runLocalPreflight = runLocalPreflight;
11741
11475
  const fs_1 = __importDefault(__webpack_require__(29021));
11742
11476
  const path_1 = __importDefault(__webpack_require__(33873));
11743
- const packer_1 = __webpack_require__(62446);
11744
- const types_1 = __webpack_require__(22724);
11477
+ const packer_1 = __webpack_require__(36245);
11478
+ const types_1 = __webpack_require__(79345);
11745
11479
  /**
11746
11480
  * 部署前环境检查(Preflight)
11747
11481
  *
@@ -11805,7 +11539,8 @@ function safeStat(target) {
11805
11539
  }
11806
11540
  /** 检查 cloud 构建上下文与 Dockerfile,确保任何云端操作前即可失败 */
11807
11541
  function checkCloudBuildSource(config, checks) {
11808
- const cwd = path_1.default.resolve(config.build.cwd || config.functionPath || process.cwd());
11542
+ const build = config.imageConfig.build;
11543
+ const cwd = path_1.default.resolve(build.cwd || config.functionPath || process.cwd());
11809
11544
  const contextStat = safeStat(cwd);
11810
11545
  if (contextStat === null) {
11811
11546
  checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.BUILD_CONTEXT_INVALID, '云端镜像构建上下文目录不存在', {
@@ -11821,7 +11556,7 @@ function checkCloudBuildSource(config, checks) {
11821
11556
  }));
11822
11557
  return;
11823
11558
  }
11824
- const dockerfile = config.build.dockerfile || types_1.DEFAULT_DOCKERFILE;
11559
+ const dockerfile = build.dockerfile || types_1.DEFAULT_DOCKERFILE;
11825
11560
  const dockerfilePath = path_1.default.resolve(cwd, dockerfile);
11826
11561
  const dockerfileStat = safeStat(dockerfilePath);
11827
11562
  if (dockerfileStat === null || !dockerfileStat.isFile()) {
@@ -12065,7 +11800,7 @@ function runLocalPreflight(config) {
12065
11800
 
12066
11801
  /***/ },
12067
11802
 
12068
- /***/ 22724
11803
+ /***/ 79345
12069
11804
  (__unused_webpack_module, exports) {
12070
11805
 
12071
11806
  "use strict";
@@ -12191,14 +11926,14 @@ exports.FUNCTION_DEPLOY_ERROR = {
12191
11926
 
12192
11927
  /***/ },
12193
11928
 
12194
- /***/ 13265
11929
+ /***/ 54640
12195
11930
  (__unused_webpack_module, exports, __webpack_require__) {
12196
11931
 
12197
11932
  "use strict";
12198
11933
 
12199
11934
  Object.defineProperty(exports, "__esModule", ({ value: true }));
12200
11935
  exports.DocsService = void 0;
12201
- const http_request_1 = __webpack_require__(7355);
11936
+ const http_request_1 = __webpack_require__(2922);
12202
11937
  const DOCS_BASE_URL = 'https://docs.cloudbase.net';
12203
11938
  const CATEGORY_URL = `${DOCS_BASE_URL}/category.json`;
12204
11939
  const ALGOLIA_SEARCH_URL = 'https://70wjvl90pg-dsn.algolia.net/1/indexes/*/queries' +
@@ -12487,7 +12222,7 @@ exports.DocsService = DocsService;
12487
12222
 
12488
12223
  /***/ },
12489
12224
 
12490
- /***/ 51865
12225
+ /***/ 20382
12491
12226
  (__unused_webpack_module, exports, __webpack_require__) {
12492
12227
 
12493
12228
  "use strict";
@@ -12505,12 +12240,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
12505
12240
  exports.EnvService = void 0;
12506
12241
  const cos_nodejs_sdk_v5_1 = __importDefault(__webpack_require__(531));
12507
12242
  const util_1 = __importDefault(__webpack_require__(28354));
12508
- const http_request_1 = __webpack_require__(7355);
12243
+ const http_request_1 = __webpack_require__(2922);
12509
12244
  const signature_nodejs_1 = __webpack_require__(38567);
12510
- const error_1 = __webpack_require__(18143);
12511
- const utils_1 = __webpack_require__(24263);
12512
- const constant_1 = __webpack_require__(3017);
12513
- const billing_1 = __webpack_require__(54913);
12245
+ const error_1 = __webpack_require__(54884);
12246
+ const utils_1 = __webpack_require__(88208);
12247
+ const constant_1 = __webpack_require__(41976);
12248
+ const billing_1 = __webpack_require__(44210);
12514
12249
  const uuid_1 = __webpack_require__(79893);
12515
12250
  class EnvService {
12516
12251
  constructor(environment) {
@@ -13473,37 +13208,37 @@ __decorate([
13473
13208
 
13474
13209
  /***/ },
13475
13210
 
13476
- /***/ 27296
13211
+ /***/ 53463
13477
13212
  (__unused_webpack_module, exports, __webpack_require__) {
13478
13213
 
13479
13214
  "use strict";
13480
13215
 
13481
13216
  Object.defineProperty(exports, "__esModule", ({ value: true }));
13482
13217
  exports.Environment = void 0;
13483
- const database_1 = __webpack_require__(71863);
13484
- const function_1 = __webpack_require__(56318);
13485
- const FunctionDeployer_1 = __webpack_require__(21773);
13486
- const cloudrun_1 = __webpack_require__(8044);
13487
- const agent_1 = __webpack_require__(33215);
13488
- const storage_1 = __webpack_require__(29903);
13489
- const env_1 = __webpack_require__(51865);
13490
- const common_1 = __webpack_require__(10443);
13491
- const log_1 = __webpack_require__(18916);
13492
- const error_1 = __webpack_require__(18143);
13493
- const constant_1 = __webpack_require__(3017);
13494
- const utils_1 = __webpack_require__(24263);
13495
- const hosting_1 = __webpack_require__(6064);
13496
- const third_1 = __webpack_require__(1155);
13497
- const access_1 = __webpack_require__(38680);
13498
- const user_1 = __webpack_require__(68569);
13499
- const cloudBaseRun_1 = __webpack_require__(27851);
13500
- const mysql_1 = __webpack_require__(22772);
13501
- const cloudApp_1 = __webpack_require__(97538);
13502
- const permission_1 = __webpack_require__(81881);
13503
- const sandbox_1 = __webpack_require__(64593);
13504
- const aiModel_1 = __webpack_require__(9537);
13505
- const monitor_1 = __webpack_require__(56088);
13506
- const integration_1 = __webpack_require__(5480);
13218
+ const database_1 = __webpack_require__(44206);
13219
+ const function_1 = __webpack_require__(99699);
13220
+ const FunctionDeployer_1 = __webpack_require__(93210);
13221
+ const cloudrun_1 = __webpack_require__(17569);
13222
+ const agent_1 = __webpack_require__(94540);
13223
+ const storage_1 = __webpack_require__(61132);
13224
+ const env_1 = __webpack_require__(20382);
13225
+ const common_1 = __webpack_require__(73906);
13226
+ const log_1 = __webpack_require__(73795);
13227
+ const error_1 = __webpack_require__(54884);
13228
+ const constant_1 = __webpack_require__(41976);
13229
+ const utils_1 = __webpack_require__(88208);
13230
+ const hosting_1 = __webpack_require__(11763);
13231
+ const third_1 = __webpack_require__(23800);
13232
+ const access_1 = __webpack_require__(58405);
13233
+ const user_1 = __webpack_require__(41180);
13234
+ const cloudBaseRun_1 = __webpack_require__(56242);
13235
+ const mysql_1 = __webpack_require__(47779);
13236
+ const cloudApp_1 = __webpack_require__(42403);
13237
+ const permission_1 = __webpack_require__(59512);
13238
+ const sandbox_1 = __webpack_require__(53854);
13239
+ const aiModel_1 = __webpack_require__(1058);
13240
+ const monitor_1 = __webpack_require__(3219);
13241
+ const integration_1 = __webpack_require__(80547);
13507
13242
  class Environment {
13508
13243
  constructor(context, envId) {
13509
13244
  this.inited = false;
@@ -13667,15 +13402,15 @@ exports.Environment = Environment;
13667
13402
 
13668
13403
  /***/ },
13669
13404
 
13670
- /***/ 70101
13405
+ /***/ 41596
13671
13406
  (__unused_webpack_module, exports, __webpack_require__) {
13672
13407
 
13673
13408
  "use strict";
13674
13409
 
13675
13410
  Object.defineProperty(exports, "__esModule", ({ value: true }));
13676
13411
  exports.EnvironmentManager = void 0;
13677
- const environment_1 = __webpack_require__(27296);
13678
- const constant_1 = __webpack_require__(3017);
13412
+ const environment_1 = __webpack_require__(53463);
13413
+ const constant_1 = __webpack_require__(41976);
13679
13414
  class EnvironmentManager {
13680
13415
  constructor(context) {
13681
13416
  this.envs = {};
@@ -13719,7 +13454,7 @@ exports.EnvironmentManager = EnvironmentManager;
13719
13454
 
13720
13455
  /***/ },
13721
13456
 
13722
- /***/ 18143
13457
+ /***/ 54884
13723
13458
  (__unused_webpack_module, exports) {
13724
13459
 
13725
13460
  "use strict";
@@ -13743,7 +13478,7 @@ exports.CloudBaseError = CloudBaseError;
13743
13478
 
13744
13479
  /***/ },
13745
13480
 
13746
- /***/ 56318
13481
+ /***/ 99699
13747
13482
  (__unused_webpack_module, exports, __webpack_require__) {
13748
13483
 
13749
13484
  "use strict";
@@ -13763,10 +13498,10 @@ const fs_1 = __importDefault(__webpack_require__(29021));
13763
13498
  const path_1 = __importDefault(__webpack_require__(33873));
13764
13499
  const lodash_1 = __importDefault(__webpack_require__(35558));
13765
13500
  const cos_nodejs_sdk_v5_1 = __importDefault(__webpack_require__(531));
13766
- const packer_1 = __webpack_require__(62446);
13767
- const error_1 = __webpack_require__(18143);
13768
- const utils_1 = __webpack_require__(24263);
13769
- const constant_1 = __webpack_require__(3017);
13501
+ const packer_1 = __webpack_require__(36245);
13502
+ const error_1 = __webpack_require__(54884);
13503
+ const utils_1 = __webpack_require__(88208);
13504
+ const constant_1 = __webpack_require__(41976);
13770
13505
  /**
13771
13506
  * 解析环境变量为布尔值
13772
13507
  * 视 'true'/'1'/'yes'/'on'(大小写不敏感)为 true,
@@ -15708,7 +15443,7 @@ __decorate([
15708
15443
 
15709
15444
  /***/ },
15710
15445
 
15711
- /***/ 62446
15446
+ /***/ 36245
15712
15447
  (__unused_webpack_module, exports, __webpack_require__) {
15713
15448
 
15714
15449
  "use strict";
@@ -15756,8 +15491,8 @@ const del_1 = __importDefault(__webpack_require__(56931));
15756
15491
  const path_1 = __importDefault(__webpack_require__(33873));
15757
15492
  const make_dir_1 = __importDefault(__webpack_require__(82823));
15758
15493
  const util_1 = __importDefault(__webpack_require__(28354));
15759
- const utils_1 = __webpack_require__(24263);
15760
- const error_1 = __webpack_require__(18143);
15494
+ const utils_1 = __webpack_require__(88208);
15495
+ const error_1 = __webpack_require__(54884);
15761
15496
  const os = __importStar(__webpack_require__(21820));
15762
15497
  // 10 MB
15763
15498
  exports.BIG_FILE_SIZE = 10485760;
@@ -15880,7 +15615,7 @@ exports.FunctionPacker = FunctionPacker;
15880
15615
 
15881
15616
  /***/ },
15882
15617
 
15883
- /***/ 6064
15618
+ /***/ 11763
15884
15619
  (__unused_webpack_module, exports, __webpack_require__) {
15885
15620
 
15886
15621
  "use strict";
@@ -15899,9 +15634,9 @@ exports.HostingService = void 0;
15899
15634
  const fs_1 = __importDefault(__webpack_require__(29021));
15900
15635
  const path_1 = __importDefault(__webpack_require__(33873));
15901
15636
  const make_dir_1 = __importDefault(__webpack_require__(82823));
15902
- const error_1 = __webpack_require__(18143);
15903
- const utils_1 = __webpack_require__(24263);
15904
- const parallel_1 = __webpack_require__(31504);
15637
+ const error_1 = __webpack_require__(54884);
15638
+ const utils_1 = __webpack_require__(88208);
15639
+ const parallel_1 = __webpack_require__(86693);
15905
15640
  const envDomainCache = new Map();
15906
15641
  const HostingStatusMap = {
15907
15642
  init: '初始化中',
@@ -16400,16 +16135,16 @@ __decorate([
16400
16135
 
16401
16136
  /***/ },
16402
16137
 
16403
- /***/ 20277
16138
+ /***/ 87798
16404
16139
  (module, __unused_webpack_exports, __webpack_require__) {
16405
16140
 
16406
16141
  "use strict";
16407
16142
 
16408
- const context_1 = __webpack_require__(91522);
16409
- const environmentManager_1 = __webpack_require__(70101);
16410
- const docs_1 = __webpack_require__(13265);
16411
- const projectValidator_1 = __webpack_require__(64047);
16412
- const DeployOrchestrator_1 = __webpack_require__(83962);
16143
+ const context_1 = __webpack_require__(81073);
16144
+ const environmentManager_1 = __webpack_require__(41596);
16145
+ const docs_1 = __webpack_require__(54640);
16146
+ const projectValidator_1 = __webpack_require__(69622);
16147
+ const DeployOrchestrator_1 = __webpack_require__(28385);
16413
16148
  class CloudBase {
16414
16149
  /**
16415
16150
  * init 初始化 为单例
@@ -16599,7 +16334,7 @@ module.exports = CloudBase;
16599
16334
 
16600
16335
  /***/ },
16601
16336
 
16602
- /***/ 36541
16337
+ /***/ 5798
16603
16338
  (__unused_webpack_module, exports) {
16604
16339
 
16605
16340
  "use strict";
@@ -16615,7 +16350,7 @@ exports.USER_KEY_BUSINESS = 'integration';
16615
16350
 
16616
16351
  /***/ },
16617
16352
 
16618
- /***/ 86823
16353
+ /***/ 90346
16619
16354
  (__unused_webpack_module, exports, __webpack_require__) {
16620
16355
 
16621
16356
  "use strict";
@@ -16725,7 +16460,7 @@ exports.AESCrypto = new AESCryptoImpl();
16725
16460
 
16726
16461
  /***/ },
16727
16462
 
16728
- /***/ 5480
16463
+ /***/ 80547
16729
16464
  (__unused_webpack_module, exports, __webpack_require__) {
16730
16465
 
16731
16466
  "use strict";
@@ -16752,12 +16487,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16752
16487
  };
16753
16488
  Object.defineProperty(exports, "__esModule", ({ value: true }));
16754
16489
  exports.IntegrationService = void 0;
16755
- const error_1 = __webpack_require__(18143);
16756
- const utils_1 = __webpack_require__(24263);
16757
- const constants_1 = __webpack_require__(36541);
16758
- const crypto_1 = __webpack_require__(86823);
16759
- const secretKey_1 = __webpack_require__(32503);
16760
- __exportStar(__webpack_require__(89869), exports);
16490
+ const error_1 = __webpack_require__(54884);
16491
+ const utils_1 = __webpack_require__(88208);
16492
+ const constants_1 = __webpack_require__(5798);
16493
+ const crypto_1 = __webpack_require__(90346);
16494
+ const secretKey_1 = __webpack_require__(98584);
16495
+ __exportStar(__webpack_require__(53890), exports);
16761
16496
  /**
16762
16497
  * 集成中心(UserKey)服务
16763
16498
  *
@@ -17086,7 +16821,7 @@ __decorate([
17086
16821
 
17087
16822
  /***/ },
17088
16823
 
17089
- /***/ 32503
16824
+ /***/ 98584
17090
16825
  (__unused_webpack_module, exports, __webpack_require__) {
17091
16826
 
17092
16827
  "use strict";
@@ -17104,8 +16839,8 @@ exports.__clearAesKeyCache = __clearAesKeyCache;
17104
16839
  * - key 仅在进程内存使用,按 group 维度缓存;
17105
16840
  * - 绝不写入任何本地文件、绝不打印日志。
17106
16841
  */
17107
- const http_request_1 = __webpack_require__(7355);
17108
- const error_1 = __webpack_require__(18143);
16842
+ const http_request_1 = __webpack_require__(2922);
16843
+ const error_1 = __webpack_require__(54884);
17109
16844
  /** 七彩石配置 */
17110
16845
  const RAINBOW_CONFIG = {
17111
16846
  ENV_TYPE: 'Default',
@@ -17182,7 +16917,7 @@ function __clearAesKeyCache() {
17182
16917
 
17183
16918
  /***/ },
17184
16919
 
17185
- /***/ 89869
16920
+ /***/ 53890
17186
16921
  (__unused_webpack_module, exports) {
17187
16922
 
17188
16923
  "use strict";
@@ -17208,7 +16943,7 @@ var UserKeyBindServiceType;
17208
16943
 
17209
16944
  /***/ },
17210
16945
 
17211
- /***/ 18916
16946
+ /***/ 73795
17212
16947
  (__unused_webpack_module, exports, __webpack_require__) {
17213
16948
 
17214
16949
  "use strict";
@@ -17230,8 +16965,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17230
16965
  Object.defineProperty(exports, "__esModule", ({ value: true }));
17231
16966
  exports.LogService = void 0;
17232
16967
  exports.isLogServiceEnabled = isLogServiceEnabled;
17233
- const utils_1 = __webpack_require__(24263);
17234
- __exportStar(__webpack_require__(54081), exports);
16968
+ const utils_1 = __webpack_require__(88208);
16969
+ __exportStar(__webpack_require__(8290), exports);
17235
16970
  /**
17236
16971
  * 纯函数:根据 DescribeEnvInfo 返回的 LogServices 列表判断日志服务是否已开通。
17237
16972
  * 已开通条件:至少一个条目有有效的 TopicId。
@@ -17317,7 +17052,7 @@ exports.LogService = LogService;
17317
17052
 
17318
17053
  /***/ },
17319
17054
 
17320
- /***/ 54081
17055
+ /***/ 8290
17321
17056
  (__unused_webpack_module, exports) {
17322
17057
 
17323
17058
  "use strict";
@@ -17349,7 +17084,7 @@ exports.CLS_MODULE_SCHEMA = {
17349
17084
 
17350
17085
  /***/ },
17351
17086
 
17352
- /***/ 56088
17087
+ /***/ 3219
17353
17088
  (__unused_webpack_module, exports, __webpack_require__) {
17354
17089
 
17355
17090
  "use strict";
@@ -17370,9 +17105,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17370
17105
  };
17371
17106
  Object.defineProperty(exports, "__esModule", ({ value: true }));
17372
17107
  exports.MonitorService = void 0;
17373
- const error_1 = __webpack_require__(18143);
17374
- const utils_1 = __webpack_require__(24263);
17375
- __exportStar(__webpack_require__(35197), exports);
17108
+ const error_1 = __webpack_require__(54884);
17109
+ const utils_1 = __webpack_require__(88208);
17110
+ __exportStar(__webpack_require__(2290), exports);
17376
17111
  // Period 与时间范围的约束规则
17377
17112
  const ONE_DAY_MS = 24 * 60 * 60 * 1000;
17378
17113
  const THREE_DAYS_MS = 3 * ONE_DAY_MS;
@@ -17462,7 +17197,7 @@ exports.MonitorService = MonitorService;
17462
17197
 
17463
17198
  /***/ },
17464
17199
 
17465
- /***/ 35197
17200
+ /***/ 2290
17466
17201
  (__unused_webpack_module, exports) {
17467
17202
 
17468
17203
  "use strict";
@@ -17472,7 +17207,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
17472
17207
 
17473
17208
  /***/ },
17474
17209
 
17475
- /***/ 22772
17210
+ /***/ 47779
17476
17211
  (__unused_webpack_module, exports, __webpack_require__) {
17477
17212
 
17478
17213
  "use strict";
@@ -17499,8 +17234,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17499
17234
  };
17500
17235
  Object.defineProperty(exports, "__esModule", ({ value: true }));
17501
17236
  exports.MysqlService = void 0;
17502
- const utils_1 = __webpack_require__(24263);
17503
- __exportStar(__webpack_require__(39434), exports);
17237
+ const utils_1 = __webpack_require__(88208);
17238
+ __exportStar(__webpack_require__(54113), exports);
17504
17239
  class MysqlService {
17505
17240
  constructor(environment) {
17506
17241
  this.environment = environment;
@@ -18031,7 +17766,7 @@ __decorate([
18031
17766
 
18032
17767
  /***/ },
18033
17768
 
18034
- /***/ 28065
17769
+ /***/ 79702
18035
17770
  (__unused_webpack_module, exports) {
18036
17771
 
18037
17772
  "use strict";
@@ -18041,7 +17776,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
18041
17776
 
18042
17777
  /***/ },
18043
17778
 
18044
- /***/ 35642
17779
+ /***/ 51715
18045
17780
  (__unused_webpack_module, exports) {
18046
17781
 
18047
17782
  "use strict";
@@ -18051,7 +17786,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
18051
17786
 
18052
17787
  /***/ },
18053
17788
 
18054
- /***/ 18505
17789
+ /***/ 34452
18055
17790
  (__unused_webpack_module, exports) {
18056
17791
 
18057
17792
  "use strict";
@@ -18061,7 +17796,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
18061
17796
 
18062
17797
  /***/ },
18063
17798
 
18064
- /***/ 39434
17799
+ /***/ 54113
18065
17800
  (__unused_webpack_module, exports, __webpack_require__) {
18066
17801
 
18067
17802
  "use strict";
@@ -18081,14 +17816,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18081
17816
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18082
17817
  };
18083
17818
  Object.defineProperty(exports, "__esModule", ({ value: true }));
18084
- __exportStar(__webpack_require__(18505), exports);
18085
- __exportStar(__webpack_require__(28065), exports);
18086
- __exportStar(__webpack_require__(35642), exports);
17819
+ __exportStar(__webpack_require__(34452), exports);
17820
+ __exportStar(__webpack_require__(79702), exports);
17821
+ __exportStar(__webpack_require__(51715), exports);
18087
17822
 
18088
17823
 
18089
17824
  /***/ },
18090
17825
 
18091
- /***/ 81881
17826
+ /***/ 59512
18092
17827
  (__unused_webpack_module, exports, __webpack_require__) {
18093
17828
 
18094
17829
  "use strict";
@@ -18101,7 +17836,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
18101
17836
  };
18102
17837
  Object.defineProperty(exports, "__esModule", ({ value: true }));
18103
17838
  exports.PermissionService = void 0;
18104
- const utils_1 = __webpack_require__(24263);
17839
+ const utils_1 = __webpack_require__(88208);
18105
17840
  const PERMISSION_BY_RESOURCE = {
18106
17841
  function: ['CUSTOM'],
18107
17842
  storage: ['READONLY', 'PRIVATE', 'ADMINWRITE', 'ADMINONLY', 'CUSTOM'],
@@ -18518,7 +18253,7 @@ __decorate([
18518
18253
 
18519
18254
  /***/ },
18520
18255
 
18521
- /***/ 64047
18256
+ /***/ 69622
18522
18257
  (__unused_webpack_module, exports, __webpack_require__) {
18523
18258
 
18524
18259
  "use strict";
@@ -18547,7 +18282,6 @@ const path_1 = __importDefault(__webpack_require__(33873));
18547
18282
  const toolbox_1 = __webpack_require__(23233);
18548
18283
  class ProjectValidator {
18549
18284
  async validate(options = {}) {
18550
- var _a;
18551
18285
  const cwd = path_1.default.resolve(options.cwd || process.cwd());
18552
18286
  const errors = [];
18553
18287
  const warnings = [];
@@ -18556,7 +18290,6 @@ class ProjectValidator {
18556
18290
  mode: options.mode,
18557
18291
  errors,
18558
18292
  });
18559
- const version = String(((_a = loaded.rawConfig) === null || _a === void 0 ? void 0 : _a.version) || '2.1');
18560
18293
  if (loaded.rawConfig) {
18561
18294
  this.validateSchema(loaded.rawConfig, errors);
18562
18295
  }
@@ -18571,7 +18304,6 @@ class ProjectValidator {
18571
18304
  const summary = this.getSummary(loaded.config);
18572
18305
  return {
18573
18306
  valid: errors.length === 0,
18574
- version,
18575
18307
  errors,
18576
18308
  warnings,
18577
18309
  summary,
@@ -18977,12 +18709,12 @@ class ProjectValidator {
18977
18709
  }
18978
18710
  }
18979
18711
  exports.ProjectValidator = ProjectValidator;
18980
- __exportStar(__webpack_require__(20006), exports);
18712
+ __exportStar(__webpack_require__(40171), exports);
18981
18713
 
18982
18714
 
18983
18715
  /***/ },
18984
18716
 
18985
- /***/ 20006
18717
+ /***/ 40171
18986
18718
  (__unused_webpack_module, exports) {
18987
18719
 
18988
18720
  "use strict";
@@ -18992,14 +18724,14 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
18992
18724
 
18993
18725
  /***/ },
18994
18726
 
18995
- /***/ 64593
18727
+ /***/ 53854
18996
18728
  (__unused_webpack_module, exports, __webpack_require__) {
18997
18729
 
18998
18730
  "use strict";
18999
18731
 
19000
18732
  Object.defineProperty(exports, "__esModule", ({ value: true }));
19001
18733
  exports.SandboxService = void 0;
19002
- const utils_1 = __webpack_require__(24263);
18734
+ const utils_1 = __webpack_require__(88208);
19003
18735
  class SandboxService {
19004
18736
  constructor(environment) {
19005
18737
  this.environment = environment;
@@ -19562,7 +19294,7 @@ exports.SandboxService = SandboxService;
19562
19294
 
19563
19295
  /***/ },
19564
19296
 
19565
- /***/ 94507
19297
+ /***/ 85914
19566
19298
  (__unused_webpack_module, exports, __webpack_require__) {
19567
19299
 
19568
19300
  "use strict";
@@ -19622,7 +19354,7 @@ function splitEntryUploadFiles(files, entryFiles) {
19622
19354
 
19623
19355
  /***/ },
19624
19356
 
19625
- /***/ 29903
19357
+ /***/ 61132
19626
19358
  (__unused_webpack_module, exports, __webpack_require__) {
19627
19359
 
19628
19360
  "use strict";
@@ -19647,19 +19379,19 @@ const walkdir_1 = __importDefault(__webpack_require__(43204));
19647
19379
  const micromatch_1 = __importDefault(__webpack_require__(40821));
19648
19380
  const mime_types_1 = __importDefault(__webpack_require__(96662));
19649
19381
  const cos_nodejs_sdk_v5_1 = __importDefault(__webpack_require__(531));
19650
- const utils_1 = __webpack_require__(24263);
19651
- const error_1 = __webpack_require__(18143);
19652
- const parallel_1 = __webpack_require__(31504);
19653
- const runenv_1 = __webpack_require__(46767);
19654
- const constant_1 = __webpack_require__(3017);
19655
- const helper_1 = __webpack_require__(94507);
19382
+ const utils_1 = __webpack_require__(88208);
19383
+ const error_1 = __webpack_require__(54884);
19384
+ const parallel_1 = __webpack_require__(86693);
19385
+ const runenv_1 = __webpack_require__(94774);
19386
+ const constant_1 = __webpack_require__(41976);
19387
+ const helper_1 = __webpack_require__(85914);
19656
19388
  const BIG_FILE_SIZE = 5242880; // 5MB 1024*1024*5
19657
19389
  // ===== hosting deploy consistency 相关能力 =====
19658
19390
  /** 默认 MD5 计算并发数 */
19659
19391
  const DEFAULT_MD5_PARALLEL = 20;
19660
19392
  /** 一致性发布备份前缀(用于 diff.removed 排除备份文件) */
19661
19393
  const CONSISTENT_DEPLOY_BACKUP_PREFIX = '.cloudbase-backup/';
19662
- var helper_2 = __webpack_require__(94507);
19394
+ var helper_2 = __webpack_require__(85914);
19663
19395
  Object.defineProperty(exports, "md5File", ({ enumerable: true, get: function () { return helper_2.md5File; } }));
19664
19396
  class StorageService {
19665
19397
  constructor(environment) {
@@ -23157,14 +22889,14 @@ __decorate([
23157
22889
 
23158
22890
  /***/ },
23159
22891
 
23160
- /***/ 1155
22892
+ /***/ 23800
23161
22893
  (__unused_webpack_module, exports, __webpack_require__) {
23162
22894
 
23163
22895
  "use strict";
23164
22896
 
23165
22897
  Object.defineProperty(exports, "__esModule", ({ value: true }));
23166
22898
  exports.ThirdService = void 0;
23167
- const utils_1 = __webpack_require__(24263);
22899
+ const utils_1 = __webpack_require__(88208);
23168
22900
  class ThirdService {
23169
22901
  constructor(environment) {
23170
22902
  this.cloudService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
@@ -23183,7 +22915,7 @@ exports.ThirdService = ThirdService;
23183
22915
 
23184
22916
  /***/ },
23185
22917
 
23186
- /***/ 68569
22918
+ /***/ 41180
23187
22919
  (__unused_webpack_module, exports, __webpack_require__) {
23188
22920
 
23189
22921
  "use strict";
@@ -23196,7 +22928,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
23196
22928
  };
23197
22929
  Object.defineProperty(exports, "__esModule", ({ value: true }));
23198
22930
  exports.UserService = void 0;
23199
- const utils_1 = __webpack_require__(24263);
22931
+ const utils_1 = __webpack_require__(88208);
23200
22932
  class UserService {
23201
22933
  constructor(environment) {
23202
22934
  this.environment = environment;
@@ -23532,7 +23264,7 @@ __decorate([
23532
23264
 
23533
23265
  /***/ },
23534
23266
 
23535
- /***/ 77357
23267
+ /***/ 764
23536
23268
  (__unused_webpack_module, exports, __webpack_require__) {
23537
23269
 
23538
23270
  "use strict";
@@ -23636,7 +23368,7 @@ function getAuth(options) {
23636
23368
 
23637
23369
  /***/ },
23638
23370
 
23639
- /***/ 78263
23371
+ /***/ 29980
23640
23372
  (__unused_webpack_module, exports, __webpack_require__) {
23641
23373
 
23642
23374
  "use strict";
@@ -23649,10 +23381,10 @@ exports.CloudService = void 0;
23649
23381
  const crypto_1 = __importDefault(__webpack_require__(55511));
23650
23382
  const url_1 = __webpack_require__(79551);
23651
23383
  const query_string_1 = __importDefault(__webpack_require__(71547));
23652
- const error_1 = __webpack_require__(18143);
23653
- const http_request_1 = __webpack_require__(7355);
23654
- const constant_1 = __webpack_require__(3017);
23655
- const utils_1 = __webpack_require__(24263);
23384
+ const error_1 = __webpack_require__(54884);
23385
+ const http_request_1 = __webpack_require__(2922);
23386
+ const constant_1 = __webpack_require__(41976);
23387
+ const utils_1 = __webpack_require__(88208);
23656
23388
  function isObject(x) {
23657
23389
  return typeof x === 'object' && !Array.isArray(x) && x !== null;
23658
23390
  }
@@ -23885,15 +23617,15 @@ exports.CloudService = CloudService;
23885
23617
 
23886
23618
  /***/ },
23887
23619
 
23888
- /***/ 46439
23620
+ /***/ 16860
23889
23621
  (__unused_webpack_module, exports, __webpack_require__) {
23890
23622
 
23891
23623
  "use strict";
23892
23624
 
23893
23625
  Object.defineProperty(exports, "__esModule", ({ value: true }));
23894
23626
  exports.cloudBaseRequest = cloudBaseRequest;
23895
- const auth_1 = __webpack_require__(77357);
23896
- const http_request_1 = __webpack_require__(7355);
23627
+ const auth_1 = __webpack_require__(764);
23628
+ const http_request_1 = __webpack_require__(2922);
23897
23629
  const SUPPORT_REGIONS = ['ap-shanghai', 'ap-guangzhou', 'ap-singapore'];
23898
23630
  async function cloudBaseRequest(options) {
23899
23631
  // const url = 'https://tcb-admin.tencentcloudapi.com/admin'
@@ -23961,7 +23693,7 @@ async function cloudBaseRequest(options) {
23961
23693
 
23962
23694
  /***/ },
23963
23695
 
23964
- /***/ 16594
23696
+ /***/ 21889
23965
23697
  (__unused_webpack_module, exports) {
23966
23698
 
23967
23699
  "use strict";
@@ -23986,7 +23718,7 @@ function preLazy() {
23986
23718
 
23987
23719
  /***/ },
23988
23720
 
23989
- /***/ 56812
23721
+ /***/ 62625
23990
23722
  (__unused_webpack_module, exports, __webpack_require__) {
23991
23723
 
23992
23724
  "use strict";
@@ -24001,7 +23733,7 @@ exports.isDirectory = isDirectory;
24001
23733
  exports.formateFileSize = formateFileSize;
24002
23734
  exports.delSync = delSync;
24003
23735
  const fs_1 = __importDefault(__webpack_require__(29021));
24004
- const error_1 = __webpack_require__(18143);
23736
+ const error_1 = __webpack_require__(54884);
24005
23737
  const del_1 = __importDefault(__webpack_require__(56931));
24006
23738
  // 检查路径是否可以访问(读、写)
24007
23739
  function checkFullAccess(dest, throwError = false) {
@@ -24064,7 +23796,7 @@ function delSync(patterns) {
24064
23796
 
24065
23797
  /***/ },
24066
23798
 
24067
- /***/ 7355
23799
+ /***/ 2922
24068
23800
  (__unused_webpack_module, exports, __webpack_require__) {
24069
23801
 
24070
23802
  "use strict";
@@ -24078,7 +23810,7 @@ exports.fetchStream = fetchStream;
24078
23810
  const url_1 = __webpack_require__(79551);
24079
23811
  const node_fetch_1 = __importDefault(__webpack_require__(30188));
24080
23812
  const https_proxy_agent_1 = __webpack_require__(11710);
24081
- const error_1 = __webpack_require__(18143);
23813
+ const error_1 = __webpack_require__(54884);
24082
23814
  // 使用 fetch + 代理
24083
23815
  async function fetch(url, config = {}, proxy = null) {
24084
23816
  if (proxy || process.env.http_proxy) {
@@ -24119,7 +23851,7 @@ async function fetchStream(url, config = {}, proxy = null) {
24119
23851
 
24120
23852
  /***/ },
24121
23853
 
24122
- /***/ 24263
23854
+ /***/ 88208
24123
23855
  (__unused_webpack_module, exports, __webpack_require__) {
24124
23856
 
24125
23857
  "use strict";
@@ -24162,15 +23894,15 @@ const lodash_1 = __importDefault(__webpack_require__(35558));
24162
23894
  const os_1 = __importDefault(__webpack_require__(21820));
24163
23895
  const path_1 = __importDefault(__webpack_require__(33873));
24164
23896
  const unzipper_1 = __importDefault(__webpack_require__(44233));
24165
- const constant_1 = __webpack_require__(3017);
24166
- const http_request_1 = __webpack_require__(7355);
24167
- __exportStar(__webpack_require__(77357), exports);
24168
- __exportStar(__webpack_require__(78263), exports);
24169
- __exportStar(__webpack_require__(46439), exports);
24170
- __exportStar(__webpack_require__(16594), exports);
24171
- __exportStar(__webpack_require__(56812), exports);
24172
- __exportStar(__webpack_require__(7355), exports);
24173
- var uuid_1 = __webpack_require__(22684);
23897
+ const constant_1 = __webpack_require__(41976);
23898
+ const http_request_1 = __webpack_require__(2922);
23899
+ __exportStar(__webpack_require__(764), exports);
23900
+ __exportStar(__webpack_require__(29980), exports);
23901
+ __exportStar(__webpack_require__(16860), exports);
23902
+ __exportStar(__webpack_require__(21889), exports);
23903
+ __exportStar(__webpack_require__(62625), exports);
23904
+ __exportStar(__webpack_require__(2922), exports);
23905
+ var uuid_1 = __webpack_require__(10829);
24174
23906
  Object.defineProperty(exports, "guid6", ({ enumerable: true, get: function () { return uuid_1.guid6; } }));
24175
23907
  async function compressToZip(option) {
24176
23908
  const { dirPath, outputPath, ignore, pattern = '**/*', extraEntries } = option;
@@ -24498,7 +24230,7 @@ function successLog(msg) {
24498
24230
 
24499
24231
  /***/ },
24500
24232
 
24501
- /***/ 31504
24233
+ /***/ 86693
24502
24234
  (__unused_webpack_module, exports) {
24503
24235
 
24504
24236
  "use strict";
@@ -24575,7 +24307,7 @@ exports.AsyncTaskParallelController = AsyncTaskParallelController;
24575
24307
 
24576
24308
  /***/ },
24577
24309
 
24578
- /***/ 46767
24310
+ /***/ 94774
24579
24311
  (__unused_webpack_module, exports) {
24580
24312
 
24581
24313
  "use strict";
@@ -24590,7 +24322,7 @@ function checkIsInScf() {
24590
24322
 
24591
24323
  /***/ },
24592
24324
 
24593
- /***/ 22684
24325
+ /***/ 10829
24594
24326
  (__unused_webpack_module, exports) {
24595
24327
 
24596
24328
  "use strict";
@@ -149842,7 +149574,7 @@ minimatch.Minimatch = Minimatch
149842
149574
 
149843
149575
  /***/ },
149844
149576
 
149845
- /***/ 6378
149577
+ /***/ 51140
149846
149578
  (__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
149847
149579
 
149848
149580
  //! moment.js locale configuration
@@ -155167,8 +154899,8 @@ var map = {
155167
154899
  "./mt.js": 95451,
155168
154900
  "./my": 76160,
155169
154901
  "./my.js": 76160,
155170
- "./nb": 6378,
155171
- "./nb.js": 6378,
154902
+ "./nb": 51140,
154903
+ "./nb.js": 51140,
155172
154904
  "./ne": 10067,
155173
154905
  "./ne.js": 10067,
155174
154906
  "./nl": 73108,
@@ -199258,6 +198990,7 @@ exports.getAuthProgressState = getAuthProgressState;
199258
198990
  exports.resolveAuthOptions = resolveAuthOptions;
199259
198991
  exports.getAuthConfigValidationError = getAuthConfigValidationError;
199260
198992
  exports.buildAuthConfigSummary = buildAuthConfigSummary;
198993
+ exports.buildDeviceLoginOptions = buildDeviceLoginOptions;
199261
198994
  exports.setPendingAuthProgressState = setPendingAuthProgressState;
199262
198995
  exports.resolveAuthProgressState = resolveAuthProgressState;
199263
198996
  exports.rejectAuthProgressState = rejectAuthProgressState;
@@ -199476,9 +199209,10 @@ function getAuthConfigValidationError(options) {
199476
199209
  if (options.oauthCustom && !options.oauthEndpoint) {
199477
199210
  return "oauthCustom=true 时必须同时提供 oauthEndpoint。";
199478
199211
  }
199479
- if (options.oauthEndpoint && !options.oauthCustom) {
199480
- return "配置自定义 oauthEndpoint 时必须启用 oauthCustom=true。";
199481
- }
199212
+ // oauthEndpoint + 显式 oauthCustom=false 放行:resolveAuthOptions 对"只配 endpoint
199213
+ // 未配 custom"已默认 custom=true,走到这里的 endpoint+false 只可能是用户显式指定——
199214
+ // 即标准 {code,result} 包装格式的自定义端点(如国际站 tcb-api.tencentcloud.com),
199215
+ // 拦截会导致标准格式端点在工具层永远不可用。
199482
199216
  return null;
199483
199217
  }
199484
199218
  function buildAuthConfigSummary(options) {
@@ -199490,6 +199224,40 @@ function buildAuthConfigSummary(options) {
199490
199224
  uses_toolbox_defaults: options.usesToolboxDefaults,
199491
199225
  };
199492
199226
  }
199227
+ /**
199228
+ * 构造 device flow 的 loginByWebAuth 基础参数(onDeviceCode 由调用方按需注入)。
199229
+ *
199230
+ * 所有 device 登录路径(ensureLogin 与 auth 工具 start_auth 的 device 分支)必须
199231
+ * 共享本函数:TCB_SITE=intl 时的 getOAuthEndpoint 覆写与 getAuthUrl 授权页改写
199232
+ * 只在 ensureLogin 生效,会导致工具层直连路径仍打国内站端点/授权页,国际站账号
199233
+ * 无法完成授权(device-code 注册表国内外隔离,国内授权页对国际站账号无效)。
199234
+ */
199235
+ function buildDeviceLoginOptions(resolvedAuthOptions, siteHints = {}) {
199236
+ const resolvedSite = (0, site_map_js_1.resolveSite)(siteHints.region, siteHints.site ?? process.env.TCB_SITE);
199237
+ const loginOptions = { flow: "device" };
199238
+ if (resolvedAuthOptions.clientId) {
199239
+ loginOptions.client_id = resolvedAuthOptions.clientId;
199240
+ }
199241
+ if (resolvedAuthOptions.oauthEndpoint) {
199242
+ loginOptions.getOAuthEndpoint = () => resolvedAuthOptions.oauthEndpoint;
199243
+ }
199244
+ else if (resolvedSite === "intl") {
199245
+ // 国际站 OAuth 后端独立部署(2026-09-01 实测 device/code+token 可用,注册表与国内站隔离);
199246
+ // 不覆写时 toolbox 默认打国内站端点,国际站账号无法完成授权
199247
+ loginOptions.getOAuthEndpoint = () => site_map_js_1.SITE_REGION_MAP.intl.oauthEndpoint;
199248
+ }
199249
+ if (resolvedSite === "intl") {
199250
+ // device 模式的 verification_uri 标准模式下由客户端拼接,指向国内站授权页;
199251
+ // 与 web 模式同款 host 改写,把授权页切到国际站
199252
+ loginOptions.getAuthUrl = (url) => url
199253
+ .replace(`${site_map_js_1.SITE_REGION_MAP.domestic.authHost}/dev`, `${site_map_js_1.SITE_REGION_MAP.intl.authHost}/dev`)
199254
+ .replace(site_map_js_1.SITE_REGION_MAP.domestic.authHost, site_map_js_1.SITE_REGION_MAP.intl.authHost);
199255
+ }
199256
+ if (resolvedAuthOptions.oauthCustom) {
199257
+ loginOptions.custom = true;
199258
+ }
199259
+ return loginOptions;
199260
+ }
199493
199261
  function setPendingAuthProgressState(challenge, authMode = "device") {
199494
199262
  return updateAuthProgressState({
199495
199263
  status: "PENDING",
@@ -199729,27 +199497,11 @@ async function ensureLogin(options) {
199729
199497
  };
199730
199498
  }
199731
199499
  else {
199732
- if (resolvedAuthOptions.clientId) {
199733
- loginOptions.client_id = resolvedAuthOptions.clientId;
199734
- }
199735
- if (resolvedAuthOptions.oauthEndpoint) {
199736
- loginOptions.getOAuthEndpoint = () => resolvedAuthOptions.oauthEndpoint;
199737
- }
199738
- else if (resolvedSite === "intl") {
199739
- // 国际站 OAuth 后端独立部署(2026-09-01 实测 device/code+token 可用,注册表与国内站隔离);
199740
- // 不覆写时 toolbox 默认打国内站端点,国际站账号无法完成授权
199741
- loginOptions.getOAuthEndpoint = () => site_map_js_1.SITE_REGION_MAP.intl.oauthEndpoint;
199742
- }
199743
- if (resolvedSite === "intl") {
199744
- // device 模式的 verification_uri 标准模式下由客户端拼接,指向国内站授权页;
199745
- // 与 web 模式同款 host 改写,把授权页切到国际站
199746
- loginOptions.getAuthUrl = (url) => url
199747
- .replace(`${site_map_js_1.SITE_REGION_MAP.domestic.authHost}/dev`, `${site_map_js_1.SITE_REGION_MAP.intl.authHost}/dev`)
199748
- .replace(site_map_js_1.SITE_REGION_MAP.domestic.authHost, site_map_js_1.SITE_REGION_MAP.intl.authHost);
199749
- }
199750
- if (resolvedAuthOptions.oauthCustom) {
199751
- loginOptions.custom = true;
199752
- }
199500
+ // device 模式:与 auth 工具 start_auth device 分支共享 intl 端点覆写与授权页改写
199501
+ Object.assign(loginOptions, buildDeviceLoginOptions(resolvedAuthOptions, {
199502
+ region: options?.region,
199503
+ site: options?.site,
199504
+ }));
199753
199505
  if (options?.onDeviceCode) {
199754
199506
  loginOptions.onDeviceCode = (info) => {
199755
199507
  setPendingAuthProgressState(info, mode);
@@ -199839,7 +199591,7 @@ exports.getCloudBaseManager = getCloudBaseManager;
199839
199591
  exports.createCloudBaseManagerWithOptions = createCloudBaseManagerWithOptions;
199840
199592
  exports.extractRequestId = extractRequestId;
199841
199593
  exports.logCloudBaseResult = logCloudBaseResult;
199842
- const manager_node_1 = __importDefault(__webpack_require__(20277));
199594
+ const manager_node_1 = __importDefault(__webpack_require__(87798));
199843
199595
  const auth_js_1 = __webpack_require__(561);
199844
199596
  const logger_js_1 = __webpack_require__(40781);
199845
199597
  const tool_result_js_1 = __webpack_require__(69645);
@@ -201353,7 +201105,7 @@ async function getInteractiveServerAsync() {
201353
201105
  "use strict";
201354
201106
 
201355
201107
  Object.defineProperty(exports, "__esModule", ({ value: true }));
201356
- exports.telemetryReporter = exports.reportToolkitLifecycle = exports.reportToolCall = exports.warn = exports.info = exports.error = exports.StdioServerTransport = void 0;
201108
+ exports.normalizeClientName = exports.telemetryReporter = exports.reportToolkitLifecycle = exports.reportToolCall = exports.warn = exports.info = exports.error = exports.StdioServerTransport = void 0;
201357
201109
  exports.createCloudBaseMcpServer = createCloudBaseMcpServer;
201358
201110
  exports.getDefaultServer = getDefaultServer;
201359
201111
  const mcp_js_1 = __webpack_require__(55375);
@@ -201371,6 +201123,7 @@ const storage_js_1 = __webpack_require__(23138);
201371
201123
  const types_js_1 = __webpack_require__(79546);
201372
201124
  const capi_js_1 = __webpack_require__(88900);
201373
201125
  const cloudrun_js_1 = __webpack_require__(5658);
201126
+ const deploy_js_1 = __webpack_require__(23668);
201374
201127
  const dataModel_js_1 = __webpack_require__(42722);
201375
201128
  const gateway_js_1 = __webpack_require__(79921);
201376
201129
  const agents_js_1 = __webpack_require__(48409);
@@ -201384,6 +201137,7 @@ const logger_js_1 = __webpack_require__(40781);
201384
201137
  const site_map_js_1 = __webpack_require__(34533);
201385
201138
  const tool_result_js_1 = __webpack_require__(69645);
201386
201139
  const tool_wrapper_js_1 = __webpack_require__(93389);
201140
+ const telemetry_js_1 = __webpack_require__(5198);
201387
201141
  // 默认插件列表
201388
201142
  const DEFAULT_PLUGINS = [
201389
201143
  "env",
@@ -201397,6 +201151,7 @@ const DEFAULT_PLUGINS = [
201397
201151
  "setup",
201398
201152
  "rag",
201399
201153
  "cloudrun",
201154
+ "deploy",
201400
201155
  "gateway",
201401
201156
  "app-auth",
201402
201157
  "apps",
@@ -201450,6 +201205,7 @@ const AVAILABLE_PLUGINS = {
201450
201205
  agents: { name: "agents", register: agents_js_1.registerAgentTools },
201451
201206
  apps: { name: "apps", register: apps_js_1.registerAppTools },
201452
201207
  cloudrun: { name: "cloudrun", register: cloudrun_js_1.registerCloudRunTools },
201208
+ deploy: { name: "deploy", register: deploy_js_1.registerDeployTools },
201453
201209
  capi: { name: "capi", register: capi_js_1.registerCapiTools },
201454
201210
  "msg-push": { name: "msg-push", register: msg_push_js_1.registerMsgPushTools },
201455
201211
  };
@@ -201527,7 +201283,7 @@ function parseEnabledPlugins(pluginsEnabled, pluginsDisabled) {
201527
201283
  * await server.connect(transport);
201528
201284
  */
201529
201285
  async function createCloudBaseMcpServer(options) {
201530
- const { name = "cloudbase-mcp", version = "1.0.0", enableTelemetry = true, cloudBaseOptions, authOptions, cloudMode = false, ide, logger, pluginsEnabled, pluginsDisabled, pluginOptions, } = options ?? {};
201286
+ const { name = "cloudbase-mcp", version = "1.0.0", enableTelemetry = true, cloudBaseOptions, authOptions, cloudMode = false, ide, client, logger, pluginsEnabled, pluginsDisabled, pluginOptions, } = options ?? {};
201531
201287
  // Enable cloud mode if specified
201532
201288
  if (cloudMode) {
201533
201289
  (0, cloud_mode_js_1.enableCloudMode)();
@@ -201590,6 +201346,11 @@ async function createCloudBaseMcpServer(options) {
201590
201346
  if (ide) {
201591
201347
  server.ide = ide;
201592
201348
  }
201349
+ // Store client in server instance for telemetry (normalized, invalid values dropped)
201350
+ const normalizedClient = (0, telemetry_js_1.normalizeClientName)(client);
201351
+ if (normalizedClient) {
201352
+ server.client = normalizedClient;
201353
+ }
201593
201354
  // Store logger in server instance for tools to access
201594
201355
  if (logger) {
201595
201356
  server.logger = logger;
@@ -201624,10 +201385,11 @@ var logger_js_2 = __webpack_require__(40781);
201624
201385
  Object.defineProperty(exports, "error", ({ enumerable: true, get: function () { return logger_js_2.error; } }));
201625
201386
  Object.defineProperty(exports, "info", ({ enumerable: true, get: function () { return logger_js_2.info; } }));
201626
201387
  Object.defineProperty(exports, "warn", ({ enumerable: true, get: function () { return logger_js_2.warn; } }));
201627
- var telemetry_js_1 = __webpack_require__(5198);
201628
- Object.defineProperty(exports, "reportToolCall", ({ enumerable: true, get: function () { return telemetry_js_1.reportToolCall; } }));
201629
- Object.defineProperty(exports, "reportToolkitLifecycle", ({ enumerable: true, get: function () { return telemetry_js_1.reportToolkitLifecycle; } }));
201630
- Object.defineProperty(exports, "telemetryReporter", ({ enumerable: true, get: function () { return telemetry_js_1.telemetryReporter; } }));
201388
+ var telemetry_js_2 = __webpack_require__(5198);
201389
+ Object.defineProperty(exports, "reportToolCall", ({ enumerable: true, get: function () { return telemetry_js_2.reportToolCall; } }));
201390
+ Object.defineProperty(exports, "reportToolkitLifecycle", ({ enumerable: true, get: function () { return telemetry_js_2.reportToolkitLifecycle; } }));
201391
+ Object.defineProperty(exports, "telemetryReporter", ({ enumerable: true, get: function () { return telemetry_js_2.telemetryReporter; } }));
201392
+ Object.defineProperty(exports, "normalizeClientName", ({ enumerable: true, get: function () { return telemetry_js_2.normalizeClientName; } }));
201631
201393
 
201632
201394
 
201633
201395
  /***/ },
@@ -203187,7 +202949,7 @@ function registerAppTools(server) {
203187
202949
  "use strict";
203188
202950
 
203189
202951
  Object.defineProperty(exports, "__esModule", ({ value: true }));
203190
- exports.CAM_AUTH_ERROR_PATTERN = void 0;
202952
+ exports.CAM_AUTH_ERROR_PATTERN = exports.ALLOWED_SERVICES = void 0;
203191
202953
  exports.assertTcbCloudRunActionAllowed = assertTcbCloudRunActionAllowed;
203192
202954
  exports.resolveCloudApiRegionAndParams = resolveCloudApiRegionAndParams;
203193
202955
  exports.removeEmptyStringParams = removeEmptyStringParams;
@@ -203201,7 +202963,7 @@ const tcb_action_index_js_1 = __webpack_require__(72550);
203201
202963
  const CATEGORY = "cloud-api";
203202
202964
  const CLOUDBASE_CONTROL_PLANE_DOC_URL = "https://cloud.tencent.com/document/product/876/34809";
203203
202965
  const CLOUDBASE_DEPENDENCY_API_DOC_URL = "https://cloud.tencent.com/document/product/876/34808";
203204
- const ALLOWED_SERVICES = [
202966
+ exports.ALLOWED_SERVICES = [
203205
202967
  "tcb",
203206
202968
  "tcbr",
203207
202969
  "scf",
@@ -203210,6 +202972,8 @@ const ALLOWED_SERVICES = [
203210
202972
  "lowcode",
203211
202973
  "cdn",
203212
202974
  "vpc",
202975
+ "monitor",
202976
+ "postgres",
203213
202977
  ];
203214
202978
  /**
203215
202979
  * Legacy tcb small-tenant CloudRun (CloudBase Run) API family — blocked.
@@ -203331,6 +203095,9 @@ function buildCapiDocGuidance(service) {
203331
203095
  if (service === "tcb" || service === "tcbr" || service === "lowcode" || service === "scf") {
203332
203096
  return `优先查阅 CloudBase API 概览 ${CLOUDBASE_CONTROL_PLANE_DOC_URL} 与云开发依赖资源接口指引 ${CLOUDBASE_DEPENDENCY_API_DOC_URL}。`;
203333
203097
  }
203098
+ if (service === "monitor") {
203099
+ return `请优先核对云监控(腾讯云可观测平台)官方 API 文档:API 概览 https://cloud.tencent.com/document/product/649/30343 ,单 Action 详细文档在 https://cloud.tencent.com/document/api/248/ 产品线下。`;
203100
+ }
203334
203101
  return `请优先核对对应官方云 API 文档;若你的场景其实是通过 HTTP 协议直接集成 auth/functions/cloudrun/storage/mysqldb 等 CloudBase 业务 API,请优先使用 OpenAPI / Swagger 或 searchKnowledgeBase(mode="openapi"),不要继续猜测管控面 Action。`;
203335
203102
  }
203336
203103
  /** Match CAM / authorization failures from Tencent Cloud control-plane APIs. */
@@ -203436,7 +203203,7 @@ function registerCapiTools(server) {
203436
203203
  const getManager = () => (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId: false });
203437
203204
  server.registerTool?.("callCloudApi", {
203438
203205
  title: "调用云API",
203439
- description: `通用的云 API 调用工具,主要用于 CloudBase / 腾讯云管控面与依赖资源相关 API 调用。调用前请先确认 service、Action 与 Param,避免猜测 Action 名称。如果你的目标是通过 HTTP 协议直接集成 auth/functions/cloudrun/storage/mysqldb 等 CloudBase 业务 API,请不要优先使用 callCloudApi,而应优先查看对应 OpenAPI / Swagger。现有 OpenAPI / Swagger 能力不是通用的管控面 Action 集合;管控面 API 请优先参考 CloudBase API 概览 ${CLOUDBASE_CONTROL_PLANE_DOC_URL} 与云开发依赖资源接口指引 ${CLOUDBASE_DEPENDENCY_API_DOC_URL}。对于 tcb service,常用 Action 分类如下:
203206
+ description: `通用的云 API 调用工具,主要用于 CloudBase / 腾讯云管控面与依赖资源相关 API 调用。**调用前必读接口索引** https://docs.cloudbase.net/ai/cloudbase-ai-toolkit/api-reference.md (每日自动同步的 Action 级索引,含 rate limit;先查此索引确认 service/Action/参数,避免猜测 Action 名称;索引未覆盖的产品再去该产品官方 API 文档核对)。如果你的目标是通过 HTTP 协议直接集成 auth/functions/cloudrun/storage/mysqldb 等 CloudBase 业务 API,请不要优先使用 callCloudApi,而应优先查看对应 OpenAPI / Swagger。现有 OpenAPI / Swagger 能力不是通用的管控面 Action 集合;管控面 API 请优先参考 CloudBase API 概览 ${CLOUDBASE_CONTROL_PLANE_DOC_URL} 与云开发依赖资源接口指引 ${CLOUDBASE_DEPENDENCY_API_DOC_URL}。对于 tcb service,常用 Action 分类如下:
203440
203207
 
203441
203208
  **环境管理**: \`CreateEnv\`、\`ModifyEnv\`、\`DescribeEnvs\`、\`DestroyEnv\`
203442
203209
  **用户管理**: \`CreateUser\`、\`ModifyUser\`、\`DescribeUserList\`、\`DeleteUsers\`
@@ -203451,8 +203218,8 @@ function registerCapiTools(server) {
203451
203218
  销毁环境时,常见做法是至少带上 \`EnvId\` 和 \`BypassCheck: true\`,如果环境已经处于隔离期再按文档补 \`IsForce: true\`。`,
203452
203219
  inputSchema: {
203453
203220
  service: zod_1.z
203454
- .enum(ALLOWED_SERVICES)
203455
- .describe("选择要访问的服务。可选:tcb、tcbr、scf、sts、cam、lowcode、cdn、vpc。对于 tcb / scf / lowcode 等 CloudBase 管控面 Action,请优先查官方文档,不要直接猜测 Action。云托管统一走 tcbr(version 需传 2022-02-17)。"),
203221
+ .enum(exports.ALLOWED_SERVICES)
203222
+ .describe("选择要访问的服务。可选:tcb、tcbr、scf、sts、cam、lowcode、cdn、vpc、monitor(云监控/告警,version 需传 2018-07-24)、postgres(云数据库 PostgreSQL,version 需传 2017-03-12)。对于 tcb / scf / lowcode 等 CloudBase 管控面 Action,请优先查官方文档,不要直接猜测 Action。云托管统一走 tcbr(version 需传 2022-02-17)。"),
203456
203223
  action: zod_1.z
203457
203224
  .string()
203458
203225
  .min(1)
@@ -203460,7 +203227,7 @@ function registerCapiTools(server) {
203460
203227
  version: zod_1.z
203461
203228
  .string()
203462
203229
  .optional()
203463
- .describe("API 版本(可选)。缺省时按 service 使用 SDK 内置默认版本;tcbr 必须传 \"2022-02-17\"(否则请求缺少 X-TC-Version 会失败)。示例:service=\"tcbr\", version=\"2022-02-17\", action=\"CreateCloudRunEnv\", params={EnvId:\"env-xxx\",PackageType:\"Standard\"}。"),
203230
+ .describe("API 版本(可选)。缺省时按 service 使用 SDK 内置默认版本;tcbr 必须传 \"2022-02-17\"(否则请求缺少 X-TC-Version 会失败),monitor 必须传 \"2018-07-24\"、postgres 必须传 \"2017-03-12\"(这两个 service 无内置默认版本,不传会失败)。示例:service=\"tcbr\", version=\"2022-02-17\", action=\"CreateCloudRunEnv\", params={EnvId:\"env-xxx\",PackageType:\"Standard\"}。"),
203464
203231
  params: zod_1.z
203465
203232
  .record(zod_1.z.any())
203466
203233
  .optional()
@@ -203478,8 +203245,8 @@ function registerCapiTools(server) {
203478
203245
  category: CATEGORY,
203479
203246
  },
203480
203247
  }, async ({ service, action, params, version, region, }) => {
203481
- if (!ALLOWED_SERVICES.includes(service)) {
203482
- throw new Error(`Service ${service} is not allowed. Allowed services: ${ALLOWED_SERVICES.join(", ")}`);
203248
+ if (!exports.ALLOWED_SERVICES.includes(service)) {
203249
+ throw new Error(`Service ${service} is not allowed. Allowed services: ${exports.ALLOWED_SERVICES.join(", ")}`);
203483
203250
  }
203484
203251
  assertTcbCloudRunActionAllowed(service, action);
203485
203252
  const { region: resolvedRegion, params: bodyParams } = resolveCloudApiRegionAndParams({ region, params });
@@ -208221,6 +207988,7 @@ const path = __importStar(__webpack_require__(33873));
208221
207988
  const zod_1 = __webpack_require__(21504);
208222
207989
  const cloudbase_manager_js_1 = __webpack_require__(33109);
208223
207990
  const tool_result_js_1 = __webpack_require__(69645);
207991
+ const sql_risk_js_1 = __webpack_require__(29885);
208224
207992
  const CATEGORY = "PostgreSQL database";
208225
207993
  const QUERY_PG_DATABASE = "queryPgDatabase";
208226
207994
  const MANAGE_PG_DATABASE = "managePgDatabase";
@@ -208380,33 +208148,9 @@ function normalizeLimit(limit, fallback = 20, max = 200) {
208380
208148
  }
208381
208149
  return Math.max(1, Math.min(max, Math.floor(limit)));
208382
208150
  }
208383
- function stripLeadingSqlComments(sql) {
208384
- let normalized = sql.trim();
208385
- while (normalized.length > 0) {
208386
- if (normalized.startsWith("--")) {
208387
- normalized = normalized.replace(/^--.*(?:\r?\n|$)/, "").trimStart();
208388
- continue;
208389
- }
208390
- if (normalized.startsWith("#")) {
208391
- normalized = normalized.replace(/^#.*(?:\r?\n|$)/, "").trimStart();
208392
- continue;
208393
- }
208394
- if (normalized.startsWith("/*")) {
208395
- normalized = normalized.replace(/^\/\*[\s\S]*?\*\//, "").trimStart();
208396
- continue;
208397
- }
208398
- break;
208399
- }
208400
- return normalized;
208401
- }
208402
- function getSqlVerb(sql) {
208403
- const normalized = stripLeadingSqlComments(sql);
208404
- const match = normalized.match(/^([a-zA-Z]+)/);
208405
- return match ? match[1].toUpperCase() : "";
208406
- }
208407
208151
  function isReadOnlySql(sql) {
208408
- const normalized = stripLeadingSqlComments(sql);
208409
- const verb = getSqlVerb(normalized);
208152
+ const normalized = (0, sql_risk_js_1.stripLeadingSqlComments)(sql);
208153
+ const verb = (0, sql_risk_js_1.getSqlVerb)(normalized);
208410
208154
  const readOnlyVerbs = new Set([
208411
208155
  "SELECT",
208412
208156
  "SHOW",
@@ -208420,27 +208164,16 @@ function isReadOnlySql(sql) {
208420
208164
  return !/\b(INSERT|UPDATE|DELETE|CREATE|ALTER|DROP|TRUNCATE|REPLACE|RENAME|GRANT|REVOKE|COMMENT|VACUUM|ANALYZE|FOR\s+UPDATE|FOR\s+SHARE)\b/i.test(normalized);
208421
208165
  }
208422
208166
  function buildLimitedReadOnlySql(sql, limit) {
208423
- const normalized = stripLeadingSqlComments(sql).replace(/;\s*$/, "");
208424
- const verb = getSqlVerb(normalized);
208167
+ const normalized = (0, sql_risk_js_1.stripLeadingSqlComments)(sql).replace(/;\s*$/, "");
208168
+ const verb = (0, sql_risk_js_1.getSqlVerb)(normalized);
208425
208169
  if (!["SELECT", "WITH", "VALUES"].includes(verb)) {
208426
208170
  return sql;
208427
208171
  }
208428
208172
  return `SELECT * FROM (${normalized}) AS cloudbase_mcp_readonly_limit LIMIT ${limit}`;
208429
208173
  }
208430
- function isDestructiveSql(sql) {
208431
- const normalized = stripLeadingSqlComments(sql);
208432
- const verb = getSqlVerb(normalized);
208433
- if (["DROP", "TRUNCATE", "DELETE"].includes(verb)) {
208434
- return true;
208435
- }
208436
- if (verb === "ALTER") {
208437
- return /\b(DROP|RENAME)\b/i.test(normalized);
208438
- }
208439
- return false;
208440
- }
208441
208174
  function classifySqlRisk(sql) {
208442
- const normalized = stripLeadingSqlComments(sql);
208443
- const verb = getSqlVerb(normalized);
208175
+ const normalized = (0, sql_risk_js_1.stripLeadingSqlComments)(sql);
208176
+ const verb = (0, sql_risk_js_1.getSqlVerb)(normalized);
208444
208177
  if (!verb) {
208445
208178
  return {
208446
208179
  risk: "unknown_risk",
@@ -208455,7 +208188,7 @@ function classifySqlRisk(sql) {
208455
208188
  requiresConfirm: false,
208456
208189
  };
208457
208190
  }
208458
- if (isDestructiveSql(normalized)) {
208191
+ if ((0, sql_risk_js_1.isDestructiveSql)(normalized)) {
208459
208192
  return {
208460
208193
  risk: "destructive",
208461
208194
  readOnly: false,
@@ -208501,7 +208234,7 @@ function isSchemaDdlRisk(risk, sql) {
208501
208234
  if (risk !== "destructive") {
208502
208235
  return false;
208503
208236
  }
208504
- const verb = getSqlVerb(stripLeadingSqlComments(sql));
208237
+ const verb = (0, sql_risk_js_1.getSqlVerb)((0, sql_risk_js_1.stripLeadingSqlComments)(sql));
208505
208238
  return ["DROP", "TRUNCATE", "ALTER"].includes(verb);
208506
208239
  }
208507
208240
  /**
@@ -209054,7 +208787,7 @@ function buildSchemaTable(schema, name) {
209054
208787
  return `${schema}.${name}`;
209055
208788
  }
209056
208789
  function parseTargetTableFromSql(sql, defaultSchema) {
209057
- const normalized = stripLeadingSqlComments(sql);
208790
+ const normalized = (0, sql_risk_js_1.stripLeadingSqlComments)(sql);
209058
208791
  const identifier = String.raw `((?:[A-Za-z_][A-Za-z0-9_$]*\.)?[A-Za-z_][A-Za-z0-9_$]*)`;
209059
208792
  const patterns = [
209060
208793
  new RegExp(String.raw `\bcreate\s+(?:temporary\s+|temp\s+|unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?${identifier}`, "i"),
@@ -209461,7 +209194,7 @@ function renderParameterizedSql(sql, values) {
209461
209194
  });
209462
209195
  }
209463
209196
  function inferCommand(sql) {
209464
- return getSqlVerb(sql) || undefined;
209197
+ return (0, sql_risk_js_1.getSqlVerb)(sql) || undefined;
209465
209198
  }
209466
209199
  function createManagerPgClient(context, cloudBaseOptions) {
209467
209200
  return {
@@ -209737,7 +209470,7 @@ async function handleExecuteSql(args, context, deps) {
209737
209470
  success: true,
209738
209471
  data: {
209739
209472
  classification,
209740
- command: result.command ?? getSqlVerb(args.sql),
209473
+ command: result.command ?? (0, sql_risk_js_1.getSqlVerb)(args.sql),
209741
209474
  rowCount: result.rowCount ?? null,
209742
209475
  previewRows: result.rows
209743
209476
  .slice(0, 5)
@@ -211833,6 +211566,475 @@ function registerSQLDatabaseTools(server) {
211833
211566
  }
211834
211567
 
211835
211568
 
211569
+ /***/ },
211570
+
211571
+ /***/ 23668
211572
+ (__unused_webpack_module, exports, __webpack_require__) {
211573
+
211574
+ "use strict";
211575
+
211576
+ var __importDefault = (this && this.__importDefault) || function (mod) {
211577
+ return (mod && mod.__esModule) ? mod : { "default": mod };
211578
+ };
211579
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
211580
+ exports.DEPLOY_ERROR_CODES = void 0;
211581
+ exports.registerDeployTools = registerDeployTools;
211582
+ const toolbox_1 = __webpack_require__(23233);
211583
+ const node_fs_1 = __importDefault(__webpack_require__(89971));
211584
+ const node_path_1 = __importDefault(__webpack_require__(26743));
211585
+ const zod_1 = __webpack_require__(21504);
211586
+ const cloudbase_manager_js_1 = __webpack_require__(33109);
211587
+ const json_content_js_1 = __webpack_require__(18027);
211588
+ const sql_risk_js_1 = __webpack_require__(29885);
211589
+ // 声明式部署可编排的资源类型,与 DeployOrchestrator 的部署顺序一致:
211590
+ // database → functions → app → hosting → gateway
211591
+ const RESOURCE_TYPES = ["database", "functions", "app", "hosting", "gateway"];
211592
+ /**
211593
+ * 声明式部署工具的稳定错误码。供 agent 程序化分支处理,不随文案调整而变化。
211594
+ * - CONFIG_NOT_FOUND:cwd 下未找到 cloudbaserc 配置文件
211595
+ * - CONFIG_INVALID:配置未通过 cloudbaserc schema 校验
211596
+ * - ENV_UNRESOLVED:无法确定目标环境 ID(配置/入参/登录态均缺失)
211597
+ * - INVALID_CONCURRENCY:并发数入参非法
211598
+ * - CONFIRM_REQUIRED:写操作未显式传 confirm=true
211599
+ * - DESTRUCTIVE_CONFIRM_REQUIRED:待执行的数据库迁移含破坏性语句,需额外传 confirmDestructive=true
211600
+ * - DEPLOY_FAILED:编排器执行失败或其它未分类错误(可能透传引擎 errorCode)
211601
+ */
211602
+ exports.DEPLOY_ERROR_CODES = {
211603
+ CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
211604
+ CONFIG_INVALID: "CONFIG_INVALID",
211605
+ ENV_UNRESOLVED: "ENV_UNRESOLVED",
211606
+ INVALID_CONCURRENCY: "INVALID_CONCURRENCY",
211607
+ CONFIRM_REQUIRED: "CONFIRM_REQUIRED",
211608
+ DESTRUCTIVE_CONFIRM_REQUIRED: "DESTRUCTIVE_CONFIRM_REQUIRED",
211609
+ DEPLOY_FAILED: "DEPLOY_FAILED",
211610
+ };
211611
+ /**
211612
+ * 携带稳定错误码的部署错误。抛出后由 buildErrorEnvelope 归一为信封的 errorCode 字段。
211613
+ */
211614
+ class DeployError extends Error {
211615
+ code;
211616
+ constructor(code, message) {
211617
+ super(message);
211618
+ this.name = "DeployError";
211619
+ this.code = code;
211620
+ }
211621
+ }
211622
+ function buildEnvelope(data, message) {
211623
+ return { success: true, data, message };
211624
+ }
211625
+ function buildErrorEnvelope(error) {
211626
+ // DeployError 带显式错误码;引擎/SDK 抛出的错误若带 code 也透传;其余归为 DEPLOY_FAILED。
211627
+ let errorCode = exports.DEPLOY_ERROR_CODES.DEPLOY_FAILED;
211628
+ if (error instanceof DeployError) {
211629
+ errorCode = error.code;
211630
+ }
211631
+ else if (error &&
211632
+ typeof error === "object" &&
211633
+ "code" in error &&
211634
+ typeof error.code === "string" &&
211635
+ error.code.length > 0) {
211636
+ errorCode = error.code;
211637
+ }
211638
+ return {
211639
+ success: false,
211640
+ data: {},
211641
+ message: error instanceof Error ? error.message : String(error),
211642
+ errorCode,
211643
+ };
211644
+ }
211645
+ /**
211646
+ * 解析 cloudbaserc 声明式部署配置。
211647
+ *
211648
+ * 分两步完成:
211649
+ * 1. 定位并读取配置文件:searchConfig 从 cwd 探测 cloudbaserc.*(json/yaml/yml/js),
211650
+ * loadConfig 读取原始内容。读取阶段不强制 envId,
211651
+ * envId 由调用方按优先级单独确定,以支持用登录态环境部署未写死 envId 的配置。
211652
+ * 2. ConfigParser.parseRawConfig:按 mode 合并 envOverrides、下发 functionDefaultConfig
211653
+ * 到各函数、加载 .env / .env.local / .env.<mode> 并渲染 {{env.*}} / {{tcb.*}} 模板变量。
211654
+ */
211655
+ async function resolveDeployConfig(options) {
211656
+ const found = await (0, toolbox_1.searchConfig)(options.cwd);
211657
+ if (!found?.filepath) {
211658
+ throw new DeployError(exports.DEPLOY_ERROR_CODES.CONFIG_NOT_FOUND, `未在 ${options.cwd} 找到 cloudbaserc 配置文件(支持 json/yaml/yml/js)`);
211659
+ }
211660
+ const rawConfig = await (0, toolbox_1.loadConfig)({ configPath: found.filepath });
211661
+ return toolbox_1.ConfigParser.parseRawConfig(rawConfig ?? {}, options.cwd, {
211662
+ mode: options.mode,
211663
+ });
211664
+ }
211665
+ /**
211666
+ * 确定部署使用的环境 ID。
211667
+ *
211668
+ * 优先级:显式传入的 envId > 解析后配置中的 envId > MCP 登录态 / 绑定环境。
211669
+ * 显式入参优先于配置文件,配置未写死 envId 时回退到当前会话绑定的环境。
211670
+ * 三者都无则抛出错误。
211671
+ */
211672
+ async function resolveDeployEnvId(options) {
211673
+ if (options.envId && options.envId.length > 0) {
211674
+ return options.envId;
211675
+ }
211676
+ const configEnvId = options.config.envId;
211677
+ if (typeof configEnvId === "string" && configEnvId.length > 0) {
211678
+ return configEnvId;
211679
+ }
211680
+ const resolved = await (0, cloudbase_manager_js_1.getEnvId)(options.cloudBaseOptions);
211681
+ if (!resolved) {
211682
+ throw new DeployError(exports.DEPLOY_ERROR_CODES.ENV_UNRESOLVED, "未能确定部署环境 ID:请在 cloudbaserc 配置 envId、通过 envId 参数指定,或先登录并绑定环境。");
211683
+ }
211684
+ return resolved;
211685
+ }
211686
+ /**
211687
+ * 按 cloudbaserc schema 校验解析后的配置。
211688
+ *
211689
+ * 校验不通过时抛出错误,错误消息包含各字段的具体校验失败原因,供调用方定位问题。
211690
+ */
211691
+ function assertConfigValid(config) {
211692
+ const result = (0, toolbox_1.validateCloudBaseConfigBySchema)(config);
211693
+ if (result.valid) {
211694
+ return;
211695
+ }
211696
+ const detail = result.errors
211697
+ .map((item) => `${item.dataPath || "<root>"} ${item.message}`)
211698
+ .join("; ");
211699
+ throw new DeployError(exports.DEPLOY_ERROR_CODES.CONFIG_INVALID, `cloudbaserc 配置校验未通过:${detail}`);
211700
+ }
211701
+ /**
211702
+ * 校验并发数取值,非法时抛出错误。
211703
+ *
211704
+ * 未指定时返回 undefined(由编排器使用默认串行);指定时必须为不小于 1 的整数。
211705
+ */
211706
+ function normalizeConcurrency(concurrency) {
211707
+ if (concurrency === undefined) {
211708
+ return undefined;
211709
+ }
211710
+ if (!Number.isInteger(concurrency) || concurrency < 1) {
211711
+ throw new DeployError(exports.DEPLOY_ERROR_CODES.INVALID_CONCURRENCY, `无效的并发数 ${concurrency},应为不小于 1 的整数`);
211712
+ }
211713
+ return concurrency;
211714
+ }
211715
+ /**
211716
+ * 让 deployPlan 的预演结论与 deployApply 的实际执行语义对齐。
211717
+ *
211718
+ * 背景:编排器把「云端已存在的函数」标为 status='update',但 deployApply 在 yes!==true
211719
+ * 且无交互确认回调时,会对 functions+update 保守跳过(reason='no-confirm')。
211720
+ * 若 plan 原样返回 update,agent 预演看到「会更新」,实际执行却「跳过」——结论相反。
211721
+ *
211722
+ * 此函数按传入的 yes 复算 functions+update 的「有效动作」:
211723
+ * - yes===true:维持 update(执行时确实会覆盖)
211724
+ * - 否则:改标为 skip,并保留原始判定到 declaredStatus,action 说明为何跳过。
211725
+ * 其它资源类型与状态原样透传(database/app/hosting/gateway 的分类不受 yes 影响)。
211726
+ */
211727
+ function reconcilePlanWithExecution(plan, yes) {
211728
+ if (!Array.isArray(plan)) {
211729
+ return [];
211730
+ }
211731
+ return plan.map((item) => {
211732
+ if (!item || typeof item !== "object") {
211733
+ return item;
211734
+ }
211735
+ if (item.type === "functions" && item.status === "update" && !yes) {
211736
+ return {
211737
+ ...item,
211738
+ status: "skip",
211739
+ declaredStatus: "update",
211740
+ action: `已存在函数 ${item.name}:未传 yes=true,执行时将保守跳过(不覆盖)。传 yes=true 才会覆盖更新。`,
211741
+ };
211742
+ }
211743
+ return item;
211744
+ });
211745
+ }
211746
+ /**
211747
+ * 解析 migrations 目录(与引擎 DatabaseDeployer.resolveMigrationsDir 同规则):
211748
+ * 未配置默认 ./cloudbase/migrations;仅允许相对路径(禁止绝对路径 / 开头)。
211749
+ * 非法时返回 undefined(交由引擎在真正执行时抛出一致的错误,这里不抢报错)。
211750
+ */
211751
+ function resolveMigrationsDir(cwd, migrations) {
211752
+ const raw = typeof migrations === "string" && migrations ? migrations : "./cloudbase/migrations";
211753
+ if (node_path_1.default.isAbsolute(raw) || raw.startsWith("/")) {
211754
+ return undefined;
211755
+ }
211756
+ return node_path_1.default.resolve(cwd, raw);
211757
+ }
211758
+ /**
211759
+ * 从 dry-run plan 中提取「待执行(pending)的数据库迁移标识」。
211760
+ *
211761
+ * 编排器把 database 计划聚合为单条 create 项,pending 迁移写在
211762
+ * changes[].to(field==='migration'),形如 "{version}_{name}"。
211763
+ * 只关注 pending:已 applied 的迁移不会被重复执行,不应触发破坏性确认门。
211764
+ */
211765
+ function extractPendingMigrations(plan) {
211766
+ const result = [];
211767
+ for (const item of plan) {
211768
+ if (!item || item.type !== "database" || item.status !== "create") {
211769
+ continue;
211770
+ }
211771
+ const changes = item.changes;
211772
+ if (!Array.isArray(changes)) {
211773
+ continue;
211774
+ }
211775
+ for (const change of changes) {
211776
+ if (change?.field === "migration" && typeof change.to === "string" && change.to) {
211777
+ result.push(change.to);
211778
+ }
211779
+ }
211780
+ }
211781
+ return result;
211782
+ }
211783
+ /**
211784
+ * 检测「本次将要执行的数据库迁移」中是否含破坏性语句(DROP/TRUNCATE/DELETE、
211785
+ * ALTER ... DROP/RENAME)。
211786
+ *
211787
+ * 仅扫描 pending 迁移对应的本地 .sql 文件;已 applied 的不扫描,避免误拦。
211788
+ * 读文件失败(缺文件/目录非法)视为无法确认破坏性,返回空——真正的存在性/
211789
+ * 格式校验交由引擎执行时处理,这里只在能确证破坏性时加门,避免与引擎报错重复。
211790
+ */
211791
+ function detectDestructiveMigrations(options) {
211792
+ const pending = extractPendingMigrations(options.plan);
211793
+ if (pending.length === 0) {
211794
+ return [];
211795
+ }
211796
+ const dbConfig = options.databaseConfig && typeof options.databaseConfig === "object"
211797
+ ? options.databaseConfig
211798
+ : undefined;
211799
+ const migrationsDir = resolveMigrationsDir(options.cwd, dbConfig?.migrations);
211800
+ if (!migrationsDir) {
211801
+ return [];
211802
+ }
211803
+ const hits = [];
211804
+ for (const migration of pending) {
211805
+ const file = node_path_1.default.join(migrationsDir, `${migration}.sql`);
211806
+ let sqlText;
211807
+ try {
211808
+ sqlText = node_fs_1.default.readFileSync(file, "utf-8");
211809
+ }
211810
+ catch {
211811
+ // 文件读不到:不在此处报错,交给引擎执行时给出一致错误
211812
+ continue;
211813
+ }
211814
+ const statements = (0, sql_risk_js_1.findDestructiveStatements)(sqlText);
211815
+ if (statements.length > 0) {
211816
+ hits.push({ migration, file, statements });
211817
+ }
211818
+ }
211819
+ return hits;
211820
+ }
211821
+ function registerDeployTools(server) {
211822
+ const cloudBaseOptions = server.cloudBaseOptions;
211823
+ const getManager = () => (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions });
211824
+ // 工具一:deployPlan —— 只读,预演部署计划(dry-run)
211825
+ server.registerTool?.("deployPlan", {
211826
+ title: "预演 CloudBase 声明式部署计划",
211827
+ description: "解析 cloudbaserc 并计算声明式部署计划(dry-run,不产生任何变更)。" +
211828
+ "这是 deployApply 的预演对仗工具:plan 计算、deployApply 执行同一份 cloudbaserc。" +
211829
+ "返回每个资源的动作分类:create=新建,update=覆盖更新,skip=无变更/不会执行," +
211830
+ "conflict=检测到冲突需中断,deploy=直传覆盖。" +
211831
+ "计划已按 yes 复算为「实际会发生的动作」:不传 yes=true 时,云端已存在的函数会标为 skip" +
211832
+ "(并在 declaredStatus 保留 update),与 deployApply 的实际执行结果一致,避免预演与执行相反。" +
211833
+ "\n适用边界:本工具用于项目级声明式编排(一份 cloudbaserc 统一 plan/apply);" +
211834
+ "单资源临时直传请用 manageFunctions/manageHosting/manageApps。" +
211835
+ "\n- cwd:项目根目录,默认当前工作目录" +
211836
+ "\n- mode:环境名,命中 envOverrides.<mode> 时合并对应的多环境覆盖配置" +
211837
+ "\n- envId:目标环境 ID,优先级高于 cloudbaserc 中的 envId;不传则用配置值或当前绑定环境" +
211838
+ "\n- only:仅计算指定资源类型的计划" +
211839
+ "\n- skip:跳过指定资源类型" +
211840
+ "\n- yes:与 deployApply 的 yes 对齐,用于复算已存在函数的有效动作。" +
211841
+ "true=预演为覆盖更新(update);false(默认)=预演为保守跳过(skip)",
211842
+ inputSchema: {
211843
+ cwd: zod_1.z
211844
+ .string()
211845
+ .optional()
211846
+ .describe("项目根目录,从此目录向下搜索 cloudbaserc;默认当前工作目录"),
211847
+ mode: zod_1.z
211848
+ .string()
211849
+ .optional()
211850
+ .describe("环境名(如 production/staging),命中 envOverrides.<mode> 时合并覆盖"),
211851
+ envId: zod_1.z
211852
+ .string()
211853
+ .optional()
211854
+ .describe("目标环境 ID,优先级高于 cloudbaserc 中的 envId;不传则用配置值或当前绑定环境"),
211855
+ only: zod_1.z
211856
+ .array(zod_1.z.enum(RESOURCE_TYPES))
211857
+ .optional()
211858
+ .describe("仅计算指定资源类型的计划,可选值:database/functions/app/hosting/gateway"),
211859
+ skip: zod_1.z
211860
+ .array(zod_1.z.enum(RESOURCE_TYPES))
211861
+ .optional()
211862
+ .describe("跳过指定资源类型,可选值:database/functions/app/hosting/gateway"),
211863
+ yes: zod_1.z
211864
+ .boolean()
211865
+ .optional()
211866
+ .describe("与 deployApply 的 yes 对齐,用于复算已存在函数的有效动作。" +
211867
+ "true=预演为覆盖更新;false(默认)=预演为保守跳过"),
211868
+ },
211869
+ annotations: {
211870
+ readOnlyHint: true,
211871
+ openWorldHint: true,
211872
+ category: "deploy",
211873
+ },
211874
+ }, async ({ cwd, mode, envId: envIdInput, only, skip, yes, }) => {
211875
+ try {
211876
+ const projectRoot = cwd ?? process.cwd();
211877
+ const config = await resolveDeployConfig({ cwd: projectRoot, mode });
211878
+ assertConfigValid(config);
211879
+ const envId = await resolveDeployEnvId({
211880
+ envId: envIdInput,
211881
+ config,
211882
+ cloudBaseOptions,
211883
+ });
211884
+ const manager = await getManager();
211885
+ const rawPlan = await manager.getDeployOrchestrator().deployPlan({
211886
+ config,
211887
+ envId,
211888
+ cwd: projectRoot,
211889
+ only,
211890
+ skip,
211891
+ dryRun: true,
211892
+ });
211893
+ // 按 yes 复算为「实际会发生的动作」,使预演与 deployApply 的执行结果一致
211894
+ const plan = reconcilePlanWithExecution(rawPlan, yes === true);
211895
+ return (0, json_content_js_1.jsonContent)(buildEnvelope({ cwd: projectRoot, mode: mode ?? null, envId, yes: yes === true, plan }, "已生成声明式部署计划"));
211896
+ }
211897
+ catch (error) {
211898
+ return (0, json_content_js_1.jsonContent)(buildErrorEnvelope(error));
211899
+ }
211900
+ });
211901
+ // 工具二:deployApply —— 写操作,执行声明式部署(本地形态的 apply,与 deployPlan 对仗)
211902
+ server.registerTool?.("deployApply", {
211903
+ title: "执行 CloudBase 声明式部署(本地 apply)",
211904
+ description: "解析 cloudbaserc 并按 database→functions→app→hosting→gateway 顺序执行声明式部署。" +
211905
+ "这是 deployPlan 的执行对仗工具(plan 预演 / deployApply 执行同一份 cloudbaserc)," +
211906
+ "属于本地形态的 apply(读本地 cloudbaserc 并在本地构建上传)," +
211907
+ "是会变更云端资源的写操作,必须显式传 confirm=true 才会执行。" +
211908
+ "建议先用 deployPlan 预演,确认计划无误后再执行。" +
211909
+ "\n适用边界:本工具用于项目级声明式编排(一份 cloudbaserc 统一 plan/apply);" +
211910
+ "单资源临时直传请用 manageFunctions/manageHosting/manageApps。" +
211911
+ "\n- confirm:必须显式传 true 才执行部署,否则直接拒绝" +
211912
+ "\n- confirmDestructive:当本次待执行的数据库迁移含破坏性语句(DROP/TRUNCATE/DELETE、" +
211913
+ "ALTER…DROP/RENAME)时,除 confirm 外还必须显式传 confirmDestructive=true 才会执行;" +
211914
+ "否则拒绝并列出命中的迁移与语句。无破坏性迁移时该参数不生效" +
211915
+ "\n- cwd:项目根目录,默认当前工作目录" +
211916
+ "\n- mode:环境名,命中 envOverrides.<mode> 时合并对应的多环境覆盖配置" +
211917
+ "\n- envId:目标环境 ID,优先级高于 cloudbaserc 中的 envId;不传则用配置值或当前绑定环境" +
211918
+ "\n- only:仅部署指定资源类型" +
211919
+ "\n- skip:跳过指定资源类型" +
211920
+ "\n- yes:遇到已存在资源时的处理方式。true=直接覆盖更新;false(默认)=保守跳过," +
211921
+ "在无法交互确认的场景下已存在资源不会被覆盖(与 deployPlan 的 yes 语义一致)" +
211922
+ "\n- concurrency:同类型资源最大并行数,默认 1(串行)" +
211923
+ "\n- continueOnError:某个资源失败后继续部署其余资源(database 失败仍强制中断)",
211924
+ inputSchema: {
211925
+ confirm: zod_1.z
211926
+ .boolean()
211927
+ .optional()
211928
+ .describe("危险操作确认开关。部署会变更云端资源,必须显式传 confirm=true 才会执行"),
211929
+ confirmDestructive: zod_1.z
211930
+ .boolean()
211931
+ .optional()
211932
+ .describe("破坏性数据库变更确认开关。当待执行迁移含 DROP/TRUNCATE/DELETE 或 ALTER…DROP/RENAME 时," +
211933
+ "必须在 confirm=true 之外额外显式传 confirmDestructive=true;无破坏性迁移时不生效"),
211934
+ cwd: zod_1.z
211935
+ .string()
211936
+ .optional()
211937
+ .describe("项目根目录,从此目录向下搜索 cloudbaserc;默认当前工作目录"),
211938
+ mode: zod_1.z
211939
+ .string()
211940
+ .optional()
211941
+ .describe("环境名(如 production/staging),命中 envOverrides.<mode> 时合并覆盖"),
211942
+ envId: zod_1.z
211943
+ .string()
211944
+ .optional()
211945
+ .describe("目标环境 ID,优先级高于 cloudbaserc 中的 envId;不传则用配置值或当前绑定环境"),
211946
+ only: zod_1.z
211947
+ .array(zod_1.z.enum(RESOURCE_TYPES))
211948
+ .optional()
211949
+ .describe("仅部署指定资源类型,可选值:database/functions/app/hosting/gateway"),
211950
+ skip: zod_1.z
211951
+ .array(zod_1.z.enum(RESOURCE_TYPES))
211952
+ .optional()
211953
+ .describe("跳过指定资源类型,可选值:database/functions/app/hosting/gateway"),
211954
+ yes: zod_1.z
211955
+ .boolean()
211956
+ .optional()
211957
+ .describe("遇到已存在资源时是否直接覆盖更新。true=覆盖;false(默认)=保守跳过已存在资源"),
211958
+ concurrency: zod_1.z
211959
+ .number()
211960
+ .int()
211961
+ .min(1)
211962
+ .optional()
211963
+ .describe("同类型资源最大并行数,默认 1(串行);仅作用于同类型资源,跨类型依赖顺序不变"),
211964
+ continueOnError: zod_1.z
211965
+ .boolean()
211966
+ .optional()
211967
+ .describe("某个资源失败后是否继续部署其余资源;database 失败始终强制中断"),
211968
+ },
211969
+ annotations: {
211970
+ readOnlyHint: false,
211971
+ destructiveHint: true,
211972
+ openWorldHint: true,
211973
+ category: "deploy",
211974
+ },
211975
+ }, async ({ confirm, confirmDestructive, cwd, mode, envId: envIdInput, only, skip, yes, concurrency, continueOnError, }) => {
211976
+ try {
211977
+ if (confirm !== true) {
211978
+ throw new DeployError(exports.DEPLOY_ERROR_CODES.CONFIRM_REQUIRED, "部署会变更云端资源,必须显式传 confirm=true 才会执行。" +
211979
+ "建议先用 deployPlan 预演部署计划,确认无误后再执行。");
211980
+ }
211981
+ const projectRoot = cwd ?? process.cwd();
211982
+ const config = await resolveDeployConfig({ cwd: projectRoot, mode });
211983
+ assertConfigValid(config);
211984
+ const envId = await resolveDeployEnvId({
211985
+ envId: envIdInput,
211986
+ config,
211987
+ cloudBaseOptions,
211988
+ });
211989
+ const manager = await getManager();
211990
+ const orchestrator = manager.getDeployOrchestrator();
211991
+ // 破坏性数据库变更门:仅当 database 参与本次部署时,先 dry-run 取 pending 迁移,
211992
+ // 检测破坏性语句;命中且未额外确认则拒绝,独立于总 confirm 之外多一道门。
211993
+ const databaseParticipates = !!config.database &&
211994
+ (!only || only.includes("database")) &&
211995
+ !(skip ?? []).includes("database");
211996
+ if (databaseParticipates && confirmDestructive !== true) {
211997
+ const dryRunPlan = await orchestrator.deployPlan({
211998
+ config,
211999
+ envId,
212000
+ cwd: projectRoot,
212001
+ only,
212002
+ skip,
212003
+ dryRun: true,
212004
+ });
212005
+ const destructive = detectDestructiveMigrations({
212006
+ plan: Array.isArray(dryRunPlan) ? dryRunPlan : [],
212007
+ cwd: projectRoot,
212008
+ databaseConfig: config.database,
212009
+ });
212010
+ if (destructive.length > 0) {
212011
+ throw new DeployError(exports.DEPLOY_ERROR_CODES.DESTRUCTIVE_CONFIRM_REQUIRED, "本次待执行的数据库迁移包含破坏性语句(DROP/TRUNCATE/DELETE 或 ALTER…DROP/RENAME)," +
212012
+ "可能造成数据/结构不可逆丢失。请先备份或复核,确认后额外传 confirmDestructive=true 再执行。" +
212013
+ "命中迁移:" +
212014
+ destructive
212015
+ .map((d) => `${d.migration}(${d.statements.length} 条破坏性语句)`)
212016
+ .join(";"));
212017
+ }
212018
+ }
212019
+ const result = await orchestrator.deploy({
212020
+ config,
212021
+ envId,
212022
+ cwd: projectRoot,
212023
+ only,
212024
+ skip,
212025
+ yes: yes === true,
212026
+ concurrency: normalizeConcurrency(concurrency),
212027
+ continueOnError,
212028
+ });
212029
+ return (0, json_content_js_1.jsonContent)(buildEnvelope({ cwd: projectRoot, mode: mode ?? null, envId, result }, "声明式部署已执行"));
212030
+ }
212031
+ catch (error) {
212032
+ return (0, json_content_js_1.jsonContent)(buildErrorEnvelope(error));
212033
+ }
212034
+ });
212035
+ }
212036
+
212037
+
211836
212038
  /***/ },
211837
212039
 
211838
212040
  /***/ 27528
@@ -213937,7 +214139,7 @@ function registerEnvTools(server) {
213937
214139
  oauthCustom: zod_1.z
213938
214140
  .boolean()
213939
214141
  .optional()
213940
- .describe("高级可选:自定义 endpoint 返回格式开关。未配置 endpoint 时默认 false;配置 endpoint 后默认 true,且不能设为 false"),
214142
+ .describe("高级可选:自定义 endpoint 返回格式开关。未配置 endpoint 时默认 false;配置 endpoint 后默认 true。标准 {code,result} 包装格式的端点(如国际站 tcb-api.tencentcloud.com)应显式传 false"),
213941
214143
  }
213942
214144
  : {}),
213943
214145
  envId: zod_1.z
@@ -214182,19 +214384,15 @@ function registerEnvTools(server) {
214182
214384
  }
214183
214385
  };
214184
214386
  try {
214185
- // 启动 Device Flow,全流程由 toolbox 负责轮询和写入 credential,这里不等待完成
214387
+ // 启动 Device Flow,全流程由 toolbox 负责轮询和写入 credential,这里不等待完成。
214388
+ // 登录参数(含 TCB_SITE=intl 端点覆写与授权页改写)与 ensureLogin 共享同一 helper,
214389
+ // 避免此直连路径绕过国际站改写导致国际站账号拿到的仍是国内站链接
214186
214390
  auth
214187
214391
  .loginByWebAuth({
214188
- flow: "device",
214189
- ...(resolvedAuthOptions.clientId
214190
- ? { client_id: resolvedAuthOptions.clientId }
214191
- : {}),
214192
- ...(resolvedAuthOptions.oauthEndpoint
214193
- ? { getOAuthEndpoint: () => resolvedAuthOptions.oauthEndpoint }
214194
- : {}),
214195
- ...(resolvedAuthOptions.oauthCustom
214196
- ? { custom: true }
214197
- : {}),
214392
+ ...(0, auth_js_1.buildDeviceLoginOptions)(resolvedAuthOptions, {
214393
+ region,
214394
+ site: server.cloudBaseOptions?.site,
214395
+ }),
214198
214396
  onDeviceCode: deviceOnCode,
214199
214397
  })
214200
214398
  .then(async () => {
@@ -224094,7 +224292,7 @@ function registerSetupTools(server) {
224094
224292
  server.registerTool("downloadTemplate", {
224095
224293
  title: "下载项目模板",
224096
224294
  description: `自动下载并部署CloudBase项目模板。
224097
- **Note**: Call this tool when the user requests to create a new project using a CloudBase template.\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- 其他IDE类型见下方列表\n\n注意:如果未传入 ide 参数且无法从环境变量检测到 IDE,将提示错误并要求传入 ide 参数\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- kiro: Kiro AI编辑器\n- aider: Aider AI编辑器\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.33.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
224295
+ **Note**: Call this tool when the user requests to create a new project using a CloudBase template.\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- 其他IDE类型见下方列表\n\n注意:如果未传入 ide 参数且无法从环境变量检测到 IDE,将提示错误并要求传入 ide 参数\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- kiro: Kiro AI编辑器\n- aider: Aider AI编辑器\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.33.2" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
224098
224296
  inputSchema: {
224099
224297
  template: zod_1.z
224100
224298
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
@@ -225072,6 +225270,7 @@ function registerPGStorageTools(server) {
225072
225270
  "use strict";
225073
225271
 
225074
225272
  Object.defineProperty(exports, "__esModule", ({ value: true }));
225273
+ exports.CLOUD_INCOMPATIBLE_ACTION_LEVEL_EXCEPTIONS = exports.CLOUD_INCOMPATIBLE_TOOLS = void 0;
225075
225274
  exports.isCloudMode = isCloudMode;
225076
225275
  exports.enableCloudMode = enableCloudMode;
225077
225276
  exports.getCloudModeStatus = getCloudModeStatus;
@@ -225117,6 +225316,65 @@ function getCloudModeStatus() {
225117
225316
  }
225118
225317
  return { enabled: false, source: null };
225119
225318
  }
225319
+ /**
225320
+ * Tools that are incompatible with cloud mode because they read from or write to
225321
+ * the local filesystem (uploads, downloads, config files, or building an upload
225322
+ * artifact from `process.cwd()`). In cloud mode these top-level tools are not
225323
+ * registered at all; where a tool has both cloud-safe and local-only actions,
225324
+ * gating happens at the action level inside the tool instead (see
225325
+ * `ensureActionAllowedInCloudMode` in functions.ts / hosting.ts).
225326
+ *
225327
+ * IMPORTANT: keep this list in sync with the tools actually registered. Entries
225328
+ * that no longer match a registered tool name are dead (they silently gate
225329
+ * nothing). `CLOUD_INCOMPATIBLE_TOOLS.test.ts` asserts every entry here maps to
225330
+ * a known tool or a documented action-level exception to prevent silent rot.
225331
+ */
225332
+ exports.CLOUD_INCOMPATIBLE_TOOLS = [
225333
+ // Auth tools - local file uploads
225334
+ 'auth',
225335
+ // Storage tools - local file uploads / downloads.
225336
+ // NOTE: `uploadFile` is not a top-level tool name (storage upload is exposed
225337
+ // via `manageStorage`); kept here as a documented action-level exception.
225338
+ 'uploadFile',
225339
+ 'manageStorage',
225340
+ // Function tools - local code uploads.
225341
+ // NOTE: createFunction / updateFunctionCode are now actions of `manageFunctions`,
225342
+ // not top-level tools, so gating them here is a no-op kept for documentation.
225343
+ // The real cloud-mode guard for those actions lives in
225344
+ // functions.ts#ensureActionAllowedInCloudMode. Left here intentionally so the
225345
+ // sync test flags them as "action-level exceptions" rather than removing the
225346
+ // record of why they are not top-level tools.
225347
+ 'updateFunctionCode',
225348
+ 'createFunction',
225349
+ // Declarative deploy tools - read local cloudbaserc and build the upload
225350
+ // artifact from cwd (process.cwd() when no cwd is passed). Same class as the
225351
+ // function/upload tools above: they have no meaning without a local project.
225352
+ 'deployApply',
225353
+ 'deployPlan',
225354
+ // Download tools - local file downloads
225355
+ 'downloadTemplate',
225356
+ // Setup tools - local config file operations.
225357
+ // NOTE: `setupEnvironmentId` is not a top-level tool name; kept as a documented
225358
+ // action-level exception (env binding is handled via `auth`/setup flows).
225359
+ 'setupEnvironmentId',
225360
+ // CloudRun tools - local file operations
225361
+ 'manageCloudRun',
225362
+ // manageApps is intentionally NOT listed: deployApp with localPath/filePath is
225363
+ // blocked per-action in apps.ts (CLOUD_MODE_UNSUPPORTED_ACTION) so cloud mode
225364
+ // can still use getUploadUrl + cosTimestamp, deleteApp, and deleteAppVersion.
225365
+ ];
225366
+ /**
225367
+ * Tool names that appear in CLOUD_INCOMPATIBLE_TOOLS for documentation but are no
225368
+ * longer registered as top-level tools (their cloud gating is enforced at the
225369
+ * action level instead). The sync test treats these as expected, everything else
225370
+ * must resolve to a registered tool.
225371
+ */
225372
+ exports.CLOUD_INCOMPATIBLE_ACTION_LEVEL_EXCEPTIONS = [
225373
+ 'createFunction',
225374
+ 'updateFunctionCode',
225375
+ 'uploadFile',
225376
+ 'setupEnvironmentId',
225377
+ ];
225120
225378
  /**
225121
225379
  * Check if a tool should be registered in cloud mode
225122
225380
  * @param toolName - The name of the tool
@@ -225127,29 +225385,7 @@ function shouldRegisterTool(toolName) {
225127
225385
  if (!isCloudMode()) {
225128
225386
  return true;
225129
225387
  }
225130
- // Cloud-incompatible tools that involve local file operations
225131
- const cloudIncompatibleTools = [
225132
- // Auth tools - local file uploads
225133
- 'auth',
225134
- // Storage tools - local file uploads
225135
- 'uploadFile',
225136
- // Hosting tools - action-level cloud gating is handled inside manageHosting
225137
- // Function tools - local code uploads
225138
- 'updateFunctionCode',
225139
- 'createFunction', // also involves local files
225140
- // Download tools - local file downloads
225141
- 'downloadTemplate',
225142
- // Setup tools - local config file operations
225143
- 'setupEnvironmentId',
225144
- // CloudRun tools - local file operations
225145
- 'manageCloudRun',
225146
- // Download tools - local file downloads
225147
- 'manageStorage',
225148
- // manageApps is intentionally NOT listed: deployApp with localPath/filePath is
225149
- // blocked per-action in apps.ts (CLOUD_MODE_UNSUPPORTED_ACTION) so cloud mode
225150
- // can still use getUploadUrl + cosTimestamp, deleteApp, and deleteAppVersion.
225151
- ];
225152
- return !cloudIncompatibleTools.includes(toolName);
225388
+ return !exports.CLOUD_INCOMPATIBLE_TOOLS.includes(toolName);
225153
225389
  }
225154
225390
 
225155
225391
 
@@ -226309,6 +226545,163 @@ function resolveSiteAndRegion(opts = {}) {
226309
226545
  }
226310
226546
 
226311
226547
 
226548
+ /***/ },
226549
+
226550
+ /***/ 29885
226551
+ (__unused_webpack_module, exports) {
226552
+
226553
+ "use strict";
226554
+
226555
+ /**
226556
+ * Shared SQL risk heuristics.
226557
+ *
226558
+ * Extracted from databasePG.ts so both the interactive PG execute path and the
226559
+ * declarative deploy path classify destructive SQL with the *same* rules,
226560
+ * avoiding drift between two independent detectors.
226561
+ *
226562
+ * These are conservative lexical heuristics, not a full SQL parser: they strip
226563
+ * leading comments, read the leading verb, and match destructive keywords. They
226564
+ * are meant to decide whether an *extra* human confirmation is warranted, not to
226565
+ * be a security boundary.
226566
+ */
226567
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
226568
+ exports.stripLeadingSqlComments = stripLeadingSqlComments;
226569
+ exports.getSqlVerb = getSqlVerb;
226570
+ exports.isDestructiveSql = isDestructiveSql;
226571
+ exports.splitSqlStatements = splitSqlStatements;
226572
+ exports.findDestructiveStatements = findDestructiveStatements;
226573
+ /** Strip leading line (`--`, `#`) and block (`/* *​/`) comments and whitespace. */
226574
+ function stripLeadingSqlComments(sql) {
226575
+ let normalized = sql.trim();
226576
+ while (normalized.length > 0) {
226577
+ if (normalized.startsWith("--")) {
226578
+ normalized = normalized.replace(/^--.*(?:\r?\n|$)/, "").trimStart();
226579
+ continue;
226580
+ }
226581
+ if (normalized.startsWith("#")) {
226582
+ normalized = normalized.replace(/^#.*(?:\r?\n|$)/, "").trimStart();
226583
+ continue;
226584
+ }
226585
+ if (normalized.startsWith("/*")) {
226586
+ normalized = normalized.replace(/^\/\*[\s\S]*?\*\//, "").trimStart();
226587
+ continue;
226588
+ }
226589
+ break;
226590
+ }
226591
+ return normalized;
226592
+ }
226593
+ /** Return the leading SQL verb (uppercased), ignoring leading comments. */
226594
+ function getSqlVerb(sql) {
226595
+ const normalized = stripLeadingSqlComments(sql);
226596
+ const match = normalized.match(/^([a-zA-Z]+)/);
226597
+ return match ? match[1].toUpperCase() : "";
226598
+ }
226599
+ /**
226600
+ * Whether a *single* SQL statement is destructive (drops/truncates data or
226601
+ * removes/renames schema objects).
226602
+ */
226603
+ function isDestructiveSql(sql) {
226604
+ const normalized = stripLeadingSqlComments(sql);
226605
+ const verb = getSqlVerb(normalized);
226606
+ if (["DROP", "TRUNCATE", "DELETE"].includes(verb)) {
226607
+ return true;
226608
+ }
226609
+ if (verb === "ALTER") {
226610
+ return /\b(DROP|RENAME)\b/i.test(normalized);
226611
+ }
226612
+ return false;
226613
+ }
226614
+ /**
226615
+ * Split a possibly multi-statement SQL script into individual statements.
226616
+ *
226617
+ * Naive split on `;` at statement boundaries, but aware of single/double quotes,
226618
+ * line/block comments, and PostgreSQL dollar-quoted strings ($$ ... $$ or
226619
+ * $tag$ ... $tag$) so semicolons inside string bodies / function definitions do
226620
+ * not split a statement. Good enough for the conservative destructive scan; not
226621
+ * a full parser.
226622
+ */
226623
+ function splitSqlStatements(sqlText) {
226624
+ const statements = [];
226625
+ let current = "";
226626
+ let i = 0;
226627
+ const n = sqlText.length;
226628
+ while (i < n) {
226629
+ const ch = sqlText[i];
226630
+ const next = sqlText[i + 1];
226631
+ // line comment -- ... (to end of line)
226632
+ if (ch === "-" && next === "-") {
226633
+ const end = sqlText.indexOf("\n", i);
226634
+ const stop = end === -1 ? n : end + 1;
226635
+ current += sqlText.slice(i, stop);
226636
+ i = stop;
226637
+ continue;
226638
+ }
226639
+ // block comment /* ... */
226640
+ if (ch === "/" && next === "*") {
226641
+ const end = sqlText.indexOf("*/", i + 2);
226642
+ const stop = end === -1 ? n : end + 2;
226643
+ current += sqlText.slice(i, stop);
226644
+ i = stop;
226645
+ continue;
226646
+ }
226647
+ // single- or double-quoted string
226648
+ if (ch === "'" || ch === '"') {
226649
+ const quote = ch;
226650
+ current += ch;
226651
+ i += 1;
226652
+ while (i < n) {
226653
+ current += sqlText[i];
226654
+ // handle escaped quote by doubling ('' or "")
226655
+ if (sqlText[i] === quote) {
226656
+ if (sqlText[i + 1] === quote) {
226657
+ current += sqlText[i + 1];
226658
+ i += 2;
226659
+ continue;
226660
+ }
226661
+ i += 1;
226662
+ break;
226663
+ }
226664
+ i += 1;
226665
+ }
226666
+ continue;
226667
+ }
226668
+ // dollar-quoted string: $$ ... $$ or $tag$ ... $tag$
226669
+ if (ch === "$") {
226670
+ const tagMatch = sqlText.slice(i).match(/^\$([a-zA-Z_][a-zA-Z0-9_]*)?\$/);
226671
+ if (tagMatch) {
226672
+ const tag = tagMatch[0];
226673
+ const end = sqlText.indexOf(tag, i + tag.length);
226674
+ const stop = end === -1 ? n : end + tag.length;
226675
+ current += sqlText.slice(i, stop);
226676
+ i = stop;
226677
+ continue;
226678
+ }
226679
+ }
226680
+ if (ch === ";") {
226681
+ if (current.trim().length > 0) {
226682
+ statements.push(current.trim());
226683
+ }
226684
+ current = "";
226685
+ i += 1;
226686
+ continue;
226687
+ }
226688
+ current += ch;
226689
+ i += 1;
226690
+ }
226691
+ if (current.trim().length > 0) {
226692
+ statements.push(current.trim());
226693
+ }
226694
+ return statements;
226695
+ }
226696
+ /**
226697
+ * Scan a (possibly multi-statement) SQL script and return the destructive
226698
+ * statements found. Empty array means no destructive statement detected.
226699
+ */
226700
+ function findDestructiveStatements(sqlText) {
226701
+ return splitSqlStatements(sqlText).filter((stmt) => isDestructiveSql(stmt));
226702
+ }
226703
+
226704
+
226312
226705
  /***/ },
226313
226706
 
226314
226707
  /***/ 5198
@@ -226323,12 +226716,14 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
226323
226716
  exports.reportToolkitLifecycle = exports.reportToolCall = exports.telemetryReporter = void 0;
226324
226717
  exports.extractMcpClientInfo = extractMcpClientInfo;
226325
226718
  exports.readMcpClientInfoFromServer = readMcpClientInfoFromServer;
226719
+ exports.normalizeClientName = normalizeClientName;
226326
226720
  const crypto_1 = __importDefault(__webpack_require__(55511));
226327
226721
  const http_1 = __importDefault(__webpack_require__(81630));
226328
226722
  const https_1 = __importDefault(__webpack_require__(55591));
226329
226723
  const os_1 = __importDefault(__webpack_require__(21820));
226330
226724
  const cloudbase_manager_js_1 = __webpack_require__(33109);
226331
226725
  const logger_js_1 = __webpack_require__(40781);
226726
+ const site_map_js_1 = __webpack_require__(34533);
226332
226727
  /**
226333
226728
  * 数据上报类
226334
226729
  * 用于收集 MCP 工具使用情况和错误信息,帮助改进产品
@@ -226358,6 +226753,12 @@ class TelemetryReporter {
226358
226753
  this.addAdditionalParams({ ide: process.env.INTEGRATION_IDE });
226359
226754
  (0, logger_js_1.debug)('检测到 IDE 集成环境', { ide: process.env.INTEGRATION_IDE });
226360
226755
  }
226756
+ // 检查 CLOUDBASE_MCP_CLIENT 环境变量(hosted 场景由上游解析真实 MCP client 后注入)
226757
+ const envClient = normalizeClientName(process.env.CLOUDBASE_MCP_CLIENT);
226758
+ if (envClient) {
226759
+ this.addAdditionalParams({ client: envClient });
226760
+ (0, logger_js_1.debug)('检测到 MCP client 标识', { client: envClient });
226761
+ }
226361
226762
  (0, logger_js_1.debug)('report_init', {
226362
226763
  enabled: this.enabled,
226363
226764
  deviceId: this.deviceId.substring(0, 8) + '...',
@@ -226375,7 +226776,7 @@ class TelemetryReporter {
226375
226776
  const arch = os_1.default.arch(); // 系统架构
226376
226777
  // Build-time injected version; guard for vitest / non-webpack runtimes.
226377
226778
  const mcpVersion = process.env.npm_package_version ||
226378
- ( true ? "2.33.0" : 0);
226779
+ ( true ? "2.33.2" : 0);
226379
226780
  return {
226380
226781
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
226381
226782
  deviceId: this.deviceId,
@@ -226586,6 +226987,58 @@ function readMcpClientInfoFromServer(server) {
226586
226987
  return {};
226587
226988
  }
226588
226989
  }
226990
+ /**
226991
+ * Normalize upstream-provided client identifier into a telemetry-safe token:
226992
+ * trim + lowercase + keep [a-z0-9-_] only + cap at 64 chars.
226993
+ * Canonical mapping (cursor-vscode -> cursor etc.) is the upstream's responsibility;
226994
+ * we only sanitize. Returns undefined when nothing usable remains.
226995
+ */
226996
+ function normalizeClientName(value) {
226997
+ if (typeof value !== "string") {
226998
+ return undefined;
226999
+ }
227000
+ const cleaned = value
227001
+ .trim()
227002
+ .toLowerCase()
227003
+ .replace(/[^a-z0-9_-]/g, "")
227004
+ .slice(0, 64);
227005
+ return cleaned || undefined;
227006
+ }
227007
+ // 进程内缓存 site/region 解析结果(resolveSiteAndRegion 会读项目配置文件,避免每次工具调用都走 IO)
227008
+ let cachedSiteRegion = null;
227009
+ /**
227010
+ * Resolve region/site for telemetry.
227011
+ * Priority: cloudBaseOptions(会话实际使用值)> resolveSiteAndRegion(env/项目配置解析,进程内缓存)。
227012
+ * 失败时降级 unknown,绝不影响工具调用主链路。
227013
+ */
227014
+ function resolveTelemetrySiteRegion(cloudBaseOptions) {
227015
+ const explicitRegion = cloudBaseOptions?.region;
227016
+ const explicitSite = (0, site_map_js_1.normalizeSite)(cloudBaseOptions?.site);
227017
+ try {
227018
+ if (!cachedSiteRegion) {
227019
+ const resolved = (0, site_map_js_1.resolveSiteAndRegion)();
227020
+ cachedSiteRegion = { site: resolved.site, region: resolved.region };
227021
+ }
227022
+ return {
227023
+ region: explicitRegion || cachedSiteRegion.region,
227024
+ site: explicitSite || cachedSiteRegion.site,
227025
+ };
227026
+ }
227027
+ catch (err) {
227028
+ (0, logger_js_1.debug)('解析 site/region 失败,遥测使用 unknown', err instanceof Error ? err : new Error(String(err)));
227029
+ return {
227030
+ region: explicitRegion || 'unknown',
227031
+ site: explicitSite || 'unknown',
227032
+ };
227033
+ }
227034
+ }
227035
+ /**
227036
+ * Resolve MCP client identifier for a single report:
227037
+ * explicit param (server.client) > CLOUDBASE_MCP_CLIENT env (hosted upstream injection).
227038
+ */
227039
+ function resolveClientName(explicit) {
227040
+ return normalizeClientName(explicit || process.env.CLOUDBASE_MCP_CLIENT);
227041
+ }
226589
227042
  function appendMcpClientInfoFields(eventData, clientInfo) {
226590
227043
  if (!clientInfo) {
226591
227044
  return;
@@ -226605,6 +227058,7 @@ const reportToolCall = async (params) => {
226605
227058
  const { nodeVersion, osType, osRelease, arch, mcpVersion } = exports.telemetryReporter.getUserAgent();
226606
227059
  // 安全获取环境ID,优先使用传入的配置
226607
227060
  const { envId, envIdSource } = resolveEnvId(params.cloudBaseOptions);
227061
+ const siteRegion = resolveTelemetrySiteRegion(params.cloudBaseOptions);
226608
227062
  (0, logger_js_1.debug)('[telemetry] 工具调用 envId 获取结果', {
226609
227063
  toolName: params.toolName,
226610
227064
  envId,
@@ -226620,6 +227074,8 @@ const reportToolCall = async (params) => {
226620
227074
  duration: params.duration !== undefined ? String(params.duration) : undefined,
226621
227075
  error: params.error ? params.error.substring(0, 200) : undefined, // 限制错误信息长度
226622
227076
  envId: envId || 'unknown',
227077
+ region: siteRegion.region,
227078
+ site: siteRegion.site,
226623
227079
  nodeVersion,
226624
227080
  osType,
226625
227081
  osRelease,
@@ -226644,6 +227100,11 @@ const reportToolCall = async (params) => {
226644
227100
  if (params.ide) {
226645
227101
  eventData.ide = params.ide;
226646
227102
  }
227103
+ // 添加 MCP client 标识(如果提供)
227104
+ const client = resolveClientName(params.client);
227105
+ if (client) {
227106
+ eventData.client = client;
227107
+ }
226647
227108
  appendMcpClientInfoFields(eventData, params.mcpClientInfo);
226648
227109
  // Debug: 打印最终上报参数
226649
227110
  (0, logger_js_1.debug)('[telemetry] 工具调用上报参数', {
@@ -226663,6 +227124,7 @@ const reportToolkitLifecycle = async (params) => {
226663
227124
  const { nodeVersion, osType, osRelease, arch, mcpVersion } = exports.telemetryReporter.getUserAgent();
226664
227125
  // 安全获取环境ID,优先使用传入的配置
226665
227126
  const { envId, envIdSource } = resolveEnvId(params.cloudBaseOptions);
227127
+ const siteRegion = resolveTelemetrySiteRegion(params.cloudBaseOptions);
226666
227128
  (0, logger_js_1.debug)('[telemetry] 生命周期事件 envId 获取结果', {
226667
227129
  event: params.event,
226668
227130
  envId,
@@ -226677,6 +227139,8 @@ const reportToolkitLifecycle = async (params) => {
226677
227139
  exitCode: params.exitCode !== undefined ? String(params.exitCode) : undefined,
226678
227140
  error: params.error ? params.error.substring(0, 200) : undefined, // 限制错误信息长度
226679
227141
  envId: envId || 'unknown',
227142
+ region: siteRegion.region,
227143
+ site: siteRegion.site,
226680
227144
  nodeVersion,
226681
227145
  osType,
226682
227146
  osRelease,
@@ -226687,6 +227151,11 @@ const reportToolkitLifecycle = async (params) => {
226687
227151
  if (params.ide) {
226688
227152
  eventData.ide = params.ide;
226689
227153
  }
227154
+ // 添加 MCP client 标识(如果提供)
227155
+ const lifecycleClient = resolveClientName(params.client);
227156
+ if (lifecycleClient) {
227157
+ eventData.client = lifecycleClient;
227158
+ }
226690
227159
  appendMcpClientInfoFields(eventData, params.mcpClientInfo);
226691
227160
  // Debug: 打印最终上报参数
226692
227161
  (0, logger_js_1.debug)('[telemetry] 生命周期事件上报参数', {
@@ -226900,7 +227369,7 @@ ${envIdSection}
226900
227369
  ## 环境信息
226901
227370
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
226902
227371
  - Node.js版本: ${process.version}
226903
- - MCP 版本:${process.env.npm_package_version || ( true ? "2.33.0" : 0)}
227372
+ - MCP 版本:${process.env.npm_package_version || ( true ? "2.33.2" : 0)}
226904
227373
  - 系统架构: ${os_1.default.arch()}
226905
227374
  - 时间: ${new Date().toISOString()}
226906
227375
  - 请求ID: ${requestId}
@@ -226989,7 +227458,7 @@ function createWrappedHandler(name, handler, server) {
226989
227458
  requestId,
226990
227459
  ide: server.ide || process.env.INTEGRATION_IDE || ''
226991
227460
  });
226992
- const mcpVersion = true ? "2.33.0" : 0;
227461
+ const mcpVersion = true ? "2.33.2" : 0;
226993
227462
  const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
226994
227463
  const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
226995
227464
  // 创建新的错误对象,保持原有的错误类型但更新消息
@@ -227027,6 +227496,7 @@ function createWrappedHandler(name, handler, server) {
227027
227496
  inputParams: sanitizeArgs(args), // 添加入参上报
227028
227497
  cloudBaseOptions: cloudBaseOptions, // 传递 CloudBase 配置(可能已更新)
227029
227498
  ide: server.ide || process.env.INTEGRATION_IDE, // 传递集成IDE信息
227499
+ client: server.client || process.env.CLOUDBASE_MCP_CLIENT, // 传递 MCP client 来源标识
227030
227500
  mcpClientInfo: (0, telemetry_js_1.readMcpClientInfoFromServer)(server),
227031
227501
  }).catch(err => {
227032
227502
  // 静默处理上报错误,不影响主要功能