@sleep2agi/commhub-server 0.9.0-preview.204 → 0.9.0-preview.205

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/commhub-server",
3
- "version": "0.9.0-preview.204",
3
+ "version": "0.9.0-preview.205",
4
4
  "description": "CommHub Server — AI Agent communication hub with MCP protocol, multi-network isolation, user auth, and MCP tools (17 collaboration-core + node/provider ops tools; authoritative list: docs-site/docs/api/mcp-tools.md).",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -292,6 +292,23 @@ describe("#2823 调用面计数(node_tool_calls)", () => {
292
292
  expect(denyRows(node.nN.id)).toBe(before.denials);
293
293
  });
294
294
 
295
+ // #2971 —— 读类 / 需求类 / 排程类原来根本不到闸里,账本因此完全看不到它们。
296
+ // 而敏感读恰恰在这一类里(list_network_secrets / list_providers / tail_node_logs)。
297
+ // 修法只有一个方向:**记账,但不判定** —— 拦截语义必须零变化。
298
+ test("#2971 读类工具会被计数,且行为不变(不被拦、不进拒绝日志)", async () => {
299
+ const before = { calls: callHits(node.nN.id, "mcp:list_providers"), denials: denyRows(node.nN.id) };
300
+ const r = await mcp(node.nN.token, "list_providers", { network_id: net });
301
+ expect(r.error).not.toBe("node_permission_denied");
302
+ expect(callHits(node.nN.id, "mcp:list_providers")).toBe(before.calls + 1);
303
+ expect(denyRows(node.nN.id)).toBe(before.denials);
304
+ });
305
+
306
+ test("#2971 always 类不进账本(心跳会把账本淹掉)", async () => {
307
+ const before = toolCallTotal(node.nN.id);
308
+ await mcp(node.nN.token, "get_inbox", { alias: node.nN.alias });
309
+ expect(toolCallTotal(node.nN.id)).toBe(before);
310
+ });
311
+
295
312
  test("本来会被拒的调用两个表都记(分子与分母同源)", async () => {
296
313
  const beforeCalls = callHits(node.nN.id, "mcp:projects_create");
297
314
  const beforeDeny = hitsOf(node.nN.id, "mcp:projects_create", "human_only");
package/src/tools.ts CHANGED
@@ -35,7 +35,7 @@ import { addAgentNetworkScope, addAgentTimelineScope, addNetworkScope, canRestWr
35
35
  import { canMessageAgent, restrictedNetworkIds, RESTRICTED_MEMBER_TOOLS, type AgentRef } from "./agent-access.js";
36
36
  import { listedToolFilter, scopeToolsList, type ToolCaller } from "./tool-audience.js";
37
37
  import { agentBatchScheduleInterval, agentCancelSchedule, agentCreateSchedule, agentGetSchedule, agentListSchedules, agentRunScheduleNow, agentScheduleRuns, agentUpdateSchedule } from "./schedule-agent.js";
38
- import { broadcastVerdict, dispatchVerdict, humanOnlyVerdict, NODE_TOOL_CLASS, nodeDecide, nodeIdentity, nodePermissionDeniedBody, writeVerdict, type NodeIdentity, type Verdict, toolAllowlistVerdict } from "./node-permissions.js";
38
+ import { broadcastVerdict, dispatchVerdict, humanOnlyVerdict, NODE_TOOL_CLASS, nodeDecide, nodeIdentity, nodePermissionDeniedBody, recordNodeToolCall, writeVerdict, type NodeIdentity, type Verdict, toolAllowlistVerdict } from "./node-permissions.js";
39
39
  import { countInFlightTasks } from "./node-in-flight-tasks.js";
40
40
  import { restrictedMemberAttachmentsDenied } from "./restricted-files.js";
41
41
  import { errorBody } from "./requirements-errors.js";
@@ -296,8 +296,15 @@ function guardNodePermissionTools(server: McpServer, tokenId: string, networkId:
296
296
  if (allowVerdict && nodeDecide(id, `mcp:${name}`, allowVerdict)) {
297
297
  return denied(allowVerdict.reason, `mcp:${name}`);
298
298
  }
299
+ // #2971 —— 账本要覆盖「到达工具的每一次调用」,不只是会被拦的那几类。
300
+ // 读类 / 需求类 / 排程类原来根本不到这里 ⇒ node_tool_calls 漏掉它们,
301
+ // 而 read 类里就有 list_network_secrets / list_providers / tail_node_logs 这些敏感读。
302
+ // 🔴 只计数、不判定:拦截语义零变化(这几类本来也不在这个闸里判)。
303
+ // always 类仍然不记:那是心跳(get_inbox / report_status),记进来只会把账本淹掉。
299
304
  const gated = cls !== "always" && cls !== "read" && cls !== "requirements" && cls !== "schedule";
300
- if (gated) {
305
+ if (!gated) {
306
+ if (cls !== "always") recordNodeToolCall(id, `mcp:${name}`);
307
+ } else {
301
308
  const args = callArgs[0] && typeof callArgs[0] === "object" ? callArgs[0] as Record<string, unknown> : {};
302
309
  const verdict = verdictFor(id, name, args);
303
310
  if (nodeDecide(id, `mcp:${name}`, verdict)) return denied(verdict!.reason, `mcp:${name}`);