pi-durable-subagents 1.0.31 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +16 -7
- package/dist/orchestrator/stats.js +14 -4
- package/dist/orchestrator/store.js +3 -1
- package/dist/ui/screen.js +14 -14
- package/dist/ui/view.js +38 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.33
|
|
4
|
+
|
|
5
|
+
- A run copies its origin session branch only when it can use it: its script
|
|
6
|
+
quotes `"fork"` or a string in its `args` is `"fork"`. Before, every run
|
|
7
|
+
started from pi copied the whole branch (tens of MB for a long session)
|
|
8
|
+
into `pinned/origin.jsonl` and its staging snapshot, read it at admission
|
|
9
|
+
and hashed it at every orchestrator start, although almost no run forks.
|
|
10
|
+
Existing workflows keep their copies until they are pruned.
|
|
11
|
+
- `orchestratorStats.readBytes` counts the orchestrator's own reads (its
|
|
12
|
+
threads' `rchar`). It used `/proc/self/io`, where Linux adds every reaped
|
|
13
|
+
child's I/O to the parent: each finished call added everything its
|
|
14
|
+
subagent's builds and tests had read, which looked like the orchestrator
|
|
15
|
+
reading gigabytes per second.
|
|
16
|
+
- A workflow started without `name` is shown by its label values
|
|
17
|
+
(`ipc-qa c4811f14`) in the dock, `/subagents`, the watch view and the
|
|
18
|
+
completion notice, instead of by its agent name.
|
|
19
|
+
|
|
20
|
+
## 1.0.32
|
|
21
|
+
|
|
22
|
+
- `/subagents` lists working workflows first (newest first) and finished ones
|
|
23
|
+
after them (most recently ended first), so running work is never buried
|
|
24
|
+
under a page of finished rows. The cursor stays on its row when a workflow
|
|
25
|
+
moves.
|
|
26
|
+
- Rows name subagents the way people know them: a workflow's only subagent by
|
|
27
|
+
the workflow's name, a generated key (`tasks:0`, `chain:1`) by its agent,
|
|
28
|
+
numbered when repeated (`worker 1`, `worker 2`). Applies to the list, the
|
|
29
|
+
dock, the watch view and the input prompts; tools and the CLI keep the key
|
|
30
|
+
as the address. A name longer than the key column is clipped so columns
|
|
31
|
+
stay aligned.
|
|
32
|
+
|
|
3
33
|
## 1.0.31
|
|
4
34
|
|
|
5
35
|
- A run can be shown in the pi session it was started for, not only the one
|
package/README.md
CHANGED
|
@@ -206,10 +206,13 @@ another extension's editor bar (a powerline bar, for example), list
|
|
|
206
206
|
pi-durable-subagents before that extension in `packages`.
|
|
207
207
|
|
|
208
208
|
Press `↓` on an empty editor, or type `/subagents`, to open the list, a floating panel: this
|
|
209
|
-
session's workflows (sessions are independent),
|
|
210
|
-
subagent with its model, what it is doing and for how long, and
|
|
211
|
-
line. Finished ones
|
|
212
|
-
|
|
209
|
+
session's workflows (sessions are independent), working ones first (newest
|
|
210
|
+
first), every subagent with its model, what it is doing and for how long, and
|
|
211
|
+
its latest line. Finished ones follow, most recently ended first, dimmed, with
|
|
212
|
+
their conclusion. A workflow's only subagent is named after the workflow (its
|
|
213
|
+
`name`, else its label values, e.g. `ipc-qa c4811f14`); in a
|
|
214
|
+
fan-out, a generated key (`tasks:0`) shows as its agent (`worker 1`,
|
|
215
|
+
`reviewer`). The key remains the address for `send` and the CLI. A session's workflows include runs started
|
|
213
216
|
through the CLI by a process this session launched (a background driver, a
|
|
214
217
|
script run from its bash tool): pi exports `DSA_SESSION`, and `run` names that
|
|
215
218
|
session (see `--session` below). Other sessions' and a terminal's runs are
|
|
@@ -369,7 +372,10 @@ yet, else 1 when one was rejected, else 0. A notify's reply adds `delivery`
|
|
|
369
372
|
|
|
370
373
|
From the `subagents` tool, `request` works the same, with one difference: a
|
|
371
374
|
run's origin session (what `context: "fork"` copies, and where notices go) is
|
|
372
|
-
not part of the digest.
|
|
375
|
+
not part of the digest. Only a run that can fork copies the origin branch: its
|
|
376
|
+
script quotes `"fork"` or a string in its `args` is `"fork"`; any other run
|
|
377
|
+
copies nothing, and a call of it that builds `context: "fork"` some other way
|
|
378
|
+
fails with "fork requested but the run has no origin session". A retry of the same id from another session therefore
|
|
373
379
|
gets the first session's workflow, its notices and its forked context. A
|
|
374
380
|
retried answer may leave out `to`, `qid` and `rev`: it addresses the question
|
|
375
381
|
the first attempt answered.
|
|
@@ -549,8 +555,11 @@ and `status --json` / `doctor --json` carry it as `orchestratorStats`:
|
|
|
549
555
|
`workflows` (not pruned), `liveWorkflows` (with work still open),
|
|
550
556
|
`openJournals` (journal files held open), `passesPerSecond` (intake passes
|
|
551
557
|
that ran, averaged over the last minute; an idle orchestrator runs almost
|
|
552
|
-
none), `readBytes` (bytes the
|
|
553
|
-
`/proc/self/io`; absent where there is none
|
|
558
|
+
none), `readBytes` (bytes the orchestrator's own threads read since it
|
|
559
|
+
started, summed from `/proc/self/task/*/io`; absent where there is none.
|
|
560
|
+
Not `/proc/<pid>/io` of the orchestrator: Linux adds every reaped child's I/O
|
|
561
|
+
to its parent there, so it grows by whatever the subagents and their builds
|
|
562
|
+
read, in a burst each time a call ends), `pid` and `at` (when it was
|
|
554
563
|
written). The orchestrator writes these to `orchestrator-stats.json` every
|
|
555
564
|
10 s; they are shown only while that process runs.
|
|
556
565
|
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
// What the running orchestrator costs, for `status --json` and `doctor`: the orchestrator writes these counters of its
|
|
2
2
|
// own process to $DSA_HOME/orchestrator-stats.json every STATS_EVERY_MS (atomic replace, no fsync: a lost write only
|
|
3
3
|
// shows older numbers). Readers show them only when the pid in the file is the orchestrator the ledger records as running.
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
4
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
5
5
|
import { rename, rm, writeFile } from "node:fs/promises";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
export const STATS_EVERY_MS = 10_000;
|
|
8
8
|
export const statsPath = (home) => join(home, "orchestrator-stats.json");
|
|
9
|
-
/**
|
|
9
|
+
/** The summed rchar of this process's live threads, or undefined where there is none (see OrchestratorStats.readBytes). */
|
|
10
10
|
export function readBytes() {
|
|
11
11
|
if (process.platform !== "linux")
|
|
12
12
|
return undefined;
|
|
13
13
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
let total = 0, found = false;
|
|
15
|
+
for (const tid of readdirSync("/proc/self/task")) {
|
|
16
|
+
try {
|
|
17
|
+
const match = /^rchar:\s*(\d+)$/m.exec(readFileSync(`/proc/self/task/${tid}/io`, "utf8"));
|
|
18
|
+
if (match) {
|
|
19
|
+
total += Number(match[1]);
|
|
20
|
+
found = true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch { /* a thread that just exited */ }
|
|
24
|
+
}
|
|
25
|
+
return found ? total : undefined;
|
|
16
26
|
}
|
|
17
27
|
catch {
|
|
18
28
|
return undefined;
|
|
@@ -131,8 +131,10 @@ export async function prepareRun(body, discovery, warnings = []) {
|
|
|
131
131
|
}
|
|
132
132
|
if (blocking.length)
|
|
133
133
|
throw new Error(blocking.join('\n'));
|
|
134
|
+
// P33: only a run that can ask for context "fork" pins the origin branch (tens of MB for a long session); a call of
|
|
135
|
+
// any other run that asks for it anyway fails with "fork requested but the run has no origin session".
|
|
134
136
|
return { source, args: body.args ?? null, agents: found.agents, inputs, inputSources: body.inputs ?? {},
|
|
135
|
-
...(body.origin ? { origin: await pinOrigin(body.origin) } : {}),
|
|
137
|
+
...(body.origin && usableNames(source, body.args, [])('fork') ? { origin: await pinOrigin(body.origin) } : {}),
|
|
136
138
|
...(body.usageBudget ? { usageBudget: body.usageBudget } : {}), ...(body.maxCalls !== undefined ? { maxCalls: body.maxCalls } : {}) };
|
|
137
139
|
}
|
|
138
140
|
/** A1, A5: Reduce only the current revision, retaining all history for seals and allocation. */
|
package/dist/ui/screen.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AssistantMessageComponent, UserMessageComponent, ToolExecutionComponent
|
|
|
2
2
|
import { Input, SelectList, fuzzyFilter, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
3
|
import { CT } from "../types.js";
|
|
4
4
|
import { UiActions, UiData } from "./data.js";
|
|
5
|
-
import { doneOrder, isOpen, plainReason, toggleOpen, duration, keepSelection, summaryText,
|
|
5
|
+
import { callName, workflowName, doneOrder, isOpen, plainReason, toggleOpen, duration, keepSelection, summaryText, listRows, modelLabel, pendingText, resultPhrase, rowText, toolCount } from "./view.js";
|
|
6
6
|
import { fitWidth, frame, inner } from "./frame.js";
|
|
7
7
|
import { thinkingElapsed } from "./thinking.js";
|
|
8
8
|
import { thoughtSummary } from "./session.js";
|
|
@@ -82,7 +82,7 @@ export class SubagentScreen {
|
|
|
82
82
|
beginListInput(kind, row) {
|
|
83
83
|
const c = row.call, w = row.workflow;
|
|
84
84
|
const q = w.attention.find(a => a.kind === "question" && a.call === c.callId);
|
|
85
|
-
this.listInput = { kind, call: c, workflow: w, editor: new Input({ prompt: `${kind} ${
|
|
85
|
+
this.listInput = { kind, call: c, workflow: w, editor: new Input({ prompt: `${kind} ${callName(w, c)}: ` }), ...(kind === "answer" && q ? { qid: q.qid, rev: q.rev } : {}) };
|
|
86
86
|
this.listInput.editor.focused = this.focused;
|
|
87
87
|
this.listNotice = undefined;
|
|
88
88
|
}
|
|
@@ -94,8 +94,8 @@ export class SubagentScreen {
|
|
|
94
94
|
if (!message)
|
|
95
95
|
return;
|
|
96
96
|
this.listInput = undefined;
|
|
97
|
-
const { call: c, kind } = draft;
|
|
98
|
-
this.listAction({ action: "send", to: c.callId, kind, message, ...(kind === "answer" ? { qid: draft.qid, rev: draft.rev } : {}) }, `${kind} ${
|
|
97
|
+
const { call: c, workflow: w, kind } = draft;
|
|
98
|
+
this.listAction({ action: "send", to: c.callId, kind, message, ...(kind === "answer" ? { qid: draft.qid, rev: draft.rev } : {}) }, `${kind} ${callName(w, c)}: ${JSON.stringify(message)}`);
|
|
99
99
|
}
|
|
100
100
|
dispose() { this.disposed = true; }
|
|
101
101
|
refresh() { if (!this.disposed)
|
|
@@ -259,7 +259,7 @@ export class SubagentScreen {
|
|
|
259
259
|
}
|
|
260
260
|
const q = w.attention.find(a => a.kind === "question" && a.call === c.callId);
|
|
261
261
|
const kind = followUp ? "follow-up" : q ? "answer" : "steer";
|
|
262
|
-
void this.send({ action: "send", to: c.callId, kind, message, ...(kind === "answer" ? { qid: q.qid, rev: q.rev } : {}) }, `${kind === "answer" ? "replied to" : followUp ? "queued follow-up for" : c.phase === "sealed" ? "continued" : "steered"} ${
|
|
262
|
+
void this.send({ action: "send", to: c.callId, kind, message, ...(kind === "answer" ? { qid: q.qid, rev: q.rev } : {}) }, `${kind === "answer" ? "replied to" : followUp ? "queued follow-up for" : c.phase === "sealed" ? "continued" : "steered"} ${callName(w, c)}: ${JSON.stringify(message)}`);
|
|
263
263
|
}
|
|
264
264
|
handleInput(key) {
|
|
265
265
|
if (this.disposed)
|
|
@@ -324,9 +324,9 @@ export class SubagentScreen {
|
|
|
324
324
|
else if (key === "m" && c)
|
|
325
325
|
this.modelMenu(c);
|
|
326
326
|
else if (key === "r" && w?.paused)
|
|
327
|
-
this.listAction({ action: "resume", wid: w.wid }, `resume ${w
|
|
327
|
+
this.listAction({ action: "resume", wid: w.wid }, `resume ${workflowName(w) ?? w.wid}`);
|
|
328
328
|
else if (key === "x" && (c && c.phase !== "sealed" || row?.kind === "workflow" && w?.status === "running")) {
|
|
329
|
-
this.stopTarget = c ? { id: c.callId, name:
|
|
329
|
+
this.stopTarget = c ? { id: c.callId, name: callName(w, c) } : { id: w.wid, name: workflowName(w) ?? w.wid };
|
|
330
330
|
}
|
|
331
331
|
// Typing that is not a list key is meant for pi (a message typed with the list still open would
|
|
332
332
|
// otherwise have its Enter open a watch view): close the list and hand the text to the editor.
|
|
@@ -377,10 +377,10 @@ export class SubagentScreen {
|
|
|
377
377
|
return;
|
|
378
378
|
// Panel coordinates: row 0 is the top border, column 2 is the first content column.
|
|
379
379
|
if (event.y === 2) {
|
|
380
|
-
const { c } = this.current();
|
|
381
|
-
if (!c)
|
|
380
|
+
const { c, w } = this.current();
|
|
381
|
+
if (!c || !w)
|
|
382
382
|
return;
|
|
383
|
-
const facts = this.data.facts.get(c.callId), model = `${
|
|
383
|
+
const facts = this.data.facts.get(c.callId), model = `${callName(w, c)} · ${this.name(facts?.model ?? c.model)} ▾ · `;
|
|
384
384
|
const x = event.x - 2;
|
|
385
385
|
if (x < visibleWidth(model))
|
|
386
386
|
this.modelMenu();
|
|
@@ -531,7 +531,7 @@ export class SubagentScreen {
|
|
|
531
531
|
const rowWidth = Math.max(1, size.width - 2);
|
|
532
532
|
this.rows = this.doneTab && w ? doneOrder(w.calls).map(c => {
|
|
533
533
|
const f = this.data.facts.get(c.callId);
|
|
534
|
-
return { id: c.callId, kind: "call", workflow: w, call: c, failed: !c.result?.ok, text: rowText(" ",
|
|
534
|
+
return { id: c.callId, kind: "call", workflow: w, call: c, failed: !c.result?.ok, text: rowText(" ", callName(w, c), this.name(f?.model ?? c.model), resultPhrase(c), [toolCount(f?.tools)], rowWidth) };
|
|
535
535
|
}) : listRows(this.data.workflows, this.state, this.data.facts, this.name, rowWidth);
|
|
536
536
|
height = this.height(Math.max(1, this.rows.length) + footerRows);
|
|
537
537
|
size = inner(width, height); // inner width does not depend on height
|
|
@@ -563,10 +563,10 @@ export class SubagentScreen {
|
|
|
563
563
|
if (!c || !w)
|
|
564
564
|
return panel(["Subagent is no longer in the current revision"], "Subagents", "Esc back");
|
|
565
565
|
const facts = this.data.facts.get(c.callId), active = w.calls.filter(c => c.phase !== "sealed"), done = w.calls.length - active.length;
|
|
566
|
-
const tabs = size.width < 60 ? `${c
|
|
566
|
+
const tabs = size.width < 60 ? `${callName(w, c)} ${w.calls.indexOf(c) + 1}/${w.calls.length}` : `${[...active.map(c => callName(w, c)), ...(done ? [`${done} done`] : [])].join(" · ")} ← → switch`;
|
|
567
567
|
const tools = toolCount(facts?.tools), pending = pendingText(c.pending), rule = this.theme.fg("borderMuted", "─".repeat(size.width));
|
|
568
568
|
const switching = c.switching ? ` → ${this.name(c.switching)} (requested)` : "";
|
|
569
|
-
const head = [tabs, `${
|
|
569
|
+
const head = [tabs, `${callName(w, c)} · ${this.name(facts?.model ?? c.model)} ▾${switching} · ${facts?.thinking ?? "off"} ▾${tools ? ` · ${tools}` : ""}${pending ? ` · ${pending}` : ""}`,
|
|
570
570
|
this.theme.fg("dim", this.spend(c, facts)), rule];
|
|
571
571
|
const asking = w.attention.some(a => a.kind === "question" && a.call === c.callId);
|
|
572
572
|
const placeholder = `${c.phase === "sealed" ? "Continue" : asking ? "Reply to" : "Steer"} ${c.key}…${this.uses < 3 ? " / for commands" : ""}`;
|
|
@@ -594,6 +594,6 @@ export class SubagentScreen {
|
|
|
594
594
|
}
|
|
595
595
|
this.inputRow = 1 + head.length + available + 1;
|
|
596
596
|
// pi's own keys for the transcript, spelled out: thinking and tool output expand in place.
|
|
597
|
-
return panel([...head, ...body, rule, ...editor, hint], `${w
|
|
597
|
+
return panel([...head, ...body, rule, ...editor, hint], new Set(w.calls.map(x => x.key)).size === 1 && workflowName(w) ? callName(w, c) : `${workflowName(w) ?? w.wid} › ${callName(w, c)}`, `${duration(Date.now() - (c.startedAt ?? Date.now()))} · ctrl+t thinking · ctrl+o tools · Esc back`);
|
|
598
598
|
}
|
|
599
599
|
}
|
package/dist/ui/view.js
CHANGED
|
@@ -29,11 +29,15 @@ export const pendingText = (n) => n ? `${n} message${n === 1 ? "" : "s"} pending
|
|
|
29
29
|
/** UI §2, P7: The list row's small pending marker (the watch header spells it out). */
|
|
30
30
|
export const pendingMarker = (n) => n ? `${n} pending` : "";
|
|
31
31
|
/** UI §2: Sessions are independent: only this session's workflows (it started them, or a run started from it named it
|
|
32
|
-
* as its session, e.g. a CLI driver launched from this pi)
|
|
33
|
-
*
|
|
32
|
+
* as its session, e.g. a CLI driver launched from this pi). Working ones come first, newest start first; finished ones
|
|
33
|
+
* follow, most recently ended first. A workflow moves once, when it finishes (or a follow-up reopens it); the list
|
|
34
|
+
* keeps the selection on the same row id, so the cursor follows it. */
|
|
34
35
|
export function orderWorkflows(workflows, own) {
|
|
36
|
+
const tie = (a, b) => (a.wid < b.wid ? 1 : a.wid > b.wid ? -1 : 0);
|
|
35
37
|
return workflows.filter(w => own === undefined || ownedBy(w, own))
|
|
36
|
-
.sort((a, b) => (b
|
|
38
|
+
.sort((a, b) => Number(isLive(b)) - Number(isLive(a))
|
|
39
|
+
|| (isLive(a) ? (b.startedAt ?? 0) - (a.startedAt ?? 0) : (b.endedAt ?? b.startedAt ?? 0) - (a.endedAt ?? a.startedAt ?? 0))
|
|
40
|
+
|| tie(a, b));
|
|
37
41
|
}
|
|
38
42
|
/** UI §2: Done rows newest result first by immutable end time; ties keep snapshot order, so rows never reshuffle. */
|
|
39
43
|
export function doneOrder(calls) {
|
|
@@ -53,7 +57,7 @@ export function rowText(indent, key, model, phrase, tail, width, cols = { key: 0
|
|
|
53
57
|
const end = tail.filter(Boolean).join(" · ");
|
|
54
58
|
// A long phrase (a long command) is clipped; the tail (tools, age) stays. Under pressure the model column goes first.
|
|
55
59
|
for (const showModel of width >= 40 ? [true, false] : [false]) {
|
|
56
|
-
const head = `${indent}${pad(key, cols.key)} ${showModel ? `${pad(short, width < 70 ? 0 : cols.model)} ` : ""}`;
|
|
60
|
+
const head = `${indent}${pad(cols.key ? truncateToWidth(key, cols.key).replaceAll("\x1b[0m", "") : key, cols.key)} ${showModel ? `${pad(short, width < 70 ? 0 : cols.model)} ` : ""}`;
|
|
57
61
|
const room = width - visibleWidth(head) - (end ? visibleWidth(end) + 2 : 0);
|
|
58
62
|
// truncateToWidth closes its ellipsis with an SGR reset; drop it so a dimmed row stays dim to its end (tools, age).
|
|
59
63
|
if (end && room >= 8)
|
|
@@ -141,6 +145,28 @@ export function statusPhrase(call, workflow, facts, now) {
|
|
|
141
145
|
function failed(c) { return c.phase === "sealed" && c.result && !c.result.ok && c.result.status !== "skipped"; }
|
|
142
146
|
/** UI §2, P37: Calls are named by key; later generations of a key carry their generation. */
|
|
143
147
|
export const label = (c) => c.gen > 1 ? `${c.key}@${c.gen}` : c.key;
|
|
148
|
+
/** A key the spec did not name: generated from the launch form's position (tasks:0, chain:1). */
|
|
149
|
+
const GENERATED = /^(?:tasks|chain):(\d+)$/;
|
|
150
|
+
/** UI §2: How a person knows a call. A workflow's only agent goes by the workflow's name; a generated key (tasks:0) by
|
|
151
|
+
* its agent, numbered when the workflow runs that agent more than once; a named key as is. "@2" marks a later
|
|
152
|
+
* generation. The key stays the address for tools and the CLI; only the UI shows this name. */
|
|
153
|
+
/** A workflow's display name: its run name, else its label values ("ipc-qa c4811f14"), else undefined. */
|
|
154
|
+
export function workflowName(w) {
|
|
155
|
+
if (w.name)
|
|
156
|
+
return w.name;
|
|
157
|
+
const values = Object.values(w.labels ?? {}).map(v => String(v).replace(/\s+/g, " ").trim()).filter(Boolean);
|
|
158
|
+
return values.length ? values.join(" ") : undefined;
|
|
159
|
+
}
|
|
160
|
+
export function callName(w, c) {
|
|
161
|
+
const keys = [...new Set(w.calls.map(x => x.key))], gen = c.gen > 1 ? `@${c.gen}` : "", name = workflowName(w);
|
|
162
|
+
if (keys.length === 1 && name)
|
|
163
|
+
return `${name}${gen}`;
|
|
164
|
+
if (!GENERATED.test(c.key))
|
|
165
|
+
return `${c.key}${gen}`;
|
|
166
|
+
const peers = keys.filter(k => GENERATED.test(k) && w.calls.find(x => x.key === k)?.agent === c.agent)
|
|
167
|
+
.sort((a, b) => Number(GENERATED.exec(a)[1]) - Number(GENERATED.exec(b)[1]));
|
|
168
|
+
return `${c.agent}${peers.length > 1 ? ` ${peers.indexOf(c.key) + 1}` : ""}${gen}`;
|
|
169
|
+
}
|
|
144
170
|
const WORDS = { ok: "done", stopped: "stopped", failed: "failed", "gate-failed": "failed", timeout: "timeout", budget: "budget", unknown: "unknown", skipped: "skipped", parked: "parked" };
|
|
145
171
|
/** v12 §4: The result word of a sealed status — a stopped call is never called failed; timeout/budget/unknown are named as such. */
|
|
146
172
|
export const resultWord = (status) => WORDS[status] ?? "failed";
|
|
@@ -182,7 +208,7 @@ export function mainLine(workflows) {
|
|
|
182
208
|
words.set(resultWord(r.status), (words.get(resultWord(r.status)) ?? 0) + 1);
|
|
183
209
|
}
|
|
184
210
|
const parts = WORD_ORDER.filter(word => words.has(word)).map(word => `${words.get(word)} ${word}`);
|
|
185
|
-
return `${w
|
|
211
|
+
return `${workflowName(w) ?? w.wid} finished: ${parts.join(" · ") || w.status} · ↓ subagents`;
|
|
186
212
|
}
|
|
187
213
|
const SPIN = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
188
214
|
/** UI §1: The dock above the editor. While agents work: one row per active agent (questions first, at most `rows`),
|
|
@@ -202,14 +228,14 @@ export function dockLines(workflows, facts, name, width, now = Date.now(), rows
|
|
|
202
228
|
const line = ended && now - (ended.endedAt ?? 0) < 10 * 60_000 ? mainLine(workflows) : undefined;
|
|
203
229
|
return line ? [truncateToWidth(line, Math.max(1, width))] : [];
|
|
204
230
|
}
|
|
205
|
-
const cols = { key: Math.min(
|
|
231
|
+
const cols = { key: Math.min(20, Math.max(...active.map(a => visibleWidth(callName(a.w, a.c))))), model: Math.min(20, Math.max(...active.map(a => visibleWidth(name(facts.get(a.c.callId)?.model ?? a.c.model))))) };
|
|
206
232
|
const shown = active.slice(0, rows);
|
|
207
233
|
const lines = shown.map(({ w, c, asking }) => {
|
|
208
234
|
// A running tool is activity; otherwise a minute without new evidence (no message, no tool) stops the spinner.
|
|
209
235
|
const f = facts.get(c.callId), fresh = Boolean(f?.activity) || now - Math.max(c.lastActivity ?? 0, f?.lastActivity ?? 0, c.startedAt ?? 0) < 60_000;
|
|
210
236
|
const mark = asking ? "?" : c.phase === "queued" ? "·" : fresh ? SPIN[Math.floor(now / 500) % SPIN.length] : "…";
|
|
211
237
|
const phrase = asking ? `asks: ${w.attention.find(a => a.kind === "question" && a.call === c.callId).text}` : statusPhrase(c, w, f, now);
|
|
212
|
-
return rowText(`${mark} `,
|
|
238
|
+
return rowText(`${mark} `, callName(w, c), name(f?.model ?? c.model), phrase, [], width, cols);
|
|
213
239
|
});
|
|
214
240
|
const more = active.length - shown.length;
|
|
215
241
|
lines.push(truncateToWidth(`${more ? `+${more} more · ` : ""}${summaryText(workflows)} · ↓ subagents`, Math.max(1, width)));
|
|
@@ -248,16 +274,16 @@ export function listRows(workflows, state, facts, name, width, now = Date.now())
|
|
|
248
274
|
state.observed.set(w.wid, { working, failures });
|
|
249
275
|
}
|
|
250
276
|
const unviewed = (w) => w.calls.some(c => failed(c) && !state.viewed.has(c.callId));
|
|
251
|
-
const visible = workflows; // caller order
|
|
277
|
+
const visible = workflows; // caller order: working first, then finished (orderWorkflows)
|
|
252
278
|
// Aligned columns across the whole list (UI §2): key and model start at the same column on every row.
|
|
253
|
-
const shownCalls = visible.flatMap(w => w.calls);
|
|
254
|
-
const cols = { key: Math.min(
|
|
255
|
-
model: Math.min(26, Math.max(0, ...shownCalls.map(c => visibleWidth(name(facts.get(c.callId)?.model ?? c.model))))) };
|
|
279
|
+
const shownCalls = visible.flatMap(w => w.calls.map(c => ({ w, c })));
|
|
280
|
+
const cols = { key: Math.min(24, Math.max(0, ...shownCalls.map(({ w, c }) => visibleWidth(callName(w, c))))),
|
|
281
|
+
model: Math.min(26, Math.max(0, ...shownCalls.map(({ c }) => visibleWidth(name(facts.get(c.callId)?.model ?? c.model))))) };
|
|
256
282
|
const callRow = (w, c, indent, preview, dim = false) => {
|
|
257
283
|
const f = facts.get(c.callId), age = c.phase === "sealed" ? `${duration(now - (c.endedAt ?? now))} ago` : c.startedAt ? duration(now - c.startedAt) : "";
|
|
258
284
|
// A requested switch shows at once (it applies when the current step ends; until then it would look as if it had failed).
|
|
259
285
|
const shown = c.switching ? `${name(f?.model ?? c.model)} → ${name(c.switching)}` : name(f?.model ?? c.model);
|
|
260
|
-
const text = rowText(indent,
|
|
286
|
+
const text = rowText(indent, callName(w, c), shown, statusPhrase(c, w, f, now), [pendingMarker(c.pending), toolCount(f?.tools), age], width, cols);
|
|
261
287
|
rows.push({ id: c.callId, kind: "call", workflow: w, call: c, failed: Boolean(failed(c)), dim, text });
|
|
262
288
|
// Overview (UI §2): every active agent shows what it last said, thought or saw, without opening it.
|
|
263
289
|
if (preview !== undefined && c.phase !== "sealed" && f?.latest)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-durable-subagents",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"description": "Subagents for pi that never lose work and never do it twice. Crash-safe workflows, automatic recovery, and a live view just like the main agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|