pi-durable-subagents 1.0.41 → 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/view.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
2
- import { answerForwardedNote, 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) {
@@ -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))))) };
@@ -238,7 +250,7 @@ export function dockLines(workflows, facts, name, width, now = Date.now(), rows
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.41",
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",