@tangle-network/agent-runtime 0.349.0 → 0.352.1
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/dist/{activation-wBipBkCf.d.ts → activation-BidzGkUQ.d.ts} +2 -24
- package/dist/{activation-tNGW73Y9.js → activation-C6zNC2kx.js} +12 -14
- package/dist/{activation-tNGW73Y9.js.map → activation-C6zNC2kx.js.map} +1 -1
- package/dist/agent.d.ts +8 -12
- package/dist/agent.js +9 -12
- package/dist/agent.js.map +1 -1
- package/dist/{analyst-loop-DZw5QWT9.js → analyst-loop-BZvXCDKy.js} +2 -3
- package/dist/{analyst-loop-DZw5QWT9.js.map → analyst-loop-BZvXCDKy.js.map} +1 -1
- package/dist/analyst-loop.d.ts +3 -5
- package/dist/analyst-loop.js +1 -2
- package/dist/{bundle-1xaJEgjq.js → bundle-DeDkJbsr.js} +3 -4
- package/dist/{bundle-1xaJEgjq.js.map → bundle-DeDkJbsr.js.map} +1 -1
- package/dist/candidate-execution/index.d.ts +13 -33
- package/dist/candidate-execution/index.js +16 -18
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/chat-turn.d.ts +2 -0
- package/dist/chat-turn.js +1 -0
- package/dist/{coordination-manager-B2Z_MmL9.js → coordination-manager-B7QadgrI.js} +101 -132
- package/dist/{coordination-manager-B2Z_MmL9.js.map → coordination-manager-B7QadgrI.js.map} +1 -1
- package/dist/{delegate-Dr-63jFl.js → delegate-CoscoyEo.js} +19 -21
- package/dist/delegate-CoscoyEo.js.map +1 -0
- package/dist/durable.d.ts +16 -149
- package/dist/durable.js +57 -980
- package/dist/durable.js.map +1 -1
- package/dist/{errors-DodWX-cb.js → errors-AzSuGI23.js} +5 -3
- package/dist/errors-AzSuGI23.js.map +1 -0
- package/dist/execution-handle-Bd2_nUB6.js +167 -0
- package/dist/execution-handle-Bd2_nUB6.js.map +1 -0
- package/dist/execution-handle-CujvqgCn.d.ts +130 -0
- package/dist/{graph-DPejYB3C.js → graph-mojMML8e.js} +192 -14
- package/dist/graph-mojMML8e.js.map +1 -0
- package/dist/{improve-DwSahPi1.js → improve-Dm5ZE8mr.js} +36 -53
- package/dist/{improve-DwSahPi1.js.map → improve-Dm5ZE8mr.js.map} +1 -1
- package/dist/{improvement-adapter-sIthWkcN.d.ts → improvement-adapter-D5GRU1eY.d.ts} +2 -6
- package/dist/index.d.ts +41 -89
- package/dist/index.js +45 -61
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +39 -59
- package/dist/intelligence.js +24 -33
- package/dist/intelligence.js.map +1 -1
- package/dist/journal-store-BJPMUydp.js +3925 -0
- package/dist/journal-store-BJPMUydp.js.map +1 -0
- package/dist/kernel.d.ts +5 -5
- package/dist/kernel.js +12 -11
- package/dist/{loop-runner-CP6MfO1b.js → loop-runner-5cL_vZi0.js} +5 -6
- package/dist/{loop-runner-CP6MfO1b.js.map → loop-runner-5cL_vZi0.js.map} +1 -1
- package/dist/{loop-runner-C6pGq-2l.d.ts → loop-runner-DyLD-aNb.d.ts} +3 -5
- package/dist/loop-runner-bin.d.ts +5 -8
- package/dist/loop-runner-bin.js +2 -3
- package/dist/mcp/bin.js +6 -8
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +8 -18
- package/dist/mcp/index.js +17 -25
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.js +4 -6
- package/dist/mcp/memory-bin.js.map +1 -1
- package/dist/{model-policy-CyCUwHed.js → model-policy-C-RGAUW4.js} +11 -13
- package/dist/{model-policy-CyCUwHed.js.map → model-policy-C-RGAUW4.js.map} +1 -1
- package/dist/placement.d.ts +12 -14
- package/dist/placement.js +1 -2
- package/dist/platform.d.ts +7 -13
- package/dist/platform.js +3 -6
- package/dist/platform.js.map +1 -1
- package/dist/{prepare-B9wWffjO.js → prepare-XWwsOh8O.js} +50 -69
- package/dist/{prepare-B9wWffjO.js.map → prepare-XWwsOh8O.js.map} +1 -1
- package/dist/{profile-JLJd2wFG.js → profile-C01SQZKa.js} +58 -92
- package/dist/profile-C01SQZKa.js.map +1 -0
- package/dist/{profile-materialization-bPm0gGLO.d.ts → profile-materialization-BRY22Oh8.d.ts} +1 -3
- package/dist/profiles.d.ts +25 -12
- package/dist/profiles.js +52 -11
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-DVVh-hEk.d.ts → protected-model-port-IKqhTypD.d.ts} +2 -14
- package/dist/{protected-redaction-DFCeo4vg.js → protected-redaction-DilFZch5.js} +2 -3
- package/dist/{protected-redaction-DFCeo4vg.js.map → protected-redaction-DilFZch5.js.map} +1 -1
- package/dist/{provision-supervisor-C4v2vqDo.js → provision-supervisor-D9pO-iPl.js} +11 -15
- package/dist/{provision-supervisor-C4v2vqDo.js.map → provision-supervisor-D9pO-iPl.js.map} +1 -1
- package/dist/{run-cancellation-CzFhQGMa.js → run-cancellation-CoJRKvih.js} +6 -7
- package/dist/{run-cancellation-CzFhQGMa.js.map → run-cancellation-CoJRKvih.js.map} +1 -1
- package/dist/{runtime-CsvGCQpl.js → runtime-BJPXHWbc.js} +652 -215
- package/dist/runtime-BJPXHWbc.js.map +1 -0
- package/dist/{runtime-hooks-tXpAarhW.js → runtime-hooks-CsW2pfFk.js} +2 -3
- package/dist/{runtime-hooks-tXpAarhW.js.map → runtime-hooks-CsW2pfFk.js.map} +1 -1
- package/dist/{runtime-hooks-nsqxSUFL.d.ts → runtime-hooks-ZQqPw-0g.d.ts} +1 -3
- package/dist/{sandbox-profile-compat-DtuJWFrM.js → sandbox-profile-compat-CXjozdWL.js} +52 -653
- package/dist/sandbox-profile-compat-CXjozdWL.js.map +1 -0
- package/dist/{search-executor-CCb82Umc.js → search-executor-CQEHMXoT.js} +12 -15
- package/dist/{search-executor-CCb82Umc.js.map → search-executor-CQEHMXoT.js.map} +1 -1
- package/dist/{server-CKPwZU-I.js → server-U9NGgudQ.js} +19 -30
- package/dist/{server-CKPwZU-I.js.map → server-U9NGgudQ.js.map} +1 -1
- package/dist/{structural-rollout-DylC_fwU.js → structural-rollout-wMSxE7bn.js} +71 -70
- package/dist/structural-rollout-wMSxE7bn.js.map +1 -0
- package/dist/{substrate-CGDFTSRh.js → substrate-Db2pp6y3.js} +2 -3
- package/dist/{substrate-CGDFTSRh.js.map → substrate-Db2pp6y3.js.map} +1 -1
- package/dist/{supervise-BGfm2GlY.js → supervise-CNNhX0ab.js} +460 -195
- package/dist/supervise-CNNhX0ab.js.map +1 -0
- package/dist/supervision-discovery-CewADdEs.js +772 -0
- package/dist/supervision-discovery-CewADdEs.js.map +1 -0
- package/dist/{supervisor-wS9Ehz_x.js → supervisor-rK5Y8en6.js} +521 -4320
- package/dist/supervisor-rK5Y8en6.js.map +1 -0
- package/dist/{task-queue-0fKkoweu.d.ts → task-queue-kefGy79U.d.ts} +1 -3
- package/dist/task-queue.d.ts +1 -1
- package/dist/task-queue.js +1 -2
- package/dist/testing.d.ts +7 -15
- package/dist/testing.js +241 -244
- package/dist/testing.js.map +1 -1
- package/dist/tool-loop.d.ts +16 -19
- package/dist/tool-loop.js +2 -3
- package/dist/{tool-server-XV4aJwoQ.js → tool-server-CZWd_Opp.js} +3 -4
- package/dist/{tool-server-XV4aJwoQ.js.map → tool-server-CZWd_Opp.js.map} +1 -1
- package/dist/{top-snapshot-CflmaDgk.js → top-snapshot-DcV7VG4m.js} +179 -163
- package/dist/top-snapshot-DcV7VG4m.js.map +1 -0
- package/dist/tui/bin.js +50 -81
- package/dist/tui/bin.js.map +1 -1
- package/dist/tui/index.d.ts +27 -58
- package/dist/tui/index.js +2 -2
- package/dist/{types-C8BGOCBn.d.ts → types-0uzVKtFW.d.ts} +388 -484
- package/dist/{types-Cwrea-bU.d.ts → types-qsqfyQoY.d.ts} +1 -3
- package/dist/util-ebWMWzY0.js +624 -0
- package/dist/util-ebWMWzY0.js.map +1 -0
- package/dist/workspace-store/index.d.ts +12 -22
- package/dist/workspace-store/index.js +13 -10
- package/dist/workspace-store/index.js.map +1 -1
- package/dist/{workspace-streams-BiS4ABah.d.ts → workspace-streams-Dq2Fzk3c.d.ts} +1 -11
- package/package.json +31 -26
- package/skills/agent-graphs/SKILL.md +17 -4
- package/skills/be-ambitious/SKILL.md +46 -0
- package/skills/graph-designer/SKILL.md +9 -2
- package/dist/delegate-Dr-63jFl.js.map +0 -1
- package/dist/errors-DodWX-cb.js.map +0 -1
- package/dist/graph-DPejYB3C.js.map +0 -1
- package/dist/profile-JLJd2wFG.js.map +0 -1
- package/dist/record-events-D93DkpAx.js +0 -263
- package/dist/record-events-D93DkpAx.js.map +0 -1
- package/dist/runtime-CsvGCQpl.js.map +0 -1
- package/dist/sandbox-profile-compat-DtuJWFrM.js.map +0 -1
- package/dist/structural-rollout-DylC_fwU.js.map +0 -1
- package/dist/supervise-BGfm2GlY.js.map +0 -1
- package/dist/supervisor-wS9Ehz_x.js.map +0 -1
- package/dist/top-snapshot-CflmaDgk.js.map +0 -1
package/dist/tui/bin.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { l as cancelWorker, n as cancelRun, w as writeWorkerSteer, y as supervisorRunsRoot } from "../run-cancellation-
|
|
3
|
-
import { a as parseTime, i as parseSpend, n as loadTopSnapshot, o as totalSpend, r as numberValue, t as aggregateSnapshot } from "../top-snapshot-
|
|
2
|
+
import { l as cancelWorker, n as cancelRun, w as writeWorkerSteer, y as supervisorRunsRoot } from "../run-cancellation-CoJRKvih.js";
|
|
3
|
+
import { a as parseTime, i as parseSpend, n as loadTopSnapshot, o as totalSpend, r as numberValue, t as aggregateSnapshot } from "../top-snapshot-DcV7VG4m.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { hostname, userInfo } from "node:os";
|
|
7
7
|
import { emitKeypressEvents } from "node:readline";
|
|
8
|
-
|
|
8
|
+
// src/tui/top-frame.ts
|
|
9
9
|
const ansiPattern = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
10
10
|
const colors = {
|
|
11
11
|
reset: "\x1B[0m",
|
|
@@ -31,8 +31,8 @@ function renderTopFrameWithLayout(snapshot, options = {}) {
|
|
|
31
31
|
const color = options.color ?? false;
|
|
32
32
|
const focus = options.focus ?? "supervisors";
|
|
33
33
|
const mode = options.mode ?? "overview";
|
|
34
|
-
const selectedSupervisor =
|
|
35
|
-
const selectedWorker = selectedSupervisor ?
|
|
34
|
+
const selectedSupervisor = selectEntity(snapshot.supervisors, options.selectedSupervisorId);
|
|
35
|
+
const selectedWorker = selectedSupervisor ? selectEntity(selectedSupervisor.workers, options.selectedWorkerId) : void 0;
|
|
36
36
|
const targets = [];
|
|
37
37
|
const lines = [];
|
|
38
38
|
const push = (line = "", target) => {
|
|
@@ -44,7 +44,7 @@ function renderTopFrameWithLayout(snapshot, options = {}) {
|
|
|
44
44
|
lines.push(fitAnsi(line, width));
|
|
45
45
|
};
|
|
46
46
|
const aggregate = aggregateSnapshot(snapshot);
|
|
47
|
-
push(`${paint("SUPERVISOR TOP", "bold", color)} ${paint(snapshot.root, "dim", color)} runs ${aggregate.supervisors} workers ${aggregate.workers} live ${aggregate.running} done ${aggregate.done} down ${aggregate.down} ${formatMoney(aggregate.usd)} tok ${formatTokens(aggregate.tokensInput)}/${formatTokens(aggregate.tokensOutput)}`);
|
|
47
|
+
push(`${paint("SUPERVISOR TOP", "bold", color)} ${paint(snapshot.root, "dim", color)} runs ${aggregate.supervisors} workers ${aggregate.workers} live ${aggregate.running} done ${aggregate.done} down ${aggregate.down} ${formatMoney(aggregate.usd, aggregate.usdKnown)} tok ${formatTokens(aggregate.tokensInput, aggregate.tokensKnown)}/${formatTokens(aggregate.tokensOutput, aggregate.tokensKnown)}`);
|
|
48
48
|
push(`${paint("keys", "dim", color)} up/down select left/right run tab focus enter detail o overview l log s steer c cancel mouse q quit`);
|
|
49
49
|
if (options.notice) push(paint(options.notice, "yellow", color));
|
|
50
50
|
if (snapshot.completeness === "partial") push(paint(`partial snapshot: ${snapshot.diagnostics.length} source${snapshot.diagnostics.length === 1 ? "" : "s"} skipped or truncated; runs loaded ${snapshot.loaded}/${snapshot.discovered}`, "yellow", color));
|
|
@@ -73,7 +73,7 @@ function renderTopFrameWithLayout(snapshot, options = {}) {
|
|
|
73
73
|
const rowFocus = selected && focus === "supervisors" ? "inverse" : void 0;
|
|
74
74
|
const workerSummary = `${supervisor.totals.running}/${supervisor.totals.workers} live`;
|
|
75
75
|
const task = compact(supervisor.task, 34);
|
|
76
|
-
const line = `${pointer} ${pad(supervisor.id, 21)} ${pad(status, 12)} ${pad(workerSummary, 13)} ${pad(formatMoney(supervisor.totals.usd), 12)} ${pad(`${formatTokens(supervisor.totals.tokensInput)}/${formatTokens(supervisor.totals.tokensOutput)}`, 16)} ${pad(formatDuration(supervisor.totals.latencyMs), 12)} ${task}`;
|
|
76
|
+
const line = `${pointer} ${pad(supervisor.id, 21)} ${pad(status, 12)} ${pad(workerSummary, 13)} ${pad(formatMoney(supervisor.totals.usd, supervisor.totals.usdKnown), 12)} ${pad(`${formatTokens(supervisor.totals.tokensInput, supervisor.totals.tokensKnown)}/${formatTokens(supervisor.totals.tokensOutput, supervisor.totals.tokensKnown)}`, 16)} ${pad(formatDuration(supervisor.totals.latencyMs), 12)} ${task}`;
|
|
77
77
|
push(rowFocus ? paint(line, rowFocus, color) : line, {
|
|
78
78
|
kind: "supervisor",
|
|
79
79
|
id: supervisor.id
|
|
@@ -93,7 +93,7 @@ function renderTopFrameWithLayout(snapshot, options = {}) {
|
|
|
93
93
|
const score = worker.verdict ?? (worker.status === "done" ? "done" : worker.status);
|
|
94
94
|
const detail = worker.reason ?? worker.outRef ?? worker.parent ?? "";
|
|
95
95
|
const spend = totalSpend(worker);
|
|
96
|
-
const line = `${pointer} ${pad(worker.label, 12)} ${pad(statusText(worker.status, color), 12)} ${pad(worker.runtime ?? "-", 10)} ${pad(formatDuration(worker.latencyMs), 12)} ${pad(formatMoney(spend.usd), 11)} ${pad(`${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)}`, 16)} ${pad(compact(score, 9), 10)} ${compact(detail, 30)}`;
|
|
96
|
+
const line = `${pointer} ${pad(worker.label, 12)} ${pad(statusText(worker.status, color), 12)} ${pad(worker.runtime ?? "-", 10)} ${pad(formatDuration(worker.latencyMs), 12)} ${pad(formatMoney(spend.usd, spend.usdKnown), 11)} ${pad(`${formatTokens(spend.tokensInput, spend.tokensKnown)}/${formatTokens(spend.tokensOutput, spend.tokensKnown)}`, 16)} ${pad(compact(score, 9), 10)} ${compact(detail, 30)}`;
|
|
97
97
|
push(rowFocus ? paint(line, rowFocus, color) : line, {
|
|
98
98
|
kind: "worker",
|
|
99
99
|
id: worker.id,
|
|
@@ -105,9 +105,9 @@ function renderTopFrameWithLayout(snapshot, options = {}) {
|
|
|
105
105
|
push(sectionTitle("OBSERVABILITY", false, color));
|
|
106
106
|
for (const line of renderStatusBars(selectedSupervisor, width, color)) push(line);
|
|
107
107
|
push();
|
|
108
|
-
for (const line of
|
|
108
|
+
for (const line of renderSpendBars(selectedSupervisor, width, color, "usd")) push(line);
|
|
109
109
|
push();
|
|
110
|
-
for (const line of
|
|
110
|
+
for (const line of renderSpendBars(selectedSupervisor, width, color, "tokens")) push(line);
|
|
111
111
|
push();
|
|
112
112
|
for (const line of renderLatencyHistogram(selectedSupervisor, width, color)) push(line);
|
|
113
113
|
push();
|
|
@@ -128,29 +128,23 @@ function renderStatusBars(supervisor, width, color) {
|
|
|
128
128
|
const barWidth = Math.max(12, Math.min(28, width - 58));
|
|
129
129
|
return [`status ${pad("running", 9)} ${bar(supervisor.totals.running, total, barWidth, "#", color, "yellow")} ${supervisor.totals.running} ${pad("done", 5)} ${bar(supervisor.totals.done, total, barWidth, "#", color, "green")} ${supervisor.totals.done} ${pad("down", 5)} ${bar(supervisor.totals.down, total, barWidth, "#", color, "red")} ${supervisor.totals.down}`];
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
})).sort((a, b) => b.spend.usd - a.spend.usd).slice(0, 6);
|
|
136
|
-
const maxUsd = Math.max(1e-6, ...workers.map((row) => row.spend.usd), supervisor.driverSpend.usd);
|
|
137
|
-
const out = [`cost total ${formatMoney(supervisor.totals.usd)} driver ${formatMoney(supervisor.driverSpend.usd)}`];
|
|
138
|
-
const barWidth = Math.max(18, Math.min(46, width - 38));
|
|
139
|
-
for (const row of workers) out.push(` ${pad(row.worker.label, 12)} ${bar(row.spend.usd, maxUsd, barWidth, "$", color, "magenta")} ${formatMoney(row.spend.usd)}`);
|
|
140
|
-
if (workers.length === 0) out.push(" no worker cost yet");
|
|
141
|
-
return out;
|
|
142
|
-
}
|
|
143
|
-
function renderTokenBars(supervisor, width, color) {
|
|
131
|
+
function renderSpendBars(supervisor, width, color, channel) {
|
|
132
|
+
const dollars = channel === "usd";
|
|
133
|
+
const amount = (spend) => dollars ? spend.usd : spend.tokensInput + spend.tokensOutput;
|
|
134
|
+
const label = (spend) => dollars ? formatMoney(spend.usd, spend.usdKnown) : `${formatTokens(spend.tokensInput, spend.tokensKnown)}/${formatTokens(spend.tokensOutput, spend.tokensKnown)}`;
|
|
144
135
|
const rows = supervisor.workers.map((worker) => ({
|
|
145
136
|
worker,
|
|
146
|
-
spend: totalSpend(worker)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
const out = [
|
|
151
|
-
const barWidth = Math.max(18, Math.min(46, width - 44));
|
|
152
|
-
for (const
|
|
153
|
-
|
|
137
|
+
spend: totalSpend(worker)
|
|
138
|
+
})).sort((a, b) => amount(b.spend) - amount(a.spend)).slice(0, 6);
|
|
139
|
+
const max = Math.max(dollars ? 1e-6 : 1, ...rows.map((row) => amount(row.spend)), amount(supervisor.driverSpend));
|
|
140
|
+
const total = dollars ? formatMoney(supervisor.totals.usd, supervisor.totals.usdKnown) : `in ${formatTokens(supervisor.totals.tokensInput, supervisor.totals.tokensKnown)} / out ${formatTokens(supervisor.totals.tokensOutput, supervisor.totals.tokensKnown)}`;
|
|
141
|
+
const out = [`${dollars ? "cost " : "tokens"} total ${total} driver ${label(supervisor.driverSpend)}`];
|
|
142
|
+
const barWidth = Math.max(18, Math.min(46, width - (dollars ? 38 : 44)));
|
|
143
|
+
for (const { worker, spend } of rows) {
|
|
144
|
+
const visual = dollars ? bar(spend.usd, max, barWidth, "$", color, "magenta") : stackedTokenBar(spend.tokensInput, spend.tokensOutput, max, barWidth, color);
|
|
145
|
+
out.push(` ${pad(worker.label, 12)} ${visual} ${label(spend)}`);
|
|
146
|
+
}
|
|
147
|
+
if (rows.length === 0) out.push(` no worker ${dollars ? "cost" : "tokens"} yet`);
|
|
154
148
|
return out;
|
|
155
149
|
}
|
|
156
150
|
function renderLatencyHistogram(supervisor, width, color) {
|
|
@@ -172,7 +166,7 @@ function renderDetail(supervisor, worker, mode, width, color) {
|
|
|
172
166
|
const spend = totalSpend(worker);
|
|
173
167
|
return [
|
|
174
168
|
`worker ${paint(worker.label, "bold", color)} (${worker.id}) ${statusText(worker.status, color)} latency ${formatDuration(worker.latencyMs)}`,
|
|
175
|
-
`tokens in/out ${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)} cost ${formatMoney(spend.usd)} iterations ${spend.iterations}`,
|
|
169
|
+
`tokens in/out ${formatTokens(spend.tokensInput, spend.tokensKnown)}/${formatTokens(spend.tokensOutput, spend.tokensKnown)} cost ${formatMoney(spend.usd, spend.usdKnown)} iterations ${spend.iterations}`,
|
|
176
170
|
`parent ${worker.parent ?? "-"} runtime ${worker.runtime ?? "-"} out ${worker.outRef ?? "-"}${worker.infra ? " infra" : ""}`,
|
|
177
171
|
`events ${compact(worker.eventFile ?? "-", width - 8)}`,
|
|
178
172
|
...worker.reason ? [`reason ${compact(worker.reason, width - 7)}`] : [],
|
|
@@ -198,17 +192,9 @@ function renderJournalTail(supervisor, width, color) {
|
|
|
198
192
|
return supervisor.journalTail.map((event) => {
|
|
199
193
|
const at = event.at ? formatClock(event.at) : "--:--:--";
|
|
200
194
|
if (event.kind === "spawned") return ` ${at} ${paint("spawn", "yellow", color)} ${pad(event.label ?? event.id, 16)} ${event.id}`;
|
|
201
|
-
if (event.kind
|
|
202
|
-
const spend = parseSpend(event.spent);
|
|
203
|
-
return ` ${at} ${statusText(event.status ?? "settled", color)} ${pad(event.id, 18)} ${formatMoney(spend.usd)} ${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)}`;
|
|
204
|
-
}
|
|
205
|
-
if (event.kind === "metered") {
|
|
206
|
-
const spend = parseSpend(event.spend);
|
|
207
|
-
return ` ${at} ${paint("meter", "cyan", color)} ${pad(event.id, 18)} ${formatMoney(spend.usd)} ${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)}`;
|
|
208
|
-
}
|
|
209
|
-
if (event.kind === "progress") {
|
|
210
|
-
const spend = parseSpend(event.spend);
|
|
211
|
-
return ` ${at} ${paint("live", "blue", color)} ${pad(event.id, 18)} ${formatMoney(spend.usd)} ${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)}`;
|
|
195
|
+
if (event.kind !== "cancelled") {
|
|
196
|
+
const spend = parseSpend(event.kind === "settled" ? event.spent : event.spend);
|
|
197
|
+
return ` ${at} ${event.kind === "settled" ? statusText(event.status ?? "settled", color) : event.kind === "metered" ? `${paint("meter", "cyan", color)} ` : `${paint("live", "blue", color)} `} ${pad(event.id, 18)} ${formatMoney(spend.usd, spend.usdKnown)} ${formatTokens(spend.tokensInput, spend.tokensKnown)}/${formatTokens(spend.tokensOutput, spend.tokensKnown)}`;
|
|
212
198
|
}
|
|
213
199
|
return ` ${at} ${paint("cancel", "red", color)} ${pad(event.id, 18)} ${compact(event.reason ?? "", width - 32)}`;
|
|
214
200
|
});
|
|
@@ -309,31 +295,22 @@ function statusText(status, color) {
|
|
|
309
295
|
].includes(status)) return paint(status.toUpperCase(), "yellow", color);
|
|
310
296
|
return paint(status.toUpperCase(), "white", color);
|
|
311
297
|
}
|
|
312
|
-
function
|
|
313
|
-
|
|
314
|
-
const found = snapshot.supervisors.find((supervisor) => supervisor.id === requested);
|
|
315
|
-
if (found) return found;
|
|
316
|
-
}
|
|
317
|
-
return snapshot.supervisors[0];
|
|
318
|
-
}
|
|
319
|
-
function selectWorker(supervisor, requested) {
|
|
320
|
-
if (requested) {
|
|
321
|
-
const found = supervisor.workers.find((worker) => worker.id === requested);
|
|
322
|
-
if (found) return found;
|
|
323
|
-
}
|
|
324
|
-
return supervisor.workers[0];
|
|
298
|
+
function selectEntity(entities, requested) {
|
|
299
|
+
return (requested ? entities.find((entity) => entity.id === requested) : void 0) ?? entities[0];
|
|
325
300
|
}
|
|
326
301
|
function formatClock(value) {
|
|
327
302
|
const parsed = parseTime(value);
|
|
328
303
|
if (parsed === void 0) return "--:--:--";
|
|
329
304
|
return new Date(parsed).toISOString().slice(11, 19);
|
|
330
305
|
}
|
|
331
|
-
function formatMoney(value) {
|
|
306
|
+
function formatMoney(value, known = true) {
|
|
307
|
+
if (!known) return value === 0 ? "unknown" : `≥${formatMoney(value)} + unknown`;
|
|
332
308
|
if (value === 0) return "$0";
|
|
333
309
|
if (Math.abs(value) < .01) return `$${value.toFixed(4)}`;
|
|
334
310
|
return `$${value.toFixed(2)}`;
|
|
335
311
|
}
|
|
336
|
-
function formatTokens(value) {
|
|
312
|
+
function formatTokens(value, known = true) {
|
|
313
|
+
if (!known) return value === 0 ? "?" : `≥${formatTokens(value)}?`;
|
|
337
314
|
if (value >= 1e6) return `${(value / 1e6).toFixed(1)}m`;
|
|
338
315
|
if (value >= 1e3) return `${(value / 1e3).toFixed(1)}k`;
|
|
339
316
|
return `${Math.round(value)}`;
|
|
@@ -374,29 +351,22 @@ function fitAnsi(value, width) {
|
|
|
374
351
|
if (visibleLength(value) <= width) return value;
|
|
375
352
|
let out = "";
|
|
376
353
|
let visible = 0;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
if (visible >= width - 1) {
|
|
389
|
-
out += "~";
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
out += ch;
|
|
393
|
-
visible += 1;
|
|
354
|
+
let cursor = 0;
|
|
355
|
+
for (const match of value.matchAll(ansiPattern)) {
|
|
356
|
+
const text = value.slice(cursor, match.index);
|
|
357
|
+
const remaining = width - 1 - visible;
|
|
358
|
+
out += text.slice(0, remaining);
|
|
359
|
+
visible += Math.min(text.length, remaining);
|
|
360
|
+
if (text.length > remaining) break;
|
|
361
|
+
out += match[0];
|
|
362
|
+
cursor = match.index + match[0].length;
|
|
394
363
|
}
|
|
364
|
+
if (visible < width - 1) out += value.slice(cursor, cursor + width - 1 - visible);
|
|
365
|
+
out += "~";
|
|
395
366
|
if (out.includes("\x1B[") && !out.endsWith(colors.reset)) out += colors.reset;
|
|
396
367
|
return out;
|
|
397
368
|
}
|
|
398
|
-
|
|
399
|
-
//#region src/tui/top-app.ts
|
|
369
|
+
// src/tui/top-app.ts
|
|
400
370
|
/**
|
|
401
371
|
* The interactive side of the supervisor-run TUI: a keypress/mouse loop over the frames
|
|
402
372
|
* `./top-frame` renders, plus the operator controls that write back to the run — steer a live
|
|
@@ -458,8 +428,9 @@ function runTopApp(options = {}) {
|
|
|
458
428
|
start();
|
|
459
429
|
}
|
|
460
430
|
function initialState(args, cwd) {
|
|
431
|
+
const rootArg = args.find((arg) => !arg.startsWith("-"));
|
|
461
432
|
return {
|
|
462
|
-
root: resolve(
|
|
433
|
+
root: resolve(rootArg ?? cwd),
|
|
463
434
|
color: Boolean(process.stdout.isTTY) && !args.includes("--no-color"),
|
|
464
435
|
focus: args.includes("--detail") ? "workers" : "supervisors",
|
|
465
436
|
mode: args.includes("--log") ? "log" : args.includes("--detail") ? "detail" : "overview",
|
|
@@ -711,8 +682,7 @@ function requestCancel() {
|
|
|
711
682
|
function wrap(value, size) {
|
|
712
683
|
return (value % size + size) % size;
|
|
713
684
|
}
|
|
714
|
-
|
|
715
|
-
//#region src/tui/bin.ts
|
|
685
|
+
// src/tui/bin.ts
|
|
716
686
|
/**
|
|
717
687
|
* `agent-runtime-top` — watch the supervisor runs of one workspace.
|
|
718
688
|
*
|
|
@@ -725,7 +695,6 @@ function wrap(value, size) {
|
|
|
725
695
|
* @experimental
|
|
726
696
|
*/
|
|
727
697
|
runTopApp();
|
|
728
|
-
//#endregion
|
|
729
698
|
export {};
|
|
730
699
|
|
|
731
700
|
//# sourceMappingURL=bin.js.map
|
package/dist/tui/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","names":[],"sources":["../../src/tui/top-frame.ts","../../src/tui/top-app.ts","../../src/tui/bin.ts"],"sourcesContent":["import { supervisorRunsRoot } from '../runtime/supervise/run-layout'\nimport {\n aggregateSnapshot,\n numberValue,\n parseSpend,\n parseTime,\n type SupervisorView,\n type TopSnapshot,\n totalSpend,\n type WorkerView,\n} from './top-snapshot'\n\ninterface RenderOptions {\n readonly width?: number\n readonly height?: number\n readonly color?: boolean\n readonly selectedSupervisorId?: string\n readonly selectedWorkerId?: string\n readonly focus?: 'supervisors' | 'workers'\n readonly mode?: 'overview' | 'detail' | 'log'\n readonly notice?: string\n readonly steerInput?: {\n readonly active: boolean\n readonly value: string\n readonly workerLabel?: string\n }\n}\n\nexport interface RenderTarget {\n readonly row: number\n readonly kind: 'supervisor' | 'worker'\n readonly id: string\n readonly supervisorId?: string\n}\n\ninterface RenderedTopFrame {\n readonly frame: string\n readonly targets: RenderTarget[]\n}\n// Width accounting depends on stripping SGR sequences, which begin with a literal ESC. Matching\n// the control character is the point of an ANSI-aware renderer, not an accident.\n// biome-ignore lint/suspicious/noControlCharactersInRegex: SGR sequences begin with ESC\nconst ansiPattern = /\\x1b\\[[0-9;?]*[ -/]*[@-~]/g\n\nconst colors = {\n reset: '\\x1b[0m',\n dim: '\\x1b[2m',\n bold: '\\x1b[1m',\n red: '\\x1b[31m',\n green: '\\x1b[32m',\n yellow: '\\x1b[33m',\n blue: '\\x1b[34m',\n magenta: '\\x1b[35m',\n cyan: '\\x1b[36m',\n white: '\\x1b[37m',\n inverse: '\\x1b[7m',\n}\n\n/** Render one snapshot to an ANSI frame. Use this when nothing needs to be clickable. */\nexport function renderTopFrame(snapshot: TopSnapshot, options: RenderOptions = {}): string {\n return renderTopFrameWithLayout(snapshot, options).frame\n}\n\n/**\n * Render one snapshot, returning the frame together with the row→entity map a mouse click resolves\n * against. The layout is the only thing that knows which row is which run or worker, so emitting it\n * alongside the text is what keeps click handling out of the renderer.\n */\nexport function renderTopFrameWithLayout(\n snapshot: TopSnapshot,\n options: RenderOptions = {},\n): RenderedTopFrame {\n const width = Math.max(88, options.width ?? 128)\n const height = Math.max(24, options.height ?? 42)\n const color = options.color ?? false\n const focus = options.focus ?? 'supervisors'\n const mode = options.mode ?? 'overview'\n const selectedSupervisor = selectSupervisor(snapshot, options.selectedSupervisorId)\n const selectedWorker = selectedSupervisor\n ? selectWorker(selectedSupervisor, options.selectedWorkerId)\n : undefined\n const targets: RenderTarget[] = []\n const lines: string[] = []\n\n const push = (line = '', target?: Omit<RenderTarget, 'row'>) => {\n if (lines.length >= height) return\n if (target) targets.push({ row: lines.length, ...target })\n lines.push(fitAnsi(line, width))\n }\n\n const aggregate = aggregateSnapshot(snapshot)\n push(\n `${paint('SUPERVISOR TOP', 'bold', color)} ${paint(snapshot.root, 'dim', color)} ` +\n `runs ${aggregate.supervisors} workers ${aggregate.workers} live ${aggregate.running} ` +\n `done ${aggregate.done} down ${aggregate.down} ` +\n `${formatMoney(aggregate.usd)} tok ${formatTokens(aggregate.tokensInput)}/${formatTokens(aggregate.tokensOutput)}`,\n )\n push(\n `${paint('keys', 'dim', color)} up/down select left/right run tab focus enter detail o overview l log s steer c cancel mouse q quit`,\n )\n if (options.notice) push(paint(options.notice, 'yellow', color))\n if (snapshot.completeness === 'partial')\n push(\n paint(\n `partial snapshot: ${snapshot.diagnostics.length} source${\n snapshot.diagnostics.length === 1 ? '' : 's'\n } skipped or truncated; runs loaded ${snapshot.loaded}/${snapshot.discovered}`,\n 'yellow',\n color,\n ),\n )\n if (options.steerInput?.active) push(renderSteerInput(options.steerInput, width, color))\n push(rule(width, color))\n\n if (snapshot.supervisors.length === 0) {\n if (snapshot.discovered > 0) {\n push(paint('NO READABLE SUPERVISORS', 'yellow', color))\n push(\n `${snapshot.discovered} run director${snapshot.discovered === 1 ? 'y' : 'ies'} found under ${supervisorRunsRoot(snapshot.root)}, none readable`,\n )\n } else {\n push(paint('NO SUPERVISORS', 'yellow', color))\n push(`No run state under ${supervisorRunsRoot(snapshot.root)}`)\n }\n push(\n `A run appears here once its driver writes state.json; re-point with: agent-runtime-top <root>`,\n )\n return { frame: `${lines.join('\\n')}\\n`, targets }\n }\n\n push(sectionTitle('SUPERVISORS', focus === 'supervisors', color))\n push(\n ` id status workers spend tok in/out latency task`,\n )\n for (const supervisor of snapshot.supervisors.slice(0, 9)) {\n const selected = supervisor.id === selectedSupervisor?.id\n const status = statusText(supervisor.status, color)\n const pointer = selected ? paint('>', 'cyan', color) : ' '\n const rowFocus = selected && focus === 'supervisors' ? 'inverse' : undefined\n const workerSummary = `${supervisor.totals.running}/${supervisor.totals.workers} live`\n const task = compact(supervisor.task, 34)\n const line =\n `${pointer} ${pad(supervisor.id, 21)} ${pad(status, 12)} ${pad(workerSummary, 13)} ` +\n `${pad(formatMoney(supervisor.totals.usd), 12)} ` +\n `${pad(`${formatTokens(supervisor.totals.tokensInput)}/${formatTokens(supervisor.totals.tokensOutput)}`, 16)} ` +\n `${pad(formatDuration(supervisor.totals.latencyMs), 12)} ${task}`\n push(rowFocus ? paint(line, rowFocus, color) : line, { kind: 'supervisor', id: supervisor.id })\n }\n\n if (!selectedSupervisor) return { frame: `${lines.join('\\n')}\\n`, targets }\n\n push()\n push(sectionTitle(`WORKERS ${selectedSupervisor.id}`, focus === 'workers', color))\n push(\n ` id state runtime latency cost tok in/out score detail`,\n )\n for (const worker of selectedSupervisor.workers.slice(0, 12)) {\n const selected = worker.id === selectedWorker?.id\n const pointer = selected ? paint('>', 'cyan', color) : ' '\n const rowFocus = selected && focus === 'workers' ? 'inverse' : undefined\n const score = worker.verdict ?? (worker.status === 'done' ? 'done' : worker.status)\n const detail = worker.reason ?? worker.outRef ?? worker.parent ?? ''\n const spend = totalSpend(worker)\n const line =\n `${pointer} ${pad(worker.label, 12)} ${pad(statusText(worker.status, color), 12)} ` +\n `${pad(worker.runtime ?? '-', 10)} ${pad(formatDuration(worker.latencyMs), 12)} ` +\n `${pad(formatMoney(spend.usd), 11)} ` +\n `${pad(`${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)}`, 16)} ` +\n `${pad(compact(score, 9), 10)} ${compact(detail, 30)}`\n push(rowFocus ? paint(line, rowFocus, color) : line, {\n kind: 'worker',\n id: worker.id,\n supervisorId: selectedSupervisor.id,\n })\n }\n if (selectedSupervisor.workers.length === 0) push(' no workers spawned yet')\n\n push()\n push(sectionTitle('OBSERVABILITY', false, color))\n for (const line of renderStatusBars(selectedSupervisor, width, color)) push(line)\n push()\n for (const line of renderCostBars(selectedSupervisor, width, color)) push(line)\n push()\n for (const line of renderTokenBars(selectedSupervisor, width, color)) push(line)\n push()\n for (const line of renderLatencyHistogram(selectedSupervisor, width, color)) push(line)\n\n push()\n if (mode === 'log') {\n push(sectionTitle('JOURNAL TAIL', false, color))\n for (const line of renderJournalTail(selectedSupervisor, width, color)) push(line)\n } else {\n push(sectionTitle(mode === 'detail' ? 'DETAIL' : 'RUN SUMMARY', false, color))\n for (const line of renderDetail(selectedSupervisor, selectedWorker, mode, width, color))\n push(line)\n }\n\n return { frame: `${lines.join('\\n')}\\n`, targets }\n}\n\nfunction renderStatusBars(supervisor: SupervisorView, width: number, color: boolean): string[] {\n const total = Math.max(1, supervisor.totals.workers)\n const barWidth = Math.max(12, Math.min(28, width - 58))\n return [\n `status ` +\n `${pad('running', 9)} ${bar(supervisor.totals.running, total, barWidth, '#', color, 'yellow')} ${supervisor.totals.running}` +\n ` ${pad('done', 5)} ${bar(supervisor.totals.done, total, barWidth, '#', color, 'green')} ${supervisor.totals.done}` +\n ` ${pad('down', 5)} ${bar(supervisor.totals.down, total, barWidth, '#', color, 'red')} ${supervisor.totals.down}`,\n ]\n}\n\nfunction renderCostBars(supervisor: SupervisorView, width: number, color: boolean): string[] {\n const workers = supervisor.workers\n .map((worker) => ({ worker, spend: totalSpend(worker) }))\n .sort((a, b) => b.spend.usd - a.spend.usd)\n .slice(0, 6)\n const maxUsd = Math.max(\n 0.000001,\n ...workers.map((row) => row.spend.usd),\n supervisor.driverSpend.usd,\n )\n const out = [\n `cost total ${formatMoney(supervisor.totals.usd)} driver ${formatMoney(supervisor.driverSpend.usd)}`,\n ]\n const barWidth = Math.max(18, Math.min(46, width - 38))\n for (const row of workers) {\n out.push(\n ` ${pad(row.worker.label, 12)} ${bar(row.spend.usd, maxUsd, barWidth, '$', color, 'magenta')} ${formatMoney(row.spend.usd)}`,\n )\n }\n if (workers.length === 0) out.push(' no worker cost yet')\n return out\n}\n\nfunction renderTokenBars(supervisor: SupervisorView, width: number, color: boolean): string[] {\n const rows = supervisor.workers\n .map((worker) => ({\n worker,\n spend: totalSpend(worker),\n total: totalSpend(worker).tokensInput + totalSpend(worker).tokensOutput,\n }))\n .sort((a, b) => b.total - a.total)\n .slice(0, 6)\n const maxTokens = Math.max(\n 1,\n ...rows.map((row) => row.total),\n supervisor.driverSpend.tokensInput + supervisor.driverSpend.tokensOutput,\n )\n const out = [\n `tokens total in ${formatTokens(supervisor.totals.tokensInput)} / out ${formatTokens(supervisor.totals.tokensOutput)} ` +\n `driver ${formatTokens(supervisor.driverSpend.tokensInput)}/${formatTokens(supervisor.driverSpend.tokensOutput)}`,\n ]\n const barWidth = Math.max(18, Math.min(46, width - 44))\n for (const row of rows) {\n out.push(\n ` ${pad(row.worker.label, 12)} ${stackedTokenBar(row.spend.tokensInput, row.spend.tokensOutput, maxTokens, barWidth, color)} ` +\n `${formatTokens(row.spend.tokensInput)}/${formatTokens(row.spend.tokensOutput)}`,\n )\n }\n if (rows.length === 0) out.push(' no worker tokens yet')\n return out\n}\n\nfunction renderLatencyHistogram(\n supervisor: SupervisorView,\n width: number,\n color: boolean,\n): string[] {\n const values = supervisor.workers.map((worker) => worker.latencyMs).filter((value) => value > 0)\n const summary = supervisor.totals.workerLatency\n const out = [\n `latency n=${summary.n} min ${formatDuration(summary.min)} p50 ${formatDuration(summary.median)} ` +\n `p90 ${formatDuration(summary.p90)} max ${formatDuration(summary.max)}`,\n ]\n if (values.length === 0) {\n out.push(' no latency samples yet')\n return out\n }\n const bins = histogram(values, 6)\n const maxCount = Math.max(1, ...bins.map((bin) => bin.count))\n const barWidth = Math.max(18, Math.min(48, width - 34))\n for (const bin of bins) {\n out.push(\n ` ${pad(`${formatDuration(bin.min)}-${formatDuration(bin.max)}`, 15)} ` +\n `${bar(bin.count, maxCount, barWidth, '#', color, 'blue')} ${bin.count}`,\n )\n }\n return out\n}\n\nfunction renderDetail(\n supervisor: SupervisorView,\n worker: WorkerView | undefined,\n mode: 'overview' | 'detail' | 'log',\n width: number,\n color: boolean,\n): string[] {\n if (mode === 'detail' && worker) {\n const spend = totalSpend(worker)\n return [\n `worker ${paint(worker.label, 'bold', color)} (${worker.id}) ${statusText(worker.status, color)} latency ${formatDuration(worker.latencyMs)}`,\n `tokens in/out ${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)} cost ${formatMoney(spend.usd)} iterations ${spend.iterations}`,\n `parent ${worker.parent ?? '-'} runtime ${worker.runtime ?? '-'} out ${worker.outRef ?? '-'}${worker.infra ? ' infra' : ''}`,\n `events ${compact(worker.eventFile ?? '-', width - 8)}`,\n ...(worker.reason ? [`reason ${compact(worker.reason, width - 7)}`] : []),\n ...renderWorkerTail(worker, width, color),\n ]\n }\n\n const caps = [\n supervisor.maxSandboxes !== undefined ? `boxes ${supervisor.maxSandboxes}` : undefined,\n supervisor.maxUsd !== undefined ? `max ${formatMoney(supervisor.maxUsd)}` : undefined,\n supervisor.maxDepth !== undefined ? `depth ${supervisor.maxDepth}` : undefined,\n supervisor.maxLifetimeSeconds !== undefined\n ? `ttl ${supervisor.maxLifetimeSeconds}s`\n : undefined,\n ].filter((value): value is string => value !== undefined)\n return [\n `task ${compact(supervisor.task, width - 7)}`,\n `workspace ${compact(supervisor.workspaceDir, width - 12)}`,\n `verify ${compact(supervisor.verifyCmd ?? '-', width - 9)}`,\n `models worker ${supervisor.workerModel ?? '-'} / driver ${supervisor.driverModel ?? '-'} caps ${caps.join(' | ') || '-'}`,\n `progress ${compact(supervisor.progress ?? supervisor.verdict ?? supervisor.status, width - 10)}`,\n ]\n}\n\nfunction renderJournalTail(supervisor: SupervisorView, width: number, color: boolean): string[] {\n if (supervisor.journalTail.length === 0) return [' no journal events yet']\n return supervisor.journalTail.map((event) => {\n const at = event.at ? formatClock(event.at) : '--:--:--'\n if (event.kind === 'spawned')\n return ` ${at} ${paint('spawn', 'yellow', color)} ${pad(event.label ?? event.id, 16)} ${event.id}`\n if (event.kind === 'settled') {\n const spend = parseSpend(event.spent)\n return ` ${at} ${statusText(event.status ?? 'settled', color)} ${pad(event.id, 18)} ${formatMoney(spend.usd)} ${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)}`\n }\n if (event.kind === 'metered') {\n const spend = parseSpend(event.spend)\n return ` ${at} ${paint('meter', 'cyan', color)} ${pad(event.id, 18)} ${formatMoney(spend.usd)} ${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)}`\n }\n if (event.kind === 'progress') {\n const spend = parseSpend(event.spend)\n return ` ${at} ${paint('live', 'blue', color)} ${pad(event.id, 18)} ${formatMoney(spend.usd)} ${formatTokens(spend.tokensInput)}/${formatTokens(spend.tokensOutput)}`\n }\n return ` ${at} ${paint('cancel', 'red', color)} ${pad(event.id, 18)} ${compact(event.reason ?? '', width - 32)}`\n })\n}\n\nfunction renderWorkerTail(worker: WorkerView, width: number, color: boolean): string[] {\n if (worker.liveTail.length === 0) return ['live events: none recorded yet']\n return [\n 'live events:',\n ...worker.liveTail\n .slice(-5)\n .map((line) => ` ${paint(compact(formatWorkerEvent(line), width - 2), 'dim', color)}`),\n ]\n}\n\nfunction renderSteerInput(\n input: NonNullable<RenderOptions['steerInput']>,\n width: number,\n color: boolean,\n): string {\n const target = input.workerLabel ?? '-'\n const value = compact(input.value, Math.max(10, width - target.length - 14))\n return `${paint('steer', 'cyan', color)} ${target} > ${value}${paint('_', 'inverse', color)}`\n}\n\nfunction formatWorkerEvent(line: string): string {\n try {\n const parsed = JSON.parse(line) as Record<string, unknown>\n const at = typeof parsed.at === 'string' ? formatClock(parsed.at) : '--:--:--'\n const kind = typeof parsed.kind === 'string' ? parsed.kind : 'event'\n if (kind === 'progress')\n return `${at} progress iter ${numberValue(parsed.iteration)} ${String(parsed.phase ?? '')}`\n if (kind === 'message') {\n const state = parsed.queued === true ? 'queued' : 'sent'\n const source =\n typeof parsed.source === 'string' && parsed.source.length > 0 ? `${parsed.source} ` : ''\n const message =\n typeof parsed.message === 'string' && parsed.message.length > 0 ? ` ${parsed.message}` : ''\n return `${at} ${source}steer ${state} delivered=${String(parsed.delivered)}${message}`\n }\n if (kind === 'verify') {\n return `${at} verify passed=${String(parsed.passed)} exit=${String(parsed.exitCode ?? '-')}${evidenceSnippet(parsed.outputTail, 160)}`\n }\n if (kind === 'finished') {\n const branch = typeof parsed.branch === 'string' ? ` branch=${parsed.branch}` : ''\n const files = typeof parsed.filesChanged === 'number' ? ` files=${parsed.filesChanged}` : ''\n const tests =\n typeof parsed.testPassed === 'boolean' ? ` tests=${String(parsed.testPassed)}` : ''\n return `${at} finished passed=${String(parsed.passed)} patchBytes=${numberValue(parsed.patchBytes)}${files}${tests}${branch}${evidenceSnippet(parsed.evidence, 220)}`\n }\n if (kind === 'error') return `${at} error ${String(parsed.error ?? '')}`\n return `${at} ${kind}`\n } catch {\n return line\n }\n}\n\n/** One-line the settle evidence / verify tail a worker event carries so the\n * failure is legible in the tail view (the full block stays in the ndjson). */\nfunction evidenceSnippet(value: unknown, max: number): string {\n if (typeof value !== 'string') return ''\n const oneLine = value.replace(/\\s+/g, ' ').trim()\n return oneLine ? ` :: ${compact(oneLine, max)}` : ''\n}\n\nfunction histogram(\n values: readonly number[],\n count: number,\n): Array<{ min: number; max: number; count: number }> {\n const min = Math.min(...values)\n const max = Math.max(...values)\n if (min === max) return [{ min, max, count: values.length }]\n const step = (max - min) / count\n return Array.from({ length: count }, (_, index) => {\n const low = min + step * index\n const high = index === count - 1 ? max : min + step * (index + 1)\n const binCount = values.filter(\n (value) => value >= low && (index === count - 1 ? value <= high : value < high),\n ).length\n return { min: low, max: high, count: binCount }\n }).filter((bin) => bin.count > 0)\n}\n\nfunction bar(\n value: number,\n max: number,\n width: number,\n ch: string,\n color: boolean,\n colorName: keyof typeof colors,\n): string {\n const filled = Math.max(0, Math.min(width, Math.round((value / Math.max(max, 0.000001)) * width)))\n const text = ch.repeat(filled).padEnd(width, '.')\n return paint(text, colorName, color)\n}\n\nfunction stackedTokenBar(\n input: number,\n output: number,\n max: number,\n width: number,\n color: boolean,\n): string {\n const inputWidth = Math.round((input / Math.max(max, 1)) * width)\n const outputWidth = Math.round((output / Math.max(max, 1)) * width)\n const clippedInput = Math.min(width, inputWidth)\n const clippedOutput = Math.min(width - clippedInput, outputWidth)\n const rest = Math.max(0, width - clippedInput - clippedOutput)\n return `${paint('#'.repeat(clippedInput), 'cyan', color)}${paint('+'.repeat(clippedOutput), 'green', color)}${'.'.repeat(rest)}`\n}\n\nfunction sectionTitle(title: string, focused: boolean, color: boolean): string {\n const text = focused ? `[${title}]` : title\n return paint(text, focused ? 'cyan' : 'bold', color)\n}\n\nfunction statusText(status: string, color: boolean): string {\n if (['completed', 'done', 'delivered', 'valid'].includes(status))\n return paint(status.toUpperCase(), 'green', color)\n if (['failed', 'down', 'cancelled', 'invalid', 'error'].includes(status))\n return paint(status.toUpperCase(), 'red', color)\n if (['running', 'spawned', 'settled'].includes(status))\n return paint(status.toUpperCase(), 'yellow', color)\n return paint(status.toUpperCase(), 'white', color)\n}\n\nfunction selectSupervisor(\n snapshot: TopSnapshot,\n requested: string | undefined,\n): SupervisorView | undefined {\n if (requested) {\n const found = snapshot.supervisors.find((supervisor) => supervisor.id === requested)\n if (found) return found\n }\n return snapshot.supervisors[0]\n}\n\nfunction selectWorker(\n supervisor: SupervisorView,\n requested: string | undefined,\n): WorkerView | undefined {\n if (requested) {\n const found = supervisor.workers.find((worker) => worker.id === requested)\n if (found) return found\n }\n return supervisor.workers[0]\n}\n\nfunction formatClock(value: string): string {\n const parsed = parseTime(value)\n if (parsed === undefined) return '--:--:--'\n return new Date(parsed).toISOString().slice(11, 19)\n}\n\nfunction formatMoney(value: number): string {\n if (value === 0) return '$0'\n if (Math.abs(value) < 0.01) return `$${value.toFixed(4)}`\n return `$${value.toFixed(2)}`\n}\n\nfunction formatTokens(value: number): string {\n if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}m`\n if (value >= 1_000) return `${(value / 1_000).toFixed(1)}k`\n return `${Math.round(value)}`\n}\n\nfunction formatDuration(ms: number): string {\n if (!Number.isFinite(ms) || ms <= 0) return '0s'\n if (ms < 1000) return `${Math.round(ms)}ms`\n const seconds = ms / 1000\n if (seconds < 60) return `${seconds.toFixed(seconds < 10 ? 1 : 0)}s`\n const minutes = seconds / 60\n if (minutes < 60) return `${minutes.toFixed(minutes < 10 ? 1 : 0)}m`\n return `${(minutes / 60).toFixed(1)}h`\n}\n\nfunction compact(value: string, width: number): string {\n if (width <= 1) return ''\n if (value.length <= width) return value\n return `${value.slice(0, width - 1)}~`\n}\n\nfunction pad(value: string, width: number): string {\n const visible = visibleLength(value)\n if (visible >= width) return fitAnsi(value, width)\n return `${value}${' '.repeat(width - visible)}`\n}\n\nfunction rule(width: number, color: boolean): string {\n return paint('-'.repeat(width), 'dim', color)\n}\n\nfunction paint(\n value: string,\n colorName: keyof typeof colors | undefined,\n enabled: boolean,\n): string {\n if (!enabled || !colorName) return value\n return `${colors[colorName]}${value}${colors.reset}`\n}\n\nfunction visibleLength(value: string): number {\n return stripAnsi(value).length\n}\n\nfunction stripAnsi(value: string): string {\n return value.replace(ansiPattern, '')\n}\n\nfunction fitAnsi(value: string, width: number): string {\n if (visibleLength(value) <= width) return value\n let out = ''\n let visible = 0\n for (let i = 0; i < value.length; i += 1) {\n const ch = value[i]\n if (ch === '\\x1b') {\n const rest = value.slice(i)\n // An escape sequence must be copied whole and counted as zero visible columns; truncating\n // inside one would emit a half-sequence the terminal interprets against the next line.\n // biome-ignore lint/suspicious/noControlCharactersInRegex: SGR sequences begin with ESC\n const match = /^\\x1b\\[[0-9;?]*[ -/]*[@-~]/.exec(rest)\n if (match) {\n out += match[0]\n i += match[0].length - 1\n continue\n }\n }\n if (visible >= width - 1) {\n out += '~'\n break\n }\n out += ch\n visible += 1\n }\n if (out.includes('\\x1b[') && !out.endsWith(colors.reset)) out += colors.reset\n return out\n}\n","/**\n * The interactive side of the supervisor-run TUI: a keypress/mouse loop over the frames\n * `./top-frame` renders, plus the operator controls that write back to the run — steer a live\n * worker, cancel one worker, and request cancellation of a whole run.\n *\n * The controls go through the owned run layout: steers via `writeWorkerSteer` (the durable inbox\n * append) and worker cancellation via `cancelWorker` (the acknowledged operation the runtime's\n * turn loop applies). Run-level cancellation targets the ROOT, which has no acknowledged runtime\n * path yet for a non-retained tree — it stays a `cancel.request.json` write inside the run\n * directory for a host process to honor. Nothing here joins a path from the workspace root.\n *\n * Extracted from the `loops` repo (`src/top.ts`). The module-level singletons are the origin's\n * shape and are kept: this drives one terminal, and `runTopApp` is its one entry point.\n *\n * @experimental\n */\n\nimport { randomUUID } from 'node:crypto'\nimport { hostname, userInfo } from 'node:os'\nimport { resolve } from 'node:path'\nimport { emitKeypressEvents } from 'node:readline'\nimport { cancelRun } from '../runtime/supervise/run-cancellation'\nimport { cancelWorker, writeWorkerSteer } from '../runtime/supervise/run-layout'\nimport { type RenderTarget, renderTopFrameWithLayout } from './top-frame'\nimport { loadTopSnapshot, type TopSnapshot } from './top-snapshot'\n\ninterface UiState {\n root: string\n color: boolean\n focus: 'supervisors' | 'workers'\n mode: 'overview' | 'detail' | 'log'\n selectedSupervisorId: string | undefined\n selectedWorkerId: string | undefined\n notice: string | undefined\n steerInput: {\n active: boolean\n value: string\n }\n}\n\n/** @experimental How the app was invoked. Defaults read `process.argv` / `process.cwd()`. */\ninterface TopAppOptions {\n readonly argv?: readonly string[]\n readonly cwd?: string\n}\n\nlet state: UiState = initialState([], process.cwd())\nlet snapshot: TopSnapshot = {\n root: state.root,\n generatedAt: 0,\n supervisors: [],\n completeness: 'complete',\n diagnostics: [],\n discovered: 0,\n loaded: 0,\n}\nlet targets: RenderTarget[] = []\nlet timer: NodeJS.Timeout | undefined\n\n/**\n * Render exactly one frame and return it. This is the non-interactive path — `--once`, a pipe, a\n * test — so it never touches raw mode, the alternate screen, or `process.exit`.\n */\nfunction renderTopOnce(options: TopAppOptions = {}): string {\n const args = [...(options.argv ?? process.argv.slice(2))]\n state = initialState(args, options.cwd ?? process.cwd())\n snapshot = loadTopSnapshot(state.root)\n clampSelection()\n return renderTopFrameWithLayout(snapshot, {\n color: state.color,\n width: process.stdout.columns ?? 128,\n focus: state.focus,\n mode: state.mode,\n ...(state.selectedSupervisorId ? { selectedSupervisorId: state.selectedSupervisorId } : {}),\n ...(state.selectedWorkerId ? { selectedWorkerId: state.selectedWorkerId } : {}),\n steerInput: renderSteerInputState(),\n }).frame\n}\n\n/**\n * Run the TUI. With a TTY on both ends and no `--once` this takes over the terminal until `q`;\n * otherwise it writes a single frame to stdout and returns.\n */\nexport function runTopApp(options: TopAppOptions = {}): void {\n const args = [...(options.argv ?? process.argv.slice(2))]\n if (!process.stdout.isTTY || !process.stdin.isTTY || args.includes('--once')) {\n process.stdout.write(renderTopOnce(options))\n return\n }\n state = initialState(args, options.cwd ?? process.cwd())\n snapshot = loadTopSnapshot(state.root)\n start()\n}\n\nfunction initialState(args: readonly string[], cwd: string): UiState {\n const rootArg = args.find((arg) => !arg.startsWith('-'))\n return {\n root: resolve(rootArg ?? cwd),\n color: Boolean(process.stdout.isTTY) && !args.includes('--no-color'),\n focus: args.includes('--detail') ? 'workers' : 'supervisors',\n mode: args.includes('--log') ? 'log' : args.includes('--detail') ? 'detail' : 'overview',\n selectedSupervisorId: undefined,\n selectedWorkerId: undefined,\n notice: undefined,\n steerInput: { active: false, value: '' },\n }\n}\n\nfunction start(): void {\n process.stdout.write('\\x1b[?1049h\\x1b[?25l\\x1b[?1000h\\x1b[?1006h')\n emitKeypressEvents(process.stdin)\n process.stdin.setRawMode(true)\n process.stdin.resume()\n process.stdin.on('keypress', onKey)\n process.stdin.on('data', onData)\n process.on('SIGINT', stop)\n draw()\n timer = setInterval(draw, 1000)\n}\n\nfunction stop(): void {\n if (timer) clearInterval(timer)\n process.stdin.setRawMode(false)\n process.stdout.write('\\x1b[?1000l\\x1b[?1006l\\x1b[?25h\\x1b[?1049l')\n process.exit(0)\n}\n\nfunction draw(): void {\n snapshot = loadTopSnapshot(state.root)\n clampSelection()\n const rendered = renderTopFrameWithLayout(snapshot, {\n width: process.stdout.columns ?? 128,\n height: process.stdout.rows ?? 42,\n color: state.color,\n focus: state.focus,\n mode: state.mode,\n ...(state.notice ? { notice: state.notice } : {}),\n ...(state.selectedSupervisorId ? { selectedSupervisorId: state.selectedSupervisorId } : {}),\n ...(state.selectedWorkerId ? { selectedWorkerId: state.selectedWorkerId } : {}),\n steerInput: renderSteerInputState(),\n })\n targets = rendered.targets\n process.stdout.write(`\\x1b[2J\\x1b[H${rendered.frame}`)\n}\n\nfunction onKey(str: string, key: { name?: string; ctrl?: boolean }): void {\n state.notice = undefined\n if (key.ctrl && key.name === 'c') stop()\n if (state.steerInput.active) {\n handleSteerInput(str, key)\n draw()\n return\n }\n if (key.name === 'q' || key.name === 'escape') stop()\n if (key.name === 'tab') {\n state.focus = state.focus === 'supervisors' ? 'workers' : 'supervisors'\n } else if (key.name === 'up') {\n moveSelection(-1)\n } else if (key.name === 'down') {\n moveSelection(1)\n } else if (key.name === 'left') {\n moveSupervisor(-1)\n } else if (key.name === 'right') {\n moveSupervisor(1)\n } else if (key.name === 'return') {\n state.mode = 'detail'\n state.focus = 'workers'\n } else if (key.name === 'o') {\n state.mode = 'overview'\n } else if (key.name === 'l') {\n state.mode = 'log'\n } else if (key.name === 's') {\n startSteerInput()\n } else if (key.name === 'c') {\n requestCancel()\n }\n draw()\n}\n\nfunction handleSteerInput(str: string, key: { name?: string; ctrl?: boolean }): void {\n if (key.name === 'escape') {\n state.steerInput = { active: false, value: '' }\n return\n }\n if (key.name === 'return') {\n submitSteerInput()\n return\n }\n if (key.name === 'backspace') {\n state.steerInput.value = state.steerInput.value.slice(0, -1)\n return\n }\n if (key.ctrl && key.name === 'u') {\n state.steerInput.value = ''\n return\n }\n if (\n key.ctrl ||\n key.name === 'tab' ||\n key.name === 'up' ||\n key.name === 'down' ||\n key.name === 'left' ||\n key.name === 'right'\n ) {\n return\n }\n if (!str || str === '\\r' || str === '\\n') return\n if ([...str].every((char) => char >= ' ' && char !== '\\x7f')) state.steerInput.value += str\n}\n\nfunction onData(data: Buffer): void {\n const click = parseMouse(data.toString('utf8'))\n if (!click) return\n const target = targets.find((candidate) => candidate.row === click.row)\n if (!target) return\n state.notice = undefined\n if (target.kind === 'supervisor') {\n state.focus = 'supervisors'\n state.selectedSupervisorId = target.id\n state.selectedWorkerId = undefined\n } else {\n state.focus = 'workers'\n state.mode = 'detail'\n state.selectedSupervisorId = target.supervisorId\n state.selectedWorkerId = target.id\n }\n draw()\n}\n\nfunction startSteerInput(): void {\n state.mode = 'detail'\n state.focus = 'workers'\n if (!selectedSupervisor()) {\n state.notice = 'no supervisor selected'\n return\n }\n if (!selectedWorker()) {\n state.notice = 'no worker selected'\n return\n }\n state.steerInput = { active: true, value: '' }\n}\n\nfunction submitSteerInput(): void {\n const supervisor = selectedSupervisor()\n const worker = selectedWorker()\n const message = state.steerInput.value\n state.steerInput = { active: false, value: '' }\n if (!supervisor) {\n state.notice = 'no supervisor selected'\n return\n }\n if (!worker) {\n state.notice = 'no worker selected'\n return\n }\n try {\n // The exact worker id routes this operation to the one manager that owns the child.\n const written = writeWorkerSteer(state.root, supervisor.id, worker.id, {\n operationId: randomUUID(),\n message,\n source: 'agent-runtime-top',\n })\n state.notice = `steer queued for ${supervisor.id}/${worker.label} (op ${written.request.operationId})`\n } catch (err) {\n state.notice = `steer failed: ${err instanceof Error ? err.message : String(err)}`\n }\n}\n\nfunction parseMouse(raw: string): { col: number; row: number } | undefined {\n // ESC is the literal first byte of an SGR mouse report; matching the control character IS the\n // parse, so the control-character rule does not apply to a terminal escape decoder.\n // biome-ignore lint/suspicious/noControlCharactersInRegex: SGR mouse reports begin with ESC\n const match = /\\x1b\\[<(\\d+);(\\d+);(\\d+)([mM])/.exec(raw)\n if (match?.[4] !== 'M') return undefined\n const col = Number(match[2])\n const row = Number(match[3])\n if (!Number.isFinite(col) || !Number.isFinite(row)) return undefined\n return { col: col - 1, row: row - 1 }\n}\n\nfunction moveSelection(delta: number): void {\n if (state.focus === 'supervisors') {\n moveSupervisor(delta)\n return\n }\n const supervisor = selectedSupervisor()\n if (!supervisor || supervisor.workers.length === 0) return\n const current = Math.max(\n 0,\n supervisor.workers.findIndex((worker) => worker.id === state.selectedWorkerId),\n )\n const next = wrap(current + delta, supervisor.workers.length)\n const worker = supervisor.workers[next]\n if (worker) state.selectedWorkerId = worker.id\n}\n\nfunction moveSupervisor(delta: number): void {\n if (snapshot.supervisors.length === 0) return\n const current = Math.max(\n 0,\n snapshot.supervisors.findIndex((supervisor) => supervisor.id === state.selectedSupervisorId),\n )\n const next = wrap(current + delta, snapshot.supervisors.length)\n const supervisor = snapshot.supervisors[next]\n if (!supervisor) return\n state.selectedSupervisorId = supervisor.id\n state.selectedWorkerId = supervisor.workers[0]?.id\n}\n\nfunction clampSelection(): void {\n if (snapshot.supervisors.length === 0) {\n state.selectedSupervisorId = undefined\n state.selectedWorkerId = undefined\n return\n }\n const supervisor = selectedSupervisor() ?? snapshot.supervisors[0]\n if (!supervisor) return\n state.selectedSupervisorId = supervisor.id\n const worker =\n supervisor.workers.find((candidate) => candidate.id === state.selectedWorkerId) ??\n supervisor.workers[0]\n state.selectedWorkerId = worker?.id\n}\n\nfunction selectedSupervisor(): TopSnapshot['supervisors'][number] | undefined {\n return snapshot.supervisors.find((supervisor) => supervisor.id === state.selectedSupervisorId)\n}\n\nfunction selectedWorker(): TopSnapshot['supervisors'][number]['workers'][number] | undefined {\n const supervisor = selectedSupervisor()\n return supervisor?.workers.find((worker) => worker.id === state.selectedWorkerId)\n}\n\nfunction renderSteerInputState(): { active: boolean; value: string; workerLabel?: string } {\n const worker = selectedWorker()\n return {\n active: state.steerInput.active,\n value: state.steerInput.value,\n ...(worker?.label ? { workerLabel: worker.label } : {}),\n }\n}\n\nfunction requestCancel(): void {\n const supervisor = selectedSupervisor()\n if (!supervisor) {\n state.notice = 'no supervisor selected'\n return\n }\n if (supervisor.status !== 'running') {\n state.notice = `${supervisor.id} is ${supervisor.status}; no cancel request written`\n return\n }\n // Worker focus cancels ONE worker through the acknowledged runtime path: the request lands in\n // the run layout's cancellation inbox, the run's own turn loop applies the abort to exactly\n // that worker's subtree, and the acknowledgement records what it proved.\n const worker = state.focus === 'workers' ? selectedWorker() : undefined\n if (worker) {\n if (worker.status !== 'running') {\n state.notice = `${worker.label} is ${worker.status}; nothing to cancel`\n return\n }\n // The request names the exact node id, so it routes to the manager that owns the worker at\n // ANY depth — the owning manager's turn loop applies the abort to exactly that subtree.\n try {\n const record = cancelWorker(supervisor.stateDir, worker.id, randomUUID(), {\n reason: 'operator requested cancel from TUI',\n source: 'agent-runtime-top',\n })\n state.notice =\n record.effect === 'unknown'\n ? `cancel queued for ${supervisor.id}/${worker.label} (op ${record.operationId}); awaiting runtime acknowledgement`\n : `cancel ${record.effect} for ${supervisor.id}/${worker.label} (op ${record.operationId})`\n } catch (err) {\n state.notice = `cancel request failed: ${err instanceof Error ? err.message : String(err)}`\n }\n return\n }\n // Supervisor focus cancels the WHOLE run through the same acknowledged contract: the request\n // lands in the run layout, the run's root manager aborts the whole tree through the one cascade\n // controller it already has, and `supervise()` records the terminal effect.\n try {\n const record = cancelRun(supervisor.stateDir, randomUUID(), {\n reason: 'operator requested cancel from TUI',\n source: 'agent-runtime-top',\n operator: `${userInfo().username}@${hostname()}`,\n })\n state.notice =\n record.effect === 'unknown'\n ? `run cancel queued for ${supervisor.id} (op ${record.operationId}); awaiting runtime acknowledgement`\n : `run cancel ${record.effect} for ${supervisor.id} (op ${record.operationId})`\n } catch (err) {\n state.notice = `cancel request failed: ${err instanceof Error ? err.message : String(err)}`\n }\n}\n\nfunction wrap(value: number, size: number): number {\n return ((value % size) + size) % size\n}\n","#!/usr/bin/env node\n\n/**\n * `agent-runtime-top` — watch the supervisor runs of one workspace.\n *\n * agent-runtime-top [root] [--once] [--no-color] [--detail] [--log]\n *\n * `root` is the workspace whose `.agent/supervisor/` runs are shown; it defaults to the current\n * directory. With a TTY on both ends the view refreshes every second and takes the keys it prints\n * in its header; otherwise (a pipe, `--once`) it writes one frame and exits.\n *\n * @experimental\n */\n\nimport { runTopApp } from './top-app'\n\nrunTopApp()\n"],"mappings":";;;;;;;;AA0CA,MAAM,cAAc;AAEpB,MAAM,SAAS;CACb,OAAO;CACP,KAAK;CACL,MAAM;CACN,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,SAAS;AACX;;;;;;AAYA,SAAgB,yBACd,UACA,UAAyB,CAAC,GACR;CAClB,MAAM,QAAQ,KAAK,IAAI,IAAI,QAAQ,SAAS,GAAG;CAC/C,MAAM,SAAS,KAAK,IAAI,IAAI,QAAQ,UAAU,EAAE;CAChD,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,OA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AC/B,MAAM,SAAS,GAAG,OAAO,MAAM,MAAM,OAAO,OAAO;GACnD;EACF;EAGA,IAAI;GACF,MAAM,SAAS,aAAa,WAAW,UAAU,OAAO,IAAI,WAAW,GAAG;IACxE,QAAQ;IACR,QAAQ;GACV,CAAC;GACD,MAAM,SACJ,OAAO,WAAW,YACd,qBAAqB,WAAW,GAAG,GAAG,OAAO,MAAM,OAAO,OAAO,YAAY,uCAC7E,UAAU,OAAO,OAAO,OAAO,WAAW,GAAG,GAAG,OAAO,MAAM,OAAO,OAAO,YAAY;EAC/F,SAAS,KAAK;GACZ,MAAM,SAAS,0BAA0B,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EAC1F;EACA;CACF;CAIA,IAAI;EACF,MAAM,SAAS,UAAU,WAAW,UAAU,WAAW,GAAG;GAC1D,QAAQ;GACR,QAAQ;GACR,UAAU,GAAG,SAAS,CAAC,CAAC,SAAS,GAAG,SAAS;EAC/C,CAAC;EACD,MAAM,SACJ,OAAO,WAAW,YACd,yBAAyB,WAAW,GAAG,OAAO,OAAO,YAAY,uCACjE,cAAc,OAAO,OAAO,OAAO,WAAW,GAAG,OAAO,OAAO,YAAY;CACnF,SAAS,KAAK;EACZ,MAAM,SAAS,0BAA0B,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;CAC1F;AACF;AAEA,SAAS,KAAK,OAAe,MAAsB;CACjD,QAAS,QAAQ,OAAQ,QAAQ;AACnC;;;;;;;;;;;;;;AC9XA,UAAU"}
|
|
1
|
+
{"version":3,"file":"bin.js","names":[],"sources":["../../src/tui/top-frame.ts","../../src/tui/top-app.ts","../../src/tui/bin.ts"],"sourcesContent":["import { supervisorRunsRoot } from '../runtime/supervise/run-layout'\nimport {\n aggregateSnapshot,\n numberValue,\n parseSpend,\n parseTime,\n type SpendStats,\n type SupervisorView,\n type TopSnapshot,\n totalSpend,\n type WorkerView,\n} from './top-snapshot'\n\ninterface RenderOptions {\n readonly width?: number\n readonly height?: number\n readonly color?: boolean\n readonly selectedSupervisorId?: string\n readonly selectedWorkerId?: string\n readonly focus?: 'supervisors' | 'workers'\n readonly mode?: 'overview' | 'detail' | 'log'\n readonly notice?: string\n readonly steerInput?: {\n readonly active: boolean\n readonly value: string\n readonly workerLabel?: string\n }\n}\n\nexport interface RenderTarget {\n readonly row: number\n readonly kind: 'supervisor' | 'worker'\n readonly id: string\n readonly supervisorId?: string\n}\n\ninterface RenderedTopFrame {\n readonly frame: string\n readonly targets: RenderTarget[]\n}\n// Width accounting depends on stripping SGR sequences, which begin with a literal ESC. Matching\n// the control character is the point of an ANSI-aware renderer, not an accident.\n// biome-ignore lint/suspicious/noControlCharactersInRegex: SGR sequences begin with ESC\nconst ansiPattern = /\\x1b\\[[0-9;?]*[ -/]*[@-~]/g\n\nconst colors = {\n reset: '\\x1b[0m',\n dim: '\\x1b[2m',\n bold: '\\x1b[1m',\n red: '\\x1b[31m',\n green: '\\x1b[32m',\n yellow: '\\x1b[33m',\n blue: '\\x1b[34m',\n magenta: '\\x1b[35m',\n cyan: '\\x1b[36m',\n white: '\\x1b[37m',\n inverse: '\\x1b[7m',\n}\n\n/** Render one snapshot to an ANSI frame. Use this when nothing needs to be clickable. */\nexport function renderTopFrame(snapshot: TopSnapshot, options: RenderOptions = {}): string {\n return renderTopFrameWithLayout(snapshot, options).frame\n}\n\n/**\n * Render one snapshot, returning the frame together with the row→entity map a mouse click resolves\n * against. The layout is the only thing that knows which row is which run or worker, so emitting it\n * alongside the text is what keeps click handling out of the renderer.\n */\nexport function renderTopFrameWithLayout(\n snapshot: TopSnapshot,\n options: RenderOptions = {},\n): RenderedTopFrame {\n const width = Math.max(88, options.width ?? 128)\n const height = Math.max(24, options.height ?? 42)\n const color = options.color ?? false\n const focus = options.focus ?? 'supervisors'\n const mode = options.mode ?? 'overview'\n const selectedSupervisor = selectEntity(snapshot.supervisors, options.selectedSupervisorId)\n const selectedWorker = selectedSupervisor\n ? selectEntity(selectedSupervisor.workers, options.selectedWorkerId)\n : undefined\n const targets: RenderTarget[] = []\n const lines: string[] = []\n\n const push = (line = '', target?: Omit<RenderTarget, 'row'>) => {\n if (lines.length >= height) return\n if (target) targets.push({ row: lines.length, ...target })\n lines.push(fitAnsi(line, width))\n }\n\n const aggregate = aggregateSnapshot(snapshot)\n push(\n `${paint('SUPERVISOR TOP', 'bold', color)} ${paint(snapshot.root, 'dim', color)} ` +\n `runs ${aggregate.supervisors} workers ${aggregate.workers} live ${aggregate.running} ` +\n `done ${aggregate.done} down ${aggregate.down} ` +\n `${formatMoney(aggregate.usd, aggregate.usdKnown)} tok ${formatTokens(aggregate.tokensInput, aggregate.tokensKnown)}/${formatTokens(aggregate.tokensOutput, aggregate.tokensKnown)}`,\n )\n push(\n `${paint('keys', 'dim', color)} up/down select left/right run tab focus enter detail o overview l log s steer c cancel mouse q quit`,\n )\n if (options.notice) push(paint(options.notice, 'yellow', color))\n if (snapshot.completeness === 'partial')\n push(\n paint(\n `partial snapshot: ${snapshot.diagnostics.length} source${\n snapshot.diagnostics.length === 1 ? '' : 's'\n } skipped or truncated; runs loaded ${snapshot.loaded}/${snapshot.discovered}`,\n 'yellow',\n color,\n ),\n )\n if (options.steerInput?.active) push(renderSteerInput(options.steerInput, width, color))\n push(rule(width, color))\n\n if (snapshot.supervisors.length === 0) {\n if (snapshot.discovered > 0) {\n push(paint('NO READABLE SUPERVISORS', 'yellow', color))\n push(\n `${snapshot.discovered} run director${snapshot.discovered === 1 ? 'y' : 'ies'} found under ${supervisorRunsRoot(snapshot.root)}, none readable`,\n )\n } else {\n push(paint('NO SUPERVISORS', 'yellow', color))\n push(`No run state under ${supervisorRunsRoot(snapshot.root)}`)\n }\n push(\n `A run appears here once its driver writes state.json; re-point with: agent-runtime-top <root>`,\n )\n return { frame: `${lines.join('\\n')}\\n`, targets }\n }\n\n push(sectionTitle('SUPERVISORS', focus === 'supervisors', color))\n push(\n ` id status workers spend tok in/out latency task`,\n )\n for (const supervisor of snapshot.supervisors.slice(0, 9)) {\n const selected = supervisor.id === selectedSupervisor?.id\n const status = statusText(supervisor.status, color)\n const pointer = selected ? paint('>', 'cyan', color) : ' '\n const rowFocus = selected && focus === 'supervisors' ? 'inverse' : undefined\n const workerSummary = `${supervisor.totals.running}/${supervisor.totals.workers} live`\n const task = compact(supervisor.task, 34)\n const line =\n `${pointer} ${pad(supervisor.id, 21)} ${pad(status, 12)} ${pad(workerSummary, 13)} ` +\n `${pad(formatMoney(supervisor.totals.usd, supervisor.totals.usdKnown), 12)} ` +\n `${pad(`${formatTokens(supervisor.totals.tokensInput, supervisor.totals.tokensKnown)}/${formatTokens(supervisor.totals.tokensOutput, supervisor.totals.tokensKnown)}`, 16)} ` +\n `${pad(formatDuration(supervisor.totals.latencyMs), 12)} ${task}`\n push(rowFocus ? paint(line, rowFocus, color) : line, { kind: 'supervisor', id: supervisor.id })\n }\n\n if (!selectedSupervisor) return { frame: `${lines.join('\\n')}\\n`, targets }\n\n push()\n push(sectionTitle(`WORKERS ${selectedSupervisor.id}`, focus === 'workers', color))\n push(\n ` id state runtime latency cost tok in/out score detail`,\n )\n for (const worker of selectedSupervisor.workers.slice(0, 12)) {\n const selected = worker.id === selectedWorker?.id\n const pointer = selected ? paint('>', 'cyan', color) : ' '\n const rowFocus = selected && focus === 'workers' ? 'inverse' : undefined\n const score = worker.verdict ?? (worker.status === 'done' ? 'done' : worker.status)\n const detail = worker.reason ?? worker.outRef ?? worker.parent ?? ''\n const spend = totalSpend(worker)\n const line =\n `${pointer} ${pad(worker.label, 12)} ${pad(statusText(worker.status, color), 12)} ` +\n `${pad(worker.runtime ?? '-', 10)} ${pad(formatDuration(worker.latencyMs), 12)} ` +\n `${pad(formatMoney(spend.usd, spend.usdKnown), 11)} ` +\n `${pad(`${formatTokens(spend.tokensInput, spend.tokensKnown)}/${formatTokens(spend.tokensOutput, spend.tokensKnown)}`, 16)} ` +\n `${pad(compact(score, 9), 10)} ${compact(detail, 30)}`\n push(rowFocus ? paint(line, rowFocus, color) : line, {\n kind: 'worker',\n id: worker.id,\n supervisorId: selectedSupervisor.id,\n })\n }\n if (selectedSupervisor.workers.length === 0) push(' no workers spawned yet')\n\n push()\n push(sectionTitle('OBSERVABILITY', false, color))\n for (const line of renderStatusBars(selectedSupervisor, width, color)) push(line)\n push()\n for (const line of renderSpendBars(selectedSupervisor, width, color, 'usd')) push(line)\n push()\n for (const line of renderSpendBars(selectedSupervisor, width, color, 'tokens')) push(line)\n push()\n for (const line of renderLatencyHistogram(selectedSupervisor, width, color)) push(line)\n\n push()\n if (mode === 'log') {\n push(sectionTitle('JOURNAL TAIL', false, color))\n for (const line of renderJournalTail(selectedSupervisor, width, color)) push(line)\n } else {\n push(sectionTitle(mode === 'detail' ? 'DETAIL' : 'RUN SUMMARY', false, color))\n for (const line of renderDetail(selectedSupervisor, selectedWorker, mode, width, color))\n push(line)\n }\n\n return { frame: `${lines.join('\\n')}\\n`, targets }\n}\n\nfunction renderStatusBars(supervisor: SupervisorView, width: number, color: boolean): string[] {\n const total = Math.max(1, supervisor.totals.workers)\n const barWidth = Math.max(12, Math.min(28, width - 58))\n return [\n `status ` +\n `${pad('running', 9)} ${bar(supervisor.totals.running, total, barWidth, '#', color, 'yellow')} ${supervisor.totals.running}` +\n ` ${pad('done', 5)} ${bar(supervisor.totals.done, total, barWidth, '#', color, 'green')} ${supervisor.totals.done}` +\n ` ${pad('down', 5)} ${bar(supervisor.totals.down, total, barWidth, '#', color, 'red')} ${supervisor.totals.down}`,\n ]\n}\n\nfunction renderSpendBars(\n supervisor: SupervisorView,\n width: number,\n color: boolean,\n channel: 'usd' | 'tokens',\n): string[] {\n const dollars = channel === 'usd'\n const amount = (spend: SpendStats) =>\n dollars ? spend.usd : spend.tokensInput + spend.tokensOutput\n const label = (spend: SpendStats) =>\n dollars\n ? formatMoney(spend.usd, spend.usdKnown)\n : `${formatTokens(spend.tokensInput, spend.tokensKnown)}/${formatTokens(spend.tokensOutput, spend.tokensKnown)}`\n const rows = supervisor.workers\n .map((worker) => ({ worker, spend: totalSpend(worker) }))\n .sort((a, b) => amount(b.spend) - amount(a.spend))\n .slice(0, 6)\n const max = Math.max(\n dollars ? 0.000001 : 1,\n ...rows.map((row) => amount(row.spend)),\n amount(supervisor.driverSpend),\n )\n const total = dollars\n ? formatMoney(supervisor.totals.usd, supervisor.totals.usdKnown)\n : `in ${formatTokens(supervisor.totals.tokensInput, supervisor.totals.tokensKnown)} / out ${formatTokens(supervisor.totals.tokensOutput, supervisor.totals.tokensKnown)}`\n const out = [\n `${dollars ? 'cost ' : 'tokens'} total ${total} driver ${label(supervisor.driverSpend)}`,\n ]\n const barWidth = Math.max(18, Math.min(46, width - (dollars ? 38 : 44)))\n for (const { worker, spend } of rows) {\n const visual = dollars\n ? bar(spend.usd, max, barWidth, '$', color, 'magenta')\n : stackedTokenBar(spend.tokensInput, spend.tokensOutput, max, barWidth, color)\n out.push(` ${pad(worker.label, 12)} ${visual} ${label(spend)}`)\n }\n if (rows.length === 0) out.push(` no worker ${dollars ? 'cost' : 'tokens'} yet`)\n return out\n}\n\nfunction renderLatencyHistogram(\n supervisor: SupervisorView,\n width: number,\n color: boolean,\n): string[] {\n const values = supervisor.workers.map((worker) => worker.latencyMs).filter((value) => value > 0)\n const summary = supervisor.totals.workerLatency\n const out = [\n `latency n=${summary.n} min ${formatDuration(summary.min)} p50 ${formatDuration(summary.median)} ` +\n `p90 ${formatDuration(summary.p90)} max ${formatDuration(summary.max)}`,\n ]\n if (values.length === 0) {\n out.push(' no latency samples yet')\n return out\n }\n const bins = histogram(values, 6)\n const maxCount = Math.max(1, ...bins.map((bin) => bin.count))\n const barWidth = Math.max(18, Math.min(48, width - 34))\n for (const bin of bins) {\n out.push(\n ` ${pad(`${formatDuration(bin.min)}-${formatDuration(bin.max)}`, 15)} ` +\n `${bar(bin.count, maxCount, barWidth, '#', color, 'blue')} ${bin.count}`,\n )\n }\n return out\n}\n\nfunction renderDetail(\n supervisor: SupervisorView,\n worker: WorkerView | undefined,\n mode: 'overview' | 'detail' | 'log',\n width: number,\n color: boolean,\n): string[] {\n if (mode === 'detail' && worker) {\n const spend = totalSpend(worker)\n return [\n `worker ${paint(worker.label, 'bold', color)} (${worker.id}) ${statusText(worker.status, color)} latency ${formatDuration(worker.latencyMs)}`,\n `tokens in/out ${formatTokens(spend.tokensInput, spend.tokensKnown)}/${formatTokens(spend.tokensOutput, spend.tokensKnown)} cost ${formatMoney(spend.usd, spend.usdKnown)} iterations ${spend.iterations}`,\n `parent ${worker.parent ?? '-'} runtime ${worker.runtime ?? '-'} out ${worker.outRef ?? '-'}${worker.infra ? ' infra' : ''}`,\n `events ${compact(worker.eventFile ?? '-', width - 8)}`,\n ...(worker.reason ? [`reason ${compact(worker.reason, width - 7)}`] : []),\n ...renderWorkerTail(worker, width, color),\n ]\n }\n\n const caps = [\n supervisor.maxSandboxes !== undefined ? `boxes ${supervisor.maxSandboxes}` : undefined,\n supervisor.maxUsd !== undefined ? `max ${formatMoney(supervisor.maxUsd)}` : undefined,\n supervisor.maxDepth !== undefined ? `depth ${supervisor.maxDepth}` : undefined,\n supervisor.maxLifetimeSeconds !== undefined\n ? `ttl ${supervisor.maxLifetimeSeconds}s`\n : undefined,\n ].filter((value): value is string => value !== undefined)\n return [\n `task ${compact(supervisor.task, width - 7)}`,\n `workspace ${compact(supervisor.workspaceDir, width - 12)}`,\n `verify ${compact(supervisor.verifyCmd ?? '-', width - 9)}`,\n `models worker ${supervisor.workerModel ?? '-'} / driver ${supervisor.driverModel ?? '-'} caps ${caps.join(' | ') || '-'}`,\n `progress ${compact(supervisor.progress ?? supervisor.verdict ?? supervisor.status, width - 10)}`,\n ]\n}\n\nfunction renderJournalTail(supervisor: SupervisorView, width: number, color: boolean): string[] {\n if (supervisor.journalTail.length === 0) return [' no journal events yet']\n return supervisor.journalTail.map((event) => {\n const at = event.at ? formatClock(event.at) : '--:--:--'\n if (event.kind === 'spawned')\n return ` ${at} ${paint('spawn', 'yellow', color)} ${pad(event.label ?? event.id, 16)} ${event.id}`\n if (event.kind !== 'cancelled') {\n const spend = parseSpend(event.kind === 'settled' ? event.spent : event.spend)\n const status =\n event.kind === 'settled'\n ? statusText(event.status ?? 'settled', color)\n : event.kind === 'metered'\n ? `${paint('meter', 'cyan', color)} `\n : `${paint('live', 'blue', color)} `\n return ` ${at} ${status} ${pad(event.id, 18)} ${formatMoney(spend.usd, spend.usdKnown)} ${formatTokens(spend.tokensInput, spend.tokensKnown)}/${formatTokens(spend.tokensOutput, spend.tokensKnown)}`\n }\n return ` ${at} ${paint('cancel', 'red', color)} ${pad(event.id, 18)} ${compact(event.reason ?? '', width - 32)}`\n })\n}\n\nfunction renderWorkerTail(worker: WorkerView, width: number, color: boolean): string[] {\n if (worker.liveTail.length === 0) return ['live events: none recorded yet']\n return [\n 'live events:',\n ...worker.liveTail\n .slice(-5)\n .map((line) => ` ${paint(compact(formatWorkerEvent(line), width - 2), 'dim', color)}`),\n ]\n}\n\nfunction renderSteerInput(\n input: NonNullable<RenderOptions['steerInput']>,\n width: number,\n color: boolean,\n): string {\n const target = input.workerLabel ?? '-'\n const value = compact(input.value, Math.max(10, width - target.length - 14))\n return `${paint('steer', 'cyan', color)} ${target} > ${value}${paint('_', 'inverse', color)}`\n}\n\nfunction formatWorkerEvent(line: string): string {\n try {\n const parsed = JSON.parse(line) as Record<string, unknown>\n const at = typeof parsed.at === 'string' ? formatClock(parsed.at) : '--:--:--'\n const kind = typeof parsed.kind === 'string' ? parsed.kind : 'event'\n if (kind === 'progress')\n return `${at} progress iter ${numberValue(parsed.iteration)} ${String(parsed.phase ?? '')}`\n if (kind === 'message') {\n const state = parsed.queued === true ? 'queued' : 'sent'\n const source =\n typeof parsed.source === 'string' && parsed.source.length > 0 ? `${parsed.source} ` : ''\n const message =\n typeof parsed.message === 'string' && parsed.message.length > 0 ? ` ${parsed.message}` : ''\n return `${at} ${source}steer ${state} delivered=${String(parsed.delivered)}${message}`\n }\n if (kind === 'verify') {\n return `${at} verify passed=${String(parsed.passed)} exit=${String(parsed.exitCode ?? '-')}${evidenceSnippet(parsed.outputTail, 160)}`\n }\n if (kind === 'finished') {\n const branch = typeof parsed.branch === 'string' ? ` branch=${parsed.branch}` : ''\n const files = typeof parsed.filesChanged === 'number' ? ` files=${parsed.filesChanged}` : ''\n const tests =\n typeof parsed.testPassed === 'boolean' ? ` tests=${String(parsed.testPassed)}` : ''\n return `${at} finished passed=${String(parsed.passed)} patchBytes=${numberValue(parsed.patchBytes)}${files}${tests}${branch}${evidenceSnippet(parsed.evidence, 220)}`\n }\n if (kind === 'error') return `${at} error ${String(parsed.error ?? '')}`\n return `${at} ${kind}`\n } catch {\n return line\n }\n}\n\n/** One-line the settle evidence / verify tail a worker event carries so the\n * failure is legible in the tail view (the full block stays in the ndjson). */\nfunction evidenceSnippet(value: unknown, max: number): string {\n if (typeof value !== 'string') return ''\n const oneLine = value.replace(/\\s+/g, ' ').trim()\n return oneLine ? ` :: ${compact(oneLine, max)}` : ''\n}\n\nfunction histogram(\n values: readonly number[],\n count: number,\n): Array<{ min: number; max: number; count: number }> {\n const min = Math.min(...values)\n const max = Math.max(...values)\n if (min === max) return [{ min, max, count: values.length }]\n const step = (max - min) / count\n return Array.from({ length: count }, (_, index) => {\n const low = min + step * index\n const high = index === count - 1 ? max : min + step * (index + 1)\n const binCount = values.filter(\n (value) => value >= low && (index === count - 1 ? value <= high : value < high),\n ).length\n return { min: low, max: high, count: binCount }\n }).filter((bin) => bin.count > 0)\n}\n\nfunction bar(\n value: number,\n max: number,\n width: number,\n ch: string,\n color: boolean,\n colorName: keyof typeof colors,\n): string {\n const filled = Math.max(0, Math.min(width, Math.round((value / Math.max(max, 0.000001)) * width)))\n const text = ch.repeat(filled).padEnd(width, '.')\n return paint(text, colorName, color)\n}\n\nfunction stackedTokenBar(\n input: number,\n output: number,\n max: number,\n width: number,\n color: boolean,\n): string {\n const inputWidth = Math.round((input / Math.max(max, 1)) * width)\n const outputWidth = Math.round((output / Math.max(max, 1)) * width)\n const clippedInput = Math.min(width, inputWidth)\n const clippedOutput = Math.min(width - clippedInput, outputWidth)\n const rest = Math.max(0, width - clippedInput - clippedOutput)\n return `${paint('#'.repeat(clippedInput), 'cyan', color)}${paint('+'.repeat(clippedOutput), 'green', color)}${'.'.repeat(rest)}`\n}\n\nfunction sectionTitle(title: string, focused: boolean, color: boolean): string {\n const text = focused ? `[${title}]` : title\n return paint(text, focused ? 'cyan' : 'bold', color)\n}\n\nfunction statusText(status: string, color: boolean): string {\n if (['completed', 'done', 'delivered', 'valid'].includes(status))\n return paint(status.toUpperCase(), 'green', color)\n if (['failed', 'down', 'cancelled', 'invalid', 'error'].includes(status))\n return paint(status.toUpperCase(), 'red', color)\n if (['running', 'spawned', 'settled'].includes(status))\n return paint(status.toUpperCase(), 'yellow', color)\n return paint(status.toUpperCase(), 'white', color)\n}\n\nfunction selectEntity<T extends { readonly id: string }>(\n entities: readonly T[],\n requested: string | undefined,\n): T | undefined {\n return (requested ? entities.find((entity) => entity.id === requested) : undefined) ?? entities[0]\n}\n\nfunction formatClock(value: string): string {\n const parsed = parseTime(value)\n if (parsed === undefined) return '--:--:--'\n return new Date(parsed).toISOString().slice(11, 19)\n}\n\nfunction formatMoney(value: number, known = true): string {\n if (!known) return value === 0 ? 'unknown' : `≥${formatMoney(value)} + unknown`\n if (value === 0) return '$0'\n if (Math.abs(value) < 0.01) return `$${value.toFixed(4)}`\n return `$${value.toFixed(2)}`\n}\n\nfunction formatTokens(value: number, known = true): string {\n if (!known) return value === 0 ? '?' : `≥${formatTokens(value)}?`\n if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}m`\n if (value >= 1_000) return `${(value / 1_000).toFixed(1)}k`\n return `${Math.round(value)}`\n}\n\nfunction formatDuration(ms: number): string {\n if (!Number.isFinite(ms) || ms <= 0) return '0s'\n if (ms < 1000) return `${Math.round(ms)}ms`\n const seconds = ms / 1000\n if (seconds < 60) return `${seconds.toFixed(seconds < 10 ? 1 : 0)}s`\n const minutes = seconds / 60\n if (minutes < 60) return `${minutes.toFixed(minutes < 10 ? 1 : 0)}m`\n return `${(minutes / 60).toFixed(1)}h`\n}\n\nfunction compact(value: string, width: number): string {\n if (width <= 1) return ''\n if (value.length <= width) return value\n return `${value.slice(0, width - 1)}~`\n}\n\nfunction pad(value: string, width: number): string {\n const visible = visibleLength(value)\n if (visible >= width) return fitAnsi(value, width)\n return `${value}${' '.repeat(width - visible)}`\n}\n\nfunction rule(width: number, color: boolean): string {\n return paint('-'.repeat(width), 'dim', color)\n}\n\nfunction paint(\n value: string,\n colorName: keyof typeof colors | undefined,\n enabled: boolean,\n): string {\n if (!enabled || !colorName) return value\n return `${colors[colorName]}${value}${colors.reset}`\n}\n\nfunction visibleLength(value: string): number {\n return stripAnsi(value).length\n}\n\nfunction stripAnsi(value: string): string {\n return value.replace(ansiPattern, '')\n}\n\nfunction fitAnsi(value: string, width: number): string {\n if (visibleLength(value) <= width) return value\n let out = ''\n let visible = 0\n let cursor = 0\n // An escape sequence must be copied whole and counted as zero visible columns; truncating\n // inside one would emit a half-sequence the terminal interprets against the next line.\n for (const match of value.matchAll(ansiPattern)) {\n const text = value.slice(cursor, match.index)\n const remaining = width - 1 - visible\n out += text.slice(0, remaining)\n visible += Math.min(text.length, remaining)\n if (text.length > remaining) break\n out += match[0]\n cursor = match.index + match[0].length\n }\n if (visible < width - 1) out += value.slice(cursor, cursor + width - 1 - visible)\n out += '~'\n if (out.includes('\\x1b[') && !out.endsWith(colors.reset)) out += colors.reset\n return out\n}\n","/**\n * The interactive side of the supervisor-run TUI: a keypress/mouse loop over the frames\n * `./top-frame` renders, plus the operator controls that write back to the run — steer a live\n * worker, cancel one worker, and request cancellation of a whole run.\n *\n * The controls go through the owned run layout: steers via `writeWorkerSteer` (the durable inbox\n * append) and worker cancellation via `cancelWorker` (the acknowledged operation the runtime's\n * turn loop applies). Run-level cancellation targets the ROOT, which has no acknowledged runtime\n * path yet for a non-retained tree — it stays a `cancel.request.json` write inside the run\n * directory for a host process to honor. Nothing here joins a path from the workspace root.\n *\n * Extracted from the `loops` repo (`src/top.ts`). The module-level singletons are the origin's\n * shape and are kept: this drives one terminal, and `runTopApp` is its one entry point.\n *\n * @experimental\n */\n\nimport { randomUUID } from 'node:crypto'\nimport { hostname, userInfo } from 'node:os'\nimport { resolve } from 'node:path'\nimport { emitKeypressEvents } from 'node:readline'\nimport { cancelRun } from '../runtime/supervise/run-cancellation'\nimport { cancelWorker, writeWorkerSteer } from '../runtime/supervise/run-layout'\nimport { type RenderTarget, renderTopFrameWithLayout } from './top-frame'\nimport { loadTopSnapshot, type TopSnapshot } from './top-snapshot'\n\ninterface UiState {\n root: string\n color: boolean\n focus: 'supervisors' | 'workers'\n mode: 'overview' | 'detail' | 'log'\n selectedSupervisorId: string | undefined\n selectedWorkerId: string | undefined\n notice: string | undefined\n steerInput: {\n active: boolean\n value: string\n }\n}\n\n/** @experimental How the app was invoked. Defaults read `process.argv` / `process.cwd()`. */\ninterface TopAppOptions {\n readonly argv?: readonly string[]\n readonly cwd?: string\n}\n\nlet state: UiState = initialState([], process.cwd())\nlet snapshot: TopSnapshot = {\n root: state.root,\n generatedAt: 0,\n supervisors: [],\n completeness: 'complete',\n diagnostics: [],\n discovered: 0,\n loaded: 0,\n}\nlet targets: RenderTarget[] = []\nlet timer: NodeJS.Timeout | undefined\n\n/**\n * Render exactly one frame and return it. This is the non-interactive path — `--once`, a pipe, a\n * test — so it never touches raw mode, the alternate screen, or `process.exit`.\n */\nfunction renderTopOnce(options: TopAppOptions = {}): string {\n const args = [...(options.argv ?? process.argv.slice(2))]\n state = initialState(args, options.cwd ?? process.cwd())\n snapshot = loadTopSnapshot(state.root)\n clampSelection()\n return renderTopFrameWithLayout(snapshot, {\n color: state.color,\n width: process.stdout.columns ?? 128,\n focus: state.focus,\n mode: state.mode,\n ...(state.selectedSupervisorId ? { selectedSupervisorId: state.selectedSupervisorId } : {}),\n ...(state.selectedWorkerId ? { selectedWorkerId: state.selectedWorkerId } : {}),\n steerInput: renderSteerInputState(),\n }).frame\n}\n\n/**\n * Run the TUI. With a TTY on both ends and no `--once` this takes over the terminal until `q`;\n * otherwise it writes a single frame to stdout and returns.\n */\nexport function runTopApp(options: TopAppOptions = {}): void {\n const args = [...(options.argv ?? process.argv.slice(2))]\n if (!process.stdout.isTTY || !process.stdin.isTTY || args.includes('--once')) {\n process.stdout.write(renderTopOnce(options))\n return\n }\n state = initialState(args, options.cwd ?? process.cwd())\n snapshot = loadTopSnapshot(state.root)\n start()\n}\n\nfunction initialState(args: readonly string[], cwd: string): UiState {\n const rootArg = args.find((arg) => !arg.startsWith('-'))\n return {\n root: resolve(rootArg ?? cwd),\n color: Boolean(process.stdout.isTTY) && !args.includes('--no-color'),\n focus: args.includes('--detail') ? 'workers' : 'supervisors',\n mode: args.includes('--log') ? 'log' : args.includes('--detail') ? 'detail' : 'overview',\n selectedSupervisorId: undefined,\n selectedWorkerId: undefined,\n notice: undefined,\n steerInput: { active: false, value: '' },\n }\n}\n\nfunction start(): void {\n process.stdout.write('\\x1b[?1049h\\x1b[?25l\\x1b[?1000h\\x1b[?1006h')\n emitKeypressEvents(process.stdin)\n process.stdin.setRawMode(true)\n process.stdin.resume()\n process.stdin.on('keypress', onKey)\n process.stdin.on('data', onData)\n process.on('SIGINT', stop)\n draw()\n timer = setInterval(draw, 1000)\n}\n\nfunction stop(): void {\n if (timer) clearInterval(timer)\n process.stdin.setRawMode(false)\n process.stdout.write('\\x1b[?1000l\\x1b[?1006l\\x1b[?25h\\x1b[?1049l')\n process.exit(0)\n}\n\nfunction draw(): void {\n snapshot = loadTopSnapshot(state.root)\n clampSelection()\n const rendered = renderTopFrameWithLayout(snapshot, {\n width: process.stdout.columns ?? 128,\n height: process.stdout.rows ?? 42,\n color: state.color,\n focus: state.focus,\n mode: state.mode,\n ...(state.notice ? { notice: state.notice } : {}),\n ...(state.selectedSupervisorId ? { selectedSupervisorId: state.selectedSupervisorId } : {}),\n ...(state.selectedWorkerId ? { selectedWorkerId: state.selectedWorkerId } : {}),\n steerInput: renderSteerInputState(),\n })\n targets = rendered.targets\n process.stdout.write(`\\x1b[2J\\x1b[H${rendered.frame}`)\n}\n\nfunction onKey(str: string, key: { name?: string; ctrl?: boolean }): void {\n state.notice = undefined\n if (key.ctrl && key.name === 'c') stop()\n if (state.steerInput.active) {\n handleSteerInput(str, key)\n draw()\n return\n }\n if (key.name === 'q' || key.name === 'escape') stop()\n if (key.name === 'tab') {\n state.focus = state.focus === 'supervisors' ? 'workers' : 'supervisors'\n } else if (key.name === 'up') {\n moveSelection(-1)\n } else if (key.name === 'down') {\n moveSelection(1)\n } else if (key.name === 'left') {\n moveSupervisor(-1)\n } else if (key.name === 'right') {\n moveSupervisor(1)\n } else if (key.name === 'return') {\n state.mode = 'detail'\n state.focus = 'workers'\n } else if (key.name === 'o') {\n state.mode = 'overview'\n } else if (key.name === 'l') {\n state.mode = 'log'\n } else if (key.name === 's') {\n startSteerInput()\n } else if (key.name === 'c') {\n requestCancel()\n }\n draw()\n}\n\nfunction handleSteerInput(str: string, key: { name?: string; ctrl?: boolean }): void {\n if (key.name === 'escape') {\n state.steerInput = { active: false, value: '' }\n return\n }\n if (key.name === 'return') {\n submitSteerInput()\n return\n }\n if (key.name === 'backspace') {\n state.steerInput.value = state.steerInput.value.slice(0, -1)\n return\n }\n if (key.ctrl && key.name === 'u') {\n state.steerInput.value = ''\n return\n }\n if (\n key.ctrl ||\n key.name === 'tab' ||\n key.name === 'up' ||\n key.name === 'down' ||\n key.name === 'left' ||\n key.name === 'right'\n ) {\n return\n }\n if (!str || str === '\\r' || str === '\\n') return\n if ([...str].every((char) => char >= ' ' && char !== '\\x7f')) state.steerInput.value += str\n}\n\nfunction onData(data: Buffer): void {\n const click = parseMouse(data.toString('utf8'))\n if (!click) return\n const target = targets.find((candidate) => candidate.row === click.row)\n if (!target) return\n state.notice = undefined\n if (target.kind === 'supervisor') {\n state.focus = 'supervisors'\n state.selectedSupervisorId = target.id\n state.selectedWorkerId = undefined\n } else {\n state.focus = 'workers'\n state.mode = 'detail'\n state.selectedSupervisorId = target.supervisorId\n state.selectedWorkerId = target.id\n }\n draw()\n}\n\nfunction startSteerInput(): void {\n state.mode = 'detail'\n state.focus = 'workers'\n if (!selectedSupervisor()) {\n state.notice = 'no supervisor selected'\n return\n }\n if (!selectedWorker()) {\n state.notice = 'no worker selected'\n return\n }\n state.steerInput = { active: true, value: '' }\n}\n\nfunction submitSteerInput(): void {\n const supervisor = selectedSupervisor()\n const worker = selectedWorker()\n const message = state.steerInput.value\n state.steerInput = { active: false, value: '' }\n if (!supervisor) {\n state.notice = 'no supervisor selected'\n return\n }\n if (!worker) {\n state.notice = 'no worker selected'\n return\n }\n try {\n // The exact worker id routes this operation to the one manager that owns the child.\n const written = writeWorkerSteer(state.root, supervisor.id, worker.id, {\n operationId: randomUUID(),\n message,\n source: 'agent-runtime-top',\n })\n state.notice = `steer queued for ${supervisor.id}/${worker.label} (op ${written.request.operationId})`\n } catch (err) {\n state.notice = `steer failed: ${err instanceof Error ? err.message : String(err)}`\n }\n}\n\nfunction parseMouse(raw: string): { col: number; row: number } | undefined {\n // ESC is the literal first byte of an SGR mouse report; matching the control character IS the\n // parse, so the control-character rule does not apply to a terminal escape decoder.\n // biome-ignore lint/suspicious/noControlCharactersInRegex: SGR mouse reports begin with ESC\n const match = /\\x1b\\[<(\\d+);(\\d+);(\\d+)([mM])/.exec(raw)\n if (match?.[4] !== 'M') return undefined\n const col = Number(match[2])\n const row = Number(match[3])\n if (!Number.isFinite(col) || !Number.isFinite(row)) return undefined\n return { col: col - 1, row: row - 1 }\n}\n\nfunction moveSelection(delta: number): void {\n if (state.focus === 'supervisors') {\n moveSupervisor(delta)\n return\n }\n const supervisor = selectedSupervisor()\n if (!supervisor || supervisor.workers.length === 0) return\n const current = Math.max(\n 0,\n supervisor.workers.findIndex((worker) => worker.id === state.selectedWorkerId),\n )\n const next = wrap(current + delta, supervisor.workers.length)\n const worker = supervisor.workers[next]\n if (worker) state.selectedWorkerId = worker.id\n}\n\nfunction moveSupervisor(delta: number): void {\n if (snapshot.supervisors.length === 0) return\n const current = Math.max(\n 0,\n snapshot.supervisors.findIndex((supervisor) => supervisor.id === state.selectedSupervisorId),\n )\n const next = wrap(current + delta, snapshot.supervisors.length)\n const supervisor = snapshot.supervisors[next]\n if (!supervisor) return\n state.selectedSupervisorId = supervisor.id\n state.selectedWorkerId = supervisor.workers[0]?.id\n}\n\nfunction clampSelection(): void {\n if (snapshot.supervisors.length === 0) {\n state.selectedSupervisorId = undefined\n state.selectedWorkerId = undefined\n return\n }\n const supervisor = selectedSupervisor() ?? snapshot.supervisors[0]\n if (!supervisor) return\n state.selectedSupervisorId = supervisor.id\n const worker =\n supervisor.workers.find((candidate) => candidate.id === state.selectedWorkerId) ??\n supervisor.workers[0]\n state.selectedWorkerId = worker?.id\n}\n\nfunction selectedSupervisor(): TopSnapshot['supervisors'][number] | undefined {\n return snapshot.supervisors.find((supervisor) => supervisor.id === state.selectedSupervisorId)\n}\n\nfunction selectedWorker(): TopSnapshot['supervisors'][number]['workers'][number] | undefined {\n const supervisor = selectedSupervisor()\n return supervisor?.workers.find((worker) => worker.id === state.selectedWorkerId)\n}\n\nfunction renderSteerInputState(): { active: boolean; value: string; workerLabel?: string } {\n const worker = selectedWorker()\n return {\n active: state.steerInput.active,\n value: state.steerInput.value,\n ...(worker?.label ? { workerLabel: worker.label } : {}),\n }\n}\n\nfunction requestCancel(): void {\n const supervisor = selectedSupervisor()\n if (!supervisor) {\n state.notice = 'no supervisor selected'\n return\n }\n if (supervisor.status !== 'running') {\n state.notice = `${supervisor.id} is ${supervisor.status}; no cancel request written`\n return\n }\n // Worker focus cancels ONE worker through the acknowledged runtime path: the request lands in\n // the run layout's cancellation inbox, the run's own turn loop applies the abort to exactly\n // that worker's subtree, and the acknowledgement records what it proved.\n const worker = state.focus === 'workers' ? selectedWorker() : undefined\n if (worker) {\n if (worker.status !== 'running') {\n state.notice = `${worker.label} is ${worker.status}; nothing to cancel`\n return\n }\n // The request names the exact node id, so it routes to the manager that owns the worker at\n // ANY depth — the owning manager's turn loop applies the abort to exactly that subtree.\n try {\n const record = cancelWorker(supervisor.stateDir, worker.id, randomUUID(), {\n reason: 'operator requested cancel from TUI',\n source: 'agent-runtime-top',\n })\n state.notice =\n record.effect === 'unknown'\n ? `cancel queued for ${supervisor.id}/${worker.label} (op ${record.operationId}); awaiting runtime acknowledgement`\n : `cancel ${record.effect} for ${supervisor.id}/${worker.label} (op ${record.operationId})`\n } catch (err) {\n state.notice = `cancel request failed: ${err instanceof Error ? err.message : String(err)}`\n }\n return\n }\n // Supervisor focus cancels the WHOLE run through the same acknowledged contract: the request\n // lands in the run layout, the run's root manager aborts the whole tree through the one cascade\n // controller it already has, and `supervise()` records the terminal effect.\n try {\n const record = cancelRun(supervisor.stateDir, randomUUID(), {\n reason: 'operator requested cancel from TUI',\n source: 'agent-runtime-top',\n operator: `${userInfo().username}@${hostname()}`,\n })\n state.notice =\n record.effect === 'unknown'\n ? `run cancel queued for ${supervisor.id} (op ${record.operationId}); awaiting runtime acknowledgement`\n : `run cancel ${record.effect} for ${supervisor.id} (op ${record.operationId})`\n } catch (err) {\n state.notice = `cancel request failed: ${err instanceof Error ? err.message : String(err)}`\n }\n}\n\nfunction wrap(value: number, size: number): number {\n return ((value % size) + size) % size\n}\n","#!/usr/bin/env node\n\n/**\n * `agent-runtime-top` — watch the supervisor runs of one workspace.\n *\n * agent-runtime-top [root] [--once] [--no-color] [--detail] [--log]\n *\n * `root` is the workspace whose `.agent/supervisor/` runs are shown; it defaults to the current\n * directory. With a TTY on both ends the view refreshes every second and takes the keys it prints\n * in its header; otherwise (a pipe, `--once`) it writes one frame and exits.\n *\n * @experimental\n */\n\nimport { runTopApp } from './top-app'\n\nrunTopApp()\n"],"mappings":";;;;;;;;AA2CA,MAAM,cAAc;AAEpB,MAAM,SAAS;CACb,OAAO;CACP,KAAK;CACL,MAAM;CACN,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP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