agent-run-inspector 0.10.4 → 0.10.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-run-inspector",
3
- "version": "0.10.4",
3
+ "version": "0.10.6",
4
4
  "description": "Local, read-only inspector for Claude Code and Codex CLI agent runs.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -1,7 +1,7 @@
1
1
  import { providerOf } from '../../model/provider.js';
2
2
  import { ClaudeCodeSession } from './index.js';
3
3
  import { AGENT_TOOLS } from './tools.js';
4
- import { OrcaDispatches } from './orca.js';
4
+ import { OrcaDispatches, dispatchIdsIn } from './orca.js';
5
5
  import { MSG } from '../../strings.js';
6
6
 
7
7
  const RECENT_MS = 10 * 60 * 1000;
@@ -170,6 +170,9 @@ export class AgentCollector {
170
170
  });
171
171
  }
172
172
  for (const [task, c] of this.orca.tasks) {
173
+ // another id of a worker that has its own card (printed both ways, or the task given out again): no second card
174
+ const found = lookup?.find(undefined, task);
175
+ if (found && found.agentId !== task) continue;
173
176
  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
177
  }
175
178
  return out;
@@ -218,6 +221,7 @@ export class AgentLookup {
218
221
  this.entries.push(entry);
219
222
  if (str(entry.meta?.toolUseId)) this.byToolUse.set(entry.meta.toolUseId, entry);
220
223
  this.byAgent.set(entry.agentId, entry);
224
+ for (const id of entry.aliases ?? []) if (!this.byAgent.has(id)) this.byAgent.set(id, entry);
221
225
  }
222
226
  find(toolUseId, agentId) {
223
227
  return this.byToolUse.get(toolUseId) ?? (agentId ? this.byAgent.get(agentId) : undefined);
@@ -251,7 +255,8 @@ export function buildSessionTree({ main, subagents = [], now }) {
251
255
  const s = new ClaudeCodeSession({ fileId: f.fileId, sessionId: sid, parentId: spanId, depth, now: clock });
252
256
  s.push(f.text);
253
257
  const lastLlm = s.llm.lastModel();
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 } : {}) };
258
+ const aliases = f.aliases ? [...new Set([...f.aliases, ...dispatchIdsIn(f.text)])] : undefined; // an Orca worker's other ids
259
+ const entry = { agentId: f.agentId, ...(aliases ? { aliases } : {}), 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
260
  lookup.add(entry);
256
261
  parsed.push({ f, s, entry, spanId, depth });
257
262
  }
@@ -26,6 +26,17 @@ const textOf = (c) => (typeof c === 'string' ? c : Array.isArray(c) ? c.map((b)
26
26
 
27
27
  /** The bot's slug when `cwd` is an Orca bot's home folder, else undefined. */
28
28
  export const botOf = (cwd) => (typeof cwd === 'string' ? BOT_CWD.exec(cwd)?.[1] : undefined);
29
+ /** The bot's slug from Claude Code's project folder name (`-Users-me--orca-bots-<slug>`), for a file with no cwd. */
30
+ export const botOfProject = (dir) => (typeof dir === 'string' ? /--orca-bots-(.+)$/.exec(dir)?.[1] : undefined);
31
+
32
+ // Orca names each run of a bot with a `custom-title` record (its first line): "Home" for a chat, and its own
33
+ // scheduled runs "Look around" (a short read-only pass that suggests next steps) and "Tidy-up" (memory upkeep).
34
+ const ROUTINES = new Set(['Look around', 'Tidy-up']);
35
+ /** The run's name when it is one of a bot's routine runs, from the file's first records, else undefined. */
36
+ export const routineOf = (head) => {
37
+ const t = head.find((r) => r?.type === 'custom-title')?.customTitle;
38
+ return ROUTINES.has(t) ? t : undefined;
39
+ };
29
40
 
30
41
  /** { task, dispatch } when this user record is Orca's dispatch prompt (call it on a file's first user record
31
42
  * only); with `helper: true` when it is Orca's branch-name helper quoting that prompt. */
@@ -44,6 +55,7 @@ export class OrcaDispatches {
44
55
  constructor() {
45
56
  this.calls = new Map(); // worker-start tool_use id -> { name, start, line }
46
57
  this.tasks = new Map();
58
+ this.seen = new Set(); // every dispatch and task id already keyed: one worker printed both ways is one worker
47
59
  }
48
60
 
49
61
  onAssistant(rec, ts, line) {
@@ -66,13 +78,19 @@ export class OrcaDispatches {
66
78
  for (const m of textOf(b.content).matchAll(DISPATCHED)) {
67
79
  // no --name: the worker's own title names it, else its workspace folder (see agents.js)
68
80
  const folder = m[3]?.split(/[\\/]/).filter(Boolean).at(-1);
69
- const key = m[2] ?? m[1];
70
- if (!this.tasks.has(key)) this.tasks.set(key, { ...call, ...(folder ? { folder } : {}) });
81
+ const ids = m[2] ? [m[1], m[2]] : [m[1]];
82
+ if (ids.some((id) => this.seen.has(id))) { ids.forEach((id) => this.seen.add(id)); continue; }
83
+ ids.forEach((id) => this.seen.add(id));
84
+ this.tasks.set(m[2] ?? m[1], { ...call, ...(folder ? { folder } : {}) });
71
85
  }
72
86
  }
73
87
  }
74
88
  }
75
89
 
90
+ /** Every dispatch id an Orca worker's file was given: the bot can send more work to a running worker. */
91
+ // ponytail: a plain text search; a worker quoting another worker's `--dispatch-id` would take that id too.
92
+ export const dispatchIdsIn = (text) => [...new Set([...text.matchAll(/--dispatch-id\s+(ctx_[0-9a-z]+)/g)].map((m) => m[1]))];
93
+
76
94
  /** Raw-byte prefilter for lines worth parsing with OrcaDispatches. */
77
95
  export const DISPATCH_MARKS = [Buffer.from('worker-start'), Buffer.from('dispatchId=ctx_')];
78
96
  export const WORKER_MARKS = [Buffer.from(WORKER_PROMPT), Buffer.from(HELPER_START)];
package/src/index/scan.js CHANGED
@@ -306,7 +306,9 @@ function linkOrcaWorkers(list, store, cache) {
306
306
  const o = owner.get(key);
307
307
  if (!o) { rest.push(e); continue; }
308
308
  // the worker's own sub-agents come along (linked to its Agent calls by tool_use id)
309
- o.lead.subs.push({ ...e.main, agentId: key, metaFileId: null, mate: true, name: folder }, ...e.subs);
309
+ // its other id (the bot may print the dispatch alone, or give the task out again) finds the same worker
310
+ const aliases = [task, dispatch].filter((id) => id && id !== key);
311
+ o.lead.subs.push({ ...e.main, agentId: key, aliases, metaFileId: null, mate: true, name: folder }, ...e.subs);
310
312
  o.lead.lastWrite = Math.max(o.lead.lastWrite, e.lastWrite);
311
313
  linked.set(task, { o, key }).set(dispatch, { o, key });
312
314
  }
@@ -12,7 +12,13 @@ import { linkCodexAgents } from '../adapters/codex/agents.js';
12
12
  import { AgentCollector, buildSessionTree } from '../adapters/claude-code/agents.js';
13
13
  import { ENDS_TURN, isLocalCommand, shutdownSignal } from '../adapters/claude-code/index.js';
14
14
  import { BackgroundTasks } from '../adapters/claude-code/tools.js';
15
- import { botOf } from '../adapters/claude-code/orca.js';
15
+ import { botOf, botOfProject, routineOf } from '../adapters/claude-code/orca.js';
16
+
17
+ // One of a bot's routine runs (Look around, Tidy-up): named so, and shown quieter in the list.
18
+ const routineFields = (bot, head) => {
19
+ const name = bot ? routineOf(head) : undefined;
20
+ return name ? { title: name, routine: true } : {};
21
+ };
16
22
  import { mapUsage } from '../adapters/codex/llm.js';
17
23
  import { MSG } from '../strings.js';
18
24
 
@@ -124,11 +130,12 @@ function quickClaude(entry, store, now) {
124
130
  for (const r of readTail(store, entry.main.fileId, entry.main.size, TITLE_SCAN_BYTES)) if (r.type === 'assistant') bg.onAssistant(r); else if (r.type === 'user') bg.onUser(r);
125
131
  }
126
132
  const running = (recent(last) && (!turnEnded || bg.open.size > 0)) || childRunning;
127
- const bot = botOf(cwd);
133
+ const bot = botOf(cwd) ?? (cwd ? undefined : botOfProject(entry.project));
128
134
  return base(entry, {
129
135
  ...(title ? { title } : {}),
130
136
  ...(bot ? { bot } : {}),
131
- project: lastSeg(cwd) || entry.project || '',
137
+ ...routineFields(bot, head),
138
+ project: lastSeg(cwd) || bot || entry.project || '',
132
139
  ...(cwd ? { cwd } : {}),
133
140
  ...(branch ? { branch } : {}),
134
141
  start: first ?? entry.main.mtimeMs,
@@ -213,6 +220,7 @@ export function openEntry(entry, store, now) {
213
220
  fileId: String(s.fileId), agentId: s.agentId, text: readText(store, s.fileId, s.size),
214
221
  meta: s.meta ?? (s.name ? { name: s.name } : readMeta(store, s)), mtime: s.mtimeMs, ...(s.mate ? { mate: true } : {}),
215
222
  ...(s.parent ? { parent: s.parent } : {}),
223
+ ...(s.aliases ? { aliases: s.aliases } : {}), // an Orca worker's other ids
216
224
  }));
217
225
  const snap = buildSessionTree({
218
226
  main: { fileId: String(entry.main.fileId), text: readText(store, entry.main.fileId, entry.main.size) },
@@ -250,7 +258,9 @@ export function openEntry(entry, store, now) {
250
258
  const m = root.meta();
251
259
  meta = m ? { cwd: m.cwd, branch: m.branch, project: lastSeg(m.cwd) } : { title: MSG.unknownFormat };
252
260
  }
253
- return { summary: fullSummary(entry, spans, meta), spans, markers, turns };
261
+ const summary = fullSummary(entry, spans, meta);
262
+ if (summary.bot) Object.assign(summary, routineFields(summary.bot, readHead(store, entry.main.fileId, entry.main.size)));
263
+ return { summary, spans, markers, turns };
254
264
  }
255
265
 
256
266
  export function fullSummary(entry, spans, meta) {
@@ -281,11 +291,11 @@ export function fullSummary(entry, spans, meta) {
281
291
  }
282
292
  totals.usd = llmCount > 0 && usdKnown ? usd : null;
283
293
  const title = meta.title;
284
- const bot = entry.source === 'claude-code' ? botOf(meta.cwd) : undefined;
294
+ const bot = entry.source === 'claude-code' ? botOf(meta.cwd) ?? (meta.cwd ? undefined : botOfProject(entry.project)) : undefined;
285
295
  return base(entry, {
286
296
  ...(title ? { title } : {}),
287
297
  ...(bot ? { bot } : {}),
288
- project: meta.project ?? '',
298
+ project: meta.project || bot || '',
289
299
  ...(meta.cwd ? { cwd: meta.cwd } : {}),
290
300
  ...(meta.branch ? { branch: meta.branch } : {}),
291
301
  start: session?.start ?? 0,
package/web/app.css CHANGED
@@ -115,6 +115,9 @@ body.resizing { cursor: col-resize; user-select: none; }
115
115
  .pi { width: 12px; height: 12px; fill: light-dark(var(--il), var(--id)); flex: none; }
116
116
  .sess .proj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12em; }
117
117
  .sess .t .dot { margin-left: auto; }
118
+ /* An Orca bot's scheduled runs (Look around, Tidy-up): quieter, back to full on hover, focus or selection */
119
+ .sess.routine:not([aria-current]):not(:hover):not(:focus-visible) { opacity: 0.55; }
120
+ .sess.routine .t .name { font-weight: 400; }
118
121
  .origin { font-size: 11px; color: var(--faint); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; }
119
122
  .link { color: var(--accent); text-decoration: underline; display: block; margin-top: 8px; }
120
123
  .link:hover { text-decoration: none; }
@@ -117,6 +117,7 @@ export function sessionRow(s, { selected = false, now = Date.now(), group = null
117
117
  row.dataset.id = s.id;
118
118
  row.draggable = true; // onto a group chip
119
119
  if (selected) row.setAttribute('aria-current', 'true');
120
+ if (s.routine) { row.classList.add('routine'); row.title = S.list.routineTip; } // an Orca bot's scheduled run
120
121
  const t = el('div', 't');
121
122
  const badge = el('span', `badge ${s.source === 'codex' ? 'cx' : 'cc'}`, S.sourceBadge[s.source] ?? '?');
122
123
  badge.title = S.sourceTip(S.source[s.source] ?? s.source);
package/web/strings.js CHANGED
@@ -34,6 +34,7 @@ export const S = {
34
34
  untitled: 'Untitled session',
35
35
  bot: 'Bot',
36
36
  botTip: (name) => `Orca bot "${name}": its workers are folded into this run`,
37
+ routineTip: "One of the Orca bot's scheduled runs (Look around: a short read-only check that suggests next steps; Tidy-up: memory upkeep)",
37
38
  searchPlaceholder: 'Search title or project',
38
39
  sourceLabel: 'Tool',
39
40
  periodLabel: 'Period',