@cloudbase/cloudbase-mcp 2.11.1 → 2.12.1

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
@@ -106,6 +106,7 @@ const archiver_1 = __importDefault(__webpack_require__(99133));
106
106
  const fs_extra_1 = __webpack_require__(21605);
107
107
  const path_1 = __importDefault(__webpack_require__(39902));
108
108
  const utils_1 = __webpack_require__(62358);
109
+ const type_1 = __webpack_require__(59411);
109
110
  /**
110
111
  * 云托管服务管理类
111
112
  * 提供云托管服务的初始化、下载、列表查询和删除等功能
@@ -195,6 +196,97 @@ class CloudRunService {
195
196
  ServerType: params === null || params === void 0 ? void 0 : params.serverType
196
197
  }));
197
198
  }
199
+ /**
200
+ *
201
+ * @param serverName 云托管服务名
202
+ * @param stablePercent 稳定版本流量比例
203
+ * @param canaryPercent 灰度版本流量比例
204
+ * @returns 灰度发布进度
205
+ */
206
+ async setTraffic(serverName, stablePercent, canaryPercent) {
207
+ // 校验比例之和是否为100%
208
+ if (stablePercent + canaryPercent !== 100) {
209
+ throw new Error('稳定版本流量比例和灰度版本流量比例之和必须等于 100');
210
+ }
211
+ const envConfig = this.environment.lazyEnvironmentConfig;
212
+ const { Task } = await this.tcbrService.request('DescribeServerManageTask', {
213
+ EnvId: envConfig.EnvId,
214
+ ServerName: serverName, // 服务名
215
+ TaskId: 0 // 任务Id
216
+ });
217
+ // 判断是否存在灰度版本
218
+ const isGary = (Task === null || Task === void 0 ? void 0 : Task.ReleaseType) === type_1.ReleaseTypeEnum.GRAY && (Task === null || Task === void 0 ? void 0 : Task.Status) === 'running';
219
+ if (!isGary) {
220
+ throw new Error('不存在灰度中的版本或灰度版本部署未完成');
221
+ }
222
+ // 获取当前版本和灰度版本
223
+ const { ReleaseOrderInfo } = await this.tcbrService.request('DescribeReleaseOrder', {
224
+ EnvId: envConfig.EnvId, // 环境 Id
225
+ ServerName: serverName // 服务名
226
+ });
227
+ const { CurrentVersion, ReleaseVersion } = ReleaseOrderInfo;
228
+ // 设置版本比例
229
+ return await this.tcbrService.request('ReleaseGray', {
230
+ EnvId: envConfig.EnvId, // 环境 Id
231
+ ServerName: serverName, // 服务名
232
+ GrayType: "gray",
233
+ TrafficType: "FLOW",
234
+ GrayFlowRatio: canaryPercent,
235
+ VersionFlowItems: [{
236
+ VersionName: CurrentVersion.VersionName,
237
+ FlowRatio: stablePercent,
238
+ IsDefaultPriority: true,
239
+ Priority: 1,
240
+ }, {
241
+ VersionName: ReleaseVersion.VersionName,
242
+ FlowRatio: canaryPercent,
243
+ IsDefaultPriority: false,
244
+ Priority: 2,
245
+ }]
246
+ });
247
+ }
248
+ /**
249
+ *
250
+ * @param serverName 云托管服务名
251
+ * @returns 发布结果
252
+ */
253
+ async promote(serverName) {
254
+ const envConfig = this.environment.lazyEnvironmentConfig;
255
+ // 获取当前版本和灰度版本
256
+ const { ReleaseOrderInfo } = await this.tcbrService.request('DescribeReleaseOrder', {
257
+ EnvId: envConfig.EnvId, // 环境 Id
258
+ ServerName: serverName // 服务名
259
+ });
260
+ const { ReleaseVersion } = ReleaseOrderInfo;
261
+ return await this.tcbrService.request('ReleaseGray', {
262
+ EnvId: envConfig.EnvId, // 环境 Id
263
+ ServerName: serverName, // 服务名
264
+ GrayType: "gray",
265
+ TrafficType: "FLOW",
266
+ GrayFlowRatio: 100,
267
+ VersionFlowItems: [{ VersionName: ReleaseVersion.VersionName, FlowRatio: 100, Priority: 0, IsDefaultPriority: true }],
268
+ CloseGrayRelease: true,
269
+ });
270
+ }
271
+ /**
272
+ *
273
+ * @param serverName 云托管服务名
274
+ * @returns 回滚结果
275
+ */
276
+ async rollback(serverName) {
277
+ const envConfig = this.environment.lazyEnvironmentConfig;
278
+ const { Task } = await this.tcbrService.request('DescribeServerManageTask', {
279
+ EnvId: envConfig.EnvId,
280
+ ServerName: serverName, // 服务名
281
+ TaskId: 0 // 任务Id
282
+ });
283
+ return await this.tcbrService.request('OperateServerManage', {
284
+ EnvId: envConfig.EnvId, // 环境 Id
285
+ ServerName: serverName,
286
+ TaskId: Task.Id,
287
+ OperateType: 'go_back',
288
+ });
289
+ }
198
290
  /**
199
291
  *查询云托管服务详情
200
292
  * @param {Object} params 查询参数
@@ -203,10 +295,11 @@ class CloudRunService {
203
295
  */
204
296
  async detail(params) {
205
297
  const envConfig = this.environment.lazyEnvironmentConfig;
206
- return this.tcbrService.request('DescribeCloudRunServerDetail', {
298
+ const res = await this.tcbrService.request('DescribeCloudRunServerDetail', {
207
299
  EnvId: envConfig.EnvId,
208
300
  ServerName: params.serverName
209
301
  });
302
+ return res;
210
303
  }
211
304
  /**
212
305
  * 删除指定的云托管服务
@@ -246,6 +339,7 @@ class CloudRunService {
246
339
  * @returns {Promise<IResponseInfo>} 返回部署操作的响应信息
247
340
  */
248
341
  async deploy(params) {
342
+ var _a;
249
343
  const { serverName, targetPath = process.cwd(), serverConfig } = params;
250
344
  /**
251
345
  * 参数校验和默认值设置
@@ -294,7 +388,7 @@ class CloudRunService {
294
388
  RepoLanguage: 'Node.js'
295
389
  };
296
390
  }
297
- deployInfo.ReleaseType = 'FULL';
391
+ deployInfo.ReleaseType = ((_a = params.deployInfo) === null || _a === void 0 ? void 0 : _a.ReleaseType) || "FULL";
298
392
  return this._upsertFunction(false, {
299
393
  name: serverName,
300
394
  deployInfo,
@@ -351,6 +445,7 @@ class CloudRunService {
351
445
  }
352
446
  catch (e) {
353
447
  if (e.code === 'ResourceNotFound' ||
448
+ e.code === 'ResourceNotFound.ServerNotFound' ||
354
449
  // 备注:以下条件当 NotFound 处理(已与 fisheryan 确认过)
355
450
  (e.code === 'InvalidParameter' && e.original.Message === 'service data illegal')) {
356
451
  return false;
@@ -369,6 +464,40 @@ class CloudRunService {
369
464
  Items,
370
465
  });
371
466
  }
467
+ /**
468
+ * 获取部署记录列表,按部署时间倒序(最新在前)
469
+ */
470
+ async getDeployRecords(params) {
471
+ const envConfig = this.environment.lazyEnvironmentConfig;
472
+ const res = await this.tcbrService.request('DescribeCloudRunDeployRecord', {
473
+ EnvId: envConfig.EnvId,
474
+ ServerName: params.serverName,
475
+ });
476
+ res.DeployRecords.sort((a, b) => new Date(b.DeployTime).getTime() - new Date(a.DeployTime).getTime());
477
+ return res;
478
+ }
479
+ async getBuildLog(params) {
480
+ const envConfig = this.environment.lazyEnvironmentConfig;
481
+ let buildId = params.buildId;
482
+ if (!buildId) {
483
+ const sortedRes = await this.getDeployRecords({ serverName: params.serverName });
484
+ buildId = sortedRes.DeployRecords[0].BuildId;
485
+ }
486
+ return this.tcbrService.request('DescribeCloudRunBuildLog', {
487
+ EnvId: envConfig.EnvId,
488
+ ServerName: params.serverName,
489
+ ServerVersion: '',
490
+ BuildId: buildId,
491
+ Offset: 0,
492
+ });
493
+ }
494
+ async getProcessLog(params) {
495
+ const envConfig = this.environment.lazyEnvironmentConfig;
496
+ return this.tcbrService.request('DescribeCloudRunProcessLog', {
497
+ EnvId: envConfig.EnvId,
498
+ RunId: params.RunId,
499
+ });
500
+ }
372
501
  }
373
502
  exports.CloudRunService = CloudRunService;
374
503
  __decorate([
@@ -380,6 +509,15 @@ __decorate([
380
509
  __decorate([
381
510
  (0, utils_1.preLazy)()
382
511
  ], CloudRunService.prototype, "list", null);
512
+ __decorate([
513
+ (0, utils_1.preLazy)()
514
+ ], CloudRunService.prototype, "setTraffic", null);
515
+ __decorate([
516
+ (0, utils_1.preLazy)()
517
+ ], CloudRunService.prototype, "promote", null);
518
+ __decorate([
519
+ (0, utils_1.preLazy)()
520
+ ], CloudRunService.prototype, "rollback", null);
383
521
  __decorate([
384
522
  (0, utils_1.preLazy)()
385
523
  ], CloudRunService.prototype, "detail", null);
@@ -389,6 +527,15 @@ __decorate([
389
527
  __decorate([
390
528
  (0, utils_1.preLazy)()
391
529
  ], CloudRunService.prototype, "deploy", null);
530
+ __decorate([
531
+ (0, utils_1.preLazy)()
532
+ ], CloudRunService.prototype, "getDeployRecords", null);
533
+ __decorate([
534
+ (0, utils_1.preLazy)()
535
+ ], CloudRunService.prototype, "getBuildLog", null);
536
+ __decorate([
537
+ (0, utils_1.preLazy)()
538
+ ], CloudRunService.prototype, "getProcessLog", null);
392
539
  async function codeToZip(cwd, options) {
393
540
  const archive = (0, archiver_1.default)('zip', {
394
541
  zlib: { level: 1 } // 保持与之前相同的压缩级别
@@ -27903,7 +28050,8 @@ const error_1 = __webpack_require__(40430);
27903
28050
  const os = __importStar(__webpack_require__(21820));
27904
28051
  // 10 MB
27905
28052
  exports.BIG_FILE_SIZE = 10485760;
27906
- exports.API_MAX_SIZE = 52428800;
28053
+ // ZipFile 上传最大 1.5MB
28054
+ exports.API_MAX_SIZE = 1.5 * 1024 * 1024;
27907
28055
  var CodeType;
27908
28056
  (function (CodeType) {
27909
28057
  CodeType[CodeType["File"] = 0] = "File";
@@ -27944,6 +28092,7 @@ class FunctionPacker {
27944
28092
  zipOption.pattern = this.incrementalPath;
27945
28093
  }
27946
28094
  await (0, utils_1.compressToZip)(zipOption);
28095
+ return this.zipFilePath;
27947
28096
  }
27948
28097
  // 获取 Java 代码
27949
28098
  getJavaFile() {
@@ -27991,7 +28140,7 @@ class FunctionPacker {
27991
28140
  const fileStats = await promiseStat(this.zipFilePath);
27992
28141
  return fileStats.size > exports.BIG_FILE_SIZE;
27993
28142
  }
27994
- // API 最大 50MB
28143
+ // ZipFile 上传最大 1.5MB
27995
28144
  async isReachMaxSize() {
27996
28145
  if (!this.zipFilePath) {
27997
28146
  await this.build();
@@ -35586,7 +35735,7 @@ function registerSecurityRuleTools(server) {
35586
35735
  .describe("资源类型:noSqlDatabase=noSQL 数据库,sqlDatabase=SQL 数据库,function=云函数,storage=存储桶"),
35587
35736
  resourceId: zod_1.z
35588
35737
  .string()
35589
- .describe("资源唯一标识。noSQL 数据库为集合名,SQL 数据库为表名,云函数为函数名,存储为桶名。"),
35738
+ .describe("资源唯一标识。noSQL 数据库为集合名,SQL 数据库为表名,云函数为函数名,存储为桶名(完整格式如 '6169-xxx-1257473911',可通过 envQuery action=info 获取 EnvInfo.Storages[].Bucket)。"),
35590
35739
  },
35591
35740
  annotations: {
35592
35741
  readOnlyHint: true,
@@ -35651,6 +35800,8 @@ function registerSecurityRuleTools(server) {
35651
35800
  type: "text",
35652
35801
  text: JSON.stringify({
35653
35802
  success: true,
35803
+ resourceType,
35804
+ resourceId,
35654
35805
  aclTag: result.AclTag,
35655
35806
  rule: result.Rule ?? null,
35656
35807
  raw: result,
@@ -35670,7 +35821,7 @@ function registerSecurityRuleTools(server) {
35670
35821
  .describe("资源类型:sqlDatabase=SQL 数据库,noSqlDatabase=noSQL 数据库,function=云函数,storage=存储桶"),
35671
35822
  resourceId: zod_1.z
35672
35823
  .string()
35673
- .describe("资源唯一标识。sqlDatabase=表名,noSqlDatabase=集合名,云函数为函数名,存储为桶名。"),
35824
+ .describe("资源唯一标识。sqlDatabase=表名,noSqlDatabase=集合名,云函数为函数名,存储为桶名(完整格式如 '6169-xxx-1257473911',可通过 envQuery action=info 获取 EnvInfo.Storages[].Bucket)。"),
35674
35825
  aclTag: zod_1.z
35675
35826
  .enum(["READONLY", "PRIVATE", "ADMINWRITE", "ADMINONLY", "CUSTOM"])
35676
35827
  .describe("权限类别"),
@@ -89257,20 +89408,22 @@ exports.TRIGGER_CONFIG_EXAMPLES = exports.SUPPORTED_TRIGGER_TYPES = exports.DEFA
89257
89408
  exports.registerFunctionTools = registerFunctionTools;
89258
89409
  const zod_1 = __webpack_require__(21614);
89259
89410
  const cloudbase_manager_js_1 = __webpack_require__(3431);
89411
+ const logger_js_1 = __webpack_require__(13039);
89260
89412
  const path_1 = __importDefault(__webpack_require__(39902));
89261
89413
  // 支持的 Node.js 运行时列表
89262
89414
  exports.SUPPORTED_NODEJS_RUNTIMES = [
89263
- 'Nodejs18.15',
89264
- 'Nodejs16.13',
89265
- 'Nodejs14.18',
89266
- 'Nodejs12.16',
89267
- 'Nodejs10.15',
89268
- 'Nodejs8.9',
89415
+ "Nodejs20.19",
89416
+ "Nodejs18.15",
89417
+ "Nodejs16.13",
89418
+ "Nodejs14.18",
89419
+ "Nodejs12.16",
89420
+ "Nodejs10.15",
89421
+ "Nodejs8.9",
89269
89422
  ];
89270
- exports.DEFAULT_NODEJS_RUNTIME = 'Nodejs18.15';
89423
+ exports.DEFAULT_NODEJS_RUNTIME = "Nodejs18.15";
89271
89424
  // Supported trigger types
89272
89425
  exports.SUPPORTED_TRIGGER_TYPES = [
89273
- 'timer', // Timer trigger
89426
+ "timer", // Timer trigger
89274
89427
  ];
89275
89428
  // Trigger configuration examples
89276
89429
  exports.TRIGGER_CONFIG_EXAMPLES = {
@@ -89281,8 +89434,8 @@ exports.TRIGGER_CONFIG_EXAMPLES = {
89281
89434
  "0 30 9 * * * *", // Execute at 9:30 AM every day
89282
89435
  "0 0 12 * * * *", // Execute at 12:00 PM every day
89283
89436
  "0 0 0 1 1 * *", // Execute at midnight on January 1st every year
89284
- ]
89285
- }
89437
+ ],
89438
+ },
89286
89439
  };
89287
89440
  /**
89288
89441
  * 处理函数根目录路径,确保不包含函数名
@@ -89313,18 +89466,27 @@ function registerFunctionTools(server) {
89313
89466
  title: "查询云函数列表或详情",
89314
89467
  description: "获取云函数列表或单个函数详情。通过 action 参数区分操作类型:list=获取函数列表(默认,无需额外参数),detail=获取函数详情(需要提供 name 参数指定函数名称)",
89315
89468
  inputSchema: {
89316
- action: zod_1.z.enum(["list", "detail"]).optional().describe("操作类型:list=获取函数列表(默认,无需额外参数),detail=获取函数详情(需要提供 name 参数)"),
89469
+ action: zod_1.z
89470
+ .enum(["list", "detail"])
89471
+ .optional()
89472
+ .describe("操作类型:list=获取函数列表(默认,无需额外参数),detail=获取函数详情(需要提供 name 参数)"),
89317
89473
  limit: zod_1.z.number().optional().describe("范围(list 操作时使用)"),
89318
89474
  offset: zod_1.z.number().optional().describe("偏移(list 操作时使用)"),
89319
- name: zod_1.z.string().optional().describe("要查询的函数名称。当 action='detail' 时,此参数为必填项,必须提供已存在的函数名称。可通过 action='list' 操作获取可用的函数名称列表"),
89320
- codeSecret: zod_1.z.string().optional().describe("代码保护密钥(detail 操作时使用)")
89475
+ name: zod_1.z
89476
+ .string()
89477
+ .optional()
89478
+ .describe("要查询的函数名称。当 action='detail' 时,此参数为必填项,必须提供已存在的函数名称。可通过 action='list' 操作获取可用的函数名称列表"),
89479
+ codeSecret: zod_1.z
89480
+ .string()
89481
+ .optional()
89482
+ .describe("代码保护密钥(detail 操作时使用)"),
89321
89483
  },
89322
89484
  annotations: {
89323
89485
  readOnlyHint: true,
89324
89486
  openWorldHint: true,
89325
- category: "functions"
89326
- }
89327
- }, async ({ action = "list", limit, offset, name, codeSecret }) => {
89487
+ category: "functions",
89488
+ },
89489
+ }, async ({ action = "list", limit, offset, name, codeSecret, }) => {
89328
89490
  // 使用闭包中的 cloudBaseOptions
89329
89491
  const cloudbase = await getManager();
89330
89492
  if (action === "list") {
@@ -89334,9 +89496,9 @@ function registerFunctionTools(server) {
89334
89496
  content: [
89335
89497
  {
89336
89498
  type: "text",
89337
- text: JSON.stringify(result, null, 2)
89338
- }
89339
- ]
89499
+ text: JSON.stringify(result, null, 2),
89500
+ },
89501
+ ],
89340
89502
  };
89341
89503
  }
89342
89504
  else if (action === "detail") {
@@ -89349,9 +89511,9 @@ function registerFunctionTools(server) {
89349
89511
  content: [
89350
89512
  {
89351
89513
  type: "text",
89352
- text: JSON.stringify(result, null, 2)
89353
- }
89354
- ]
89514
+ text: JSON.stringify(result, null, 2),
89515
+ },
89516
+ ],
89355
89517
  };
89356
89518
  }
89357
89519
  else {
@@ -89361,59 +89523,115 @@ function registerFunctionTools(server) {
89361
89523
  // createFunction - 创建云函数 (cloud-incompatible)
89362
89524
  server.registerTool("createFunction", {
89363
89525
  title: "创建云函数",
89364
- description: "创建云函数",
89526
+ description: "创建云函数。云函数分为事件型云函数和 HTTP 云函数,请确认你要创建的函数类型。",
89365
89527
  inputSchema: {
89366
- func: zod_1.z.object({
89528
+ func: zod_1.z
89529
+ .object({
89367
89530
  name: zod_1.z.string().describe("函数名称"),
89531
+ type: zod_1.z
89532
+ .enum(["Event", "HTTP"])
89533
+ .optional()
89534
+ .describe("函数类型,Event 为事件型云函数,HTTP 为 HTTP 云函数"),
89535
+ protocolType: zod_1.z
89536
+ .enum(["HTTP", "WS"])
89537
+ .optional()
89538
+ .describe("HTTP 云函数的协议类型,HTTP 为 HTTP 协议(默认),WS 为 WebSocket 协议,仅当 type 为 HTTP 时有效"),
89539
+ protocolParams: zod_1.z
89540
+ .object({
89541
+ wsParams: zod_1.z
89542
+ .object({
89543
+ idleTimeOut: zod_1.z.number().optional().describe("WebSocket 空闲超时时间(秒),默认 15 秒"),
89544
+ })
89545
+ .optional()
89546
+ .describe("WebSocket 协议参数"),
89547
+ })
89548
+ .optional()
89549
+ .describe("协议参数配置,仅当 protocolType 为 WS 时有效"),
89550
+ instanceConcurrencyConfig: zod_1.z
89551
+ .object({
89552
+ dynamicEnabled: zod_1.z.boolean().optional().describe("是否启用动态并发,默认 false"),
89553
+ maxConcurrency: zod_1.z.number().optional().describe("最大并发数,默认 10"),
89554
+ })
89555
+ .optional()
89556
+ .describe("多并发配置,仅当 type 为 HTTP 时有效"),
89368
89557
  timeout: zod_1.z.number().optional().describe("函数超时时间"),
89369
89558
  envVariables: zod_1.z.record(zod_1.z.string()).optional().describe("环境变量"),
89370
- vpc: zod_1.z.object({
89559
+ vpc: zod_1.z
89560
+ .object({
89371
89561
  vpcId: zod_1.z.string(),
89372
- subnetId: zod_1.z.string()
89373
- }).optional().describe("私有网络配置"),
89374
- runtime: zod_1.z.string().optional().describe("运行时环境,建议指定为 'Nodejs18.15',其他可选值:" + exports.SUPPORTED_NODEJS_RUNTIMES.join(',')),
89375
- triggers: zod_1.z.array(zod_1.z.object({
89562
+ subnetId: zod_1.z.string(),
89563
+ })
89564
+ .optional()
89565
+ .describe("私有网络配置"),
89566
+ runtime: zod_1.z
89567
+ .string()
89568
+ .optional()
89569
+ .describe("运行时环境,建议指定为 'Nodejs18.15',其他可选值:" +
89570
+ exports.SUPPORTED_NODEJS_RUNTIMES.join(",")),
89571
+ triggers: zod_1.z
89572
+ .array(zod_1.z.object({
89376
89573
  name: zod_1.z.string().describe("Trigger name"),
89377
- type: zod_1.z.enum(exports.SUPPORTED_TRIGGER_TYPES).describe("Trigger type, currently only supports 'timer'"),
89378
- config: zod_1.z.string().describe("Trigger configuration. For timer triggers, use cron expression format: second minute hour day month week year. IMPORTANT: Must include exactly 7 fields (second minute hour day month week year). Examples: '0 0 2 1 * * *' (monthly), '0 30 9 * * * *' (daily at 9:30 AM)")
89379
- })).optional().describe("Trigger configuration array"),
89574
+ type: zod_1.z
89575
+ .enum(exports.SUPPORTED_TRIGGER_TYPES)
89576
+ .describe("Trigger type, currently only supports 'timer'"),
89577
+ config: zod_1.z
89578
+ .string()
89579
+ .describe("Trigger configuration. For timer triggers, use cron expression format: second minute hour day month week year. IMPORTANT: Must include exactly 7 fields (second minute hour day month week year). Examples: '0 0 2 1 * * *' (monthly), '0 30 9 * * * *' (daily at 9:30 AM)"),
89580
+ }))
89581
+ .optional()
89582
+ .describe("Trigger configuration array"),
89380
89583
  handler: zod_1.z.string().optional().describe("函数入口"),
89381
- ignore: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional().describe("忽略文件"),
89584
+ ignore: zod_1.z
89585
+ .union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())])
89586
+ .optional()
89587
+ .describe("忽略文件"),
89382
89588
  isWaitInstall: zod_1.z.boolean().optional().describe("是否等待依赖安装"),
89383
- layers: zod_1.z.array(zod_1.z.object({
89589
+ layers: zod_1.z
89590
+ .array(zod_1.z.object({
89384
89591
  name: zod_1.z.string(),
89385
- version: zod_1.z.number()
89386
- })).optional().describe("Layer配置")
89387
- }).describe("函数配置"),
89388
- functionRootPath: zod_1.z.string().optional().describe("函数根目录(云函数目录的父目录),这里需要传操作系统上文件的绝对路径,注意:不要包含函数名本身,例如函数名为 'hello',应传入 '/path/to/cloudfunctions',而不是 '/path/to/cloudfunctions/hello'"),
89389
- force: zod_1.z.boolean().describe("是否覆盖")
89592
+ version: zod_1.z.number(),
89593
+ }))
89594
+ .optional()
89595
+ .describe("Layer配置"),
89596
+ })
89597
+ .describe("函数配置"),
89598
+ functionRootPath: zod_1.z
89599
+ .string()
89600
+ .optional()
89601
+ .describe("函数根目录(云函数目录的父目录),这里需要传操作系统上文件的绝对路径,注意:不要包含函数名本身,例如函数名为 'hello',应传入 '/path/to/cloudfunctions',而不是 '/path/to/cloudfunctions/hello'"),
89602
+ force: zod_1.z.boolean().describe("是否覆盖"),
89390
89603
  },
89391
89604
  annotations: {
89392
89605
  readOnlyHint: false,
89393
89606
  destructiveHint: false,
89394
89607
  idempotentHint: false,
89395
89608
  openWorldHint: true,
89396
- category: "functions"
89397
- }
89398
- }, async ({ func, functionRootPath, force }) => {
89399
- // 自动填充默认 runtime
89400
- if (!func.runtime) {
89401
- func.runtime = exports.DEFAULT_NODEJS_RUNTIME;
89402
- }
89403
- else {
89404
- // 验证 runtime 格式,防止常见的空格问题
89405
- const normalizedRuntime = func.runtime.replace(/\s+/g, '');
89406
- if (exports.SUPPORTED_NODEJS_RUNTIMES.includes(normalizedRuntime)) {
89407
- func.runtime = normalizedRuntime;
89609
+ category: "functions",
89610
+ },
89611
+ }, async ({ func, functionRootPath, force, }) => {
89612
+ (0, logger_js_1.debug)(`[createFunction] name=${func.name}, type=${func.type || "Event"}`);
89613
+ // HTTP 云函数跳过 runtime 验证,Event 云函数进行验证
89614
+ const isHttpFunction = func.type === "HTTP";
89615
+ if (!isHttpFunction) {
89616
+ // 自动填充默认 runtime
89617
+ if (!func.runtime) {
89618
+ func.runtime = exports.DEFAULT_NODEJS_RUNTIME;
89408
89619
  }
89409
- else if (func.runtime.includes(' ')) {
89410
- console.warn(`检测到 runtime 参数包含空格: "${func.runtime}",已自动移除空格`);
89411
- func.runtime = normalizedRuntime;
89620
+ else {
89621
+ // 验证 runtime 格式,防止常见的空格问题
89622
+ const normalizedRuntime = func.runtime.replace(/\s+/g, "");
89623
+ if (exports.SUPPORTED_NODEJS_RUNTIMES.includes(normalizedRuntime)) {
89624
+ func.runtime = normalizedRuntime;
89625
+ }
89626
+ else if (func.runtime.includes(" ")) {
89627
+ console.warn(`检测到 runtime 参数包含空格: "${func.runtime}",已自动移除空格`);
89628
+ func.runtime = normalizedRuntime;
89629
+ }
89630
+ }
89631
+ // 验证 runtime 是否有效
89632
+ if (!exports.SUPPORTED_NODEJS_RUNTIMES.includes(func.runtime)) {
89633
+ throw new Error(`不支持的运行时环境: "${func.runtime}"。支持的值:${exports.SUPPORTED_NODEJS_RUNTIMES.join(", ")}`);
89412
89634
  }
89413
- }
89414
- // 验证 runtime 是否有效
89415
- if (!exports.SUPPORTED_NODEJS_RUNTIMES.includes(func.runtime)) {
89416
- throw new Error(`不支持的运行时环境: "${func.runtime}"。支持的值:${exports.SUPPORTED_NODEJS_RUNTIMES.join(', ')}`);
89417
89635
  }
89418
89636
  // 强制设置 installDependency 为 true(不暴露给AI)
89419
89637
  func.installDependency = true;
@@ -89424,16 +89642,16 @@ function registerFunctionTools(server) {
89424
89642
  const result = await cloudbase.functions.createFunction({
89425
89643
  func,
89426
89644
  functionRootPath: processedRootPath,
89427
- force
89645
+ force,
89428
89646
  });
89429
89647
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
89430
89648
  return {
89431
89649
  content: [
89432
89650
  {
89433
89651
  type: "text",
89434
- text: JSON.stringify(result, null, 2)
89435
- }
89436
- ]
89652
+ text: JSON.stringify(result, null, 2),
89653
+ },
89654
+ ],
89437
89655
  };
89438
89656
  });
89439
89657
  // updateFunctionCode - 更新函数代码 (cloud-incompatible)
@@ -89442,7 +89660,9 @@ function registerFunctionTools(server) {
89442
89660
  description: "更新已存在函数的代码。注意:此工具仅用于更新代码,不支持修改函数配置(如 runtime)。如果需要修改 runtime,需要删除函数后使用 createFunction 重新创建。",
89443
89661
  inputSchema: {
89444
89662
  name: zod_1.z.string().describe("函数名称"),
89445
- functionRootPath: zod_1.z.string().describe("函数根目录(云函数目录的父目录),这里需要传操作系统上文件的绝对路径"),
89663
+ functionRootPath: zod_1.z
89664
+ .string()
89665
+ .describe("函数根目录(云函数目录的父目录),这里需要传操作系统上文件的绝对路径"),
89446
89666
  // zipFile: z.string().optional().describe("Base64编码的函数包"),
89447
89667
  // handler: z.string().optional().describe("函数入口"),
89448
89668
  // runtime: z.string().optional().describe("运行时(可选值:" + SUPPORTED_NODEJS_RUNTIMES.join(',') + ",默认 Nodejs 18.15)")
@@ -89452,9 +89672,9 @@ function registerFunctionTools(server) {
89452
89672
  destructiveHint: false,
89453
89673
  idempotentHint: false,
89454
89674
  openWorldHint: true,
89455
- category: "functions"
89456
- }
89457
- }, async ({ name, functionRootPath, zipFile, handler }) => {
89675
+ category: "functions",
89676
+ },
89677
+ }, async ({ name, functionRootPath, zipFile, handler, }) => {
89458
89678
  // 处理函数根目录路径,确保不包含函数名
89459
89679
  const processedRootPath = processFunctionRootPath(functionRootPath, name);
89460
89680
  // 构建更新参数,强制设置 installDependency 为 true(不暴露给AI)
@@ -89463,9 +89683,9 @@ function registerFunctionTools(server) {
89463
89683
  func: {
89464
89684
  name,
89465
89685
  installDependency: true,
89466
- ...(handler && { handler })
89686
+ ...(handler && { handler }),
89467
89687
  },
89468
- functionRootPath: processedRootPath
89688
+ functionRootPath: processedRootPath,
89469
89689
  };
89470
89690
  // 如果提供了zipFile,则添加到参数中
89471
89691
  if (zipFile) {
@@ -89479,9 +89699,9 @@ function registerFunctionTools(server) {
89479
89699
  content: [
89480
89700
  {
89481
89701
  type: "text",
89482
- text: JSON.stringify(result, null, 2)
89483
- }
89484
- ]
89702
+ text: JSON.stringify(result, null, 2),
89703
+ },
89704
+ ],
89485
89705
  };
89486
89706
  });
89487
89707
  // updateFunctionConfig - 更新函数配置
@@ -89489,24 +89709,29 @@ function registerFunctionTools(server) {
89489
89709
  title: "更新云函数配置",
89490
89710
  description: "更新云函数配置",
89491
89711
  inputSchema: {
89492
- funcParam: zod_1.z.object({
89712
+ funcParam: zod_1.z
89713
+ .object({
89493
89714
  name: zod_1.z.string().describe("函数名称"),
89494
89715
  timeout: zod_1.z.number().optional().describe("超时时间"),
89495
89716
  envVariables: zod_1.z.record(zod_1.z.string()).optional().describe("环境变量"),
89496
- vpc: zod_1.z.object({
89717
+ vpc: zod_1.z
89718
+ .object({
89497
89719
  vpcId: zod_1.z.string(),
89498
- subnetId: zod_1.z.string()
89499
- }).optional().describe("VPC配置"),
89720
+ subnetId: zod_1.z.string(),
89721
+ })
89722
+ .optional()
89723
+ .describe("VPC配置"),
89500
89724
  // runtime: z.string().optional().describe("运行时(可选值:" + SUPPORTED_NODEJS_RUNTIMES.join(',') + ",默认 Nodejs 18.15)")
89501
- }).describe("函数配置")
89725
+ })
89726
+ .describe("函数配置"),
89502
89727
  },
89503
89728
  annotations: {
89504
89729
  readOnlyHint: false,
89505
89730
  destructiveHint: false,
89506
89731
  idempotentHint: false,
89507
89732
  openWorldHint: true,
89508
- category: "functions"
89509
- }
89733
+ category: "functions",
89734
+ },
89510
89735
  }, async ({ funcParam }) => {
89511
89736
  // 自动填充默认 runtime
89512
89737
  // if (!funcParam.runtime) {
@@ -89516,10 +89741,15 @@ function registerFunctionTools(server) {
89516
89741
  const cloudbase = await getManager();
89517
89742
  const functionDetail = await cloudbase.functions.getFunctionDetail(funcParam.name);
89518
89743
  functionDetail.Environment;
89519
- const vpc = (typeof functionDetail.VpcConfig === 'object' && functionDetail.VpcConfig !== null && functionDetail.VpcConfig.SubnetId && functionDetail.VpcConfig.VpcId) ? {
89520
- subnetId: functionDetail.VpcConfig.SubnetId,
89521
- vpcId: functionDetail.VpcConfig.VpcId
89522
- } : undefined;
89744
+ const vpc = typeof functionDetail.VpcConfig === "object" &&
89745
+ functionDetail.VpcConfig !== null &&
89746
+ functionDetail.VpcConfig.SubnetId &&
89747
+ functionDetail.VpcConfig.VpcId
89748
+ ? {
89749
+ subnetId: functionDetail.VpcConfig.SubnetId,
89750
+ vpcId: functionDetail.VpcConfig.VpcId,
89751
+ }
89752
+ : undefined;
89523
89753
  const result = await cloudbase.functions.updateFunctionConfig({
89524
89754
  name: funcParam.name,
89525
89755
  envVariables: Object.assign({}, functionDetail.Environment.Variables.reduce((acc, curr) => {
@@ -89534,9 +89764,9 @@ function registerFunctionTools(server) {
89534
89764
  content: [
89535
89765
  {
89536
89766
  type: "text",
89537
- text: JSON.stringify(result, null, 2)
89538
- }
89539
- ]
89767
+ text: JSON.stringify(result, null, 2),
89768
+ },
89769
+ ],
89540
89770
  };
89541
89771
  });
89542
89772
  // invokeFunction - 调用函数
@@ -89545,16 +89775,16 @@ function registerFunctionTools(server) {
89545
89775
  description: "调用云函数",
89546
89776
  inputSchema: {
89547
89777
  name: zod_1.z.string().describe("函数名称"),
89548
- params: zod_1.z.record(zod_1.z.any()).optional().describe("调用参数")
89778
+ params: zod_1.z.record(zod_1.z.any()).optional().describe("调用参数"),
89549
89779
  },
89550
89780
  annotations: {
89551
89781
  readOnlyHint: false,
89552
89782
  destructiveHint: false,
89553
89783
  idempotentHint: false,
89554
89784
  openWorldHint: true,
89555
- category: "functions"
89556
- }
89557
- }, async ({ name, params }) => {
89785
+ category: "functions",
89786
+ },
89787
+ }, async ({ name, params, }) => {
89558
89788
  // 使用闭包中的 cloudBaseOptions
89559
89789
  try {
89560
89790
  const cloudbase = await getManager();
@@ -89564,13 +89794,13 @@ function registerFunctionTools(server) {
89564
89794
  content: [
89565
89795
  {
89566
89796
  type: "text",
89567
- text: JSON.stringify(result, null, 2)
89568
- }
89569
- ]
89797
+ text: JSON.stringify(result, null, 2),
89798
+ },
89799
+ ],
89570
89800
  };
89571
89801
  }
89572
89802
  catch (error) {
89573
- const errorMessage = (error instanceof Error ? error.message : String(error));
89803
+ const errorMessage = error instanceof Error ? error.message : String(error);
89574
89804
  if (errorMessage.includes("Function not found") ||
89575
89805
  errorMessage.includes("函数不存在")) {
89576
89806
  throw new Error(`${errorMessage}\n\n` +
@@ -89587,19 +89817,31 @@ function registerFunctionTools(server) {
89587
89817
  description: "获取云函数日志基础信息(LogList),如需日志详情请用 RequestId 调用 getFunctionLogDetail 工具。此接口基于 manger-node 4.4.0+ 的 getFunctionLogsV2 实现,不返回具体日志内容。参数 offset+limit 不得大于 10000,startTime/endTime 间隔不得超过一天。",
89588
89818
  inputSchema: {
89589
89819
  name: zod_1.z.string().describe("函数名称"),
89590
- offset: zod_1.z.number().optional().describe("数据的偏移量,Offset+Limit 不能大于 10000"),
89591
- limit: zod_1.z.number().optional().describe("返回数据的长度,Offset+Limit 不能大于 10000"),
89592
- startTime: zod_1.z.string().optional().describe("查询的具体日期,例如:2017-05-16 20:00:00,只能与 EndTime 相差一天之内"),
89593
- endTime: zod_1.z.string().optional().describe("查询的具体日期,例如:2017-05-16 20:59:59,只能与 StartTime 相差一天之内"),
89820
+ offset: zod_1.z
89821
+ .number()
89822
+ .optional()
89823
+ .describe("数据的偏移量,Offset+Limit 不能大于 10000"),
89824
+ limit: zod_1.z
89825
+ .number()
89826
+ .optional()
89827
+ .describe("返回数据的长度,Offset+Limit 不能大于 10000"),
89828
+ startTime: zod_1.z
89829
+ .string()
89830
+ .optional()
89831
+ .describe("查询的具体日期,例如:2017-05-16 20:00:00,只能与 EndTime 相差一天之内"),
89832
+ endTime: zod_1.z
89833
+ .string()
89834
+ .optional()
89835
+ .describe("查询的具体日期,例如:2017-05-16 20:59:59,只能与 StartTime 相差一天之内"),
89594
89836
  requestId: zod_1.z.string().optional().describe("执行该函数对应的 requestId"),
89595
- qualifier: zod_1.z.string().optional().describe("函数版本,默认为 $LATEST")
89837
+ qualifier: zod_1.z.string().optional().describe("函数版本,默认为 $LATEST"),
89596
89838
  },
89597
89839
  annotations: {
89598
89840
  readOnlyHint: true,
89599
89841
  openWorldHint: true,
89600
- category: "functions"
89601
- }
89602
- }, async ({ name, offset, limit, startTime, endTime, requestId, qualifier }) => {
89842
+ category: "functions",
89843
+ },
89844
+ }, async ({ name, offset, limit, startTime, endTime, requestId, qualifier, }) => {
89603
89845
  if ((offset || 0) + (limit || 0) > 10000) {
89604
89846
  throw new Error("offset+limit 不能大于 10000");
89605
89847
  }
@@ -89611,15 +89853,23 @@ function registerFunctionTools(server) {
89611
89853
  }
89612
89854
  }
89613
89855
  const cloudbase = await getManager();
89614
- const result = await cloudbase.functions.getFunctionLogsV2({ name, offset, limit, startTime, endTime, requestId, qualifier });
89856
+ const result = await cloudbase.functions.getFunctionLogsV2({
89857
+ name,
89858
+ offset,
89859
+ limit,
89860
+ startTime,
89861
+ endTime,
89862
+ requestId,
89863
+ qualifier,
89864
+ });
89615
89865
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
89616
89866
  return {
89617
89867
  content: [
89618
89868
  {
89619
89869
  type: "text",
89620
- text: JSON.stringify(result, null, 2)
89621
- }
89622
- ]
89870
+ text: JSON.stringify(result, null, 2),
89871
+ },
89872
+ ],
89623
89873
  };
89624
89874
  });
89625
89875
  // getFunctionLogDetail - 查询日志详情(参数直接展开)
@@ -89627,15 +89877,21 @@ function registerFunctionTools(server) {
89627
89877
  title: "获取云函数日志详情",
89628
89878
  description: "根据 getFunctionLogs 返回的 RequestId 查询日志详情。参数 startTime、endTime、requestId,返回日志内容(LogJson 等)。仅支持 manger-node 4.4.0+。",
89629
89879
  inputSchema: {
89630
- startTime: zod_1.z.string().optional().describe("查询的具体日期,例如:2017-05-16 20:00:00,只能与 EndTime 相差一天之内"),
89631
- endTime: zod_1.z.string().optional().describe("查询的具体日期,例如:2017-05-16 20:59:59,只能与 StartTime 相差一天之内"),
89632
- requestId: zod_1.z.string().describe("执行该函数对应的 requestId")
89880
+ startTime: zod_1.z
89881
+ .string()
89882
+ .optional()
89883
+ .describe("查询的具体日期,例如:2017-05-16 20:00:00,只能与 EndTime 相差一天之内"),
89884
+ endTime: zod_1.z
89885
+ .string()
89886
+ .optional()
89887
+ .describe("查询的具体日期,例如:2017-05-16 20:59:59,只能与 StartTime 相差一天之内"),
89888
+ requestId: zod_1.z.string().describe("执行该函数对应的 requestId"),
89633
89889
  },
89634
89890
  annotations: {
89635
89891
  readOnlyHint: true,
89636
89892
  openWorldHint: true,
89637
- category: "functions"
89638
- }
89893
+ category: "functions",
89894
+ },
89639
89895
  }, async ({ startTime, endTime, requestId }) => {
89640
89896
  if (startTime && endTime) {
89641
89897
  const start = new Date(startTime).getTime();
@@ -89648,16 +89904,16 @@ function registerFunctionTools(server) {
89648
89904
  const result = await cloudbase.functions.getFunctionLogDetail({
89649
89905
  startTime,
89650
89906
  endTime,
89651
- logRequestId: requestId
89907
+ logRequestId: requestId,
89652
89908
  });
89653
89909
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
89654
89910
  return {
89655
89911
  content: [
89656
89912
  {
89657
89913
  type: "text",
89658
- text: JSON.stringify(result, null, 2)
89659
- }
89660
- ]
89914
+ text: JSON.stringify(result, null, 2),
89915
+ },
89916
+ ],
89661
89917
  };
89662
89918
  });
89663
89919
  // manageFunctionTriggers - 管理云函数触发器(创建/删除)
@@ -89665,23 +89921,32 @@ function registerFunctionTools(server) {
89665
89921
  title: "管理云函数触发器",
89666
89922
  description: "创建或删除云函数触发器,通过 action 参数区分操作类型",
89667
89923
  inputSchema: {
89668
- action: zod_1.z.enum(["create", "delete"]).describe("操作类型:create=创建触发器,delete=删除触发器"),
89924
+ action: zod_1.z
89925
+ .enum(["create", "delete"])
89926
+ .describe("操作类型:create=创建触发器,delete=删除触发器"),
89669
89927
  name: zod_1.z.string().describe("函数名"),
89670
- triggers: zod_1.z.array(zod_1.z.object({
89928
+ triggers: zod_1.z
89929
+ .array(zod_1.z.object({
89671
89930
  name: zod_1.z.string().describe("Trigger name"),
89672
- type: zod_1.z.enum(exports.SUPPORTED_TRIGGER_TYPES).describe("Trigger type, currently only supports 'timer'"),
89673
- config: zod_1.z.string().describe("Trigger configuration. For timer triggers, use cron expression format: second minute hour day month week year. IMPORTANT: Must include exactly 7 fields (second minute hour day month week year). Examples: '0 0 2 1 * * *' (monthly), '0 30 9 * * * *' (daily at 9:30 AM)")
89674
- })).optional().describe("触发器配置数组(创建时必需)"),
89675
- triggerName: zod_1.z.string().optional().describe("触发器名称(删除时必需)")
89931
+ type: zod_1.z
89932
+ .enum(exports.SUPPORTED_TRIGGER_TYPES)
89933
+ .describe("Trigger type, currently only supports 'timer'"),
89934
+ config: zod_1.z
89935
+ .string()
89936
+ .describe("Trigger configuration. For timer triggers, use cron expression format: second minute hour day month week year. IMPORTANT: Must include exactly 7 fields (second minute hour day month week year). Examples: '0 0 2 1 * * *' (monthly), '0 30 9 * * * *' (daily at 9:30 AM)"),
89937
+ }))
89938
+ .optional()
89939
+ .describe("触发器配置数组(创建时必需)"),
89940
+ triggerName: zod_1.z.string().optional().describe("触发器名称(删除时必需)"),
89676
89941
  },
89677
89942
  annotations: {
89678
89943
  readOnlyHint: false,
89679
89944
  destructiveHint: false,
89680
89945
  idempotentHint: false,
89681
89946
  openWorldHint: true,
89682
- category: "functions"
89683
- }
89684
- }, async ({ action, name, triggers, triggerName }) => {
89947
+ category: "functions",
89948
+ },
89949
+ }, async ({ action, name, triggers, triggerName, }) => {
89685
89950
  // 使用闭包中的 cloudBaseOptions
89686
89951
  const cloudbase = await getManager();
89687
89952
  if (action === "create") {
@@ -89694,9 +89959,9 @@ function registerFunctionTools(server) {
89694
89959
  content: [
89695
89960
  {
89696
89961
  type: "text",
89697
- text: JSON.stringify(result, null, 2)
89698
- }
89699
- ]
89962
+ text: JSON.stringify(result, null, 2),
89963
+ },
89964
+ ],
89700
89965
  };
89701
89966
  }
89702
89967
  else if (action === "delete") {
@@ -89709,9 +89974,9 @@ function registerFunctionTools(server) {
89709
89974
  content: [
89710
89975
  {
89711
89976
  type: "text",
89712
- text: JSON.stringify(result, null, 2)
89713
- }
89714
- ]
89977
+ text: JSON.stringify(result, null, 2),
89978
+ },
89979
+ ],
89715
89980
  };
89716
89981
  }
89717
89982
  else {
@@ -92398,6 +92663,30 @@ class EnvService {
92398
92663
  EnvId: this.envId
92399
92664
  });
92400
92665
  }
92666
+ /**
92667
+ * 创建环境订单
92668
+ */
92669
+ async createBillingDeal(params) {
92670
+ return this.cloudService.request('CreateBillDeal', Object.assign({}, params));
92671
+ }
92672
+ /**
92673
+ * 取消未支付的订单
92674
+ */
92675
+ async cancelDeal(params) {
92676
+ return this.cloudService.request('CancelDeal', Object.assign({}, params));
92677
+ }
92678
+ /**
92679
+ * 删除已取消的订单
92680
+ */
92681
+ // public async deleteDeal(params: {
92682
+ // TranId: string
92683
+ // UserClientIp: string
92684
+ // WxAppId?: string
92685
+ // }) {
92686
+ // return this.cloudService.request<any>('DeleteDeal', {
92687
+ // ...params
92688
+ // })
92689
+ // }
92401
92690
  // 获取 COS CORS 域名
92402
92691
  async getCOSDomains() {
92403
92692
  const cos = this.getCos();
@@ -125717,7 +126006,7 @@ function registerCapiTools(server) {
125717
126006
  // static credentail = 'credential'
125718
126007
  // }
125719
126008
  Object.defineProperty(exports, "__esModule", ({ value: true }));
125720
- exports.COS_SDK_KEEPALIVE = exports.COS_SDK_PROTOCOL = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
126009
+ exports.SCF_TEMP_COS = exports.COS_SDK_KEEPALIVE = exports.COS_SDK_PROTOCOL = exports.INTERNAL_ENDPOINT_REGION = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
125721
126010
  exports.ENV_NAME = {
125722
126011
  ENV_SECRETID: 'TENCENTCLOUD_SECRETID',
125723
126012
  ENV_SECRETKEY: 'TENCENTCLOUD_SECRETKEY',
@@ -125769,8 +126058,22 @@ exports.SCF_STATUS = {
125769
126058
  };
125770
126059
  // 是否使用内网域名
125771
126060
  exports.USE_INTERNAL_ENDPOINT = "USE_INTERNAL_ENDPOINT" in process.env;
126061
+ exports.INTERNAL_ENDPOINT_REGION = process.env.INTERNAL_ENDPOINT_REGION;
125772
126062
  exports.COS_SDK_PROTOCOL = process.env.COS_SDK_PROTOCOL;
125773
126063
  exports.COS_SDK_KEEPALIVE = process.env.COS_SDK_KEEPALIVE;
126064
+ // SCF 临时 COS 配置(用于函数代码上传)
126065
+ exports.SCF_TEMP_COS = {
126066
+ APPID: '1253665819',
126067
+ // 区域前缀映射:region -> bucket 前缀
126068
+ REGION_PREFIX_MAP: {
126069
+ 'ap-shanghai': 'sh',
126070
+ 'ap-guangzhou': 'gz',
126071
+ 'ap-beijing': 'bj',
126072
+ 'ap-singapore': 'sg'
126073
+ },
126074
+ DEFAULT_REGION_PREFIX: 'sh',
126075
+ DEFAULT_REGION: 'ap-shanghai'
126076
+ };
125774
126077
 
125775
126078
 
125776
126079
  /***/ }),
@@ -137208,7 +137511,7 @@ class TelemetryReporter {
137208
137511
  const nodeVersion = process.version; // Node.js版本
137209
137512
  const arch = os_1.default.arch(); // 系统架构
137210
137513
  // 从构建时注入的版本号获取MCP版本信息
137211
- const mcpVersion = process.env.npm_package_version || "2.11.1" || 0;
137514
+ const mcpVersion = process.env.npm_package_version || "2.12.1" || 0;
137212
137515
  return {
137213
137516
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
137214
137517
  deviceId: this.deviceId,
@@ -157029,7 +157332,7 @@ class HostingService {
157029
157332
  * @param options
157030
157333
  */
157031
157334
  async uploadFiles(options) {
157032
- const { localPath, cloudPath, files = [], onProgress, onFileFinish, parallel = 20, ignore, retryCount, retryInterval } = options;
157335
+ const { localPath, cloudPath, files = [], onProgress, onFileFinish, parallel = 20, ignore = ['.DS_Store'], retryCount, retryInterval } = options;
157033
157336
  const hosting = await this.checkStatus();
157034
157337
  const { Bucket, Regoin } = hosting;
157035
157338
  const storageService = await this.environment.getStorageService();
@@ -176917,6 +177220,39 @@ function validation(yargs, usage, y18n) {
176917
177220
  exports.validation = validation;
176918
177221
 
176919
177222
 
177223
+ /***/ }),
177224
+
177225
+ /***/ 59411:
177226
+ /***/ ((__unused_webpack_module, exports) => {
177227
+
177228
+ "use strict";
177229
+
177230
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
177231
+ exports.ReleaseTypeEnum = exports.CloudrunServerType = void 0;
177232
+ var CloudrunServerType;
177233
+ (function (CloudrunServerType) {
177234
+ /**
177235
+ * 函数型服务
177236
+ */
177237
+ CloudrunServerType["Function"] = "function";
177238
+ /**
177239
+ * 容器型服务
177240
+ */
177241
+ CloudrunServerType["Container"] = "container";
177242
+ })(CloudrunServerType || (exports.CloudrunServerType = CloudrunServerType = {}));
177243
+ var ReleaseTypeEnum;
177244
+ (function (ReleaseTypeEnum) {
177245
+ /**
177246
+ * 灰度发布
177247
+ */
177248
+ ReleaseTypeEnum["GRAY"] = "GRAY";
177249
+ /**
177250
+ * 全量发布
177251
+ */
177252
+ ReleaseTypeEnum["FULL"] = "FULL";
177253
+ })(ReleaseTypeEnum || (exports.ReleaseTypeEnum = ReleaseTypeEnum = {}));
177254
+
177255
+
176920
177256
  /***/ }),
176921
177257
 
176922
177258
  /***/ 59527:
@@ -177055,6 +177391,7 @@ class Environment {
177055
177391
  this.cloudBaseContext = context;
177056
177392
  this.envType = context.envType;
177057
177393
  // 拉取当前环境 的环境信息 todo
177394
+ this.userService = new user_1.UserService(this);
177058
177395
  this.functionService = new function_1.FunctionService(this);
177059
177396
  this.cloudRunService = new cloudrun_1.CloudRunService(this);
177060
177397
  this.agentService = new agent_1.AgentService(this);
@@ -194050,7 +194387,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
194050
194387
  exports.CloudBaseContext = void 0;
194051
194388
  const constant_1 = __webpack_require__(40762);
194052
194389
  class CloudBaseContext {
194053
- constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined }) {
194390
+ constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined, internalEndpointRegion = undefined }) {
194054
194391
  this.secretId = secretId;
194055
194392
  this.secretKey = secretKey;
194056
194393
  this.token = token;
@@ -194058,10 +194395,14 @@ class CloudBaseContext {
194058
194395
  this.region = region;
194059
194396
  this.envType = envType;
194060
194397
  this.useInternalEndpoint = useInternalEndpoint;
194398
+ this.internalEndpointRegion = internalEndpointRegion;
194061
194399
  }
194062
194400
  isInternalEndpoint() {
194063
194401
  return this.useInternalEndpoint !== undefined ? this.useInternalEndpoint : constant_1.USE_INTERNAL_ENDPOINT;
194064
194402
  }
194403
+ getInternalEndpointRegion() {
194404
+ return this.internalEndpointRegion || constant_1.INTERNAL_ENDPOINT_REGION;
194405
+ }
194065
194406
  }
194066
194407
  exports.CloudBaseContext = CloudBaseContext;
194067
194408
 
@@ -203869,7 +204210,7 @@ ${envIdSection}
203869
204210
  ## 环境信息
203870
204211
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
203871
204212
  - Node.js版本: ${process.version}
203872
- - MCP 版本:${process.env.npm_package_version || "2.11.1" || 0}
204213
+ - MCP 版本:${process.env.npm_package_version || "2.12.1" || 0}
203873
204214
  - 系统架构: ${os_1.default.arch()}
203874
204215
  - 时间: ${new Date().toISOString()}
203875
204216
  - 请求ID: ${requestId}
@@ -205379,6 +205720,9 @@ class UserService {
205379
205720
  }]
205380
205721
  });
205381
205722
  }
205723
+ async getTcbAccountInfo() {
205724
+ return this.tcbService.request('DescribeTcbAccountInfo');
205725
+ }
205382
205726
  isValidStr(obj) {
205383
205727
  return typeof obj === 'string' && obj.trim().length > 0;
205384
205728
  }
@@ -218626,7 +218970,7 @@ function registerSetupTools(server) {
218626
218970
  title: "下载项目模板",
218627
218971
  description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
218628
218972
 
218629
- **CRITICAL**: This tool MUST be called FIRST when starting a new project.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置\n- cursor: Cursor AI编辑器\n- 其他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.11.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
218973
+ **CRITICAL**: This tool MUST be called FIRST when starting a new project.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置\n- cursor: Cursor AI编辑器\n- 其他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.12.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
218630
218974
  inputSchema: {
218631
218975
  template: zod_1.z
218632
218976
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
@@ -230173,6 +230517,7 @@ class CloudService {
230173
230517
  }
230174
230518
  get baseUrl() {
230175
230519
  const internalEndpoint = this.cloudBaseContext.isInternalEndpoint();
230520
+ const internalEndpointRegion = this.cloudBaseContext.getInternalEndpointRegion();
230176
230521
  const tcb = process.env.TCB_BASE_URL || 'https://tcb.tencentcloudapi.com';
230177
230522
  const urlMap = {
230178
230523
  tcb,
@@ -230187,6 +230532,9 @@ class CloudService {
230187
230532
  [service]: `https://${service}.internal.tencentcloudapi.com`,
230188
230533
  })).reduce((acc, cur) => (Object.assign(Object.assign({}, acc), cur)), {});
230189
230534
  if (internalEndpoint) {
230535
+ if (internalEndpointRegion) {
230536
+ return `https://${this.service}.${internalEndpointRegion}.tencentcloudapi.woa.com`;
230537
+ }
230190
230538
  return intranetUrlMap[this.service] || `https://${this.service}.internal.tencentcloudapi.com`;
230191
230539
  }
230192
230540
  if (urlMap[this.service]) {
@@ -236964,7 +237312,11 @@ function registerGatewayTools(server) {
236964
237312
  description: "创建云函数的 HTTP 访问",
236965
237313
  inputSchema: {
236966
237314
  name: zod_1.z.string().describe("函数名"),
236967
- path: zod_1.z.string().describe("HTTP 访问路径")
237315
+ path: zod_1.z.string().describe("HTTP 访问路径"),
237316
+ type: zod_1.z
237317
+ .enum(["Event", "HTTP"])
237318
+ .optional()
237319
+ .describe("函数类型,Event 为事件型云函数(默认),HTTP 为 HTTP 云函数")
236968
237320
  },
236969
237321
  annotations: {
236970
237322
  readOnlyHint: false,
@@ -236973,10 +237325,12 @@ function registerGatewayTools(server) {
236973
237325
  openWorldHint: true,
236974
237326
  category: "gateway"
236975
237327
  }
236976
- }, async ({ name, path }) => {
237328
+ }, async ({ name, path, type }) => {
236977
237329
  const cloudbase = await getManager();
237330
+ // Event 云函数 type=1,HTTP 云函数 type=6
237331
+ const accessType = type === "HTTP" ? 6 : 1;
236978
237332
  const result = await cloudbase.access.createAccess({
236979
- type: 1,
237333
+ type: accessType, // HTTP 云函数使用 type=6,需要类型断言
236980
237334
  name,
236981
237335
  path
236982
237336
  });
@@ -274455,20 +274809,21 @@ class CloudBase {
274455
274809
  }
274456
274810
  constructor(config = {}) {
274457
274811
  this.cloudBaseConfig = {};
274458
- let { secretId, secretKey, token, envId, proxy, region, envType, useInternalEndpoint } = config;
274812
+ let { secretId, secretKey, token, envId, proxy, region, envType, useInternalEndpoint, internalEndpointRegion } = config;
274459
274813
  // config 中传入的 secretId secretkey 必须同时存在
274460
274814
  if ((secretId && !secretKey) || (!secretId && secretKey)) {
274461
274815
  throw new Error('secretId and secretKey must be a pair');
274462
274816
  }
274463
274817
  this.cloudBaseConfig = {
274464
- secretId,
274465
- secretKey,
274818
+ secretId: secretId ? secretId.trim() : secretId,
274819
+ secretKey: secretKey ? secretKey.trim() : secretKey,
274466
274820
  token,
274467
274821
  envId,
274468
274822
  envType,
274469
274823
  proxy,
274470
274824
  region,
274471
- useInternalEndpoint
274825
+ useInternalEndpoint,
274826
+ internalEndpointRegion,
274472
274827
  };
274473
274828
  // 初始化 context
274474
274829
  this.context = new context_1.CloudBaseContext(this.cloudBaseConfig);
@@ -276645,6 +277000,7 @@ exports.FunctionService = void 0;
276645
277000
  const fs_1 = __importDefault(__webpack_require__(29021));
276646
277001
  const path_1 = __importDefault(__webpack_require__(39902));
276647
277002
  const lodash_1 = __importDefault(__webpack_require__(2543));
277003
+ const cos_nodejs_sdk_v5_1 = __importDefault(__webpack_require__(93625));
276648
277004
  const packer_1 = __webpack_require__(5147);
276649
277005
  const error_1 = __webpack_require__(40430);
276650
277006
  const utils_1 = __webpack_require__(62358);
@@ -276654,9 +277010,33 @@ function isNodeFunction(runtime) {
276654
277010
  // 不严格限制
276655
277011
  return runtime === 'Nodejs10.15' || runtime === 'Nodejs8.9' || (runtime === null || runtime === void 0 ? void 0 : runtime.includes('Nodejs'));
276656
277012
  }
277013
+ /**
277014
+ * 构建镜像配置对象
277015
+ * @param imageConfig 镜像配置
277016
+ * @param options 可选配置
277017
+ * @param options.includeCommandList 是否包含 CommandList/ArgsList(仅 CreateFunction 支持)
277018
+ * @returns 构建好的镜像配置对象
277019
+ */
277020
+ function buildImageConfig(imageConfig, options) {
277021
+ var _a, _b;
277022
+ const { includeCommandList = false } = options || {};
277023
+ const config = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ ImageType: imageConfig.imageType || 'enterprise', ImageUri: imageConfig.imageUri }, (imageConfig.registryId && { RegistryId: imageConfig.registryId })), (imageConfig.entryPoint && { EntryPoint: imageConfig.entryPoint })), (imageConfig.command && { Command: imageConfig.command })), (imageConfig.args && { Args: imageConfig.args })), (typeof imageConfig.containerImageAccelerate === 'boolean' && {
277024
+ ContainerImageAccelerate: imageConfig.containerImageAccelerate
277025
+ })), { ImagePort: imageConfig.imagePort || 9000 });
277026
+ // CommandList 和 ArgsList 仅在 CreateFunction 时支持
277027
+ if (includeCommandList) {
277028
+ if ((_a = imageConfig.commandList) === null || _a === void 0 ? void 0 : _a.length) {
277029
+ config.CommandList = imageConfig.commandList;
277030
+ }
277031
+ if ((_b = imageConfig.argsList) === null || _b === void 0 ? void 0 : _b.length) {
277032
+ config.ArgsList = imageConfig.argsList;
277033
+ }
277034
+ }
277035
+ return config;
277036
+ }
276657
277037
  // 解析函数配置,换成请求参数
276658
277038
  function configToParams(options) {
276659
- var _a, _b, _c, _d, _e;
277039
+ var _a, _b, _c, _d, _e, _f, _g;
276660
277040
  const { func, codeSecret, baseParams } = options;
276661
277041
  let installDependency;
276662
277042
  // Node 函数默认安装依赖
@@ -276709,6 +277089,40 @@ function configToParams(options) {
276709
277089
  }));
276710
277090
  params.Layers = transformLayers;
276711
277091
  }
277092
+ // HTTP 云函数类型
277093
+ if ((func === null || func === void 0 ? void 0 : func.type) === 'HTTP') {
277094
+ params.Type = 'HTTP';
277095
+ // WebSocket 协议支持
277096
+ if ((func === null || func === void 0 ? void 0 : func.protocolType) === 'WS') {
277097
+ params.ProtocolType = 'WS';
277098
+ // 协议参数,直接透传或使用默认值
277099
+ // 参考文档:https://cloud.tencent.com/document/api/583/17244#ProtocolParams
277100
+ const idleTimeOut = (_g = (_f = func === null || func === void 0 ? void 0 : func.protocolParams) === null || _f === void 0 ? void 0 : _f.wsParams) === null || _g === void 0 ? void 0 : _g.idleTimeOut;
277101
+ params.ProtocolParams = {
277102
+ WSParams: {
277103
+ IdleTimeOut: typeof idleTimeOut === 'number' ? idleTimeOut : 15
277104
+ }
277105
+ };
277106
+ }
277107
+ // 多并发配置
277108
+ // 参考文档:https://cloud.tencent.com/document/api/583/17244#InstanceConcurrencyConfig
277109
+ if (func === null || func === void 0 ? void 0 : func.instanceConcurrencyConfig) {
277110
+ params.InstanceConcurrencyConfig = {
277111
+ DynamicEnabled: func.instanceConcurrencyConfig.dynamicEnabled || 'FALSE',
277112
+ MaxConcurrency: func.instanceConcurrencyConfig.maxConcurrency || 10
277113
+ };
277114
+ }
277115
+ }
277116
+ // 云函数描述
277117
+ if (func === null || func === void 0 ? void 0 : func.description) {
277118
+ params.Description = func.description;
277119
+ }
277120
+ // 镜像配置(用于镜像部署)
277121
+ if (func === null || func === void 0 ? void 0 : func.imageConfig) {
277122
+ params.Code = {
277123
+ ImageConfig: buildImageConfig(func.imageConfig, { includeCommandList: true })
277124
+ };
277125
+ }
276712
277126
  return params;
276713
277127
  }
276714
277128
  class FunctionService {
@@ -276717,6 +277131,7 @@ class FunctionService {
276717
277131
  this.scfService = new utils_1.CloudService(environment.cloudBaseContext, 'scf', '2018-04-16');
276718
277132
  this.vpcService = new utils_1.CloudService(environment.cloudBaseContext, 'vpc', '2017-03-12');
276719
277133
  this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
277134
+ this.userService = environment.getUserService();
276720
277135
  }
276721
277136
  /**
276722
277137
  * 增量更新函数代码
@@ -276725,11 +277140,12 @@ class FunctionService {
276725
277140
  * @memberof FunctionService
276726
277141
  */
276727
277142
  async updateFunctionIncrementalCode(funcParam) {
276728
- const { namespace } = this.getFunctionConfig();
277143
+ const { env, namespace } = this.getFunctionConfig();
276729
277144
  const { functionRootPath, func, deleteFiles, addFiles } = funcParam;
276730
277145
  const { name, runtime } = func;
276731
277146
  const params = {
276732
277147
  FunctionName: name,
277148
+ EnvId: env,
276733
277149
  Namespace: namespace
276734
277150
  };
276735
277151
  let packer;
@@ -276754,7 +277170,7 @@ class FunctionService {
276754
277170
  }
276755
277171
  params.AddFiles = base64;
276756
277172
  }
276757
- return this.scfService.request('UpdateFunctionIncrementalCode', params);
277173
+ return this.tcbService.request('UpdateFunctionIncrementalCode', params);
276758
277174
  }
276759
277175
  /**
276760
277176
  * 创建云函数
@@ -276762,30 +277178,49 @@ class FunctionService {
276762
277178
  * @returns {(Promise<IResponseInfo | ICreateFunctionRes>)}
276763
277179
  */
276764
277180
  async createFunction(funcParam) {
276765
- const { namespace } = this.getFunctionConfig();
276766
- const { func, functionRootPath, force = false, base64Code, codeSecret, functionPath } = funcParam;
277181
+ var _a;
277182
+ const { env } = this.getFunctionConfig();
277183
+ const { func, functionRootPath, force = false, base64Code, codeSecret, functionPath, deployMode } = funcParam;
276767
277184
  const funcName = func.name;
276768
277185
  const params = configToParams({
276769
277186
  func,
276770
277187
  codeSecret,
276771
277188
  baseParams: {
276772
- Namespace: namespace,
277189
+ EnvId: env,
276773
277190
  Role: 'TCB_QcsRole',
276774
277191
  Stamp: 'MINI_QCBASE'
276775
277192
  }
276776
277193
  });
276777
- params.Code = await this.getCodeParams({
276778
- func,
276779
- base64Code,
276780
- functionPath,
276781
- functionRootPath
276782
- }, params.InstallDependency);
277194
+ // 根据部署方式处理 Code 参数
277195
+ // 优先使用显式指定的 deployMode,如果未指定但存在 imageConfig 则认为是镜像部署
277196
+ const isImageDeploy = deployMode === 'image' || (!deployMode && func.imageConfig);
277197
+ if (isImageDeploy) {
277198
+ // 镜像部署:Code 参数已在 configToParams 中通过 imageConfig 设置
277199
+ if (!((_a = func.imageConfig) === null || _a === void 0 ? void 0 : _a.imageUri)) {
277200
+ throw new error_1.CloudBaseError('镜像部署需要配置 imageConfig.imageUri');
277201
+ }
277202
+ // 镜像部署的特殊配置
277203
+ // 镜像函数不需要 Handler
277204
+ delete params.Handler;
277205
+ // 镜像函数不需要安装依赖
277206
+ delete params.InstallDependency;
277207
+ }
277208
+ else {
277209
+ // 代码部署:通过 getCodeParams 获取代码参数
277210
+ params.Code = await this.getCodeParams({
277211
+ func,
277212
+ base64Code,
277213
+ functionPath,
277214
+ functionRootPath,
277215
+ deployMode
277216
+ }, params.InstallDependency);
277217
+ }
276783
277218
  const { TopicId, LogsetId } = this.getClsServiceConfig();
276784
277219
  params.ClsTopicId = TopicId;
276785
277220
  params.ClsLogsetId = LogsetId;
276786
277221
  try {
276787
277222
  // 创建云函数
276788
- const res = await this.scfService.request('CreateFunction', params);
277223
+ const res = await this.tcbService.request('CreateFunction', params);
276789
277224
  // 等待函数状态正常
276790
277225
  await this.waitFunctionActive(funcName, codeSecret);
276791
277226
  // 创建函数触发器、失败自动重试
@@ -276803,13 +277238,14 @@ class FunctionService {
276803
277238
  const functionExist = e.code === 'ResourceInUse.FunctionName' || e.code === 'ResourceInUse.Function';
276804
277239
  // 已存在同名函数,强制更新
276805
277240
  if (functionExist && force) {
276806
- // 1. 更新函数配置和代码,同名函数可能存在 codeSecret,先修改代码,清除 codeSecret
277241
+ // 1. 更新函数代码(通过 deployMode 区分镜像部署和代码部署)
276807
277242
  const codeRes = await this.updateFunctionCode({
276808
277243
  func,
276809
277244
  base64Code,
276810
277245
  functionPath,
276811
277246
  functionRootPath,
276812
- codeSecret: codeSecret
277247
+ codeSecret: codeSecret,
277248
+ deployMode: isImageDeploy ? 'image' : undefined
276813
277249
  });
276814
277250
  // 等待函数状态正常
276815
277251
  await this.waitFunctionActive(funcName, codeSecret);
@@ -276854,9 +277290,9 @@ class FunctionService {
276854
277290
  */
276855
277291
  async getFunctionList(limit = 20, offset = 0) {
276856
277292
  // 获取Function 环境配置
276857
- const { namespace } = this.getFunctionConfig();
276858
- const res = await this.scfService.request('ListFunctions', {
276859
- Namespace: namespace,
277293
+ const { env } = this.getFunctionConfig();
277294
+ const res = await this.tcbService.request('ListFunctions', {
277295
+ EnvId: env,
276860
277296
  Limit: limit,
276861
277297
  Offset: offset
276862
277298
  });
@@ -276870,9 +277306,9 @@ class FunctionService {
276870
277306
  */
276871
277307
  async listFunctions(limit = 20, offset = 0) {
276872
277308
  // 获取Function 环境配置
276873
- const { namespace } = this.getFunctionConfig();
276874
- const res = await this.scfService.request('ListFunctions', {
276875
- Namespace: namespace,
277309
+ const { env } = this.getFunctionConfig();
277310
+ const res = await this.tcbService.request('ListFunctions', {
277311
+ EnvId: env,
276876
277312
  Limit: limit,
276877
277313
  Offset: offset
276878
277314
  });
@@ -276903,8 +277339,8 @@ class FunctionService {
276903
277339
  const { envId } = options;
276904
277340
  while (true) {
276905
277341
  try {
276906
- const res = await this.scfService.request('ListFunctions', {
276907
- Namespace: envId,
277342
+ const res = await this.tcbService.request('ListFunctions', {
277343
+ EnvId: envId,
276908
277344
  Limit: pageSize,
276909
277345
  Offset: currentOffset
276910
277346
  });
@@ -276987,16 +277423,17 @@ class FunctionService {
276987
277423
  * @returns {Promise<Record<string, string>>}
276988
277424
  */
276989
277425
  async getFunctionDetail(name, codeSecret) {
276990
- const { namespace } = this.getFunctionConfig();
277426
+ const { env } = this.getFunctionConfig();
276991
277427
  const params = {
276992
277428
  FunctionName: name,
276993
- Namespace: namespace,
276994
- ShowCode: 'TRUE'
277429
+ EnvId: env,
277430
+ ShowCode: 'TRUE',
277431
+ Namespace: env
276995
277432
  };
276996
277433
  if (codeSecret) {
276997
277434
  params.CodeSecret = codeSecret;
276998
277435
  }
276999
- const data = await this.scfService.request('GetFunction', params);
277436
+ const data = await this.tcbService.request('GetFunction', params);
277000
277437
  // 解析 VPC 配置
277001
277438
  const { VpcId = '', SubnetId = '' } = data.VpcConfig || {};
277002
277439
  if (VpcId && SubnetId) {
@@ -277173,7 +277610,7 @@ class FunctionService {
277173
277610
  * @returns {Promise<IResponseInfo>}
277174
277611
  */
277175
277612
  async updateFunctionConfig(func) {
277176
- var _a, _b, _c, _d, _e;
277613
+ var _a, _b, _c, _d, _e, _f, _g;
277177
277614
  const { namespace } = this.getFunctionConfig();
277178
277615
  const envVariables = Object.keys(func.envVariables || {}).map(key => ({
277179
277616
  Key: key,
@@ -277186,6 +277623,9 @@ class FunctionService {
277186
277623
  Namespace: namespace,
277187
277624
  L5Enable: l5Enable
277188
277625
  };
277626
+ if (func === null || func === void 0 ? void 0 : func.description) {
277627
+ params.Description = func.description;
277628
+ }
277189
277629
  // 修复参数存在 undefined 字段时,会出现鉴权失败的情况
277190
277630
  // Environment 为覆盖式修改,不保留已有字段
277191
277631
  envVariables.length && (params.Environment = { Variables: envVariables });
@@ -277216,6 +277656,22 @@ class FunctionService {
277216
277656
  }));
277217
277657
  params.Layers = transformLayers;
277218
277658
  }
277659
+ // WebSocket 协议支持(仅 HTTP 函数)
277660
+ if (func === null || func === void 0 ? void 0 : func.protocolParams) {
277661
+ const idleTimeOut = (_g = (_f = func === null || func === void 0 ? void 0 : func.protocolParams) === null || _f === void 0 ? void 0 : _f.wsParams) === null || _g === void 0 ? void 0 : _g.idleTimeOut;
277662
+ params.ProtocolParams = {
277663
+ WSParams: {
277664
+ IdleTimeOut: typeof idleTimeOut === 'number' ? idleTimeOut : 15
277665
+ }
277666
+ };
277667
+ }
277668
+ // 多并发配置(仅 HTTP 函数)
277669
+ if (func === null || func === void 0 ? void 0 : func.instanceConcurrencyConfig) {
277670
+ params.InstanceConcurrencyConfig = {
277671
+ DynamicEnabled: func.instanceConcurrencyConfig.dynamicEnabled || 'FALSE',
277672
+ MaxConcurrency: func.instanceConcurrencyConfig.maxConcurrency || 10
277673
+ };
277674
+ }
277219
277675
  try {
277220
277676
  // 如果函数配置中包含触发器,则更新触发器
277221
277677
  if (func.triggers && func.triggers.length > 0) {
@@ -277231,7 +277687,8 @@ class FunctionService {
277231
277687
  }
277232
277688
  catch (e) {
277233
277689
  throw new error_1.CloudBaseError(`[${func.name}] 更新函数配置失败:${e.message}`, {
277234
- code: e.code
277690
+ code: e.code,
277691
+ requestId: e.requestId
277235
277692
  });
277236
277693
  }
277237
277694
  }
@@ -277242,9 +277699,35 @@ class FunctionService {
277242
277699
  * @memberof FunctionService
277243
277700
  */
277244
277701
  async updateFunctionCode(funcParam) {
277245
- const { func, functionRootPath, base64Code, codeSecret, functionPath } = funcParam;
277702
+ var _a;
277703
+ const { func, functionRootPath, base64Code, codeSecret, functionPath, deployMode } = funcParam;
277246
277704
  const funcName = func.name;
277247
- const { namespace } = this.getFunctionConfig();
277705
+ const { env } = this.getFunctionConfig();
277706
+ // 镜像部署:使用镜像配置更新函数代码
277707
+ if (deployMode === 'image') {
277708
+ if (!((_a = func.imageConfig) === null || _a === void 0 ? void 0 : _a.imageUri)) {
277709
+ throw new error_1.CloudBaseError('镜像部署需要配置 imageConfig.imageUri');
277710
+ }
277711
+ const params = {
277712
+ FunctionName: funcName,
277713
+ EnvId: env,
277714
+ Code: {
277715
+ ImageConfig: buildImageConfig(func.imageConfig)
277716
+ }
277717
+ };
277718
+ try {
277719
+ // 等待函数状态正常
277720
+ await this.waitFunctionActive(funcName, codeSecret);
277721
+ return await this.tcbService.request('UpdateFunctionCode', params);
277722
+ }
277723
+ catch (e) {
277724
+ throw new error_1.CloudBaseError(`[${funcName}] 函数代码更新失败:${e.message}`, {
277725
+ code: e.code,
277726
+ requestId: e.requestId
277727
+ });
277728
+ }
277729
+ }
277730
+ // 代码部署:原有逻辑
277248
277731
  let installDependency;
277249
277732
  // Node 函数默认安装依赖
277250
277733
  installDependency = isNodeFunction(func.runtime) ? 'TRUE' : 'FALSE';
@@ -277256,9 +277739,16 @@ class FunctionService {
277256
277739
  func,
277257
277740
  functionPath,
277258
277741
  functionRootPath,
277259
- base64Code
277742
+ base64Code,
277743
+ deployMode
277260
277744
  }, installDependency);
277261
- const params = Object.assign({ FunctionName: funcName, Namespace: namespace, Handler: func.handler || 'index.main', InstallDependency: installDependency }, codeParams);
277745
+ const params = {
277746
+ FunctionName: funcName,
277747
+ EnvId: env,
277748
+ Handler: func.handler || 'index.main',
277749
+ InstallDependency: installDependency,
277750
+ Code: codeParams
277751
+ };
277262
277752
  if (codeSecret) {
277263
277753
  params.CodeSecret = codeSecret;
277264
277754
  }
@@ -277266,15 +277756,16 @@ class FunctionService {
277266
277756
  // 等待函数状态正常
277267
277757
  await this.waitFunctionActive(funcName, codeSecret);
277268
277758
  // 更新云函数代码
277269
- const res = await this.scfService.request('UpdateFunctionCode', params);
277759
+ const res = await this.tcbService.request('UpdateFunctionCode', params);
277270
277760
  if (installDependency && func.isWaitInstall === true) {
277271
277761
  await this.waitFunctionActive(funcName, codeSecret);
277272
277762
  }
277273
277763
  return res;
277274
277764
  }
277275
277765
  catch (e) {
277276
- throw new error_1.CloudBaseError(`[${funcName}] 函数代码更新失败: ${e.message}`, {
277277
- code: e.code
277766
+ throw new error_1.CloudBaseError(`[${funcName}] 函数代码更新失败:${e.message}`, {
277767
+ code: e.code,
277768
+ requestId: e.requestId
277278
277769
  });
277279
277770
  }
277280
277771
  }
@@ -277299,7 +277790,9 @@ class FunctionService {
277299
277790
  return Object.assign({ RequestId }, Result);
277300
277791
  }
277301
277792
  catch (e) {
277302
- throw new error_1.CloudBaseError(`[${name}] 调用失败:\n${e.message}`);
277793
+ throw new error_1.CloudBaseError(`[${name}] 调用失败:${e.message}`, {
277794
+ requestId: e.requestId
277795
+ });
277303
277796
  }
277304
277797
  }
277305
277798
  /**
@@ -277377,7 +277870,8 @@ class FunctionService {
277377
277870
  catch (e) {
277378
277871
  throw new error_1.CloudBaseError(`[${name}] 创建触发器失败:${e.message}`, {
277379
277872
  action: e.action,
277380
- code: e.code
277873
+ code: e.code,
277874
+ requestId: e.requestId
277381
277875
  });
277382
277876
  }
277383
277877
  }
@@ -277469,7 +277963,9 @@ class FunctionService {
277469
277963
  return { Url, RequestId, CodeSha256 };
277470
277964
  }
277471
277965
  catch (e) {
277472
- throw new error_1.CloudBaseError(`[${functionName}] 获取函数代码下载链接失败:\n${e.message}`);
277966
+ throw new error_1.CloudBaseError(`[${functionName}] 获取函数代码下载链接失败:${e.message}`, {
277967
+ requestId: e.requestId
277968
+ });
277473
277969
  }
277474
277970
  }
277475
277971
  // 函数绑定文件层
@@ -277621,6 +278117,45 @@ class FunctionService {
277621
278117
  LayerVersion: version
277622
278118
  });
277623
278119
  }
278120
+ // 检查函数状态,部分操作在函数更新中时不可进行
278121
+ async waitFunctionActive(funcName, codeSecret) {
278122
+ let ticker;
278123
+ let timer;
278124
+ let resolved;
278125
+ return new Promise((resolve, reject) => {
278126
+ // 超时时间 5 分钟
278127
+ timer = setTimeout(() => {
278128
+ clearInterval(ticker);
278129
+ if (!resolved) {
278130
+ reject(new error_1.CloudBaseError('函数状态异常,检查超时'));
278131
+ }
278132
+ }, 300000);
278133
+ ticker = setInterval(async () => {
278134
+ try {
278135
+ const { Status, StatusDesc, StatusReasons, RequestId } = await this.getFunctionDetail(funcName, codeSecret);
278136
+ // 更新中
278137
+ if (Status === constant_1.SCF_STATUS.CREATING || Status === constant_1.SCF_STATUS.UPDATING)
278138
+ return;
278139
+ // 创建失败
278140
+ if (Status === constant_1.SCF_STATUS.CREATE_FAILED) {
278141
+ const errorDetails = (StatusReasons === null || StatusReasons === void 0 ? void 0 : StatusReasons.map(item => `[${item.ErrorCode}] ${item.ErrorMessage}`).join('\n')) || '';
278142
+ const errorMsg = `云函数创建失败${StatusDesc ? `\n状态描述: ${StatusDesc}` : ''}${errorDetails ? `\n失败信息: ${errorDetails}` : ''}`;
278143
+ throw new error_1.CloudBaseError(errorMsg, { requestId: RequestId });
278144
+ }
278145
+ // 函数状态正常
278146
+ clearInterval(ticker);
278147
+ clearTimeout(timer);
278148
+ resolve();
278149
+ }
278150
+ catch (e) {
278151
+ clearInterval(ticker);
278152
+ clearTimeout(timer);
278153
+ reject(e);
278154
+ }
278155
+ resolved = true;
278156
+ }, 1000);
278157
+ });
278158
+ }
277624
278159
  /**
277625
278160
  * 设置预置并发
277626
278161
  * @private
@@ -277736,6 +278271,116 @@ class FunctionService {
277736
278271
  Namespace: namespace
277737
278272
  });
277738
278273
  }
278274
+ /**
278275
+ * 通过scf COS 上传方式(通过 GetTempCosInfo + COS SDK 上传)
278276
+ * 返回 TempCosObjectName 用于创建/更新函数
278277
+ */
278278
+ async uploadFunctionZipToCosLegacy(options, installDependency) {
278279
+ const { func, functionPath, functionRootPath } = options;
278280
+ const { env } = this.getFunctionConfig();
278281
+ const { CloudAppId } = await this.userService.getTcbAccountInfo();
278282
+ const objectPath = `${CloudAppId}/${env}/${func.name}.zip`;
278283
+ // 1. 生成存放函数包的临时 Cos 目录
278284
+ const { Date: cosDate, Sign } = await this.scfService.request('GetTempCosInfo', {
278285
+ ObjectPath: `${objectPath}`
278286
+ });
278287
+ // 2. 本地压缩
278288
+ const codeType = packer_1.CodeType.File;
278289
+ // 云端安装依赖,自动忽略 node_modules 目录
278290
+ const ignore = installDependency === 'TRUE'
278291
+ ? ['node_modules/**/*', 'node_modules', ...(func.ignore || [])]
278292
+ : [...(func.ignore || [])];
278293
+ const packer = new packer_1.FunctionPacker({
278294
+ ignore,
278295
+ codeType,
278296
+ functionPath,
278297
+ name: func.name,
278298
+ root: functionRootPath
278299
+ });
278300
+ const zipFilePath = await packer.compressFiles();
278301
+ // 3. 初始化 cos 并上传
278302
+ // 根据环境 region 获取对应的 bucket 前缀
278303
+ const region = this.environment.cloudBaseContext.region || constant_1.SCF_TEMP_COS.DEFAULT_REGION;
278304
+ const regionPrefix = constant_1.SCF_TEMP_COS.REGION_PREFIX_MAP[region] || constant_1.SCF_TEMP_COS.DEFAULT_REGION_PREFIX;
278305
+ const tempCosObjectName = `/${cosDate}/${objectPath}`;
278306
+ const uploadParams = {
278307
+ Bucket: `${regionPrefix}tempcos-${constant_1.SCF_TEMP_COS.APPID}`,
278308
+ Key: tempCosObjectName,
278309
+ Region: region,
278310
+ FilePath: zipFilePath,
278311
+ };
278312
+ const cos = new cos_nodejs_sdk_v5_1.default({
278313
+ getAuthorization: function (options, callback) {
278314
+ // 注入上一步获取的临时密钥
278315
+ callback(Sign);
278316
+ }
278317
+ });
278318
+ return new Promise((resolve, reject) => {
278319
+ cos.sliceUploadFile(uploadParams, async (err, data) => {
278320
+ // 清理临时文件
278321
+ await packer.clean();
278322
+ if (err) {
278323
+ reject(new error_1.CloudBaseError(`COS 上传失败: ${err.message || err}`));
278324
+ }
278325
+ else {
278326
+ resolve(data);
278327
+ }
278328
+ });
278329
+ });
278330
+ }
278331
+ /**
278332
+ * 新的 COS 上传方式(通过 DescribeBuildServiceCosInfo + PUT 上传)
278333
+ * 返回 CosTimestamp 用于创建/更新函数
278334
+ */
278335
+ async uploadFunctionZipToCos(options, installDependency) {
278336
+ const { func, functionPath, functionRootPath } = options;
278337
+ const { env } = this.getFunctionConfig();
278338
+ // 1. 生成存放函数包的临时 Cos 目录
278339
+ const { UploadUrl, UnixTimestamp, UploadHeaders } = await this.tcbService.request('DescribeBuildServiceCosInfo', {
278340
+ EnvId: env,
278341
+ ServiceName: func.name,
278342
+ Business: 'scf',
278343
+ Suffix: '.zip'
278344
+ });
278345
+ // 2. 本地压缩
278346
+ const codeType = packer_1.CodeType.File;
278347
+ // 云端安装依赖,自动忽略 node_modules 目录
278348
+ const ignore = installDependency === 'TRUE'
278349
+ ? ['node_modules/**/*', 'node_modules', ...(func.ignore || [])]
278350
+ : [...(func.ignore || [])];
278351
+ const packer = new packer_1.FunctionPacker({
278352
+ ignore,
278353
+ codeType,
278354
+ functionPath,
278355
+ name: func.name,
278356
+ root: functionRootPath
278357
+ });
278358
+ const zipFilePath = await packer.compressFiles();
278359
+ // 3. 通过 UploadUrl 直接上传
278360
+ const fileBuffer = fs_1.default.readFileSync(zipFilePath);
278361
+ // 构建请求头
278362
+ const headers = {
278363
+ 'Content-Type': 'application/zip'
278364
+ };
278365
+ if (UploadHeaders && UploadHeaders.length > 0) {
278366
+ UploadHeaders.forEach(item => {
278367
+ headers[item.Key] = item.Value;
278368
+ });
278369
+ }
278370
+ const response = await fetch(UploadUrl, {
278371
+ method: 'PUT',
278372
+ body: fileBuffer,
278373
+ headers
278374
+ });
278375
+ if (!response.ok) {
278376
+ throw new error_1.CloudBaseError(`上传失败: ${response.status} ${response.statusText}`);
278377
+ }
278378
+ // 清理临时文件
278379
+ await packer.clean();
278380
+ return {
278381
+ UnixTimestamp
278382
+ };
278383
+ }
277739
278384
  async createAccessPath(name, path) {
277740
278385
  const access = this.environment.getAccessService();
277741
278386
  try {
@@ -277760,11 +278405,13 @@ class FunctionService {
277760
278405
  }
277761
278406
  }
277762
278407
  async getCodeParams(options, installDependency) {
277763
- const { func, functionPath, functionRootPath, base64Code } = options;
277764
- // 20MB
277765
- const BIG_LENGTH = 167772160;
277766
- if ((base64Code === null || base64Code === void 0 ? void 0 : base64Code.length) > BIG_LENGTH) {
277767
- throw new error_1.CloudBaseError('base64 不能大于 20 MB');
278408
+ const { func, functionPath, functionRootPath, base64Code, deployMode } = options;
278409
+ // 直接传入 base64Code 的情况,校验大小
278410
+ // ZipFile 上传大小上限 1.5MB,base64 编码后长度约为原始大小的 4/3
278411
+ const MAX_ZIP_SIZE = 1.5 * 1024 * 1024; // 1.5MB
278412
+ const MAX_BASE64_LENGTH = Math.floor(MAX_ZIP_SIZE * 4 / 3); // ≈ 2097152
278413
+ if ((base64Code === null || base64Code === void 0 ? void 0 : base64Code.length) > MAX_BASE64_LENGTH) {
278414
+ throw new error_1.CloudBaseError('ZipFile 上传不能大于 1.5MB,请使用 COS 上传方式');
277768
278415
  }
277769
278416
  if (base64Code === null || base64Code === void 0 ? void 0 : base64Code.length) {
277770
278417
  return {
@@ -277784,17 +278431,29 @@ class FunctionService {
277784
278431
  root: functionRootPath
277785
278432
  });
277786
278433
  await packer.build();
277787
- // 通过云 API 传输的代码大小不能超过 50MB
277788
- const reachMax = await packer.isReachMaxSize();
277789
- if (reachMax) {
277790
- throw new error_1.CloudBaseError('函数代码不能大于 50MB');
277791
- }
277792
- const base64 = await packer.getBase64Code();
277793
- if (!(base64 === null || base64 === void 0 ? void 0 : base64.length)) {
277794
- throw new error_1.CloudBaseError('文件不能为空');
278434
+ // 指定 zip 上传方式:走 ZipFile base64 上传
278435
+ if (deployMode === 'zip') {
278436
+ // 判断是否超过 ZipFile 上传大小限制(1.5MB)
278437
+ const reachMax = await packer.isReachMaxSize();
278438
+ if (reachMax) {
278439
+ throw new error_1.CloudBaseError('ZipFile 上传不能大于 1.5MB,请使用 COS 上传方式(deployMode: "cos")');
278440
+ }
278441
+ const base64 = await packer.getBase64Code();
278442
+ if (!(base64 === null || base64 === void 0 ? void 0 : base64.length)) {
278443
+ throw new error_1.CloudBaseError('文件不能为空');
278444
+ }
278445
+ console.log(`[${func.name}] 部署方式: ZIP base64 上传`);
278446
+ return {
278447
+ ZipFile: base64
278448
+ };
277795
278449
  }
278450
+ // 默认走 COS 上传
278451
+ console.log(`[${func.name}] 部署方式: COS 上传`);
278452
+ const region = this.environment.cloudBaseContext.region || constant_1.SCF_TEMP_COS.DEFAULT_REGION;
278453
+ const legacyResult = await this.uploadFunctionZipToCosLegacy(options, installDependency);
277796
278454
  return {
277797
- ZipFile: base64
278455
+ CosBucketRegion: region,
278456
+ TempCosObjectName: `/${legacyResult.Key}`
277798
278457
  };
277799
278458
  }
277800
278459
  // 获取 COS 临时信息
@@ -277833,10 +278492,11 @@ class FunctionService {
277833
278492
  * @memberof FunctionService
277834
278493
  */
277835
278494
  getFunctionConfig() {
277836
- var _a;
278495
+ var _a, _b, _c, _d;
277837
278496
  const envConfig = this.environment.lazyEnvironmentConfig;
277838
- const namespace = envConfig.Functions[0].Namespace;
277839
- const appId = (_a = envConfig.Storages[0]) === null || _a === void 0 ? void 0 : _a.AppId;
278497
+ // Functions 可能为空
278498
+ const namespace = ((_b = (_a = envConfig.Functions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.Namespace) || '';
278499
+ const appId = (_d = (_c = envConfig.Storages) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.AppId;
277840
278500
  const { proxy } = this.environment.cloudBaseContext;
277841
278501
  return {
277842
278502
  proxy,
@@ -277882,45 +278542,6 @@ class FunctionService {
277882
278542
  });
277883
278543
  return SubnetSet;
277884
278544
  }
277885
- // 检查函数状态,部分操作在函数更新中时不可进行
277886
- async waitFunctionActive(funcName, codeSecret) {
277887
- let ticker;
277888
- let timer;
277889
- let resolved;
277890
- return new Promise((resolve, reject) => {
277891
- // 超时时间 5 分钟
277892
- timer = setTimeout(() => {
277893
- clearInterval(ticker);
277894
- if (!resolved) {
277895
- reject(new error_1.CloudBaseError('函数状态异常,检查超时'));
277896
- }
277897
- }, 300000);
277898
- ticker = setInterval(async () => {
277899
- try {
277900
- const { Status, StatusDesc, StatusReasons, RequestId } = await this.getFunctionDetail(funcName, codeSecret);
277901
- // 更新中
277902
- if (Status === constant_1.SCF_STATUS.CREATING || Status === constant_1.SCF_STATUS.UPDATING)
277903
- return;
277904
- // 创建失败
277905
- if (Status === constant_1.SCF_STATUS.CREATE_FAILED) {
277906
- StatusDesc && console.log(`函数状态描述: ${StatusDesc}`);
277907
- const errorDetails = StatusReasons.map(item => `[${item.ErrorCode}] ${item.ErrorMessage}`).join('\n');
277908
- throw new error_1.CloudBaseError(`云函数创建失败\n失败信息: ${errorDetails}\nRequestId: ${RequestId}`);
277909
- }
277910
- // 函数状态正常
277911
- clearInterval(ticker);
277912
- clearTimeout(timer);
277913
- resolve();
277914
- }
277915
- catch (e) {
277916
- clearInterval(ticker);
277917
- clearTimeout(timer);
277918
- reject(e);
277919
- }
277920
- resolved = true;
277921
- }, 1000);
277922
- });
277923
- }
277924
278545
  }
277925
278546
  exports.FunctionService = FunctionService;
277926
278547
  __decorate([
@@ -278031,6 +278652,12 @@ __decorate([
278031
278652
  __decorate([
278032
278653
  (0, utils_1.preLazy)()
278033
278654
  ], FunctionService.prototype, "getFunctionAlias", null);
278655
+ __decorate([
278656
+ (0, utils_1.preLazy)()
278657
+ ], FunctionService.prototype, "uploadFunctionZipToCosLegacy", null);
278658
+ __decorate([
278659
+ (0, utils_1.preLazy)()
278660
+ ], FunctionService.prototype, "uploadFunctionZipToCos", null);
278034
278661
  __decorate([
278035
278662
  (0, utils_1.preLazy)()
278036
278663
  ], FunctionService.prototype, "createAccessPath", null);