@sleep2agi/commhub-server 0.9.0-preview.243 → 0.9.0-preview.244

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.243",
3
+ "version": "0.9.0-preview.244",
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",
@@ -128,7 +128,17 @@ test("legacy owner and exact bound identity remain supported", async () => {
128
128
  // 计数与数组同源:两个 count 必须等于各自数组长度(否则「有 N 条」与「列出来」会分叉)
129
129
  expect(pendLife.stop_count).toBe(pendLife.stop_requests.length);
130
130
  expect(pendLife.start_count).toBe(pendLife.start_requests.length);
131
- expect((await call(token, "get_adopt_request", { request_id: requestId })).ok).toBe(true);
131
+ // 2026-10-31 —— #3275:形状由**一次真实调用**给出(不靠读源码猜)
132
+ const gotAdopt = await call(token, "get_adopt_request", { request_id: requestId });
133
+ expect(gotAdopt.ok).toBe(true);
134
+ // ⚠️ 我第一版按源码猜了 7 个键(binding_request_id / child_alias / child_node_id …)——**全错**。
135
+ // 真实形状由这次调用给出,12 个键;其中 error 为空、request_id 是这一行自己的 id。
136
+ // 这是本卡第三次被「读源码猜形状」打回,写进注释免得下一个人再猜:
137
+ // 行对象整行透传时,源码里看到的字段名是**SQL 的列名**,与对外载荷不是一回事。
138
+ expect(Object.keys(gotAdopt).sort()).toEqual([
139
+ "alias", "created_at", "daemon_node_id", "error", "network_id", "node_id",
140
+ "ok", "request_id", "requested_by", "status", "updated_at", "workdir",
141
+ ]);
132
142
  }
133
143
  // An explicit binding does not bypass the network or revocation boundaries.
134
144
  expect(await call(crossNetwork, "list_my_children")).toMatchObject({ ok: false, error: "caller_not_a_daemon" });
@@ -140,15 +150,32 @@ test("legacy owner and exact bound identity remain supported", async () => {
140
150
  expect(adopted).toMatchObject({ ok: true, status: "active" });
141
151
  expect(Object.keys(adopted).sort()).toEqual(["ok", "status"]);
142
152
  expect((await call(legacy, "list_my_children")).children).toContainEqual({ child_node_id: child, alias: child, lifecycle_state: "active", managed: "adopted", binding_request_id: requestId });
153
+ // 2026-10-31 —— #3275:get_probe_request 的**不存在**分支键集(成功分支需要真实 probe 夹具,
154
+ // 本文件不造;错误分支同样是契约:客户端按 error 分支,多一个键就会多一个没人知道的分支)
155
+ const gotProbe = await call(legacy, "get_probe_request", { probe_id: "probe_fixture_absent" });
156
+ expect(gotProbe.ok).toBe(false);
157
+ // 实测:错误分支多一个 reason(不是只 {error, ok})——**又一次由真实调用纠正**
158
+ expect(Object.keys(gotProbe).sort()).toEqual(["error", "ok", "reason"]);
143
159
  const stop = await call(owner.token, "stop_node", { node_id: child, network_id: owner.network_id });
144
160
  expect(stop.ok).toBe(true);
145
- expect((await call(legacy, "get_stop_request", { request_id: stop.request_id })).ok).toBe(true);
161
+ // 2026-10-31 —— #3275 批次 2:get_stop_request 的**成功体**键集(daemon 按字段名读,
162
+ // 尤其 delete_config / grace_seconds / force 三个决定它要不要删配置)
163
+ const gotStop = await call(legacy, "get_stop_request", { request_id: stop.request_id });
164
+ expect(gotStop.ok).toBe(true);
165
+ expect(Object.keys(gotStop).sort()).toEqual([
166
+ "action", "child_alias", "child_node_id", "delete_config", "force", "grace_seconds", "ok", "request_id",
167
+ ]);
146
168
  const stoppedAck = await call(legacy, "ack_stop_request", { request_id: stop.request_id, status: "stopped" });
147
169
  expect(stoppedAck.ok).toBe(true);
148
170
  expect(Object.keys(stoppedAck).sort()).toEqual(["ok", "status"]); // #3275:成功体键集
149
171
  const start = await call(owner.token, "start_node", { node_id: child, network_id: owner.network_id });
150
172
  expect(start.ok).toBe(true);
151
- expect((await call(legacy, "get_start_request", { request_id: start.request_id })).ok).toBe(true);
173
+ const gotStart = await call(legacy, "get_start_request", { request_id: start.request_id });
174
+ expect(gotStart.ok).toBe(true);
175
+ // 成功体:四个固定键 + start_completion_capable;fork_recovery 只在「创建即恢复」路径出现(条件键)
176
+ expect(Object.keys(gotStart).sort()).toEqual([
177
+ "child_alias", "child_node_id", "ok", "request_id", "start_completion_capable",
178
+ ]);
152
179
  const startedAck = await call(legacy, "ack_start_request", { request_id: start.request_id, status: "started", child_pid: 4321 });
153
180
  expect(startedAck).toMatchObject({ ok: true, status: "started" });
154
181
  expect(Object.keys(startedAck).sort()).toEqual(["ok", "status"]); // #3275:成功体键集
@@ -327,7 +327,10 @@ describe("GET /api/providers", () => {
327
327
  expect(a.status).toBe(200);
328
328
  expect(a.body.state).toBe("never_switched");
329
329
  expect(a.body.selection).toBeNull();
330
- expect(String(a.body.hint)).toContain("本地默认配置");
330
+ expect(String(a.body.hint)).toContain("本地的默认配置");
331
+ // 2026-10-31 —— **hint 必须自带动作**(外部复核:一句只描述状态的提示产不出下一步)。
332
+ // 这条断言钉住「它至少告诉读者第一步是什么」,而不是只说「现在是这样」。
333
+ expect(String(a.body.hint)).toMatch(/POST|GET|切一次/);
331
334
 
332
335
  // ② 正在切:pending 时不带 hint(hint 只属于「没有读数」那一档)
333
336
  const q = (requestId: string, status: string, payload: string | null, error: string | null) => db.run(
package/src/server.ts CHANGED
@@ -4051,7 +4051,10 @@ return Bun.serve({
4051
4051
  observed_at: row?.observed_at ? new Date(row.observed_at).toISOString() : null,
4052
4052
  ...(state === "failed" ? { error: row?.error ?? null } : {}),
4053
4053
  ...(state === "never_switched"
4054
- ? { hint: "这个节点还没有被切换过 provider;显示的是它的本地默认配置(不是 Hub 的读数)" }
4054
+ // 2026-10-31 —— **hint 必须自带动作**(外部复核:互斥选项若需要不同动作才能区分,
4055
+ // 「一次动作」就只对其中一部分成立;同理,一句只描述状态的 hint 产不出下一步)。
4056
+ // 原来这句只说「显示的是本地默认配置」——读者知道现状,但不知道该做什么。
4057
+ ? { hint: "这个节点还没有被切换过 provider,现在显示的是它本地的默认配置(不是 Hub 的读数)。要看 Hub 这份读数,先给节点切一次:POST 同一路由 {revision, selection},再 GET 回读 state 是否变 applied" }
4055
4058
  : {}),
4056
4059
  ...(state === "unknown"
4057
4060
  ? {