orcareplay 0.1.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 (109) hide show
  1. package/dist/api.d.ts +127 -0
  2. package/dist/api.d.ts.map +1 -0
  3. package/dist/api.js +159 -0
  4. package/dist/api.js.map +1 -0
  5. package/dist/args.d.ts +24 -0
  6. package/dist/args.d.ts.map +1 -0
  7. package/dist/args.js +124 -0
  8. package/dist/args.js.map +1 -0
  9. package/dist/cli.d.ts +3 -0
  10. package/dist/cli.d.ts.map +1 -0
  11. package/dist/cli.js +4 -0
  12. package/dist/cli.js.map +1 -0
  13. package/dist/commands/compare.d.ts +27 -0
  14. package/dist/commands/compare.d.ts.map +1 -0
  15. package/dist/commands/compare.js +182 -0
  16. package/dist/commands/compare.js.map +1 -0
  17. package/dist/commands/doctor.d.ts +24 -0
  18. package/dist/commands/doctor.d.ts.map +1 -0
  19. package/dist/commands/doctor.js +358 -0
  20. package/dist/commands/doctor.js.map +1 -0
  21. package/dist/commands/gc.d.ts +24 -0
  22. package/dist/commands/gc.d.ts.map +1 -0
  23. package/dist/commands/gc.js +326 -0
  24. package/dist/commands/gc.js.map +1 -0
  25. package/dist/commands/inspect.d.ts +24 -0
  26. package/dist/commands/inspect.d.ts.map +1 -0
  27. package/dist/commands/inspect.js +262 -0
  28. package/dist/commands/inspect.js.map +1 -0
  29. package/dist/commands/record.d.ts +17 -0
  30. package/dist/commands/record.d.ts.map +1 -0
  31. package/dist/commands/record.js +497 -0
  32. package/dist/commands/record.js.map +1 -0
  33. package/dist/commands/replay.d.ts +43 -0
  34. package/dist/commands/replay.d.ts.map +1 -0
  35. package/dist/commands/replay.js +800 -0
  36. package/dist/commands/replay.js.map +1 -0
  37. package/dist/commands/scrub.d.ts +34 -0
  38. package/dist/commands/scrub.d.ts.map +1 -0
  39. package/dist/commands/scrub.js +452 -0
  40. package/dist/commands/scrub.js.map +1 -0
  41. package/dist/commands/setup.d.ts +23 -0
  42. package/dist/commands/setup.d.ts.map +1 -0
  43. package/dist/commands/setup.js +177 -0
  44. package/dist/commands/setup.js.map +1 -0
  45. package/dist/config.d.ts +80 -0
  46. package/dist/config.d.ts.map +1 -0
  47. package/dist/config.js +117 -0
  48. package/dist/config.js.map +1 -0
  49. package/dist/exchange-events.d.ts +72 -0
  50. package/dist/exchange-events.d.ts.map +1 -0
  51. package/dist/exchange-events.js +170 -0
  52. package/dist/exchange-events.js.map +1 -0
  53. package/dist/flags.d.ts +10 -0
  54. package/dist/flags.d.ts.map +1 -0
  55. package/dist/flags.js +83 -0
  56. package/dist/flags.js.map +1 -0
  57. package/dist/fs-events.d.ts +19 -0
  58. package/dist/fs-events.d.ts.map +1 -0
  59. package/dist/fs-events.js +53 -0
  60. package/dist/fs-events.js.map +1 -0
  61. package/dist/index.d.ts +18 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +18 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/main.d.ts +2 -0
  66. package/dist/main.d.ts.map +1 -0
  67. package/dist/main.js +282 -0
  68. package/dist/main.js.map +1 -0
  69. package/dist/mcp-server.d.ts +44 -0
  70. package/dist/mcp-server.d.ts.map +1 -0
  71. package/dist/mcp-server.js +245 -0
  72. package/dist/mcp-server.js.map +1 -0
  73. package/dist/mcp.d.ts +111 -0
  74. package/dist/mcp.d.ts.map +1 -0
  75. package/dist/mcp.js +221 -0
  76. package/dist/mcp.js.map +1 -0
  77. package/dist/out.d.ts +69 -0
  78. package/dist/out.d.ts.map +1 -0
  79. package/dist/out.js +138 -0
  80. package/dist/out.js.map +1 -0
  81. package/dist/rasterize.d.ts +62 -0
  82. package/dist/rasterize.d.ts.map +1 -0
  83. package/dist/rasterize.js +154 -0
  84. package/dist/rasterize.js.map +1 -0
  85. package/dist/serial.d.ts +19 -0
  86. package/dist/serial.d.ts.map +1 -0
  87. package/dist/serial.js +34 -0
  88. package/dist/serial.js.map +1 -0
  89. package/dist/share-card.d.ts +73 -0
  90. package/dist/share-card.d.ts.map +1 -0
  91. package/dist/share-card.js +413 -0
  92. package/dist/share-card.js.map +1 -0
  93. package/dist/snapshot.d.ts +30 -0
  94. package/dist/snapshot.d.ts.map +1 -0
  95. package/dist/snapshot.js +43 -0
  96. package/dist/snapshot.js.map +1 -0
  97. package/dist/tls-capture.d.ts +57 -0
  98. package/dist/tls-capture.d.ts.map +1 -0
  99. package/dist/tls-capture.js +198 -0
  100. package/dist/tls-capture.js.map +1 -0
  101. package/dist/upstream.d.ts +20 -0
  102. package/dist/upstream.d.ts.map +1 -0
  103. package/dist/upstream.js +31 -0
  104. package/dist/upstream.js.map +1 -0
  105. package/dist/version.d.ts +2 -0
  106. package/dist/version.d.ts.map +1 -0
  107. package/dist/version.js +2 -0
  108. package/dist/version.js.map +1 -0
  109. package/package.json +49 -0
@@ -0,0 +1,413 @@
1
+ import { CREDIT_MADE_BY, CREDIT_REPO } from '@orcareplay/viewer';
2
+ const ROW_HEIGHT = 30;
3
+ const HEADER = 120;
4
+ const FOOTER = 46;
5
+ const WIDTH = 720;
6
+ export function renderCompareCard(rows, meta) {
7
+ const height = HEADER + Math.max(1, rows.length) * ROW_HEIGHT + FOOTER;
8
+ const measured = meta.verify
9
+ ? `verdict = exit code of \`${meta.verify}\``
10
+ : 'verdict = the agent’s own exit code';
11
+ const body = rows
12
+ .map((row, i) => {
13
+ const y = HEADER + i * ROW_HEIGHT;
14
+ const failed = row.verdict === 'fail';
15
+ return [
16
+ `<rect x="0" y="${y - 21}" width="${WIDTH}" height="${ROW_HEIGHT}" fill="${i % 2 === 0 ? '#0E1214' : '#0A0D0F'}"/>`,
17
+ text(28, y, row.model, { size: 13, weight: failed ? 600 : 400 }),
18
+ // Verdict reads by form as well as word: the failing row is the one in solid inverse.
19
+ failed
20
+ ? `<rect x="286" y="${y - 14}" width="42" height="18" fill="#E8ECEC"/>` +
21
+ text(291, y, 'FAIL', { size: 10, weight: 600, fill: '#08090A', mono: true })
22
+ : `<rect x="286" y="${y - 14}" width="42" height="18" fill="none" stroke="#374043"/>` +
23
+ text(291, y, 'PASS', { size: 10, fill: '#9AA4A7', mono: true }),
24
+ text(360, y, formatTokens(row.inputTokens + row.outputTokens), {
25
+ size: 12,
26
+ mono: true,
27
+ fill: '#9AA4A7',
28
+ }),
29
+ text(470, y, row.cost === null ? '—' : `$${trimCost(row.cost)}`, { size: 12, mono: true }),
30
+ text(600, y, `${(row.wallMs / 1000).toFixed(0)}s`, {
31
+ size: 12,
32
+ mono: true,
33
+ fill: '#9AA4A7',
34
+ }),
35
+ ].join('');
36
+ })
37
+ .join('');
38
+ const empty = rows.length === 0 ? text(28, HEADER, 'no models compared', { size: 13, fill: '#6B7578' }) : '';
39
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${WIDTH} ${height}" width="${WIDTH}" height="${height}" role="img" aria-label="OrcaReplay model comparison">
40
+ <rect width="${WIDTH}" height="${height}" fill="#08090A"/>
41
+ ${text(28, 40, 'Same task, same state, different model', { size: 17, weight: 600 })}
42
+ ${text(28, 62, `${meta.runId} · forked at checkpoint ${meta.forkPoint}`, { size: 11, mono: true, fill: '#9AA4A7' })}
43
+ ${text(28, 78, measured, { size: 11, mono: true, fill: '#6B7578' })}
44
+ <line x1="0" y1="${HEADER - 24}" x2="${WIDTH}" y2="${HEADER - 24}" stroke="#1F2426"/>
45
+ ${text(28, HEADER - 30, 'MODEL', { size: 9, mono: true, fill: '#6B7578' })}
46
+ ${text(286, HEADER - 30, 'VERDICT', { size: 9, mono: true, fill: '#6B7578' })}
47
+ ${text(360, HEADER - 30, 'TOKENS', { size: 9, mono: true, fill: '#6B7578' })}
48
+ ${text(470, HEADER - 30, 'COST', { size: 9, mono: true, fill: '#6B7578' })}
49
+ ${text(600, HEADER - 30, 'WALL', { size: 9, mono: true, fill: '#6B7578' })}
50
+ ${body}${empty}
51
+ <line x1="0" y1="${height - FOOTER + 14}" x2="${WIDTH}" y2="${height - FOOTER + 14}" stroke="#1F2426"/>
52
+ ${text(28, height - 16, CREDIT_MADE_BY, { size: 10, mono: true, fill: '#6B7578' })}
53
+ ${text(WIDTH - 28, height - 16, CREDIT_REPO, { size: 10, mono: true, fill: '#6B7578', anchor: 'end' })}
54
+ </svg>`;
55
+ }
56
+ const CHAIN_ROW = 30;
57
+ const CHAIN_HEAD = 96;
58
+ const CHAIN_FOOT = 76;
59
+ const RAIL_X = 92;
60
+ /**
61
+ * One causal chain as a self-contained SVG.
62
+ *
63
+ * The timeline answers "what happened"; this answers "what produced this", which is the shape of
64
+ * the thing worth showing someone else. It carries three things a picture that travels without
65
+ * its trace has to carry on its own face: the claim, stated first; the command that reproduces it;
66
+ * and — where any hop was inferred — the fact that it was, because a dashed line nobody explains
67
+ * launders a guess into a fact.
68
+ *
69
+ * Monochrome and dependency-free for the same reason the viewer is: it has to survive being
70
+ * dropped into an issue, a README, a chat window or a dark-mode client with nothing installed.
71
+ */
72
+ export function renderChainCard(graph, meta) {
73
+ const nodes = [...graph.nodes].sort((a, b) => a.seq - b.seq);
74
+ const inferred = graph.edges.filter((e) => e.kind === 'inferred').length;
75
+ const last = nodes[nodes.length - 1];
76
+ const height = CHAIN_HEAD + Math.max(1, nodes.length) * CHAIN_ROW + CHAIN_FOOT;
77
+ if (nodes.length === 0) {
78
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${WIDTH} 120" width="${WIDTH}" height="120" role="img" aria-label="OrcaReplay causal chain">
79
+ <rect width="${WIDTH}" height="120" fill="#0E1214"/>
80
+ ${text(28, 56, 'Nothing to show — this chain has no events', { size: 15, weight: 600 })}
81
+ ${text(28, 92, CREDIT_MADE_BY, { size: 10, mono: true, fill: '#6B7578' })}
82
+ </svg>`;
83
+ }
84
+ // One segment per hop, each drawn as what that hop actually is. A single rail dashed whenever
85
+ // *any* hop was inferred told the reader every hop was a guess — the legend cannot rescue a
86
+ // picture whose own lines overstate what the trace vouches for.
87
+ const kindOf = new Map(graph.edges.map((e) => [`${e.from}→${e.to}`, e.kind]));
88
+ const shown = meta.reveal === undefined ? nodes.length : Math.max(0, meta.reveal);
89
+ const rail = nodes
90
+ .slice(0, Math.max(0, shown - 1))
91
+ .map((node, i) => {
92
+ const next = nodes[i + 1];
93
+ if (!next)
94
+ return '';
95
+ const y = CHAIN_HEAD + i * CHAIN_ROW;
96
+ const kind = kindOf.get(`${node.seq}→${next.seq}`);
97
+ // No edge between these two, so no line. Solid is this card's word for "recorded", and a
98
+ // chain whose nodes are not one path — a diamond, say — would otherwise draw a hop the
99
+ // trace does not contain and state it in the strongest form the card has.
100
+ if (kind === undefined)
101
+ return '';
102
+ return `<line x1="${RAIL_X}" y1="${y + 6}" x2="${RAIL_X}" y2="${y + CHAIN_ROW - 6}" stroke="#5A6669" stroke-width="1.5"${kind === 'inferred' ? ' stroke-dasharray="4 3"' : ''}/>`;
103
+ })
104
+ .join('');
105
+ const rows = nodes
106
+ .slice(0, shown)
107
+ .map((node, i) => {
108
+ const y = CHAIN_HEAD + i * CHAIN_ROW;
109
+ const terminal = node.seq === last?.seq;
110
+ const detail = detailOf(node);
111
+ return [
112
+ `<circle cx="${RAIL_X}" cy="${y}" r="3.5" fill="${terminal ? '#E8ECEC' : '#0E1214'}" stroke="#9AA4A7" stroke-width="1.5"/>`,
113
+ text(30, y + 4, `seq ${node.seq}`, { size: 11, mono: true, fill: '#6E7B7F' }),
114
+ text(110, y + 4, node.type, { size: 12, mono: true }),
115
+ detail === '' ? '' : text(250, y + 4, detail, { size: 11, mono: true, fill: '#9AA4A7' }),
116
+ ].join('');
117
+ })
118
+ .join('');
119
+ const footTop = height - CHAIN_FOOT + 30;
120
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${WIDTH} ${height}" width="${WIDTH}" height="${height}" role="img" aria-label="OrcaReplay causal chain">
121
+ <rect width="${WIDTH}" height="${height}" fill="#0E1214"/>
122
+ ${text(28, 38, headline(last), { size: 16, weight: 600 })}
123
+ ${text(28, 60, `${meta.runId} · causal chain, ${nodes.length} event${nodes.length === 1 ? '' : 's'}`, { size: 11, mono: true, fill: '#9AA4A7' })}
124
+ <line x1="28" y1="76" x2="${WIDTH - 28}" y2="76" stroke="#374043"/>
125
+ ${rail}${rows}
126
+ <line x1="28" y1="${footTop - 18}" x2="${WIDTH - 28}" y2="${footTop - 18}" stroke="#374043"/>
127
+ ${text(28, footTop, `orca graph ${meta.runId} --to ${last?.seq ?? 0}`, { size: 10, mono: true, fill: '#6E7B7F' })}
128
+ ${inferred > 0
129
+ ? text(WIDTH - 28, footTop, 'dashed = inferred, not recorded', {
130
+ size: 10,
131
+ mono: true,
132
+ fill: '#6E7B7F',
133
+ anchor: 'end',
134
+ })
135
+ : ''}
136
+ ${text(28, footTop + 22, CREDIT_MADE_BY, { size: 10, mono: true, fill: '#6B7578' })}
137
+ ${text(WIDTH - 28, footTop + 22, CREDIT_REPO, { size: 10, mono: true, fill: '#6B7578', anchor: 'end' })}
138
+ </svg>`;
139
+ }
140
+ /**
141
+ * The claim, from the event the chain ends at.
142
+ *
143
+ * Stated as what went wrong rather than as an event type, because a card is read by someone who
144
+ * has not seen the run and may never open it.
145
+ */
146
+ function headline(node) {
147
+ if (!node)
148
+ return 'A causal chain';
149
+ const attrs = node.attrs ?? {};
150
+ switch (node.type) {
151
+ case 'shell.result': {
152
+ const code = attrs['exit_code'];
153
+ return typeof code === 'number' && code !== 0
154
+ ? `A command the agent ran exited ${code}`
155
+ : 'A command the agent ran finished';
156
+ }
157
+ case 'tool.result':
158
+ return attrs['is_error'] === true
159
+ ? 'A tool call came back as an error'
160
+ : 'A tool call returned';
161
+ case 'fs.change':
162
+ return `What changed ${String(attrs['path'] ?? 'a file')}`;
163
+ case 'error':
164
+ return 'What led to the error';
165
+ case 'divergence':
166
+ return 'What led to the divergence';
167
+ default:
168
+ return `What produced ${node.type}`;
169
+ }
170
+ }
171
+ /** The one fact worth reading beside the event type. Never more than a line. */
172
+ function detailOf(node) {
173
+ const attrs = node.attrs ?? {};
174
+ switch (node.type) {
175
+ case 'model.response':
176
+ return String(attrs['stop_reason'] ?? '');
177
+ case 'tool.call':
178
+ return String(attrs['name'] ?? '');
179
+ case 'shell.exec': {
180
+ const argv = attrs['argv'];
181
+ if (!Array.isArray(argv))
182
+ return '';
183
+ let longest = '';
184
+ for (const part of argv) {
185
+ if (typeof part === 'string' && part.length > longest.length)
186
+ longest = part;
187
+ }
188
+ return longest.length > 44 ? `${longest.slice(0, 43)}…` : longest;
189
+ }
190
+ case 'shell.result':
191
+ return `exit ${String(attrs['exit_code'] ?? '?')}`;
192
+ case 'fs.change':
193
+ return String(attrs['path'] ?? '');
194
+ case 'tool.result':
195
+ return attrs['is_error'] === true ? 'error' : 'ok';
196
+ default:
197
+ return '';
198
+ }
199
+ }
200
+ function text(x, y, value, options) {
201
+ const family = options.mono
202
+ ? 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace'
203
+ : 'system-ui, -apple-system, Segoe UI, Helvetica, Arial, sans-serif';
204
+ const anchor = options.anchor ? ` text-anchor="${options.anchor}"` : '';
205
+ return `<text x="${x}" y="${y}"${anchor} font-family="${family}" font-size="${options.size}" font-weight="${options.weight ?? 400}" fill="${options.fill ?? '#E8ECEC'}">${escapeXml(value)}</text>`;
206
+ }
207
+ /** Model names come out of a trace, which is someone else's machine. Treat them as untrusted. */
208
+ function escapeXml(value) {
209
+ return value
210
+ .replace(/&/g, '&amp;')
211
+ .replace(/</g, '&lt;')
212
+ .replace(/>/g, '&gt;')
213
+ .replace(/"/g, '&quot;')
214
+ .replace(/'/g, '&apos;');
215
+ }
216
+ function trimCost(amount) {
217
+ if (amount >= 0.01)
218
+ return amount.toFixed(2);
219
+ if (amount >= 0.0001)
220
+ return amount.toFixed(6);
221
+ return amount.toExponential(2);
222
+ }
223
+ function formatTokens(n) {
224
+ return n >= 1000 ? `${Math.round(n / 1000)}k` : String(n);
225
+ }
226
+ /** Which row an event is drawn on. Undefined means it is not part of the loop and is not drawn. */
227
+ function laneOf(type) {
228
+ if (type === 'model.request' || type === 'model.response')
229
+ return 'model';
230
+ if (type.startsWith('tool.') || type.startsWith('mcp.'))
231
+ return 'tool';
232
+ if (type.startsWith('shell.') || type.startsWith('fs.change') || type.startsWith('net.')) {
233
+ return 'effect';
234
+ }
235
+ // `pickChainTarget` can name either of these, so leaving them laneless dropped the very event
236
+ // the card was drawn about. They are outcomes, which is what the effect row holds.
237
+ if (type === 'error' || type === 'divergence')
238
+ return 'effect';
239
+ return undefined;
240
+ }
241
+ const LANE_Y = { model: 118, tool: 194, effect: 270 };
242
+ const NODE_X0 = 116;
243
+ const NODE_STEP = 66;
244
+ const NODE_R = 12;
245
+ const GRAPH_HEIGHT = 360;
246
+ /**
247
+ * The part of a graph worth drawing, narrowed when a whole run would be a hairball.
248
+ *
249
+ * A pane that draws all 400 events of a real run is strictly worse than the list beside it, so
250
+ * past `max` drawable events this keeps only the turns the highlighted chain touches. Narrowing
251
+ * is recorded rather than silent: a picture of part of a run that looks like a picture of the run
252
+ * is the same failure as an inferred edge that looks recorded.
253
+ */
254
+ export function scopeForCard(graph, highlight, max = 18) {
255
+ const drawable = graph.nodes.filter((n) => laneOf(n.type) !== undefined);
256
+ const undrawable = graph.nodes.length - drawable.length;
257
+ let kept = drawable;
258
+ let narrowed = false;
259
+ if (drawable.length > max) {
260
+ const turns = new Set(drawable.filter((n) => highlight.has(n.seq)).map((n) => n.turn));
261
+ // Nothing highlighted to narrow around: keep the most recent turns instead, since that is
262
+ // where a run ends up and the earlier ones are the cheapest to lose.
263
+ const chosen = turns.size > 0 ? turns : new Set(drawable.slice(-max).map((n) => n.turn));
264
+ kept = drawable.filter((n) => chosen.has(n.turn));
265
+ narrowed = kept.length !== drawable.length;
266
+ }
267
+ const seqs = new Set(kept.map((n) => n.seq));
268
+ return {
269
+ nodes: kept,
270
+ // An edge with one end off the picture would point at nothing.
271
+ edges: graph.edges.filter((e) => seqs.has(e.from) && seqs.has(e.to)),
272
+ narrowed,
273
+ omitted: undrawable + (drawable.length - kept.length),
274
+ turns: [...new Set(kept.map((n) => n.turn))].sort((a, b) => a - b),
275
+ };
276
+ }
277
+ /**
278
+ * A whole run as a causal graph: time left to right, kind of thing top to bottom.
279
+ *
280
+ * The chain card follows one path; this shows the shape. Two things only the shape gives you —
281
+ * the run's repeating motif, so anything that breaks it is worth a look, and an event with no edge
282
+ * leaving it, which is an absence a list cannot show at all.
283
+ */
284
+ export function renderGraphCard(graph, meta) {
285
+ const scoped = 'narrowed' in graph ? graph : scopeForCard(graph, meta.highlight, Number.MAX_SAFE_INTEGER);
286
+ // By turn first, then seq. Shell and MCP frames are drained after the agent exits and keep their
287
+ // original turn, so they are not contiguous in seq — laying out by seq alone interleaved two
288
+ // turns and drew their bands on top of each other. Turn is monotonic in time, so this is also
289
+ // the truer left-to-right order for an out-of-band frame.
290
+ const nodes = [...scoped.nodes].sort((a, b) => a.turn - b.turn || a.seq - b.seq);
291
+ if (nodes.length === 0) {
292
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${WIDTH} 120" width="${WIDTH}" height="120" role="img" aria-label="OrcaReplay causal graph">
293
+ <rect width="${WIDTH}" height="120" fill="#0E1214"/>
294
+ ${text(28, 56, 'Nothing to show — this run has no model loop', { size: 15, weight: 600 })}
295
+ ${text(28, 92, CREDIT_MADE_BY, { size: 10, mono: true, fill: '#6B7578' })}
296
+ </svg>`;
297
+ }
298
+ const at = new Map(nodes.map((n, i) => [n.seq, NODE_X0 + i * NODE_STEP]));
299
+ const yOf = (type) => LANE_Y[laneOf(type) ?? 'model'];
300
+ const width = Math.max(WIDTH, NODE_X0 + (nodes.length - 1) * NODE_STEP + 48);
301
+ const bands = scoped.turns
302
+ .map((turn) => {
303
+ const inTurn = nodes.filter((n) => n.turn === turn);
304
+ const first = at.get(inTurn[0]?.seq ?? -1);
305
+ const last = at.get(inTurn[inTurn.length - 1]?.seq ?? -1);
306
+ if (first === undefined || last === undefined)
307
+ return '';
308
+ const x = first - 26;
309
+ const w = last - first + 52;
310
+ return (`<rect x="${x}" y="84" width="${w}" height="216" rx="4" fill="none" stroke="#232A2D" stroke-dasharray="3 3"/>` +
311
+ text(x + w / 2, 76, `TURN ${turn}`, {
312
+ size: 9,
313
+ mono: true,
314
+ fill: '#6E7B7F',
315
+ anchor: 'middle',
316
+ }));
317
+ })
318
+ .join('');
319
+ const edges = scoped.edges
320
+ .map((e) => {
321
+ const x1 = at.get(e.from);
322
+ const x2 = at.get(e.to);
323
+ if (x1 === undefined || x2 === undefined)
324
+ return '';
325
+ const y1 = yOf(nodes.find((n) => n.seq === e.from)?.type ?? '');
326
+ const y2 = yOf(nodes.find((n) => n.seq === e.to)?.type ?? '');
327
+ const lit = meta.highlight.has(e.from) && meta.highlight.has(e.to);
328
+ // Shorten both ends so the line meets the circle rather than running under it.
329
+ const dx = x2 - x1;
330
+ const dy = y2 - y1;
331
+ const len = Math.hypot(dx, dy) || 1;
332
+ const ox = (dx / len) * (NODE_R + 3);
333
+ const oy = (dy / len) * (NODE_R + 3);
334
+ return `<line class="e" x1="${(x1 + ox).toFixed(1)}" y1="${(y1 + oy).toFixed(1)}" x2="${(x2 - ox).toFixed(1)}" y2="${(y2 - oy).toFixed(1)}" stroke="${lit ? '#E8ECEC' : '#4A5457'}" stroke-width="${lit ? 1.8 : 1.3}"${e.kind === 'inferred' ? ' stroke-dasharray="4 3"' : ''}/>`;
335
+ })
336
+ .join('');
337
+ const drawn = nodes
338
+ .map((node) => {
339
+ const x = at.get(node.seq) ?? 0;
340
+ const y = yOf(node.type);
341
+ const lit = meta.highlight.has(node.seq);
342
+ return (`<circle class="n${lit ? ' on' : ''}" cx="${x}" cy="${y}" r="${NODE_R}" fill="${lit ? '#1C2427' : '#0E1214'}" stroke="${lit ? '#E8ECEC' : '#3A4448'}" stroke-width="${lit ? 2 : 1.4}"/>` +
343
+ text(x, y + 3.5, String(node.seq), {
344
+ size: 9.5,
345
+ mono: true,
346
+ fill: lit ? '#E8ECEC' : '#6E7B7F',
347
+ anchor: 'middle',
348
+ }) +
349
+ // Model edges always descend into the tool lane, so a label below the node sits right on
350
+ // the line leaving it. Above for that lane, below for the rest.
351
+ text(x, laneOf(node.type) === 'model' ? y - 20 : y + 26, shortLabel(node), {
352
+ size: 8.5,
353
+ mono: true,
354
+ fill: lit ? '#9AA4A7' : '#5A6669',
355
+ anchor: 'middle',
356
+ }));
357
+ })
358
+ .join('');
359
+ const turnLabel = scoped.turns.length === 1
360
+ ? `turn ${scoped.turns[0]}`
361
+ : `turns ${scoped.turns[0]}–${scoped.turns.at(-1)}`;
362
+ const subtitle = `${meta.runId} · ${turnLabel} · ${nodes.length} events` +
363
+ (scoped.omitted > 0 ? ` · ${scoped.omitted} not shown` : '') +
364
+ (scoped.narrowed ? ' · narrowed' : '');
365
+ const inferred = scoped.edges.filter((e) => e.kind === 'inferred').length;
366
+ const foot = GRAPH_HEIGHT - 34;
367
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${GRAPH_HEIGHT}" width="${width}" height="${GRAPH_HEIGHT}" role="img" aria-label="OrcaReplay causal graph">
368
+ <rect width="${width}" height="${GRAPH_HEIGHT}" fill="#0E1214"/>
369
+ ${text(28, 38, 'What caused what', { size: 16, weight: 600 })}
370
+ ${text(28, 60, subtitle, { size: 11, mono: true, fill: '#9AA4A7' })}
371
+ ${bands}
372
+ ${text(16, LANE_Y.model + 4, 'MODEL', { size: 9, mono: true, fill: '#6E7B7F' })}
373
+ ${text(16, LANE_Y.tool + 4, 'TOOL', { size: 9, mono: true, fill: '#6E7B7F' })}
374
+ ${text(16, LANE_Y.effect + 4, 'EFFECT', { size: 9, mono: true, fill: '#6E7B7F' })}
375
+ ${edges}${drawn}
376
+ <line x1="28" y1="${foot - 22}" x2="${width - 28}" y2="${foot - 22}" stroke="#374043"/>
377
+ ${text(28, foot, CREDIT_MADE_BY, { size: 10, mono: true, fill: '#6B7578' })}
378
+ ${inferred > 0
379
+ ? text(width - 28, foot, 'dashed = inferred, not recorded', {
380
+ size: 10,
381
+ mono: true,
382
+ fill: '#6B7578',
383
+ anchor: 'end',
384
+ })
385
+ : text(width - 28, foot, CREDIT_REPO, { size: 10, mono: true, fill: '#6B7578', anchor: 'end' })}
386
+ </svg>`;
387
+ }
388
+ /** A few characters under a node: enough to tell two of the same type apart. */
389
+ function shortLabel(node) {
390
+ const attrs = node.attrs ?? {};
391
+ const raw = (() => {
392
+ switch (node.type) {
393
+ case 'model.request':
394
+ return 'req';
395
+ case 'model.response':
396
+ return String(attrs['stop_reason'] ?? 'resp');
397
+ case 'tool.call':
398
+ return String(attrs['name'] ?? 'call');
399
+ case 'tool.result':
400
+ return attrs['is_error'] === true ? 'error' : 'result';
401
+ case 'shell.exec':
402
+ return 'exec';
403
+ case 'shell.result':
404
+ return `exit ${String(attrs['exit_code'] ?? '?')}`;
405
+ case 'fs.change':
406
+ return String(attrs['path'] ?? 'file');
407
+ default:
408
+ return node.type.split('.')[1] ?? node.type;
409
+ }
410
+ })();
411
+ return raw.length > 9 ? `${raw.slice(0, 8)}…` : raw;
412
+ }
413
+ //# sourceMappingURL=share-card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-card.js","sourceRoot":"","sources":["../src/share-card.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAuBjE,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,MAAM,GAAG,GAAG,CAAC;AACnB,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,MAAM,KAAK,GAAG,GAAG,CAAC;AAElB,MAAM,UAAU,iBAAiB,CAAC,IAAkB,EAAE,IAAc;IAClE,MAAM,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,UAAU,GAAG,MAAM,CAAC;IACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM;QAC1B,CAAC,CAAC,4BAA4B,IAAI,CAAC,MAAM,IAAI;QAC7C,CAAC,CAAC,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GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACtD,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { FileChange } from '@orcareplay/fs-capture';
2
+ export interface SnapshotResult {
3
+ tree: string;
4
+ changes: FileChange[];
5
+ firstSnapshot?: boolean;
6
+ }
7
+ /** The slice of FsCapture this helper needs, so it can be stubbed in tests. */
8
+ export interface SnapshotSource {
9
+ snapshotTurn(turn: number): Promise<SnapshotResult>;
10
+ }
11
+ export interface RetryOptions {
12
+ attempts?: number;
13
+ delayMs?: number;
14
+ }
15
+ export interface RetryOutcome {
16
+ ok: boolean;
17
+ snapshot?: SnapshotResult;
18
+ attempts: number;
19
+ error?: string;
20
+ }
21
+ /**
22
+ * Snapshot the workspace, retrying the races that come from watching a process that is still
23
+ * writing.
24
+ *
25
+ * Never throws. A lost snapshot costs one checkpoint; an exception here would cost the user the
26
+ * run they were actually trying to record, which is a far worse trade — and the run is the thing
27
+ * that is hard to reproduce.
28
+ */
29
+ export declare function snapshotWithRetry(source: SnapshotSource, turn: number, options?: RetryOptions): Promise<RetryOutcome>;
30
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAeD;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,YAAY,CAAC,CAuBvB"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Transient collisions between the recorder and the agent it is watching.
3
+ *
4
+ * We snapshot a *live* workspace, so git can catch a file mid-write ("short read while indexing")
5
+ * or find the index momentarily locked. Both clear on their own within milliseconds, and neither
6
+ * says anything is wrong with the run.
7
+ */
8
+ const TRANSIENT = [/short read while indexing/i, /index\.lock/i, /unable to create.*\.lock/i];
9
+ function isTransient(message) {
10
+ return TRANSIENT.some((re) => re.test(message));
11
+ }
12
+ /**
13
+ * Snapshot the workspace, retrying the races that come from watching a process that is still
14
+ * writing.
15
+ *
16
+ * Never throws. A lost snapshot costs one checkpoint; an exception here would cost the user the
17
+ * run they were actually trying to record, which is a far worse trade — and the run is the thing
18
+ * that is hard to reproduce.
19
+ */
20
+ export async function snapshotWithRetry(source, turn, options = {}) {
21
+ const maxAttempts = options.attempts ?? 3;
22
+ const delayMs = options.delayMs ?? 25;
23
+ let attempts = 0;
24
+ let lastError = '';
25
+ while (attempts < maxAttempts) {
26
+ attempts += 1;
27
+ try {
28
+ return { ok: true, snapshot: await source.snapshotTurn(turn), attempts };
29
+ }
30
+ catch (err) {
31
+ lastError = err instanceof Error ? err.message : String(err);
32
+ // A permanent failure — no git, not a repository — will not fix itself, and retrying it
33
+ // just makes the agent wait.
34
+ if (!isTransient(lastError))
35
+ break;
36
+ if (attempts < maxAttempts && delayMs > 0) {
37
+ await new Promise((resolve) => setTimeout(resolve, delayMs * attempts));
38
+ }
39
+ }
40
+ }
41
+ return { ok: false, attempts, error: lastError };
42
+ }
43
+ //# sourceMappingURL=snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAyBA;;;;;;GAMG;AACH,MAAM,SAAS,GAAG,CAAC,4BAA4B,EAAE,cAAc,EAAE,2BAA2B,CAAC,CAAC;AAE9F,SAAS,WAAW,CAAC,OAAe;IAClC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAsB,EACtB,IAAY,EACZ,UAAwB,EAAE;IAE1B,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IAEtC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,OAAO,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC9B,QAAQ,IAAI,CAAC,CAAC;QACd,IAAI,CAAC;YACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;QAC3E,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,SAAS,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7D,wFAAwF;YACxF,6BAA6B;YAC7B,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;gBAAE,MAAM;YACnC,IAAI,QAAQ,GAAG,WAAW,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;gBAC1C,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACnD,CAAC"}
@@ -0,0 +1,57 @@
1
+ import type { TraceWriter } from '@orcareplay/core';
2
+ import { RunCa, type NetExchange, type TlsInterceptInfo } from '@orcareplay/proxy';
3
+ import type { ParsedArgs } from './args.js';
4
+ import type { Output } from './out.js';
5
+ import type { SerialQueue } from './serial.js';
6
+ /**
7
+ * TLS interception, shared by every command that runs an agent live.
8
+ *
9
+ * This lived inside `orca record` and nowhere else, which made `--tls-intercept` a flag the parser
10
+ * accepted and `orca replay --model`, `orca fork` and `orca compare` silently discarded — the three
11
+ * commands that also launch a real agent, and so the three where a harness talking to its own
12
+ * backend over TLS is just as invisible. A flag that is accepted and ignored is worse than one that
13
+ * is rejected: the operator believes they captured the traffic.
14
+ *
15
+ * Everything that can be rejected is rejected before anything is minted, so a run that is not going
16
+ * to happen — `--tls-hosts '*'`, an unreadable `ORCA_TLS_UPSTREAM_CA` — leaves no private key on
17
+ * disk at all. The caller owns the CA's lifetime and must dispose it on every exit path.
18
+ */
19
+ export interface TlsCaptureRequest {
20
+ args: ParsedArgs;
21
+ out: Output;
22
+ writer?: TraceWriter;
23
+ /** Used by an exact replay running with --no-trace, where there is no writer to own the CA. */
24
+ runDir?: string;
25
+ writes: SerialQueue;
26
+ /**
27
+ * The turn a frame belongs to, read when the frame is persisted rather than when capture is set
28
+ * up: out-of-band traffic is attributed to whichever turn was in progress at the time, and the
29
+ * caller's turn counter moves under us.
30
+ */
31
+ turn: () => number;
32
+ }
33
+ export interface TlsCapture {
34
+ /** The CA, present only when interception was asked for. The caller disposes it. */
35
+ ca?: RunCa;
36
+ /** Spread into `createProxy()`. Empty when interception was not asked for. */
37
+ proxyOptions: Record<string, unknown>;
38
+ }
39
+ export declare function setupTlsCapture(req: TlsCaptureRequest): Promise<TlsCapture>;
40
+ /**
41
+ * What the launched agent needs in its environment to be intercepted, and the disclosure the
42
+ * operator needs before it happens.
43
+ *
44
+ * Lived in `orca record` alongside the setup, so a fork that minted a CA would have decrypted
45
+ * nothing: the child was never pointed at the proxy and never told to trust the root. Interception
46
+ * is only two halves working together, so both halves belong in one place.
47
+ */
48
+ export declare function trustRunCa(writer: TraceWriter | undefined, proxyTls: TlsInterceptInfo, proxyUrl: string, env: Record<string, string>, out: Output): Promise<void>;
49
+ /**
50
+ * One decrypted HTTP exchange orca did not recognise as a model call.
51
+ *
52
+ * `net.request` / `net.response` have been in the spec since v0 and nothing has ever emitted them;
53
+ * this is what makes them real. The pair is deliberately shaped like `model.request` /
54
+ * `model.response` so the timeline reads the same either way.
55
+ */
56
+ export declare function persistNetExchange(writer: TraceWriter, turn: number, exchange: NetExchange): Promise<void>;
57
+ //# sourceMappingURL=tls-capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tls-capture.d.ts","sourceRoot":"","sources":["../src/tls-capture.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAGL,KAAK,EAEL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAEtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,WAAW,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