@cloudbase/cloudbase-mcp 2.23.3 → 2.23.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3314,9 +3314,9 @@ function registerEnvTools(server) {
3314
3314
  .optional()
3315
3315
  .describe("环境地域(action=create 时可选)。默认 ap-shanghai,可选 ap-guangzhou、ap-beijing 等"),
3316
3316
  resources: zod_1.z
3317
- .array(zod_1.z.enum(["flexdb", "storage", "function"]))
3317
+ .array(zod_1.z.enum(["flexdb", "storage", "function", "postgresql"]))
3318
3318
  .optional()
3319
- .describe("启用的资源类型(action=create 时可选)。默认启用全部三项:flexdb(文档数据库)、storage(存储)、function(云函数)"),
3319
+ .describe("启用的资源类型(action=create 时可选)。默认启用全部四项:flexdb(文档数据库)、storage(存储)、function(云函数)、postgresql(PostgreSQL 数据库)"),
3320
3320
  duration: zod_1.z
3321
3321
  .number()
3322
3322
  .int()
@@ -3369,7 +3369,7 @@ function registerEnvTools(server) {
3369
3369
  return (0, tool_result_js_1.buildJsonToolResult)({
3370
3370
  ok: false,
3371
3371
  code: "CONFIRM_REQUIRED",
3372
- message: `创建环境需要您确认。请确认以下配置信息后传入 confirm="yes":\n别名: ${alias}\n套餐: ${packageId}\n地域: ${region}\n资源类型: ${resources?.join(", ") ?? "flexdb, storage, function"}\n时长: ${duration} 个月`,
3372
+ message: `创建环境需要您确认。请确认以下配置信息后传入 confirm="yes":\n别名: ${alias}\n套餐: ${packageId}\n地域: ${region}\n资源类型: ${resources?.join(", ") ?? "flexdb, storage, function, postgresql"}\n时长: ${duration} 个月`,
3373
3373
  next_step: {
3374
3374
  tool: "manageEnv",
3375
3375
  action: "create",
@@ -37032,6 +37032,119 @@ module.exports.Printf
37032
37032
  = Printf;
37033
37033
 
37034
37034
 
37035
+ /***/ }),
37036
+
37037
+ /***/ 8901:
37038
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
37039
+
37040
+ "use strict";
37041
+
37042
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
37043
+ if (k2 === undefined) k2 = k;
37044
+ var desc = Object.getOwnPropertyDescriptor(m, k);
37045
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
37046
+ desc = { enumerable: true, get: function() { return m[k]; } };
37047
+ }
37048
+ Object.defineProperty(o, k2, desc);
37049
+ }) : (function(o, m, k, k2) {
37050
+ if (k2 === undefined) k2 = k;
37051
+ o[k2] = m[k];
37052
+ }));
37053
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
37054
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37055
+ };
37056
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
37057
+ exports.MonitorService = void 0;
37058
+ const error_1 = __webpack_require__(40430);
37059
+ const utils_1 = __webpack_require__(62358);
37060
+ __exportStar(__webpack_require__(57676), exports);
37061
+ // Period 与时间范围的约束规则
37062
+ const ONE_DAY_MS = 24 * 60 * 60 * 1000;
37063
+ const THREE_DAYS_MS = 3 * ONE_DAY_MS;
37064
+ const PERIOD_RULES = [
37065
+ { maxRangeMs: ONE_DAY_MS, allowed: [300, 3600] },
37066
+ { maxRangeMs: THREE_DAYS_MS, allowed: [300, 3600, 86400] },
37067
+ // 超过3天
37068
+ { maxRangeMs: Infinity, allowed: [3600, 86400] }
37069
+ ];
37070
+ function validatePeriod(startStr, endStr, period) {
37071
+ if (period === undefined)
37072
+ return;
37073
+ const startMs = new Date(startStr).getTime();
37074
+ const endMs = new Date(endStr).getTime();
37075
+ if (isNaN(startMs) || isNaN(endMs))
37076
+ return;
37077
+ const rangeMs = endMs - startMs;
37078
+ const rule = PERIOD_RULES.find(r => rangeMs <= r.maxRangeMs);
37079
+ if (rule && !rule.allowed.includes(period)) {
37080
+ throw new error_1.CloudBaseError(`Period=${period} 不适用于当前时间范围。` +
37081
+ `时间范围 ${startStr} ~ ${endStr}(约 ${(rangeMs / ONE_DAY_MS).toFixed(1)} 天)` +
37082
+ `仅支持 Period: [${rule.allowed.join(', ')}]`);
37083
+ }
37084
+ }
37085
+ class MonitorService {
37086
+ constructor(environment) {
37087
+ this.envId = environment.getEnvId();
37088
+ this.cloudService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
37089
+ }
37090
+ /**
37091
+ * 查询环境监控数据
37092
+ *
37093
+ * 根据指定指标名称,查询当前环境在指定时间范围内的监控数据,
37094
+ * 返回按统计粒度聚合后的时序数据。
37095
+ *
37096
+ * @param params 查询参数
37097
+ * @returns 时序监控数据
37098
+ *
37099
+ * @example
37100
+ * // 查询静态网站存储容量
37101
+ * const res = await monitor.describeCurveData({
37102
+ * MetricName: 'StaticFsSizePkg',
37103
+ * StartTime: '2026-02-05 00:00:00',
37104
+ * EndTime: '2026-02-06 23:59:59',
37105
+ * Period: 3600
37106
+ * })
37107
+ *
37108
+ * @example
37109
+ * // 查询云托管某服务某版本的错误响应
37110
+ * const res = await monitor.describeCurveData({
37111
+ * MetricName: 'TkeHttpErrorService',
37112
+ * StartTime: '2026-03-13 00:00:00',
37113
+ * EndTime: '2026-03-16 23:59:59',
37114
+ * ResourceID: 'my-service',
37115
+ * SubresourceID: 'my-service-001'
37116
+ * })
37117
+ */
37118
+ async describeCurveData(params) {
37119
+ // 校验 Period 与时间范围的约束关系
37120
+ validatePeriod(params.StartTime, params.EndTime, params.Period);
37121
+ const requestParams = {
37122
+ EnvId: this.envId,
37123
+ MetricName: params.MetricName,
37124
+ StartTime: params.StartTime,
37125
+ EndTime: params.EndTime
37126
+ };
37127
+ if (params.ResourceID !== undefined) {
37128
+ requestParams.ResourceID = params.ResourceID;
37129
+ }
37130
+ if (params.WxAppId !== undefined) {
37131
+ requestParams.WxAppId = params.WxAppId;
37132
+ }
37133
+ if (params.SubresourceID !== undefined) {
37134
+ requestParams.SubresourceID = params.SubresourceID;
37135
+ }
37136
+ if (params.ThirdResource !== undefined) {
37137
+ requestParams.ThirdResource = params.ThirdResource;
37138
+ }
37139
+ if (params.Period !== undefined) {
37140
+ requestParams.Period = params.Period;
37141
+ }
37142
+ return this.cloudService.request('DescribeCurveData', requestParams);
37143
+ }
37144
+ }
37145
+ exports.MonitorService = MonitorService;
37146
+
37147
+
37035
37148
  /***/ }),
37036
37149
 
37037
37150
  /***/ 8904:
@@ -39129,6 +39242,8 @@ function registerAgentTools(server) {
39129
39242
  category: "agents",
39130
39243
  },
39131
39244
  }, async ({ action, agentId, name, description, runtime, timeout, memorySize, installDependency, zipFile, cosBucketRegion, tempCosObjectName, sessionConfig, cwd, params, }) => {
39245
+ let _agentName;
39246
+ let _agentRuntime;
39132
39247
  try {
39133
39248
  const cloudbase = await getManager();
39134
39249
  const payload = normalizeAgentPayload({
@@ -39145,11 +39260,19 @@ function registerAgentTools(server) {
39145
39260
  cwd,
39146
39261
  ...(params ?? {}),
39147
39262
  });
39263
+ _agentName = payload?.Name;
39264
+ _agentRuntime = payload?.Runtime;
39148
39265
  if (action === "createAgent") {
39149
39266
  const normalizedName = normalizeString(payload.Name);
39150
39267
  if (!normalizedName) {
39151
39268
  throw new Error("action=createAgent 时必须提供 name(可通过顶层 name 或 params.name 传入)");
39152
39269
  }
39270
+ // CloudBase 后端在创建 Agent 时会同步创建云函数,函数名/别名长度受 SCF 限制(最大 64 字符)。
39271
+ // envId 可能被用作前缀或别名的一部分,因此这里预留足够余量,避免后端 CreateFunction 失败。
39272
+ if (normalizedName.length > 30) {
39273
+ throw new Error(`agent name 过长(当前 ${normalizedName.length} 字符)。CloudBase 创建 Agent 时会同步创建云函数,` +
39274
+ `函数名/别名受 SCF 64 字符限制,且 envId 可能作为前缀拼接。请将 name 控制在 30 字符以内。`);
39275
+ }
39153
39276
  const createPayload = {
39154
39277
  ...payload,
39155
39278
  Name: normalizedName,
@@ -39188,6 +39311,17 @@ function registerAgentTools(server) {
39188
39311
  }, "Agent 删除成功"));
39189
39312
  }
39190
39313
  catch (error) {
39314
+ // 对后端 InternalError 提供更有意义的错误信息
39315
+ const errMsg = error instanceof Error ? error.message : String(error);
39316
+ if (errMsg.includes("InternalError") || errMsg.includes("服务处理出错")) {
39317
+ server.logger?.({
39318
+ type: "createAgentError",
39319
+ message: "createAgent 后端返回 InternalError,可能是云函数创建失败",
39320
+ originalError: errMsg,
39321
+ name: _agentName,
39322
+ runtime: _agentRuntime,
39323
+ });
39324
+ }
39191
39325
  return (0, json_content_js_1.jsonContent)(buildErrorEnvelope(error));
39192
39326
  }
39193
39327
  });
@@ -51060,6 +51194,207 @@ function configure (options) {
51060
51194
  }
51061
51195
 
51062
51196
 
51197
+ /***/ }),
51198
+
51199
+ /***/ 12129:
51200
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
51201
+
51202
+ "use strict";
51203
+
51204
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
51205
+ const crypto = __webpack_require__(55511);
51206
+ const utils_1 = __webpack_require__(98786);
51207
+ const utils_lang_1 = __webpack_require__(82174);
51208
+ const keyvalue_1 = __webpack_require__(36255);
51209
+ const url_1 = __webpack_require__(79551);
51210
+ const debug = (__webpack_require__(28354).debuglog)('@cloudbase/signature');
51211
+ const isStream = __webpack_require__(31232);
51212
+ exports.signedParamsSeparator = ';';
51213
+ const HOST_KEY = 'host';
51214
+ const CONTENT_TYPE_KEY = 'content-type';
51215
+ var MIME;
51216
+ (function (MIME) {
51217
+ MIME["MULTIPART_FORM_DATA"] = "multipart/form-data";
51218
+ MIME["APPLICATION_JSON"] = "application/json";
51219
+ })(MIME || (MIME = {}));
51220
+ class Signer {
51221
+ constructor(credential, service, options = {}) {
51222
+ this.credential = credential;
51223
+ this.service = service;
51224
+ this.algorithm = 'TC3-HMAC-SHA256';
51225
+ this.options = options;
51226
+ }
51227
+ static camSafeUrlEncode(str) {
51228
+ return encodeURIComponent(str)
51229
+ .replace(/!/g, '%21')
51230
+ .replace(/'/g, '%27')
51231
+ .replace(/\(/g, '%28')
51232
+ .replace(/\)/g, '%29')
51233
+ .replace(/\*/g, '%2A');
51234
+ }
51235
+ /**
51236
+ * 将一个对象处理成 KeyValue 形式,嵌套的对象将会被处理成字符串,Key转换成小写字母
51237
+ * @param {Object} obj - 待处理的对象
51238
+ * @param {Object} options
51239
+ * @param {Boolean} options.enableBuffer
51240
+ */
51241
+ static formatKeyAndValue(obj, options = {}) {
51242
+ if (!utils_lang_1.isPlainObject(obj)) {
51243
+ return obj;
51244
+ }
51245
+ // enableValueToLowerCase:头部字段,要求小写,其他数据不需要小写,所以这里避免转小写
51246
+ const { multipart, enableValueToLowerCase = false, selectedKeys, filter } = options;
51247
+ const kv = {};
51248
+ Object.keys(obj || {}).forEach(key => {
51249
+ // NOTE: 客户端类型在服务端可能会丢失
51250
+ const lowercaseKey = Signer.camSafeUrlEncode(key.toLowerCase().trim());
51251
+ // 过滤 Key,服务端接收到的数据,可能含有未签名的 Key,通常是签名的时候被过滤掉的流,数据量可能会比较大
51252
+ // 所以这里提供一个过滤的判断,避免不必要的计算
51253
+ // istanbul ignore next
51254
+ if (Array.isArray(selectedKeys) && !selectedKeys.includes(lowercaseKey)) {
51255
+ return;
51256
+ }
51257
+ // istanbul ignore next
51258
+ if (typeof filter === 'function') {
51259
+ if (filter(key, obj[key], options)) {
51260
+ return;
51261
+ }
51262
+ }
51263
+ // istanbul ignore else
51264
+ if (key && obj[key] !== undefined) {
51265
+ if (lowercaseKey === CONTENT_TYPE_KEY) {
51266
+ // multipart/form-data; boundary=???
51267
+ if (obj[key].startsWith(MIME.MULTIPART_FORM_DATA)) {
51268
+ kv[lowercaseKey] = MIME.MULTIPART_FORM_DATA;
51269
+ }
51270
+ else {
51271
+ kv[lowercaseKey] = obj[key];
51272
+ }
51273
+ return;
51274
+ }
51275
+ if (isStream(obj[key])) {
51276
+ // 这里如果是个文件流,在发送的时候可以识别
51277
+ // 服务端接收到数据之后传到这里判断不出来的
51278
+ // 所以会进入后边的逻辑
51279
+ return;
51280
+ }
51281
+ else if (utils_1.isNodeEnv() && Buffer.isBuffer(obj[key])) {
51282
+ if (multipart) {
51283
+ kv[lowercaseKey] = obj[key];
51284
+ }
51285
+ else {
51286
+ kv[lowercaseKey] = enableValueToLowerCase
51287
+ ? utils_1.stringify(obj[key]).trim().toLowerCase()
51288
+ : utils_1.stringify(obj[key]).trim();
51289
+ }
51290
+ }
51291
+ else {
51292
+ kv[lowercaseKey] = enableValueToLowerCase
51293
+ ? utils_1.stringify(obj[key]).trim().toLowerCase()
51294
+ : utils_1.stringify(obj[key]).trim();
51295
+ }
51296
+ }
51297
+ });
51298
+ return kv;
51299
+ }
51300
+ static calcParamsHash(params, keys = null, options = {}) {
51301
+ debug(params, 'calcParamsHash');
51302
+ if (utils_lang_1.isString(params)) {
51303
+ return utils_1.sha256hash(params);
51304
+ }
51305
+ // 只关心业务参数,不关心以什么类型的 Content-Type 传递的
51306
+ // 所以 application/json multipart/form-data 计算方式是相同的
51307
+ keys = keys || keyvalue_1.SortedKeyValue.kv(params).keys();
51308
+ const hash = crypto.createHash('sha256');
51309
+ for (const key of keys) {
51310
+ // istanbul ignore next
51311
+ if (!params[key]) {
51312
+ continue;
51313
+ }
51314
+ // istanbul ignore next
51315
+ if (isStream(params[key])) {
51316
+ continue;
51317
+ }
51318
+ // string && buffer
51319
+ hash.update(`&${key}=`);
51320
+ hash.update(params[key]);
51321
+ hash.update('\r\n');
51322
+ }
51323
+ return hash.digest(options.encoding || 'hex');
51324
+ }
51325
+ /**
51326
+ * 计算签名信息
51327
+ * 注:默认是tcb签名算法,传入 options.isCloudApi=true,则使用云API V3签名算法
51328
+ * 云API V3算法文档:https://cloud.tencent.com/document/api/598/38504#NodeJS
51329
+ *
51330
+ * @param {string} method - Http Verb:GET/get POST/post 区分大小写
51331
+ * @param {string} url - 地址:http://abc.org/api/v1?a=1&b=2
51332
+ * @param {Object} headers - 需要签名的头部字段
51333
+ * @param {string} params - 请求参数
51334
+ * @param {number} [timestamp] - 签名时间戳
51335
+ * @param {object} [options] - 可选参数
51336
+ */
51337
+ tc3sign(method, url, headers, params, timestamp, options = {}) {
51338
+ timestamp = timestamp || utils_1.second();
51339
+ const urlInfo = url_1.parse(url);
51340
+ const formatedHeaders = Signer.formatKeyAndValue(headers, {
51341
+ enableValueToLowerCase: true
51342
+ });
51343
+ const headerKV = keyvalue_1.SortedKeyValue.kv(formatedHeaders);
51344
+ const signedHeaders = headerKV.keys();
51345
+ const canonicalHeaders = headerKV.toString(':', '\n') + '\n';
51346
+ const { enableHostCheck = true, enableContentTypeCheck = true, isCloudApi = false } = options;
51347
+ if (enableHostCheck && headerKV.get(HOST_KEY) !== urlInfo.host) {
51348
+ throw new TypeError(`host:${urlInfo.host} in url must be equals to host:${headerKV.get('host')} in headers`);
51349
+ }
51350
+ if (enableContentTypeCheck && !headerKV.get(CONTENT_TYPE_KEY)) {
51351
+ throw new TypeError(`${CONTENT_TYPE_KEY} field must in headers`);
51352
+ }
51353
+ const multipart = headerKV.get(CONTENT_TYPE_KEY).startsWith(MIME.MULTIPART_FORM_DATA);
51354
+ const formatedParams = isCloudApi ?
51355
+ JSON.stringify(params)
51356
+ : method.toUpperCase() === 'GET'
51357
+ ? ''
51358
+ : Signer.formatKeyAndValue(params, {
51359
+ multipart
51360
+ });
51361
+ const paramKV = keyvalue_1.SortedKeyValue.kv(formatedParams);
51362
+ const signedParams = paramKV.keys();
51363
+ const hashedPayload = Signer.calcParamsHash(formatedParams, null);
51364
+ const signedUrl = isCloudApi ? urlInfo.pathname : url.replace(/^https?:/, '').split('?')[0];
51365
+ const canonicalRequest = `${method}\n${signedUrl}\n${urlInfo.query || ''}\n${canonicalHeaders}\n${signedHeaders.join(';')}\n${hashedPayload}`;
51366
+ debug(canonicalRequest, 'canonicalRequest\n\n');
51367
+ const date = utils_1.formateDate(timestamp);
51368
+ const service = this.service;
51369
+ const algorithm = this.algorithm;
51370
+ const credentialScope = `${date}/${service}/tc3_request`;
51371
+ const stringToSign = `${algorithm}\n${timestamp}\n${credentialScope}\n${utils_1.sha256hash(canonicalRequest)}`;
51372
+ debug(stringToSign, 'stringToSign\n\n');
51373
+ const secretDate = utils_1.sha256hmac(date, `TC3${this.credential.secretKey}`);
51374
+ const secretService = utils_1.sha256hmac(service, secretDate);
51375
+ const secretSigning = utils_1.sha256hmac('tc3_request', secretService);
51376
+ const signature = utils_1.sha256hmac(stringToSign, secretSigning, 'hex');
51377
+ debug(secretDate.toString('hex'), 'secretDate');
51378
+ debug(secretService.toString('hex'), 'secretService');
51379
+ debug(secretSigning.toString('hex'), 'secretSigning');
51380
+ debug(signature, 'signature');
51381
+ const { withSignedParams = false } = options;
51382
+ return {
51383
+ // 需注意该字段长度
51384
+ // https://stackoverflow.com/questions/686217/maximum-on-http-header-values
51385
+ // https://www.tutorialspoint.com/What-is-the-maximum-size-of-HTTP-header-values
51386
+ authorization: `${algorithm} Credential=${this.credential.secretId}/${credentialScope},${withSignedParams ? ` SignedParams=${signedParams.join(';')},` : ''} SignedHeaders=${signedHeaders.join(';')}, Signature=${signature}`,
51387
+ signedParams,
51388
+ signedHeaders,
51389
+ signature,
51390
+ timestamp,
51391
+ multipart
51392
+ };
51393
+ }
51394
+ }
51395
+ exports.Signer = Signer;
51396
+
51397
+
51063
51398
  /***/ }),
51064
51399
 
51065
51400
  /***/ 12146:
@@ -62038,6 +62373,14 @@ class DatabaseService {
62038
62373
  Tag: Databases[0].InstanceId
62039
62374
  };
62040
62375
  }
62376
+ getMongoConnector() {
62377
+ const currEnv = this.environment;
62378
+ const { Databases } = currEnv.lazyEnvironmentConfig;
62379
+ return {
62380
+ DatabaseName: Databases[0].InstanceId,
62381
+ InstanceId: 'flexdb'
62382
+ };
62383
+ }
62041
62384
  async checkCollectionExists(collectionName) {
62042
62385
  try {
62043
62386
  const result = await this.describeCollection(collectionName);
@@ -62055,9 +62398,10 @@ class DatabaseService {
62055
62398
  }
62056
62399
  }
62057
62400
  async createCollection(collectionName) {
62058
- let { Tag } = this.getDatabaseConfig();
62059
- const res = await this.collOpService.request('CreateTable', {
62060
- Tag,
62401
+ const MongoConnector = this.getMongoConnector();
62402
+ const res = await this.dbOpService.request('CreateTable', {
62403
+ EnvId: this.envId,
62404
+ MongoConnector,
62061
62405
  TableName: collectionName
62062
62406
  });
62063
62407
  return res;
@@ -62066,9 +62410,10 @@ class DatabaseService {
62066
62410
  // 先检查当前集合是否存在
62067
62411
  const existRes = await this.checkCollectionExists(collectionName);
62068
62412
  if (existRes.Exists) {
62069
- let { Tag } = this.getDatabaseConfig();
62070
- const res = await this.collOpService.request('DeleteTable', {
62071
- Tag,
62413
+ const MongoConnector = this.getMongoConnector();
62414
+ const res = await this.dbOpService.request('DeleteTable', {
62415
+ EnvId: this.envId,
62416
+ MongoConnector,
62072
62417
  TableName: collectionName
62073
62418
  });
62074
62419
  return res;
@@ -62078,14 +62423,15 @@ class DatabaseService {
62078
62423
  }
62079
62424
  }
62080
62425
  async updateCollection(collectionName, indexiesInfo) {
62081
- let { Tag } = this.getDatabaseConfig();
62082
- const res = await this.collOpService.request('UpdateTable', Object.assign({ Tag, TableName: collectionName }, indexiesInfo));
62426
+ const MongoConnector = this.getMongoConnector();
62427
+ const res = await this.dbOpService.request('UpdateTable', Object.assign({ EnvId: this.envId, MongoConnector, TableName: collectionName }, indexiesInfo));
62083
62428
  return res;
62084
62429
  }
62085
62430
  async describeCollection(collectionName) {
62086
- let { Tag } = this.getDatabaseConfig();
62087
- return this.collOpService.request('DescribeTable', {
62088
- Tag,
62431
+ const MongoConnector = this.getMongoConnector();
62432
+ return this.dbOpService.request('DescribeTable', {
62433
+ EnvId: this.envId,
62434
+ MongoConnector,
62089
62435
  TableName: collectionName
62090
62436
  });
62091
62437
  }
@@ -62094,14 +62440,14 @@ class DatabaseService {
62094
62440
  MgoLimit: this.DEFAULT_MGO_LIMIT,
62095
62441
  MgoOffset: this.DEFAULT_MGO_OFFSET
62096
62442
  }) {
62097
- let { Tag } = this.getDatabaseConfig();
62443
+ const MongoConnector = this.getMongoConnector();
62098
62444
  if (options.MgoLimit === undefined) {
62099
62445
  options.MgoLimit = this.DEFAULT_MGO_LIMIT;
62100
62446
  }
62101
62447
  if (options.MgoOffset === undefined) {
62102
62448
  options.MgoOffset = this.DEFAULT_MGO_OFFSET;
62103
62449
  }
62104
- const res = await this.collOpService.request('ListTables', Object.assign({ Tag }, options));
62450
+ const res = await this.dbOpService.request('ListTables', Object.assign({ EnvId: this.envId, MongoConnector }, options));
62105
62451
  if (res.Tables === null) {
62106
62452
  // 无集合
62107
62453
  res.Collections = [];
@@ -62266,12 +62612,16 @@ class DatabaseService {
62266
62612
  }
62267
62613
  /**
62268
62614
  * 执行文档型数据库命令
62269
- * @param options 命令参数(命令列表、可选的 Tag/EnvId/MongoConnector)
62615
+ * @param options 命令参数(命令列表、可选的 EnvId/MongoConnector)
62270
62616
  * @returns 执行结果,Data 为 JSON 字符串数组
62271
62617
  */
62272
62618
  async runCommands(options) {
62273
- let { Tag } = this.getDatabaseConfig();
62274
- return this.dbOpService.request('RunCommands', Object.assign({ MgoCommands: options.MgoCommands, Tag: options.Tag || Tag, EnvId: options.EnvId || this.envId }, (options.MongoConnector ? { MongoConnector: options.MongoConnector } : {})));
62619
+ const MongoConnector = options.MongoConnector || this.getMongoConnector();
62620
+ return this.dbOpService.request('RunCommands', {
62621
+ MgoCommands: options.MgoCommands,
62622
+ MongoConnector,
62623
+ EnvId: options.EnvId || this.envId,
62624
+ });
62275
62625
  }
62276
62626
  /**
62277
62627
  * 在 PostgreSQL 数据库上执行 SQL 语句
@@ -86776,7 +87126,11 @@ class PermissionService {
86776
87126
  constructor(environment) {
86777
87127
  this.environment = environment;
86778
87128
  this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
87129
+ this.lowcodeService = new utils_1.CloudService(environment.cloudBaseContext, 'lowcode', '2021-01-08');
86779
87130
  }
87131
+ /**
87132
+ * @deprecated 已废弃,网关鉴权策略已由 OPA 接管,请使用 modifyEnvAuthzConfig 替代
87133
+ */
86780
87134
  async modifyResourcePermission(options) {
86781
87135
  const { EnvId } = this.environment.lazyEnvironmentConfig;
86782
87136
  const { resourceType, resource, permission, securityRule } = options;
@@ -86809,6 +87163,9 @@ class PermissionService {
86809
87163
  }
86810
87164
  return this.tcbService.request('ModifyResourcePermission', reqData);
86811
87165
  }
87166
+ /**
87167
+ * @deprecated 已废弃,网关鉴权策略已由 OPA 接管,请使用 describeResourcePolicyList 或 describeEnvAuthzConfig 替代
87168
+ */
86812
87169
  async describeResourcePermission(options) {
86813
87170
  const { EnvId } = this.environment.lazyEnvironmentConfig;
86814
87171
  const { resourceType, resources } = options;
@@ -87046,6 +87403,102 @@ class PermissionService {
87046
87403
  RoleIds: roleIds
87047
87404
  });
87048
87405
  }
87406
+ /**
87407
+ * 拉取环境下的所有用户自定义的网关鉴权策略列表
87408
+ * 注意:PG 环境无需调用,直接按照无存量策略处理;
87409
+ * 若环境 meta 中 authz_engine 值为 opa,则网关策略不生效,无需调用
87410
+ */
87411
+ async describeResourcePolicyList(options = {}) {
87412
+ const { resourceType } = options;
87413
+ if (resourceType !== undefined && (typeof resourceType !== 'string' || resourceType.trim().length === 0)) {
87414
+ throw new Error('Invalid resourceType');
87415
+ }
87416
+ // PG 环境无需调用,直接返回空策略列表
87417
+ if (await this.isPostgresqlEnv()) {
87418
+ const emptyData = { PolicyList: [], Total: '0' };
87419
+ return {
87420
+ Data: emptyData,
87421
+ RequestId: ''
87422
+ };
87423
+ }
87424
+ // authz_engine 为 opa 时网关策略不生效,无需调用,直接返回空策略列表
87425
+ if (await this.isOpaAuthzEngine()) {
87426
+ const emptyData = { PolicyList: [], Total: '0' };
87427
+ return {
87428
+ Data: emptyData,
87429
+ RequestId: ''
87430
+ };
87431
+ }
87432
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
87433
+ const reqData = {
87434
+ EnvId,
87435
+ ResourceType: resourceType || 'policy'
87436
+ };
87437
+ return this.lowcodeService.request('DescribeResourcePolicyList', reqData);
87438
+ }
87439
+ /**
87440
+ * 拉取环境下的鉴权策略配置
87441
+ * key: authz.platform.extension.rego - 单独为该环境配置的策略
87442
+ * key: authz.user.rego - 用户配置的策略
87443
+ */
87444
+ async describeEnvAuthzConfig(options) {
87445
+ const { key } = options;
87446
+ if (!key || (key !== 'authz.platform.extension.rego' && key !== 'authz.user.rego')) {
87447
+ throw new Error('key must be "authz.platform.extension.rego" or "authz.user.rego"');
87448
+ }
87449
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
87450
+ return this.tcbService.request('DescribeEnvConfig', {
87451
+ EnvId,
87452
+ Key: key
87453
+ });
87454
+ }
87455
+ /**
87456
+ * 保存用户编写的 rego 策略,保存后旧网关鉴权将直接失效
87457
+ */
87458
+ async modifyEnvAuthzConfig(options) {
87459
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
87460
+ const { key, value } = options;
87461
+ if (key !== 'authz.user.rego') {
87462
+ throw new Error('key must be "authz.user.rego"');
87463
+ }
87464
+ if (typeof value !== 'string' || value.trim().length === 0) {
87465
+ throw new Error('value is required and must be a non-empty string');
87466
+ }
87467
+ return this.tcbService.request('ModifyEnvConfig', {
87468
+ EnvId,
87469
+ Key: key,
87470
+ Value: value
87471
+ });
87472
+ }
87473
+ /**
87474
+ * 获取完整的环境基础信息(含 PostgreSQL、Meta 等字段)
87475
+ */
87476
+ async getEnvBaseInfo() {
87477
+ var _a;
87478
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
87479
+ const params = { EnvId };
87480
+ const res = await this.environment.getEnvService().describeEnvInfo(params);
87481
+ return ((_a = res === null || res === void 0 ? void 0 : res.EnvInfo) === null || _a === void 0 ? void 0 : _a.EnvBaseInfo) || {};
87482
+ }
87483
+ /**
87484
+ * 判断当前环境是否为 PostgreSQL 环境
87485
+ */
87486
+ async isPostgresqlEnv() {
87487
+ return this.environment.getEnvService().isPostgresqlEnv();
87488
+ }
87489
+ /**
87490
+ * 判断当前环境的 authz_engine 是否为 opa
87491
+ * 从环境 Meta 中查找 Key 为 authz_engine 的标签,Value 为 opa 表示已切到 OPA
87492
+ */
87493
+ async isOpaAuthzEngine() {
87494
+ const envBaseInfo = await this.getEnvBaseInfo();
87495
+ const meta = envBaseInfo === null || envBaseInfo === void 0 ? void 0 : envBaseInfo.Meta;
87496
+ if (!Array.isArray(meta)) {
87497
+ return false;
87498
+ }
87499
+ const authzEngineTag = meta.find(tag => tag.Key === 'authz_engine');
87500
+ return (authzEngineTag === null || authzEngineTag === void 0 ? void 0 : authzEngineTag.Value) === 'opa';
87501
+ }
87049
87502
  }
87050
87503
  exports.PermissionService = PermissionService;
87051
87504
  __decorate([
@@ -87066,6 +87519,15 @@ __decorate([
87066
87519
  __decorate([
87067
87520
  (0, utils_1.preLazy)()
87068
87521
  ], PermissionService.prototype, "deleteRoles", null);
87522
+ __decorate([
87523
+ (0, utils_1.preLazy)()
87524
+ ], PermissionService.prototype, "describeResourcePolicyList", null);
87525
+ __decorate([
87526
+ (0, utils_1.preLazy)()
87527
+ ], PermissionService.prototype, "describeEnvAuthzConfig", null);
87528
+ __decorate([
87529
+ (0, utils_1.preLazy)()
87530
+ ], PermissionService.prototype, "modifyEnvAuthzConfig", null);
87069
87531
 
87070
87532
 
87071
87533
  /***/ }),
@@ -89171,7 +89633,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
89171
89633
  return (mod && mod.__esModule) ? mod : { "default": mod };
89172
89634
  };
89173
89635
  Object.defineProperty(exports, "__esModule", ({ value: true }));
89174
- exports.MANAGE_FUNCTION_ACTIONS = exports.QUERY_FUNCTION_ACTIONS = exports.TRIGGER_CONFIG_EXAMPLES = exports.SUPPORTED_TRIGGER_TYPES = exports.DEFAULT_NODEJS_RUNTIME = exports.SUPPORTED_NODEJS_RUNTIMES = exports.RECOMMENDED_RUNTIMES = exports.DEFAULT_RUNTIME = exports.ALL_SUPPORTED_RUNTIMES = exports.SUPPORTED_RUNTIMES = void 0;
89636
+ exports.CUSTOM_IMAGE_RUNTIME = exports.MANAGE_FUNCTION_ACTIONS = exports.QUERY_FUNCTION_ACTIONS = exports.TRIGGER_CONFIG_EXAMPLES = exports.SUPPORTED_TRIGGER_TYPES = exports.DEFAULT_NODEJS_RUNTIME = exports.SUPPORTED_NODEJS_RUNTIMES = exports.RECOMMENDED_RUNTIMES = exports.DEFAULT_RUNTIME = exports.ALL_SUPPORTED_RUNTIMES = exports.SUPPORTED_RUNTIMES = void 0;
89175
89637
  exports.formatRuntimeList = formatRuntimeList;
89176
89638
  exports.validateTimerCron = validateTimerCron;
89177
89639
  exports.shouldInstallDependencyForFunction = shouldInstallDependencyForFunction;
@@ -89279,6 +89741,41 @@ const VPC_SCHEMA = zod_1.z.object({
89279
89741
  vpcId: zod_1.z.string(),
89280
89742
  subnetId: zod_1.z.string(),
89281
89743
  });
89744
+ // 镜像部署值,对应 SCF Runtime=CustomImage
89745
+ exports.CUSTOM_IMAGE_RUNTIME = "CustomImage";
89746
+ // HTTP 函数镜像部署配置,对应 Manager SDK 的 IFunctionImageConfig(camelCase)。
89747
+ // 用于 zip→COS→CloudApp custom 构建→TCR→SCF 镜像部署链路的「阶段 B」:基于已推送到 TCR 的镜像创建/更新函数。
89748
+ const IMAGE_CONFIG_SCHEMA = zod_1.z.object({
89749
+ imageType: zod_1.z
89750
+ .enum(["enterprise", "personal"])
89751
+ .optional()
89752
+ .describe("镜像仓库类型:enterprise(企业版 TCR)或 personal(个人版)。省略时默认 enterprise。"),
89753
+ imageUri: zod_1.z
89754
+ .string()
89755
+ .describe("完整镜像地址(必须含 tag),格式 {domain}/{namespace}/{image}:{tag}," +
89756
+ "例如 ccr.ccs.tencentyun.com/your-ns/demo-app:demo-app-001。不要使用 :latest。"),
89757
+ registryId: zod_1.z
89758
+ .string()
89759
+ .optional()
89760
+ .describe("TCR 实例 ID,形如 tcr-xxxxxxxx。imageType=enterprise 时必填。"),
89761
+ command: zod_1.z
89762
+ .string()
89763
+ .optional()
89764
+ .describe("覆盖镜像 ENTRYPOINT。不填则使用 Dockerfile 默认值,例如 python。"),
89765
+ args: zod_1.z
89766
+ .string()
89767
+ .optional()
89768
+ .describe("覆盖镜像 CMD,空格分隔,例如 -u app.py。"),
89769
+ entryPoint: zod_1.z.string().optional().describe("镜像入口点,一般不需要单独设置。"),
89770
+ imagePort: zod_1.z
89771
+ .number()
89772
+ .optional()
89773
+ .describe("容器监听端口。Web Server 函数填 9000(默认),Job 型镜像填 -1。"),
89774
+ containerImageAccelerate: zod_1.z
89775
+ .boolean()
89776
+ .optional()
89777
+ .describe("是否开启镜像加速。镜像较大时建议开启以缩短冷启动时间。"),
89778
+ });
89282
89779
  const SEVEN_FIELD_CRON_REGEX = /^\s*\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s*$/;
89283
89780
  function validateTimerCron(config) {
89284
89781
  const trimmed = config.trim();
@@ -89338,7 +89835,11 @@ const CREATE_FUNCTION_SCHEMA = zod_1.z.object({
89338
89835
  ` Python: ${exports.RECOMMENDED_RUNTIMES.python}\n` +
89339
89836
  ` PHP: ${exports.RECOMMENDED_RUNTIMES.php}\n` +
89340
89837
  ` Java: ${exports.RECOMMENDED_RUNTIMES.java}\n` +
89341
- ` Go: ${exports.RECOMMENDED_RUNTIMES.golang}`),
89838
+ ` Go: ${exports.RECOMMENDED_RUNTIMES.golang}\n\n` +
89839
+ `镜像部署(基于 TCR 镜像创建函数)时填 "${exports.CUSTOM_IMAGE_RUNTIME}",并提供 imageConfig;此时无需 functionRootPath/zipFile。`),
89840
+ imageConfig: IMAGE_CONFIG_SCHEMA.optional().describe("镜像部署配置(仅 runtime=CustomImage 时使用)。" +
89841
+ "用于 zip→COS→CloudApp custom 构建→TCR→SCF 的「阶段 B」:基于已推送到 TCR 的镜像创建 HTTP 函数。" +
89842
+ "传入 imageConfig 后即按镜像部署处理,函数无需打包本地代码、scf_bootstrap 或 Handler。"),
89342
89843
  triggers: zod_1.z.array(TRIGGER_SCHEMA).optional().describe("触发器配置数组"),
89343
89844
  handler: zod_1.z.string().optional().describe("函数入口"),
89344
89845
  ignore: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional().describe("忽略文件"),
@@ -89487,7 +89988,12 @@ function registerFunctionTools(server) {
89487
89988
  return;
89488
89989
  }
89489
89990
  if (input.action === "createFunction" || input.action === "updateFunctionCode") {
89490
- throw new Error(`${input.action} 在 cloud mode 下不可用,因为该操作依赖本地函数代码目录。请改用本地模式执行。`);
89991
+ // 镜像部署不依赖本地代码目录(代码已在 TCR),cloud mode 下可用。
89992
+ const hasImageConfig = Boolean(input.imageConfig ?? input.func?.imageConfig);
89993
+ if (hasImageConfig) {
89994
+ return;
89995
+ }
89996
+ throw new Error(`${input.action} 在 cloud mode 下不可用,因为该操作依赖本地函数代码目录。请改用本地模式执行,或使用镜像部署(runtime=CustomImage + imageConfig)。`);
89491
89997
  }
89492
89998
  if (input.action === "createLayerVersion" && input.contentPath) {
89493
89999
  throw new Error("createLayerVersion 在 cloud mode 下不支持 contentPath,本地文件内容请改为 base64Content 或改用本地模式执行。");
@@ -89837,6 +90343,70 @@ function registerFunctionTools(server) {
89837
90343
  const func = { ...input.func };
89838
90344
  const functionName = String(func.name);
89839
90345
  (0, logger_js_1.debug)(`[createFunction] name=${functionName}, type=${String(func.type || "Event")}`);
90346
+ // 镜像部署分支(Runtime=CustomImage):基于已推送到 TCR 的镜像创建 HTTP 函数。
90347
+ // 对应 zip→COS→CloudApp custom 构建→TCR→SCF 链路的「阶段 B」。
90348
+ const createImageConfig = input.imageConfig ??
90349
+ func.imageConfig;
90350
+ const isImageRuntime = typeof func.runtime === "string" &&
90351
+ func.runtime.replace(/\s+/g, "").toLowerCase() ===
90352
+ exports.CUSTOM_IMAGE_RUNTIME.toLowerCase();
90353
+ if (createImageConfig || isImageRuntime) {
90354
+ if (!createImageConfig?.imageUri) {
90355
+ throw new Error("镜像部署(runtime=CustomImage)时,imageConfig.imageUri 是必需的," +
90356
+ "格式为 {domain}/{namespace}/{image}:{tag}(含 tag,不要用 :latest)。");
90357
+ }
90358
+ if ((createImageConfig.imageType ?? "enterprise") === "enterprise" &&
90359
+ !createImageConfig.registryId) {
90360
+ throw new Error("imageType=enterprise(企业版 TCR)时,imageConfig.registryId(tcr-xxxxxxxx)是必需的。");
90361
+ }
90362
+ // 镜像函数即 HTTP 函数;Manager SDK 会自动补 ImageType=enterprise、ImagePort=9000,
90363
+ // 并在镜像部署时剥离 Handler / InstallDependency,故此处不需要 functionRootPath。
90364
+ const imageFunc = {
90365
+ ...func,
90366
+ type: func.type ?? "HTTP",
90367
+ runtime: exports.CUSTOM_IMAGE_RUNTIME,
90368
+ imageConfig: createImageConfig,
90369
+ };
90370
+ delete imageFunc.installDependency;
90371
+ let imageResult;
90372
+ try {
90373
+ imageResult = await cloudbase.functions.createFunction({
90374
+ func: imageFunc,
90375
+ deployMode: "image",
90376
+ force: Boolean(input.force),
90377
+ });
90378
+ }
90379
+ catch (error) {
90380
+ throw wrapFunctionOperationError("createFunction", functionName, undefined, error);
90381
+ }
90382
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, imageResult);
90383
+ return buildEnvelope({
90384
+ action: input.action,
90385
+ functionName,
90386
+ deployMode: "image",
90387
+ imageUri: createImageConfig.imageUri,
90388
+ raw: imageResult,
90389
+ }, `已基于镜像 ${createImageConfig.imageUri} 创建 HTTP 函数 ${functionName}。` +
90390
+ `请确认 TCR、SCF 与构建管道处于同一地域;如需通过 URL 访问,请显式调用 ` +
90391
+ `manageGateway(action="createAccess", type="HTTP") 并按需调整函数安全规则。` +
90392
+ `部署后可用 queryFunctions(action="getFunctionDetail") 确认函数已就绪。`, [
90393
+ {
90394
+ tool: "queryFunctions",
90395
+ action: "getFunctionDetail",
90396
+ reason: "确认镜像函数已就绪(Active)",
90397
+ },
90398
+ {
90399
+ tool: "manageFunctions",
90400
+ action: "updateFunctionCode",
90401
+ reason: "后续迭代只需用新镜像 tag 调用 updateFunctionCode 更新镜像",
90402
+ },
90403
+ {
90404
+ tool: "manageGateway",
90405
+ action: "createAccess",
90406
+ reason: "如需通过 URL 访问镜像 HTTP 函数,显式创建网关访问入口并传 type=\"HTTP\"",
90407
+ },
90408
+ ]);
90409
+ }
89840
90410
  if (func.type !== "HTTP") {
89841
90411
  const originalRuntime = typeof func.runtime === "string" ? func.runtime : undefined;
89842
90412
  func.runtime = resolveEventFunctionRuntime(func.runtime);
@@ -89930,6 +90500,42 @@ function registerFunctionTools(server) {
89930
90500
  throw new Error("updateFunctionCode 操作时,functionName 参数是必需的");
89931
90501
  }
89932
90502
  const cloudbase = await getManager();
90503
+ // 镜像更新分支:后续迭代只需用新镜像 tag 更新函数。
90504
+ const updateImageConfig = input.imageConfig ??
90505
+ input.func?.imageConfig;
90506
+ if (updateImageConfig) {
90507
+ if (!updateImageConfig.imageUri) {
90508
+ throw new Error("镜像更新时,imageConfig.imageUri 是必需的,格式为 {domain}/{namespace}/{image}:{tag}(含 tag,不要用 :latest)。");
90509
+ }
90510
+ let imageResult;
90511
+ try {
90512
+ imageResult = await cloudbase.functions.updateFunctionCode({
90513
+ func: {
90514
+ name: input.functionName,
90515
+ imageConfig: updateImageConfig,
90516
+ },
90517
+ deployMode: "image",
90518
+ });
90519
+ }
90520
+ catch (error) {
90521
+ throw wrapFunctionOperationError("updateFunctionCode", input.functionName, undefined, error);
90522
+ }
90523
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, imageResult);
90524
+ return buildEnvelope({
90525
+ action: input.action,
90526
+ functionName: input.functionName,
90527
+ deployMode: "image",
90528
+ imageUri: updateImageConfig.imageUri,
90529
+ raw: imageResult,
90530
+ }, `已将函数 ${input.functionName} 的镜像更新为 ${updateImageConfig.imageUri}。` +
90531
+ `部署后可用 queryFunctions(action="getFunctionDetail") 确认函数已就绪(Active)。`, [
90532
+ {
90533
+ tool: "queryFunctions",
90534
+ action: "getFunctionDetail",
90535
+ reason: "确认镜像更新后函数已就绪(Active)",
90536
+ },
90537
+ ]);
90538
+ }
89933
90539
  const processedRootPath = processFunctionRootPath(input.functionRootPath, input.functionName);
89934
90540
  const updateParams = {
89935
90541
  func: {
@@ -90340,6 +90946,8 @@ function registerFunctionTools(server) {
90340
90946
  title: "管理 CloudBase 云函数",
90341
90947
  description: "CloudBase 云函数统一写入口。支持创建函数、更新代码、更新配置、调用函数、管理定时跑 / 定时任务 / scheduled job 的 timer 触发器和层绑定。" +
90342
90948
  "如果要创建 cron 定时任务,先用 createFunction 创建函数,再用 createFunctionTrigger 创建 timer 触发器(支持7段cron表达式),deleteFunctionTrigger 删除触发器。" +
90949
+ "镜像部署(Runtime=CustomImage):先把代码经 zip→COS→CloudApp custom 构建→TCR 推镜像(这一阶段为裸腾讯云 API,本工具不覆盖)," +
90950
+ "再用 createFunction(func.runtime=\"CustomImage\", imageConfig) 基于 TCR 镜像创建 HTTP 函数;后续迭代用 updateFunctionCode + imageConfig 换镜像 tag。" +
90343
90951
  "危险操作需要显式 confirm=true。",
90344
90952
  inputSchema: {
90345
90953
  action: zod_1.z
@@ -90379,6 +90987,9 @@ function registerFunctionTools(server) {
90379
90987
  .optional()
90380
90988
  .describe("updateFunctionLayers 的目标层列表,顺序即最终顺序"),
90381
90989
  codeSecret: zod_1.z.string().optional().describe("层绑定时的代码保护密钥"),
90990
+ imageConfig: IMAGE_CONFIG_SCHEMA.optional().describe("镜像部署配置(Runtime=CustomImage)。createFunction 时基于 TCR 镜像创建 HTTP 函数," +
90991
+ "updateFunctionCode 时仅更换镜像 tag。需提供 imageUri(含 tag),企业版 TCR 还需 registryId。" +
90992
+ "也可在 func.imageConfig 中提供;两处都传时以顶层 imageConfig 优先。"),
90382
90993
  confirm: zod_1.z.boolean().optional().describe("危险操作确认开关。deleteFunction、deleteFunctionTrigger、deleteLayerVersion、detachLayer 等删除类操作需要显式传入 confirm=true"),
90383
90994
  incrementalFile: zod_1.z.string().optional().describe("incrementalDeployFunction 增量部署时的变更文件路径"),
90384
90995
  },
@@ -92501,6 +93112,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
92501
93112
  exports.EnvService = void 0;
92502
93113
  const cos_nodejs_sdk_v5_1 = __importDefault(__webpack_require__(93625));
92503
93114
  const util_1 = __importDefault(__webpack_require__(28354));
93115
+ const http_request_1 = __webpack_require__(72088);
93116
+ const signature_nodejs_1 = __webpack_require__(77463);
92504
93117
  const error_1 = __webpack_require__(40430);
92505
93118
  const utils_1 = __webpack_require__(62358);
92506
93119
  const constant_1 = __webpack_require__(40762);
@@ -92515,6 +93128,7 @@ class EnvService {
92515
93128
  this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
92516
93129
  this.commonService = environment.getCommonService('lowcode', '2021-01-08');
92517
93130
  this.billingService = new billing_1.BillingService(environment.cloudBaseContext);
93131
+ this.tokenCache = new Map();
92518
93132
  }
92519
93133
  /**
92520
93134
  * 列出所有环境
@@ -92632,7 +93246,7 @@ class EnvService {
92632
93246
  };
92633
93247
  const response = await this.describeEnvInfo(params);
92634
93248
  const envBaseInfo = (_a = response === null || response === void 0 ? void 0 : response.EnvInfo) === null || _a === void 0 ? void 0 : _a.EnvBaseInfo;
92635
- // 成功获取环境信息,将 EnvBaseInfo 映射到 EnvInfo 类型
93249
+ // 将 EnvBaseInfo 完整映射到 EnvInfo 类型,避免新增字段被丢弃
92636
93250
  const envInfo = {
92637
93251
  EnvId: envBaseInfo.EnvId,
92638
93252
  Alias: envBaseInfo.Alias,
@@ -92647,7 +93261,22 @@ class EnvService {
92647
93261
  Region: envBaseInfo.Region || '',
92648
93262
  Source: envBaseInfo.Source,
92649
93263
  CreateTime: envBaseInfo.CreateTime,
92650
- UpdateTime: envBaseInfo.UpdateTime
93264
+ UpdateTime: envBaseInfo.UpdateTime,
93265
+ StaticStorages: envBaseInfo.StaticStorages,
93266
+ IsAutoDegrade: envBaseInfo.IsAutoDegrade,
93267
+ EnvChannel: envBaseInfo.EnvChannel,
93268
+ PayMode: envBaseInfo.PayMode,
93269
+ IsDefault: envBaseInfo.IsDefault,
93270
+ Tags: envBaseInfo.Tags,
93271
+ EnvType: envBaseInfo.EnvType,
93272
+ IsDauPackage: envBaseInfo.IsDauPackage,
93273
+ PackageType: envBaseInfo.PackageType,
93274
+ ArchitectureType: envBaseInfo.ArchitectureType,
93275
+ Recycle: envBaseInfo.Recycle,
93276
+ EnvPreferences: envBaseInfo.EnvPreferences,
93277
+ Meta: envBaseInfo.Meta,
93278
+ PostgreSQL: envBaseInfo.PostgreSQL,
93279
+ EnvStatus: envBaseInfo.EnvStatus
92651
93280
  };
92652
93281
  return {
92653
93282
  EnvInfo: envInfo,
@@ -92672,6 +93301,18 @@ class EnvService {
92672
93301
  async describeEnvInfo(params) {
92673
93302
  return this.cloudService.request('DescribeEnvInfo', params);
92674
93303
  }
93304
+ /**
93305
+ * 判断当前环境是否为 PostgreSQL 环境
93306
+ * PostgreSQL 字段为数组且长度 > 0 时视为 PG 环境
93307
+ *
93308
+ * @returns 是否为 PG 环境
93309
+ */
93310
+ async isPostgresqlEnv() {
93311
+ var _a, _b;
93312
+ const response = await this.describeEnvInfo({ EnvId: this.envId });
93313
+ const postgresql = (_b = (_a = response === null || response === void 0 ? void 0 : response.EnvInfo) === null || _a === void 0 ? void 0 : _a.EnvBaseInfo) === null || _b === void 0 ? void 0 : _b.PostgreSQL;
93314
+ return Array.isArray(postgresql) && postgresql.length > 0;
93315
+ }
92675
93316
  /**
92676
93317
  * 修改环境名称
92677
93318
  * @param {string} alias 环境名称
@@ -92899,6 +93540,74 @@ class EnvService {
92899
93540
  async describeApiKeyList(options) {
92900
93541
  return this.tcbService.request('DescribeApiKeyList', Object.assign({ EnvId: this.envId }, options));
92901
93542
  }
93543
+ /**
93544
+ * 根据密钥信息获取管理员访问令牌
93545
+ * 使用 secretId、secretKey 和 sessionToken 签发访问令牌
93546
+ * 默认从初始化时的 cloudBaseContext 中读取密钥,也可显式传入 credentials 覆盖
93547
+ * @param {Object} [credentials] 密钥信息,不传则使用初始化时的密钥
93548
+ * @param {string} credentials.secretId 密钥ID
93549
+ * @param {string} credentials.secretKey 密钥Key
93550
+ * @param {string} [credentials.token] sessionToken
93551
+ * @returns {Promise<string>} 访问令牌
93552
+ */
93553
+ async getAdminAccessToken(credentials) {
93554
+ const { secretId, secretKey, token } = credentials || this.environment.cloudBaseContext;
93555
+ if (!secretId || !secretKey) {
93556
+ throw new error_1.CloudBaseError('missing secretId or secretKey of tencent cloud');
93557
+ }
93558
+ const envId = this.envId;
93559
+ const cacheKey = `access_token_secret_${envId}_${secretId}`;
93560
+ const cached = this.tokenCache.get(cacheKey);
93561
+ if (cached && cached.expiry > Date.now()) {
93562
+ return cached.token;
93563
+ }
93564
+ const host = `${envId}${this.environment.cloudBaseContext.isInternalEndpoint()
93565
+ ? '.api.intl.tcloudbasegateway.com'
93566
+ : '.api.tcloudbasegateway.com'}`;
93567
+ const url = `https://${host}/auth/v1/token/clientCredential`;
93568
+ const method = 'POST';
93569
+ const headers = {
93570
+ 'Content-Type': 'application/json',
93571
+ Host: host,
93572
+ };
93573
+ const data = { grant_type: 'client_credentials' };
93574
+ const timestamp = Math.floor(new Date().getTime() / 1000) - 1;
93575
+ const { authorization, timestamp: signTimestamp } = (0, signature_nodejs_1.sign)({
93576
+ secretId,
93577
+ secretKey,
93578
+ method,
93579
+ url,
93580
+ headers,
93581
+ params: data,
93582
+ timestamp,
93583
+ withSignedParams: false,
93584
+ isCloudApi: true,
93585
+ });
93586
+ headers['Authorization'] = `${authorization}, Timestamp=${signTimestamp}${token ? `, Token=${token}` : ''}`;
93587
+ headers['X-Signature-Expires'] = 600;
93588
+ headers['X-Timestamp'] = signTimestamp;
93589
+ try {
93590
+ const response = await (0, http_request_1.fetch)(url, {
93591
+ method,
93592
+ headers,
93593
+ body: JSON.stringify(data),
93594
+ });
93595
+ const res = await response.json();
93596
+ const access_token = res === null || res === void 0 ? void 0 : res.access_token;
93597
+ const expires_in = (res === null || res === void 0 ? void 0 : res.expires_in) || 0;
93598
+ if (access_token && expires_in) {
93599
+ this.tokenCache.set(cacheKey, {
93600
+ token: access_token,
93601
+ expiry: Date.now() + (expires_in * 1000) / 2,
93602
+ });
93603
+ }
93604
+ return access_token;
93605
+ }
93606
+ catch (e) {
93607
+ console.log(e);
93608
+ throw e;
93609
+ }
93610
+ }
92902
93611
  // 创建自定义登录私钥
92903
93612
  async createCustomLoginKeys() {
92904
93613
  return this.cloudService.request('CreateCustomLoginKeys', {
@@ -112940,6 +113649,52 @@ Promise.PromiseInspection = PromiseInspection;
112940
113649
  };
112941
113650
 
112942
113651
 
113652
+ /***/ }),
113653
+
113654
+ /***/ 34902:
113655
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
113656
+
113657
+ "use strict";
113658
+
113659
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
113660
+ const utils_1 = __webpack_require__(98786);
113661
+ const utils_lang_1 = __webpack_require__(82174);
113662
+ const isStream = __webpack_require__(31232);
113663
+ /**
113664
+ * 是否能够使用 FormData 发送数据
113665
+ * @param {any} data - 待发送的数据
113666
+ */
113667
+ function canUseFormdata(data) {
113668
+ let enable = true;
113669
+ for (const key in data) {
113670
+ const value = data[key];
113671
+ if (!isStream(value) && (utils_1.isNodeEnv() && !Buffer.isBuffer(value)) && !utils_lang_1.isString(value) && !utils_lang_1.isNumber(value)) {
113672
+ enable = false;
113673
+ break;
113674
+ }
113675
+ }
113676
+ return enable;
113677
+ }
113678
+ exports.canUseFormdata = canUseFormdata;
113679
+ /**
113680
+ * 是否一定要通过 FormData 发送数据
113681
+ * 如果有 Buffer 和 Stream 必须用 multipart/form-data,如果同时还含有
113682
+ * @param {any} data - 待发送的数据
113683
+ */
113684
+ function mustUseFormdata(data) {
113685
+ let must = false;
113686
+ for (const key in data) {
113687
+ const value = data[key];
113688
+ if ((utils_1.isNodeEnv() && Buffer.isBuffer(value)) || isStream(value)) {
113689
+ must = true;
113690
+ break;
113691
+ }
113692
+ }
113693
+ return must;
113694
+ }
113695
+ exports.mustUseFormdata = mustUseFormdata;
113696
+
113697
+
112943
113698
  /***/ }),
112944
113699
 
112945
113700
  /***/ 34958:
@@ -115366,6 +116121,59 @@ function callSuccessCallback(callback, entries) {
115366
116121
  }
115367
116122
 
115368
116123
 
116124
+ /***/ }),
116125
+
116126
+ /***/ 36255:
116127
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
116128
+
116129
+ "use strict";
116130
+
116131
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
116132
+ const utils_lang_1 = __webpack_require__(82174);
116133
+ class SortedKeyValue {
116134
+ constructor(obj, selectkeys) {
116135
+ this._keys = [];
116136
+ this._values = [];
116137
+ this._pairs = [];
116138
+ this._obj = {};
116139
+ if (!utils_lang_1.isObject(obj)) {
116140
+ return this;
116141
+ }
116142
+ // https://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order
116143
+ // https://www.stefanjudis.com/today-i-learned/property-order-is-predictable-in-javascript-objects-since-es2015/
116144
+ Object.keys(obj || {}).sort((l, r) => {
116145
+ return l.toString().localeCompare(r);
116146
+ }).forEach(key => {
116147
+ if (!selectkeys || selectkeys.includes(key)) {
116148
+ this._keys.push(key);
116149
+ this._values.push(obj[key]);
116150
+ this._pairs.push([key, obj[key]]);
116151
+ this._obj[key.toLowerCase()] = obj[key];
116152
+ }
116153
+ });
116154
+ }
116155
+ static kv(obj, selectkeys) {
116156
+ return new SortedKeyValue(obj, selectkeys);
116157
+ }
116158
+ get(key) {
116159
+ return this._obj[key];
116160
+ }
116161
+ keys() {
116162
+ return this._keys;
116163
+ }
116164
+ values() {
116165
+ return this._values;
116166
+ }
116167
+ pairs() {
116168
+ return this._pairs;
116169
+ }
116170
+ toString(kvSeparator = '=', joinSeparator = '&') {
116171
+ return this._pairs.map((pair) => pair.join(kvSeparator)).join(joinSeparator);
116172
+ }
116173
+ }
116174
+ exports.SortedKeyValue = SortedKeyValue;
116175
+
116176
+
115369
116177
  /***/ }),
115370
116178
 
115371
116179
  /***/ 36340:
@@ -125826,6 +126634,7 @@ module.exports = setup;
125826
126634
  "use strict";
125827
126635
 
125828
126636
  Object.defineProperty(exports, "__esModule", ({ value: true }));
126637
+ exports.removeEmptyStringParams = removeEmptyStringParams;
125829
126638
  exports.buildCapiErrorMessage = buildCapiErrorMessage;
125830
126639
  exports.registerCapiTools = registerCapiTools;
125831
126640
  const zod_1 = __webpack_require__(21614);
@@ -125861,6 +126670,19 @@ function levenshteinDistance(left, right) {
125861
126670
  }
125862
126671
  return matrix[left.length][right.length];
125863
126672
  }
126673
+ /**
126674
+ * Remove empty string parameters from the params object.
126675
+ * Tencent Cloud APIs reject empty strings for required parameters like StartTime/EndTime.
126676
+ */
126677
+ function removeEmptyStringParams(params) {
126678
+ const cleaned = {};
126679
+ for (const [key, value] of Object.entries(params)) {
126680
+ if (value !== "") {
126681
+ cleaned[key] = value;
126682
+ }
126683
+ }
126684
+ return cleaned;
126685
+ }
125864
126686
  function findTcbActionEntry(action) {
125865
126687
  if (tcb_action_index_js_1.TCB_ACTION_INDEX_MAP[action]) {
125866
126688
  return tcb_action_index_js_1.TCB_ACTION_INDEX_MAP[action];
@@ -126047,9 +126869,10 @@ function registerCapiTools(server) {
126047
126869
  }
126048
126870
  let result;
126049
126871
  try {
126872
+ const cleanedParams = params ? removeEmptyStringParams(params) : {};
126050
126873
  result = await cloudbase.commonService(service).call({
126051
126874
  Action: action,
126052
- Param: params ?? {},
126875
+ Param: cleanedParams,
126053
126876
  });
126054
126877
  }
126055
126878
  catch (error) {
@@ -135849,7 +136672,7 @@ class TelemetryReporter {
135849
136672
  const nodeVersion = process.version; // Node.js版本
135850
136673
  const arch = os_1.default.arch(); // 系统架构
135851
136674
  // 从构建时注入的版本号获取MCP版本信息
135852
- const mcpVersion = process.env.npm_package_version || "2.23.3" || 0;
136675
+ const mcpVersion = process.env.npm_package_version || "2.23.5" || 0;
135853
136676
  return {
135854
136677
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
135855
136678
  deviceId: this.deviceId,
@@ -168346,6 +169169,16 @@ class SyncReader extends reader_1.default {
168346
169169
  exports["default"] = SyncReader;
168347
169170
 
168348
169171
 
169172
+ /***/ }),
169173
+
169174
+ /***/ 57676:
169175
+ /***/ ((__unused_webpack_module, exports) => {
169176
+
169177
+ "use strict";
169178
+
169179
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
169180
+
169181
+
168349
169182
  /***/ }),
168350
169183
 
168351
169184
  /***/ 57705:
@@ -171475,6 +172308,7 @@ const cloudApp_1 = __webpack_require__(32665);
171475
172308
  const permission_1 = __webpack_require__(24786);
171476
172309
  const sandbox_1 = __webpack_require__(48488);
171477
172310
  const aiModel_1 = __webpack_require__(34800);
172311
+ const monitor_1 = __webpack_require__(8901);
171478
172312
  class Environment {
171479
172313
  constructor(context, envId) {
171480
172314
  this.inited = false;
@@ -171500,6 +172334,7 @@ class Environment {
171500
172334
  this.cloudAppService = new cloudApp_1.CloudAppService(this);
171501
172335
  this.sandboxService = new sandbox_1.SandboxService(this);
171502
172336
  this.aiModelService = new aiModel_1.AiModelService(this);
172337
+ this.monitorService = new monitor_1.MonitorService(this);
171503
172338
  }
171504
172339
  async lazyInit() {
171505
172340
  if (!this.inited) {
@@ -171574,6 +172409,9 @@ class Environment {
171574
172409
  getAiModelService() {
171575
172410
  return this.aiModelService;
171576
172411
  }
172412
+ getMonitorService() {
172413
+ return this.monitorService;
172414
+ }
171577
172415
  getCommonService(serviceType = 'tcb', serviceVersion) {
171578
172416
  return new common_1.CommonService(this, serviceType, serviceVersion);
171579
172417
  }
@@ -187714,7 +188552,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
187714
188552
  exports.CloudBaseContext = void 0;
187715
188553
  const constant_1 = __webpack_require__(40762);
187716
188554
  class CloudBaseContext {
187717
- constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined, internalEndpointRegion = undefined, requestFn = undefined }) {
188555
+ constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined, internalEndpointRegion = undefined }) {
187718
188556
  this.secretId = secretId;
187719
188557
  this.secretKey = secretKey;
187720
188558
  this.token = token;
@@ -187723,7 +188561,6 @@ class CloudBaseContext {
187723
188561
  this.envType = envType;
187724
188562
  this.useInternalEndpoint = useInternalEndpoint;
187725
188563
  this.internalEndpointRegion = internalEndpointRegion;
187726
- this.requestFn = requestFn;
187727
188564
  }
187728
188565
  isInternalEndpoint() {
187729
188566
  return this.useInternalEndpoint !== undefined ? this.useInternalEndpoint : constant_1.USE_INTERNAL_ENDPOINT;
@@ -195620,7 +196457,7 @@ ${envIdSection}
195620
196457
  ## 环境信息
195621
196458
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
195622
196459
  - Node.js版本: ${process.version}
195623
- - MCP 版本:${process.env.npm_package_version || "2.23.3" || 0}
196460
+ - MCP 版本:${process.env.npm_package_version || "2.23.5" || 0}
195624
196461
  - 系统架构: ${os_1.default.arch()}
195625
196462
  - 时间: ${new Date().toISOString()}
195626
196463
  - 请求ID: ${requestId}
@@ -195701,7 +196538,7 @@ function createWrappedHandler(name, handler, server) {
195701
196538
  requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
195702
196539
  ide: server.ide || process.env.INTEGRATION_IDE || ''
195703
196540
  });
195704
- const mcpVersion = true ? "2.23.3" : 0;
196541
+ const mcpVersion = true ? "2.23.5" : 0;
195705
196542
  const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
195706
196543
  const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
195707
196544
  // 创建新的错误对象,保持原有的错误类型但更新消息
@@ -197010,7 +197847,7 @@ class UserService {
197010
197847
  }
197011
197848
  async describeUserList(options = {}) {
197012
197849
  const { EnvId } = this.environment.lazyEnvironmentConfig;
197013
- const { pageNo = 1, pageSize = 20, name, nickName, phone, email } = options;
197850
+ const { pageNo = 1, pageSize = 20, name, nickName, phone, email, uidList } = options;
197014
197851
  if (!Number.isInteger(pageNo) || pageNo < 1) {
197015
197852
  throw new Error('Invalid pageNo');
197016
197853
  }
@@ -197030,6 +197867,8 @@ class UserService {
197030
197867
  reqData.Phone = phone;
197031
197868
  if (this.isValidStr(email))
197032
197869
  reqData.Email = email;
197870
+ if (Array.isArray(uidList) && uidList.length > 0)
197871
+ reqData.UidList = uidList;
197033
197872
  return this.tcbService.request('DescribeUserList', reqData);
197034
197873
  }
197035
197874
  async modifyUser(options) {
@@ -199065,8 +199904,8 @@ class StorageService {
199065
199904
  typeof cacheControl === 'number' ? `max-age=${cacheControl}` : String(cacheControl);
199066
199905
  }
199067
199906
  if (metadata) {
199068
- // X-Metadata 放在 Header 里,具体大小限制由服务端/网关决定
199069
- headers['X-Metadata'] = Buffer.from(JSON.stringify(metadata), 'utf8').toString('base64');
199907
+ // x-metadata 放在 Header 里,具体大小限制由服务端/网关决定
199908
+ headers['x-metadata'] = Buffer.from(JSON.stringify(metadata), 'utf8').toString('base64');
199070
199909
  }
199071
199910
  if (upsert) {
199072
199911
  headers['x-upsert'] = 'true';
@@ -211713,7 +212552,7 @@ function registerSetupTools(server) {
211713
212552
  server.registerTool("downloadTemplate", {
211714
212553
  title: "下载项目模板",
211715
212554
  description: `自动下载并部署CloudBase项目模板。
211716
- **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.23.3" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
212555
+ **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.23.5" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
211717
212556
  inputSchema: {
211718
212557
  template: zod_1.z
211719
212558
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
@@ -213556,6 +214395,50 @@ module.exports = function one(fn) {
213556
214395
  };
213557
214396
 
213558
214397
 
214398
+ /***/ }),
214399
+
214400
+ /***/ 77463:
214401
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
214402
+
214403
+ "use strict";
214404
+
214405
+ function __export(m) {
214406
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
214407
+ }
214408
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
214409
+ __export(__webpack_require__(36255));
214410
+ __export(__webpack_require__(12129));
214411
+ __export(__webpack_require__(34902));
214412
+ __export(__webpack_require__(82174));
214413
+ __export(__webpack_require__(98786));
214414
+ const signer_1 = __webpack_require__(12129);
214415
+ const utils_1 = __webpack_require__(98786);
214416
+ const clone = __webpack_require__(1779);
214417
+ function sign(options) {
214418
+ const { secretId, secretKey, method, url, service, withSignedParams, isCloudApi } = options;
214419
+ // isCloudApi 为 true, 说明使用 cloud api v3, 返回签名值中不能携带 signedParams
214420
+ let validWithSignedParams = withSignedParams;
214421
+ if (isCloudApi === true && withSignedParams === true) {
214422
+ console.warn('isCloudApi 和 withSignedParams 参数同时为 true, withSignedParams 会自动转为 false');
214423
+ validWithSignedParams = false;
214424
+ }
214425
+ const signer = new signer_1.Signer({ secretId, secretKey }, service || 'tcb');
214426
+ const headers = clone(options.headers || {});
214427
+ const params = clone(options.params || {});
214428
+ const timestamp = options.timestamp || utils_1.second() - 1;
214429
+ const signatureInfo = signer.tc3sign(method, url, headers, params, timestamp, {
214430
+ withSignedParams: validWithSignedParams,
214431
+ isCloudApi
214432
+ });
214433
+ return {
214434
+ authorization: signatureInfo.authorization,
214435
+ timestamp: signatureInfo.timestamp,
214436
+ multipart: signatureInfo.multipart
214437
+ };
214438
+ }
214439
+ exports.sign = sign;
214440
+
214441
+
213559
214442
  /***/ }),
213560
214443
 
213561
214444
  /***/ 77474:
@@ -221900,13 +222783,12 @@ function getDate(timestamp) {
221900
222783
  }
221901
222784
  class CloudService {
221902
222785
  /* eslint-disable-next-line */
221903
- constructor(context, service, version, baseParams, requestFn) {
222786
+ constructor(context, service, version, baseParams) {
221904
222787
  this.service = service;
221905
222788
  this.version = version;
221906
222789
  this.timeout = 60000;
221907
222790
  this.baseParams = baseParams || {};
221908
222791
  this.cloudBaseContext = context;
221909
- this.requestFn = requestFn !== null && requestFn !== void 0 ? requestFn : context.requestFn;
221910
222792
  }
221911
222793
  get baseUrl() {
221912
222794
  const internalEndpoint = this.cloudBaseContext.isInternalEndpoint();
@@ -221938,31 +222820,8 @@ class CloudService {
221938
222820
  }
221939
222821
  }
221940
222822
  async request(action, data = {}, method = 'POST') {
221941
- var _a;
221942
222823
  this.action = action;
221943
222824
  this.data = deepRemoveVoid(Object.assign(Object.assign({}, data), this.baseParams));
221944
- // 如果注入了 requestFn,直接委托,跳过 TC3 签名逻辑
221945
- if (this.requestFn) {
221946
- try {
221947
- const result = await this.requestFn({
221948
- service: this.service,
221949
- action,
221950
- version: this.version,
221951
- region: (_a = this.cloudBaseContext.region) !== null && _a !== void 0 ? _a : '',
221952
- payload: this.data,
221953
- });
221954
- return result;
221955
- }
221956
- catch (e) {
221957
- if (e.name === 'CloudBaseError') {
221958
- throw e;
221959
- }
221960
- throw new error_1.CloudBaseError(e.message, {
221961
- action,
221962
- code: e.code
221963
- });
221964
- }
221965
- }
221966
222825
  this.method = method;
221967
222826
  this.url = this.baseUrl;
221968
222827
  let { secretId, secretKey, token } = this.cloudBaseContext;
@@ -222363,6 +223222,32 @@ webpackEmptyContext.resolve = webpackEmptyContext;
222363
223222
  webpackEmptyContext.id = 82154;
222364
223223
  module.exports = webpackEmptyContext;
222365
223224
 
223225
+ /***/ }),
223226
+
223227
+ /***/ 82174:
223228
+ /***/ ((__unused_webpack_module, exports) => {
223229
+
223230
+ "use strict";
223231
+
223232
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
223233
+ function isNumber(v) {
223234
+ return v === +v;
223235
+ }
223236
+ exports.isNumber = isNumber;
223237
+ function isString(v) {
223238
+ return typeof v === 'string';
223239
+ }
223240
+ exports.isString = isString;
223241
+ function isObject(v) {
223242
+ return v != null && typeof v === 'object' && Array.isArray(v) === false;
223243
+ }
223244
+ exports.isObject = isObject;
223245
+ function isPlainObject(v) {
223246
+ return isObject(v) && [null, Object.prototype].includes(Object.getPrototypeOf(v));
223247
+ }
223248
+ exports.isPlainObject = isPlainObject;
223249
+
223250
+
222366
223251
  /***/ }),
222367
223252
 
222368
223253
  /***/ 82218:
@@ -252713,7 +253598,7 @@ const queryStorageInputSchema = {
252713
253598
  // Input schema for manageStorage tool
252714
253599
  const manageStorageInputSchema = {
252715
253600
  action: zod_1.z.enum(['upload', 'download', 'delete']).describe('管理操作类型:upload=上传文件或目录,download=下载文件或目录,delete=删除文件或目录'),
252716
- localPath: zod_1.z.string().describe('本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt'),
253601
+ localPath: zod_1.z.string().optional().describe('本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt;upload/download 操作时必填,delete 操作时不需要传该参数'),
252717
253602
  cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt'),
252718
253603
  force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,删除操作时建议设置为true以确认删除,默认false'),
252719
253604
  isDirectory: zod_1.z.boolean().optional().default(false).describe('是否为目录操作,true=目录操作,false=文件操作,默认false')
@@ -252963,14 +253848,16 @@ function registerStorageTools(server) {
252963
253848
  const storageService = manager.storage;
252964
253849
  switch (input.action) {
252965
253850
  case 'upload': {
253851
+ const localPath = input.localPath;
253852
+ const cloudPath = input.cloudPath;
252966
253853
  if (input.isDirectory) {
252967
253854
  if (storageOverrides?.uploadDirectory) {
252968
- await storageOverrides.uploadDirectory({ localPath: input.localPath, cloudPath: input.cloudPath });
253855
+ await storageOverrides.uploadDirectory({ localPath, cloudPath });
252969
253856
  }
252970
253857
  else {
252971
253858
  await storageService.uploadDirectory({
252972
- localPath: input.localPath,
252973
- cloudPath: input.cloudPath,
253859
+ localPath,
253860
+ cloudPath,
252974
253861
  onProgress: (progressData) => {
252975
253862
  console.log("Upload directory progress:", progressData);
252976
253863
  }
@@ -252979,12 +253866,12 @@ function registerStorageTools(server) {
252979
253866
  }
252980
253867
  else {
252981
253868
  if (storageOverrides?.uploadFile) {
252982
- await storageOverrides.uploadFile({ localPath: input.localPath, cloudPath: input.cloudPath });
253869
+ await storageOverrides.uploadFile({ localPath, cloudPath });
252983
253870
  }
252984
253871
  else {
252985
253872
  await storageService.uploadFile({
252986
- localPath: input.localPath,
252987
- cloudPath: input.cloudPath,
253873
+ localPath,
253874
+ cloudPath,
252988
253875
  onProgress: (progressData) => {
252989
253876
  console.log("Upload file progress:", progressData);
252990
253877
  }
@@ -253051,25 +253938,27 @@ function registerStorageTools(server) {
253051
253938
  };
253052
253939
  }
253053
253940
  case 'download': {
253941
+ const dlCloudPath = input.cloudPath;
253942
+ const dlLocalPath = input.localPath;
253054
253943
  if (input.isDirectory) {
253055
253944
  if (storageOverrides?.downloadDirectory) {
253056
- await storageOverrides.downloadDirectory({ cloudPath: input.cloudPath, localPath: input.localPath });
253945
+ await storageOverrides.downloadDirectory({ cloudPath: dlCloudPath, localPath: dlLocalPath });
253057
253946
  }
253058
253947
  else {
253059
253948
  await storageService.downloadDirectory({
253060
- cloudPath: input.cloudPath,
253061
- localPath: input.localPath
253949
+ cloudPath: dlCloudPath,
253950
+ localPath: dlLocalPath
253062
253951
  });
253063
253952
  }
253064
253953
  }
253065
253954
  else {
253066
253955
  if (storageOverrides?.downloadFile) {
253067
- await storageOverrides.downloadFile({ cloudPath: input.cloudPath, localPath: input.localPath });
253956
+ await storageOverrides.downloadFile({ cloudPath: dlCloudPath, localPath: dlLocalPath });
253068
253957
  }
253069
253958
  else {
253070
253959
  await storageService.downloadFile({
253071
- cloudPath: input.cloudPath,
253072
- localPath: input.localPath
253960
+ cloudPath: dlCloudPath,
253961
+ localPath: dlLocalPath
253073
253962
  });
253074
253963
  }
253075
253964
  }
@@ -261405,9 +262294,9 @@ class CloudBase {
261405
262294
  }
261406
262295
  constructor(config = {}) {
261407
262296
  this.cloudBaseConfig = {};
261408
- let { secretId, secretKey, token, envId, proxy, region, envType, useInternalEndpoint, internalEndpointRegion, requestFn } = config;
261409
- // config 中传入的 secretId secretkey 必须同时存在(有 requestFn 时可以不传)
261410
- if (!requestFn && ((secretId && !secretKey) || (!secretId && secretKey))) {
262297
+ let { secretId, secretKey, token, envId, proxy, region, envType, useInternalEndpoint, internalEndpointRegion } = config;
262298
+ // config 中传入的 secretId secretkey 必须同时存在
262299
+ if ((secretId && !secretKey) || (!secretId && secretKey)) {
261411
262300
  throw new Error('secretId and secretKey must be a pair');
261412
262301
  }
261413
262302
  this.cloudBaseConfig = {
@@ -261420,7 +262309,6 @@ class CloudBase {
261420
262309
  region,
261421
262310
  useInternalEndpoint,
261422
262311
  internalEndpointRegion,
261423
- requestFn,
261424
262312
  };
261425
262313
  // 初始化 context
261426
262314
  this.context = new context_1.CloudBaseContext(this.cloudBaseConfig);
@@ -261509,6 +262397,9 @@ class CloudBase {
261509
262397
  get aiModel() {
261510
262398
  return this.currentEnvironment().getAiModelService();
261511
262399
  }
262400
+ get monitor() {
262401
+ return this.currentEnvironment().getMonitorService();
262402
+ }
261512
262403
  get docs() {
261513
262404
  if (!this.docsService) {
261514
262405
  this.docsService = new docs_1.DocsService();
@@ -266328,6 +267219,48 @@ if (typeof fs.realpath.native === 'function') {
266328
267219
  }
266329
267220
 
266330
267221
 
267222
+ /***/ }),
267223
+
267224
+ /***/ 98786:
267225
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
267226
+
267227
+ "use strict";
267228
+
267229
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
267230
+ const crypto = __webpack_require__(55511);
267231
+ function formateDate(timestamp) {
267232
+ return new Date(timestamp * 1000).toISOString().split('T')[0];
267233
+ }
267234
+ exports.formateDate = formateDate;
267235
+ function second() {
267236
+ // istanbul ignore next
267237
+ return Math.floor(new Date().getTime() / 1000);
267238
+ }
267239
+ exports.second = second;
267240
+ function stringify(v) {
267241
+ return typeof v !== 'string' ? JSON.stringify(v) : v;
267242
+ }
267243
+ exports.stringify = stringify;
267244
+ function sha256hash(string, encoding = 'hex') {
267245
+ return crypto
267246
+ .createHash('sha256')
267247
+ .update(string)
267248
+ .digest(encoding);
267249
+ }
267250
+ exports.sha256hash = sha256hash;
267251
+ function sha256hmac(string, secret = '', encoding) {
267252
+ return crypto
267253
+ .createHmac('sha256', secret)
267254
+ .update(string)
267255
+ .digest(encoding);
267256
+ }
267257
+ exports.sha256hmac = sha256hmac;
267258
+ function isNodeEnv() {
267259
+ return process && process.release && process.release.name === 'node';
267260
+ }
267261
+ exports.isNodeEnv = isNodeEnv;
267262
+
267263
+
266331
267264
  /***/ }),
266332
267265
 
266333
267266
  /***/ 98916: