@sleep2agi/commhub-server 0.9.0-preview.187 → 0.9.0-preview.188
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/agent-department-http.test.ts +16 -0
- package/src/server.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/commhub-server",
|
|
3
|
-
"version": "0.9.0-preview.
|
|
3
|
+
"version": "0.9.0-preview.188",
|
|
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",
|
|
@@ -149,6 +149,22 @@ describe("Agent 显式归属部门", () => {
|
|
|
149
149
|
// #1976 —— Agent 归属与人类部门是两个独立的结构。通讯录顶层要说明「这个 Hub 支持显式
|
|
150
150
|
// Agent 部门」,客户端据此把「行里没有 department_id」读成「没有显式归属」,
|
|
151
151
|
// 而不是从「负责人在哪个部门」推断出来。
|
|
152
|
+
// #2888(通信客户端欧 2026-10-28 提)—— 军团按部门分区时,N 个部门要发 N 次
|
|
153
|
+
// `…/departments/:dept/nodes` 才能拼出「每个 Agent 属于哪个部门」,人数一多就慢。
|
|
154
|
+
// 事实上 /api/nodes 早就返回全部节点,只是没 select `department_id` 这一列。
|
|
155
|
+
// 补上之后一次往返就能完成分区初始化。
|
|
156
|
+
test("/api/nodes 一次返回全部节点且带 department_id(免 N 次部门往返)", async () => {
|
|
157
|
+
expect((await send(U.owner.token, "PUT", `/api/networks/${NET}/nodes/${NODE_A}/department`, { department_id: D.tmai })).status).toBe(200);
|
|
158
|
+
const all = await send(U.owner.token, "GET", `/api/nodes?network_id=${NET}`);
|
|
159
|
+
expect(all.status).toBe(200);
|
|
160
|
+
const row = (all.body.nodes ?? []).find((n: any) => n.node_id === NODE_A);
|
|
161
|
+
expect(row).toBeDefined();
|
|
162
|
+
expect(row.department_id).toBe(D.tmai);
|
|
163
|
+
// 未归属的节点这一格是 null(不是缺键)——分区逻辑可以统一按 null 判「未分组」。
|
|
164
|
+
const other = (all.body.nodes ?? []).find((n: any) => n.node_id === NODE_OUTSIDE);
|
|
165
|
+
if (other) expect(other.department_id ?? null).toBeNull();
|
|
166
|
+
});
|
|
167
|
+
|
|
152
168
|
test("通讯录声明支持显式 Agent 部门(与人类部门相互独立)", async () => {
|
|
153
169
|
const dir = await send(U.owner.token, "GET", `/api/requirements/people/directory?network_id=${NET}`);
|
|
154
170
|
expect(dir.status).toBe(200);
|
package/src/server.ts
CHANGED
|
@@ -5272,7 +5272,8 @@ return Bun.serve({
|
|
|
5272
5272
|
config_path, channels, server, hostname,
|
|
5273
5273
|
network_id, created_at, updated_at,
|
|
5274
5274
|
config_snapshot, lifecycle_state, avatar_url,
|
|
5275
|
-
display_name, team, tags, attrs_revision, permission_mode, owner_user_id
|
|
5275
|
+
display_name, team, tags, attrs_revision, permission_mode, owner_user_id,
|
|
5276
|
+
department_id
|
|
5276
5277
|
FROM nodes WHERE 1=1`;
|
|
5277
5278
|
const params: any[] = [];
|
|
5278
5279
|
sql = addAgentNetworkScope(sql, params, restScope, { alias: "alias", nodeId: "node_id" });
|