agent-run-inspector 0.10.0 → 0.10.2
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 +1 -1
- package/src/adapters/claude-code/agents.js +1 -1
- package/src/adapters/claude-code/orca.js +15 -10
- package/src/index/scan.js +9 -6
- package/src/index/summary.js +10 -3
- package/src/live/sse.js +4 -1
- package/web/app.css +7 -0
- package/web/app.js +25 -0
- package/web/strings.js +5 -1
package/package.json
CHANGED
|
@@ -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 ?? key.split('@')[0], status: live ? 'running' : 'ok',
|
|
192
|
+
...base, id: externalSpanId(key), name: c.name ?? str(mate.meta?.name) ?? 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) } : {}),
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
// rules live here so a format change is one edit. Only ids and names are taken from prompts and results.
|
|
3
3
|
// - A bot is a long-lived session whose cwd is `~/.orca/bots/<slug>`.
|
|
4
4
|
// - A coordinator (a bot or any session) starts workers with `orca orchestration worker-start`; that
|
|
5
|
-
// Bash call's result prints `dispatchId=ctx_… taskId=task_…` per worker
|
|
6
|
-
//
|
|
5
|
+
// Bash call's result prints `dispatchId=ctx_… taskId=task_…` per worker (bots often grep it down to
|
|
6
|
+
// the dispatch id alone).
|
|
7
|
+
// - A worker's own file opens with Orca's dispatch prompt, which names its task and dispatch ids.
|
|
7
8
|
// A session that only quotes these strings (a tool output, a pasted log) claims nothing: the ids count
|
|
8
9
|
// only from a worker-start call's own result, or from a file's first user message.
|
|
9
10
|
|
|
10
11
|
const BOT_CWD = /[\\/]\.orca[\\/]bots[\\/]([^\\/]+)(?:[\\/]|$)/; // its folder or one below
|
|
11
12
|
const WORKER_START = /\borchestration\s+worker-start\b/;
|
|
12
|
-
// one line per worker: `dispatchId=ctx_… taskId=task_… … workspace=<id>::<path
|
|
13
|
-
const DISPATCHED = /\bdispatchId=(ctx_[0-9a-z]+)
|
|
13
|
+
// one line per worker: `dispatchId=ctx_… taskId=task_… … workspace=<id>::<path>`, or only `dispatchId=ctx_…`
|
|
14
|
+
const DISPATCHED = /\bdispatchId=(ctx_[0-9a-z]+)(?:\s+taskId=(task_[0-9a-z]+))?(?:[^\n]*?\sworkspace=\S*::(\S+))?/g;
|
|
14
15
|
const WORKER_PROMPT = 'You are a dispatched worker';
|
|
15
16
|
const PROMPT_START = 'You are working inside Orca'; // the prompt opens the message; helpers that quote it do not
|
|
16
17
|
const TASK_LINE = /Your task ID is:\s*(task_[0-9a-z]+)/;
|
|
18
|
+
const DISPATCH_FLAG = /--dispatch-id\s+(ctx_[0-9a-z]+)/;
|
|
17
19
|
const flag = (name) => new RegExp(`--${name}\\s+(?:"([^"]+)"|'([^']+)'|(\\S+))`);
|
|
18
20
|
const NAME_FLAG = flag('name');
|
|
19
21
|
const TITLE_FLAG = flag('task-title');
|
|
@@ -24,14 +26,16 @@ const textOf = (c) => (typeof c === 'string' ? c : Array.isArray(c) ? c.map((b)
|
|
|
24
26
|
/** The bot's slug when `cwd` is an Orca bot's home folder, else undefined. */
|
|
25
27
|
export const botOf = (cwd) => (typeof cwd === 'string' ? BOT_CWD.exec(cwd)?.[1] : undefined);
|
|
26
28
|
|
|
27
|
-
/**
|
|
28
|
-
export function
|
|
29
|
+
/** { task, dispatch } when this user record is Orca's dispatch prompt (call it on a file's first user record only). */
|
|
30
|
+
export function workerOf(rec) {
|
|
29
31
|
if (rec?.type !== 'user') return undefined;
|
|
30
32
|
const t = textOf(rec.message?.content).trimStart();
|
|
31
|
-
|
|
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;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
/** Workers a file started: feed records in order; `tasks` maps task id
|
|
37
|
+
/** Workers a file started: feed records in order; `tasks` maps task id (dispatch id when the result shows
|
|
38
|
+
* only that) -> { name, task, start, line }. */
|
|
35
39
|
export class OrcaDispatches {
|
|
36
40
|
constructor() {
|
|
37
41
|
this.calls = new Map(); // worker-start tool_use id -> { name, start, line }
|
|
@@ -58,14 +62,15 @@ export class OrcaDispatches {
|
|
|
58
62
|
for (const m of textOf(b.content).matchAll(DISPATCHED)) {
|
|
59
63
|
// no --name: the worker's workspace folder names it
|
|
60
64
|
const folder = m[3]?.split(/[\\/]/).filter(Boolean).at(-1);
|
|
61
|
-
|
|
65
|
+
const key = m[2] ?? m[1];
|
|
66
|
+
if (!this.tasks.has(key)) this.tasks.set(key, { ...call, name: call.name ?? folder });
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
/** Raw-byte prefilter for lines worth parsing with OrcaDispatches. */
|
|
68
|
-
export const DISPATCH_MARKS = [Buffer.from('worker-start'), Buffer.from('
|
|
73
|
+
export const DISPATCH_MARKS = [Buffer.from('worker-start'), Buffer.from('dispatchId=ctx_')];
|
|
69
74
|
export const WORKER_MARK = Buffer.from(WORKER_PROMPT);
|
|
70
75
|
/** Worker files are started by Orca, not the claude CLI: their head says so (prefilter for a wider read). */
|
|
71
76
|
export const WORKER_HEAD_MARKS = ['"entrypoint":"orca"', '"entrypoint":"sdk-cli"'].map((s) => Buffer.from(s));
|
package/src/index/scan.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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,
|
|
7
|
+
import { OrcaDispatches, workerOf, DISPATCH_MARKS, WORKER_MARK, WORKER_HEAD_MARKS } from '../adapters/claude-code/orca.js';
|
|
8
8
|
|
|
9
9
|
export const HEAD_BYTES = 16 * 1024;
|
|
10
10
|
export const TAIL_BYTES = 16 * 1024;
|
|
@@ -218,9 +218,11 @@ function firstUser(buf) {
|
|
|
218
218
|
let r = null;
|
|
219
219
|
try { r = JSON.parse(line.toString('utf8')); } catch { /* not a record */ }
|
|
220
220
|
if (r?.type !== 'user') continue;
|
|
221
|
-
const
|
|
221
|
+
const w = line.includes(WORKER_MARK) ? workerOf(r) : undefined;
|
|
222
222
|
const t = Date.parse(r.timestamp);
|
|
223
|
-
|
|
223
|
+
// the worker's folder names it when its coordinator's result did not
|
|
224
|
+
const folder = typeof r.cwd === 'string' ? r.cwd.split(/[\\/]/).filter(Boolean).at(-1) : undefined;
|
|
225
|
+
return { found: true, key: w ? { ...w, folder, ts: Number.isFinite(t) ? t : 0 } : null };
|
|
224
226
|
}
|
|
225
227
|
return { found: false, key: null };
|
|
226
228
|
}
|
|
@@ -286,7 +288,7 @@ function linkOrcaWorkers(list, store, cache) {
|
|
|
286
288
|
else rest.push(e);
|
|
287
289
|
}
|
|
288
290
|
if (!workers.length) return list;
|
|
289
|
-
const owner = new Map(); // task id -> { lead, start }
|
|
291
|
+
const owner = new Map(); // task or dispatch id -> { lead, start }
|
|
290
292
|
// a coordinator writes after its workers start: older sessions are not read
|
|
291
293
|
const since = Math.min(...workers.map((w) => w.key.ts));
|
|
292
294
|
for (const l of rest) {
|
|
@@ -296,11 +298,12 @@ function linkOrcaWorkers(list, store, cache) {
|
|
|
296
298
|
if (!o || call.start < o.start) owner.set(task, { lead: l, start: call.start });
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
|
-
for (const { e, key: { task
|
|
301
|
+
for (const { e, key: { task, dispatch, folder } } of workers) {
|
|
302
|
+
const key = owner.has(task) ? task : dispatch;
|
|
300
303
|
const o = owner.get(key);
|
|
301
304
|
if (!o) { rest.push(e); continue; }
|
|
302
305
|
// the worker's own sub-agents come along (linked to its Agent calls by tool_use id)
|
|
303
|
-
o.lead.subs.push({ ...e.main, agentId: key, metaFileId: null, mate: true }, ...e.subs);
|
|
306
|
+
o.lead.subs.push({ ...e.main, agentId: key, metaFileId: null, mate: true, name: folder }, ...e.subs);
|
|
304
307
|
o.lead.lastWrite = Math.max(o.lead.lastWrite, e.lastWrite);
|
|
305
308
|
}
|
|
306
309
|
return rest;
|
package/src/index/summary.js
CHANGED
|
@@ -130,7 +130,8 @@ function quickClaude(entry, store, now) {
|
|
|
130
130
|
start: first ?? entry.main.mtimeMs,
|
|
131
131
|
end: running ? null : last,
|
|
132
132
|
status: running ? 'running' : 'ok',
|
|
133
|
-
|
|
133
|
+
// a bot waiting on its workers is the bot at work: Running, not Background
|
|
134
|
+
...(running && turnEnded && !bot ? { background: true } : {}),
|
|
134
135
|
agentCount: 1 + entry.subs.length,
|
|
135
136
|
totals, models,
|
|
136
137
|
});
|
|
@@ -206,7 +207,7 @@ export function openEntry(entry, store, now) {
|
|
|
206
207
|
if (entry.source === 'claude-code') {
|
|
207
208
|
const subagents = entry.subs.map((s) => ({
|
|
208
209
|
fileId: String(s.fileId), agentId: s.agentId, text: readText(store, s.fileId, s.size),
|
|
209
|
-
meta: readMeta(store, s), mtime: s.mtimeMs, ...(s.mate ? { mate: true } : {}),
|
|
210
|
+
meta: s.name ? { name: s.name } : readMeta(store, s), mtime: s.mtimeMs, ...(s.mate ? { mate: true } : {}),
|
|
210
211
|
}));
|
|
211
212
|
const snap = buildSessionTree({
|
|
212
213
|
main: { fileId: String(entry.main.fileId), text: readText(store, entry.main.fileId, entry.main.size) },
|
|
@@ -216,7 +217,13 @@ export function openEntry(entry, store, now) {
|
|
|
216
217
|
meta = snap.session;
|
|
217
218
|
// an Orca bot's own session: its root agent is the bot, not an orchestrator (see roles.js)
|
|
218
219
|
const bot = botOf(meta.cwd);
|
|
219
|
-
if (bot)
|
|
220
|
+
if (bot) {
|
|
221
|
+
// waiting on its workers is the bot at work: Running, not Background (as in the list)
|
|
222
|
+
for (const s of spans) {
|
|
223
|
+
if (s.kind === 'session') delete s.background;
|
|
224
|
+
if (s.kind === 'agent' && (s.depth ?? 0) === 0 && !s.external) { s.bot = bot; delete s.background; }
|
|
225
|
+
}
|
|
226
|
+
}
|
|
220
227
|
} else {
|
|
221
228
|
const mk = (f) => {
|
|
222
229
|
const p = createCodexParser({ fileId: String(f.fileId), now: () => now });
|
package/src/live/sse.js
CHANGED
|
@@ -125,7 +125,10 @@ export function createLiveHub({ index, redactor, pingMs = PING_MS, sweepMs = SWE
|
|
|
125
125
|
listSeen.set(summary.id, json);
|
|
126
126
|
if (!first) emit(listFeed, { type: 'session', summary });
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
// a session left the list (folded under its Orca bot or lead, or out of the window): clients reload it
|
|
129
|
+
let gone = false;
|
|
130
|
+
for (const id of listSeen.keys()) if (!now.has(id)) { listSeen.delete(id); gone = true; }
|
|
131
|
+
if (gone && !first) emit(listFeed, { type: 'resync' });
|
|
129
132
|
return summaries;
|
|
130
133
|
}
|
|
131
134
|
|
package/web/app.css
CHANGED
|
@@ -55,6 +55,13 @@ button:focus-visible, .sess:focus-visible { outline: 2px solid var(--accent); ou
|
|
|
55
55
|
.ver { color: var(--muted); font-size: 11px; font-weight: 400; }
|
|
56
56
|
.upd { font-size: 11px; font-weight: 500; color: var(--llm); background: var(--llm-soft); border-radius: 999px; padding: 1px 8px; cursor: help; }
|
|
57
57
|
.upd.act { cursor: pointer; }
|
|
58
|
+
.upd-pop { position: fixed; right: 20px; bottom: 20px; z-index: 20; width: 320px; max-width: calc(100vw - 32px); display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--panel); color: var(--text); border: 1px solid var(--llm); border-radius: 12px; box-shadow: 0 12px 32px -8px rgba(0,0,0,.35); font-size: 13px; }
|
|
59
|
+
.upd-pop b { font-size: 15px; }
|
|
60
|
+
.upd-pop p { margin: 0; color: var(--muted); }
|
|
61
|
+
.upd-pop code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); border-radius: 6px; padding: 6px 8px; user-select: all; }
|
|
62
|
+
.upd-pop div { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
|
|
63
|
+
.upd-pop button { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
|
|
64
|
+
.upd-pop button.primary { background: var(--llm); border-color: var(--llm); color: #fff; }
|
|
58
65
|
.upd.act:hover { filter: brightness(0.95); text-decoration: underline; }
|
|
59
66
|
.spacer { flex: 1; }
|
|
60
67
|
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
|
package/web/app.js
CHANGED
|
@@ -264,7 +264,32 @@ if (state.mini) {
|
|
|
264
264
|
const upd = $('upd');
|
|
265
265
|
upd.hidden = !m.latest;
|
|
266
266
|
if (m.latest) { upd.textContent = S.meta.update(m.latest); upd.title = bridge ? S.meta.click(m.latest) : S.meta.how(m.latest); }
|
|
267
|
+
if (m.latest) showUpdatePop(m.latest);
|
|
267
268
|
}, () => {});
|
|
269
|
+
// A newer version: a card once per version (Later remembers it); the header badge stays either way.
|
|
270
|
+
const showUpdatePop = (v) => {
|
|
271
|
+
let seen = null;
|
|
272
|
+
try { seen = localStorage.getItem('ari.updSeen'); } catch { /* storage blocked */ }
|
|
273
|
+
if (seen === v || document.querySelector('.upd-pop')) return;
|
|
274
|
+
const pop = document.createElement('div');
|
|
275
|
+
pop.className = 'upd-pop';
|
|
276
|
+
pop.setAttribute('role', 'dialog');
|
|
277
|
+
const close = () => { pop.remove(); try { localStorage.setItem('ari.updSeen', v); } catch { /* storage blocked */ } };
|
|
278
|
+
const h = document.createElement('b'); h.textContent = S.meta.popTitle(v);
|
|
279
|
+
const p = document.createElement('p'); p.textContent = bridge ? S.meta.popApp : S.meta.popCli;
|
|
280
|
+
pop.append(h, p);
|
|
281
|
+
if (!bridge) { const c = document.createElement('code'); c.textContent = 'npm i -g agent-run-inspector'; pop.append(c); }
|
|
282
|
+
const row = document.createElement('div');
|
|
283
|
+
const later = document.createElement('button'); later.textContent = S.meta.popLater; later.addEventListener('click', close);
|
|
284
|
+
row.append(later);
|
|
285
|
+
if (bridge) {
|
|
286
|
+
const now = document.createElement('button'); now.className = 'primary'; now.textContent = S.meta.popNow;
|
|
287
|
+
now.addEventListener('click', () => { close(); bridge.postMessage({ update: true }); });
|
|
288
|
+
row.append(now);
|
|
289
|
+
}
|
|
290
|
+
pop.append(row);
|
|
291
|
+
document.body.append(pop);
|
|
292
|
+
};
|
|
268
293
|
const bridge = window.webkit?.messageHandlers?.ari; // inside the Mac app: the badge starts the update
|
|
269
294
|
if (bridge) {
|
|
270
295
|
$('upd').classList.add('act');
|
package/web/strings.js
CHANGED
|
@@ -20,7 +20,11 @@ export const S = {
|
|
|
20
20
|
add: '+ New group', addTo: 'Add to group', remove: 'Remove from group', del: 'Delete group',
|
|
21
21
|
dropHint: 'Drop a session here to add it to this group',
|
|
22
22
|
},
|
|
23
|
-
meta: {
|
|
23
|
+
meta: {
|
|
24
|
+
popTitle: (v) => `Version ${v} is out`, popApp: 'Update now and the app reopens on the new version.',
|
|
25
|
+
popCli: 'Run this, then "ari service install" if you use the app or the service:', popNow: 'Update now', popLater: 'Later',
|
|
26
|
+
update: (v) => `Update ${v}`, click: (v) => `Click to update to ${v}. The app reopens when it is done.`, how: (v) => `Version ${v} is out. In the Mac app: right-click the menu bar item, then "Update to ${v}". Or run "npm i -g agent-run-inspector", then "ari service install" if you use the app or the service.`,
|
|
27
|
+
},
|
|
24
28
|
auth: { restarted: 'Signed out. Open the new address printed in the terminal, or run "ari open" if the inspector runs as a service.', detail: 'The server was restarted or this tab lost its sign-in, so the server no longer accepts it.' },
|
|
25
29
|
list: {
|
|
26
30
|
heading: 'Sessions',
|