agent-run-inspector 0.9.1 → 0.9.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
CHANGED
|
@@ -24,6 +24,15 @@ export function shutdownSignal(rec) {
|
|
|
24
24
|
return Array.isArray(c) && c.every((b) => b?.type === 'tool_result') ? undefined : false;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* A slash command Claude Code ran itself (/clear, /usage, /model ...): its records say nothing about a turn.
|
|
29
|
+
* A command that prompts the model is followed by a real prompt record, which starts the turn.
|
|
30
|
+
*/
|
|
31
|
+
export const isLocalCommand = (rec) => {
|
|
32
|
+
const c = rec?.message?.content;
|
|
33
|
+
return typeof c === 'string' && /^\s*<(command-name|local-command-stdout|local-command-stderr|local-command-caveat)>/.test(c);
|
|
34
|
+
};
|
|
35
|
+
|
|
27
36
|
/** Id of the root agent span under the session span (Codex: `cx:<sid>:main`). */
|
|
28
37
|
export const rootAgentId = (sessionId) => `${sessionId}:main`;
|
|
29
38
|
|
|
@@ -55,7 +64,7 @@ export class ClaudeCodeSession {
|
|
|
55
64
|
this.title = undefined;
|
|
56
65
|
// The last turn closed and nothing came after it: the model's final answer (stop_reason end_turn)
|
|
57
66
|
// or system/turn_duration (not written for every turn).
|
|
58
|
-
this.turnEnded =
|
|
67
|
+
this.turnEnded = true; // no turn yet (a file /clear started holds only command records)
|
|
59
68
|
this.shutDown = false; // see shutdownSignal
|
|
60
69
|
this.cwd = undefined;
|
|
61
70
|
this.branch = undefined;
|
|
@@ -125,7 +134,7 @@ export class ClaudeCodeSession {
|
|
|
125
134
|
this.bg.onAssistant(rec);
|
|
126
135
|
break;
|
|
127
136
|
case 'user':
|
|
128
|
-
this.turnEnded = false;
|
|
137
|
+
if (!isLocalCommand(rec)) this.turnEnded = false;
|
|
129
138
|
this.bg.onUser(rec);
|
|
130
139
|
this.tools.onUser(rec, ts);
|
|
131
140
|
this.agents.onUser(rec, ts);
|
package/src/index/summary.js
CHANGED
|
@@ -10,7 +10,7 @@ import { HEAD_BYTES, TAIL_BYTES, TITLE_SCAN_BYTES, findLastTitle, readEnds, read
|
|
|
10
10
|
import { createCodexParser } from '../adapters/codex/index.js';
|
|
11
11
|
import { linkCodexAgents } from '../adapters/codex/agents.js';
|
|
12
12
|
import { AgentCollector, buildSessionTree } from '../adapters/claude-code/agents.js';
|
|
13
|
-
import { ENDS_TURN, shutdownSignal } from '../adapters/claude-code/index.js';
|
|
13
|
+
import { ENDS_TURN, isLocalCommand, shutdownSignal } from '../adapters/claude-code/index.js';
|
|
14
14
|
import { BackgroundTasks } from '../adapters/claude-code/tools.js';
|
|
15
15
|
import { mapUsage } from '../adapters/codex/llm.js';
|
|
16
16
|
import { MSG } from '../strings.js';
|
|
@@ -45,7 +45,7 @@ function subFinished(store, sub) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// The record that says whether a Claude Code thread is mid-turn, and whether that turn ended.
|
|
48
|
-
const turnRec = (tail) => lastOf(tail, (r) => r.type === 'user' || r.type === 'assistant' || (r.type === 'system' && r.subtype === 'turn_duration'));
|
|
48
|
+
const turnRec = (tail) => lastOf(tail, (r) => (r.type === 'user' && !isLocalCommand(r)) || r.type === 'assistant' || (r.type === 'system' && r.subtype === 'turn_duration'));
|
|
49
49
|
const ended = (r) => r?.type === 'system' || (r?.type === 'assistant' && ENDS_TURN.has(r.message?.stop_reason));
|
|
50
50
|
|
|
51
51
|
// Teammates the lead stopped (TaskStop) or heard shut down, from the lead's tail: name -> time.
|
|
@@ -104,7 +104,10 @@ function quickClaude(entry, store, now) {
|
|
|
104
104
|
}
|
|
105
105
|
const recent = (t) => now - t < RUNNING_MS && now >= t;
|
|
106
106
|
// The main thread's last turn ended (a final answer or system/turn_duration last): it waits for the user.
|
|
107
|
-
|
|
107
|
+
// No turn record at all: done when the tail holds only command records (a file /clear started); otherwise
|
|
108
|
+
// the tail may just sit inside one huge record, so keep the old reading (not ended).
|
|
109
|
+
const lastTurn = turnRec(tail);
|
|
110
|
+
const turnEnded = lastTurn ? ended(lastTurn) : tail.some(isLocalCommand);
|
|
108
111
|
// ...but a sub-agent or teammate still writing keeps the run going (same rule as the full parse).
|
|
109
112
|
const stopped = entry.subs.some((s) => s.mate) ? stoppedMates(tail) : new Map();
|
|
110
113
|
const childRunning = entry.subs.some((s) => recent(s.mtimeMs) && (s.mate ? !mateDone(store, s, stopped) : !subFinished(store, s)));
|