@namzu/cli 26.3.0 → 27.0.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.
- package/CHANGELOG.md +214 -0
- package/README.md +49 -34
- package/dist/bin.js +7 -0
- package/dist/bin.js.map +1 -1
- package/dist/checkpoints/store.d.ts +17 -4
- package/dist/checkpoints/store.d.ts.map +1 -1
- package/dist/checkpoints/store.js +20 -5
- package/dist/checkpoints/store.js.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/acp.d.ts +23 -1
- package/dist/commands/acp.d.ts.map +1 -1
- package/dist/commands/acp.js +41 -2
- package/dist/commands/acp.js.map +1 -1
- package/dist/commands/drain.d.ts +69 -2
- package/dist/commands/drain.d.ts.map +1 -1
- package/dist/commands/drain.js +214 -134
- package/dist/commands/drain.js.map +1 -1
- package/dist/commands/eval.js +1 -1
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/provider-wait.d.ts +5 -5
- package/dist/commands/provider-wait.d.ts.map +1 -1
- package/dist/commands/provider-wait.js +2 -2
- package/dist/commands/resident.d.ts.map +1 -1
- package/dist/commands/resident.js +2 -1
- package/dist/commands/resident.js.map +1 -1
- package/dist/commands/run-flags.d.ts +7 -7
- package/dist/commands/run-flags.js +4 -4
- package/dist/commands/run-stream.d.ts +16 -12
- package/dist/commands/run-stream.d.ts.map +1 -1
- package/dist/commands/run-stream.js +142 -98
- package/dist/commands/run-stream.js.map +1 -1
- package/dist/commands/run.d.ts +6 -4
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +129 -45
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/serve.js +2 -2
- package/dist/commands/serve.js.map +1 -1
- package/dist/commands/state.js +8 -8
- package/dist/commands/state.js.map +1 -1
- package/dist/config/load.d.ts +1 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +17 -5
- package/dist/config/load.js.map +1 -1
- package/dist/config/run-limits.d.ts +20 -8
- package/dist/config/run-limits.d.ts.map +1 -1
- package/dist/config/run-limits.js +28 -46
- package/dist/config/run-limits.js.map +1 -1
- package/dist/config/schema.d.ts +44 -19
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/config/tool-result-screens.js +1 -1
- package/dist/context/directories.d.ts +37 -0
- package/dist/context/directories.d.ts.map +1 -0
- package/dist/context/directories.js +69 -0
- package/dist/context/directories.js.map +1 -0
- package/dist/context/environment.d.ts +55 -0
- package/dist/context/environment.d.ts.map +1 -1
- package/dist/context/environment.js +96 -0
- package/dist/context/environment.js.map +1 -1
- package/dist/context/project-tracker.d.ts +3 -3
- package/dist/context/project-tracker.d.ts.map +1 -1
- package/dist/context/project-tracker.js +3 -3
- package/dist/context/project-tracker.js.map +1 -1
- package/dist/context/project.d.ts +1 -1
- package/dist/context/project.js +1 -1
- package/dist/context/sandbox.d.ts +22 -3
- package/dist/context/sandbox.d.ts.map +1 -1
- package/dist/context/sandbox.js +42 -4
- package/dist/context/sandbox.js.map +1 -1
- package/dist/doctor/checks/chain.d.ts +1 -1
- package/dist/doctor/checks/chain.js +5 -5
- package/dist/doctor/checks/chain.js.map +1 -1
- package/dist/doctor/checks/invariants.d.ts +2 -2
- package/dist/doctor/checks/invariants.js +5 -5
- package/dist/doctor/checks/invariants.js.map +1 -1
- package/dist/doctor/checks/logging.js +1 -1
- package/dist/doctor/checks/logging.js.map +1 -1
- package/dist/doctor/checks/sandbox.js +1 -1
- package/dist/doctor/checks/sandbox.js.map +1 -1
- package/dist/doctor/checks/session-export.d.ts +1 -1
- package/dist/doctor/checks/session-export.js +2 -2
- package/dist/doctor/checks/session-export.js.map +1 -1
- package/dist/doctor/checks/telemetry.d.ts +1 -1
- package/dist/doctor/checks/telemetry.js +1 -1
- package/dist/doctor/registry.js +2 -2
- package/dist/doctor/registry.js.map +1 -1
- package/dist/exit-codes.d.ts +2 -2
- package/dist/exit-codes.js +2 -2
- package/dist/integrations/mcp/servers.d.ts +1 -1
- package/dist/integrations/providers/chain-capabilities.d.ts +6 -6
- package/dist/integrations/providers/chain-capabilities.js +8 -8
- package/dist/integrations/providers/chain-capabilities.js.map +1 -1
- package/dist/integrations/providers/register.d.ts +1 -1
- package/dist/integrations/providers/register.js +1 -1
- package/dist/integrations/providers/registry.d.ts +1 -1
- package/dist/integrations/resident/inspection.d.ts +4 -1
- package/dist/integrations/resident/inspection.d.ts.map +1 -1
- package/dist/integrations/resident/inspection.js +53 -34
- package/dist/integrations/resident/inspection.js.map +1 -1
- package/dist/integrations/resident/learning-storage.d.ts +7 -2
- package/dist/integrations/resident/learning-storage.d.ts.map +1 -1
- package/dist/integrations/resident/learning-storage.js +12 -8
- package/dist/integrations/resident/learning-storage.js.map +1 -1
- package/dist/integrations/resident/runner-store.d.ts +1 -1
- package/dist/integrations/resident/runner-store.d.ts.map +1 -1
- package/dist/integrations/resident/runner-store.js +5 -2
- package/dist/integrations/resident/runner-store.js.map +1 -1
- package/dist/integrations/resident/runner-worker.js +1 -0
- package/dist/integrations/resident/runner-worker.js.map +1 -1
- package/dist/integrations/resident/session-log-reads.d.ts +37 -0
- package/dist/integrations/resident/session-log-reads.d.ts.map +1 -0
- package/dist/integrations/resident/session-log-reads.js +125 -0
- package/dist/integrations/resident/session-log-reads.js.map +1 -0
- package/dist/integrations/resident/session-step.d.ts +2 -0
- package/dist/integrations/resident/session-step.d.ts.map +1 -1
- package/dist/integrations/resident/session-step.js +15 -13
- package/dist/integrations/resident/session-step.js.map +1 -1
- package/dist/integrations/resident/storage.d.ts +23 -1
- package/dist/integrations/resident/storage.d.ts.map +1 -1
- package/dist/integrations/resident/storage.js +60 -17
- package/dist/integrations/resident/storage.js.map +1 -1
- package/dist/integrations/resident/tool-evidence.d.ts +4 -2
- package/dist/integrations/resident/tool-evidence.d.ts.map +1 -1
- package/dist/integrations/resident/tool-evidence.js +36 -30
- package/dist/integrations/resident/tool-evidence.js.map +1 -1
- package/dist/integrations/resident/verification.d.ts +2 -2
- package/dist/integrations/resident/verification.d.ts.map +1 -1
- package/dist/integrations/resident/verification.js +4 -4
- package/dist/integrations/resident/verification.js.map +1 -1
- package/dist/integrations/sessions/checkpoint-view.d.ts +13 -0
- package/dist/integrations/sessions/checkpoint-view.d.ts.map +1 -0
- package/dist/integrations/sessions/checkpoint-view.js +48 -0
- package/dist/integrations/sessions/checkpoint-view.js.map +1 -0
- package/dist/integrations/sessions/context-inventory.js +1 -1
- package/dist/integrations/sessions/context-inventory.js.map +1 -1
- package/dist/integrations/sessions/conversation-search.d.ts +16 -20
- package/dist/integrations/sessions/conversation-search.d.ts.map +1 -1
- package/dist/integrations/sessions/conversation-search.js +305 -731
- package/dist/integrations/sessions/conversation-search.js.map +1 -1
- package/dist/integrations/sessions/evidence-page-validation.d.ts +4 -4
- package/dist/integrations/sessions/evidence-page-validation.d.ts.map +1 -1
- package/dist/integrations/sessions/evidence-page-validation.js +1 -1
- package/dist/integrations/sessions/evidence-page-validation.js.map +1 -1
- package/dist/integrations/sessions/evidence-recall.d.ts +40 -2
- package/dist/integrations/sessions/evidence-recall.d.ts.map +1 -1
- package/dist/integrations/sessions/evidence-recall.js +41 -97
- package/dist/integrations/sessions/evidence-recall.js.map +1 -1
- package/dist/integrations/sessions/store.d.ts +153 -85
- package/dist/integrations/sessions/store.d.ts.map +1 -1
- package/dist/integrations/sessions/store.js +414 -484
- package/dist/integrations/sessions/store.js.map +1 -1
- package/dist/integrations/sessions/task-context.d.ts +15 -2
- package/dist/integrations/sessions/task-context.d.ts.map +1 -1
- package/dist/integrations/sessions/task-context.js +34 -11
- package/dist/integrations/sessions/task-context.js.map +1 -1
- package/dist/integrations/sessions/transcript-export.d.ts +13 -6
- package/dist/integrations/sessions/transcript-export.d.ts.map +1 -1
- package/dist/integrations/sessions/transcript-export.js +148 -263
- package/dist/integrations/sessions/transcript-export.js.map +1 -1
- package/dist/integrations/state/home.d.ts +4 -16
- package/dist/integrations/state/home.d.ts.map +1 -1
- package/dist/integrations/state/home.js +6 -42
- package/dist/integrations/state/home.js.map +1 -1
- package/dist/integrations/state/project.d.ts +6 -7
- package/dist/integrations/state/project.d.ts.map +1 -1
- package/dist/integrations/state/project.js +7 -9
- package/dist/integrations/state/project.js.map +1 -1
- package/dist/integrations/state/report.d.ts +27 -41
- package/dist/integrations/state/report.d.ts.map +1 -1
- package/dist/integrations/state/report.js +172 -464
- package/dist/integrations/state/report.js.map +1 -1
- package/dist/integrations/state/retention.d.ts +18 -0
- package/dist/integrations/state/retention.d.ts.map +1 -0
- package/dist/integrations/state/retention.js +18 -0
- package/dist/integrations/state/retention.js.map +1 -0
- package/dist/integrations/subagents/activity.d.ts +36 -31
- package/dist/integrations/subagents/activity.d.ts.map +1 -1
- package/dist/integrations/subagents/activity.js +27 -23
- package/dist/integrations/subagents/activity.js.map +1 -1
- package/dist/integrations/subagents/batches.d.ts +91 -0
- package/dist/integrations/subagents/batches.d.ts.map +1 -0
- package/dist/integrations/subagents/batches.js +172 -0
- package/dist/integrations/subagents/batches.js.map +1 -0
- package/dist/integrations/subagents/parent.d.ts +26 -11
- package/dist/integrations/subagents/parent.d.ts.map +1 -1
- package/dist/integrations/subagents/parent.js +13 -28
- package/dist/integrations/subagents/parent.js.map +1 -1
- package/dist/integrations/subagents/policy.d.ts +2 -2
- package/dist/integrations/subagents/policy.d.ts.map +1 -1
- package/dist/integrations/subagents/policy.js +2 -2
- package/dist/integrations/subagents/policy.js.map +1 -1
- package/dist/integrations/subagents/replay.d.ts +91 -26
- package/dist/integrations/subagents/replay.d.ts.map +1 -1
- package/dist/integrations/subagents/replay.js +216 -114
- package/dist/integrations/subagents/replay.js.map +1 -1
- package/dist/integrations/subagents/runtime.d.ts +50 -26
- package/dist/integrations/subagents/runtime.d.ts.map +1 -1
- package/dist/integrations/subagents/runtime.js +132 -126
- package/dist/integrations/subagents/runtime.js.map +1 -1
- package/dist/integrations/subagents/saved-agents.d.ts +57 -0
- package/dist/integrations/subagents/saved-agents.d.ts.map +1 -0
- package/dist/integrations/subagents/saved-agents.js +102 -0
- package/dist/integrations/subagents/saved-agents.js.map +1 -0
- package/dist/integrations/subagents/slash.d.ts +55 -0
- package/dist/integrations/subagents/slash.d.ts.map +1 -0
- package/dist/integrations/subagents/slash.js +45 -0
- package/dist/integrations/subagents/slash.js.map +1 -0
- package/dist/integrations/telemetry/session-export.d.ts +6 -6
- package/dist/integrations/telemetry/session-export.d.ts.map +1 -1
- package/dist/integrations/telemetry/session-export.js +2 -2
- package/dist/memory/presentation.d.ts +11 -0
- package/dist/memory/presentation.d.ts.map +1 -1
- package/dist/memory/presentation.js +25 -0
- package/dist/memory/presentation.js.map +1 -1
- package/dist/memory/store.d.ts +13 -7
- package/dist/memory/store.d.ts.map +1 -1
- package/dist/memory/store.js +37 -11
- package/dist/memory/store.js.map +1 -1
- package/dist/memory/typed.d.ts +116 -0
- package/dist/memory/typed.d.ts.map +1 -0
- package/dist/memory/typed.js +336 -0
- package/dist/memory/typed.js.map +1 -0
- package/dist/permissions/checks.d.ts +1 -1
- package/dist/permissions/checks.js +1 -1
- package/dist/permissions/headless-trust.d.ts +2 -2
- package/dist/permissions/headless-trust.d.ts.map +1 -1
- package/dist/permissions/headless-trust.js +3 -3
- package/dist/permissions/headless-trust.js.map +1 -1
- package/dist/permissions/mode.d.ts +4 -4
- package/dist/permissions/mode.js +1 -1
- package/dist/permissions/rules.d.ts +1 -1
- package/dist/permissions/rules.js +1 -1
- package/dist/termination.d.ts +75 -0
- package/dist/termination.d.ts.map +1 -0
- package/dist/termination.js +143 -0
- package/dist/termination.js.map +1 -0
- package/dist/tui/AgentExplorer.d.ts +2 -2
- package/dist/tui/AgentExplorer.js +4 -4
- package/dist/tui/AgentExplorer.js.map +1 -1
- package/dist/tui/App.d.ts +9 -1
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +452 -303
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/LiveActivity.d.ts +1 -1
- package/dist/tui/LiveActivity.d.ts.map +1 -1
- package/dist/tui/PermissionOverlay.d.ts +8 -0
- package/dist/tui/PermissionOverlay.d.ts.map +1 -1
- package/dist/tui/PermissionOverlay.js +25 -2
- package/dist/tui/PermissionOverlay.js.map +1 -1
- package/dist/tui/Picker.js +1 -1
- package/dist/tui/agent.d.ts +208 -132
- package/dist/tui/agent.d.ts.map +1 -1
- package/dist/tui/agent.js +523 -313
- package/dist/tui/agent.js.map +1 -1
- package/dist/tui/conversation-evidence-view.js +3 -3
- package/dist/tui/conversation-evidence-view.js.map +1 -1
- package/dist/tui/conversation-history.d.ts +4 -21
- package/dist/tui/conversation-history.d.ts.map +1 -1
- package/dist/tui/conversation-history.js +4 -28
- package/dist/tui/conversation-history.js.map +1 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +27 -1
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/log-pane.js +1 -1
- package/dist/tui/markdownParser.d.ts +1 -1
- package/dist/tui/markdownParser.js +1 -1
- package/dist/tui/permission-review.d.ts +16 -0
- package/dist/tui/permission-review.d.ts.map +1 -1
- package/dist/tui/permission-review.js +25 -2
- package/dist/tui/permission-review.js.map +1 -1
- package/dist/tui/slashCommands.d.ts +29 -40
- package/dist/tui/slashCommands.d.ts.map +1 -1
- package/dist/tui/slashCommands.js +70 -61
- package/dist/tui/slashCommands.js.map +1 -1
- package/dist/tui/{run-interruption.d.ts → turn-interruption.d.ts} +4 -4
- package/dist/tui/turn-interruption.d.ts.map +1 -0
- package/dist/tui/{run-interruption.js → turn-interruption.js} +20 -20
- package/dist/tui/turn-interruption.js.map +1 -0
- package/dist/tui/turn-limits-settings.d.ts +39 -0
- package/dist/tui/turn-limits-settings.d.ts.map +1 -0
- package/dist/tui/{run-limits-settings.js → turn-limits-settings.js} +18 -18
- package/dist/tui/turn-limits-settings.js.map +1 -0
- package/dist/tui/types.d.ts +3 -3
- package/dist/tui/types.d.ts.map +1 -1
- package/dist/user-commands/store.d.ts +1 -1
- package/dist/user-commands/store.js +1 -1
- package/package.json +7 -7
- package/dist/integrations/sessions/compaction-evidence.d.ts +0 -5
- package/dist/integrations/sessions/compaction-evidence.d.ts.map +0 -1
- package/dist/integrations/sessions/compaction-evidence.js +0 -59
- package/dist/integrations/sessions/compaction-evidence.js.map +0 -1
- package/dist/integrations/sessions/database.d.ts +0 -5
- package/dist/integrations/sessions/database.d.ts.map +0 -1
- package/dist/integrations/sessions/database.js +0 -34
- package/dist/integrations/sessions/database.js.map +0 -1
- package/dist/integrations/sessions/paths.d.ts +0 -7
- package/dist/integrations/sessions/paths.d.ts.map +0 -1
- package/dist/integrations/sessions/paths.js +0 -14
- package/dist/integrations/sessions/paths.js.map +0 -1
- package/dist/integrations/sessions/run-discovery.d.ts +0 -24
- package/dist/integrations/sessions/run-discovery.d.ts.map +0 -1
- package/dist/integrations/sessions/run-discovery.js +0 -142
- package/dist/integrations/sessions/run-discovery.js.map +0 -1
- package/dist/integrations/sessions/turn-evidence.d.ts +0 -129
- package/dist/integrations/sessions/turn-evidence.d.ts.map +0 -1
- package/dist/integrations/sessions/turn-evidence.js +0 -517
- package/dist/integrations/sessions/turn-evidence.js.map +0 -1
- package/dist/integrations/subagents/history.d.ts +0 -26
- package/dist/integrations/subagents/history.d.ts.map +0 -1
- package/dist/integrations/subagents/history.js +0 -76
- package/dist/integrations/subagents/history.js.map +0 -1
- package/dist/integrations/subagents/runs.d.ts +0 -72
- package/dist/integrations/subagents/runs.d.ts.map +0 -1
- package/dist/integrations/subagents/runs.js +0 -155
- package/dist/integrations/subagents/runs.js.map +0 -1
- package/dist/tui/run-interruption.d.ts.map +0 -1
- package/dist/tui/run-interruption.js.map +0 -1
- package/dist/tui/run-limits-settings.d.ts +0 -39
- package/dist/tui/run-limits-settings.d.ts.map +0 -1
- package/dist/tui/run-limits-settings.js.map +0 -1
|
@@ -1,37 +1,73 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ChildSessionSummary, type Logger, type SessionEvent, type SessionIndex, type SessionLocator, type SessionPaths, type SessionRecord, type TurnExecutionStatus } from '@namzu/sdk';
|
|
2
2
|
import { type SubagentActivity } from './activity.js';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Child summaries one listing considers.
|
|
5
|
+
*
|
|
6
|
+
* The index answers `listChildren` from one query, so this no longer bounds a
|
|
7
|
+
* directory scan. It bounds what one listing does with the answer: a
|
|
8
|
+
* conversation that delegated tens of thousands of times is still summarised
|
|
9
|
+
* from its most recent work rather than from its whole history. Children are
|
|
10
|
+
* taken newest first, so past this many it is the OLDEST that stop being
|
|
11
|
+
* counted.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAX_CONSIDERED_CHILDREN = 2000;
|
|
14
|
+
/**
|
|
15
|
+
* Children replayed into one monitor, matching the live monitor's own
|
|
16
|
+
* retention. Replay walks the newest first and stops at this many, so a
|
|
17
|
+
* conversation that delegated thousands of times opens its most recent work
|
|
18
|
+
* instead of its whole history.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MAX_REPLAYED_CHILDREN = 80;
|
|
21
|
+
/** The parts of the session index a saved-children reader asks. */
|
|
22
|
+
export type SavedChildIndex = Pick<SessionIndex, 'refresh' | 'listChildren'>;
|
|
23
|
+
/** Where a conversation's delegated children are recorded. */
|
|
4
24
|
export interface SavedChildScope {
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The index over the project's logs. The conversation's own log is
|
|
27
|
+
* refreshed before it is asked, so a child spawned a moment ago is listed.
|
|
28
|
+
*/
|
|
29
|
+
readonly index: SavedChildIndex;
|
|
30
|
+
/** The project layout the conversation's log lives in. */
|
|
31
|
+
readonly paths: SessionPaths;
|
|
32
|
+
/** The conversation whose turns spawned the children being looked for. */
|
|
33
|
+
readonly session: SessionLocator;
|
|
9
34
|
readonly maxChildren?: number;
|
|
10
35
|
readonly log?: Logger;
|
|
11
36
|
}
|
|
37
|
+
/** One child as the parent's log records it, plus where its own log is. */
|
|
38
|
+
export interface SavedChild extends ChildSessionSummary {
|
|
39
|
+
/** `<parent-session-dir>/subagents/<child-id>.jsonl`, derived from checked ids, never from `path`. */
|
|
40
|
+
readonly logPath: string;
|
|
41
|
+
}
|
|
12
42
|
/**
|
|
13
|
-
*
|
|
14
|
-
* first.
|
|
43
|
+
* Up to `limit` of a conversation's children, newest first.
|
|
15
44
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* one of this conversation's runs.
|
|
45
|
+
* The parent's log is the record of which children it spawned
|
|
46
|
+
* (`child_session_spawned`) and how each one ended (`child_session_ended`);
|
|
47
|
+
* the index derives {@link ChildSessionSummary} from exactly those records.
|
|
48
|
+
* The parent's log is refreshed first. A refresh that fails is reported and
|
|
49
|
+
* the index is asked anyway: a listing that is one child short is better than
|
|
50
|
+
* none, and the next refresh catches up.
|
|
23
51
|
*
|
|
24
|
-
*
|
|
25
|
-
* the
|
|
26
|
-
*
|
|
27
|
-
* counts. A child session directory holds exactly one parent run id, so the
|
|
28
|
-
* inner listing runs only where there is something to list.
|
|
29
|
-
*
|
|
30
|
-
* READ-ONLY throughout. Nothing here creates a directory, and in particular
|
|
31
|
-
* nothing binds a `RunDiskStore`, which would mint the run directory it was
|
|
32
|
-
* asked about.
|
|
52
|
+
* Nothing here writes a log, a meta file or a session directory. The only
|
|
53
|
+
* write is the refresh, which brings the rebuildable index up to date with a
|
|
54
|
+
* log it already derives from.
|
|
33
55
|
*/
|
|
34
|
-
export declare function
|
|
56
|
+
export declare function readSavedChildren(scope: SavedChildScope, limit: number): Promise<readonly SavedChild[]>;
|
|
57
|
+
/**
|
|
58
|
+
* The newest `limit` children, as {@link readSavedChildren}, plus how many
|
|
59
|
+
* children the index lists in all, so a bounded listing can say exactly how
|
|
60
|
+
* many it left out.
|
|
61
|
+
*/
|
|
62
|
+
export declare function readSavedChildrenPage(scope: SavedChildScope, limit: number): Promise<{
|
|
63
|
+
readonly children: readonly SavedChild[];
|
|
64
|
+
readonly total: number;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Every delegated child one conversation's turns spawned, in launch order,
|
|
68
|
+
* bounded to the newest {@link MAX_REPLAYED_CHILDREN}.
|
|
69
|
+
*/
|
|
70
|
+
export declare function listSavedChildren(scope: SavedChildScope): Promise<readonly SavedChild[]>;
|
|
35
71
|
/**
|
|
36
72
|
* Replays saved children into the display shape the live monitor publishes.
|
|
37
73
|
*
|
|
@@ -40,7 +76,36 @@ export declare function listSavedChildren(scope: SavedChildScope): Promise<reado
|
|
|
40
76
|
* {@link SubagentActivity.replayed} so no surface offers to act on work that
|
|
41
77
|
* finished in another process.
|
|
42
78
|
*/
|
|
43
|
-
export declare function replaySavedChildren(children: readonly
|
|
79
|
+
export declare function replaySavedChildren(children: readonly SavedChild[], log?: Logger): Promise<readonly SubagentActivity[]>;
|
|
44
80
|
/** Discovery and replay in one call, for a host that wants the whole list. */
|
|
45
81
|
export declare function replaySavedChildrenFor(scope: SavedChildScope): Promise<readonly SubagentActivity[]>;
|
|
82
|
+
/** What one child's own log says, projected for the monitor. */
|
|
83
|
+
interface ChildLogEvidence {
|
|
84
|
+
readonly events: readonly SessionEvent[];
|
|
85
|
+
readonly partial: boolean;
|
|
86
|
+
readonly agentId?: string;
|
|
87
|
+
readonly model?: string;
|
|
88
|
+
readonly prompt?: string;
|
|
89
|
+
/** The child's last settled turn, for a child whose parent never recorded an ending. */
|
|
90
|
+
readonly terminal?: {
|
|
91
|
+
readonly status: TurnExecutionStatus;
|
|
92
|
+
readonly tokens: number;
|
|
93
|
+
readonly at: number;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A child's records as the live stream would have delivered them.
|
|
98
|
+
*
|
|
99
|
+
* Persisted events pass through unchanged: a record IS its event plus the
|
|
100
|
+
* envelope, and the projection reads only the event's own fields. An
|
|
101
|
+
* assistant `message` record stands in for the `text_delta`s that produced it
|
|
102
|
+
* (deltas are ephemeral and never reach a log), with any later
|
|
103
|
+
* `message_replaced` applied first, so a replay shows the answer the parent
|
|
104
|
+
* was given and never a raw one a guardrail or review replaced. Every other
|
|
105
|
+
* record-only type (checkpoints, decisions, audit, compaction) has no row.
|
|
106
|
+
*/
|
|
107
|
+
export declare function projectChildLog(records: readonly SessionRecord[]): Omit<ChildLogEvidence, 'partial'>;
|
|
108
|
+
/** Milliseconds since the epoch of an ISO timestamp; NaN for a missing or unreadable one. */
|
|
109
|
+
export declare function timeOf(iso: string | undefined): number;
|
|
110
|
+
export {};
|
|
46
111
|
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../src/integrations/subagents/replay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../src/integrations/subagents/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,MAAM,EAEX,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EAEnB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAGxB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACN,KAAK,gBAAgB,EAGrB,MAAM,eAAe,CAAA;AAEtB;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,OAAQ,CAAA;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAA;AAEvC,mEAAmE;AACnE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,cAAc,CAAC,CAAA;AAE5E,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC/B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAA;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;IAC5B,0EAA0E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AAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACnB,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAA;QACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;QACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KACnB,CAAA;CACD;AA4CD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC9B,OAAO,EAAE,SAAS,aAAa,EAAE,GAC/B,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,CA+DnC;AAmCD,6FAA6F;AAC7F,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEtD"}
|
|
@@ -1,81 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { RunDiskStore, readRunEventsIn, } from '@namzu/sdk';
|
|
1
|
+
import { SESSION_EVENT_TYPES, asSessionId, readSessionLog, } from '@namzu/sdk';
|
|
4
2
|
import { SubagentActivityMonitor, } from './activity.js';
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
7
|
-
* children.
|
|
4
|
+
* Child summaries one listing considers.
|
|
8
5
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* It is a bound, not a policy. Entries come back in the order the filesystem
|
|
16
|
-
* lists them, so past this many directories WHICH children are found stops
|
|
17
|
-
* being predictable — which is an argument for a prune command, not a
|
|
18
|
-
* substitute for one.
|
|
6
|
+
* The index answers `listChildren` from one query, so this no longer bounds a
|
|
7
|
+
* directory scan. It bounds what one listing does with the answer: a
|
|
8
|
+
* conversation that delegated tens of thousands of times is still summarised
|
|
9
|
+
* from its most recent work rather than from its whole history. Children are
|
|
10
|
+
* taken newest first, so past this many it is the OLDEST that stop being
|
|
11
|
+
* counted.
|
|
19
12
|
*/
|
|
20
|
-
const
|
|
13
|
+
export const MAX_CONSIDERED_CHILDREN = 2_000;
|
|
21
14
|
/**
|
|
22
15
|
* Children replayed into one monitor, matching the live monitor's own
|
|
23
16
|
* retention. Replay walks the newest first and stops at this many, so a
|
|
24
17
|
* conversation that delegated thousands of times opens its most recent work
|
|
25
18
|
* instead of its whole history.
|
|
26
19
|
*/
|
|
27
|
-
const MAX_REPLAYED_CHILDREN = 80;
|
|
20
|
+
export const MAX_REPLAYED_CHILDREN = 80;
|
|
28
21
|
/**
|
|
29
|
-
*
|
|
30
|
-
* first.
|
|
31
|
-
*
|
|
32
|
-
* Two directory shapes have to meet here. A conversation's own runs are
|
|
33
|
-
* `<sessionsRoot>/<sessionId>/runs/<runId>`, which is where the parent run
|
|
34
|
-
* ids come from after a restart has forgotten them. A child's evidence is
|
|
35
|
-
* `<sessionsRoot>/<childSessionId>/runs/<parentRunId>/children/<childRunId>`,
|
|
36
|
-
* under the child's session and not the parent's — so finding a child means
|
|
37
|
-
* asking every session directory whether it holds a `runs/` entry named after
|
|
38
|
-
* one of this conversation's runs.
|
|
22
|
+
* Up to `limit` of a conversation's children, newest first.
|
|
39
23
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
24
|
+
* The parent's log is the record of which children it spawned
|
|
25
|
+
* (`child_session_spawned`) and how each one ended (`child_session_ended`);
|
|
26
|
+
* the index derives {@link ChildSessionSummary} from exactly those records.
|
|
27
|
+
* The parent's log is refreshed first. A refresh that fails is reported and
|
|
28
|
+
* the index is asked anyway: a listing that is one child short is better than
|
|
29
|
+
* none, and the next refresh catches up.
|
|
45
30
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
31
|
+
* Nothing here writes a log, a meta file or a session directory. The only
|
|
32
|
+
* write is the refresh, which brings the rebuildable index up to date with a
|
|
33
|
+
* log it already derives from.
|
|
49
34
|
*/
|
|
50
|
-
export async function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
export async function readSavedChildren(scope, limit) {
|
|
36
|
+
return (await readSavedChildrenPage(scope, limit)).children;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The newest `limit` children, as {@link readSavedChildren}, plus how many
|
|
40
|
+
* children the index lists in all, so a bounded listing can say exactly how
|
|
41
|
+
* many it left out.
|
|
42
|
+
*/
|
|
43
|
+
export async function readSavedChildrenPage(scope, limit) {
|
|
44
|
+
const sessionId = asSessionId(scope.session.sessionId);
|
|
45
|
+
try {
|
|
46
|
+
await scope.index.refresh({
|
|
47
|
+
slug: scope.paths.slug,
|
|
48
|
+
logPath: scope.paths.sessionLog(scope.session),
|
|
49
|
+
sessionId,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
scope.log?.warn('The conversation log could not be refreshed in the session index', {
|
|
54
|
+
'namzu.subagent.replay.session_id': sessionId,
|
|
55
|
+
'namzu.subagent.replay.error': errorMessage(error),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const children = [...(await scope.index.listChildren(sessionId))];
|
|
59
|
+
children.sort((left, right) => sortTime(right.spawnedAt) - sortTime(left.spawnedAt));
|
|
55
60
|
const found = [];
|
|
56
|
-
for (const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
scope.log?.warn('Saved delegated children could not be listed', {
|
|
68
|
-
'namzu.subagent.replay.runs_dir': runsDir,
|
|
69
|
-
'namzu.subagent.replay.parent_run_id': runId,
|
|
70
|
-
'namzu.subagent.replay.error': errorMessage(error),
|
|
71
|
-
});
|
|
72
|
-
}
|
|
61
|
+
for (const child of children.slice(0, Math.max(0, limit))) {
|
|
62
|
+
try {
|
|
63
|
+
found.push({ ...child, logPath: scope.paths.subagentLog(scope.session, child.sessionId) });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// A child id the layout refuses is not a path to read. Named so the
|
|
67
|
+
// operator can find the record that carried it.
|
|
68
|
+
scope.log?.warn('A saved child names an id the session layout refuses', {
|
|
69
|
+
'namzu.subagent.replay.child_session_id': String(child.sessionId),
|
|
70
|
+
'namzu.subagent.replay.error': errorMessage(error),
|
|
71
|
+
});
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
return { children: found, total: children.length };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Every delegated child one conversation's turns spawned, in launch order,
|
|
78
|
+
* bounded to the newest {@link MAX_REPLAYED_CHILDREN}.
|
|
79
|
+
*/
|
|
80
|
+
export async function listSavedChildren(scope) {
|
|
81
|
+
const newestFirst = await readSavedChildren(scope, scope.maxChildren ?? MAX_REPLAYED_CHILDREN);
|
|
82
|
+
return [...newestFirst].reverse();
|
|
79
83
|
}
|
|
80
84
|
/**
|
|
81
85
|
* Replays saved children into the display shape the live monitor publishes.
|
|
@@ -88,23 +92,32 @@ export async function listSavedChildren(scope) {
|
|
|
88
92
|
export async function replaySavedChildren(children, log) {
|
|
89
93
|
const monitor = new SubagentActivityMonitor({ replay: true });
|
|
90
94
|
for (const child of children) {
|
|
91
|
-
const evidence = await
|
|
95
|
+
const evidence = await readChildLog(child, log);
|
|
96
|
+
const ended = child.endedAt !== undefined;
|
|
97
|
+
const status = ended ? child.status : evidence.terminal?.status;
|
|
98
|
+
const tokens = ended ? child.tokens : evidence.terminal?.tokens;
|
|
99
|
+
const completedAt = ended ? timeOf(child.endedAt) : evidence.terminal?.at;
|
|
100
|
+
const startedAt = timeOf(child.spawnedAt);
|
|
92
101
|
monitor.replay({
|
|
93
|
-
agentId:
|
|
94
|
-
description: child.
|
|
95
|
-
...(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
...(child.
|
|
107
|
-
...(child.
|
|
102
|
+
agentId: evidence.agentId ?? child.kind,
|
|
103
|
+
description: child.description,
|
|
104
|
+
...(evidence.prompt !== undefined ? { prompt: evidence.prompt } : {}),
|
|
105
|
+
...(evidence.model ? { model: evidence.model } : {}),
|
|
106
|
+
sessionId: child.sessionId,
|
|
107
|
+
// The parent turn is the display group a live cohort is keyed by
|
|
108
|
+
// (`workflowId` on a live row is the invoking turn's id), so a saved
|
|
109
|
+
// child groups under the same identity it had while it ran.
|
|
110
|
+
workflowId: child.parentTurnId,
|
|
111
|
+
batchId: child.batch?.batchId ?? `saved:${child.parentTurnId}`,
|
|
112
|
+
// The labels the parent recorded on `child_session_spawned.batch`:
|
|
113
|
+
// unlike a live-only annotation these survive the process, so a
|
|
114
|
+
// saved child comes back under the workflow and phase it ran in.
|
|
115
|
+
...(child.batch?.name ? { workflow: child.batch.name } : {}),
|
|
116
|
+
...(child.batch?.phase ? { phase: child.batch.phase } : {}),
|
|
117
|
+
...(status ? { status: activityStatus(status) } : {}),
|
|
118
|
+
...(tokens !== undefined ? { tokens } : {}),
|
|
119
|
+
...(Number.isFinite(startedAt) ? { startedAt } : {}),
|
|
120
|
+
...(completedAt !== undefined && Number.isFinite(completedAt) ? { completedAt } : {}),
|
|
108
121
|
...(evidence.partial ? { partial: true } : {}),
|
|
109
122
|
}, evidence.events);
|
|
110
123
|
}
|
|
@@ -114,49 +127,139 @@ export async function replaySavedChildren(children, log) {
|
|
|
114
127
|
export async function replaySavedChildrenFor(scope) {
|
|
115
128
|
return replaySavedChildren(await listSavedChildren(scope), scope.log);
|
|
116
129
|
}
|
|
130
|
+
const LIVE_EVENT_TYPES = new Set(SESSION_EVENT_TYPES);
|
|
117
131
|
/**
|
|
118
|
-
* One child's
|
|
132
|
+
* One child's log as the events the live monitor projects, and whether all
|
|
133
|
+
* of it could be read.
|
|
119
134
|
*
|
|
120
|
-
* Read
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* it is partial.
|
|
135
|
+
* Read tolerantly, once. A tolerant read stops at the first break in the
|
|
136
|
+
* hash chain and says so (`intact: false`), and a torn final line is counted
|
|
137
|
+
* in `tornBytes`, so the read itself tells a damaged log from a short one. A
|
|
138
|
+
* replay that quietly showed four rows of a forty-row session would be the
|
|
139
|
+
* most misleading thing this view could do, so the damage is reported
|
|
140
|
+
* instead: the rows that survive are shown, and the transcript says it is
|
|
141
|
+
* partial.
|
|
128
142
|
*
|
|
129
|
-
* A
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
143
|
+
* A log that cannot be read AT ALL — a missing file, or a path that is not a
|
|
144
|
+
* file — is the same answer taken to its limit: no rows, and partial. It is
|
|
145
|
+
* not a reason to leave the child out of the listing. The parent's log still
|
|
146
|
+
* records that the child was spawned and how it ended, dropping the row
|
|
147
|
+
* would say this child never existed, and a row that shows the facts it has
|
|
148
|
+
* under a notice saying the record is incomplete is the honest version of the
|
|
149
|
+
* same information.
|
|
136
150
|
*/
|
|
137
|
-
async function
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
// Falls through to the tolerant read below.
|
|
143
|
-
}
|
|
151
|
+
async function readChildLog(child, log) {
|
|
152
|
+
let entries;
|
|
153
|
+
let partial;
|
|
144
154
|
try {
|
|
145
|
-
|
|
155
|
+
const read = await readSessionLog(child.logPath, {
|
|
156
|
+
mode: 'tolerant',
|
|
157
|
+
sessionId: child.sessionId,
|
|
158
|
+
});
|
|
159
|
+
entries = read.entries;
|
|
160
|
+
partial = !read.intact || read.tornBytes > 0 || read.entries.length === 0;
|
|
146
161
|
}
|
|
147
162
|
catch (error) {
|
|
148
|
-
log?.warn('Saved child
|
|
149
|
-
'namzu.subagent.replay.
|
|
163
|
+
log?.warn('Saved child log could not be read', {
|
|
164
|
+
'namzu.subagent.replay.child_log': child.logPath,
|
|
150
165
|
'namzu.subagent.replay.error': errorMessage(error),
|
|
151
166
|
});
|
|
152
167
|
return { events: [], partial: true };
|
|
153
168
|
}
|
|
169
|
+
return { ...projectChildLog(entries.map((entry) => entry.record)), partial };
|
|
154
170
|
}
|
|
155
171
|
/**
|
|
156
|
-
* A
|
|
172
|
+
* A child's records as the live stream would have delivered them.
|
|
173
|
+
*
|
|
174
|
+
* Persisted events pass through unchanged: a record IS its event plus the
|
|
175
|
+
* envelope, and the projection reads only the event's own fields. An
|
|
176
|
+
* assistant `message` record stands in for the `text_delta`s that produced it
|
|
177
|
+
* (deltas are ephemeral and never reach a log), with any later
|
|
178
|
+
* `message_replaced` applied first, so a replay shows the answer the parent
|
|
179
|
+
* was given and never a raw one a guardrail or review replaced. Every other
|
|
180
|
+
* record-only type (checkpoints, decisions, audit, compaction) has no row.
|
|
181
|
+
*/
|
|
182
|
+
export function projectChildLog(records) {
|
|
183
|
+
const replacements = new Map();
|
|
184
|
+
for (const record of records) {
|
|
185
|
+
if (record.type === 'message_replaced')
|
|
186
|
+
replacements.set(record.targetMessageId, record.content);
|
|
187
|
+
}
|
|
188
|
+
const events = [];
|
|
189
|
+
let agentId;
|
|
190
|
+
let model;
|
|
191
|
+
let prompt;
|
|
192
|
+
let terminal;
|
|
193
|
+
for (const record of records) {
|
|
194
|
+
switch (record.type) {
|
|
195
|
+
case 'session_started':
|
|
196
|
+
agentId ??= record.agent.id || record.agent.name || undefined;
|
|
197
|
+
continue;
|
|
198
|
+
case 'message': {
|
|
199
|
+
if (record.role === 'user' && record.kind === 'prompt' && prompt === undefined) {
|
|
200
|
+
const text = messageText(record.content);
|
|
201
|
+
if (text !== undefined)
|
|
202
|
+
prompt = text;
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (record.role !== 'assistant' || record.turnId === undefined)
|
|
206
|
+
continue;
|
|
207
|
+
const text = messageText(replacements.get(record.messageId) ?? record.content);
|
|
208
|
+
if (!text)
|
|
209
|
+
continue;
|
|
210
|
+
events.push({
|
|
211
|
+
type: 'text_delta',
|
|
212
|
+
sessionId: record.sessionId,
|
|
213
|
+
turnId: record.turnId,
|
|
214
|
+
iteration: 0,
|
|
215
|
+
messageId: record.messageId,
|
|
216
|
+
text,
|
|
217
|
+
});
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
case 'turn_started':
|
|
221
|
+
model ??= record.config.model || undefined;
|
|
222
|
+
break;
|
|
223
|
+
case 'turn_completed':
|
|
224
|
+
terminal = {
|
|
225
|
+
status: record.settlement.status,
|
|
226
|
+
tokens: record.settlement.usage.totalTokens,
|
|
227
|
+
at: timeOf(record.ts),
|
|
228
|
+
};
|
|
229
|
+
break;
|
|
230
|
+
case 'turn_failed':
|
|
231
|
+
terminal = {
|
|
232
|
+
status: 'failed',
|
|
233
|
+
tokens: record.settlement.usage.totalTokens,
|
|
234
|
+
at: timeOf(record.ts),
|
|
235
|
+
};
|
|
236
|
+
break;
|
|
237
|
+
default:
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
if (LIVE_EVENT_TYPES.has(record.type))
|
|
241
|
+
events.push(record);
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
events,
|
|
245
|
+
...(agentId ? { agentId } : {}),
|
|
246
|
+
...(model ? { model } : {}),
|
|
247
|
+
...(prompt !== undefined ? { prompt } : {}),
|
|
248
|
+
...(terminal ? { terminal } : {}),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/** The plain text of a message body, when it has one. */
|
|
252
|
+
function messageText(content) {
|
|
253
|
+
if (typeof content !== 'object' || content === null)
|
|
254
|
+
return undefined;
|
|
255
|
+
const body = content.content;
|
|
256
|
+
return typeof body === 'string' ? body : undefined;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* A saved turn status as the display status the monitor projects.
|
|
157
260
|
*
|
|
158
261
|
* `running` survives as `working` rather than being rewritten to a terminal
|
|
159
|
-
* value: a process killed mid-
|
|
262
|
+
* value: a process killed mid-turn genuinely did not record an ending, and
|
|
160
263
|
* claiming one would be a different lie from the one this view exists to
|
|
161
264
|
* avoid. Nothing is attached to the row either way — `replayed` is what says
|
|
162
265
|
* that, on every replayed row regardless of status.
|
|
@@ -177,15 +280,14 @@ function activityStatus(status) {
|
|
|
177
280
|
return 'cancelled';
|
|
178
281
|
}
|
|
179
282
|
}
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
283
|
+
/** Milliseconds since the epoch of an ISO timestamp; NaN for a missing or unreadable one. */
|
|
284
|
+
export function timeOf(iso) {
|
|
285
|
+
return iso === undefined ? Number.NaN : Date.parse(iso);
|
|
286
|
+
}
|
|
287
|
+
/** {@link timeOf} for ordering: an unreadable time sorts as the oldest. */
|
|
288
|
+
function sortTime(iso) {
|
|
289
|
+
const time = timeOf(iso);
|
|
290
|
+
return Number.isFinite(time) ? time : 0;
|
|
189
291
|
}
|
|
190
292
|
function errorMessage(error) {
|
|
191
293
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../../src/integrations/subagents/replay.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../../src/integrations/subagents/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,mBAAmB,EAQnB,WAAW,EACX,cAAc,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAEN,uBAAuB,GAEvB,MAAM,eAAe,CAAA;AAEtB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAA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