pi-durable-subagents 1.0.32 → 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 +17 -0
- package/README.md +11 -4
- package/dist/orchestrator/stats.js +14 -4
- package/dist/orchestrator/store.js +3 -1
- package/dist/ui/screen.js +4 -4
- package/dist/ui/view.js +11 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
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
|
+
|
|
3
20
|
## 1.0.32
|
|
4
21
|
|
|
5
22
|
- `/subagents` lists working workflows first (newest first) and finished ones
|
package/README.md
CHANGED
|
@@ -209,7 +209,8 @@ Press `↓` on an empty editor, or type `/subagents`, to open the list, a floati
|
|
|
209
209
|
session's workflows (sessions are independent), working ones first (newest
|
|
210
210
|
first), every subagent with its model, what it is doing and for how long, and
|
|
211
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
|
|
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
|
|
213
214
|
fan-out, a generated key (`tasks:0`) shows as its agent (`worker 1`,
|
|
214
215
|
`reviewer`). The key remains the address for `send` and the CLI. A session's workflows include runs started
|
|
215
216
|
through the CLI by a process this session launched (a background driver, a
|
|
@@ -371,7 +372,10 @@ yet, else 1 when one was rejected, else 0. A notify's reply adds `delivery`
|
|
|
371
372
|
|
|
372
373
|
From the `subagents` tool, `request` works the same, with one difference: a
|
|
373
374
|
run's origin session (what `context: "fork"` copies, and where notices go) is
|
|
374
|
-
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
|
|
375
379
|
gets the first session's workflow, its notices and its forked context. A
|
|
376
380
|
retried answer may leave out `to`, `qid` and `rev`: it addresses the question
|
|
377
381
|
the first attempt answered.
|
|
@@ -551,8 +555,11 @@ and `status --json` / `doctor --json` carry it as `orchestratorStats`:
|
|
|
551
555
|
`workflows` (not pruned), `liveWorkflows` (with work still open),
|
|
552
556
|
`openJournals` (journal files held open), `passesPerSecond` (intake passes
|
|
553
557
|
that ran, averaged over the last minute; an idle orchestrator runs almost
|
|
554
|
-
none), `readBytes` (bytes the
|
|
555
|
-
`/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
|
|
556
563
|
written). The orchestrator writes these to `orchestrator-stats.json` every
|
|
557
564
|
10 s; they are shown only while that process runs.
|
|
558
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 { callName, doneOrder, isOpen, plainReason, toggleOpen, duration, keepSelection, summaryText, listRows, modelLabel, pendingText, resultPhrase, rowText, toolCount } from "./view.js";
|
|
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";
|
|
@@ -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: callName(w, c) } : { id: w.wid, name: w
|
|
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.
|
|
@@ -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], new Set(w.calls.map(x => x.key)).size === 1 && 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
|
@@ -150,10 +150,17 @@ const GENERATED = /^(?:tasks|chain):(\d+)$/;
|
|
|
150
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
151
|
* its agent, numbered when the workflow runs that agent more than once; a named key as is. "@2" marks a later
|
|
152
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
|
+
}
|
|
153
160
|
export function callName(w, c) {
|
|
154
|
-
const keys = [...new Set(w.calls.map(x => x.key))], gen = c.gen > 1 ? `@${c.gen}` : "";
|
|
155
|
-
if (keys.length === 1 &&
|
|
156
|
-
return `${
|
|
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}`;
|
|
157
164
|
if (!GENERATED.test(c.key))
|
|
158
165
|
return `${c.key}${gen}`;
|
|
159
166
|
const peers = keys.filter(k => GENERATED.test(k) && w.calls.find(x => x.key === k)?.agent === c.agent)
|
|
@@ -201,7 +208,7 @@ export function mainLine(workflows) {
|
|
|
201
208
|
words.set(resultWord(r.status), (words.get(resultWord(r.status)) ?? 0) + 1);
|
|
202
209
|
}
|
|
203
210
|
const parts = WORD_ORDER.filter(word => words.has(word)).map(word => `${words.get(word)} ${word}`);
|
|
204
|
-
return `${w
|
|
211
|
+
return `${workflowName(w) ?? w.wid} finished: ${parts.join(" · ") || w.status} · ↓ subagents`;
|
|
205
212
|
}
|
|
206
213
|
const SPIN = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
207
214
|
/** UI §1: The dock above the editor. While agents work: one row per active agent (questions first, at most `rows`),
|
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",
|