@vrs-soft/wecom-aibot-mcp 2.4.6 → 2.4.7

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.
@@ -16,6 +16,7 @@ import * as fs from 'fs';
16
16
  import * as path from 'path';
17
17
  import * as os from 'os';
18
18
  import { VERSION } from './config-wizard.js';
19
+ import { addPermissionHook } from './project-config.js';
19
20
  const MCP_URL = process.env.MCP_URL || 'http://127.0.0.1:18963';
20
21
  const MCP_AUTH_TOKEN = process.env.MCP_AUTH_TOKEN;
21
22
  // 构建带 auth 的 fetch headers
@@ -419,6 +420,10 @@ function registerChannelTools(server) {
419
420
  if (parsed.ccId) {
420
421
  logChannel('Got ccId, connecting SSE', { ccId: parsed.ccId, mode });
421
422
  connectSSE(parsed.ccId);
423
+ // Channel 模式:在本地项目写入 PermissionRequest hook
424
+ const localProjectDir = project_dir || process.cwd();
425
+ const hookResult = addPermissionHook(localProjectDir);
426
+ logChannel('本地 PermissionRequest hook 已写入', { path: hookResult.path, success: hookResult.success });
422
427
  // Channel 模式:过滤 heartbeat 信息,简化消息
423
428
  if (mode === 'channel' || parsed.mode === 'channel') {
424
429
  delete parsed.heartbeat; // Channel 模式不需要 heartbeat loop
@@ -1020,19 +1020,18 @@ function writeMcpPermissions() {
1020
1020
  if (!existingPerms.has(perm))
1021
1021
  settings.permissions.allow.push(perm);
1022
1022
  }
1023
- // 删除全局 PermissionRequest hookhook enter_headless_mode 写入项目级别)
1024
- if (settings.hooks && settings.hooks['PermissionRequest']) {
1025
- // 只删除 wecom-aibot 相关的 hook
1026
- settings.hooks['PermissionRequest'] = settings.hooks['PermissionRequest'].filter((hook) => !hook.hooks?.some?.((h) => h.command?.includes?.('wecom-aibot-mcp')));
1027
- if (settings.hooks['PermissionRequest'].length === 0) {
1028
- delete settings.hooks['PermissionRequest'];
1029
- }
1030
- if (Object.keys(settings.hooks).length === 0) {
1031
- delete settings.hooks;
1032
- }
1023
+ // 注册全局 PermissionRequest hook(支持 channel 模式,hook 内部有 wechatMode 检查)
1024
+ if (!settings.hooks)
1025
+ settings.hooks = {};
1026
+ if (!settings.hooks['PermissionRequest'])
1027
+ settings.hooks['PermissionRequest'] = [];
1028
+ const hookCommand = HOOK_SCRIPT_PATH;
1029
+ const alreadyRegistered = settings.hooks['PermissionRequest'].some((entry) => entry.hooks?.some?.((h) => h.command === hookCommand));
1030
+ if (!alreadyRegistered) {
1031
+ settings.hooks['PermissionRequest'].push({ hooks: [{ type: 'command', command: hookCommand }] });
1033
1032
  }
1034
1033
  fs.writeFileSync(CLAUDE_SETTINGS_FILE, JSON.stringify(settings, null, 2));
1035
- // 确保 hook 脚本文件存在(进入微信模式时需要)
1034
+ // 确保 hook 脚本文件存在
1036
1035
  writeHookScript();
1037
1036
  }
1038
1037
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vrs-soft/wecom-aibot-mcp",
3
- "version": "2.4.6",
3
+ "version": "2.4.7",
4
4
  "description": "企业微信智能机器人 MCP 服务 - Claude Code 审批通道",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",