pi-durable-subagents 1.0.40 → 1.0.42

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/ui/tool.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Text } from "@earendil-works/pi-tui";
2
- import { plainReason } from "./view.js";
2
+ import { plainReason, queuedPhrase } from "./view.js";
3
3
  const short = (id) => typeof id === "string" ? (id.length > 12 ? `${id.slice(0, 10)}…` : id) : "";
4
4
  const clip = (s, n) => s.length > n ? `${s.slice(0, n - 1)}…` : s;
5
5
  /** UI §5: One line per tool call: what was asked, never the raw arguments (scripts and task prompts stay out of the transcript). */
@@ -32,7 +32,7 @@ export function resultLines(details) {
32
32
  const d = (details ?? {});
33
33
  if (typeof d.wid === "string" && typeof d.key === "string" && typeof d.phase === "string") {
34
34
  const r = d.result;
35
- return [`${d.key} · ${r?.status ?? (d.phase === "queued" && d.answered ? "queued (answered, waiting for a slot)" : d.phase)}${typeof d.model === "string" ? ` · ${d.model}` : ""}`];
35
+ return [`${d.key} · ${r?.status ?? (d.phase === "queued" ? queuedPhrase(d, Date.now()) : d.phase)}${typeof d.model === "string" ? ` · ${d.model}` : ""}`];
36
36
  }
37
37
  if (typeof d.wid === "string" && !Array.isArray(d.calls))
38
38
  return [`started workflow ${d.wid}`, ...(typeof d.paused === "string" ? [`⚠ ${d.paused}`] : [])];
@@ -53,7 +53,9 @@ export function resultLines(details) {
53
53
  return `${w.name ?? short(w.wid)} · ${w.paused ? "paused" : w.followUps ? `follow-up running (run ${w.status})` : w.status} · ${w.progress} done${failed ? ` · ${failed} not ok` : ""}${asks ? ` · ${asks} asking` : ""}${alerts ? ` · ${alerts} alert${alerts > 1 ? "s" : ""}` : ""}`;
54
54
  });
55
55
  const finished = Array.isArray(d.finished) ? d.finished.length + Number(d.olderFinished ?? 0) : 0;
56
- return [...(typeof d.paused === "string" ? [`⚠ ${d.paused}`] : []), ...(rows.length ? rows.slice(0, 6) : ["nothing running"]),
56
+ // The orchestrator line ("1.0.42 (pid 7, starting 12s)") while it recovers: nothing queued starts until then.
57
+ const starting = typeof d.orchestrator === "string" ? /^[^(]*\(pid \d+, starting ([^)]+)\)/.exec(d.orchestrator)?.[1] : undefined;
58
+ return [...(typeof d.paused === "string" ? [`⚠ ${d.paused}`] : []), ...(starting ? [`orchestrator starting (${starting})`] : []), ...(rows.length ? rows.slice(0, 6) : ["nothing running"]),
57
59
  ...(rows.length > 6 ? [`… ${rows.length - 6} more`] : []), ...(finished ? [`${finished} finished`] : [])];
58
60
  }
59
61
  if (Array.isArray(d.workflows)) {
package/dist/ui/view.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
2
- import { isLive, labelsText, liveCalls, ownedBy, progressOf } from "../orchestrator/snapshot.js";
2
+ import { answerForwardedNote, isLive, queuedText, labelsText, liveCalls, ownedBy, progressOf } from "../orchestrator/snapshot.js";
3
3
  import { oneLine } from "./frame.js";
4
4
  /** UI §2: Render compact wall-clock durations; never present these as charged active time. */
5
5
  export function duration(ms) {
@@ -121,7 +121,7 @@ export function statusPhrase(call, workflow, facts, now) {
121
121
  return resultPhrase(call);
122
122
  const question = workflow.attention.find(a => a.kind === "question" && a.call === call.callId);
123
123
  if (question)
124
- return `asking main agent: ${question.text}`;
124
+ return answerForwardedNote(call, now) || `asking main agent: ${question.text}`;
125
125
  const noProgress = workflow.attention.find(a => a.kind === "stall" && a.call === call.callId && a.id.startsWith("noprogress:"));
126
126
  // The alert's duration measures progress, whereas lastActivity also advances on provider retries.
127
127
  if (noProgress)
@@ -129,7 +129,7 @@ export function statusPhrase(call, workflow, facts, now) {
129
129
  if (workflow.attention.some(a => a.kind === "stall" && a.call === call.callId))
130
130
  return `no activity for ${duration(now - Math.max(call.lastActivity ?? call.startedAt ?? now, facts?.lastActivity ?? 0))}`;
131
131
  if (call.phase === "queued")
132
- return workflow.paused ? "paused · r resumes" : call.answered ? "queued (answered, waiting for a slot)" : "queued: waiting for a free slot";
132
+ return workflow.paused ? "paused · r resumes" : queuedPhrase(call, now);
133
133
  // Liveness (UI §2): the age of the newest evidence ticks, and resets whenever the agent does anything.
134
134
  const since = duration(Math.max(0, now - Math.max(call.lastActivity ?? 0, facts?.lastActivity ?? 0, call.startedAt ?? 0)));
135
135
  if (facts?.activity)
@@ -142,6 +142,16 @@ export function statusPhrase(call, workflow, facts, now) {
142
142
  return live.tool ? `writing a ${live.tool} call · ${age}` : live.text ? `writing · ${age}` : `thinking · ${age}`;
143
143
  return `thinking · ${since}`;
144
144
  }
145
+ /** Why a queued call does not start, only as far as the orchestrator ledger says (CallSnapshot.queuedFor): a call is
146
+ * never said to wait for a slot without a full provider, an answered asker neither ("queued (answered)"). */
147
+ export function queuedPhrase(call, now) {
148
+ const why = call.queuedFor;
149
+ if (why?.reason === "starting")
150
+ return `queued: ${queuedText(why, now, duration)}`;
151
+ if (call.answered)
152
+ return why ? `queued (answered): ${why.detail}` : "queued (answered)";
153
+ return why ? `queued: ${queuedText(why, now, duration)}` : "queued";
154
+ }
145
155
  function failed(c) { return c.phase === "sealed" && c.result && !c.result.ok && c.result.status !== "skipped"; }
146
156
  /** UI §2, P37: Calls are named by key; later generations of a key carry their generation. */
147
157
  export const label = (c) => c.gen > 1 ? `${c.key}@${c.gen}` : c.key;
@@ -183,19 +193,21 @@ export function summary(workflows) {
183
193
  done: progress.reduce((n, p) => n + p.done, 0), total: progress.reduce((n, p) => n + p.total, 0), plus: progress.some(p => p.plus) };
184
194
  }
185
195
  /** UI §1, v12 §4: What needs you first, then what is running, then progress — e.g. "1 asking · 3 working · 12/40 done". */
186
- export function summaryText(workflows) {
196
+ export function summaryText(workflows, now = Date.now()) {
187
197
  const s = summary(workflows), finished = workflows.filter(w => !isLive(w)).length;
188
198
  if (!s.total)
189
199
  return finished ? `${finished} finished` : "nothing running";
190
- return [s.asking ? `${s.asking} asking` : "", s.working ? `${s.working} working` : "", s.queued ? `${s.queued} queued` : "", s.paused ? `${s.paused} paused` : "", `${s.done}/${s.total}${s.plus ? "+" : ""} done`].filter(Boolean).join(" · ");
200
+ // While the orchestrator recovers, nothing queued starts: say so once, rather than suggest a slot shortage.
201
+ const starting = s.queued ? workflows.filter(w => isLive(w) && !w.paused).flatMap(liveCalls).find(c => c.phase === "queued" && c.queuedFor?.reason === "starting")?.queuedFor : undefined;
202
+ return [s.asking ? `${s.asking} asking` : "", s.working ? `${s.working} working` : "", s.queued ? `${s.queued} queued${starting ? `: ${queuedText(starting, now, duration)}` : ""}` : "", s.paused ? `${s.paused} paused` : "", `${s.done}/${s.total}${s.plus ? "+" : ""} done`].filter(Boolean).join(" · ");
191
203
  }
192
- export function mainLine(workflows) {
204
+ export function mainLine(workflows, now = Date.now()) {
193
205
  if (!workflows.length)
194
206
  return undefined;
195
207
  const s = summary(workflows);
196
208
  // The key that opens the list is spelled out: a bare arrow is easy to miss.
197
209
  if (s.working || s.asking || s.queued || s.paused)
198
- return `${summaryText(workflows)} · ↓ subagents`;
210
+ return `${summaryText(workflows, now)} · ↓ subagents`;
199
211
  const w = workflows.filter(w => !isLive(w)).sort((a, b) => (b.endedAt ?? 0) - (a.endedAt ?? 0))[0];
200
212
  if (!w)
201
213
  return undefined;
@@ -225,7 +237,7 @@ export function dockLines(workflows, facts, name, width, now = Date.now(), rows
225
237
  }).sort((a, b) => Number(b.asking) - Number(a.asking));
226
238
  if (!active.length) {
227
239
  const ended = workflows.filter(w => !isLive(w)).sort((a, b) => (b.endedAt ?? 0) - (a.endedAt ?? 0))[0];
228
- const line = ended && now - (ended.endedAt ?? 0) < 10 * 60_000 ? mainLine(workflows) : undefined;
240
+ const line = ended && now - (ended.endedAt ?? 0) < 10 * 60_000 ? mainLine(workflows, now) : undefined;
229
241
  return line ? [truncateToWidth(line, Math.max(1, width))] : [];
230
242
  }
231
243
  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))))) };
@@ -234,11 +246,11 @@ export function dockLines(workflows, facts, name, width, now = Date.now(), rows
234
246
  // A running tool is activity; otherwise a minute without new evidence (no message, no tool) stops the spinner.
235
247
  const f = facts.get(c.callId), fresh = Boolean(f?.activity) || now - Math.max(c.lastActivity ?? 0, f?.lastActivity ?? 0, c.startedAt ?? 0) < 60_000;
236
248
  const mark = asking ? "?" : c.phase === "queued" ? "·" : fresh ? SPIN[Math.floor(now / 500) % SPIN.length] : "…";
237
- const phrase = asking ? `asks: ${w.attention.find(a => a.kind === "question" && a.call === c.callId).text}` : statusPhrase(c, w, f, now);
249
+ const phrase = answerForwardedNote(c, now) || (asking ? `asks: ${w.attention.find(a => a.kind === "question" && a.call === c.callId).text}` : statusPhrase(c, w, f, now));
238
250
  return rowText(`${mark} `, callName(w, c), name(f?.model ?? c.model), phrase, [], width, cols);
239
251
  });
240
252
  const more = active.length - shown.length;
241
- lines.push(truncateToWidth(`${more ? `+${more} more · ` : ""}${summaryText(workflows)} · ↓ subagents`, Math.max(1, width)));
253
+ lines.push(truncateToWidth(`${more ? `+${more} more · ` : ""}${summaryText(workflows, now)} · ↓ subagents`, Math.max(1, width)));
242
254
  return lines;
243
255
  }
244
256
  /** UI §2, v12 §5: Group workflows (finished ones stay listed, dimmed and expandable — never hidden behind a toggle),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-durable-subagents",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
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",