@sleep2agi/commhub-server 0.9.0-preview.216 → 0.9.0-preview.217

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.216",
3
+ "version": "0.9.0-preview.217",
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",
@@ -358,6 +358,8 @@ describe("#698 atomic peer reply", () => {
358
358
  expect(db.get<{ n: number }>("SELECT COUNT(*) AS n FROM tasks WHERE parent_task_id = ?1", taskId)?.n).toBe(0);
359
359
  });
360
360
 
361
+ // #3259 收口 —— 迟到通道只对「终态但没成功交付过回复」的任务开放;
362
+ // `replied` 的任务再补就是重复投递,仍然必须以 reply_task_terminal 拒绝。
361
363
  test("terminal replay is rejected and cannot deliver twice", async () => {
362
364
  const taskId = await dispatch(A, B, "idempotent work");
363
365
  const handler = toolsFor(B).send_peer_reply;
@@ -204,7 +204,11 @@ describe("#464 stuck timeout", () => {
204
204
  const inboxBefore = db.get<any>("SELECT COUNT(*) AS n FROM inbox WHERE network_id = ?1", NET).n;
205
205
  const out = await nodeReply({ alias: "scheduler", text: "late answer", in_reply_to: first.taskId, status: "replied", from_session: ALIAS });
206
206
  expect(out.ok).toBe(false);
207
- expect(out.error).toBe("reply_task_terminal");
207
+ // #3259 / .216 —— 到期任务不再以 reply_task_terminal 一刀切拒绝:迟到的回复
208
+ // 会进入「迟到结果」通道(task_late_replies,任务行保持 expired)。而这条通道
209
+ // 只对**执行节点**开放,这里是从 from_session 的路由回执,因此被按节点令牌拦下。
210
+ // 结论不变:这次回复什么都没改(下面几条断言仍然检查这一点)。
211
+ expect(out.error).toBe("late_reply_node_token_required");
208
212
  expect(out.reply_queued).toBe(false);
209
213
  expect(taskRow(first.taskId!).status).toBe("expired");
210
214
  expect(runRow(first.runId).status).toBe("expired");
@@ -235,8 +235,10 @@ describe("#519 at 72h", () => {
235
235
  withHours("72", () => patrol());
236
236
  expect(taskRow(a.id).status).toBe("expired");
237
237
  const r = await tool(nodes.target.token, "send_reply", { in_reply_to: a.id, text: "late answer", status: "replied", network_id: NET });
238
- expect(r.ok).toBe(false);
239
- expect(r.error).toBe("reply_task_terminal");
238
+ // #3259 / .216 —— 执行节点的迟到结果不再被 reply_task_terminal 拒绝:
239
+ // 它作为 task_late_replies 追加,任务行**保持 expired**(迟到 ≠ 追认成功)。
240
+ expect(r.ok).toBe(true);
241
+ expect(r.late).toBe(true);
240
242
  expect(taskRow(a.id).status).toBe("expired");
241
243
  });
242
244
 
package/src/tools.ts CHANGED
@@ -2536,7 +2536,11 @@ export function registerTools(server: McpServer, clientIP?: string, enforceNetwo
2536
2536
  let lateSql = "SELECT status,from_name,to_node_id,thread_id,turn_id FROM tasks WHERE task_id=?1";
2537
2537
  lateSql = addScope(lateSql, lateParams, effectiveNetId);
2538
2538
  const lateCandidate = db.get<LateTask>(lateSql, ...lateParams) ?? null;
2539
- if (lateCandidate && !["created", "delivered", "acked", "running"].includes(lateCandidate.status)) {
2539
+ // #3259 收口 —— 迟到通道只对「终态但**没有成功交付回复**」的任务开放。
2540
+ // `replied` 的任务发送方已经拿到了结果,再补一次就是重复投递
2541
+ // (#698 的 idempotency 测试就是这条:replay 不能变成第二条 inbox 回复)。
2542
+ if (lateCandidate && lateCandidate.status !== "replied"
2543
+ && !["created", "delivered", "acked", "running"].includes(lateCandidate.status)) {
2540
2544
  if (workSignal.outcome) return { content: [{ type: "text" as const, text: JSON.stringify({ ok: false, error: "scheduled_work_outcome_terminal", reply_queued: false }) }] };
2541
2545
  // Old runtimes do not send turn identity and retain the old result.
2542
2546
  // #3061 续 —— 任务**从未记下 turn 上下文**时,不该再要求调用方凭空给出 id。