zcode-acp-server 0.84.2 → 0.85.0
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/README.md +1 -1
- package/dist/code-fingerprint.json +2 -2
- package/dist/config/user-config.d.ts +33 -0
- package/dist/config/user-config.d.ts.map +1 -1
- package/dist/config/user-config.js +36 -0
- package/dist/config/user-config.js.map +1 -1
- package/dist/handlers/session.d.ts.map +1 -1
- package/dist/handlers/session.js +130 -10
- package/dist/handlers/session.js.map +1 -1
- package/dist/push/config.d.ts +2 -0
- package/dist/push/config.d.ts.map +1 -1
- package/dist/push/config.js +1 -0
- package/dist/push/config.js.map +1 -1
- package/dist/push/push.d.ts +14 -1
- package/dist/push/push.d.ts.map +1 -1
- package/dist/push/push.js +19 -0
- package/dist/push/push.js.map +1 -1
- package/dist/remote/config.d.ts +9 -0
- package/dist/remote/config.d.ts.map +1 -1
- package/dist/remote/config.js +14 -0
- package/dist/remote/config.js.map +1 -1
- package/dist/remote/hub-server.d.ts +13 -0
- package/dist/remote/hub-server.d.ts.map +1 -1
- package/dist/remote/hub-server.js +171 -7
- package/dist/remote/hub-server.js.map +1 -1
- package/dist/remote/session-delete-endpoint.d.ts +15 -5
- package/dist/remote/session-delete-endpoint.d.ts.map +1 -1
- package/dist/remote/session-delete-endpoint.js +146 -11
- package/dist/remote/session-delete-endpoint.js.map +1 -1
- package/dist/remote/terminal-relay.d.ts +61 -0
- package/dist/remote/terminal-relay.d.ts.map +1 -0
- package/dist/remote/terminal-relay.js +263 -0
- package/dist/remote/terminal-relay.js.map +1 -0
- package/dist/server.d.ts +31 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +104 -0
- package/dist/server.js.map +1 -1
- package/dist/tasks-index.d.ts +46 -1
- package/dist/tasks-index.d.ts.map +1 -1
- package/dist/tasks-index.js +136 -2
- package/dist/tasks-index.js.map +1 -1
- package/docs/REMOTE-CLIENTS.md +58 -0
- package/docs/REMOTE.md +7 -0
- package/package.json +1 -1
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Remote session delete endpoint
|
|
3
|
-
*
|
|
4
|
-
* POST /api/instances/{id}/sessions/{sessionId}/delete.
|
|
2
|
+
* Remote session delete endpoint, served on the bridge's loopback HTTP server
|
|
3
|
+
* and byte-proxied by the hub at POST /api/instances/{id}/sessions/{sessionId}/delete.
|
|
5
4
|
*
|
|
6
|
-
* "Delete" is the upstream App's soft delete: the tasks-index row
|
|
7
|
-
* deleted=1, every listing (this bridge's /sessions history, the hub's
|
|
5
|
+
* "Delete" is by default the upstream App's soft delete: the tasks-index row
|
|
6
|
+
* gets deleted=1, every listing (this bridge's /sessions history, the hub's
|
|
8
7
|
* project list, the desktop App sidebar) hides the session, and the backend
|
|
9
8
|
* store keeps the conversation bytes — reversible, never a purge. The id is
|
|
10
9
|
* the RAW backend sid (the /sessions listing's currency, same as the
|
|
11
10
|
* pass-through resume). Live conversations are refused (409): a delete
|
|
12
11
|
* reaching one means a stale client — the listing never offers them.
|
|
12
|
+
*
|
|
13
|
+
* `{"purge": true}` (opt-in, and only when the machine is armed via
|
|
14
|
+
* `delete.purge` in the user config or ZCODE_ACP_DELETE_PURGE=1) physically
|
|
15
|
+
* destroys the bytes through the upstream 3.18+ v4 face —
|
|
16
|
+
* `storage/sessionData/deletionPreview` → `deletionExecute` with its sha256
|
|
17
|
+
* revision guard, busy/in-use blocking and retained-artifact allowlist
|
|
18
|
+
* (ADR-0031's 2026-11-12 revision: the bridge never mints deletes itself;
|
|
19
|
+
* physical delete goes through the upstream face only). The tombstone is
|
|
20
|
+
* written FIRST (hide before the slow purge), so any purge failure degrades
|
|
21
|
+
* to the plain soft delete; a completed purge removes the tasks row (its
|
|
22
|
+
* bytes are gone — the row would be a zombie every reader filters around).
|
|
13
23
|
*/
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
24
|
+
import { randomUUID } from "node:crypto";
|
|
25
|
+
import { hardDeleteArmed } from "../config/user-config.js";
|
|
26
|
+
import { deleteTaskRows, retireTasks, softDeleteTask, taskWorkspacePath } from "../tasks-index.js";
|
|
27
|
+
import { log, warn } from "../utils.js";
|
|
16
28
|
import { liveZcodeSids } from "./session-list-endpoint.js";
|
|
17
29
|
/** Same charset gate as the hub's beforeId/sessionId validation. */
|
|
18
30
|
const SESSION_ID_RE = /^[\w.:-]+$/;
|
|
31
|
+
/** The v4 deletion face moves files — give preview and execute room. */
|
|
32
|
+
const DELETION_RPC_TIMEOUT_MS = 30000;
|
|
19
33
|
function sendText(res, code, message) {
|
|
20
34
|
if (res.writableEnded)
|
|
21
35
|
return;
|
|
@@ -30,13 +44,117 @@ function sendJson(res, code, body) {
|
|
|
30
44
|
});
|
|
31
45
|
res.end(payload);
|
|
32
46
|
}
|
|
47
|
+
/** Read one small optional JSON body (`{"purge": true}`); absent or non-JSON
|
|
48
|
+
* reads as undefined — older clients send no body at all. */
|
|
49
|
+
async function readOptionalJson(req) {
|
|
50
|
+
const chunks = [];
|
|
51
|
+
for await (const chunk of req) {
|
|
52
|
+
chunks.push(chunk);
|
|
53
|
+
if (chunks.reduce((n, c) => n + c.length, 0) > 65536) {
|
|
54
|
+
return undefined; // oversized — not a body shape we defined
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!chunks.length)
|
|
58
|
+
return undefined;
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
61
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed)
|
|
62
|
+
? parsed
|
|
63
|
+
: undefined;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function purgeSessionBytes(server, sessionId) {
|
|
70
|
+
let backend;
|
|
71
|
+
try {
|
|
72
|
+
backend = await server.ensureBackend();
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
return {
|
|
76
|
+
kind: "degraded",
|
|
77
|
+
reason: `backend unavailable: ${e instanceof Error ? e.message : String(e)}`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// The store must answer with the SAME workspace path or the preview refuses
|
|
81
|
+
// with identity-mismatch — prefer the tasks row's recorded attribution over
|
|
82
|
+
// the serve bridge's pinned cwd (imported sessions may predate the pin).
|
|
83
|
+
const workspacePath = (await taskWorkspacePath(sessionId)) ?? server.projectCwd();
|
|
84
|
+
let preview;
|
|
85
|
+
try {
|
|
86
|
+
const resp = await backend.request(server.nextId(), "v4/storage/sessionData/deletionPreview", { sessionId, workspace: { workspacePath } }, DELETION_RPC_TIMEOUT_MS);
|
|
87
|
+
if (resp.error) {
|
|
88
|
+
return { kind: "degraded", reason: `preview failed: ${resp.error.message ?? "unknown"}` };
|
|
89
|
+
}
|
|
90
|
+
preview = (resp.result ?? {});
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
return {
|
|
94
|
+
kind: "degraded",
|
|
95
|
+
reason: `preview failed: ${e instanceof Error ? e.message : String(e)}`,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (preview?.completed) {
|
|
99
|
+
// A previous execution already destroyed the bytes — finish the record.
|
|
100
|
+
await deleteTaskRows([sessionId]);
|
|
101
|
+
return { kind: "purged" };
|
|
102
|
+
}
|
|
103
|
+
if (preview?.blockedReason) {
|
|
104
|
+
if (preview.blockedReason === "not-found") {
|
|
105
|
+
// Physically gone or soft-deleted upstream — resume refuses both, so
|
|
106
|
+
// the row RETIRES (never revivable) instead of holding a zombie tombstone.
|
|
107
|
+
await retireTasks([sessionId]);
|
|
108
|
+
return { kind: "degraded", reason: "not-found" };
|
|
109
|
+
}
|
|
110
|
+
return { kind: "blocked", reason: preview.blockedReason };
|
|
111
|
+
}
|
|
112
|
+
if (!preview?.revision) {
|
|
113
|
+
return { kind: "degraded", reason: "preview returned no revision" };
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const resp = await backend.request(server.nextId(), "v4/storage/sessionData/deletionExecute", {
|
|
117
|
+
sessionId,
|
|
118
|
+
workspace: { workspacePath },
|
|
119
|
+
revision: preview.revision,
|
|
120
|
+
operationId: randomUUID(),
|
|
121
|
+
}, DELETION_RPC_TIMEOUT_MS);
|
|
122
|
+
if (resp.error) {
|
|
123
|
+
return { kind: "degraded", reason: `execute failed: ${resp.error.message ?? "unknown"}` };
|
|
124
|
+
}
|
|
125
|
+
const result = (resp.result ?? {});
|
|
126
|
+
if (result.status === "deleted") {
|
|
127
|
+
await deleteTaskRows([sessionId]);
|
|
128
|
+
return { kind: "purged" };
|
|
129
|
+
}
|
|
130
|
+
if (result.status === "incomplete") {
|
|
131
|
+
// Admitted but some files failed — upstream keeps the deletion receipt
|
|
132
|
+
// and a retry completes it; the tombstone hides the session meanwhile.
|
|
133
|
+
warn(`purge of ${sessionId.slice(0, 8)} incomplete: ${result.reason ?? "unknown"}`);
|
|
134
|
+
return { kind: "degraded", reason: `incomplete: ${result.reason ?? "unknown"}` };
|
|
135
|
+
}
|
|
136
|
+
return { kind: "blocked", reason: result.reason ?? result.status ?? "unknown" };
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
return {
|
|
140
|
+
kind: "degraded",
|
|
141
|
+
reason: `execute failed: ${e instanceof Error ? e.message : String(e)}`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
33
145
|
async function handleDelete(server, req, res, sessionId) {
|
|
34
|
-
|
|
35
|
-
|
|
146
|
+
const body = await readOptionalJson(req);
|
|
147
|
+
const purge = body?.["purge"] === true;
|
|
36
148
|
if (!SESSION_ID_RE.test(sessionId)) {
|
|
37
149
|
sendText(res, 400, "invalid sessionId");
|
|
38
150
|
return;
|
|
39
151
|
}
|
|
152
|
+
if (purge && !hardDeleteArmed()) {
|
|
153
|
+
// Refuse the WHOLE request, tombstone included: the client asked for a
|
|
154
|
+
// purge, and silently soft-deleting would read as success.
|
|
155
|
+
sendText(res, 403, "purge disabled — arm it via delete.purge in the user config or ZCODE_ACP_DELETE_PURGE=1");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
40
158
|
if (liveZcodeSids(server).has(sessionId)) {
|
|
41
159
|
sendText(res, 409, "session is live — stop or close it first");
|
|
42
160
|
return;
|
|
@@ -52,8 +170,25 @@ async function handleDelete(server, req, res, sessionId) {
|
|
|
52
170
|
sendText(res, 503, "tasks index unavailable");
|
|
53
171
|
return;
|
|
54
172
|
}
|
|
55
|
-
|
|
56
|
-
|
|
173
|
+
if (!purge) {
|
|
174
|
+
log(`remote: session ${sessionId.slice(0, 8)} soft-deleted (tombstone)`);
|
|
175
|
+
sendJson(res, 200, { ok: true, deleted: true });
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const outcome = await purgeSessionBytes(server, sessionId);
|
|
179
|
+
if (outcome.kind === "purged") {
|
|
180
|
+
log(`remote: session ${sessionId.slice(0, 8)} purged (v4 deletion face)`);
|
|
181
|
+
sendJson(res, 200, { ok: true, deleted: true, purged: true });
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (outcome.kind === "blocked") {
|
|
185
|
+
// The tombstone stands; the purge itself was refused by the upstream
|
|
186
|
+
// guards (running / in-use / changed) — the client may retry later.
|
|
187
|
+
sendJson(res, 409, { ok: false, deleted: true, purged: false, reason: outcome.reason });
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
log(`remote: session ${sessionId.slice(0, 8)} soft-deleted (purge degraded: ${outcome.reason})`);
|
|
191
|
+
sendJson(res, 200, { ok: true, deleted: true, purged: false, reason: outcome.reason });
|
|
57
192
|
}
|
|
58
193
|
/**
|
|
59
194
|
* Build the /sessions/{id}/delete request handler for the loopback endpoint.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-delete-endpoint.js","sourceRoot":"","sources":["../../src/remote/session-delete-endpoint.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session-delete-endpoint.js","sourceRoot":"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GG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAsB;IAEtB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE;QAC7B,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC1B,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,oBAAoB,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;QACD,KAAK,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACxD,IAAI,GAAG,CAAC,WAAW;gBAAE,GAAG,CAAC,OAAO,EAAE,CAAC;;gBAC9B,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Terminal relay (app ADR-0011): the hub is a DUMB AUTHENTICATED PIPE
|
|
3
|
+
* between remote clients (phone/web) and the desktop workbench. The hub never
|
|
4
|
+
* interprets terminal frames — the Remote Terminal object, event log, and
|
|
5
|
+
* turn state machine live in the workbench (`.zcode/docs/remote-terminal-
|
|
6
|
+
* requirements.md` in the app repo). Two WebSocket endpoints:
|
|
7
|
+
*
|
|
8
|
+
* /api/desktop-control — the workbench's outbound control connection
|
|
9
|
+
* (auth + the x-zcode-client desktop header, checked by the caller).
|
|
10
|
+
* Counts as connection-tier Desktop Presence while open. Exactly one is
|
|
11
|
+
* kept: a second connection supersedes the first (app restart race).
|
|
12
|
+
* /api/terminals/ws — a remote client's terminal socket, frame-relayed
|
|
13
|
+
* onto the control connection verbatim, both directions.
|
|
14
|
+
*
|
|
15
|
+
* The only hub-consumed frames come FROM the workbench (never relayed):
|
|
16
|
+
* {type:"push", title, body} — the shared push pipeline (push.ts: per-kind
|
|
17
|
+
* switch push.notify.terminal, `contentDetail:"minimal"` strips the body
|
|
18
|
+
* — command output transits Tencent otherwise — and the delivered-diary
|
|
19
|
+
* trail records every send; best-effort like every push)
|
|
20
|
+
* {type:"audit", line} — one diary line per turn (warn(), NOT log(): the
|
|
21
|
+
* hub daemon's stderr is null in production, so the on-disk diary is the
|
|
22
|
+
* only record — this line is the compensating control ADR-0011 names
|
|
23
|
+
* for the arbitrary-execution capability)
|
|
24
|
+
*
|
|
25
|
+
* The one hub-GENERATED frame goes TO the workbench (never relayed from a
|
|
26
|
+
* client): {type:"subs", count} whenever the relayed-client count changes —
|
|
27
|
+
* the workbench's only signal for "nobody is watching" (it gates turn-done
|
|
28
|
+
* pushes on count 0).
|
|
29
|
+
*
|
|
30
|
+
* The `remote.exec.enabled` gate (default false, live-read by the caller) is
|
|
31
|
+
* enforced at client-socket accept, re-checked on every relayed frame, and
|
|
32
|
+
* swept by the keepalive interval — so flipping the config tears down live
|
|
33
|
+
* pairings (idle ones included) without a hub restart. The control
|
|
34
|
+
* connection itself is never gated — it carries Desktop Presence
|
|
35
|
+
* regardless, and its relay-side frames are dropped while disabled.
|
|
36
|
+
*
|
|
37
|
+
* Keepalive mirrors the hub's proxy pinger: ping every interval, terminate a
|
|
38
|
+
* leg that missed one full interval of pongs — a half-open socket (laptop
|
|
39
|
+
* sleep, NAT cut) would otherwise stay OPEN locally, keep `controlAlive()`
|
|
40
|
+
* reporting presence on a dead workbench, and buffer frames into the void
|
|
41
|
+
* while the phone waits forever.
|
|
42
|
+
*/
|
|
43
|
+
import type { IncomingMessage } from "node:http";
|
|
44
|
+
import type { Duplex } from "node:stream";
|
|
45
|
+
/** Keepalive cadence for both endpoints (tunnels drop idle links ~100s). */
|
|
46
|
+
export declare const PING_INTERVAL_MS = 30000;
|
|
47
|
+
export interface TerminalRelayOptions {
|
|
48
|
+
/** Live `remote.exec.enabled` gate (default false — caller wires the live read). */
|
|
49
|
+
enabled: () => boolean;
|
|
50
|
+
/** Keepalive sweep cadence (tests shrink it); default PING_INTERVAL_MS. */
|
|
51
|
+
pingIntervalMs?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface TerminalRelay {
|
|
54
|
+
/** Complete an authenticated upgrade onto one of the two relay endpoints. */
|
|
55
|
+
handleUpgrade(req: IncomingMessage, socket: Duplex, head: Buffer, kind: "control" | "client"): void;
|
|
56
|
+
/** True while a workbench control connection is open (Desktop Presence). */
|
|
57
|
+
controlAlive(): boolean;
|
|
58
|
+
close(): void;
|
|
59
|
+
}
|
|
60
|
+
export declare function createTerminalRelay(opts: TerminalRelayOptions): TerminalRelay;
|
|
61
|
+
//# sourceMappingURL=terminal-relay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-relay.d.ts","sourceRoot":"","sources":["../../src/remote/terminal-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAS1C,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAMvC,MAAM,WAAW,oBAAoB;IACnC,oFAAoF;IACpF,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,aAAa,CACX,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,GAAG,QAAQ,GACzB,IAAI,CAAC;IACR,4EAA4E;IAC5E,YAAY,IAAI,OAAO,CAAC;IACxB,KAAK,IAAI,IAAI,CAAC;CACf;AAuCD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,aAAa,CAoL7E"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Terminal relay (app ADR-0011): the hub is a DUMB AUTHENTICATED PIPE
|
|
3
|
+
* between remote clients (phone/web) and the desktop workbench. The hub never
|
|
4
|
+
* interprets terminal frames — the Remote Terminal object, event log, and
|
|
5
|
+
* turn state machine live in the workbench (`.zcode/docs/remote-terminal-
|
|
6
|
+
* requirements.md` in the app repo). Two WebSocket endpoints:
|
|
7
|
+
*
|
|
8
|
+
* /api/desktop-control — the workbench's outbound control connection
|
|
9
|
+
* (auth + the x-zcode-client desktop header, checked by the caller).
|
|
10
|
+
* Counts as connection-tier Desktop Presence while open. Exactly one is
|
|
11
|
+
* kept: a second connection supersedes the first (app restart race).
|
|
12
|
+
* /api/terminals/ws — a remote client's terminal socket, frame-relayed
|
|
13
|
+
* onto the control connection verbatim, both directions.
|
|
14
|
+
*
|
|
15
|
+
* The only hub-consumed frames come FROM the workbench (never relayed):
|
|
16
|
+
* {type:"push", title, body} — the shared push pipeline (push.ts: per-kind
|
|
17
|
+
* switch push.notify.terminal, `contentDetail:"minimal"` strips the body
|
|
18
|
+
* — command output transits Tencent otherwise — and the delivered-diary
|
|
19
|
+
* trail records every send; best-effort like every push)
|
|
20
|
+
* {type:"audit", line} — one diary line per turn (warn(), NOT log(): the
|
|
21
|
+
* hub daemon's stderr is null in production, so the on-disk diary is the
|
|
22
|
+
* only record — this line is the compensating control ADR-0011 names
|
|
23
|
+
* for the arbitrary-execution capability)
|
|
24
|
+
*
|
|
25
|
+
* The one hub-GENERATED frame goes TO the workbench (never relayed from a
|
|
26
|
+
* client): {type:"subs", count} whenever the relayed-client count changes —
|
|
27
|
+
* the workbench's only signal for "nobody is watching" (it gates turn-done
|
|
28
|
+
* pushes on count 0).
|
|
29
|
+
*
|
|
30
|
+
* The `remote.exec.enabled` gate (default false, live-read by the caller) is
|
|
31
|
+
* enforced at client-socket accept, re-checked on every relayed frame, and
|
|
32
|
+
* swept by the keepalive interval — so flipping the config tears down live
|
|
33
|
+
* pairings (idle ones included) without a hub restart. The control
|
|
34
|
+
* connection itself is never gated — it carries Desktop Presence
|
|
35
|
+
* regardless, and its relay-side frames are dropped while disabled.
|
|
36
|
+
*
|
|
37
|
+
* Keepalive mirrors the hub's proxy pinger: ping every interval, terminate a
|
|
38
|
+
* leg that missed one full interval of pongs — a half-open socket (laptop
|
|
39
|
+
* sleep, NAT cut) would otherwise stay OPEN locally, keep `controlAlive()`
|
|
40
|
+
* reporting presence on a dead workbench, and buffer frames into the void
|
|
41
|
+
* while the phone waits forever.
|
|
42
|
+
*/
|
|
43
|
+
import { WebSocket, WebSocketServer } from "ws";
|
|
44
|
+
import { pushTerminalNotification } from "../push/push.js";
|
|
45
|
+
import { log, warn } from "../utils.js";
|
|
46
|
+
/** Frame cap: input lines and result tails are small; bigger is abuse or a bug. */
|
|
47
|
+
const MAX_FRAME_BYTES = 256 * 1024;
|
|
48
|
+
/** Keepalive cadence for both endpoints (tunnels drop idle links ~100s). */
|
|
49
|
+
export const PING_INTERVAL_MS = 30_000;
|
|
50
|
+
/** Audit line cap — the workbench composes the line, the hub just bounds it. */
|
|
51
|
+
const MAX_AUDIT_CHARS = 500;
|
|
52
|
+
const MAX_PUSH_TITLE = 200;
|
|
53
|
+
const MAX_PUSH_BODY = 1024;
|
|
54
|
+
/** Normalize a ws message payload to one Buffer (forwarded verbatim, parsed for control). */
|
|
55
|
+
function toBuffer(data) {
|
|
56
|
+
if (Array.isArray(data))
|
|
57
|
+
return Buffer.concat(data);
|
|
58
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
59
|
+
}
|
|
60
|
+
function parseJsonFrame(data) {
|
|
61
|
+
try {
|
|
62
|
+
const parsed = JSON.parse(toBuffer(data).toString("utf8"));
|
|
63
|
+
return typeof parsed === "object" && parsed !== null ? parsed : null;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function errorFrame(code, message) {
|
|
70
|
+
return JSON.stringify({ v: 1, type: "error", code, message });
|
|
71
|
+
}
|
|
72
|
+
/** Send one error frame, then close with a matching code — the client renders the reason. */
|
|
73
|
+
function errorClose(ws, code, message, closeCode = 4001) {
|
|
74
|
+
if (ws.readyState !== WebSocket.OPEN)
|
|
75
|
+
return;
|
|
76
|
+
try {
|
|
77
|
+
ws.send(errorFrame(code, message));
|
|
78
|
+
ws.close(closeCode, code);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
ws.terminate();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function createTerminalRelay(opts) {
|
|
85
|
+
const { pingIntervalMs = PING_INTERVAL_MS } = opts;
|
|
86
|
+
const wss = new WebSocketServer({ noServer: true, maxPayload: MAX_FRAME_BYTES });
|
|
87
|
+
/** The single workbench control connection (superseded on a second one). */
|
|
88
|
+
let control = null;
|
|
89
|
+
/** Remote client sockets, all frame-relayed onto the control connection. */
|
|
90
|
+
const clients = new Set();
|
|
91
|
+
/** Legs that answered the last ping (WeakSet: membership dies with the socket). */
|
|
92
|
+
const pongResponsive = new WeakSet();
|
|
93
|
+
/** Arm keepalive supervision on one leg (grace until the first sweep — a fresh socket has not had a chance to pong yet). */
|
|
94
|
+
function supervise(ws) {
|
|
95
|
+
pongResponsive.add(ws);
|
|
96
|
+
ws.on("pong", () => pongResponsive.add(ws));
|
|
97
|
+
}
|
|
98
|
+
const ping = setInterval(() => {
|
|
99
|
+
// Spec §Security sweep: the gate is live-read, so a flip must also reach
|
|
100
|
+
// IDLE pairs — the per-frame checks only fire when something moves.
|
|
101
|
+
if (!opts.enabled() && clients.size > 0) {
|
|
102
|
+
dropClients("disabled", "remote terminal disabled (remote.exec.enabled)");
|
|
103
|
+
}
|
|
104
|
+
for (const ws of [control, ...clients]) {
|
|
105
|
+
if (!ws || ws.readyState !== WebSocket.OPEN)
|
|
106
|
+
continue;
|
|
107
|
+
if (pongResponsive.has(ws)) {
|
|
108
|
+
pongResponsive.delete(ws);
|
|
109
|
+
try {
|
|
110
|
+
ws.ping();
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
/* dead sockets surface via their own close/error handlers */
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
log("terminal-relay: leg missed a keepalive pong — terminating (dead peer)");
|
|
118
|
+
ws.terminate();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, pingIntervalMs);
|
|
122
|
+
ping.unref();
|
|
123
|
+
/** Hub-consumed workbench frames (push/audit); true when the frame was consumed. */
|
|
124
|
+
function consumeHubFrame(frame) {
|
|
125
|
+
if (frame.type === "push") {
|
|
126
|
+
const title = typeof frame.title === "string" && frame.title.trim()
|
|
127
|
+
? frame.title.trim().slice(0, MAX_PUSH_TITLE)
|
|
128
|
+
: "Remote terminal";
|
|
129
|
+
const body = typeof frame.body === "string" ? frame.body.slice(0, MAX_PUSH_BODY).trim() : "";
|
|
130
|
+
pushTerminalNotification({ kind: "terminal", title, body: body || undefined });
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
if (frame.type === "audit") {
|
|
134
|
+
if (typeof frame.line === "string" && frame.line.trim()) {
|
|
135
|
+
warn(`terminal: ${frame.line.slice(0, MAX_AUDIT_CHARS)}`);
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
function dropClients(code, message) {
|
|
142
|
+
for (const c of clients)
|
|
143
|
+
errorClose(c, code, message);
|
|
144
|
+
clients.clear();
|
|
145
|
+
}
|
|
146
|
+
/** Tell the workbench how many remote clients are attached (push gate). */
|
|
147
|
+
function notifySubs() {
|
|
148
|
+
if (!control || control.readyState !== WebSocket.OPEN)
|
|
149
|
+
return;
|
|
150
|
+
try {
|
|
151
|
+
control.send(JSON.stringify({ v: 1, type: "subs", count: clients.size }));
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
/* a dead control is reaped by its own close handler */
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function attachControl(ws) {
|
|
158
|
+
const prev = control;
|
|
159
|
+
control = ws;
|
|
160
|
+
supervise(ws);
|
|
161
|
+
if (prev && prev.readyState === WebSocket.OPEN) {
|
|
162
|
+
log("terminal-relay: new workbench control connection — superseding the previous one");
|
|
163
|
+
prev.close(4000, "superseded");
|
|
164
|
+
}
|
|
165
|
+
log("terminal-relay: workbench control connected");
|
|
166
|
+
if (!opts.enabled()) {
|
|
167
|
+
warn("terminal-relay: remote.exec disabled — control connection stays (presence), relay inert");
|
|
168
|
+
}
|
|
169
|
+
ws.on("message", (data) => {
|
|
170
|
+
// push/audit always land (they report turns that already ran); relaying
|
|
171
|
+
// is the part the switch gates.
|
|
172
|
+
const frame = parseJsonFrame(data);
|
|
173
|
+
if (frame && consumeHubFrame(frame))
|
|
174
|
+
return;
|
|
175
|
+
if (!opts.enabled()) {
|
|
176
|
+
// Spec §Security: a gated frame means live pairs must go NOW — the
|
|
177
|
+
// idle ones are swept by the keepalive interval above. A silent drop
|
|
178
|
+
// here would freeze phone screens mid-turn with no error frame.
|
|
179
|
+
dropClients("disabled", "remote terminal disabled (remote.exec.enabled)");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (frame === null) {
|
|
183
|
+
warn("terminal-relay: non-JSON frame from workbench — dropped");
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const buf = toBuffer(data);
|
|
187
|
+
for (const c of clients) {
|
|
188
|
+
if (c.readyState === WebSocket.OPEN) {
|
|
189
|
+
try {
|
|
190
|
+
c.send(buf);
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
/* a dead client is reaped by its own close handler */
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
const gone = () => {
|
|
199
|
+
if (control !== ws)
|
|
200
|
+
return;
|
|
201
|
+
control = null;
|
|
202
|
+
log("terminal-relay: workbench control gone — dropping remote clients");
|
|
203
|
+
dropClients("no_carrier", "desktop workbench disconnected");
|
|
204
|
+
};
|
|
205
|
+
ws.on("close", gone);
|
|
206
|
+
ws.on("error", gone);
|
|
207
|
+
}
|
|
208
|
+
const relay = {
|
|
209
|
+
handleUpgrade(req, socket, head, kind) {
|
|
210
|
+
if (kind === "control") {
|
|
211
|
+
wss.handleUpgrade(req, socket, head, attachControl);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
wss.handleUpgrade(req, socket, head, (ws) => {
|
|
215
|
+
if (!opts.enabled()) {
|
|
216
|
+
errorClose(ws, "disabled", "remote terminal disabled (remote.exec.enabled)");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (!control || control.readyState !== WebSocket.OPEN) {
|
|
220
|
+
errorClose(ws, "no_carrier", "no desktop workbench connected");
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
clients.add(ws);
|
|
224
|
+
supervise(ws);
|
|
225
|
+
notifySubs();
|
|
226
|
+
ws.on("message", (data) => {
|
|
227
|
+
if (!opts.enabled()) {
|
|
228
|
+
errorClose(ws, "disabled", "remote terminal disabled (remote.exec.enabled)");
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (!control || control.readyState !== WebSocket.OPEN) {
|
|
232
|
+
errorClose(ws, "no_carrier", "desktop workbench disconnected");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
control.send(toBuffer(data));
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
errorClose(ws, "no_carrier", "desktop workbench disconnected");
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
const goneClient = () => {
|
|
243
|
+
if (clients.delete(ws))
|
|
244
|
+
notifySubs();
|
|
245
|
+
};
|
|
246
|
+
ws.on("close", goneClient);
|
|
247
|
+
ws.on("error", goneClient);
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
controlAlive() {
|
|
251
|
+
return control !== null && control.readyState === WebSocket.OPEN;
|
|
252
|
+
},
|
|
253
|
+
close() {
|
|
254
|
+
clearInterval(ping);
|
|
255
|
+
dropClients("no_carrier", "hub shutting down");
|
|
256
|
+
control?.close(1001, "hub shutting down");
|
|
257
|
+
control = null;
|
|
258
|
+
wss.close();
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
return relay;
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=terminal-relay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-relay.js","sourceRoot":"","sources":["../../src/remote/terminal-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAgB,MAAM,IAAI,CAAC;AAE9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,mFAAmF;AACnF,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,CAAC;AACnC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACvC,gFAAgF;AAChF,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,aAAa,GAAG,IAAI,CAAC;AAsB3B,6FAA6F;AAC7F,SAAS,QAAQ,CAAC,IAAa;IAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC;AASD,SAAS,cAAc,CAAC,IAAa;IACnC,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CA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BAAmB,CAAC,CAAC;YAC1C,OAAO,GAAG,IAAI,CAAC;YACf,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -290,6 +290,13 @@ export declare class ZcodeAcpServer {
|
|
|
290
290
|
* toolDenylistRejected — a respawned process may be an older build.
|
|
291
291
|
*/
|
|
292
292
|
backendLifecycleApi: boolean | null;
|
|
293
|
+
/**
|
|
294
|
+
* `session/list`'s `sessionIds` key acceptance on the CURRENT backend build:
|
|
295
|
+
* null = not yet probed, true = rejected (strict zod "Unrecognized key" —
|
|
296
|
+
* fall back to per-id lifecycle probes), false = accepted. Pinned per
|
|
297
|
+
* backend generation like toolDenylistRejected.
|
|
298
|
+
*/
|
|
299
|
+
sessionIdsQueryRejected: boolean | null;
|
|
293
300
|
/**
|
|
294
301
|
* The full slash-command list (set once by buildAgentApp in index.ts).
|
|
295
302
|
* Read by the gate-aware menu catch-up (resendMenuAfterGateSettled in
|
|
@@ -767,6 +774,30 @@ export declare class ZcodeAcpServer {
|
|
|
767
774
|
* retired conversation, and its terminal activity must not resurrect it.
|
|
768
775
|
*/
|
|
769
776
|
wasDiscoveryRetiredSince(acpSid: string, sinceMs: number): boolean;
|
|
777
|
+
/**
|
|
778
|
+
* Which of `ids` the CURRENT backend can no longer serve — the oracle
|
|
779
|
+
* behind tombstone retirement (#376). Uses the EXISTING backend only
|
|
780
|
+
* (never spawns: the session/new revival path is fire-and-forget and must
|
|
781
|
+
* stay free) and answers with the ids ABSENT from
|
|
782
|
+
* `session/list {sessionIds}` — upstream drops both physically deleted and
|
|
783
|
+
* soft-deleted (time_deleted) sessions there, and resume refuses both the
|
|
784
|
+
* same way, so both deserve retirement while bridge-tombstoned sessions
|
|
785
|
+
* (no time_deleted) keep reviving per the ADR-0031 self-heal contract.
|
|
786
|
+
*
|
|
787
|
+
* A backend whose schema predates the `sessionIds` key (strict zod
|
|
788
|
+
* "Unrecognized key", verdict pinned per generation) falls back to per-id
|
|
789
|
+
* `session/lifecycle/getState` probes (>= 0.17.1). Failure semantics: a
|
|
790
|
+
* chunk that ERRORS or a thrown transport aborts further probing and
|
|
791
|
+
* returns what earlier chunks already PROVED gone (each entry carries its
|
|
792
|
+
* own positive evidence); an id with no verdict is simply absent — the
|
|
793
|
+
* caller treats it as "revive blindly" (the pre-#376 behavior): a probe
|
|
794
|
+
* hiccup must never un-revive a session the store still has.
|
|
795
|
+
*/
|
|
796
|
+
probeGoneBackendSessions(ids: string[]): Promise<Set<string>>;
|
|
797
|
+
/** Per-id fallback oracle: `session/lifecycle/getState`'s "Session not
|
|
798
|
+
* found" is the same resume-refused verdict as the batch face. Unavailable
|
|
799
|
+
* on pre-0.17.1 builds — no oracle, no retirement. */
|
|
800
|
+
private probeGoneViaLifecycle;
|
|
770
801
|
/**
|
|
771
802
|
* Tombstone revival behind markSessionActive. Guarded, not destructured:
|
|
772
803
|
* several test suites mock tasks-index PARTIALLY (without this export), and
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAErD,OAAO,EAEL,KAAK,WAAW,EAIhB,KAAK,sBAAsB,EAE3B,YAAY,EACb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAsB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAErD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