@sleep2agi/commhub-server 0.9.0-preview.143 → 0.9.0-preview.144
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.
|
|
3
|
+
"version": "0.9.0-preview.144",
|
|
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",
|
|
@@ -145,4 +145,20 @@ describe("Agent 显式归属部门", () => {
|
|
|
145
145
|
const agents2 = [...(dir2.body.people ?? []).flatMap((p: any) => p.agents ?? []), ...(dir2.body.agents_without_owner ?? [])];
|
|
146
146
|
expect(agents2.find((a: any) => a.node_id === NODE_A)?.department_id ?? null).toBeNull();
|
|
147
147
|
});
|
|
148
|
+
|
|
149
|
+
// #1976 —— Agent 归属与人类部门是两个独立的结构。通讯录顶层要说明「这个 Hub 支持显式
|
|
150
|
+
// Agent 部门」,客户端据此把「行里没有 department_id」读成「没有显式归属」,
|
|
151
|
+
// 而不是从「负责人在哪个部门」推断出来。
|
|
152
|
+
test("通讯录声明支持显式 Agent 部门(与人类部门相互独立)", async () => {
|
|
153
|
+
const dir = await send(U.owner.token, "GET", `/api/requirements/people/directory?network_id=${NET}`);
|
|
154
|
+
expect(dir.status).toBe(200);
|
|
155
|
+
expect(dir.body.agent_department_supported).toBe(true);
|
|
156
|
+
// 行形状不变:没有显式归属的行**不带** department_id 这一格(旧客户端形状不变)。
|
|
157
|
+
const agents = [...(dir.body.people ?? []).flatMap((p: any) => p.agents ?? []), ...(dir.body.agents_without_owner ?? [])];
|
|
158
|
+
for (const a of agents) {
|
|
159
|
+
// 显式归属 ⇒ 带这一格且非空;没有显式归属 ⇒ **不带这一格**(旧客户端形状不变)。
|
|
160
|
+
if (a.department_id) expect(typeof a.department_id).toBe("string");
|
|
161
|
+
else expect(Object.prototype.hasOwnProperty.call(a, "department_id")).toBe(false);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
148
164
|
});
|
|
@@ -72,8 +72,9 @@ export function peopleDirectory(networkId: string, hidden: HiddenNode, query: {
|
|
|
72
72
|
const byOwner = new Map<string, DirectoryAgent[]>();
|
|
73
73
|
const unowned: DirectoryAgent[] = [];
|
|
74
74
|
for (const n of nodes) {
|
|
75
|
-
// 只在**显式**归属时带这一格:没设 =
|
|
76
|
-
//
|
|
75
|
+
// 只在**显式**归属时带这一格:没设 = 没有显式归属(顶层 agent_department_supported 告诉
|
|
76
|
+
// 客户端这一点)。行形状保持不变 —— 旧客户端拿到的行还是老样子(多一个键会让严格要求
|
|
77
|
+
// 形状的测试/客户端意外),只是新客户端不再把「负责人在哪个部门」当成 Agent 的部门。
|
|
77
78
|
const agent = { node_id: n.node_id, alias: n.alias || n.node_name, ...(n.department_id ? { department_id: n.department_id } : {}) };
|
|
78
79
|
if (n.owner_user_id && memberIds.has(n.owner_user_id)) {
|
|
79
80
|
const list = byOwner.get(n.owner_user_id) ?? [];
|
|
@@ -104,6 +105,12 @@ export function peopleDirectory(networkId: string, hidden: HiddenNode, query: {
|
|
|
104
105
|
network_id: networkId,
|
|
105
106
|
total: people.length,
|
|
106
107
|
people: page,
|
|
108
|
+
// #1976 —— 「Agent 归属」与「人类部门」是两个独立的结构。
|
|
109
|
+
// Agent 放哪个部门,只由**显式**设置(nodes.department_id)决定;**不再**从「负责人在哪个部门」推断。
|
|
110
|
+
// 这一格告诉客户端「这个 Hub 支持显式 Agent 部门」:客户端据此把「没有 department_id 这一行」
|
|
111
|
+
// 读成「没有显式归属 ⇒ 未归属」,而不是「按负责人部门推断」。
|
|
112
|
+
// 老 Hub 没有这一格 ⇒ 客户端保留旧的推断口径,行为不变。
|
|
113
|
+
agent_department_supported: true,
|
|
107
114
|
...(query.offset === 0 ? { agents_without_owner: unowned.filter(a => hit(a.alias)) } : {}),
|
|
108
115
|
has_more: hasMore,
|
|
109
116
|
next_offset: hasMore ? query.offset + query.limit : null,
|