@sleep2agi/commhub-server 0.9.0-preview.276 → 0.9.0-preview.277
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/build-info.json
CHANGED
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.277",
|
|
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",
|
|
@@ -778,6 +778,14 @@ test("HTTP source-fork refusals carry a diagnostic reason once source permission
|
|
|
778
778
|
const reused = await api(human.token!, "", { ...value("reason-reuse"), child_name: "reason-different" });
|
|
779
779
|
expect(reused.status).toBe(409);
|
|
780
780
|
expect(reused.body.reason).toBe("intent_reused");
|
|
781
|
+
// Hand-started source (no daemon created/adopted it): members learn why, outsiders do not.
|
|
782
|
+
const unmanaged = await api(human.token!, "", { ...value("reason-unmanaged"), source_node_id: "n_unmanaged_source" });
|
|
783
|
+
expect(unmanaged.status).toBe(409);
|
|
784
|
+
expect(unmanaged.body).toEqual({ ok: false, error: "source_fork_unavailable", reason: "source_not_managed" });
|
|
785
|
+
const stranger = register("reason_stranger", "Fixture-Strong-4150!");
|
|
786
|
+
const strangerUnmanaged = await api(stranger.token!, "", { ...value("reason-stranger"), source_node_id: "n_unmanaged_source" });
|
|
787
|
+
expect(strangerUnmanaged.status).toBe(409);
|
|
788
|
+
expect(strangerUnmanaged.body.reason).toBeUndefined();
|
|
781
789
|
// Callers without permission on the source still get no reason (no management-state disclosure).
|
|
782
790
|
const outsider = register("reason_outsider", "Fixture-Strong-4150!");
|
|
783
791
|
const foreign = await api(outsider.token!, "", value("reason-foreign"));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { db } from "./db";
|
|
3
|
-
import { resolveToken } from "./auth";
|
|
3
|
+
import { resolveToken, getUserNetworkRole } from "./auth";
|
|
4
4
|
import { isHumanCredential, readSessionControlCredential, resolveSessionControlNodeCaller, readSessionControlBody } from "./node-session-control";
|
|
5
5
|
import { createSessionSourceIssuer } from "./session-source-issuer";
|
|
6
6
|
import { createSessionSourceEvidenceQueue } from "./session-source-evidence";
|
|
@@ -26,7 +26,8 @@ const terminal = (r: Row) => ["registration_confirmed", "refused", "unknown_rota
|
|
|
26
26
|
const ok = (value: object) => Response.json({ ok: true, ...value }, { headers: { "cache-control": "no-store" } });
|
|
27
27
|
|
|
28
28
|
/** Why a fork create was refused after the caller's source permissions were verified. */
|
|
29
|
-
export type SourceForkFailureReason = "daemon_offline" | "daemon_not_capable" | "hub_busy" | "evidence_unavailable" | "intent_reused"
|
|
29
|
+
export type SourceForkFailureReason = "daemon_offline" | "daemon_not_capable" | "hub_busy" | "evidence_unavailable" | "intent_reused"
|
|
30
|
+
| "source_not_managed" | "source_management_ambiguous";
|
|
30
31
|
|
|
31
32
|
/** Separate REST semantics within the existing session-control HTTP surface.
|
|
32
33
|
* Secret bodies are never persisted. Original human Request lives ONLY in this
|
|
@@ -267,7 +268,13 @@ export function createSessionSourceTransport(options: { enabled?: boolean; direc
|
|
|
267
268
|
WHERE node_id=?1 AND network_id=?2 AND status='active'
|
|
268
269
|
UNION SELECT daemon_node_id FROM session_project_creates
|
|
269
270
|
WHERE child_node_id=?1 AND network_id=?2 AND state='registration_confirmed'`, b.source_node_id, b.network_id);
|
|
270
|
-
if (owners.length !== 1)
|
|
271
|
+
if (owners.length !== 1) {
|
|
272
|
+
// No daemon (hand-started node, never adopted) or more than one: the source cannot be
|
|
273
|
+
// forked. Network members already see `managed` in /api/nodes, so naming the cause
|
|
274
|
+
// to them discloses nothing new; anyone else still gets a bare refusal.
|
|
275
|
+
const member = !!getUserNetworkRole(auth.user.user_id, b.network_id);
|
|
276
|
+
return fail(409, member ? (owners.length === 0 ? "source_not_managed" : "source_management_ambiguous") : undefined);
|
|
277
|
+
}
|
|
271
278
|
const s = { network_id: b.network_id, source_node_id: b.source_node_id, daemon_node_id: owners[0].daemon_node_id, mode: "fork_independent" as const };
|
|
272
279
|
if (!("permissions_verified" in issuer.inspect(req, s))) return fail(403);
|
|
273
280
|
const existing = db.get<Row>("SELECT * FROM session_source_transports WHERE user_id=?1 AND network_id=?2 AND intent_id=?3", auth.user.user_id, b.network_id, b.intent_id);
|