sensorium-mcp 3.1.0-refactor.17 → 3.1.0-refactor.18

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.
Files changed (109) hide show
  1. package/dist/config/agent-settings.d.ts +0 -6
  2. package/dist/config/agent-settings.d.ts.map +1 -1
  3. package/dist/config/agent-settings.js +0 -22
  4. package/dist/config/agent-settings.js.map +1 -1
  5. package/dist/config/index.d.ts +0 -1
  6. package/dist/config/index.d.ts.map +1 -1
  7. package/dist/config/index.js +0 -1
  8. package/dist/config/index.js.map +1 -1
  9. package/dist/dashboard/routes/copilot.d.ts.map +1 -1
  10. package/dist/dashboard/routes/copilot.js +1 -17
  11. package/dist/dashboard/routes/copilot.js.map +1 -1
  12. package/dist/dashboard/routes/threads-read.d.ts.map +1 -1
  13. package/dist/dashboard/routes/threads-read.js +2 -9
  14. package/dist/dashboard/routes/threads-read.js.map +1 -1
  15. package/dist/dashboard/routes/threads.js +3 -3
  16. package/dist/dashboard/routes/threads.js.map +1 -1
  17. package/dist/dashboard/routes.d.ts.map +1 -1
  18. package/dist/dashboard/routes.js +4 -11
  19. package/dist/dashboard/routes.js.map +1 -1
  20. package/dist/dashboard/spa.html +11 -11
  21. package/dist/index.js +13 -48
  22. package/dist/index.js.map +1 -1
  23. package/dist/lib/logger.d.ts.map +1 -1
  24. package/dist/lib/logger.js +2 -21
  25. package/dist/lib/logger.js.map +1 -1
  26. package/dist/server/factory.js +6 -16
  27. package/dist/server/factory.js.map +1 -1
  28. package/dist/server/http-server.d.ts.map +1 -1
  29. package/dist/server/http-server.js +7 -10
  30. package/dist/server/http-server.js.map +1 -1
  31. package/dist/services/agent-spawn.service.d.ts +3 -3
  32. package/dist/services/agent-spawn.service.d.ts.map +1 -1
  33. package/dist/services/agent-spawn.service.js +8 -14
  34. package/dist/services/agent-spawn.service.js.map +1 -1
  35. package/dist/services/background-runner.d.ts.map +1 -1
  36. package/dist/services/background-runner.js +12 -6
  37. package/dist/services/background-runner.js.map +1 -1
  38. package/dist/services/claude-spawn.service.d.ts +1 -1
  39. package/dist/services/claude-spawn.service.d.ts.map +1 -1
  40. package/dist/services/claude-spawn.service.js +25 -25
  41. package/dist/services/claude-spawn.service.js.map +1 -1
  42. package/dist/services/codex-spawn.service.d.ts +1 -1
  43. package/dist/services/codex-spawn.service.d.ts.map +1 -1
  44. package/dist/services/codex-spawn.service.js +24 -19
  45. package/dist/services/codex-spawn.service.js.map +1 -1
  46. package/dist/services/copilot-spawn.service.d.ts +1 -1
  47. package/dist/services/copilot-spawn.service.d.ts.map +1 -1
  48. package/dist/services/copilot-spawn.service.js +36 -45
  49. package/dist/services/copilot-spawn.service.js.map +1 -1
  50. package/dist/services/dispatcher/poller.d.ts.map +1 -1
  51. package/dist/services/dispatcher/poller.js +5 -24
  52. package/dist/services/dispatcher/poller.js.map +1 -1
  53. package/dist/services/flight-recorder.service.d.ts.map +1 -1
  54. package/dist/services/flight-recorder.service.js +2 -41
  55. package/dist/services/flight-recorder.service.js.map +1 -1
  56. package/dist/services/keeper.service.d.ts +0 -9
  57. package/dist/services/keeper.service.d.ts.map +1 -1
  58. package/dist/services/keeper.service.js +31 -147
  59. package/dist/services/keeper.service.js.map +1 -1
  60. package/dist/services/process.service.d.ts +62 -40
  61. package/dist/services/process.service.d.ts.map +1 -1
  62. package/dist/services/process.service.js +613 -118
  63. package/dist/services/process.service.js.map +1 -1
  64. package/dist/services/scheduler.d.ts +0 -1
  65. package/dist/services/scheduler.d.ts.map +1 -1
  66. package/dist/services/scheduler.js +11 -58
  67. package/dist/services/scheduler.js.map +1 -1
  68. package/dist/services/self-update.service.d.ts +3 -14
  69. package/dist/services/self-update.service.d.ts.map +1 -1
  70. package/dist/services/self-update.service.js +72 -141
  71. package/dist/services/self-update.service.js.map +1 -1
  72. package/dist/services/spawn-common.d.ts +23 -49
  73. package/dist/services/spawn-common.d.ts.map +1 -1
  74. package/dist/services/spawn-common.js +47 -262
  75. package/dist/services/spawn-common.js.map +1 -1
  76. package/dist/services/thread-health.service.d.ts +1 -1
  77. package/dist/services/thread-health.service.d.ts.map +1 -1
  78. package/dist/services/thread-health.service.js +6 -6
  79. package/dist/services/thread-health.service.js.map +1 -1
  80. package/dist/services/worker-cleanup.service.d.ts.map +1 -1
  81. package/dist/services/worker-cleanup.service.js +92 -9
  82. package/dist/services/worker-cleanup.service.js.map +1 -1
  83. package/dist/tools/defs/session-defs.js +1 -1
  84. package/dist/tools/defs/session-defs.js.map +1 -1
  85. package/dist/tools/defs/utility-defs.d.ts.map +1 -1
  86. package/dist/tools/defs/utility-defs.js +3 -4
  87. package/dist/tools/defs/utility-defs.js.map +1 -1
  88. package/dist/tools/delegate-tool.d.ts +1 -1
  89. package/dist/tools/delegate-tool.d.ts.map +1 -1
  90. package/dist/tools/delegate-tool.js +5 -5
  91. package/dist/tools/delegate-tool.js.map +1 -1
  92. package/dist/tools/session-tools.d.ts.map +1 -1
  93. package/dist/tools/session-tools.js +9 -26
  94. package/dist/tools/session-tools.js.map +1 -1
  95. package/dist/tools/utility-tools.js +1 -1
  96. package/dist/tools/utility-tools.js.map +1 -1
  97. package/package.json +1 -1
  98. package/dist/config/detail-grant.d.ts +0 -39
  99. package/dist/config/detail-grant.d.ts.map +0 -1
  100. package/dist/config/detail-grant.js +0 -61
  101. package/dist/config/detail-grant.js.map +0 -1
  102. package/dist/services/broker-client.d.ts +0 -181
  103. package/dist/services/broker-client.d.ts.map +0 -1
  104. package/dist/services/broker-client.js +0 -323
  105. package/dist/services/broker-client.js.map +0 -1
  106. package/dist/services/spawn-exit-watcher.d.ts +0 -32
  107. package/dist/services/spawn-exit-watcher.d.ts.map +0 -1
  108. package/dist/services/spawn-exit-watcher.js +0 -102
  109. package/dist/services/spawn-exit-watcher.js.map +0 -1
@@ -1,323 +0,0 @@
1
- /**
2
- * Thin HTTP client for the supervisor's process broker (plan §4.1, Phase 2).
3
- *
4
- * Liveness, identity and kill move OFF the Node event loop and OUT of child
5
- * processes: the supervisor answers from one native NtQuerySystemInformation
6
- * snapshot and kills via native TerminateProcess/TerminateJobObject. Nothing
7
- * here ever spawns a process — the EDR-gated tasklist/powershell/taskkill
8
- * machinery this replaces was itself the leading event-loop stall generator.
9
- *
10
- * Degradation contract (the audited-safe direction, same as the old breakers):
11
- * every function returns `null` when the broker cannot answer (unreachable,
12
- * auth-rejected, timeout) and the caller MUST treat null as "cannot confirm
13
- * → assume alive / kill not performed". Communication is strictly one-way
14
- * MCP → supervisor.
15
- */
16
- import { log } from "../lib/logger.js";
17
- import { errorMessage } from "../lib/utils.js";
18
- const REQUEST_TIMEOUT_MS = 3000;
19
- // Timeouts here are pure LIVENESS backstops — correctness never depends on
20
- // their values. A spawn whose request outlives the client timeout is resolved
21
- // through the reconcile path (query the broker registry, adopt or retry the
22
- // idempotent spawn — see launchAgent), never by a blind local spawn, so no
23
- // timeout value can cause a duplicate agent. Spawns are sub-second on this
24
- // machine; the generous budgets only keep a pathologically slow call from
25
- // tying up its caller forever. Kill's TerminateJobObject settle loop alone can
26
- // take ~2.2s server-side, hence the longer mutate budget. Reads keep 3s.
27
- const SPAWN_TIMEOUT_MS = 30_000;
28
- const MUTATE_TIMEOUT_MS = 10_000;
29
- // After a failed broker call, skip further calls for a short window instead of
30
- // re-paying a connect timeout for every pid in a sweep (the keeper checks many
31
- // pids per cycle). Connection-refused fails in ~1 ms so this is only load-bearing
32
- // when the supervisor itself is wedged.
33
- const UNREACHABLE_COOLDOWN_MS = 5000;
34
- let unreachableUntil = 0;
35
- let unreachableLogged = false;
36
- let lastFailureKind = "uncertain";
37
- function classifyFetchError(err) {
38
- const e = err;
39
- // AbortSignal.timeout → the request was sent and the response never arrived.
40
- if (e?.name === "TimeoutError" || e?.name === "AbortError")
41
- return "uncertain";
42
- const code = e?.cause?.code ?? e?.cause?.errors?.find((x) => x?.code)?.code ?? e?.code ?? undefined;
43
- switch (code) {
44
- case "ECONNREFUSED":
45
- case "ENOTFOUND":
46
- case "EAI_AGAIN":
47
- case "EADDRNOTAVAIL":
48
- case "EHOSTUNREACH":
49
- case "ENETUNREACH":
50
- case "UND_ERR_CONNECT_TIMEOUT":
51
- return "no-connection";
52
- }
53
- // Some undici versions wrap the socket error in a bare Error with only a
54
- // message ("connect ECONNREFUSED …", "bad port"). Fall back to the text for
55
- // the same connection-never-established classes; anything unrecognized stays
56
- // "uncertain" — the safe direction.
57
- const msg = e?.cause?.message ?? "";
58
- if (/ECONNREFUSED|ENOTFOUND|EHOSTUNREACH|ENETUNREACH|bad port|invalid url/i.test(msg))
59
- return "no-connection";
60
- return "uncertain";
61
- }
62
- function brokerBaseUrl() {
63
- const port = Number.parseInt(process.env.SUPERVISOR_HTTP_PORT ?? "", 10) || 8848;
64
- return `http://127.0.0.1:${port}`;
65
- }
66
- function authHeaders() {
67
- const secret = process.env.MCP_HTTP_SECRET;
68
- return secret ? { Authorization: `Bearer ${secret}` } : {};
69
- }
70
- async function brokerFetchClassified(path, init, timeoutMs = REQUEST_TIMEOUT_MS, opts) {
71
- const now = Date.now();
72
- // During the cooldown we answer from the LAST observed failure kind: the
73
- // spawn contract needs "could the broker have received a request" and a
74
- // skipped call inherits the evidence that started the cooldown. The cooldown
75
- // exists to protect the keeper's many-pids-per-cycle sweeps from paying a
76
- // full timeout each; spawn/reconcile calls are rare and correctness-critical,
77
- // so they bypass it — a reconcile probe must never be answered from stale
78
- // evidence created by the very spawn it is reconciling.
79
- if (!opts?.bypassCooldown && now < unreachableUntil)
80
- return { res: null, failure: lastFailureKind };
81
- try {
82
- const res = await fetch(`${brokerBaseUrl()}${path}`, {
83
- ...init,
84
- headers: { ...authHeaders(), ...init?.headers },
85
- signal: AbortSignal.timeout(timeoutMs),
86
- });
87
- unreachableLogged = false;
88
- return { res };
89
- }
90
- catch (err) {
91
- const failure = classifyFetchError(err);
92
- unreachableUntil = Date.now() + UNREACHABLE_COOLDOWN_MS;
93
- lastFailureKind = failure;
94
- if (!unreachableLogged) {
95
- // WARN, deliberately: every liveness answer during this outage degrades to
96
- // "cannot confirm → treat alive" and every kill falls back to best-effort —
97
- // a silent fallback must never look like a healthy answer. Logged once per
98
- // outage episode (reset on the first successful call) to avoid a warn storm
99
- // when the keeper sweeps many pids per cycle.
100
- log.warn(`[broker] unreachable (${errorMessage(err)}, ${failure}) — degrading to "cannot confirm": liveness treated as alive, kills fall back to native root-only`);
101
- unreachableLogged = true;
102
- }
103
- return { res: null, failure };
104
- }
105
- }
106
- async function brokerFetch(path, init, timeoutMs = REQUEST_TIMEOUT_MS) {
107
- return (await brokerFetchClassified(path, init, timeoutMs)).res;
108
- }
109
- /**
110
- * Ask the broker whether `pid` is alive AND (when `startedAtMs` is given) still
111
- * the same process we spawned (creation-time identity, ±60s tolerance — the
112
- * same rule the deleted tasklist/Get-Process snapshots enforced).
113
- * `startTimeTicks` (native creation FILETIME from a broker spawn) upgrades the
114
- * check to exact identity. Returns null when the broker cannot answer.
115
- */
116
- export async function brokerCheckAlive(pid, startedAtMs, startTimeTicks) {
117
- const params = new URLSearchParams({ pid: String(pid) });
118
- if (startTimeTicks !== undefined && startTimeTicks !== 0)
119
- params.set("startTicks", String(startTimeTicks));
120
- else if (startedAtMs !== undefined)
121
- params.set("startMs", String(Math.round(startedAtMs)));
122
- const res = await brokerFetch(`/proc/alive?${params}`);
123
- if (!res || !res.ok)
124
- return null;
125
- try {
126
- return (await res.json());
127
- }
128
- catch {
129
- return null;
130
- }
131
- }
132
- /**
133
- * Ask the broker to kill the process tree rooted at `pid` (native, identity-
134
- * checked when `startedAtMs` is given; the broker records the outcome in its
135
- * on-disk registry). Returns null when the broker cannot answer — the caller
136
- * must then fall back / re-verify, never assume the kill happened.
137
- */
138
- export async function brokerKillTree(pid, opts = {}) {
139
- const res = await brokerFetch(`/proc/kill`, {
140
- method: "POST",
141
- headers: { "Content-Type": "application/json" },
142
- body: JSON.stringify({
143
- pid,
144
- threadId: opts.threadId,
145
- startMs: opts.startedAtMs !== undefined ? Math.round(opts.startedAtMs) : undefined,
146
- killedBy: opts.killedBy ?? "mcp",
147
- reason: opts.reason,
148
- }),
149
- }, MUTATE_TIMEOUT_MS);
150
- if (!res)
151
- return null;
152
- // 403 = the broker REFUSED (self/server protection). That is an answer, not an
153
- // outage: report it as not-killed-still-alive so callers never retry-storm.
154
- if (!res.ok && res.status !== 403)
155
- return null;
156
- try {
157
- return (await res.json());
158
- }
159
- catch {
160
- return null;
161
- }
162
- }
163
- /**
164
- * Ask the supervisor to spawn an agent process: CreateProcess(CREATE_SUSPENDED)
165
- * → assign to the thread's named job → resume. The supervisor is the process
166
- * owner; children (hooks, grandchildren) land in the job automatically.
167
- * Spawn is idempotent by threadId server-side (create-or-return), which is what
168
- * makes retrying after an uncertain outcome safe.
169
- */
170
- export async function brokerSpawn(spec) {
171
- const { res, failure } = await brokerFetchClassified(`/proc/spawn`, {
172
- method: "POST",
173
- headers: { "Content-Type": "application/json" },
174
- body: JSON.stringify(spec),
175
- }, spawnTimeoutOverride ?? SPAWN_TIMEOUT_MS, { bypassCooldown: true });
176
- if (!res) {
177
- return failure === "no-connection"
178
- ? { unavailable: "broker unreachable — connection never established" }
179
- : { uncertain: "spawn request timed out or the connection was lost mid-flight" };
180
- }
181
- if (res.status === 404 || res.status === 401)
182
- return {
183
- unavailable: res.status === 404
184
- ? "/proc/spawn not available on this supervisor build"
185
- : "broker rejected the bearer secret",
186
- };
187
- try {
188
- const body = (await res.json());
189
- if (res.ok && body.ok && typeof body.pid === "number" && body.pid > 0) {
190
- return {
191
- pid: body.pid,
192
- startTimeTicks: body.startTimeTicks ?? 0,
193
- startTimeMs: body.startTimeMs ?? Date.now(),
194
- jobName: body.jobName ?? null,
195
- jobAssignFailed: body.jobAssignFailed ?? false,
196
- existing: body.existing ?? false,
197
- };
198
- }
199
- return { error: body.error ?? `broker answered HTTP ${res.status} without an error detail` };
200
- }
201
- catch {
202
- // A 200 the broker sent but we could not read — the spawn may well have
203
- // happened. Only a non-OK status is a definitive failure.
204
- return res.ok
205
- ? { uncertain: `broker answered HTTP ${res.status} but the body was unreadable` }
206
- : { error: `broker answered HTTP ${res.status} with an unparseable body` };
207
- }
208
- }
209
- /**
210
- * The broker's live process list for a thread (job members, falling back to the
211
- * registry root's tree). This is the reconcile source of truth after an
212
- * uncertain spawn: a live entry here means the thread HAS its process — adopt
213
- * it, never spawn another. `known:false` → the broker answered and has no
214
- * record of the thread. Null → broker could not answer.
215
- */
216
- export async function brokerListThread(threadId) {
217
- const { res } = await brokerFetchClassified(`/proc/list?threadId=${threadId}`, undefined, REQUEST_TIMEOUT_MS, {
218
- bypassCooldown: true,
219
- });
220
- if (!res)
221
- return null;
222
- if (res.status === 404)
223
- return { known: false, processes: [] };
224
- if (!res.ok)
225
- return null;
226
- try {
227
- const body = (await res.json());
228
- return { known: true, processes: body.processes ?? [] };
229
- }
230
- catch {
231
- return null;
232
- }
233
- }
234
- // ── Adopt (safe-cutover migration) ──────────────────────────────────────────
235
- /**
236
- * Ask the broker to adopt an already-running process (spawned before the broker
237
- * owned spawning, or during a broker outage) into the thread's job + registry.
238
- * Idempotent server-side. Best-effort: null when the broker cannot answer.
239
- */
240
- export async function brokerAdopt(threadId, pid, startedAtMs, role) {
241
- const res = await brokerFetch(`/proc/adopt`, {
242
- method: "POST",
243
- headers: { "Content-Type": "application/json" },
244
- body: JSON.stringify({
245
- threadId,
246
- pid,
247
- startMs: startedAtMs !== undefined ? Math.round(startedAtMs) : undefined,
248
- role,
249
- }),
250
- },
251
- // Adopt walks and job-assigns a whole tree — give it the mutate budget.
252
- MUTATE_TIMEOUT_MS);
253
- if (!res || !res.ok)
254
- return null;
255
- try {
256
- return (await res.json());
257
- }
258
- catch {
259
- return null;
260
- }
261
- }
262
- /**
263
- * Ask the supervisor — the single process-lifecycle owner — to tear down and
264
- * respawn THIS server (self-update path). The supervisor answers 202 before
265
- * doing anything: the requester is the process about to be killed, so it can
266
- * never observe completion. 409 means a restart is already in progress, which
267
- * delivers exactly what the caller wants — treat it as success.
268
- *
269
- * Returns null when the supervisor cannot answer (unreachable, or an old
270
- * binary without /restart → 404/401). The caller decides between the flagged
271
- * legacy self-spawn fallback and a loud abort — same contract as brokerSpawn.
272
- */
273
- export async function brokerRequestRestart(reason) {
274
- const res = await brokerFetch(`/restart`, {
275
- method: "POST",
276
- headers: { "Content-Type": "application/json" },
277
- body: JSON.stringify({ reason }),
278
- });
279
- if (!res)
280
- return null;
281
- if (res.status === 202)
282
- return "accepted";
283
- if (res.status === 409)
284
- return "in-progress";
285
- return null; // 404 = old supervisor binary; 401 = misconfigured secret
286
- }
287
- /** Load a thread's persisted keeper counters. Null → broker unreachable OR no
288
- * state saved yet (both mean "start from defaults"). */
289
- export async function brokerGetKeeperState(threadId) {
290
- const res = await brokerFetch(`/proc/keeper?threadId=${threadId}`);
291
- if (!res || !res.ok)
292
- return null;
293
- try {
294
- const body = (await res.json());
295
- return body.found && body.state ? body.state : null;
296
- }
297
- catch {
298
- return null;
299
- }
300
- }
301
- /** Persist a thread's keeper counters (fire-and-forget from the keeper; a lost
302
- * write degrades to today's in-memory behavior, already logged at WARN by the
303
- * unreachable path). */
304
- export async function brokerSaveKeeperState(state) {
305
- await brokerFetch(`/proc/keeper`, {
306
- method: "POST",
307
- headers: { "Content-Type": "application/json" },
308
- body: JSON.stringify(state),
309
- });
310
- }
311
- /** Test hook: reset the unreachable-cooldown state. */
312
- export function resetBrokerClientState() {
313
- unreachableUntil = 0;
314
- unreachableLogged = false;
315
- lastFailureKind = "uncertain";
316
- }
317
- /** Test hook: shrink the spawn liveness backstop so timeout-class tests don't
318
- * wait 30s. Pass null to restore the default. */
319
- let spawnTimeoutOverride = null;
320
- export function brokerSpawnTimeoutForTest(ms) {
321
- spawnTimeoutOverride = ms;
322
- }
323
- //# sourceMappingURL=broker-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"broker-client.js","sourceRoot":"","sources":["../../src/services/broker-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,C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MAAM,WAAW,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;IACnE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,IAAI,CAAC;IACjC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAwD,CAAC;QACvF,OAAO,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;yBAEyB;AACzB,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAwB;IAClE,MAAM,WAAW,CAAC,cAAc,EAAE;QAChC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;KAC5B,CAAC,CAAC;AACL,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,sBAAsB;IACpC,gBAAgB,GAAG,CAAC,CAAC;IACrB,iBAAiB,GAAG,KAAK,CAAC;IAC1B,eAAe,GAAG,WAAW,CAAC;AAChC,CAAC;AAED;kDACkD;AAClD,IAAI,oBAAoB,GAAkB,IAAI,CAAC;AAC/C,MAAM,UAAU,yBAAyB,CAAC,EAAiB;IACzD,oBAAoB,GAAG,EAAE,CAAC;AAC5B,CAAC"}
@@ -1,32 +0,0 @@
1
- /**
2
- * Exit watching for broker-spawned agents (Phase 3).
3
- *
4
- * A locally-spawned child reports its death through `child.on("exit")`; a
5
- * broker-spawned process is the SUPERVISOR's child, so the MCP has no handle to
6
- * wait on. Communication is strictly one-way (MCP → supervisor — hard
7
- * criterion), so the supervisor cannot push the event either. Instead this
8
- * watcher polls: a cheap local `process.kill(pid, 0)` syscall first (no broker
9
- * traffic while the child is alive and no child process ever spawned), then the
10
- * broker for the identity-checked verdict + the exit code its handle-wait
11
- * recorded in the registry.
12
- *
13
- * Degradation: broker unreachable → the local syscall still detects "pid gone"
14
- * (exit code then unknown → null), and a locally-alive pid is treated as alive
15
- * (the audited-safe direction). A watched pid is only resolved ONCE.
16
- */
17
- export interface WatchedSpawn {
18
- pid: number;
19
- threadId: number;
20
- /** Broker-reported creation time (ms) — identity for the alive checks. */
21
- startedAtMs: number;
22
- /** Native creation FILETIME when known — exact identity. */
23
- startTimeTicks?: number;
24
- onExit: (exitCode: number | null) => void;
25
- }
26
- /** Register a broker-spawned pid for exit detection. */
27
- export declare function watchBrokerSpawnExit(entry: WatchedSpawn): void;
28
- /** Test hooks. */
29
- export declare function stopExitWatcher(): void;
30
- export declare function sweepOnceForTest(): Promise<void>;
31
- export declare function watchedCountForTest(): number;
32
- //# sourceMappingURL=spawn-exit-watcher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spawn-exit-watcher.d.ts","sourceRoot":"","sources":["../../src/services/spawn-exit-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3C;AAMD,wDAAwD;AACxD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAM9D;AAyDD,kBAAkB;AAClB,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AACD,wBAAgB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEhD;AACD,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C"}
@@ -1,102 +0,0 @@
1
- /**
2
- * Exit watching for broker-spawned agents (Phase 3).
3
- *
4
- * A locally-spawned child reports its death through `child.on("exit")`; a
5
- * broker-spawned process is the SUPERVISOR's child, so the MCP has no handle to
6
- * wait on. Communication is strictly one-way (MCP → supervisor — hard
7
- * criterion), so the supervisor cannot push the event either. Instead this
8
- * watcher polls: a cheap local `process.kill(pid, 0)` syscall first (no broker
9
- * traffic while the child is alive and no child process ever spawned), then the
10
- * broker for the identity-checked verdict + the exit code its handle-wait
11
- * recorded in the registry.
12
- *
13
- * Degradation: broker unreachable → the local syscall still detects "pid gone"
14
- * (exit code then unknown → null), and a locally-alive pid is treated as alive
15
- * (the audited-safe direction). A watched pid is only resolved ONCE.
16
- */
17
- import { log } from "../lib/logger.js";
18
- import { errorMessage } from "../lib/utils.js";
19
- import { brokerCheckAlive } from "./broker-client.js";
20
- const SWEEP_INTERVAL_MS = 20_000;
21
- const watched = new Map();
22
- let timer = null;
23
- let sweepInFlight = false;
24
- /** Register a broker-spawned pid for exit detection. */
25
- export function watchBrokerSpawnExit(entry) {
26
- watched.set(entry.pid, entry);
27
- if (timer === null) {
28
- timer = setInterval(() => void sweep(), SWEEP_INTERVAL_MS);
29
- timer.unref();
30
- }
31
- }
32
- async function sweep() {
33
- if (sweepInFlight)
34
- return; // a slow broker must not stack sweeps
35
- sweepInFlight = true;
36
- try {
37
- for (const entry of [...watched.values()]) {
38
- try {
39
- await checkOne(entry);
40
- }
41
- catch (err) {
42
- log.warn(`[exit-watch] sweep failed for pid ${entry.pid} (thread ${entry.threadId}): ${errorMessage(err)}`);
43
- }
44
- }
45
- }
46
- finally {
47
- sweepInFlight = false;
48
- if (watched.size === 0 && timer !== null) {
49
- clearInterval(timer);
50
- timer = null;
51
- }
52
- }
53
- }
54
- async function checkOne(entry) {
55
- // 1. Local syscall: ESRCH is a definitive "gone" even with the broker down.
56
- let locallyDead = false;
57
- try {
58
- process.kill(entry.pid, 0);
59
- }
60
- catch (err) {
61
- if (err.code !== "EPERM")
62
- locallyDead = true;
63
- }
64
- // 2. Broker verdict — identity-checked, and carries the recorded exit code.
65
- const verdict = await brokerCheckAlive(entry.pid, entry.startedAtMs, entry.startTimeTicks);
66
- if (verdict !== null) {
67
- if (verdict.alive)
68
- return; // definitely alive (kill(0) can lie on Windows; this can't)
69
- resolveExit(entry, verdict.exitCode ?? null, verdict.registryState ?? undefined);
70
- return;
71
- }
72
- // Broker unreachable: only the local definitive signal may resolve the watch —
73
- // "cannot confirm" must never count as an exit.
74
- if (locallyDead)
75
- resolveExit(entry, null, "broker-unreachable");
76
- }
77
- function resolveExit(entry, exitCode, source) {
78
- if (!watched.delete(entry.pid))
79
- return; // already resolved
80
- log.info(`[exit-watch] broker-spawned PID=${entry.pid} (thread ${entry.threadId}) exited: code ${exitCode ?? "unknown"}${source ? ` (${source})` : ""}`);
81
- try {
82
- entry.onExit(exitCode);
83
- }
84
- catch (err) {
85
- log.warn(`[exit-watch] onExit handler failed for thread ${entry.threadId}: ${errorMessage(err)}`);
86
- }
87
- }
88
- /** Test hooks. */
89
- export function stopExitWatcher() {
90
- if (timer !== null) {
91
- clearInterval(timer);
92
- timer = null;
93
- }
94
- watched.clear();
95
- }
96
- export function sweepOnceForTest() {
97
- return sweep();
98
- }
99
- export function watchedCountForTest() {
100
- return watched.size;
101
- }
102
- //# sourceMappingURL=spawn-exit-watcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spawn-exit-watcher.js","sourceRoot":"","sources":["../../src/services/spawn-exit-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAYjC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;AAChD,IAAI,KAAK,GAA0B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