@sleep2agi/commhub-server 0.9.0-preview.92 → 0.9.0-preview.93
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 +1 -1
- package/src/auth.ts +2 -2
- package/src/department-groups-http.test.ts +209 -0
- package/src/department-groups-sync-http.test.ts +328 -0
- package/src/department-groups.ts +358 -0
- package/src/departments.ts +30 -9
- package/src/group-messages-http.test.ts +482 -0
- package/src/group-messages.ts +297 -0
- package/src/human-dm.ts +2 -2
- package/src/mcp-context-cost-http.test.ts +4 -2
- package/src/node-permissions-http.test.ts +18 -0
- package/src/requirements-status-participants-http.test.ts +5 -1
- package/src/server.ts +166 -10
- package/src/tool-audience-http.test.ts +195 -0
- package/src/tool-audience.ts +109 -0
- package/src/tools-list-json-schema.test.ts +2 -1
- package/src/tools.ts +8 -1
package/src/tools.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { pendingInboxCount } from "./inbox-count.js";
|
|
|
13
13
|
import { getUserNetworkRole, createNetworkTokenForNode } from "./auth.js";
|
|
14
14
|
import { addAgentNetworkScope, addNetworkScope, addOwnTrafficScope, canRestWriteNetwork, canRestWriteNetworkAsHuman, getUserNetworkIds, resolveRestNetworkScope, singleNetworkId, type RestNetworkScope } from "./network-scope.js";
|
|
15
15
|
import { canMessageAgent, restrictedNetworkIds, RESTRICTED_MEMBER_TOOLS, type AgentRef } from "./agent-access.js";
|
|
16
|
+
import { listedToolFilter, scopeToolsList, type ToolCaller } from "./tool-audience.js";
|
|
16
17
|
import { broadcastVerdict, dispatchVerdict, humanOnlyVerdict, NODE_TOOL_CLASS, nodeDecide, nodeIdentity, nodePermissionDeniedBody, writeVerdict, type NodeIdentity, type Verdict } from "./node-permissions.js";
|
|
17
18
|
import { restrictedMemberAttachmentsDenied } from "./restricted-files.js";
|
|
18
19
|
import { errorBody } from "./requirements-errors.js";
|
|
@@ -258,7 +259,7 @@ function guardNodePermissionTools(server: McpServer, tokenId: string, networkId:
|
|
|
258
259
|
}
|
|
259
260
|
}
|
|
260
261
|
|
|
261
|
-
export function registerTools(server: McpServer, clientIP?: string, enforceNetworkId?: string | null, enforceUserId?: string | null, callerAlias?: string | null, callerTokenIsNetwork = false, callerTokenId?: string | null) {
|
|
262
|
+
export function registerTools(server: McpServer, clientIP?: string, enforceNetworkId?: string | null, enforceUserId?: string | null, callerAlias?: string | null, callerTokenIsNetwork = false, callerTokenId?: string | null, listing: { includeProtocol?: boolean } = {}) {
|
|
262
263
|
// 多用户 Agent 权限:用户令牌调用者在哪些网络里是受限成员(只看授权 Agent)。
|
|
263
264
|
// 网络令牌不会走到这里 —— 受限成员的网络令牌在 resolveToken 就被拒了。
|
|
264
265
|
const restrictedNets = enforceUserId && !callerTokenIsNetwork && !enforceNetworkId ? restrictedNetworkIds(enforceUserId) : [];
|
|
@@ -6133,6 +6134,12 @@ export function registerTools(server: McpServer, clientIP?: string, enforceNetwo
|
|
|
6133
6134
|
},
|
|
6134
6135
|
async ({ id, text, network_id }) => requirementsCall("POST", `/api/requirements/${encodeURIComponent(id)}/comments`, network_id, { text }),
|
|
6135
6136
|
);
|
|
6137
|
+
|
|
6138
|
+
// #478:tools/list 只列这个调用者真能用的工具(tool-audience.ts)。只滤列表,tools/call 不变。
|
|
6139
|
+
const caller: ToolCaller = callerTokenIsNetwork
|
|
6140
|
+
? { kind: "node", tokenId: callerTokenId ?? null, networkId: enforceNetworkId ?? null, includeProtocol: listing.includeProtocol === true }
|
|
6141
|
+
: enforceUserId ? { kind: "user", includeProtocol: listing.includeProtocol === true } : { kind: "unknown" };
|
|
6142
|
+
scopeToolsList(server, listedToolFilter(caller));
|
|
6136
6143
|
}
|
|
6137
6144
|
|
|
6138
6145
|
// ────────────────────────────────────────────────────────────────────
|