dsh-remote-vs 0.26.0 → 0.27.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.
Files changed (46) hide show
  1. package/README.en.md +4 -11
  2. package/README.md +4 -8
  3. package/THIRD-PARTY-NOTICES.md +7 -2
  4. package/lib/client.js +6622 -5821
  5. package/lib/index.js +275 -1
  6. package/lib/types/client/CodeEditor.d.ts +14 -0
  7. package/lib/types/client/OutlinePanel.d.ts +22 -0
  8. package/lib/types/client/ProcessesSection.d.ts +19 -0
  9. package/lib/types/client/api.d.ts +5 -1
  10. package/lib/types/client/blame-model.d.ts +77 -0
  11. package/lib/types/client/i18n.d.ts +1 -1
  12. package/lib/types/client/outline-model.d.ts +59 -0
  13. package/lib/types/client/scm/actions.d.ts +12 -1
  14. package/lib/types/client/store.d.ts +18 -0
  15. package/lib/types/client/vsc/blame.d.ts +19 -0
  16. package/lib/types/client/vsc/kit.d.ts +0 -2
  17. package/lib/types/client/vsc/preview-document.d.ts +46 -0
  18. package/lib/types/client/vsc/preview-model.d.ts +31 -0
  19. package/lib/types/client/vsc/preview-services.d.ts +24 -0
  20. package/lib/types/git-ops.d.ts +18 -0
  21. package/lib/types/processes.d.ts +43 -0
  22. package/lib/types/protocol.d.ts +34 -0
  23. package/package.json +2 -1
  24. package/src/client/CodeEditor.tsx +43 -1
  25. package/src/client/EditorPane.tsx +520 -37
  26. package/src/client/MonitorView.tsx +16 -5
  27. package/src/client/OutlinePanel.tsx +287 -0
  28. package/src/client/ProcessesSection.tsx +292 -0
  29. package/src/client/api.ts +8 -0
  30. package/src/client/blame-model.ts +242 -0
  31. package/src/client/i18n.ts +194 -0
  32. package/src/client/index.tsx +4 -0
  33. package/src/client/outline-model.ts +775 -0
  34. package/src/client/scm/HistoryPanel.tsx +38 -1
  35. package/src/client/scm/actions.ts +55 -2
  36. package/src/client/store.tsx +54 -5
  37. package/src/client/vsc/blame.ts +147 -0
  38. package/src/client/vsc/kit.tsx +3 -11
  39. package/src/client/vsc/preview-document.tsx +323 -0
  40. package/src/client/vsc/preview-model.ts +216 -0
  41. package/src/client/vsc/preview-services.ts +118 -0
  42. package/src/client/vsc/vsc.css +6509 -5716
  43. package/src/git-ops.ts +34 -0
  44. package/src/processes.ts +177 -0
  45. package/src/protocol.ts +37 -0
  46. package/src/routes.ts +118 -0
package/src/git-ops.ts CHANGED
@@ -327,6 +327,40 @@ export function fileAtRevCommand(workdir: string, rev: string, path: string): st
327
327
  return capped(`${git(workdir)} show ${shQuote(spec)}`)
328
328
  }
329
329
 
330
+ /**
331
+ * One inclusive line window of `git blame` for a repo-relative file.
332
+ *
333
+ * The window is part of the command (not a post-filter): blame is one of the
334
+ * reads that can be very expensive on a large file, and the editor only ever
335
+ * needs the lines around the viewport. `--line-porcelain` repeats the commit
336
+ * header for every line, so the parser is stateless (see `blame-model.ts`).
337
+ */
338
+ export function blameCommand(workdir: string, path: string, from: number, to: number): string {
339
+ const start = Number.isFinite(from) ? Math.max(1, Math.floor(from)) : 1
340
+ const end = Number.isFinite(to) ? Math.max(start, Math.floor(to)) : start
341
+ return capped(`${git(workdir)} blame --line-porcelain -L ${start},${end} -- ${shQuote(assertRepoPath(path))}`)
342
+ }
343
+
344
+ /**
345
+ * Commits that touched one file, newest first, with rename following.
346
+ *
347
+ * `--follow` works only for a single path; the format matches `parseLog`, so
348
+ * the existing history row type is reused without a second parser.
349
+ */
350
+ export function fileHistoryCommand(workdir: string, path: string, max = 100): string {
351
+ const count = Math.min(Math.max(Number.isFinite(max) ? Math.floor(max) : 100, 1), 200)
352
+ return capped(
353
+ `${git(workdir)} log --follow --name-status -M --pretty=format:'%x00%H%x1f%P%x1f%an%x1f%ae%x1f%at%x1f%D%x1f%s' -n ${count} -- ${shQuote(assertRepoPath(path))}`,
354
+ )
355
+ }
356
+
357
+ /** One commit's header fields, even when it is older than the log window. */
358
+ export function commitMetaCommand(workdir: string, ref: string): string {
359
+ return capped(
360
+ `${git(workdir)} log -1 --pretty=format:'%H%x1f%P%x1f%an%x1f%ae%x1f%at%x1f%D%x1f%s%x1e' ${assertRef(ref)} --`,
361
+ )
362
+ }
363
+
330
364
  /** Local + remote-tracking branches with their upstream and tip. */
331
365
  export function allBranchesCommand(workdir: string): string {
332
366
  return capped(`${git(workdir)} for-each-ref --format='%(refname:short)%x1f%(objectname:short)%x1f%(upstream:short)%x1f%(HEAD)%x1f%(refname)' refs/heads refs/remotes`)
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Remote process snapshots for the monitor page.
3
+ *
4
+ * Same model as `listen-ports.ts`: one bounded POSIX probe (GNU `ps`, a BSD
5
+ * `ps` fallback, then an explicit `none`), with all parsing done host-side so
6
+ * the browser only receives a bounded table. A process is never killed by a
7
+ * command assembled in the browser: the route validates the PID against the
8
+ * latest snapshot and builds the one signal command here.
9
+ */
10
+ import type { RemoteProcess, RemoteProcessesResult } from './protocol.ts'
11
+ import { shQuote } from './git-format.ts'
12
+
13
+ /** Marker proving which probe branch actually ran. */
14
+ export const PROCESSES_MARK = '@@RVS-PROCS'
15
+
16
+ /** Budget for the whole probe; a stuck process table must not pin a channel. */
17
+ export const PROCESSES_TIMEOUT_MS = 15_000
18
+
19
+ /** Hard cap on rows per snapshot (a container host can have thousands). */
20
+ export const PROCESSES_MAX = 500
21
+
22
+ /** Longest command string sent to the browser per row. */
23
+ export const PROCESS_COMMAND_MAX = 300
24
+
25
+ /**
26
+ * One bounded probe.
27
+ *
28
+ * GNU first (`--sort` + `etimes`), then the portable `ps aux` table for BSD /
29
+ * old systems (`ppid` and elapsed time are unknown there). The marker
30
+ * line is printed BEFORE the table so an interrupted probe is distinguishable
31
+ * from a genuinely empty one; the final marker lets the parser reject a
32
+ * truncated run.
33
+ */
34
+ export function processesCommand(max: number = PROCESSES_MAX): string {
35
+ const cap = Math.max(1, Math.min(PROCESSES_MAX, Math.floor(max)))
36
+ // Cap + 1: the parser needs one extra row to tell "exactly at the cap" from
37
+ // "there were more rows, we cut them". The GNU branch is sorted by ps; the
38
+ // aux fallback is sorted here (ps aux on BSD has no --sort) on the %CPU column.
39
+ // `user:20` avoids procps' default 8-character user truncation (the panel's
40
+ // user filter would otherwise silently miss the rest of the name).
41
+ const gnu = `ps -eo pid=,ppid=,user:20=,pcpu=,pmem=,etimes=,args= --sort=-pcpu 2>/dev/null`
42
+ return [
43
+ // EXPORTED: a plain LC_ALL assignment does not reach `ps` itself.
44
+ 'export LC_ALL=C',
45
+ `if ${gnu} >/dev/null 2>&1; then`,
46
+ ` echo "${PROCESSES_MARK} gnu"`,
47
+ ` ${gnu} | head -n ${cap + 1}`,
48
+ 'elif ps aux >/dev/null 2>&1; then',
49
+ ` echo "${PROCESSES_MARK} bsd"`,
50
+ ` ps aux | tail -n +2 | sort -k3 -rn | head -n ${cap + 1}`,
51
+ 'else',
52
+ ` echo "${PROCESSES_MARK} none"`,
53
+ 'fi',
54
+ `echo "${PROCESSES_MARK} end"`,
55
+ ].join('\n')
56
+ }
57
+
58
+ /** A kill signal the route accepts; never an arbitrary string from the client. */
59
+ export type KillSignal = 'TERM' | 'KILL'
60
+
61
+ export function isKillSignal(value: unknown): value is KillSignal {
62
+ return value === 'TERM' || value === 'KILL'
63
+ }
64
+
65
+ /** Assert a PID a process snapshot may contain (1 is the remote init). */
66
+ export function assertProcessPid(value: unknown): number {
67
+ const pid = typeof value === 'number' ? value : Number(value)
68
+ if (!Number.isInteger(pid) || pid <= 1 || pid > 2_147_483_647) throw new Error('invalid process id')
69
+ return pid
70
+ }
71
+
72
+ /**
73
+ * Build the one kill command. The PID has already passed the snapshot check;
74
+ * single-quoting it keeps the command shape uniform with every other builder.
75
+ */
76
+ export function killCommand(pid: number, signal: KillSignal): string {
77
+ return `kill -s ${signal} ${shQuote(String(assertProcessPid(pid)))}`
78
+ }
79
+
80
+ function numberOr(value: string): number | null {
81
+ if (!/^[0-9]+(?:\.[0-9]+)?$/.test(value)) return null
82
+ const number = Number(value)
83
+ return Number.isFinite(number) ? number : null
84
+ }
85
+
86
+ /** Bound one argv line before it is serialized into the JSON response. */
87
+ function trimCommand(command: string): string {
88
+ return command.length <= PROCESS_COMMAND_MAX
89
+ ? command
90
+ : `${command.slice(0, PROCESS_COMMAND_MAX - 1)}…`
91
+ }
92
+
93
+ /** GNU row: pid ppid user pcpu pmem etimes args. */
94
+ function parseGnuRow(line: string): RemoteProcess | undefined {
95
+ const match = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+([0-9.]+)\s+([0-9.]+)\s+(\d+)\s+(.*)$/.exec(line)
96
+ if (match === null) return undefined
97
+ const pid = match[1] as string
98
+ const ppid = match[2] as string
99
+ const user = match[3] as string
100
+ const cpu = match[4] as string
101
+ const mem = match[5] as string
102
+ const elapsed = match[6] as string
103
+ const command = match[7] as string
104
+ return {
105
+ pid: Number(pid),
106
+ ppid: Number(ppid),
107
+ user,
108
+ cpuPercent: numberOr(cpu) ?? 0,
109
+ memPercent: numberOr(mem) ?? 0,
110
+ elapsedSeconds: numberOr(elapsed) ?? null,
111
+ command: trimCommand(command.trim()),
112
+ }
113
+ }
114
+
115
+ /** BSD `ps aux` row: user pid %cpu %mem vsz rss tt stat started time command. */
116
+ function parseBsdRow(line: string): RemoteProcess | undefined {
117
+ const match = /^\s*(\S+)\s+(\d+)\s+([0-9.]+)\s+([0-9.]+)\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)\s+\S+\s+(.*)$/.exec(line)
118
+ if (match === null) return undefined
119
+ const user = match[1] as string
120
+ const pid = match[2] as string
121
+ const cpu = match[3] as string
122
+ const mem = match[4] as string
123
+ const command = match[6] as string
124
+ return {
125
+ pid: Number(pid),
126
+ ppid: 0,
127
+ user,
128
+ cpuPercent: numberOr(cpu) ?? 0,
129
+ memPercent: numberOr(mem) ?? 0,
130
+ elapsedSeconds: null,
131
+ command: trimCommand(command.trim()),
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Parse one probe. `exitCode === null` (channel died) or a missing end marker
137
+ * means `unknown`, never an empty process table.
138
+ */
139
+ export function parseProcesses(stdout: string, exitCode: number | null): RemoteProcessesResult {
140
+ const lines = stdout.split('\n').map(line => line.endsWith('\r') ? line.slice(0, -1) : line)
141
+ const markerAt = lines.findIndex(line => line.trim() === `${PROCESSES_MARK} gnu` || line.trim() === `${PROCESSES_MARK} bsd` || line.trim() === `${PROCESSES_MARK} none`)
142
+ if (exitCode === null || markerAt < 0) {
143
+ return { tool: 'unknown', processes: [], truncated: false, error: 'the remote process probe ended without a complete answer' }
144
+ }
145
+ const marker = lines[markerAt]?.trim() ?? ''
146
+ // The real terminator is the LAST marker line: a process argv containing a
147
+ // literal `@@RVS-PROCS end` must not truncate the table early.
148
+ let endAt = -1
149
+ for (let index = lines.length - 1; index > markerAt; index -= 1) {
150
+ if ((lines[index] as string).trim() === `${PROCESSES_MARK} end`) {
151
+ endAt = index
152
+ break
153
+ }
154
+ }
155
+ if (endAt < 0) {
156
+ return { tool: 'unknown', processes: [], truncated: false, error: 'the remote process probe was interrupted' }
157
+ }
158
+ if (marker.endsWith('none')) return { tool: 'none', processes: [], truncated: false }
159
+ const gnu = marker.endsWith('gnu')
160
+ const parsedProcesses: RemoteProcess[] = []
161
+ for (const line of lines.slice(markerAt + 1, endAt)) {
162
+ if (line.trim() === '') continue
163
+ const row = gnu ? parseGnuRow(line) : parseBsdRow(line)
164
+ // The probe's own shell/head/ps wrappers contain the marker in their argv;
165
+ // they are not user processes and must not be offered for a kill.
166
+ if (row !== undefined && !row.command.includes(PROCESSES_MARK)) parsedProcesses.push(row)
167
+ }
168
+ if (parsedProcesses.length === 0) {
169
+ return { tool: 'unknown', processes: [], truncated: false, error: 'the remote ps output could not be parsed' }
170
+ }
171
+ const truncated = parsedProcesses.length > PROCESSES_MAX
172
+ return {
173
+ tool: gnu ? 'gnu' : 'bsd',
174
+ processes: parsedProcesses.slice(0, PROCESSES_MAX),
175
+ truncated,
176
+ }
177
+ }
package/src/protocol.ts CHANGED
@@ -42,6 +42,8 @@ export const REMOTE_API = {
42
42
  listenPorts: '/api/dsh-remote/listen-ports',
43
43
  /** Live system metrics for the monitor panel (one bounded probe per host). */
44
44
  metrics: '/api/dsh-remote/metrics',
45
+ /** One bounded process table for the monitor page, plus TERM/KILL actions. */
46
+ processes: '/api/dsh-remote/processes',
45
47
  } as const
46
48
 
47
49
  /**
@@ -716,6 +718,41 @@ export interface RemoteListenPortsResult {
716
718
  error?: string
717
719
  }
718
720
 
721
+ /** One row of the remote process table. */
722
+ export interface RemoteProcess {
723
+ pid: number
724
+ /** Parent PID; 0 on a BSD `ps aux` table that does not print it. */
725
+ ppid: number
726
+ user: string
727
+ cpuPercent: number
728
+ memPercent: number
729
+ /** Elapsed seconds when the probe can provide them; null on BSD `ps aux`. */
730
+ elapsedSeconds: number | null
731
+ command: string
732
+ }
733
+
734
+ /**
735
+ * The remote process probe's answer.
736
+ *
737
+ * `tool: 'none' | 'unknown'` means "cannot enumerate", never "no processes";
738
+ * the monitor page must explain that instead of rendering an empty table.
739
+ */
740
+ export interface RemoteProcessesResult {
741
+ tool: 'gnu' | 'bsd' | 'none' | 'unknown'
742
+ processes: RemoteProcess[]
743
+ truncated: boolean
744
+ error?: string
745
+ }
746
+
747
+ /** Result of one TERM/KILL request (the route validates the PID first). */
748
+ export interface RemoteProcessKillResult {
749
+ ok: boolean
750
+ pid: number
751
+ signal: 'TERM' | 'KILL'
752
+ /** Remote error text when the signal was refused. */
753
+ error?: string
754
+ }
755
+
719
756
  /**
720
757
  * How one host metrics sample ended.
721
758
  *
package/src/routes.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  selectionDownloadName,
19
19
  type ExecStreamEvent,
20
20
  type ImportReport,
21
+ type RemoteProcessesResult,
21
22
  type RemoteHostMetrics,
22
23
  type RemoteTimeouts,
23
24
  } from './protocol.ts'
@@ -33,6 +34,7 @@ import { TERMINAL_MAX_FRAME_BYTES, TerminalSessionRegistry } from './terminal.ts
33
34
  import { ForwardManager, validateForwardRequest } from './forward.ts'
34
35
  import { LISTEN_PORTS_TIMEOUT_MS, listenPortsCommand, parseListenPorts } from './listen-ports.ts'
35
36
  import { HostMonitor } from './monitor.ts'
37
+ import { PROCESSES_TIMEOUT_MS, assertProcessPid, isKillSignal, killCommand, parseProcesses, processesCommand } from './processes.ts'
36
38
  import type { SessionChanges } from './changes/recorder.ts'
37
39
  import { DEFAULT_TIMEOUTS, clampExecTimeout } from './timeouts.ts'
38
40
  import { RemoteViewSettingsStore } from './view-settings.ts'
@@ -299,6 +301,49 @@ export function makeRoutes(deps: RemoteRoutesDeps): {
299
301
  // costs one extra sample, so it is safe to construct here instead of owning a
300
302
  // fiber-scoped effect like the forward manager.
301
303
  const monitor = new HostMonitor(pool)
304
+ /**
305
+ * Last process snapshot per alias. The kill route validates against this
306
+ * table, so a browser cannot construct a `kill` for an arbitrary PID; a stale
307
+ * entry is refreshed before validation rather than trusted indefinitely.
308
+ */
309
+ const processSnapshots = new Map<string, { at: number; result: RemoteProcessesResult }>()
310
+ /** One probe per alias at a time; a second reader joins the in-flight one. */
311
+ const processInflight = new Map<string, Promise<RemoteProcessesResult>>()
312
+ const forgetProcesses = (alias: string): void => {
313
+ processSnapshots.delete(alias)
314
+ processInflight.delete(alias)
315
+ }
316
+ const readProcesses = async (alias: string, maxAgeMs: number): Promise<RemoteProcessesResult> => {
317
+ const cached = processSnapshots.get(alias)
318
+ if (maxAgeMs > 0 && cached !== undefined && Date.now() - cached.at < maxAgeMs) return cached.result
319
+ const joined = processInflight.get(alias)
320
+ if (joined !== undefined) return joined
321
+ const task = (async (): Promise<RemoteProcessesResult> => {
322
+ const result = await pool.exec(alias, processesCommand(), { timeoutMs: PROCESSES_TIMEOUT_MS })
323
+ let parsed: RemoteProcessesResult
324
+ if (result.error !== undefined) {
325
+ parsed = { tool: 'unknown', processes: [], truncated: false, error: result.error }
326
+ } else if (result.timedOut) {
327
+ parsed = { tool: 'unknown', processes: [], truncated: false, error: `the process probe did not finish within ${PROCESSES_TIMEOUT_MS / 1000}s` }
328
+ } else if (result.exitCode === null) {
329
+ parsed = { tool: 'unknown', processes: [], truncated: false, error: 'the process probe ended without an exit status' }
330
+ } else {
331
+ parsed = parseProcesses(result.stdout, result.exitCode)
332
+ }
333
+ if (parsed.tool === 'gnu' || parsed.tool === 'bsd') {
334
+ processSnapshots.set(alias, { at: Date.now(), result: parsed })
335
+ } else {
336
+ processSnapshots.delete(alias)
337
+ }
338
+ return parsed
339
+ })()
340
+ processInflight.set(alias, task)
341
+ void task.then(
342
+ () => { if (processInflight.get(alias) === task) processInflight.delete(alias) },
343
+ () => { if (processInflight.get(alias) === task) processInflight.delete(alias) },
344
+ )
345
+ return task
346
+ }
302
347
  const forwards = deps.forwards
303
348
  const viewSettings = deps.viewSettings ?? new RemoteViewSettingsStore()
304
349
 
@@ -509,6 +554,7 @@ export function makeRoutes(deps: RemoteRoutesDeps): {
509
554
  forwards?.stopAlias(alias)
510
555
  pool.forget(alias)
511
556
  monitor.forget(alias)
557
+ forgetProcesses(alias)
512
558
  void worlds.dropHost(alias).catch(() => undefined)
513
559
  if (!store.remove(alias)) {
514
560
  writeJson(res, 404, { error: `unknown host alias: ${alias}` })
@@ -528,6 +574,7 @@ export function makeRoutes(deps: RemoteRoutesDeps): {
528
574
  try {
529
575
  pool.forget(alias)
530
576
  monitor.forget(alias)
577
+ forgetProcesses(alias)
531
578
  void worlds.dropHost(alias).catch(() => undefined)
532
579
  const entry = store.update(alias, body as Partial<HostPayload>)
533
580
  writeJson(res, 200, { host: store.summarize(entry) })
@@ -1632,6 +1679,77 @@ export function makeRoutes(deps: RemoteRoutesDeps): {
1632
1679
  }
1633
1680
  },
1634
1681
  },
1682
+ // -------------------------------------------------- remote processes
1683
+ {
1684
+ kind: 'exact',
1685
+ path: REMOTE_API.processes,
1686
+ handler: async (req, res) => {
1687
+ if (!isLoopbackRequest(req)) {
1688
+ writeJson(res, 403, { error: 'forbidden: loopback-only' })
1689
+ return
1690
+ }
1691
+ const method = req.method ?? 'GET'
1692
+ if (method !== 'GET' && method !== 'POST') {
1693
+ writeJson(res, 405, { error: `method not allowed: ${method}` })
1694
+ return
1695
+ }
1696
+ try {
1697
+ if (method === 'GET') {
1698
+ const url = new URL(req.url ?? '/', 'http://localhost')
1699
+ const alias = queryParam(url, 'alias')
1700
+ if (alias === undefined || alias === '') {
1701
+ writeJson(res, 400, { error: 'alias query parameter is required' })
1702
+ return
1703
+ }
1704
+ if (store.get(alias) === undefined) {
1705
+ writeJson(res, 404, { error: `unknown host alias: ${alias}` })
1706
+ return
1707
+ }
1708
+ writeJson(res, 200, await readProcesses(alias, queryParam(url, 'refresh') === '1' ? 0 : 3_000))
1709
+ return
1710
+ }
1711
+ const read = await readBodyOrError<{ alias?: unknown; pid?: unknown; signal?: unknown }>(req, res, { objectOnly: true })
1712
+ if (!read.ok) return
1713
+ const body = read.body ?? {}
1714
+ const alias = typeof body.alias === 'string' ? body.alias : ''
1715
+ if (alias === '') {
1716
+ writeJson(res, 400, { error: 'alias is required' })
1717
+ return
1718
+ }
1719
+ let pid: number
1720
+ try {
1721
+ pid = assertProcessPid(body.pid)
1722
+ } catch (error) {
1723
+ writeJson(res, 400, { error: error instanceof Error ? error.message : String(error) })
1724
+ return
1725
+ }
1726
+ if (!isKillSignal(body.signal)) {
1727
+ writeJson(res, 400, { error: 'signal must be TERM or KILL' })
1728
+ return
1729
+ }
1730
+ // The snapshot is the authorization list: a PID that is not in the
1731
+ // current remote table cannot be signalled, even if it is numeric.
1732
+ const snapshot = await readProcesses(alias, 0)
1733
+ const target = snapshot.processes.find(process => process.pid === pid)
1734
+ if (target === undefined) {
1735
+ writeJson(res, 400, { error: `process ${pid} is not in the current remote snapshot` })
1736
+ return
1737
+ }
1738
+ const result = await pool.exec(alias, killCommand(pid, body.signal), { timeoutMs: 10_000 })
1739
+ if (result.error !== undefined || result.exitCode !== 0) {
1740
+ const message = result.error ?? result.stderr.trim() ?? ''
1741
+ writeJson(res, 502, { error: message === '' ? `kill failed [exit code: ${result.exitCode ?? '?'}]` : message })
1742
+ return
1743
+ }
1744
+ // The next GET must not serve the pre-kill snapshot.
1745
+ processSnapshots.delete(alias)
1746
+ writeJson(res, 200, { ok: true, pid, signal: body.signal })
1747
+ } catch (error) {
1748
+ if (isStoreError(error)) writeStoreError(res, error)
1749
+ else writeJson(res, 502, { error: error instanceof Error ? error.message : String(error) })
1750
+ }
1751
+ },
1752
+ },
1635
1753
  // ------------------------------------------------------- host metrics
1636
1754
  // Live CPU/RAM/disk/net/temperature for the monitor panel. One bounded
1637
1755
  // POSIX probe per host (no helper, no Python on the remote); `HostMonitor`