@yeaft/webchat-agent 0.1.35 → 0.1.37

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/claude.js CHANGED
@@ -254,6 +254,7 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
254
254
  console.log(`Claude session ID: ${state.claudeSessionId}`);
255
255
  console.log(`Model: ${state.model}`);
256
256
  console.log(`Available tools: ${state.tools.length}`);
257
+ console.log(`Tools: ${state.tools.join(', ')}`);
257
258
  console.log(`Available slash commands: ${state.slashCommands.join(', ')}`);
258
259
 
259
260
  // 通知服务器更新 claudeSessionId(用于历史会话恢复)
@@ -277,6 +278,23 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
277
278
  });
278
279
  }
279
280
  }
281
+
282
+ // 从 tools 列表提取 MCP servers,发送 per-conversation MCP 列表
283
+ const mcpServers = extractMcpServers(state.tools);
284
+ if (mcpServers.length > 0) {
285
+ // 根据当前 disallowed 设置计算每个 server 的 enabled 状态
286
+ const effectiveDisallowed = state.disallowedTools ?? ctx.CONFIG.disallowedTools ?? [];
287
+ const serversWithState = mcpServers.map(name => ({
288
+ name,
289
+ enabled: !effectiveDisallowed.some(d => d === `mcp__${name}`),
290
+ source: name === 'playwright' ? 'Built-in' : 'MCP'
291
+ }));
292
+ ctx.sendToServer({
293
+ type: 'conversation_mcp_update',
294
+ conversationId,
295
+ servers: serversWithState
296
+ });
297
+ }
280
298
  }
281
299
 
282
300
  // 捕获 compact 相关的 system 消息
@@ -459,3 +477,20 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
459
477
  }
460
478
  }
461
479
 
480
+ /**
481
+ * 从 tools 列表中提取 MCP server 名称。
482
+ * MCP 工具名称格式: mcp__<serverName>__<toolName>
483
+ * @param {string[]} tools
484
+ * @returns {string[]} 去重后的 server 名称列表
485
+ */
486
+ function extractMcpServers(tools) {
487
+ const serverNames = new Set();
488
+ for (const tool of tools) {
489
+ const parts = tool.split('__');
490
+ if (parts.length >= 3 && parts[0] === 'mcp') {
491
+ serverNames.add(parts[1]);
492
+ }
493
+ }
494
+ return [...serverNames];
495
+ }
496
+
package/conversation.js CHANGED
@@ -144,6 +144,23 @@ export async function createConversation(msg) {
144
144
  disallowedTools: disallowedTools || null
145
145
  });
146
146
 
147
+ // 立即发送 agent 级别的 MCP servers 列表(从 ~/.claude.json 读取的)
148
+ // 让前端在 Claude CLI init 之前就能显示 MCP 配置入口
149
+ // Claude CLI init 后会用实际 tools 列表覆盖更新
150
+ if (ctx.mcpServers.length > 0) {
151
+ const effectiveDisallowed = disallowedTools || ctx.CONFIG.disallowedTools || [];
152
+ const serversWithState = ctx.mcpServers.map(s => ({
153
+ name: s.name,
154
+ enabled: !effectiveDisallowed.some(d => d === `mcp__${s.name}`),
155
+ source: s.source
156
+ }));
157
+ ctx.sendToServer({
158
+ type: 'conversation_mcp_update',
159
+ conversationId,
160
+ servers: serversWithState
161
+ });
162
+ }
163
+
147
164
  sendConversationList();
148
165
  }
149
166
 
@@ -208,6 +225,21 @@ export async function resumeConversation(msg) {
208
225
  username
209
226
  });
210
227
 
228
+ // 立即发送 agent 级别的 MCP servers 列表
229
+ if (ctx.mcpServers.length > 0) {
230
+ const effectiveDisallowed = disallowedTools || ctx.CONFIG.disallowedTools || [];
231
+ const serversWithState = ctx.mcpServers.map(s => ({
232
+ name: s.name,
233
+ enabled: !effectiveDisallowed.some(d => d === `mcp__${s.name}`),
234
+ source: s.source
235
+ }));
236
+ ctx.sendToServer({
237
+ type: 'conversation_mcp_update',
238
+ conversationId,
239
+ servers: serversWithState
240
+ });
241
+ }
242
+
211
243
  sendConversationList();
212
244
  }
213
245
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",