@vrs-soft/wecom-aibot-mcp 2.4.16 → 2.4.18

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.
@@ -50,6 +50,9 @@ let sseConnected = false;
50
50
  let sseAbortController = null;
51
51
  let mcpServer = null;
52
52
  let sseCurrentCcId = undefined;
53
+ // 保存首次 enter_headless_mode 的参数,重连时原样复用
54
+ let sseRobotId = undefined;
55
+ let sseProjectDir = undefined;
53
56
  // HTTP MCP session ID(需要在转发请求前初始化)
54
57
  let httpSessionId = null;
55
58
  /**
@@ -215,8 +218,9 @@ function connectSSE(ccId) {
215
218
  // 重新调 enter_headless_mode 恢复 server 端 ccId 注册
216
219
  await forwardToHttpMcp('enter_headless_mode', {
217
220
  cc_id: ccId,
221
+ robot_id: sseRobotId,
218
222
  mode: 'channel',
219
- project_dir: process.cwd(),
223
+ project_dir: sseProjectDir || process.cwd(),
220
224
  }).catch((e) => logChannel('重注册 ccId 失败', { error: String(e) }));
221
225
  }
222
226
  connectSSE(ccId);
@@ -435,6 +439,9 @@ function registerChannelTools(server) {
435
439
  const parsed = JSON.parse(content[0].text);
436
440
  if (parsed.ccId) {
437
441
  logChannel('Got ccId, connecting SSE', { ccId: parsed.ccId, mode });
442
+ // 保存连接参数供重连复用
443
+ sseRobotId = robot_id || parsed.robotName;
444
+ sseProjectDir = project_dir || process.cwd();
438
445
  connectSSE(parsed.ccId);
439
446
  // Channel 模式:在本地项目写入 PermissionRequest hook
440
447
  const localProjectDir = project_dir || process.cwd();
package/dist/client.js CHANGED
@@ -252,7 +252,7 @@ class WecomClient extends EventEmitter {
252
252
  : eventKey === 'allow-always' ? '✅ 已允许(永久)'
253
253
  : '❌ 已拒绝';
254
254
  const toolInfo = approval.toolName ? `: ${approval.toolName}` : '';
255
- const desc = approval.description || '';
255
+ const desc = (approval.description || '').replace(/^执行命令:\s*/i, '');
256
256
  const descSnippet = desc ? `\n执行命令: ${desc.slice(0, 100)}${desc.length > 100 ? '…' : ''}` : '';
257
257
  const content = `**审批结果**${toolInfo}\n\n${resultText}${descSnippet}`;
258
258
  this.sendText(content).catch(err => {
@@ -462,7 +462,7 @@ class WecomClient extends EventEmitter {
462
462
  const resultText = result === 'deny' ? '❌ 已拒绝' : '✅ 已允许';
463
463
  const reasonText = reason ? `\n\n原因:${reason}` : '';
464
464
  const toolInfo = approval.toolName ? `: ${approval.toolName}` : '';
465
- const desc = approval.description || '';
465
+ const desc = (approval.description || '').replace(/^执行命令:\s*/i, '');
466
466
  const descBlock = desc ? `\n\n**执行命令**\n\`\`\`\n${desc}\n\`\`\`` : '';
467
467
  this.sendText(`**审批结果(超时自动决策)**${toolInfo}\n\n${resultText}${reasonText}${descBlock}`).catch(err => {
468
468
  logger.error('[wecom] 发送审批确认失败:', err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vrs-soft/wecom-aibot-mcp",
3
- "version": "2.4.16",
3
+ "version": "2.4.18",
4
4
  "description": "企业微信智能机器人 MCP 服务 - Claude Code 审批通道",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",