@cloudbase/cloudbase-mcp 2.24.0 → 2.24.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
@@ -1761,6 +1761,8 @@ warn.forProperties(exports, 'deprecated', ['emitErrs', 'levelLength']);
1761
1761
  "use strict";
1762
1762
 
1763
1763
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1764
+ exports.DEFAULT_CREATE_ENV_RESOURCES = exports.CREATE_ENV_RESOURCE_VALUES = void 0;
1765
+ exports.resolveCreateEnvResources = resolveCreateEnvResources;
1764
1766
  exports.simplifyEnvList = simplifyEnvList;
1765
1767
  exports.registerEnvTools = registerEnvTools;
1766
1768
  const toolbox_1 = __webpack_require__(25901);
@@ -1770,6 +1772,26 @@ const cloudbase_manager_js_1 = __webpack_require__(3431);
1770
1772
  const logger_js_1 = __webpack_require__(13039);
1771
1773
  const tool_result_js_1 = __webpack_require__(9835);
1772
1774
  const env_setup_js_1 = __webpack_require__(6978);
1775
+ /**
1776
+ * Resources accepted by CreateEnv. Matches Cloud API / Manager SDK contract.
1777
+ * `postgresql` enables CloudBase PostgreSQL (PG mode) when supported by the package.
1778
+ */
1779
+ exports.CREATE_ENV_RESOURCE_VALUES = [
1780
+ "flexdb",
1781
+ "storage",
1782
+ "function",
1783
+ "postgresql",
1784
+ ];
1785
+ /** Default Resources when callers omit the field (schema promises "all four"). */
1786
+ exports.DEFAULT_CREATE_ENV_RESOURCES = [
1787
+ ...exports.CREATE_ENV_RESOURCE_VALUES,
1788
+ ];
1789
+ function resolveCreateEnvResources(resources) {
1790
+ if (Array.isArray(resources) && resources.length > 0) {
1791
+ return [...resources];
1792
+ }
1793
+ return [...exports.DEFAULT_CREATE_ENV_RESOURCES];
1794
+ }
1773
1795
  /**
1774
1796
  * Simplify environment list data by keeping only essential fields for AI assistant
1775
1797
  * This reduces token consumption when returning environment lists via MCP tools
@@ -2535,7 +2557,13 @@ function resolveToolAuthOptions(server, overrides) {
2535
2557
  function registerEnvTools(server) {
2536
2558
  // 获取 cloudBaseOptions,如果没有则为 undefined
2537
2559
  const cloudBaseOptions = server.cloudBaseOptions;
2538
- const getManager = () => (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, mcpServer: server });
2560
+ // Default: env-scoped tools need a bound envId (domains / domain management use SDK this.envId).
2561
+ // manageEnv create/listPackages are account-level — use requireEnvId: false there only.
2562
+ const getManager = (options) => (0, cloudbase_manager_js_1.getCloudBaseManager)({
2563
+ cloudBaseOptions,
2564
+ requireEnvId: options?.requireEnvId ?? true,
2565
+ mcpServer: server,
2566
+ });
2539
2567
  const getManagerForEnvQuery = (targetEnvId, requireEnvId = true) => (0, cloudbase_manager_js_1.getCloudBaseManager)({
2540
2568
  cloudBaseOptions: targetEnvId && targetEnvId !== cloudBaseOptions?.envId
2541
2569
  ? {
@@ -3416,14 +3444,10 @@ function registerEnvTools(server) {
3416
3444
  .string()
3417
3445
  .optional()
3418
3446
  .describe("套餐 ID(action=create/modifyPlan 时必填)。可选值如 baas_personal(个人版)、baas_pf_standard(标准版)、baas_pf_enterprise(企业版)"),
3419
- region: zod_1.z
3420
- .string()
3421
- .optional()
3422
- .describe("环境地域(action=create 时可选)。默认 ap-shanghai,可选 ap-guangzhou、ap-beijing 等"),
3423
3447
  resources: zod_1.z
3424
- .array(zod_1.z.enum(["flexdb", "storage", "function", "postgresql"]))
3448
+ .array(zod_1.z.enum(exports.CREATE_ENV_RESOURCE_VALUES))
3425
3449
  .optional()
3426
- .describe("启用的资源类型(action=create 时可选)。默认启用全部四项:flexdb(文档数据库)、storage(存储)、function(云函数)、postgresql(PostgreSQL 数据库)"),
3450
+ .describe("启用的资源类型(action=create 时可选)。省略时默认全部四项:flexdb(文档数据库)、storage(存储)、function(云函数)、postgresql(PostgreSQL)。CreateEnv 要求 Resources 非空,MCP 会始终下发该字段。"),
3427
3451
  duration: zod_1.z
3428
3452
  .number()
3429
3453
  .int()
@@ -3451,17 +3475,19 @@ function registerEnvTools(server) {
3451
3475
  const action = rawArgs.action ?? "";
3452
3476
  const alias = normalizeOptionalToolString(rawArgs.alias);
3453
3477
  const packageId = normalizeOptionalToolString(rawArgs.packageId);
3454
- const region = normalizeOptionalToolString(rawArgs.region) ?? "ap-shanghai";
3455
- const resources = rawArgs.resources;
3478
+ const resolvedResources = resolveCreateEnvResources(rawArgs.resources);
3456
3479
  const duration = rawArgs.duration ?? 1;
3457
3480
  const envId = normalizeOptionalToolString(rawArgs.envId);
3458
3481
  const confirmed = rawArgs.confirm === "yes";
3459
3482
  try {
3460
- const cloudbase = await getManager();
3483
+ const cloudbase = await getManager({ requireEnvId: false });
3461
3484
  switch (action) {
3462
3485
  case "listPackages": {
3463
- // 查询可选套餐列表(新购场景)
3464
- const result = await cloudbase.env.describeBaasPackageList({ TargetAction: "new" });
3486
+ // Query packages for new purchase. Source aligns with billing-side Baas package APIs.
3487
+ const result = await cloudbase.env.describeBaasPackageList({
3488
+ TargetAction: "new",
3489
+ Source: "qcloud",
3490
+ });
3465
3491
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
3466
3492
  return (0, tool_result_js_1.buildJsonToolResult)({
3467
3493
  ok: true,
@@ -3471,12 +3497,13 @@ function registerEnvTools(server) {
3471
3497
  });
3472
3498
  }
3473
3499
  case "create": {
3474
- // 创建环境需要 confirm
3500
+ // CreateEnv (Manager SDK / Cloud API) accepts Alias, PackageId, Resources, Period, etc.
3501
+ // It does NOT accept Region — region is determined by account/package, not this call.
3475
3502
  if (!confirmed) {
3476
3503
  return (0, tool_result_js_1.buildJsonToolResult)({
3477
3504
  ok: false,
3478
3505
  code: "CONFIRM_REQUIRED",
3479
- message: `创建环境需要您确认。请确认以下配置信息后传入 confirm="yes":\n别名: ${alias}\n套餐: ${packageId}\n地域: ${region}\n资源类型: ${resources?.join(", ") ?? "flexdb, storage, function, postgresql"}\n时长: ${duration} 个月`,
3506
+ message: `创建环境需要您确认。请确认以下配置信息后传入 confirm="yes":\n别名: ${alias}\n套餐: ${packageId}\n资源类型: ${resolvedResources.join(", ")}\n时长: ${duration} 个月\n说明: CreateEnv 不接受 Region;环境地域由账号与套餐侧决定。`,
3480
3507
  next_step: {
3481
3508
  tool: "manageEnv",
3482
3509
  action: "create",
@@ -3493,12 +3520,9 @@ function registerEnvTools(server) {
3493
3520
  const createParams = {
3494
3521
  Alias: alias,
3495
3522
  PackageId: packageId,
3496
- Region: region,
3523
+ Resources: resolvedResources,
3497
3524
  Period: duration,
3498
3525
  };
3499
- if (resources && resources.length > 0) {
3500
- createParams.Resources = resources;
3501
- }
3502
3526
  const result = await cloudbase.env.createEnv(createParams);
3503
3527
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
3504
3528
  return (0, tool_result_js_1.buildJsonToolResult)({
@@ -3506,6 +3530,7 @@ function registerEnvTools(server) {
3506
3530
  code: "ENV_CREATED",
3507
3531
  message: `环境创建成功!新环境 ID: ${result.EnvId}。环境初始化可能需要几分钟,请通过 queryEnv(action="info", envId="${result.EnvId}") 轮询直到 Status 为正常。`,
3508
3532
  envId: result.EnvId,
3533
+ resources: resolvedResources,
3509
3534
  });
3510
3535
  }
3511
3536
  case "modifyPlan": {
@@ -3583,11 +3608,19 @@ function registerEnvTools(server) {
3583
3608
  if (toolPayloadResult) {
3584
3609
  return toolPayloadResult;
3585
3610
  }
3611
+ const errorMessage = error instanceof Error ? error.message : String(error);
3612
+ if (action === "listPackages" && /billTags/i.test(errorMessage)) {
3613
+ return (0, tool_result_js_1.buildJsonToolResult)({
3614
+ ok: false,
3615
+ code: "PACKAGE_LIST_FAILED",
3616
+ message: `查询套餐列表失败(计费标签 BillTags):${errorMessage}。可改用控制台查看套餐,或直接使用已知 packageId(如 baas_personal)调用 manageEnv(action="create")。`,
3617
+ });
3618
+ }
3586
3619
  return {
3587
3620
  content: [
3588
3621
  {
3589
3622
  type: "text",
3590
- text: `环境管理操作失败: ${error instanceof Error ? error.message : String(error)}`,
3623
+ text: `环境管理操作失败: ${errorMessage}`,
3591
3624
  },
3592
3625
  ],
3593
3626
  };
@@ -136828,6 +136861,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
136828
136861
  };
136829
136862
  Object.defineProperty(exports, "__esModule", ({ value: true }));
136830
136863
  exports.reportToolkitLifecycle = exports.reportToolCall = exports.telemetryReporter = void 0;
136864
+ exports.extractMcpClientInfo = extractMcpClientInfo;
136865
+ exports.readMcpClientInfoFromServer = readMcpClientInfoFromServer;
136831
136866
  const crypto_1 = __importDefault(__webpack_require__(55511));
136832
136867
  const http_1 = __importDefault(__webpack_require__(81630));
136833
136868
  const https_1 = __importDefault(__webpack_require__(55591));
@@ -136879,7 +136914,7 @@ class TelemetryReporter {
136879
136914
  const nodeVersion = process.version; // Node.js版本
136880
136915
  const arch = os_1.default.arch(); // 系统架构
136881
136916
  // 从构建时注入的版本号获取MCP版本信息
136882
- const mcpVersion = process.env.npm_package_version || "2.24.0" || 0;
136917
+ const mcpVersion = process.env.npm_package_version || "2.24.1" || 0;
136883
136918
  return {
136884
136919
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
136885
136920
  deviceId: this.deviceId,
@@ -137061,6 +137096,49 @@ function resolveEnvId(cloudBaseOptions) {
137061
137096
  }
137062
137097
  return { envId, envIdSource };
137063
137098
  }
137099
+ /**
137100
+ * Normalize SDK Implementation / clientInfo into telemetry-safe fields.
137101
+ */
137102
+ function extractMcpClientInfo(clientVersion) {
137103
+ if (!clientVersion || typeof clientVersion !== "object") {
137104
+ return {};
137105
+ }
137106
+ const info = clientVersion;
137107
+ const name = typeof info.name === "string" ? info.name.trim() : "";
137108
+ const version = typeof info.version === "string" ? info.version.trim() : "";
137109
+ const title = typeof info.title === "string" ? info.title.trim() : "";
137110
+ return {
137111
+ ...(name ? { name } : {}),
137112
+ ...(version ? { version } : {}),
137113
+ ...(title ? { title } : {}),
137114
+ };
137115
+ }
137116
+ /**
137117
+ * Read MCP clientInfo from an McpServer after initialize.
137118
+ * Returns empty object when handshake has not completed or the accessor is unavailable.
137119
+ */
137120
+ function readMcpClientInfoFromServer(server) {
137121
+ try {
137122
+ return extractMcpClientInfo(server?.server?.getClientVersion?.());
137123
+ }
137124
+ catch {
137125
+ return {};
137126
+ }
137127
+ }
137128
+ function appendMcpClientInfoFields(eventData, clientInfo) {
137129
+ if (!clientInfo) {
137130
+ return;
137131
+ }
137132
+ if (clientInfo.name) {
137133
+ eventData.mcpClientName = clientInfo.name;
137134
+ }
137135
+ if (clientInfo.version) {
137136
+ eventData.mcpClientVersion = clientInfo.version;
137137
+ }
137138
+ if (clientInfo.title) {
137139
+ eventData.mcpClientTitle = clientInfo.title;
137140
+ }
137141
+ }
137064
137142
  // 便捷方法
137065
137143
  const reportToolCall = async (params) => {
137066
137144
  const { nodeVersion, osType, osRelease, arch, mcpVersion } = exports.telemetryReporter.getUserAgent();
@@ -137105,6 +137183,7 @@ const reportToolCall = async (params) => {
137105
137183
  if (params.ide) {
137106
137184
  eventData.ide = params.ide;
137107
137185
  }
137186
+ appendMcpClientInfoFields(eventData, params.mcpClientInfo);
137108
137187
  // Debug: 打印最终上报参数
137109
137188
  (0, logger_js_1.debug)('[telemetry] 工具调用上报参数', {
137110
137189
  toolName: params.toolName,
@@ -137147,6 +137226,7 @@ const reportToolkitLifecycle = async (params) => {
137147
137226
  if (params.ide) {
137148
137227
  eventData.ide = params.ide;
137149
137228
  }
137229
+ appendMcpClientInfoFields(eventData, params.mcpClientInfo);
137150
137230
  // Debug: 打印最终上报参数
137151
137231
  (0, logger_js_1.debug)('[telemetry] 生命周期事件上报参数', {
137152
137232
  event: params.event,
@@ -194204,10 +194284,13 @@ function parseCommaParts(str) {
194204
194284
  return parts;
194205
194285
  }
194206
194286
 
194207
- function expandTop(str) {
194287
+ function expandTop(str, options) {
194208
194288
  if (!str)
194209
194289
  return [];
194210
194290
 
194291
+ options = options || {};
194292
+ var max = options.max == null ? Infinity : options.max;
194293
+
194211
194294
  // I don't know why Bash 4.3 does this, but it does.
194212
194295
  // Anything starting with {} will have the first two bytes preserved
194213
194296
  // but *only* at the top level, so {},a}b will not expand to anything,
@@ -194218,7 +194301,7 @@ function expandTop(str) {
194218
194301
  str = '\\{\\}' + str.substr(2);
194219
194302
  }
194220
194303
 
194221
- return expand(escapeBraces(str), true).map(unescapeBraces);
194304
+ return expand(escapeBraces(str), max, true).map(unescapeBraces);
194222
194305
  }
194223
194306
 
194224
194307
  function identity(e) {
@@ -194239,110 +194322,115 @@ function gte(i, y) {
194239
194322
  return i >= y;
194240
194323
  }
194241
194324
 
194242
- function expand(str, isTop) {
194325
+ function expand(str, max, isTop) {
194243
194326
  var expansions = [];
194244
194327
 
194245
- var m = balanced('{', '}', str);
194246
- if (!m || /\$$/.test(m.pre)) return [str];
194328
+ // The `{a},b}` rewrite below restarts expansion on a rewritten string with
194329
+ // the same `max` and `isTop = true`. Loop instead of recursing so a long run
194330
+ // of non-expanding `{}` groups can't exhaust the call stack.
194331
+ for (;;) {
194332
+ var m = balanced('{', '}', str);
194333
+ if (!m || /\$$/.test(m.pre)) return [str];
194247
194334
 
194248
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
194249
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
194250
- var isSequence = isNumericSequence || isAlphaSequence;
194251
- var isOptions = m.body.indexOf(',') >= 0;
194252
- if (!isSequence && !isOptions) {
194253
- // {a},b}
194254
- if (m.post.match(/,(?!,).*\}/)) {
194255
- str = m.pre + '{' + m.body + escClose + m.post;
194256
- return expand(str);
194335
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
194336
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
194337
+ var isSequence = isNumericSequence || isAlphaSequence;
194338
+ var isOptions = m.body.indexOf(',') >= 0;
194339
+ if (!isSequence && !isOptions) {
194340
+ // {a},b}
194341
+ if (m.post.match(/,(?!,).*\}/)) {
194342
+ str = m.pre + '{' + m.body + escClose + m.post;
194343
+ isTop = true
194344
+ continue
194345
+ }
194346
+ return [str];
194257
194347
  }
194258
- return [str];
194259
- }
194260
194348
 
194261
- var n;
194262
- if (isSequence) {
194263
- n = m.body.split(/\.\./);
194264
- } else {
194265
- n = parseCommaParts(m.body);
194266
- if (n.length === 1) {
194267
- // x{{a,b}}y ==> x{a}y x{b}y
194268
- n = expand(n[0], false).map(embrace);
194349
+ var n;
194350
+ if (isSequence) {
194351
+ n = m.body.split(/\.\./);
194352
+ } else {
194353
+ n = parseCommaParts(m.body);
194269
194354
  if (n.length === 1) {
194270
- var post = m.post.length
194271
- ? expand(m.post, false)
194272
- : [''];
194273
- return post.map(function(p) {
194274
- return m.pre + n[0] + p;
194275
- });
194355
+ // x{{a,b}}y ==> x{a}y x{b}y
194356
+ n = expand(n[0], max, false).map(embrace);
194357
+ if (n.length === 1) {
194358
+ var post = m.post.length
194359
+ ? expand(m.post, max, false)
194360
+ : [''];
194361
+ return post.map(function(p) {
194362
+ return m.pre + n[0] + p;
194363
+ });
194364
+ }
194276
194365
  }
194277
194366
  }
194278
- }
194279
194367
 
194280
- // at this point, n is the parts, and we know it's not a comma set
194281
- // with a single entry.
194368
+ // at this point, n is the parts, and we know it's not a comma set
194369
+ // with a single entry.
194282
194370
 
194283
- // no need to expand pre, since it is guaranteed to be free of brace-sets
194284
- var pre = m.pre;
194285
- var post = m.post.length
194286
- ? expand(m.post, false)
194287
- : [''];
194288
-
194289
- var N;
194290
-
194291
- if (isSequence) {
194292
- var x = numeric(n[0]);
194293
- var y = numeric(n[1]);
194294
- var width = Math.max(n[0].length, n[1].length)
194295
- var incr = n.length == 3
194296
- ? Math.abs(numeric(n[2]))
194297
- : 1;
194298
- var test = lte;
194299
- var reverse = y < x;
194300
- if (reverse) {
194301
- incr *= -1;
194302
- test = gte;
194303
- }
194304
- var pad = n.some(isPadded);
194305
-
194306
- N = [];
194307
-
194308
- for (var i = x; test(i, y); i += incr) {
194309
- var c;
194310
- if (isAlphaSequence) {
194311
- c = String.fromCharCode(i);
194312
- if (c === '\\')
194313
- c = '';
194314
- } else {
194315
- c = String(i);
194316
- if (pad) {
194317
- var need = width - c.length;
194318
- if (need > 0) {
194319
- var z = new Array(need + 1).join('0');
194320
- if (i < 0)
194321
- c = '-' + z + c.slice(1);
194322
- else
194323
- c = z + c;
194371
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
194372
+ var pre = m.pre;
194373
+ var post = m.post.length
194374
+ ? expand(m.post, max, false)
194375
+ : [''];
194376
+
194377
+ var N;
194378
+
194379
+ if (isSequence) {
194380
+ var x = numeric(n[0]);
194381
+ var y = numeric(n[1]);
194382
+ var width = Math.max(n[0].length, n[1].length)
194383
+ var incr = n.length == 3
194384
+ ? Math.max(Math.abs(numeric(n[2])), 1)
194385
+ : 1;
194386
+ var test = lte;
194387
+ var reverse = y < x;
194388
+ if (reverse) {
194389
+ incr *= -1;
194390
+ test = gte;
194391
+ }
194392
+ var pad = n.some(isPadded);
194393
+
194394
+ N = [];
194395
+
194396
+ for (var i = x; test(i, y) && N.length < max; i += incr) {
194397
+ var c;
194398
+ if (isAlphaSequence) {
194399
+ c = String.fromCharCode(i);
194400
+ if (c === '\\')
194401
+ c = '';
194402
+ } else {
194403
+ c = String(i);
194404
+ if (pad) {
194405
+ var need = width - c.length;
194406
+ if (need > 0) {
194407
+ var z = new Array(need + 1).join('0');
194408
+ if (i < 0)
194409
+ c = '-' + z + c.slice(1);
194410
+ else
194411
+ c = z + c;
194412
+ }
194324
194413
  }
194325
194414
  }
194415
+ N.push(c);
194326
194416
  }
194327
- N.push(c);
194417
+ } else {
194418
+ N = concatMap(n, function(el) { return expand(el, max, false) });
194328
194419
  }
194329
- } else {
194330
- N = concatMap(n, function(el) { return expand(el, false) });
194331
- }
194332
194420
 
194333
- for (var j = 0; j < N.length; j++) {
194334
- for (var k = 0; k < post.length; k++) {
194335
- var expansion = pre + N[j] + post[k];
194336
- if (!isTop || isSequence || expansion)
194337
- expansions.push(expansion);
194421
+ for (var j = 0; j < N.length; j++) {
194422
+ for (var k = 0; k < post.length && expansions.length < max; k++) {
194423
+ var expansion = pre + N[j] + post[k];
194424
+ if (!isTop || isSequence || expansion)
194425
+ expansions.push(expansion);
194426
+ }
194338
194427
  }
194339
- }
194340
194428
 
194341
- return expansions;
194429
+ return expansions;
194430
+ }
194342
194431
  }
194343
194432
 
194344
194433
 
194345
-
194346
194434
  /***/ }),
194347
194435
 
194348
194436
  /***/ 69027:
@@ -196917,7 +197005,7 @@ ${envIdSection}
196917
197005
  ## 环境信息
196918
197006
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
196919
197007
  - Node.js版本: ${process.version}
196920
- - MCP 版本:${process.env.npm_package_version || "2.24.0" || 0}
197008
+ - MCP 版本:${process.env.npm_package_version || "2.24.1" || 0}
196921
197009
  - 系统架构: ${os_1.default.arch()}
196922
197010
  - 时间: ${new Date().toISOString()}
196923
197011
  - 请求ID: ${requestId}
@@ -196998,7 +197086,7 @@ function createWrappedHandler(name, handler, server) {
196998
197086
  requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
196999
197087
  ide: server.ide || process.env.INTEGRATION_IDE || ''
197000
197088
  });
197001
- const mcpVersion = true ? "2.24.0" : 0;
197089
+ const mcpVersion = true ? "2.24.1" : 0;
197002
197090
  const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
197003
197091
  const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
197004
197092
  // 创建新的错误对象,保持原有的错误类型但更新消息
@@ -197035,7 +197123,8 @@ function createWrappedHandler(name, handler, server) {
197035
197123
  error: errorMessage,
197036
197124
  inputParams: sanitizeArgs(args), // 添加入参上报
197037
197125
  cloudBaseOptions: cloudBaseOptions, // 传递 CloudBase 配置(可能已更新)
197038
- ide: server.ide || process.env.INTEGRATION_IDE // 传递集成IDE信息
197126
+ ide: server.ide || process.env.INTEGRATION_IDE, // 传递集成IDE信息
197127
+ mcpClientInfo: (0, telemetry_js_1.readMcpClientInfoFromServer)(server),
197039
197128
  }).catch(err => {
197040
197129
  // 静默处理上报错误,不影响主要功能
197041
197130
  (0, logger_js_1.debug)('遥测上报失败', { toolName: name, error: err instanceof Error ? err.message : String(err) });
@@ -213011,7 +213100,7 @@ function registerSetupTools(server) {
213011
213100
  server.registerTool("downloadTemplate", {
213012
213101
  title: "下载项目模板",
213013
213102
  description: `自动下载并部署CloudBase项目模板。
213014
- **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.24.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
213103
+ **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.24.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
213015
213104
  inputSchema: {
213016
213105
  template: zod_1.z
213017
213106
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
@@ -231225,10 +231314,13 @@ function parseCommaParts(str) {
231225
231314
  return parts;
231226
231315
  }
231227
231316
 
231228
- function expandTop(str) {
231317
+ function expandTop(str, options) {
231229
231318
  if (!str)
231230
231319
  return [];
231231
231320
 
231321
+ options = options || {};
231322
+ var max = options.max == null ? Infinity : options.max;
231323
+
231232
231324
  // I don't know why Bash 4.3 does this, but it does.
231233
231325
  // Anything starting with {} will have the first two bytes preserved
231234
231326
  // but *only* at the top level, so {},a}b will not expand to anything,
@@ -231239,7 +231331,7 @@ function expandTop(str) {
231239
231331
  str = '\\{\\}' + str.substr(2);
231240
231332
  }
231241
231333
 
231242
- return expand(escapeBraces(str), true).map(unescapeBraces);
231334
+ return expand(escapeBraces(str), max, true).map(unescapeBraces);
231243
231335
  }
231244
231336
 
231245
231337
  function embrace(str) {
@@ -231256,24 +231348,29 @@ function gte(i, y) {
231256
231348
  return i >= y;
231257
231349
  }
231258
231350
 
231259
- function expand(str, isTop) {
231351
+ function expand(str, max, isTop) {
231260
231352
  var expansions = [];
231261
231353
 
231262
- var m = balanced('{', '}', str);
231263
- if (!m) return [str];
231354
+ // The `{a},b}` rewrite below restarts expansion on a rewritten string with
231355
+ // the same `max` and `isTop = true`. Loop instead of recursing so a long run
231356
+ // of non-expanding `{}` groups can't exhaust the call stack.
231357
+ for (;;) {
231358
+ const m = balanced('{', '}', str)
231359
+ if (!m) return [str]
231264
231360
 
231265
- // no need to expand pre, since it is guaranteed to be free of brace-sets
231266
- var pre = m.pre;
231267
- var post = m.post.length
231268
- ? expand(m.post, false)
231269
- : [''];
231361
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
231362
+ const pre = m.pre
231270
231363
 
231271
- if (/\$$/.test(m.pre)) {
231272
- for (var k = 0; k < post.length; k++) {
231273
- var expansion = pre+ '{' + m.body + '}' + post[k];
231274
- expansions.push(expansion);
231364
+ if (/\$$/.test(m.pre)) {
231365
+ const post =
231366
+ m.post.length ? expand(m.post, max, false) : ['']
231367
+ for (let k = 0; k < post.length && k < max; k++) {
231368
+ const expansion = pre + '{' + m.body + '}' + post[k]
231369
+ expansions.push(expansion)
231370
+ }
231371
+ return expansions
231275
231372
  }
231276
- } else {
231373
+
231277
231374
  var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
231278
231375
  var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
231279
231376
  var isSequence = isNumericSequence || isAlphaSequence;
@@ -231282,11 +231379,18 @@ function expand(str, isTop) {
231282
231379
  // {a},b}
231283
231380
  if (m.post.match(/,(?!,).*\}/)) {
231284
231381
  str = m.pre + '{' + m.body + escClose + m.post;
231285
- return expand(str);
231382
+ isTop = true;
231383
+ continue;
231286
231384
  }
231287
231385
  return [str];
231288
231386
  }
231289
231387
 
231388
+ // Only expand post once we know this brace set actually expands. Computing
231389
+ // it before the early returns above expanded post a second time on every
231390
+ // non-expanding `{}`, which is what made inputs like `a{},{},{}...` blow up
231391
+ // exponentially.
231392
+ const post =
231393
+ m.post.length ? expand(m.post, max, false) : ['']
231290
231394
  var n;
231291
231395
  if (isSequence) {
231292
231396
  n = m.body.split(/\.\./);
@@ -231294,7 +231398,7 @@ function expand(str, isTop) {
231294
231398
  n = parseCommaParts(m.body);
231295
231399
  if (n.length === 1) {
231296
231400
  // x{{a,b}}y ==> x{a}y x{b}y
231297
- n = expand(n[0], false).map(embrace);
231401
+ n = expand(n[0], max, false).map(embrace);
231298
231402
  if (n.length === 1) {
231299
231403
  return post.map(function(p) {
231300
231404
  return m.pre + n[0] + p;
@@ -231312,7 +231416,7 @@ function expand(str, isTop) {
231312
231416
  var y = numeric(n[1]);
231313
231417
  var width = Math.max(n[0].length, n[1].length)
231314
231418
  var incr = n.length == 3
231315
- ? Math.abs(numeric(n[2]))
231419
+ ? Math.max(Math.abs(numeric(n[2])), 1)
231316
231420
  : 1;
231317
231421
  var test = lte;
231318
231422
  var reverse = y < x;
@@ -231324,7 +231428,7 @@ function expand(str, isTop) {
231324
231428
 
231325
231429
  N = [];
231326
231430
 
231327
- for (var i = x; test(i, y); i += incr) {
231431
+ for (var i = x; test(i, y) && N.length < max; i += incr) {
231328
231432
  var c;
231329
231433
  if (isAlphaSequence) {
231330
231434
  c = String.fromCharCode(i);
@@ -231349,24 +231453,23 @@ function expand(str, isTop) {
231349
231453
  N = [];
231350
231454
 
231351
231455
  for (var j = 0; j < n.length; j++) {
231352
- N.push.apply(N, expand(n[j], false));
231456
+ N.push.apply(N, expand(n[j], max, false));
231353
231457
  }
231354
231458
  }
231355
231459
 
231356
231460
  for (var j = 0; j < N.length; j++) {
231357
- for (var k = 0; k < post.length; k++) {
231461
+ for (var k = 0; k < post.length && expansions.length < max; k++) {
231358
231462
  var expansion = pre + N[j] + post[k];
231359
231463
  if (!isTop || isSequence || expansion)
231360
231464
  expansions.push(expansion);
231361
231465
  }
231362
231466
  }
231363
- }
231364
231467
 
231365
- return expansions;
231468
+ return expansions;
231469
+ }
231366
231470
  }
231367
231471
 
231368
231472
 
231369
-
231370
231473
  /***/ }),
231371
231474
 
231372
231475
  /***/ 85014:
package/dist/index.d.ts CHANGED
@@ -330,6 +330,13 @@ declare interface LoginState {
330
330
 
331
331
  export declare function logout(): Promise<void>;
332
332
 
333
+ /** MCP initialize clientInfo fields available after handshake via Server.getClientVersion(). */
334
+ declare type McpClientInfo = {
335
+ name?: string;
336
+ version?: string;
337
+ title?: string;
338
+ };
339
+
333
340
  export { McpServer }
334
341
 
335
342
  /** 各插件的可选配置 */
@@ -357,6 +364,7 @@ export declare const reportToolCall: (params: {
357
364
  inputParams?: any;
358
365
  cloudBaseOptions?: CloudBaseOptions;
359
366
  ide?: string;
367
+ mcpClientInfo?: McpClientInfo;
360
368
  }) => Promise<void>;
361
369
 
362
370
  export declare const reportToolkitLifecycle: (params: {
@@ -366,6 +374,7 @@ export declare const reportToolkitLifecycle: (params: {
366
374
  error?: string;
367
375
  cloudBaseOptions?: CloudBaseOptions;
368
376
  ide?: string;
377
+ mcpClientInfo?: McpClientInfo;
369
378
  }) => Promise<void>;
370
379
 
371
380
  export declare function resetCloudBaseManagerCache(): void;