pi-long-task 0.5.0 → 0.6.0

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 CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  Notable changes to Pi Long Task are recorded here. This project follows semantic versioning.
4
4
 
5
+ ## 0.6.0 - 2026-09-05
6
+
7
+ ### Added
8
+
9
+ - Add opt-in coordinator-level recovery after Pi exhausts its bounded provider retries, with configurable jittered backoff, a bounded five-minute outage window by default, and an indefinite wait-until-cancelled mode.
10
+ - Show `Waiting for connection…` lifecycle status with retry and outage timing across worker, TODO planning, steering, goal planning/discovery, and review operations.
11
+ - Classify transient transport, timeout, stream, overload, rate-limit, and retryable server failures while failing fast for authentication, authorization, billing, quota, invalid request/model, certificate, cancellation, and unknown failures.
12
+
13
+ ### Changed
14
+
15
+ - Preserve TODO identity, ordinary attempt counts, durable evidence, accepted steering, working-tree changes, goal-loop state, and cost accounting while network recovery is active.
16
+ - Exclude network-recovery time and retries from worker, planner, reviewer, goal-loop timeout and retry budgets; rotate interrupted sessions before safely resuming the same operation.
17
+
18
+ ### Security and reliability
19
+
20
+ - Prevent blind replay of completed side-effectful worker actions by recording interruption evidence and requiring fresh continuation sessions to inspect durable state before acting.
21
+ - Keep cancellation immediate during backoff and retry execution, with exact-once cleanup of recovery timers, listeners, sessions, and status resources.
22
+
5
23
  ## 0.5.0 - 2026-08-31
6
24
 
7
25
  ### Added
package/README.md CHANGED
@@ -15,6 +15,7 @@ Use it when a coding request is bigger than one focused interaction. Pi Long Tas
15
15
  - **Take on bigger tasks:** split broad product, refactor, testing, or cleanup requests into smaller TODOs that Pi can complete one at a time.
16
16
  - **Track progress visibly:** in Pi TUI, see the active TODO, inferred `**Status:**` subtasks, completed/failed/blocked counts, and remaining work in the Pi Long Task sidebar while the run is active.
17
17
  - **Recover with retries:** tasks that do not report completion can be retried with context from previous attempts instead of losing the thread.
18
+ - **Wait through transient outages:** optionally pause after Pi exhausts its bounded provider retries, show connection-wait status, and safely resume the interrupted coordinator phase.
18
19
  - **Commit safely when asked:** enable commits for completed task work, while generated run files and pre-existing dirty files are kept out of those commits.
19
20
  - **Keep task artifacts:** every run writes a generated `TODO.md`, generated `TASK_RESULT.md`, attempt summaries, and final status under `tmp/pi-long-task/<run-id>/`.
20
21
  - **Watch cost visibility:** worker spend is captured and surfaced in progress and final summaries when usage cost data is available.
@@ -289,6 +290,73 @@ await runCoordinator({
289
290
 
290
291
  Explicit, complete `status: partial` results may continue in the same healthy, compatible, below-threshold session on the next attempt. All independent retries—including timeout, abort, cancellation, errors, invalid/incomplete results, and non-partial failures—start fresh. Existing retry limits and delays are unchanged. Setting `workerSessionReuse: false` (or the disabling directive) always isolates assignments.
291
292
 
293
+ ### Coordinator-level network recovery
294
+
295
+ Network recovery is **disabled by default** for backward compatibility. When enabled, it begins only after Pi has exhausted its own bounded provider-request retries. Pi Long Task then uses jittered exponential backoff starting at **1 second**, capped at **30 seconds**, for a maximum continuous outage of **5 minutes**. During recovery, progress displays `Waiting for connection…` with the retry number, next retry delay, or elapsed outage time. Cancellation interrupts both backoff waits and in-flight recovery calls immediately.
296
+
297
+ Add directives to `inputText` or to the global instructions of a pasted TODO plan. These examples cover every mode:
298
+
299
+ ```text
300
+ # Default: recovery is disabled; the timing defaults below are dormant.
301
+ Run a long task without commits to implement @TODO.md.
302
+ ```
303
+
304
+ ```text
305
+ # Bounded recovery using the default 1s base, 30s cap, and 5m outage window.
306
+ Network recovery: enabled
307
+ ```
308
+
309
+ ```text
310
+ # Bounded recovery with explicit timing.
311
+ Network recovery: enabled
312
+ Network recovery base delay: 2s
313
+ Network recovery maximum delay: 45s
314
+ Network recovery maximum outage: 10m
315
+ ```
316
+
317
+ ```text
318
+ # Explicitly retain fail-fast behavior after Pi's own request retries.
319
+ Network recovery: disabled
320
+ ```
321
+
322
+ To wait indefinitely while the provider or network remains unavailable, enable recovery and set the maximum outage to `unlimited`, `indefinite`, or `until cancelled`:
323
+
324
+ ```text
325
+ Network recovery: enabled
326
+ Network recovery maximum outage: until cancelled
327
+ ```
328
+
329
+ Indefinite mode has no outage deadline; it always remains cancellable. It does not turn deterministic errors into recoverable ones.
330
+
331
+ Programmatic `runCoordinator()` callers can pass the same policy as structured options; `pi_long_task` and `pi_goal_task` expose the same `networkRecovery` object in their tool parameters:
332
+
333
+ ```ts
334
+ await runCoordinator({
335
+ commit: false,
336
+ inputText: "implement the TODO plan",
337
+ networkRecovery: {
338
+ enabled: true,
339
+ baseDelayMs: 2_000,
340
+ maxDelayMs: 45_000,
341
+ maxOutageMs: 10 * 60_000,
342
+ },
343
+ });
344
+ ```
345
+
346
+ Use `maxOutageMs: null` for indefinite waiting or `enabled: false` to disable recovery. Durations must be positive finite safe integers, `maxDelayMs` must be at least `baseDelayMs`, and a bounded `maxOutageMs` must be at least `baseDelayMs`.
347
+
348
+ #### Recovery classification boundaries
349
+
350
+ Recovery is deliberately narrow. Recoverable failures include failed fetches; DNS, connection, and socket failures such as `ENOTFOUND`, `ECONNRESET`, or `ETIMEDOUT`; premature HTTP/WebSocket/stream termination; request and gateway timeouts; temporary provider overload; HTTP 408, 425, and overload-style 429 responses; and retryable server responses such as HTTP 500, 502, 503, and 504. Provider errors and nested causes are inspected so useful status, code, request ID, and retry metadata can be retained.
351
+
352
+ Authentication and authorization failures, billing or credit failures, exhausted account/usage quota, invalid models, malformed or unsupported requests, context-length and content-policy failures, most other 4xx responses, non-retryable server responses, certificate/configuration failures, coordinator timeouts, cancellation, and unknown errors fail immediately through the existing error path. Deterministic evidence wins over transient-looking wrapper text—for example, a 429 response that says the account quota is exhausted is not treated as temporary rate limiting.
353
+
354
+ #### Timeouts, limits, and preserved state
355
+
356
+ Network retries have their own counter and outage window. Recovery waits do not consume TODO attempts, planner repair retries, reviewer retries, or goal-loop iterations. Time attributed to network recovery is excluded from worker, TODO-planner, reviewer, goal-iteration, and overall goal-loop timeout budgets; while connectivity is unavailable, `maxOutageMs` (or cancellation in indefinite mode) is the recovery limit. Once the operation resumes, its ordinary timeout and retry rules still apply. If the outage window expires, the run fails with the last classified network failure retained as evidence.
357
+
358
+ Completed TODOs, current TODO identity and ordinary attempt number, durable attempt evidence, working-tree changes, accepted steering revisions, accumulated costs, and persisted goal/review state remain intact across an outage. An interrupted worker resumes the same TODO in a fresh session: the errored session is rotated, and the continuation is told to inspect the result artifact and current files before acting. This avoids blindly replaying already completed tool calls. The coordinator does not roll back external side effects, so tasks that call non-idempotent external systems should record durable completion/idempotency evidence that a resumed worker can verify.
359
+
292
360
  ### Reuse diagnostics and accounting
293
361
 
294
362
  Programmatic progress callbacks receive lifecycle updates with `phase: "worker_session"`. The additive fields are:
@@ -305,6 +373,7 @@ Pi session statistics can be cumulative across reused assignments. `outcomes[].w
305
373
  ## Feature reference
306
374
 
307
375
  - **Adaptive worker-session reuse:** reuse healthy compatible sessions below the 62.5% default context threshold, while preserving task boundaries and rotating conservatively.
376
+ - **Optional network recovery:** wait through classified transient provider/transport outages without consuming ordinary attempts, while keeping deterministic failures fail-fast and cancellation immediate.
308
377
  - **Real Pi TUI sidebar:** in TUI sessions, every TODO appears in a registered sidebar/widget with past, current, and future statuses so you can distinguish completed, active, upcoming, failed, blocked, and remaining work at a glance.
309
378
  - **Main-thread worker activity:** the active worker still streams commands, edits, verification, and its per-task `TASK_RESULT` back into the main Pi conversation; the sidebar does not replace tool-result rendering.
310
379
  - **Cost visibility:** worker spend is included in Pi Long Task progress and is added to the main Pi `$ spent` total when cost data is available.
@@ -415,24 +484,32 @@ Safety controls:
415
484
  - `iterationTimeoutMs` caps each generation, execution, and review sequence; default is `10800000` ms (3 hours).
416
485
  - `reviewerTimeoutMs` caps each reviewer session within the remaining overall and iteration budgets; default is `1800000` ms (30 minutes).
417
486
  - tool cancellation is passed through, bounded locally even if an SDK prompt does not settle after abort, and stops the loop with `cancelled` status.
487
+ - `networkRecovery` applies the same coordinator recovery policy to discovery, TODO generation/execution, and review; its wait time is excluded from goal-loop deadlines and iteration counts.
418
488
  - `maxAttemptsPerTask` and `maxBashTimeoutMs` are forwarded to worker long-task runs.
419
489
  - `commit` controls whether implementation workers may commit; goal loops default to `commit true`, so pass `commit false` when you want to review all changes first.
420
490
 
421
491
  ## Options
422
492
 
423
- `pi_long_task` has one required input and two optional inputs:
493
+ `pi_long_task` has one required input and three optional inputs:
424
494
 
425
495
  ```ts
426
496
  {
427
497
  commit: boolean;
428
498
  inputText?: string;
429
499
  goal?: string;
500
+ networkRecovery?: {
501
+ enabled?: boolean;
502
+ baseDelayMs?: number;
503
+ maxDelayMs?: number;
504
+ maxOutageMs?: number | null;
505
+ };
430
506
  }
431
507
  ```
432
508
 
433
509
  - `commit` controls whether Pi Long Task may create git commits.
434
510
  - `inputText` optionally provides the request or TODO markdown to work on.
435
511
  - `goal` optionally provides a high-level desired outcome that is passed to TODO planning and worker task prompts. Coverage goals such as `have testing line coverage above 80%` add coverage-specific planning and verification guidance.
512
+ - `networkRecovery` optionally enables and tunes coordinator-level transient network recovery. See [Coordinator-level network recovery](#coordinator-level-network-recovery) for defaults and safety behavior.
436
513
 
437
514
  `pi_goal_task` accepts a high-level goal plus safety controls:
438
515
 
@@ -447,6 +524,12 @@ Safety controls:
447
524
  reviewerTimeoutMs?: number;
448
525
  maxAttemptsPerTask?: number;
449
526
  maxBashTimeoutMs?: number;
527
+ networkRecovery?: {
528
+ enabled?: boolean;
529
+ baseDelayMs?: number;
530
+ maxDelayMs?: number;
531
+ maxOutageMs?: number | null;
532
+ };
450
533
  }
451
534
  ```
452
535
 
@@ -530,7 +613,7 @@ That smoke test creates disposable git repos and verifies both `commit: false` a
530
613
  - Tasks run sequentially, one TODO at a time; Pi Long Task prioritizes task isolation, progress tracking, and safe handoff over parallel execution. Adaptive reuse may share the underlying SDK session only while policy checks remain safe.
531
614
  - Natural-language TODO planning has a bounded time budget (five minutes by default, with a short graceful-shutdown request). If planning times out or is aborted before a valid plan exists, the run fails before worker tasks start and records planner diagnostics in `TASK_RESULT.md`.
532
615
  - If the planner returns invalid TODO markdown, Pi Long Task makes one repair attempt. A second invalid response fails planning with diagnostics instead of guessing at a plan.
533
- - Real runs require usable Pi model credentials, such as a working Pi login or API key for the selected model.
616
+ - Real runs require usable Pi model credentials, such as a working Pi login or API key for the selected model. Network recovery does not retry invalid or exhausted credentials, billing failures, or account quota exhaustion.
534
617
  - Worker spend is added to the main Pi `$ spent` total as cost-only usage. Token counts are not merged into the main thread because worker sessions have separate context windows, and merging their token usage would corrupt the main conversation's context statistics.
535
618
  - Run artifacts are written under `tmp/pi-long-task/<run-id>/`.
536
619
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-long-task",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Pi coding agent extension that breaks large coding requests into tracked TODOs and runs them in bounded, adaptively reused AI worker sessions. A long-running task runner and subagent orchestrator for Pi, with a live TUI progress sidebar, retries, goal loops, and optional per-task git commits.",
6
6
  "keywords": [