@yeaft/webchat-agent 0.0.82 → 0.0.84

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.
Files changed (3) hide show
  1. package/crew.js +17 -1
  2. package/index.js +44 -7
  3. package/package.json +1 -1
package/crew.js CHANGED
@@ -724,7 +724,23 @@ ${otherRoles.map(r => `- ${r.name}: ${r.displayName}`).join('\n')}
724
724
  - 如果你有足够的信息做出决策,直接决定并 @相关角色执行
725
725
  - 如果你需要更多信息,@具体角色请求补充
726
726
  - 如果问题超出你的能力范围或需要业务判断,@human 请人类决定
727
- - 你可以随时审查其他角色的工作并给出反馈`;
727
+ - 你可以随时审查其他角色的工作并给出反馈
728
+
729
+ # 任务清单
730
+ 你可以在回复中添加 TASKS 块来发布/更新任务清单,团队界面会自动展示:
731
+
732
+ \`\`\`
733
+ ---TASKS---
734
+ - [ ] 任务描述 @角色name
735
+ - [x] 已完成的任务 @角色name
736
+ ---END_TASKS---
737
+ \`\`\`
738
+
739
+ 注意:
740
+ - 每行一个任务,[ ] 表示待办,[x] 表示已完成
741
+ - @角色name 标注负责人(可选)
742
+ - 后续回复中可更新 TASKS 块(标记完成的任务)
743
+ - TASKS 块不需要在回复最末尾,可以放在任意位置`;
728
744
  }
729
745
 
730
746
  return prompt;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'dotenv/config';
2
- import { platform } from 'os';
2
+ import { platform, homedir } from 'os';
3
3
  import { existsSync, readFileSync, writeFileSync } from 'fs';
4
4
  import { join, dirname } from 'path';
5
5
  import { exec } from 'child_process';
@@ -62,14 +62,51 @@ const CONFIG = {
62
62
  workDir: process.env.WORK_DIR || fileConfig.workDir,
63
63
  reconnectInterval: fileConfig.reconnectInterval,
64
64
  agentSecret: process.env.AGENT_SECRET || fileConfig.agentSecret,
65
- // 禁用的工具列表(逗号分隔),如 "mcp__github,mcp__sentry"
66
- // 默认不禁用任何工具(MCP 工具由 ~/.claude.json 中的 mcpServers 配置控制)
67
- // 设置 DISALLOWED_TOOLS 可指定需要禁用的工具
65
+ // MCP 白名单:只允许这些 MCP 服务器的工具,其余自动禁用
66
+ // 通过 ALLOWED_MCP_SERVERS 环境变量(逗号分隔)或配置文件 allowedMcpServers 指定
67
+ // 默认只允许 playwright
68
68
  disallowedTools: (() => {
69
+ // 解析显式禁用列表
69
70
  const raw = process.env.DISALLOWED_TOOLS || fileConfig.disallowedTools || '';
70
- if (raw === 'none') return [];
71
- const list = raw.split(',').map(s => s.trim()).filter(Boolean);
72
- return list;
71
+ const explicit = raw === 'none' ? [] : raw.split(',').map(s => s.trim()).filter(Boolean);
72
+
73
+ // 解析 MCP 白名单
74
+ const allowedRaw = process.env.ALLOWED_MCP_SERVERS || fileConfig.allowedMcpServers || 'playwright';
75
+ const allowedMcpServers = allowedRaw.split(',').map(s => s.trim()).filter(Boolean);
76
+
77
+ // 读取 ~/.claude.json 中所有配置的 MCP 服务器名
78
+ const claudeConfigPath = join(homedir(), '.claude.json');
79
+ const mcpDisallowed = [];
80
+ try {
81
+ if (existsSync(claudeConfigPath)) {
82
+ const claudeConfig = JSON.parse(readFileSync(claudeConfigPath, 'utf-8'));
83
+ const allMcpNames = new Set();
84
+ // 收集所有项目中配置的 MCP 服务器名
85
+ for (const [, projCfg] of Object.entries(claudeConfig.projects || {})) {
86
+ for (const name of Object.keys(projCfg.mcpServers || {})) {
87
+ allMcpNames.add(name);
88
+ }
89
+ }
90
+ // 顶层 mcpServers
91
+ for (const name of Object.keys(claudeConfig.mcpServers || {})) {
92
+ allMcpNames.add(name);
93
+ }
94
+ // 不在白名单中的 MCP 服务器 → 禁用
95
+ for (const name of allMcpNames) {
96
+ if (!allowedMcpServers.includes(name)) {
97
+ mcpDisallowed.push(`mcp__${name}`);
98
+ }
99
+ }
100
+ if (mcpDisallowed.length > 0) {
101
+ console.log(`[MCP] Allowed: ${allowedMcpServers.join(', ')}`);
102
+ console.log(`[MCP] Disallowed: ${mcpDisallowed.join(', ')}`);
103
+ }
104
+ }
105
+ } catch (e) {
106
+ console.warn('[MCP] Failed to read ~/.claude.json:', e.message);
107
+ }
108
+
109
+ return [...explicit, ...mcpDisallowed];
73
110
  })()
74
111
  };
75
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.0.82",
3
+ "version": "0.0.84",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",