@sleep2agi/commhub-server 0.9.0-preview.195 → 0.9.0-preview.196
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/parent-source-marker.test.ts +13 -2
- package/src/server.ts +9 -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.196",
|
|
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",
|
|
@@ -31,9 +31,20 @@ describe("#669 parent source marker", () => {
|
|
|
31
31
|
expect(inserts.some((l) => l.includes("metaJsonWithParent"))).toBe(true);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
// 这条原本断言「REST 里根本没有 parent_source」——理由是「REST 不走推断,
|
|
35
|
+
// 不要造第二真相」。方向对,但结论错了一半:REST 确实**不该推断**,
|
|
36
|
+
// 可它建的子任务同样是显式父子关系,不标就会被统计漏掉。
|
|
37
|
+
//
|
|
38
|
+
// 实测(2026-10-29,.195 上线后 90 分钟):3 条带 parent 的任务全部走 REST、
|
|
39
|
+
// 全部没有 parent_source。而 MCP 那条路是标的 ⇒ 分母只含 MCP,
|
|
40
|
+
// explicit 占比会被系统性压低。#669 要统计的正是这个比例。
|
|
41
|
+
test("REST /api/task 标「显式」,但不推断", () => {
|
|
35
42
|
const rest = readFileSync(new URL("./server.ts", import.meta.url), "utf8");
|
|
36
43
|
expect(rest).toContain("body.parent_task_id ?? null");
|
|
37
|
-
expect(rest.
|
|
44
|
+
expect(rest).toContain('parent_source: "explicit"');
|
|
45
|
+
// 不能出现第二份推断:REST 里没有「找最近 delivered」这种 SQL。
|
|
46
|
+
const restBlock = rest.slice(rest.indexOf("const metaWithParent"), rest.indexOf("const metaWithParent") + 400);
|
|
47
|
+
expect(restBlock.toLowerCase()).not.toContain("delivered");
|
|
48
|
+
expect(rest).not.toContain('parentSource = "inferred"');
|
|
38
49
|
});
|
|
39
50
|
});
|
package/src/server.ts
CHANGED
|
@@ -4248,7 +4248,15 @@ return Bun.serve({
|
|
|
4248
4248
|
: restAuth
|
|
4249
4249
|
? "user"
|
|
4250
4250
|
: "legacy";
|
|
4251
|
-
|
|
4251
|
+
// #669 —— REST 这一侧只标「显式」,**绝不推断**(推断只存在于 MCP send_task)。
|
|
4252
|
+
// 但不标就会有一个偏差:REST 建的子任务全部落进「无标记」,
|
|
4253
|
+
// 而 MCP 建的显式子任务有标记 ⇒ 统计里 explicit 被系统性地压低。
|
|
4254
|
+
// 实测(2026-10-29):近 90 分钟 3 条带 parent 的任务全部走 REST、全部无标记。
|
|
4255
|
+
// parent_source 已排除出幂等指纹(task-idempotency.ts),加上它不影响重放判定。
|
|
4256
|
+
const metaWithParent = body.parent_task_id
|
|
4257
|
+
? { ...(mergedMeta && typeof mergedMeta === "object" ? mergedMeta : {}), parent_source: "explicit" }
|
|
4258
|
+
: mergedMeta;
|
|
4259
|
+
const metaJson = normalizeMetaJson(stampTaskAuthOrigin(metaWithParent, authOrigin));
|
|
4252
4260
|
|
|
4253
4261
|
// Client-request-id idempotency, mirroring the MCP `send_task` tool
|
|
4254
4262
|
// (tools.ts). The app/Dashboard mint one `meta.client_request_id` per
|