pi-agent-squad 0.8.4 → 0.8.5

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/README.md CHANGED
@@ -64,6 +64,8 @@ metadata and does not sandbox filesystem access.
64
64
  ## Features
65
65
 
66
66
  - **Delegation**: `subagent` tool (sync / background `async:true`); background results are injected into the main session when done.
67
+ - **Durable background ledger**: key background lifecycle snapshots are stored as TUI-only custom entries on the current Pi session branch.
68
+ - **Recovery and explicit retry**: reopening a session restores background history, marks stale work interrupted, repairs pending result delivery, and supports `/subagent-retry <runId>` without automatically rerunning old work.
67
69
  - **Real-time two-way**: subagent<->main and subagent<->subagent, via file channel + an active-run registry that covers both direct runs and resident RPC processes.
68
70
  - **Non-blocking**: background tasks do not occupy the main session.
69
71
  - **Adaptive orchestration is opt-in**: `/orchestrate on` enables main's discretion to delegate based on speed, quality, context management, independent judgment, and parallel progress while weighing latency, over-analysis, misunderstanding, duplication, and integration risk.
@@ -178,6 +180,39 @@ from the visible transcript:
178
180
  `triggerTurn: true` and `deliverAs: "steer"`, preserving the former
179
181
  synthetic-user-message behavior without inheriting `userMessageBg`.
180
182
 
183
+ ## Background task persistence and recovery
184
+
185
+ Background task lifecycle state is append-only in the current Pi session. The
186
+ plugin writes `agent-squad-task-state` snapshots for `starting`, `running`,
187
+ `completed`, `failed`, `cancelled`, and `interrupted` transitions. These custom
188
+ entries do not enter LLM context.
189
+
190
+ When the same session is reopened, the plugin reconstructs the ledger from the
191
+ **active branch**. The last valid snapshot for each run is authoritative.
192
+ Malformed entries and unknown schema versions are ignored independently.
193
+
194
+ - A `starting` or `running` task owned by an older plugin runtime is changed to
195
+ `interrupted`; it is never assumed alive from a PID or child-session path.
196
+ - Interrupted, failed, and cancelled work is **not** automatically rerun. Use
197
+ `/subagent-retry <runId>` to create a new background run with a new run ID and
198
+ address. The new ledger entry records `retryOf`.
199
+ - Completion is persisted before its result is injected. If a completed result
200
+ was not delivered before shutdown, reopening the session schedules recovery
201
+ delivery after session initialization.
202
+ - Each completed result uses `agent-squad-result:<runId>` as its stable
203
+ `deliveryId`. Recovery scans durable custom-message entries for that ID before
204
+ sending and again immediately before delivery, preventing duplicate result
205
+ messages across crash windows.
206
+ - `/subagent-status` merges current live tasks with bounded current-branch
207
+ history and distinguishes delivered from pending completed results.
208
+
209
+ The ledger stores bounded metadata and result/error summaries, not complete
210
+ child transcripts, credentials, controllers, promises, streams, or callbacks.
211
+ Background child Pi sessions remain separate and retain their full transcript;
212
+ the ledger stores only the bounded summary plus the child session file path.
213
+ This version does **not** revive dead OS processes, take over processes from an
214
+ older runtime, daemonize subagents, or provide cross-runtime process keepalive.
215
+
181
216
  ## Architecture
182
217
 
183
218
  ```
@@ -210,6 +245,10 @@ subagents/
210
245
  |-- message.ts # generic messaging (file channel + send/reply/read + main-side router)
211
246
  |-- session.ts # common interactive session-handle interface
212
247
  |-- session-ui.ts # focused overlay for live transcript + interactive input
248
+ |-- task-state.ts # durable schema, validation, and branch reconstruction
249
+ |-- task-recovery.ts # stale-run and undelivered-result reconciliation planning
250
+ |-- task-delivery.ts # delivery IDs, durable dedupe, and recovery outbox
251
+ |-- task-status.ts # bounded live + persisted status formatting
213
252
  |-- orchestrator.md # main-agent adaptive delegation prompt (enabled with /orchestrate on)
214
253
  `-- README.md
215
254
  ```
@@ -230,6 +269,9 @@ pi --append-system-prompt ~/.pi/agent/extensions/subagents/orchestrator.md
230
269
  "Use subagent async=true, agent=actor, task=..." # explicit background delegation
231
270
  "Use subagent agent=reviewer timeoutSeconds=120 ..." # override the default 6h task timeout (only when the user asked)
232
271
  "Have reviewer review the recent changes" # main agent delegates to reviewer
272
+
273
+ /subagent-status # live tasks plus bounded current-branch history
274
+ /subagent-retry <full-run-id> # explicit retry; creates a new run id/address
233
275
  ```
234
276
 
235
277
  Main is not required to follow a fixed planner → actor → reviewer chain. It may