@raytrace-cli/cli 0.4.0 → 0.5.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 (102) hide show
  1. package/README.md +132 -126
  2. package/bin/raytrace.mjs +41 -20
  3. package/dist/dashboard/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
  4. package/dist/dashboard/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
  5. package/dist/dashboard/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
  6. package/dist/dashboard/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
  7. package/dist/dashboard/assets/dm-sans-latin-600-normal-Aqo67rzb.woff2 +0 -0
  8. package/dist/dashboard/assets/dm-sans-latin-600-normal-BmdmIIQ2.woff +0 -0
  9. package/dist/dashboard/assets/dm-sans-latin-700-normal-CUSSCpQX.woff +0 -0
  10. package/dist/dashboard/assets/dm-sans-latin-700-normal-DvUfVpUG.woff2 +0 -0
  11. package/dist/dashboard/assets/dm-sans-latin-ext-400-normal-BjWJ59Pq.woff +0 -0
  12. package/dist/dashboard/assets/dm-sans-latin-ext-400-normal-BtiwyxMk.woff2 +0 -0
  13. package/dist/dashboard/assets/dm-sans-latin-ext-500-normal-BJfUCQsA.woff2 +0 -0
  14. package/dist/dashboard/assets/dm-sans-latin-ext-500-normal-DR84L5F-.woff +0 -0
  15. package/dist/dashboard/assets/dm-sans-latin-ext-600-normal-4vooXBpG.woff2 +0 -0
  16. package/dist/dashboard/assets/dm-sans-latin-ext-600-normal-DRtaDpgU.woff +0 -0
  17. package/dist/dashboard/assets/dm-sans-latin-ext-700-normal-BLI3TTWz.woff +0 -0
  18. package/dist/dashboard/assets/dm-sans-latin-ext-700-normal-CJIcxD6K.woff2 +0 -0
  19. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  20. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  21. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  22. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  23. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  24. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  25. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  26. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  27. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  28. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  29. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  30. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  31. package/dist/dashboard/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  32. package/dist/dashboard/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  33. package/dist/dashboard/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  34. package/dist/dashboard/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  35. package/dist/dashboard/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  36. package/dist/dashboard/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  37. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  38. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  39. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  40. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  41. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  42. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  43. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  44. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  45. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  46. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  47. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  48. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  49. package/dist/dashboard/assets/index-DtV3UdEB.css +1 -0
  50. package/dist/dashboard/assets/index-jyV5iYHJ.js +38 -0
  51. package/dist/dashboard/index.html +2 -2
  52. package/package.json +3 -1
  53. package/proxy/call-assessment.mjs +385 -0
  54. package/proxy/call-category.mjs +461 -0
  55. package/proxy/capture.mjs +31 -0
  56. package/proxy/claude-code-adapter.mjs +46 -3
  57. package/proxy/evidence-store.mjs +617 -15
  58. package/proxy/exec-narrative.mjs +625 -0
  59. package/proxy/execution-correlation.mjs +185 -0
  60. package/proxy/experiment-engine.mjs +7 -4
  61. package/proxy/failure-signature.mjs +56 -0
  62. package/proxy/gvisor-forwarder.mjs +454 -0
  63. package/proxy/init-evidence-db.mjs +136 -12
  64. package/proxy/local-sandboxes.mjs +94 -0
  65. package/proxy/playground.mjs +411 -0
  66. package/proxy/prompt-context.mjs +12 -7
  67. package/proxy/prompt-traces.mjs +6 -0
  68. package/proxy/raytace-proxy.mjs +460 -176
  69. package/proxy/run-recap.mjs +139 -0
  70. package/proxy/runtime-attribution.mjs +110 -0
  71. package/proxy/sandbox-bridge.mjs +46 -0
  72. package/proxy/schema/EVIDENCE_DATABASE.md +276 -0
  73. package/proxy/schema/auxiliary.sql +48 -1
  74. package/proxy/schema/classification.sql +89 -0
  75. package/proxy/schema/file_context.sql +53 -0
  76. package/proxy/schema/runtime_evidence.sql +201 -0
  77. package/proxy/schema/search.sql +66 -0
  78. package/proxy/search.mjs +418 -0
  79. package/proxy/step-attribution.mjs +380 -0
  80. package/proxy/tool-metadata.mjs +36 -0
  81. package/proxy/trace-view.mjs +276 -0
  82. package/proxy/typesafe.mjs +63 -0
  83. package/src/commands.mjs +73 -4
  84. package/src/lima.mjs +135 -0
  85. package/src/local-sandbox.mjs +324 -0
  86. package/src/proxy-process.mjs +20 -1
  87. package/src/sandbox.mjs +24 -6
  88. package/worker/sandbox/Dockerfile +8 -0
  89. package/worker/sandbox/SYSCALL_CATALOG.md +197 -0
  90. package/worker/sandbox/claude-hook.mjs +331 -0
  91. package/worker/sandbox/collector.py +357 -0
  92. package/worker/sandbox/dns_forwarder.py +255 -0
  93. package/worker/sandbox/engine.py +940 -0
  94. package/worker/sandbox/file_scan.py +491 -0
  95. package/worker/sandbox/lima.yaml +29 -0
  96. package/worker/sandbox/network.py +90 -0
  97. package/worker/sandbox/projects.py +678 -0
  98. package/worker/sandbox/setup.py +159 -0
  99. package/worker/sandbox/syscall_catalog.sql +985 -0
  100. package/worker/sandbox/viewer.py +132 -0
  101. package/dist/dashboard/assets/index-BQ9_JxGq.js +0 -27
  102. package/dist/dashboard/assets/index-L5cUAvhE.css +0 -1
@@ -0,0 +1,276 @@
1
+ /**
2
+ * The dashboard's trace view: captured exchanges grouped into turns, each
3
+ * with its steps, its evidence, and what the sandbox observed for every tool
4
+ * call. Shared by the local proxy (raytace-proxy.mjs, its SQLite store) and
5
+ * the hosted evidence service (RayTrace's cloud, a Postgres
6
+ * store bound to one org); `db` is either, every call into it awaited.
7
+ */
8
+ import { evidenceFor, outcome, proposedCommand } from './experiment-engine.mjs';
9
+ import { callKind } from './tool-metadata.mjs';
10
+ import { callCategory } from './call-category.mjs';
11
+ import { latestSessionRows, promptAsWritten } from './prompt-traces.mjs';
12
+ import { omitToolChunkIds, toolResultStatus } from './tool-metadata.mjs';
13
+ import { requestMetrics } from './request-metrics.mjs';
14
+ import { describeCommand } from './exec-narrative.mjs';
15
+
16
+ function shortened(value, limit = 104) { const text = typeof value === 'string' ? value : JSON.stringify(value ?? ''); return text.length > limit ? `${text.slice(0, limit - 1)}…` : text; }
17
+ function toolKind(name) { const lower = name.toLowerCase(); return /search|rg|grep/.test(lower) ? 'search' : /read|open|cat|list/.test(lower) ? 'read' : /write|edit|patch|apply/.test(lower) ? 'edit' : 'test'; }
18
+ function event(kind, title, detail, time, raw) { return { kind, title, detail, time, raw: JSON.stringify(raw, null, 2) }; }
19
+ function publicOutput(item) {
20
+ // Reasoning items can contain opaque/private model state. Keep only the
21
+ // configuration and any explicit summary; never present hidden content as a trace.
22
+ if (item?.type === 'reasoning') return { type: 'reasoning', id: item.id, summary: item.summary ?? null, encrypted_content: item.encrypted_content ? '[present]' : undefined };
23
+ return item;
24
+ }
25
+ function extractText(item) {
26
+ const content = item?.content;
27
+ if (typeof content === 'string') return content;
28
+ if (Array.isArray(content)) return content.map((part) => part?.text || part?.content || '').filter(Boolean).join(' ');
29
+ return item?.text || '';
30
+ }
31
+ export function executionFields(real) {
32
+ return {
33
+ exec_id: real?.exec_id ?? null,
34
+ pid: real?.pid ?? null,
35
+ start_time_ns: real?.start_time_ns ?? null,
36
+ argv: Array.isArray(real?.argv) ? real.argv : null,
37
+ started_at: real?.started_at ?? null,
38
+ ended_at: real?.ended_at ?? null,
39
+ exit_code: real?.exit_code ?? null,
40
+ window_start_ms: real?.window_start_ms ?? null,
41
+ window_end_ms: real?.window_end_ms ?? null,
42
+ };
43
+ }
44
+ export function splitExchange(row, replayReason = () => undefined) {
45
+ const request = row.request?.payload || {}; const response = row.response?.payload || {};
46
+ // Preserve the date and UTC offset so each viewer can render their local time.
47
+ const started = new Date(row.timestamp).toISOString(); const completed = new Date(row.completed_at || row.timestamp).toISOString();
48
+ const input = Array.isArray(request.input) ? request.input : Array.isArray(request.messages) ? request.messages : [];
49
+ const output = Array.isArray(response.output) ? response.output : Array.isArray(response.content) ? response.content : [];
50
+ const toolCount = (request.tools || []).length + input.flatMap((item) => item?.tools || []).length;
51
+ // undefined: no replay snapshot held for it; null: replayable.
52
+ const held = replayReason(row.span_id);
53
+ const reason = held === undefined ? 'Capture a fresh request after starting this proxy. Replay snapshots expire after 30 minutes or a restart.' : held;
54
+ let decision = null; try { decision = outcome(response); } catch { /* incomplete capture */ }
55
+ const steps = [event('model', 'Context assembled', `${request.model || 'unknown model'} · ${input.length} input items · ${toolCount} available tools`, started, { exchange_id: row.span_id, model: request.model, stream: request.stream, input_items: input.length, tool_count: toolCount, reasoning: request.reasoning ?? null, replay_reason: reason, decision })];
56
+ for (const item of input) {
57
+ if (!/function_call_output|tool_result/i.test(item?.type || '')) continue;
58
+ const name = item.name || item.tool_name || item.call_id || 'tool';
59
+ steps.push(event(toolKind(name), `Tool result: ${name}`, toolResultStatus(item), started, item));
60
+ }
61
+ for (const [outputIndex, item] of output.entries()) {
62
+ if (item?.type === 'reasoning') {
63
+ const effort = response.reasoning?.effort || request.reasoning?.effort || 'model default';
64
+ steps.push(event('model', 'Reasoning phase', `Effort: ${effort}. Private reasoning content is intentionally not displayed.`, completed, publicOutput(item)));
65
+ continue;
66
+ }
67
+ const name = item?.name || item?.function?.name;
68
+ if (name && /function_call|tool_use|tool_call/i.test(item?.type || '')) {
69
+ const data = item.arguments || item.input || item.function?.arguments || '';
70
+ steps.push({ ...event(toolKind(name), `Tool call: ${name}`, shortened(data), completed, publicOutput(item)), exchange_id: row.span_id, output_index: outputIndex });
71
+ continue;
72
+ }
73
+ if (/message|text/i.test(item?.type || '')) steps.push({ ...event('model', 'Model answer', shortened(extractText(item), 180) || 'Message completed', completed, publicOutput(item)), exchange_id: row.span_id, output_index: outputIndex });
74
+ }
75
+ steps.push(event('model', `Exchange complete · ${row.response?.status || 'unknown'}`, `${row.request?.bytes || 0} B sent · ${row.response?.bytes || 0} B received`, completed, { response_status: response.status ?? null, http_status: row.response?.status ?? null, request_bytes: row.request?.bytes || 0, response_bytes: row.response?.bytes || 0, response_reasoning: response.reasoning ?? null }));
76
+ return steps;
77
+ }
78
+ export async function readTraces(db, { includeHistory = false, evidence = true, replayReason = () => undefined } = {}) {
79
+ const rows = (await db.exchangeRows({ history: includeHistory })).map(omitToolChunkIds);
80
+ // Rows arrive already grouped: each carries its turn as trace_id and the
81
+ // turn's prompt as promptTitle, decided once at capture (evidence-store.mjs).
82
+ const groupedRows = rows;
83
+ // The store already scopes the live view to the newest session; keep the
84
+ // filter so captures made before session tracking behave as they always did.
85
+ const exchangeRows = includeHistory ? groupedRows : (latestSessionRows(groupedRows).length ? latestSessionRows(groupedRows) : groupedRows);
86
+ // A tool call proposed in one captured exchange comes back as evidence (its
87
+ // result) in a later one. Index call_id -> the exchange that first proposed it
88
+ // so the UI can jump from "this evidence" to "the decision that produced it".
89
+ const origins = new Map();
90
+ for (const row of exchangeRows) {
91
+ const output = row.response?.payload?.output;
92
+ if (!Array.isArray(output)) continue;
93
+ for (const [outputIndex, item] of output.entries()) {
94
+ if (item?.call_id && /function_call|tool_use|tool_call/i.test(item?.type || '') && !origins.has(item.call_id)) {
95
+ const args = item.arguments ?? item.input ?? item.function?.arguments ?? '';
96
+ origins.set(item.call_id, { call_id: item.call_id, trace_id: row.trace_id, exchange_id: row.span_id, output_index: outputIndex, name: item.name,
97
+ kind: callKind(item.name),
98
+ // What the call did, for the Tool column; null with its command
99
+ // when only Jev can say (call-category.mjs resolveCategories).
100
+ category: callCategory(item.name, args),
101
+ proposed: proposedCommand(args, item.name) });
102
+ }
103
+ }
104
+ }
105
+ const grouped = new Map();
106
+ const shownResultsByTrace = new Map(); // trace_id -> Set(call_id) already rendered once
107
+ for (const row of exchangeRows) {
108
+ const trace = grouped.get(row.trace_id) || { id: row.trace_id, provider: row.provider, model: row.request?.payload?.model || 'unknown model', title: promptAsWritten(row.promptTitle), promptRaw: row.promptTitle, startedAt: row.timestamp, status: 'complete', events: [], evidence: [], requests: [] };
109
+ const shownResults = shownResultsByTrace.get(row.trace_id) || new Set();
110
+ // rtp- a project's sandbox; rtf- a Playground fork of one (playground.mjs).
111
+ if (/^rt[pf]-[a-f0-9]{32}$/.test(row.session_id || '')) trace.sandboxId = row.session_id;
112
+ if (/^rtf-[a-f0-9]{32}$/.test(row.session_id || '')) trace.forkId = row.session_id;
113
+ shownResultsByTrace.set(row.trace_id, shownResults);
114
+ trace.requests.push({ id: row.span_id, model: row.request?.payload?.model || 'unknown', startedAt: row.timestamp, completedAt: row.completed_at || null, ...(row.metrics || requestMetrics(row)) });
115
+ // Rows are oldest-first, so the last request that produced text is the
116
+ // turn's final answer, and the last completion is when the turn ended.
117
+ trace.endedAt = row.completed_at || row.timestamp;
118
+ try { const text = outcome(row.response?.payload || {}).text; if (text) trace.answer = text; } catch { /* incomplete capture */ }
119
+ trace.events.push(...splitExchange(row, replayReason).map((step) => {
120
+ if (!step.title.startsWith('Tool result:')) return step;
121
+ const raw = JSON.parse(step.raw); const origin = origins.get(raw.call_id);
122
+ // The tool result carries only a call_id and output, never the tool's
123
+ // name — fall back to the exchange that originally proposed the call,
124
+ // where the real name is known, instead of showing the raw id.
125
+ const label = origin?.name ? `Tool result: ${origin.name}` : step.title;
126
+ // The icon was classified from the same fallback name (usually the raw
127
+ // call_id, which never matches any category) — reclassify once the real
128
+ // tool name is known so the icon matches what the tool actually did.
129
+ const kind = origin?.name ? toolKind(origin.name) : step.kind;
130
+ // Clicking a result investigates the earlier decision to call that tool,
131
+ // using its pre-action context rather than its newly returned contents.
132
+ return { ...step, title: label, kind, ...(origin ? { exchange_id: origin.exchange_id, output_index: origin.output_index } : {}) };
133
+ }).filter((step) => {
134
+ if (!step.title.startsWith('Tool result:')) return true;
135
+ // Full conversation history is resent on every turn, so the same result
136
+ // would otherwise appear again in every later request's input — once is
137
+ // enough; the repeats carry no new information.
138
+ const raw = JSON.parse(step.raw);
139
+ if (!raw.call_id || !shownResults.has(raw.call_id)) { if (raw.call_id) shownResults.add(raw.call_id); return true; }
140
+ return false;
141
+ }));
142
+ for (const item of evidence ? evidenceFor(row.request?.payload, row.span_id) : []) {
143
+ const origin = item.call_id ? origins.get(item.call_id) : null;
144
+ trace.evidence.push({ ...item, origin: origin && origin.exchange_id !== row.span_id ? origin : null });
145
+ }
146
+ grouped.set(row.trace_id, trace);
147
+ }
148
+ // Overlay observed sandbox execution (runtime_processes + attributions,
149
+ // via db.divergence) onto each tool-result evidence item, keyed by call_id —
150
+ // the one field both sides share. Falls back to evidenceFor's regex
151
+ // heuristic (succeeded, based on scanning the result text) wherever no
152
+ // process was tied to the call, e.g. a session run outside the sandbox.
153
+ for (const trace of grouped.values()) {
154
+ const spanIds = trace.requests.map((request) => request.id);
155
+ const divergenceRows = (await db.divergence(spanIds)).filter((row) => row.call_id);
156
+ const byCallId = new Map(divergenceRows.map((row) => [row.call_id, row]));
157
+ // Processes that ran underneath each call. divergence() joins on call_id
158
+ // and a descendant's is null by definition, so these need their own query
159
+ // (inherited attributions; see db.descendants in evidence-store.mjs).
160
+ const descendantsByCall = new Map();
161
+ for (const row of await db.descendants(spanIds)) {
162
+ if (!descendantsByCall.has(row.parent_call_id)) descendantsByCall.set(row.parent_call_id, []);
163
+ descendantsByCall.get(row.parent_call_id).push({
164
+ id: row.id, tier: row.tier, pid: row.pid, ppid: row.ppid, start_time_ns: row.start_time_ns ?? null, argv: row.argv,
165
+ status: row.status ?? null, error: row.error ?? null,
166
+ started_at: row.started_at ?? null, ended_at: row.ended_at ?? null,
167
+ });
168
+ }
169
+ trace.evidence = trace.evidence.map((item) => {
170
+ const real = item.call_id ? byCallId.get(item.call_id) : null;
171
+ if (!real) return item;
172
+ // 'not_executed' means no execution row was correlated — this could be
173
+ // a call that genuinely never ran, or one the (deliberately
174
+ // conservative) matcher failed to correlate. Either way, there is no
175
+ // real ground truth to show yet, so this stays "unverified" and keeps
176
+ // the regex-heuristic succeeded value rather than asserting a fact we
177
+ // don't actually have.
178
+ const verified = real.outcome !== 'not_executed';
179
+ return {
180
+ ...item,
181
+ real_outcome: real.outcome,
182
+ real_status: real.status ?? null,
183
+ real_error: real.error ?? null,
184
+ match_score: real.match_score ?? null,
185
+ match_basis: real.match_basis ?? null,
186
+ // Which witness observed it (only 'gvisor' now), and whether the
187
+ // runtime layer saw it start. Both drive the badge.
188
+ source: real.source ?? null,
189
+ kernel_confirmed: real.kernel_confirmed === 1,
190
+ // How this call's execution was attributed, recorded at capture (see
191
+ // migration 005). The UI badges this directly instead of re-deriving
192
+ // confidence from kernel_confirmed + match_basis, which is how a
193
+ // text-similarity guess ended up wearing the same badge as an exact
194
+ // join. Null for rows written before 005.
195
+ tier: real.tier ?? null,
196
+ // The call's own process, so the decision chain can say which pid
197
+ // this call ran as and jump to it in the sandbox tree.
198
+ ...executionFields(real),
199
+ descendants: descendantsByCall.get(item.call_id) ?? [],
200
+ descendant_count: real.descendant_count ?? 0,
201
+ verified,
202
+ // Whether the agent's own report of the result (exit code, wall
203
+ // time) agrees with what the runtime observed. See migration 007.
204
+ reported_check: real.reported_check ?? null,
205
+ // Real ground truth overrides the text-scanning heuristic once we
206
+ // have it -- except while a sandbox command is still 'running'
207
+ // (gVisor has seen it start but not exit yet) or its outcome is
208
+ // 'unknown' (the evidence that would say was lost): asserting success
209
+ // or failure there would be a fact we don't have, so keep the heuristic.
210
+ succeeded: verified && real.status !== 'running' && real.status !== 'unknown' ? real.status === 'completed' : item.succeeded,
211
+ };
212
+ });
213
+
214
+ // Flat, per-call verification list for the graph view: unlike `evidence`
215
+ // above, this isn't limited to calls whose result got resent as later
216
+ // input — it covers every call this trace ever proposed, including one
217
+ // in the very last response with no later request to resend it into.
218
+ // `origins` already has one entry per call_id with the exchange that
219
+ // proposed it, so this is just that, decorated with whatever real
220
+ // execution data (if any) `divergence()` found for the same call_id.
221
+ const traceOrigins = [...origins.values()].filter((origin) => origin.trace_id === trace.id);
222
+ // Where a sandboxed Claude Code's project folder stood after each call.
223
+ const snapshots = await db.snapshotsForCalls(traceOrigins.map((origin) => origin.call_id));
224
+ trace.callVerifications = traceOrigins.map((origin) => {
225
+ const real = byCallId.get(origin.call_id);
226
+ return {
227
+ call_id: origin.call_id,
228
+ exchange_id: origin.exchange_id,
229
+ name: origin.name,
230
+ kind: origin.kind,
231
+ category: origin.category.category,
232
+ category_source: origin.category.source,
233
+ ...(origin.category.command ? { category_command: origin.category.command } : {}),
234
+ verified: real ? real.outcome !== 'not_executed' : false,
235
+ status: real?.status ?? null,
236
+ error: real?.error ?? null,
237
+ match_score: real?.match_score ?? null,
238
+ match_basis: real?.match_basis ?? null,
239
+ source: real?.source ?? null,
240
+ kernel_confirmed: real?.kernel_confirmed === 1,
241
+ tier: real?.tier ?? null,
242
+ reported_check: real?.reported_check ?? null,
243
+ descendant_count: real?.descendant_count ?? 0,
244
+ // Everything the "proposed vs observed" table needs for this row:
245
+ // what the model asked for, and the process that actually ran.
246
+ output_index: origin.output_index,
247
+ proposed: origin.proposed ?? null,
248
+ // The proposed command in plain English, from the same rules Sandbox
249
+ // evidence uses (exec-narrative.mjs). Rule-only here: a model fallback
250
+ // would spend on every trace fetch, and the raw command stays beside it.
251
+ description: origin.kind === 'command' ? describeCommand(origin.proposed) : null,
252
+ ...executionFields(real),
253
+ descendants: descendantsByCall.get(origin.call_id) ?? [],
254
+ snapshot: snapshots.get(origin.call_id) ?? null,
255
+ };
256
+ });
257
+ }
258
+
259
+ // Codex requests include a large tool schema. Return recent traces only so the
260
+ // live dashboard stays responsive instead of repeatedly transferring history.
261
+ const result = [...grouped.values()].sort((a, b) => b.startedAt.localeCompare(a.startedAt)).slice(0, includeHistory ? 100 : 10);
262
+ // Every request resends the whole conversation, so each earlier item comes
263
+ // back once per later request: a long Claude Code session made one prompt
264
+ // tens of MB, fetched every few seconds. An item is sent in full once; a
265
+ // repeat keeps only where it sits and names the item that has the rest
266
+ // (content_of).
267
+ for (const trace of result) {
268
+ const first = new Map();
269
+ trace.evidence = trace.evidence.map((item) => {
270
+ const key = `${item.kind}\0${item.label}\0${item.content ?? item.preview ?? ''}`;
271
+ if (!first.has(key)) { first.set(key, item.id); return item; }
272
+ return { id: item.id, exchange_id: item.exchange_id, index: item.index, kind: item.kind, label: item.label, call_id: item.call_id ?? null, content_of: first.get(key) };
273
+ });
274
+ }
275
+ return result;
276
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Minimal client for TypeSafe's System One endpoint (the Jev models).
3
+ *
4
+ * Jev is a decision model, not a text model: it takes `state` plus named,
5
+ * typed questions (score / choice / noul) and returns calibrated
6
+ * probabilities. It never writes prose, so nothing here expects any.
7
+ *
8
+ * Plain fetch rather than @typesafe-ai/sdk, matching how the proxy reaches
9
+ * every other provider (invokeReplay), and because the SDK does not install
10
+ * cleanly next to this repo's React peer ranges.
11
+ * API: https://docs.typesafe.ai/api
12
+ */
13
+
14
+ const DEFAULT_URL = 'https://api.typesafe.ai';
15
+ const DEFAULT_MODEL = 'jev-latest';
16
+ const TIMEOUT_MS = 15_000;
17
+ const MAX_ATTEMPTS = 3;
18
+ // 429 = rate limited, 529 = overloaded: the two statuses the API documents as
19
+ // safe to retry with backoff. Everything else is a real error.
20
+ const RETRYABLE = new Set([429, 529]);
21
+
22
+ export function typesafeConfig(env = process.env) {
23
+ const apiKey = env.TYPESAFE_API_KEY?.trim() || null;
24
+ return {
25
+ enabled: Boolean(apiKey),
26
+ apiKey,
27
+ model: env.RAYTACE_TYPESAFE_MODEL?.trim() || DEFAULT_MODEL,
28
+ url: (env.RAYTACE_TYPESAFE_URL || DEFAULT_URL).replace(/\/$/, ''),
29
+ };
30
+ }
31
+
32
+ const wait = (ms, signal) => new Promise((resolve, reject) => {
33
+ const timer = setTimeout(resolve, ms);
34
+ signal?.addEventListener('abort', () => { clearTimeout(timer); reject(signal.reason); }, { once: true });
35
+ });
36
+
37
+ /**
38
+ * One System One request. Resolves to `{ model, answers, usage }` exactly as
39
+ * the API returns it; `model` is the concrete version that answered (e.g.
40
+ * jev-1.13.0), which callers should record rather than the alias they sent.
41
+ */
42
+ export async function systemOne(config, { state, questions }, { signal, fetchImpl = fetch } = {}) {
43
+ if (!config?.enabled) throw new Error('Set TYPESAFE_API_KEY to enable Jev.');
44
+ const body = JSON.stringify({ model: config.model, state, questions });
45
+ let lastError;
46
+ for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt += 1) {
47
+ const timeout = AbortSignal.timeout(TIMEOUT_MS);
48
+ const response = await fetchImpl(`${config.url}/v1/systemone`, {
49
+ method: 'POST',
50
+ headers: { authorization: `Bearer ${config.apiKey}`, 'content-type': 'application/json' },
51
+ body,
52
+ signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
53
+ });
54
+ if (response.ok) return response.json();
55
+ const detail = (await response.text().catch(() => '')).slice(0, 300);
56
+ lastError = new Error(`TypeSafe ${response.status}${detail ? `: ${detail}` : ''}`);
57
+ lastError.status = response.status;
58
+ if (!RETRYABLE.has(response.status) || attempt === MAX_ATTEMPTS) break;
59
+ const retryAfter = Number(response.headers.get('retry-after'));
60
+ await wait(Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1000 : 500 * 2 ** (attempt - 1), signal);
61
+ }
62
+ throw lastError;
63
+ }
package/src/commands.mjs CHANGED
@@ -6,7 +6,7 @@ import { paths } from './paths.mjs';
6
6
  import { portOf, proxyEnv, readConfig, writeConfig } from './config.mjs';
7
7
  import { healthy, portInUse, runningPid, start, status, stop } from './proxy-process.mjs';
8
8
  import { HOOK_COMMAND, hookState, setHook } from './claude-code.mjs';
9
- import { confirm, interactive } from './prompt.mjs';
9
+ import { askSecret, confirm, interactive } from './prompt.mjs';
10
10
 
11
11
  const say = (line = '') => console.log(line);
12
12
  const CLOUD_URL = 'https://app.raytracer.si';
@@ -76,7 +76,8 @@ export async function setup(flags) {
76
76
  export async function startCommand({ open = false } = {}) {
77
77
  const result = await start();
78
78
  const url = `http://127.0.0.1:${result.port}`;
79
- say(result.started ? `RayTrace is running: ${url}` : `RayTrace was already running: ${url}`);
79
+ say(result.replaced ? `RayTrace restarted with this version (an older one was running): ${url}`
80
+ : result.started ? `RayTrace is running: ${url}` : `RayTrace was already running: ${url}`);
80
81
  if (!result.started && !result.pid) say(' (started outside this CLI, e.g. from the RayTrace repo; `raytrace stop` will not stop it)');
81
82
  say(` Logs: ${paths.proxyLog}`);
82
83
  if (open) openUrl(url);
@@ -104,6 +105,56 @@ export async function openCommand() {
104
105
  say(`Opening ${state.url}`);
105
106
  }
106
107
 
108
+ // ------------------------------------------------------------------ keys
109
+
110
+ // The keys the dashboard's AI features run on: the user's own, kept in
111
+ // config.env (readable only by them) and used only by the proxy here.
112
+ const KEYS = {
113
+ openrouter: { name: 'OPENROUTER_API_KEY', label: 'OpenRouter', where: 'https://openrouter.ai/keys',
114
+ turnsOn: 'step summaries, command descriptions, run recaps and Chain of thought, and `raytrace codex`',
115
+ models: 'Qwen3 Coder (Chain of thought), gpt-oss-120b (summaries), Claude Sonnet 5.5 (recaps)' },
116
+ typesafe: { name: 'TYPESAFE_API_KEY', label: 'TypeSafe (Jev)', where: 'your TypeSafe account',
117
+ turnsOn: 'ranking Chain of thought\'s causes and rating each command\'s severity' },
118
+ };
119
+ const masked = (value) => (value ? `set (…${value.slice(-4)})` : 'not set');
120
+
121
+ /**
122
+ * `raytrace key` lists the keys; `raytrace key <openrouter|typesafe>` asks for
123
+ * one (typed without echo, or piped in) and saves it; `--remove` deletes it.
124
+ * The key is never taken as an argument, so it stays out of shell history.
125
+ */
126
+ export async function keyCommand(which, flags) {
127
+ const config = readConfig();
128
+ if (!which) {
129
+ for (const [id, key] of Object.entries(KEYS)) say(`${id.padEnd(11)} ${masked(config[key.name])} ${key.turnsOn}`);
130
+ say('\nAdd one: raytrace key openrouter (or typesafe). Remove one: raytrace key openrouter --remove');
131
+ return;
132
+ }
133
+ const key = KEYS[which];
134
+ if (!key) throw new Error(`Unknown key "${which}". Use: raytrace key openrouter | typesafe`);
135
+ let value = '';
136
+ if (!flags.remove) {
137
+ if (interactive()) {
138
+ say(`Your ${key.label} key turns on ${key.turnsOn}. Get one at ${key.where}.`);
139
+ if (key.models) say(`Calls are made on your key and billed to you; models: ${key.models}.`);
140
+ value = await askSecret(`${key.label} key: `);
141
+ } else {
142
+ const chunks = [];
143
+ for await (const chunk of process.stdin) chunks.push(chunk);
144
+ value = Buffer.concat(chunks).toString('utf8').trim();
145
+ }
146
+ if (!value) throw new Error('No key given; nothing changed.');
147
+ if (/\s/.test(value)) throw new Error('That does not look like a key (it has spaces); nothing changed.');
148
+ }
149
+ const next = { ...config, [key.name]: value };
150
+ if (which === 'openrouter') next.RAYTACE_PROVIDER = value ? 'openrouter' : 'native';
151
+ writeConfig(next);
152
+ say(value ? `${key.label} key saved in ${paths.config} (only you can read it).` : `${key.label} key removed.`);
153
+ // A proxy this CLI started is restarted so the key applies.
154
+ if (runningPid()) { await stop(); await start(); say('RayTrace restarted with it.'); }
155
+ else if (await healthy(portOf(readConfig()))) say('A RayTrace proxy started outside this CLI is running; restart it to use this.');
156
+ }
157
+
107
158
  // ------------------------------------------------------------------ doctor
108
159
 
109
160
  export async function doctor() {
@@ -125,7 +176,7 @@ export async function doctor() {
125
176
  line(hooks.installed ? true : null, 'claude code hook', hooks.installed ? `installed in ${hooks.file}` : 'not installed (raytrace setup)');
126
177
  if (hooks.repoHook) line(null, 'repo hook', 'the RayTrace repo\'s hook is also installed; sessions are reported twice');
127
178
 
128
- line(config.OPENROUTER_API_KEY ? true : null, 'openrouter', config.OPENROUTER_API_KEY ? 'key set: summaries and codex on' : 'no key: summaries and codex off');
179
+ line(config.OPENROUTER_API_KEY ? true : null, 'openrouter', config.OPENROUTER_API_KEY ? 'key set: AI features on' : 'no key: AI features off (raytrace key openrouter)');
129
180
 
130
181
  const pid = runningPid();
131
182
  if (await healthy(port)) line(true, 'proxy', `running on :${port}${pid ? ` (pid ${pid})` : ' (started outside this CLI)'}`);
@@ -133,6 +184,17 @@ export async function doctor() {
133
184
  else line(null, 'proxy', `stopped (port ${port} free)`);
134
185
  line(existsSync(paths.database) ? true : null, 'database', existsSync(paths.database) ? `${paths.database} (${(statSync(paths.database).size / 1e6).toFixed(1)} MB)` : 'not created yet; it is made on first start');
135
186
 
187
+ // Local sandboxes are optional: what they lack is shown, not counted as a problem.
188
+ say('\nLocal sandboxes (raytrace sandbox create --local):');
189
+ const { checks } = await import('./lima.mjs');
190
+ const { vmStatus } = await import('./local-sandbox.mjs');
191
+ let vm = null;
192
+ try { vm = vmStatus(); } catch { /* no Lima yet */ }
193
+ const rows = await checks({ vmRunning: vm === 'Running' });
194
+ for (const { ok, label, detail, fix } of rows) say(`${ok === false ? '✗' : ok === null ? '·' : '✓'} ${label.padEnd(22)} ${detail}${fix ? `\n ${''.padEnd(22)} fix: ${fix}` : ''}`);
195
+ if (vm) say(`· ${'vm'.padEnd(22)} raytrace: ${vm.toLowerCase()}`);
196
+ else if (rows.every((row) => row.ok !== false)) say(`· ${'vm'.padEnd(22)} not created yet; the first local sandbox makes it`);
197
+
136
198
  say(problems ? `\n${problems} problem${problems === 1 ? '' : 's'} found.` : '\nNo problems found.');
137
199
  if (problems) process.exitCode = 1;
138
200
  }
@@ -165,7 +227,14 @@ export async function uninstall(flags) {
165
227
  if (hookState().installed) say(`Removed the Claude Code hook from ${setHook({ remove: true })}.`);
166
228
  if (existsSync(paths.home)) {
167
229
  const purge = flags.purge || (!yes && await confirm(`Delete ${paths.home} (recorded sessions and settings)?`, false));
168
- if (purge) { rmSync(paths.home, { recursive: true, force: true }); say(`Deleted ${paths.home}.`); }
230
+ if (purge) {
231
+ // Before the folder goes: the Lima that RayTrace downloaded, which removes the VM, is in it.
232
+ const { deleteVm } = await import('./local-sandbox.mjs');
233
+ try { if (deleteVm()) say('Deleted the local sandbox VM (raytrace) and its sandboxes.'); }
234
+ catch (error) { say(`The local sandbox VM was not deleted (${error.message.split('\n')[0]}); limactl delete --force raytrace removes it.`); }
235
+ rmSync(paths.home, { recursive: true, force: true });
236
+ say(`Deleted ${paths.home}.`);
237
+ }
169
238
  else say(`Kept ${paths.home}.`);
170
239
  }
171
240
  say('To remove the command itself: npm uninstall -g @raytrace/cli');
package/src/lima.mjs ADDED
@@ -0,0 +1,135 @@
1
+ // Lima, which runs the Linux VM local sandboxes live in, and the checks made
2
+ // before one is created (`raytrace sandbox create --local`, `raytrace doctor`).
3
+ //
4
+ // A Lima the user installed is used when it is recent enough. Otherwise
5
+ // RayTrace downloads Lima's own release for this OS and CPU into
6
+ // ~/.raytrace/lima/<version>, after asking: no admin rights, nothing outside
7
+ // that folder. The archive is checked against the checksum pinned here, not
8
+ // one fetched beside it, so a changed release is refused. Lima keeps its VMs
9
+ // in ~/.lima either way.
10
+ //
11
+ // What cannot be downloaded is named with the command that installs it: QEMU
12
+ // on Linux (and on macOS before 13.5) comes from the system's package manager.
13
+ import { spawnSync } from 'node:child_process';
14
+ import { createHash } from 'node:crypto';
15
+ import { accessSync, constants, existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
16
+ import { totalmem } from 'node:os';
17
+ import { join } from 'node:path';
18
+ import { paths } from './paths.mjs';
19
+ import { portInUse } from './proxy-process.mjs';
20
+
21
+ export const LIMA_VERSION = '2.2.1';
22
+ // Lima's release archives for each host, and their SHA-256 from the release's SHA256SUMS.
23
+ const RELEASES = {
24
+ 'darwin-arm64': ['Darwin-arm64', '9e9eacce88f37e185c346bad73aa6136f738d8cdf8c3bb23cd42b071824bc66e'],
25
+ 'darwin-x64': ['Darwin-x86_64', '6b776e4bc41f358e6ee01fefcc78e2eb26f11635a0fcff632234af77a566c6c4'],
26
+ 'linux-arm64': ['Linux-aarch64', 'fbcf4d127936666aa2cf6013b663c250431f2a59394757b404070f8d6a160e10'],
27
+ 'linux-x64': ['Linux-x86_64', 'b391ac7fcac2b2a5a1628107756463188ded4d18d3104a40a66a8bb6fec01bcb'],
28
+ };
29
+ // The oldest Lima of the user's own that is used; an older one is left alone and the managed one used.
30
+ const MINIMUM = [2, 0];
31
+ const MANAGED = join(paths.home, 'lima', LIMA_VERSION);
32
+ const MANAGED_LIMACTL = join(MANAGED, 'bin', 'limactl');
33
+ // What the sandbox VM forwards to this machine: the evidence viewer.
34
+ const VIEWER_PORT = 8798;
35
+
36
+ function version(binary) {
37
+ const result = spawnSync(binary, ['--version'], { encoding: 'utf8' });
38
+ if (result.error || result.status !== 0) return null;
39
+ const match = /(\d+)\.(\d+)\.(\d+)/.exec(result.stdout);
40
+ return match ? match.slice(1).map(Number) : null;
41
+ }
42
+ const atLeast = (have, want) => have[0] > want[0] || (have[0] === want[0] && have[1] >= want[1]);
43
+ const onPath = (name) => !spawnSync(process.platform === 'win32' ? 'where' : 'which', [name], { stdio: 'ignore' }).status;
44
+
45
+ /** The limactl to run, and where it came from; null when there is none yet. */
46
+ export function findLima() {
47
+ const own = version('limactl');
48
+ if (own && atLeast(own, MINIMUM)) return { binary: 'limactl', version: own.join('.'), source: 'installed' };
49
+ if (existsSync(MANAGED_LIMACTL) && version(MANAGED_LIMACTL)) return { binary: MANAGED_LIMACTL, version: LIMA_VERSION, source: 'managed', old: own?.join('.') };
50
+ return own ? { binary: null, old: own.join('.') } : null;
51
+ }
52
+
53
+ export const canDownload = () => Boolean(RELEASES[`${process.platform}-${process.arch}`]);
54
+
55
+ /** Lima's release for this machine, downloaded, checked and unpacked into ~/.raytrace/lima. */
56
+ export async function downloadLima(say) {
57
+ const [name, sha256] = RELEASES[`${process.platform}-${process.arch}`];
58
+ const url = `https://github.com/lima-vm/lima/releases/download/v${LIMA_VERSION}/lima-${LIMA_VERSION}-${name}.tar.gz`;
59
+ say(`Downloading Lima ${LIMA_VERSION} for ${name}...`);
60
+ let response;
61
+ try { response = await fetch(url, { signal: AbortSignal.timeout(300_000) }); } catch (error) {
62
+ throw new Error(`Could not download Lima (${error.message}). Check your connection, or install Lima yourself: https://lima-vm.io/docs/installation/`);
63
+ }
64
+ if (!response.ok) throw new Error(`Could not download Lima: HTTP ${response.status} from ${url}`);
65
+ const archive = Buffer.from(await response.arrayBuffer());
66
+ if (createHash('sha256').update(archive).digest('hex') !== sha256) {
67
+ throw new Error(`The Lima download did not match its pinned checksum, so it was not used. Install Lima yourself: https://lima-vm.io/docs/installation/`);
68
+ }
69
+ // Unpacked beside the final folder and moved over, so a half-unpacked one is never used.
70
+ const staging = `${MANAGED}.partial`;
71
+ rmSync(staging, { recursive: true, force: true });
72
+ mkdirSync(staging, { recursive: true });
73
+ const file = join(staging, 'lima.tar.gz');
74
+ writeFileSync(file, archive);
75
+ const unpacked = spawnSync('tar', ['-xzf', file, '-C', staging], { encoding: 'utf8' });
76
+ if (unpacked.status !== 0) throw new Error(`Could not unpack Lima: ${unpacked.stderr || unpacked.error?.message}`);
77
+ rmSync(file);
78
+ rmSync(MANAGED, { recursive: true, force: true });
79
+ renameSync(staging, MANAGED);
80
+ if (!version(MANAGED_LIMACTL)) throw new Error(`The downloaded Lima does not run on this machine (${MANAGED_LIMACTL}).`);
81
+ say(`Lima ${LIMA_VERSION} is in ${MANAGED}`);
82
+ return { binary: MANAGED_LIMACTL, version: LIMA_VERSION, source: 'managed' };
83
+ }
84
+
85
+ function macVersion() {
86
+ const shown = spawnSync('sw_vers', ['-productVersion'], { encoding: 'utf8' }).stdout?.trim() ?? '';
87
+ return shown.split('.').map(Number);
88
+ }
89
+ const qemu = () => (process.arch === 'arm64' ? 'qemu-system-aarch64' : 'qemu-system-x86_64');
90
+
91
+ /**
92
+ * What stands between this machine and a local sandbox, as rows of
93
+ * {ok: true | false | null (a warning), label, detail, fix?}. Lima itself is
94
+ * reported, not fetched: create offers the download.
95
+ */
96
+ export async function checks({ vmRunning = false } = {}) {
97
+ const rows = [];
98
+ const row = (ok, label, detail, fix) => rows.push({ ok, label, detail, fix });
99
+ const platform = process.platform;
100
+
101
+ if (platform === 'win32') row(null, 'platform', 'Windows: local sandboxes are experimental here (Lima on Windows is)');
102
+ else if (platform !== 'darwin' && platform !== 'linux') row(false, 'platform', `${platform} is not supported for local sandboxes`);
103
+
104
+ const lima = findLima();
105
+ if (lima?.binary) row(true, 'lima', `${lima.version} (${lima.source === 'managed' ? `downloaded by RayTrace, ${MANAGED}` : 'installed'})`);
106
+ else if (canDownload()) {
107
+ row(null, 'lima', `${lima?.old ? `${lima.old} is older than ${MINIMUM.join('.')}` : 'not installed'}; RayTrace downloads Lima ${LIMA_VERSION} on the first \`raytrace sandbox create --local\``);
108
+ } else {
109
+ row(false, 'lima', lima?.old ? `${lima.old} is older than ${MINIMUM.join('.')}` : 'not installed', 'install Lima: https://lima-vm.io/docs/installation/');
110
+ }
111
+
112
+ if (platform === 'darwin') {
113
+ const [major, minor = 0] = macVersion();
114
+ // Lima uses Apple's own virtualization (vz) from macOS 13.5; before that, QEMU.
115
+ if (major > 13 || (major === 13 && minor >= 5)) row(true, 'virtualization', `macOS ${major}.${minor}: Apple Virtualization, nothing to install`);
116
+ else if (onPath(qemu())) row(true, 'virtualization', `macOS ${major}.${minor}: QEMU`);
117
+ else row(false, 'virtualization', `macOS ${major}.${minor} needs QEMU for the VM`, 'brew install qemu');
118
+ } else if (platform === 'linux') {
119
+ row(onPath(qemu()) ? true : false, 'qemu', onPath(qemu()) ? qemu() : `${qemu()} not found`,
120
+ 'install QEMU: sudo apt install qemu-system (Fedora: sudo dnf install qemu-kvm; Arch: sudo pacman -S qemu-full)');
121
+ if (!existsSync('/dev/kvm')) row(null, 'kvm', 'no /dev/kvm: the VM will be very slow (turn on virtualization, or nested virtualization in a VM)');
122
+ else {
123
+ try { accessSync('/dev/kvm', constants.R_OK | constants.W_OK); row(true, 'kvm', '/dev/kvm'); }
124
+ catch { row(false, 'kvm', 'no access to /dev/kvm', 'sudo usermod -aG kvm $USER, then log out and in again'); }
125
+ }
126
+ }
127
+
128
+ // The VM forwards the evidence viewer here; while it runs, the port is its own.
129
+ if (!vmRunning && await portInUse(VIEWER_PORT)) {
130
+ row(false, 'port 8798', 'in use; the evidence viewer needs it', 'stop what holds it (another Lima VM? limactl list)');
131
+ }
132
+ const gib = totalmem() / 1024 ** 3;
133
+ if (gib < 8) row(null, 'memory', `${gib.toFixed(0)} GiB; the VM takes 4 GiB while it runs`);
134
+ return rows;
135
+ }