agent-run-inspector 0.10.2 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -103,7 +103,7 @@ Inside Orca the address opens as a new Orca browser tab (`orca tab create`). If
103
103
  - **Agent Run Inspector.app** in `~/Applications`, added to the Dock (`--no-dock` to skip): its own window and Launchpad entry, signed in at every launch. It also puts an item in the menu bar (see [The menu bar](#the-menu-bar)). At login the app starts with only the menu bar item, and the window opens from the menu or the Dock. It is built on your Mac with the built-in `osacompile`, so there is nothing to download and no developer signing. If that fails, open the address in Chrome or Edge and choose Install instead.
104
104
  - **A sign-in that lasts a year** for that address, so a bookmark works too. If a browser tab says "Signed out", run `ari open`.
105
105
 
106
- **Updates**: the app checks the latest GitHub release every 6 hours. When there is a newer one and npm already serves it, the menu bar panel shows an "Update to …" button and the right-click menu an "Update to …" item (otherwise "Check for Updates…"); the page header shows an "Update …" badge too, which works the same in the app window. Click one and the app installs the new version and reopens (about a minute; a failed install is tried twice more, 30 seconds apart). If that fails, it shows the commands to run: install the package again and run `ari service install` again, which restarts the service and the app on the new code. `ari service uninstall` removes the service, the app, its Dock icon and its login item. The log is `~/Library/Logs/agent-run-inspector.log`.
106
+ **Updates**: the app checks the latest GitHub release every hour. When there is a newer one and npm already serves it, the menu bar panel shows an "Update to …" button and the right-click menu an "Update to …" item (otherwise "Check for Updates…"); the page header shows an "Update …" badge too, which works the same in the app window. Click one and the app installs the new version and reopens (about a minute; a failed install is tried twice more, 30 seconds apart). If that fails, it shows the commands to run: install the package again and run `ari service install` again, which restarts the service and the app on the new code. `ari service uninstall` removes the service, the app, its Dock icon and its login item. The log is `~/Library/Logs/agent-run-inspector.log`.
107
107
 
108
108
  ### The menu bar
109
109
 
@@ -126,7 +126,7 @@ Run logs can hold customer data and secrets, so nothing leaves your machine exce
126
126
  - The server listens on `127.0.0.1` only.
127
127
  - Each run makes a random token. The first address carries it once, then it becomes an HttpOnly, SameSite=Strict cookie and disappears from the address bar. Requests without the cookie get 401, except the web app manifest and its icons (browsers fetch them without cookies; they hold nothing about your logs). Host and Origin headers are checked.
128
128
  - The service (`ari service install`) instead keeps one token in `~/.config/agent-run-inspector/service.json` (readable by you only), and its cookie lasts a year. The token is never in the LaunchAgent file, the process arguments or the log. `ari service uninstall` deletes it; installing again keeps it.
129
- - Outside requests are update checks only. The CLI asks GitHub (`api.github.com`, the latest release of this project) once a day and prints a line in the terminal if there is a newer version. The Mac app asks the same every 6 hours, and before it offers a newer version it checks that npm (`registry.npmjs.org`) has that version's package. Neither sends anything about you or your logs. Turn the CLI check off with `--no-update-check` or `ARI_NO_UPDATE_CHECK=1` (also off when `CI` or `NO_UPDATE_NOTIFIER` is set). Scripts and icons ship in the package and text uses the system's own fonts: no CDN, web fonts or telemetry.
129
+ - Outside requests are update checks only. The CLI asks GitHub (`api.github.com`, the latest release of this project) once an hour and prints a line in the terminal if there is a newer version. The Mac app asks the same every hour, and before it offers a newer version it checks that npm (`registry.npmjs.org`) has that version's package. Neither sends anything about you or your logs. Turn the CLI check off with `--no-update-check` or `ARI_NO_UPDATE_CHECK=1` (also off when `CI` or `NO_UPDATE_NOTIFIER` is set). Scripts and icons ship in the package and text uses the system's own fonts: no CDN, web fonts or telemetry.
130
130
  - Updates install only when you press Update in the Mac app: it runs `npm i -g agent-run-inspector` (the newest release, not unreleased work) and `ari service install`, and writes what happened to `~/Library/Logs/agent-run-inspector-update.log`.
131
131
  - Found a security problem? See [SECURITY.md](SECURITY.md).
132
132
  - Read-only: log files are never written or deleted. The screen never sends a file path; files are found by opaque ids and must stay inside the known log folders.
package/bin/cli.js CHANGED
@@ -231,7 +231,7 @@ async function main(argv, env) {
231
231
  if (v && !stopping) console.error(MSG.updateAvailable(version, v));
232
232
  }, () => {});
233
233
  check();
234
- if (svc) setInterval(check, 6 * 60 * 60 * 1000).unref(); // a service runs for days; the check itself is cached a day
234
+ setInterval(check, 60 * 60 * 1000).unref(); // a long run (the service, the app) hears of a release within the hour
235
235
  }
236
236
  });
237
237
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-run-inspector",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "Local, read-only inspector for Claude Code and Codex CLI agent runs.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -170,7 +170,7 @@ export class AgentCollector {
170
170
  });
171
171
  }
172
172
  for (const [task, c] of this.orca.tasks) {
173
- out.push(this.#mateSpan(task, c, c.name ?? task, { lookup, now, base, ref: { fileId: this.ctx.fileId, line: c.line }, orca: true }));
173
+ out.push(this.#mateSpan(task, c, c.name ?? c.folder ?? task, { lookup, now, base, ref: { fileId: this.ctx.fileId, line: c.line }, orca: true }));
174
174
  }
175
175
  return out;
176
176
  }
@@ -189,7 +189,7 @@ export class AgentCollector {
189
189
  const end = live ? null : (mate.lastTs ?? c.start);
190
190
  const model = c.model ?? mate.model;
191
191
  return {
192
- ...base, id: externalSpanId(key), name: c.name ?? str(mate.meta?.name) ?? key.split('@')[0], status: live ? 'running' : 'ok',
192
+ ...base, id: externalSpanId(key), name: c.name ?? (orca ? mate.title ?? c.folder ?? str(mate.meta?.name) : undefined) ?? key.split('@')[0], status: live ? 'running' : 'ok',
193
193
  start: c.start, end, ref: { fileId: mate.fileId, line: 1 }, depth: this.ctx.depth + 1, role: 'worker',
194
194
  ...extra, ...(c.task ? { task: c.task } : {}),
195
195
  ...(model ? { model, provider: providerOf(model) } : {}),
@@ -251,7 +251,7 @@ export function buildSessionTree({ main, subagents = [], now }) {
251
251
  const s = new ClaudeCodeSession({ fileId: f.fileId, sessionId: sid, parentId: spanId, depth, now: clock });
252
252
  s.push(f.text);
253
253
  const lastLlm = s.llm.lastModel();
254
- const entry = { agentId: f.agentId, meta, lastTs: s.lastTs, firstTs: s.firstTs, mtime: f.mtime, model: lastLlm, fileId: f.fileId, ...(f.mate ? { mate: true, turnEnded: s.turnEnded, shutDown: s.shutDown } : {}) };
254
+ const entry = { agentId: f.agentId, meta, title: s.title, lastTs: s.lastTs, firstTs: s.firstTs, mtime: f.mtime, model: lastLlm, fileId: f.fileId, ...(f.mate ? { mate: true, turnEnded: s.turnEnded, shutDown: s.shutDown } : {}) };
255
255
  lookup.add(entry);
256
256
  parsed.push({ f, s, entry, spanId, depth });
257
257
  }
@@ -272,7 +272,7 @@ export function buildSessionTree({ main, subagents = [], now }) {
272
272
  else status = isLive(last, clock) ? 'running' : 'unknown';
273
273
  const model = m.model ?? p.entry.model;
274
274
  children.push({
275
- id: p.spanId, parentId: rootId, sessionId: sid, source: 'claude-code', kind: 'agent',
275
+ id: p.spanId, parentId: p.f.parent ? externalSpanId(p.f.parent) : rootId, sessionId: sid, source: 'claude-code', kind: 'agent',
276
276
  name: str(m.name) ?? str(m.agentType) ?? (p.f.mate ? p.f.agentId.split('@')[0] : 'Agent'), status,
277
277
  start: p.entry.firstTs ?? 0, end, ref: { fileId: p.f.fileId, line: 1 }, depth: p.depth, role: 'worker',
278
278
  ...(str(m.agentType) ? { agentType: m.agentType } : {}),
@@ -14,6 +14,7 @@ const WORKER_START = /\borchestration\s+worker-start\b/;
14
14
  const DISPATCHED = /\bdispatchId=(ctx_[0-9a-z]+)(?:\s+taskId=(task_[0-9a-z]+))?(?:[^\n]*?\sworkspace=\S*::(\S+))?/g;
15
15
  const WORKER_PROMPT = 'You are a dispatched worker';
16
16
  const PROMPT_START = 'You are working inside Orca'; // the prompt opens the message; helpers that quote it do not
17
+ const HELPER_START = 'Generate a short git branch name'; // Orca's one-shot helper that names a worker's branch
17
18
  const TASK_LINE = /Your task ID is:\s*(task_[0-9a-z]+)/;
18
19
  const DISPATCH_FLAG = /--dispatch-id\s+(ctx_[0-9a-z]+)/;
19
20
  const flag = (name) => new RegExp(`--${name}\\s+(?:"([^"]+)"|'([^']+)'|(\\S+))`);
@@ -26,12 +27,15 @@ const textOf = (c) => (typeof c === 'string' ? c : Array.isArray(c) ? c.map((b)
26
27
  /** The bot's slug when `cwd` is an Orca bot's home folder, else undefined. */
27
28
  export const botOf = (cwd) => (typeof cwd === 'string' ? BOT_CWD.exec(cwd)?.[1] : undefined);
28
29
 
29
- /** { task, dispatch } when this user record is Orca's dispatch prompt (call it on a file's first user record only). */
30
+ /** { task, dispatch } when this user record is Orca's dispatch prompt (call it on a file's first user record
31
+ * only); with `helper: true` when it is Orca's branch-name helper quoting that prompt. */
30
32
  export function workerOf(rec) {
31
33
  if (rec?.type !== 'user') return undefined;
32
34
  const t = textOf(rec.message?.content).trimStart();
33
- const task = t.startsWith(PROMPT_START) && t.includes(WORKER_PROMPT) ? TASK_LINE.exec(t)?.[1] : undefined;
34
- return task ? { task, dispatch: DISPATCH_FLAG.exec(t)?.[1] } : undefined;
35
+ // the helper quotes a shortened prompt: the task id, not always the worker line or the dispatch id
36
+ const helper = t.startsWith(HELPER_START) && t.includes(PROMPT_START);
37
+ const task = helper || (t.startsWith(PROMPT_START) && t.includes(WORKER_PROMPT)) ? TASK_LINE.exec(t)?.[1] : undefined;
38
+ return task ? { task, dispatch: DISPATCH_FLAG.exec(t)?.[1], ...(helper ? { helper } : {}) } : undefined;
35
39
  }
36
40
 
37
41
  /** Workers a file started: feed records in order; `tasks` maps task id (dispatch id when the result shows
@@ -60,10 +64,10 @@ export class OrcaDispatches {
60
64
  if (!call) continue;
61
65
  // one call can start several workers (a shell loop): each result line names one
62
66
  for (const m of textOf(b.content).matchAll(DISPATCHED)) {
63
- // no --name: the worker's workspace folder names it
67
+ // no --name: the worker's own title names it, else its workspace folder (see agents.js)
64
68
  const folder = m[3]?.split(/[\\/]/).filter(Boolean).at(-1);
65
69
  const key = m[2] ?? m[1];
66
- if (!this.tasks.has(key)) this.tasks.set(key, { ...call, name: call.name ?? folder });
70
+ if (!this.tasks.has(key)) this.tasks.set(key, { ...call, ...(folder ? { folder } : {}) });
67
71
  }
68
72
  }
69
73
  }
@@ -71,6 +75,6 @@ export class OrcaDispatches {
71
75
 
72
76
  /** Raw-byte prefilter for lines worth parsing with OrcaDispatches. */
73
77
  export const DISPATCH_MARKS = [Buffer.from('worker-start'), Buffer.from('dispatchId=ctx_')];
74
- export const WORKER_MARK = Buffer.from(WORKER_PROMPT);
78
+ export const WORKER_MARKS = [Buffer.from(WORKER_PROMPT), Buffer.from(HELPER_START)];
75
79
  /** Worker files are started by Orca, not the claude CLI: their head says so (prefilter for a wider read). */
76
80
  export const WORKER_HEAD_MARKS = ['"entrypoint":"orca"', '"entrypoint":"sdk-cli"'].map((s) => Buffer.from(s));
package/src/index/scan.js CHANGED
@@ -4,7 +4,8 @@
4
4
  import { readdirSync, statSync } from 'node:fs';
5
5
  import { dirname, join } from 'node:path';
6
6
  import { createFileStore } from '../files.js';
7
- import { OrcaDispatches, workerOf, DISPATCH_MARKS, WORKER_MARK, WORKER_HEAD_MARKS } from '../adapters/claude-code/orca.js';
7
+ import { MSG } from '../strings.js';
8
+ import { OrcaDispatches, workerOf, DISPATCH_MARKS, WORKER_MARKS, WORKER_HEAD_MARKS } from '../adapters/claude-code/orca.js';
8
9
 
9
10
  export const HEAD_BYTES = 16 * 1024;
10
11
  export const TAIL_BYTES = 16 * 1024;
@@ -218,7 +219,7 @@ function firstUser(buf) {
218
219
  let r = null;
219
220
  try { r = JSON.parse(line.toString('utf8')); } catch { /* not a record */ }
220
221
  if (r?.type !== 'user') continue;
221
- const w = line.includes(WORKER_MARK) ? workerOf(r) : undefined;
222
+ const w = WORKER_MARKS.some((m) => line.includes(m)) ? workerOf(r) : undefined; // a worker, or Orca's helper for one
222
223
  const t = Date.parse(r.timestamp);
223
224
  // the worker's folder names it when its coordinator's result did not
224
225
  const folder = typeof r.cwd === 'string' ? r.cwd.split(/[\\/]/).filter(Boolean).at(-1) : undefined;
@@ -238,7 +239,7 @@ function workerKey(store, file, cache) {
238
239
  if (WORKER_HEAD_MARKS.some((m) => head.includes(m))) {
239
240
  n = Math.min(file.size, WORKER_SCAN);
240
241
  const buf = n > head.length ? store.readRange(file.fileId, 0, n) : head;
241
- res = buf.includes(WORKER_MARK) ? firstUser(buf) : { found: n >= WORKER_SCAN, key: null };
242
+ res = WORKER_MARKS.some((m) => buf.includes(m)) ? firstUser(buf) : { found: n >= WORKER_SCAN, key: null };
242
243
  }
243
244
  const orca = WORKER_HEAD_MARKS.some((m) => head.includes(m));
244
245
  const settled = res.found || n >= WORKER_SCAN || (!orca && n < file.size);
@@ -298,13 +299,24 @@ function linkOrcaWorkers(list, store, cache) {
298
299
  if (!o || call.start < o.start) owner.set(task, { lead: l, start: call.start });
299
300
  }
300
301
  }
301
- for (const { e, key: { task, dispatch, folder } } of workers) {
302
+ const linked = new Map(); // task and dispatch id -> the linked worker's key
303
+ for (const { e, key: { task, dispatch, folder, helper } } of workers) {
304
+ if (helper) continue;
302
305
  const key = owner.has(task) ? task : dispatch;
303
306
  const o = owner.get(key);
304
307
  if (!o) { rest.push(e); continue; }
305
308
  // the worker's own sub-agents come along (linked to its Agent calls by tool_use id)
306
309
  o.lead.subs.push({ ...e.main, agentId: key, metaFileId: null, mate: true, name: folder }, ...e.subs);
307
310
  o.lead.lastWrite = Math.max(o.lead.lastWrite, e.lastWrite);
311
+ linked.set(task, { o, key }).set(dispatch, { o, key });
312
+ }
313
+ // Orca's branch-name helper (a one-shot run quoting the worker's prompt) goes under that worker's node
314
+ for (const { e, key: { task, helper } } of workers) {
315
+ if (!helper) continue;
316
+ const w = linked.get(task);
317
+ if (!w) { rest.push(e); continue; }
318
+ w.o.lead.subs.push({ ...e.main, agentId: `${w.key}~branch~${e.id}`, metaFileId: null, mate: true, parent: w.key,
319
+ meta: { name: MSG.orcaBranchHelper, finished: true, spawnDepth: 2 } });
308
320
  }
309
321
  return rest;
310
322
  }
@@ -47,6 +47,10 @@ function subFinished(store, sub) {
47
47
 
48
48
  // The record that says whether a Claude Code thread is mid-turn, and whether that turn ended.
49
49
  const turnRec = (tail) => lastOf(tail, (r) => (r.type === 'user' && !isLocalCommand(r)) || r.type === 'assistant' || (r.type === 'system' && r.subtype === 'turn_duration'));
50
+ // One big record (an attachment, a long tool result) after the last turn can fill the whole tail:
51
+ // then look further back. Call it only while the file is recent, so the list stays cheap.
52
+ const lastTurn = (store, fileId, size, tail) => turnRec(tail)
53
+ ?? (size > TAIL_BYTES ? turnRec(readTail(store, fileId, size, TITLE_SCAN_BYTES)) : undefined);
50
54
  const ended = (r) => r?.type === 'system' || (r?.type === 'assistant' && ENDS_TURN.has(r.message?.stop_reason));
51
55
 
52
56
  // Teammates the lead stopped (TaskStop) or heard shut down, from the lead's tail: name -> time.
@@ -63,7 +67,7 @@ function stoppedMates(tail) {
63
67
  // after its last message.
64
68
  function mateDone(store, sub, stopped) {
65
69
  const { tail } = readEnds(store, sub.fileId, sub.size);
66
- const r = turnRec(tail);
70
+ const r = lastTurn(store, sub.fileId, sub.size, tail);
67
71
  if (ended(r)) return true;
68
72
  if (stopped.get(sub.agentId.split('@')[0]) >= (ts(r) ?? Infinity)) return true;
69
73
  let down = false;
@@ -107,8 +111,8 @@ function quickClaude(entry, store, now) {
107
111
  // The main thread's last turn ended (a final answer or system/turn_duration last): it waits for the user.
108
112
  // No turn record at all: done when the tail holds only command records (a file /clear started); otherwise
109
113
  // the tail may just sit inside one huge record, so keep the old reading (not ended).
110
- const lastTurn = turnRec(tail);
111
- const turnEnded = lastTurn ? ended(lastTurn) : tail.some(isLocalCommand);
114
+ const turn = recent(last) ? lastTurn(store, entry.main.fileId, entry.main.size, tail) : turnRec(tail);
115
+ const turnEnded = turn ? ended(turn) : tail.some(isLocalCommand);
112
116
  // ...but a sub-agent or teammate still writing keeps the run going (same rule as the full parse).
113
117
  const stopped = entry.subs.some((s) => s.mate) ? stoppedMates(tail) : new Map();
114
118
  const childRunning = entry.subs.some((s) => recent(s.mtimeMs) && (s.mate ? !mateDone(store, s, stopped) : !subFinished(store, s)));
@@ -207,7 +211,8 @@ export function openEntry(entry, store, now) {
207
211
  if (entry.source === 'claude-code') {
208
212
  const subagents = entry.subs.map((s) => ({
209
213
  fileId: String(s.fileId), agentId: s.agentId, text: readText(store, s.fileId, s.size),
210
- meta: s.name ? { name: s.name } : readMeta(store, s), mtime: s.mtimeMs, ...(s.mate ? { mate: true } : {}),
214
+ meta: s.meta ?? (s.name ? { name: s.name } : readMeta(store, s)), mtime: s.mtimeMs, ...(s.mate ? { mate: true } : {}),
215
+ ...(s.parent ? { parent: s.parent } : {}),
211
216
  }));
212
217
  const snap = buildSessionTree({
213
218
  main: { fileId: String(entry.main.fileId), text: readText(store, entry.main.fileId, entry.main.size) },
package/src/macos/app.js CHANGED
@@ -17,7 +17,7 @@ ObjC.import('WebKit');
17
17
  const REFRESH_S = 10;
18
18
  const RELEASES = 'https://api.github.com/repos/th-yong/agent-run-inspector/releases/latest';
19
19
  const INSTALL = "agent-run-inspector"; // what "Update" installs (npm i -g ...): the latest npm release, never unreleased main
20
- const CHECK_EVERY = (6 * 3600) / REFRESH_S; // ticks between update checks (6 h)
20
+ const CHECK_EVERY = 3600 / REFRESH_S; // ticks between update checks (1 h)
21
21
  const UPDATE_LOG = '~/Library/Logs/agent-run-inspector-update.log';
22
22
  let win = null;
23
23
  let web = null;
package/src/strings.js CHANGED
@@ -17,7 +17,7 @@ Options:
17
17
  --redact[=strict] Hide message bodies (strict: hide more)
18
18
  --prices <file> Price table that overrides the built-in one
19
19
  --session <id> Open this session directly
20
- --no-update-check Do not check npm for a newer version (once a day)
20
+ --no-update-check Do not check npm for a newer version (once an hour)
21
21
  -v, --version Print the version
22
22
  -h, --help Show this help
23
23
 
@@ -42,6 +42,7 @@ export const MSG = {
42
42
  untitledSession: 'Untitled session',
43
43
  toolFailed: 'Tool call failed',
44
44
  agentFailed: 'Agent call failed',
45
+ orcaBranchHelper: 'Branch name',
45
46
  mainAgent: 'Main agent',
46
47
  badPrices: (m) => `Error: ${m}`,
47
48
  unknownCommand: (c) => `Error: unknown command "${c}"`,
@@ -1,4 +1,4 @@
1
- // Once a day, ask GitHub for the latest release of this project (its version number only). Sends nothing but
1
+ // Once an hour, ask GitHub for the latest release of this project (its version number only). Sends nothing but
2
2
  // the request itself; any failure (offline, rate limit, timeout) is silent. Off with --no-update-check, ARI_NO_UPDATE_CHECK,
3
3
  // NO_UPDATE_NOTIFIER or in CI.
4
4
  import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
@@ -6,7 +6,7 @@ import { dirname, join } from 'node:path';
6
6
  import { configPath } from './config.js';
7
7
 
8
8
  export const URL_LATEST = 'https://api.github.com/repos/th-yong/agent-run-inspector/releases/latest';
9
- const DAY_MS = 24 * 60 * 60 * 1000;
9
+ const HOUR_MS = 60 * 60 * 1000;
10
10
 
11
11
  /** True when `latest` is a higher plain x.y.z than `current` (pre-releases are ignored). */
12
12
  export function isNewer(latest, current) {
@@ -30,11 +30,11 @@ export async function checkForUpdate({ version, env = process.env, now = Date.no
30
30
  let cache = {};
31
31
  try { cache = JSON.parse(readFileSync(file, 'utf8')); } catch { /* none yet */ }
32
32
  let latest = typeof cache.latest === 'string' ? cache.latest : null;
33
- if (!(now - cache.checkedAt < DAY_MS)) {
33
+ if (!(now - cache.checkedAt < HOUR_MS)) {
34
34
  try {
35
35
  const res = await fetchImpl(URL_LATEST, { headers: { accept: 'application/vnd.github+json' }, signal: AbortSignal.timeout(3000) });
36
36
  if (res.ok) latest = versionOfTag((await res.json())?.tag_name) ?? latest;
37
- } catch { /* offline: try again tomorrow */ }
37
+ } catch { /* offline: try again in an hour */ }
38
38
  try {
39
39
  mkdirSync(dirname(file), { recursive: true });
40
40
  writeFileSync(file, JSON.stringify({ checkedAt: now, latest }));
package/web/app.js CHANGED
@@ -147,7 +147,7 @@ function renderMain() {
147
147
  const agent = state.gsel ? spans.find((s) => s.id === state.gsel && s.kind === 'agent' && !s.external) : null;
148
148
  view.classList.toggle('with-panel', Boolean(agent));
149
149
  graph.panel.update({ agent, spans, totals: agent ? run.data?.totals?.byAgent?.[agent.id] : null, sessionId: state.s, openId: state.gopen });
150
- graph.graph.update({ spans, selectedId: state.gsel, hide: state.hide, detailOpen: Boolean(agent) });
150
+ graph.graph.update({ spans, totals: run.data?.totals, selectedId: state.gsel, hide: state.hide, detailOpen: Boolean(agent) });
151
151
  return;
152
152
  }
153
153
  const note = run.status === 'loading' ? S.run.loading : run.status === 'missing' ? S.run.notFound : run.status === 'error' ? S.run.loadFailed : S.views[state.tab];
@@ -258,7 +258,7 @@ if (state.mini) {
258
258
  applyTheme();
259
259
  startMini(document.body);
260
260
  } else {
261
- // Version, and a newer one when the server's daily npm check found it (app users never see the terminal).
261
+ // Version, and a newer one when the server's hourly check found it (app users never see the terminal).
262
262
  const showMeta = () => fetchMeta().then((m) => {
263
263
  $('ver').textContent = m.version ? `v${m.version}` : '';
264
264
  const upd = $('upd');
package/web/card.js CHANGED
@@ -25,8 +25,9 @@ export function statusKey(status) {
25
25
  return 'unknown';
26
26
  }
27
27
 
28
- /** Fields the card header and footer show. `calls` are the agent's own llm/tool spans. */
29
- export function cardInfo(agent, calls, now) {
28
+ /** Fields the card header and footer show. `calls` are the agent's own llm/tool spans (old ones may have been
29
+ * dropped in the browser, see trimSpans); `own`, the server's totals for this agent alone, wins for count and cost. */
30
+ export function cardInfo(agent, calls, now, own = null) {
30
31
  const llms = calls.filter((c) => c.kind === 'llm');
31
32
  const real = llms.find((c) => c.model && !c.model.startsWith('<'));
32
33
  const model = agent.model ?? real?.model ?? null;
@@ -40,9 +41,9 @@ export function cardInfo(agent, calls, now) {
40
41
  modelForIcon: model ?? agent.name,
41
42
  status: statusKey(agent.status),
42
43
  task: agent.task ?? '',
43
- usd: priced.length ? priced.reduce((s, c) => s + c.cost.usd, 0) : null,
44
+ usd: own ? (own.priced > 0 ? own.usd : null) : priced.length ? priced.reduce((s, c) => s + c.cost.usd, 0) : null,
44
45
  durationMs: known(agent.start) && end != null ? Math.max(0, end - agent.start) : null,
45
- callCount: calls.length,
46
+ callCount: own ? own.modelCalls + own.toolCalls : calls.length,
46
47
  external: Boolean(agent.external),
47
48
  watcher: agent.role === 'watcher',
48
49
  bot: agent.role === 'bot',
package/web/graph.js CHANGED
@@ -10,6 +10,20 @@ export const FOLD_DELAY_MS = 1600; // a finished agent shows its Done / Failed b
10
10
  const FINISHED = new Set(['ok', 'error', 'cancelled']);
11
11
  const isFinished = (a) => FINISHED.has(a.status) && !a.external;
12
12
 
13
+ /** Each agent's own totals from the server's (which are per subtree): minus its child agents'. The browser may
14
+ * have dropped an old agent's calls (trimSpans), the server totals never do. */
15
+ export function ownTotals(agents, byAgent) {
16
+ const out = new Map();
17
+ if (!byAgent) return out;
18
+ for (const a of agents) if (byAgent[a.id]) out.set(a.id, { ...byAgent[a.id] });
19
+ for (const a of agents) {
20
+ const o = out.get(a.parentId);
21
+ const t = byAgent[a.id];
22
+ if (o && t) for (const k of ['modelCalls', 'toolCalls', 'usd', 'priced']) o[k] -= t[k] ?? 0;
23
+ }
24
+ return out;
25
+ }
26
+
13
27
  /** Agent spans (with callCount = their own llm + tool calls) and each agent's calls in start order. */
14
28
  export function prepareGraph(spans) {
15
29
  const calls = new Map();
@@ -193,6 +207,7 @@ export function createGraph({ onSelect }) {
193
207
  function render() {
194
208
  if (!props || lastWidth <= 0) return;
195
209
  const { agents, calls } = prepareGraph(props.spans);
210
+ const own = ownTotals(agents, props.totals?.byAgent);
196
211
  const selected = props.selectedId && agents.some((a) => a.id === props.selectedId) ? props.selectedId : null;
197
212
  const now = Date.now();
198
213
  const animate = !reduceMotion();
@@ -227,7 +242,7 @@ export function createGraph({ onSelect }) {
227
242
  for (const box of layout.cards) {
228
243
  seen.add(box.id);
229
244
  const agent = byId.get(box.id);
230
- const own = calls.get(box.id) ?? [];
245
+ const mine = calls.get(box.id) ?? [];
231
246
  let c = cards.get(box.id);
232
247
  if (!c) {
233
248
  c = createCard();
@@ -237,8 +252,8 @@ export function createGraph({ onSelect }) {
237
252
  canvas.append(c.root);
238
253
  }
239
254
  updateCard(c, {
240
- info: cardInfo(agent, own, now),
241
- rows: callRows(own, box.shownCalls, box.w < COMPACT_W),
255
+ info: cardInfo(agent, mine, now, own.get(box.id)),
256
+ rows: callRows(mine, box.shownCalls, box.w < COMPACT_W),
242
257
  moreCalls: box.moreCalls,
243
258
  showTask: box.showTask,
244
259
  folded: box.folded,