pi-harness-runtime 1.1.484 → 1.1.486

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/harness/pi-retry-visibility.ts +133 -0
  3. package/harness/provider-failure.ts +26 -0
  4. package/harness/provider-recovery-runtime.ts +480 -0
  5. package/index.ts +140 -224
  6. package/package.json +1 -1
  7. package/packages/agent-policy/package.json +1 -1
  8. package/packages/auth/package.json +1 -1
  9. package/packages/autonomous-runtime/package.json +1 -1
  10. package/packages/checkpoint/package.json +1 -1
  11. package/packages/clipboard/package.json +1 -1
  12. package/packages/codex-watcher/package.json +1 -1
  13. package/packages/config-capture/package.json +1 -1
  14. package/packages/contracts/package.json +1 -1
  15. package/packages/cookie-sanitizer/package.json +1 -1
  16. package/packages/evaluation-engine/package.json +1 -1
  17. package/packages/event-bus/package.json +1 -1
  18. package/packages/event-store/package.json +1 -1
  19. package/packages/experience-replay/package.json +1 -1
  20. package/packages/file-copy-helper/package.json +1 -1
  21. package/packages/intent-analyzer/package.json +1 -1
  22. package/packages/jev-judge/dist/continuation-controller.d.ts +8 -0
  23. package/packages/jev-judge/dist/continuation-controller.d.ts.map +1 -1
  24. package/packages/jev-judge/dist/continuation-controller.js +10 -0
  25. package/packages/jev-judge/dist/continuation-controller.js.map +1 -1
  26. package/packages/jev-judge/package.json +1 -1
  27. package/packages/jev-judge/src/continuation-controller.ts +11 -0
  28. package/packages/knowledge-retrieval/package.json +1 -1
  29. package/packages/learning-engine/package.json +1 -1
  30. package/packages/logging/package.json +1 -1
  31. package/packages/memory-engine/package.json +1 -1
  32. package/packages/notification/package.json +1 -1
  33. package/packages/paperclip-integration/package.json +1 -1
  34. package/packages/performance-optimizer/package.json +1 -1
  35. package/packages/privilege-broker/package.json +1 -1
  36. package/packages/prompt-compiler/package.json +1 -1
  37. package/packages/providers/package.json +1 -1
  38. package/packages/qdrant-skills/package.json +1 -1
  39. package/packages/quota-manager/package.json +1 -1
  40. package/packages/relay/package.json +1 -1
  41. package/packages/skill-mcp-client/package.json +1 -1
  42. package/packages/skills/package.json +1 -1
  43. package/packages/todo-bd-sync/package.json +1 -1
  44. package/packages/token-estimation/package.json +1 -1
  45. package/packages/tooling-preference/package.json +1 -1
  46. package/packages/trajectory/package.json +1 -1
  47. package/packages/tui/package.json +1 -1
  48. package/packages/two-phase-review/package.json +1 -1
  49. package/packages/types/package.json +1 -1
  50. package/packages/webmcp-tester/package.json +1 -1
  51. package/packages/wiki/package.json +1 -1
  52. package/packages/write-review/package.json +1 -1
  53. package/proactive-compact.ts +17 -3
package/index.ts CHANGED
@@ -59,7 +59,8 @@ import {
59
59
  createPendingActionRegistry,
60
60
  createPendingActionTicker,
61
61
  } from "./harness/pending-actions.ts";
62
- import { classifyProviderFailure } from "./harness/provider-failure.ts";
62
+ import { classifyProviderFailure, usesBoundedRecovery } from "./harness/provider-failure.ts";
63
+ import { ProviderRecoveryRuntime } from "./harness/provider-recovery-runtime.ts";
63
64
  import type { ProviderFailure } from "./harness/provider-failure.ts";
64
65
  import {
65
66
  createProviderRecoveryController,
@@ -108,11 +109,13 @@ import { registerGithubLoginCommand } from "./packages/clipboard/dist/src/github
108
109
  import {
109
110
  MAX_PROACTIVE_COMPACT_FAILURES,
110
111
  OUTPUT_LIMIT_RESUME_PROMPT,
112
+ PROVIDER_OVERLOAD_AUTO_RESUME_LIMIT,
111
113
  PROVIDER_OVERLOAD_RESUME_PROMPT,
112
114
  getProviderOverloadResumeDelayMs,
113
115
  PROACTIVE_COMPACT_COOLDOWN_MS,
114
116
  shouldQueueOutputLimitResume,
115
117
  shouldQueueProviderOverloadResume,
118
+ isProviderRetryFailedReport,
116
119
  shouldQueuePostCompactionResume,
117
120
  shouldTriggerProactiveCompact,
118
121
  } from "./proactive-compact.ts";
@@ -380,41 +383,47 @@ const PROVIDER_RECOVERY_ACTION_ID = "provider-recovery";
380
383
  const PROVIDER_BLOCKED_ACTION_ID = "provider-blocked";
381
384
 
382
385
  /**
383
- * The controller of the bounded recovery cycles.
386
+ * The runtime of the automatic resumes after a provider failure.
384
387
  *
385
- * The controller decides the deadlines of the attempts; the executor that
386
- * owns the resume stays the only owner of the execution.
388
+ * The runtime owns the sequence of a failure: it waits for the settled
389
+ * boundary, and it checks that a scheduled resume still owns the session
390
+ * before it dispatches. The Jev scope uses it to cancel the pending
391
+ * resumes when the user pauses the work.
387
392
  */
388
- const providerRecovery = createProviderRecoveryController();
393
+ let providerRecoveryRuntime: ProviderRecoveryRuntime | null = null;
389
394
 
390
395
  /**
391
- * The timer of the pending recovery attempt.
396
+ * The continuation controller of the todos.
392
397
  *
393
- * It is the executor of the attempt, so it owns the deadline it shows.
398
+ * The runtime reads the pause state of the user through this handle: the
399
+ * injected resume is a resume, and a resume that ignores a pause overrides
400
+ * the decision of the user.
394
401
  */
395
- let providerRecoveryTimer: ReturnType<typeof setTimeout> | null = null;
402
+ let todoContinuationHandle: { isExplicitlyPaused(): boolean } | null = null;
396
403
 
397
404
  /**
398
- * The counter of the failures that carry no identity.
405
+ * The context of the running extension.
399
406
  *
400
- * A failure without a response id still needs its own identity, so a copy
401
- * of it cannot be mistaken for a later attempt.
407
+ * The context knows whether messages wait in the queue. A resume that
408
+ * injects itself while the user is typing competes with the user.
402
409
  */
403
- let providerFailureCounter = 0;
410
+ let activeExtensionContext: ExtensionContext | null = null;
404
411
 
405
412
  /**
406
- * Cancel a pending recovery attempt.
413
+ * The controller of the bounded recovery cycles.
407
414
  *
408
- * The cycle ends with it: a cancelled attempt is not an attempt of the
409
- * budget.
415
+ * The controller decides the deadlines of the attempts; the executor that
416
+ * owns the resume stays the only owner of the execution.
410
417
  */
411
- function clearProviderRecoveryAttempt(): void {
412
- if (providerRecoveryTimer) {
413
- clearTimeout(providerRecoveryTimer);
414
- providerRecoveryTimer = null;
415
- }
416
- pendingActions.remove(PROVIDER_RECOVERY_ACTION_ID);
417
- }
418
+ const providerRecovery = createProviderRecoveryController();
419
+
420
+ /**
421
+ * The counter of the failures that carry no identity.
422
+ *
423
+ * A failure without a response id still needs its own identity, so a copy
424
+ * of it cannot be mistaken for a later attempt.
425
+ */
426
+ let providerFailureCounter = 0;
418
427
 
419
428
  /**
420
429
  * The identity of the pending action of the decision of the judge.
@@ -1569,6 +1578,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1569
1578
 
1570
1579
  // Capture UI context from session_start
1571
1580
  pi.on("session_start", (_event, ctx) => {
1581
+ // The context of the running extension: a resume checks it
1582
+ // before it dispatches, so it does not compete with the user.
1583
+ activeExtensionContext = ctx;
1572
1584
  // The session of the runtime: the countdown of a question belongs
1573
1585
  // to the session that asked it.
1574
1586
  const sessionId = (
@@ -1631,7 +1643,10 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1631
1643
  pendingActionTicker.stop();
1632
1644
  pendingActions.clear();
1633
1645
  providerRecovery.clear();
1634
- clearProviderRecoveryAttempt();
1646
+ // The pending resumes die with the session: a restart does not
1647
+ // inherit a countdown, a blocked provider, or a resume that would
1648
+ // inject itself into the new session.
1649
+ providerRecoveryRuntime?.reset();
1635
1650
  setPendingActionsStatus?.(undefined);
1636
1651
  setPendingActionsStatus = null;
1637
1652
  activeSessionId = "";
@@ -1945,6 +1960,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1945
1960
  // so nothing but an explicit resume directive clears
1946
1961
  // it.
1947
1962
  (sharedState.todoContinuationController as any)?.explicitPause?.();
1963
+ // The user took over: a pending resume of the provider
1964
+ // would inject itself against the decline.
1965
+ providerRecoveryRuntime?.cancel();
1948
1966
  logToFile(
1949
1967
  "[auto-continue]",
1950
1968
  "The reply declined the proposal; the work is paused",
@@ -2470,6 +2488,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2470
2488
  validationLedger,
2471
2489
  }
2472
2490
  );
2491
+ // The runtime of the provider recovery reads the pause state
2492
+ // of the user through this handle.
2493
+ todoContinuationHandle = todoContinuationController;
2473
2494
  logToFile("[auto-continue]", "Todo continuation controller initialized");
2474
2495
  } catch (err) {
2475
2496
  logToFile("[auto-continue]", "Failed to create todo continuation controller:", String(err));
@@ -2482,6 +2503,7 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2482
2503
  // keep a timer alive nor block a later continuation.
2483
2504
  todoContinuationController?.dispose?.();
2484
2505
  todoContinuationController = null;
2506
+ todoContinuationHandle = null;
2485
2507
  sharedState.validationLedger = null;
2486
2508
  });
2487
2509
 
@@ -2554,6 +2576,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2554
2576
  todoContinuationController.explicitPause();
2555
2577
  logToFile("[auto-continue]", "Explicit pause/stop detected");
2556
2578
  }
2579
+ // The user took over: a pending resume would inject
2580
+ // itself against the decision of the user.
2581
+ providerRecoveryRuntime?.cancel();
2557
2582
  // Invalidate any pending Jev evaluations to prevent late dispatch
2558
2583
  if (taskIntakeController) {
2559
2584
  taskIntakeController.invalidatePending();
@@ -6378,7 +6403,61 @@ Run \`bd ready\` to see current bd issues.
6378
6403
  });
6379
6404
 
6380
6405
  // --- Auto-track every assistant message ------------------------------
6406
+ // The runtime of the automatic resumes after a provider failure.
6407
+ //
6408
+ // The runtime owns the sequence of a failure: the failure waits for the
6409
+ // settled boundary, because Pi retries a failed turn internally first,
6410
+ // and a scheduled resume checks that it still owns the session before it
6411
+ // dispatches. The resume itself goes through the executor below, so
6412
+ // there is no second resume loop.
6413
+ providerRecoveryRuntime = new ProviderRecoveryRuntime({
6414
+ controller: providerRecovery,
6415
+ actions: pendingActions,
6416
+ recoveryActionId: PROVIDER_RECOVERY_ACTION_ID,
6417
+ blockedActionId: PROVIDER_BLOCKED_ACTION_ID,
6418
+ overloadActionId: PROVIDER_OVERLOAD_ACTION_ID,
6419
+ maxAttempts: MAX_RECOVERY_ATTEMPTS,
6420
+ context: () => ({
6421
+ sessionId: activeSessionId,
6422
+ explicitlyPaused: todoContinuationHandle?.isExplicitlyPaused() ?? false,
6423
+ questionPending:
6424
+ sharedState.pqController?.hasPendingQuestion?.() ?? false,
6425
+ }),
6426
+ resetEvidence: (failure) => applicableResetEvidence(failure),
6427
+ overloadDelayMs: () => getProviderOverloadResumeDelayMs(),
6428
+ overloadMaxAttempts: PROVIDER_OVERLOAD_AUTO_RESUME_LIMIT,
6429
+ dispatch: async (reason) => {
6430
+ // The user is typing: a resume that injects itself now competes
6431
+ // with the user.
6432
+ if (activeExtensionContext?.hasPendingMessages()) {
6433
+ logToFile("[pi-harness]", "Resume skipped: hasPendingMessages=true");
6434
+ return;
6435
+ }
6436
+ await queueAutoResume(reason, PROVIDER_OVERLOAD_RESUME_PROMPT, "followUp");
6437
+ },
6438
+ log: (message) => logToFile("[pi-harness]", message),
6439
+ });
6440
+
6441
+ // The run settled: the internal retries of Pi are over, so a failure
6442
+ // that waited for the boundary is final and the recovery starts now.
6443
+ //
6444
+ // An aborted run is a decision of the user, not a failure of the
6445
+ // provider: an automatic resume would fight the user.
6446
+ pi.on("agent_settled", (event) => {
6447
+ // The flag of the abort is optional: the installed core of Pi does
6448
+ // not carry it yet, a newer one does. The check reads it when it is
6449
+ // there, and it never assumes that it is.
6450
+ if ("aborted" in event && event.aborted === true) {
6451
+ providerRecoveryRuntime?.cancel();
6452
+ return;
6453
+ }
6454
+ providerRecoveryRuntime?.noteSettled();
6455
+ });
6456
+
6381
6457
  pi.on("message_end", async (event, ctx) => {
6458
+ // The context of the running extension: the resume checks it before
6459
+ // it dispatches, so it does not compete with the user.
6460
+ activeExtensionContext = ctx;
6382
6461
  if (isOutputLimitResumePromptMessage(event.message)) {
6383
6462
  pendingOutputLimitResumeAfterSettled = false;
6384
6463
  return;
@@ -6423,23 +6502,39 @@ Run \`bd ready\` to see current bd issues.
6423
6502
  })();
6424
6503
 
6425
6504
  if (providerFailure) {
6426
- const recoverable =
6427
- providerFailure.recovery === "bounded-recovery" ||
6428
- providerFailure.recovery === "retry-after";
6429
- if (recoverable) {
6430
- // The bounded recovery cycle decides the deadline of the next
6431
- // attempt. The identity of the failure keeps a repeated copy
6432
- // of the same error from starting a second cycle.
6433
- let failureKey =
6434
- typeof m.responseId === "string" && m.responseId.length > 0
6435
- ? m.responseId
6436
- : "";
6437
- if (!failureKey) {
6438
- providerFailureCounter += 1;
6439
- failureKey = `${activeSessionId}:${providerFailureCounter}`;
6440
- }
6441
- scheduleProviderRecovery(providerFailure, failureKey);
6442
- } else if (!providerFailure.retryable) {
6505
+ // The failure is a candidate: the recovery starts when the run
6506
+ // settles, because Pi retries a failed turn internally first.
6507
+ // A recovery that starts at the message of the failed attempt is
6508
+ // a competing continuation.
6509
+ let failureKey =
6510
+ typeof m.responseId === "string" && m.responseId.length > 0
6511
+ ? m.responseId
6512
+ : "";
6513
+ if (!failureKey) {
6514
+ providerFailureCounter += 1;
6515
+ failureKey = `${activeSessionId}:${providerFailureCounter}`;
6516
+ }
6517
+ if (providerFailure.retryable) {
6518
+ // The identity of the failure keeps a repeated copy of the
6519
+ // same error from starting a second cycle.
6520
+ const overloadEligible =
6521
+ providerFailure.kind === "overload" &&
6522
+ !isProviderRetryFailedReport(readMessageText(event.message)) &&
6523
+ shouldQueueProviderOverloadResume(
6524
+ m,
6525
+ providerRecoveryRuntime?.overloadAttemptCount ?? 0,
6526
+ ctx.hasPendingMessages(),
6527
+ { detected: true },
6528
+ );
6529
+ providerRecoveryRuntime?.noteFailure(providerFailure, failureKey, {
6530
+ ...(typeof m.provider === "string" ? { provider: m.provider } : {}),
6531
+ overloadEligible,
6532
+ // The classification owns the policy: a rate limit and an
6533
+ // exhausted plan join the cycle, an overload keeps its own
6534
+ // executor. One failure has one executor.
6535
+ boundedEligible: usesBoundedRecovery(providerFailure),
6536
+ });
6537
+ } else {
6443
6538
  // No automatic retry can fix this failure: the row says that
6444
6539
  // nothing is scheduled.
6445
6540
  pendingActions.register({
@@ -6475,38 +6570,16 @@ Run \`bd ready\` to see current bd issues.
6475
6570
  requirement: "Session output",
6476
6571
  error: `Attempt ${outputLimitResumeAttempts}`,
6477
6572
  });
6478
- } else if (
6479
- shouldQueueProviderOverloadResume(
6480
- m,
6481
- providerOverloadResumeAttempts,
6482
- ctx.hasPendingMessages(),
6483
- )
6484
- ) {
6485
- providerOverloadResumeAttempts += 1;
6486
- logToFile("[pi-harness]", `Scheduling provider overload resume #${providerOverloadResumeAttempts}`);
6487
- scheduleProviderOverloadResume(() => ctx.hasPendingMessages());
6488
6573
  } else if (m.stopReason === "stop") {
6489
6574
  outputLimitResumeAttempts = 0;
6490
6575
  pendingOutputLimitResumeAfterSettled = false;
6491
- if (providerOverloadResumeAttempts > 0) {
6492
- logToFile("[pi-harness]", `Counter reset (stopReason=stop), was=${providerOverloadResumeAttempts}`);
6493
- }
6494
- providerOverloadResumeAttempts = 0;
6495
- clearProviderOverloadResume();
6496
6576
  // The turn completed: the provider works again. The recovery
6497
6577
  // cycle ends with it, so the next failure starts at the first
6498
- // attempt, and a pending attempt of the cycle is cancelled.
6499
- if (typeof m.provider === "string" && m.provider.length > 0) {
6500
- providerRecovery.noteSuccess({
6501
- sessionId: activeSessionId,
6502
- provider: m.provider.toLowerCase(),
6503
- });
6504
- }
6505
- clearProviderRecoveryAttempt();
6506
- // The turn completed: a provider that was blocked is not blocked
6507
- // any more. The row of the blocked provider leaves with it.
6508
- pendingActions.removeWhere(
6509
- (action) => action.owner === "provider" && action.state === "blocked",
6578
+ // attempt, and a pending attempt of the cycle is cancelled. A
6579
+ // provider that was blocked is not blocked any more, and its row
6580
+ // leaves with it.
6581
+ providerRecoveryRuntime?.noteSuccess(
6582
+ typeof m.provider === "string" ? m.provider : undefined,
6510
6583
  );
6511
6584
 
6512
6585
  // --- Auto-Continue: Check todos and keep going -------------------------------
@@ -6728,8 +6801,6 @@ Run \`bd ready\` to see current bd issues.
6728
6801
  let outputLimitResumeAttempts = 0;
6729
6802
  let pendingOutputLimitResumeAfterCompact = false;
6730
6803
  let pendingOutputLimitResumeAfterSettled = false;
6731
- let providerOverloadResumeAttempts = 0;
6732
- let providerOverloadResumeTimer: ReturnType<typeof setTimeout> | null = null;
6733
6804
 
6734
6805
  // --- Context-usage escalating warning tiers -----------------------------
6735
6806
  // Amber at 75%, red at 85%. No notify above 90% (proactive compact handles it).
@@ -7942,16 +8013,6 @@ Run \`bd ready\` to see current bd issues.
7942
8013
  }
7943
8014
  }, MINIMAX_REFRESH_MIN_INTERVAL_MS);
7944
8015
 
7945
- function clearProviderOverloadResume(): void {
7946
- if (providerOverloadResumeTimer) {
7947
- clearTimeout(providerOverloadResumeTimer);
7948
- providerOverloadResumeTimer = null;
7949
- }
7950
- // The pending action goes with the timer: a cancelled resume has no
7951
- // countdown any more.
7952
- pendingActions.remove(PROVIDER_OVERLOAD_ACTION_ID);
7953
- }
7954
-
7955
8016
  /**
7956
8017
  * The reset of the provider that applies to a failure.
7957
8018
  *
@@ -7986,151 +8047,6 @@ Run \`bd ready\` to see current bd issues.
7986
8047
  };
7987
8048
  }
7988
8049
 
7989
- /**
7990
- * React to a provider failure that the bounded recovery may retry.
7991
- *
7992
- * The cycle decides the deadline of the attempt; the existing
7993
- * auto-resume executor sends the resume, so there is no second resume
7994
- * loop. The pending action shows the exact deadline the executor uses.
7995
- */
7996
- function scheduleProviderRecovery(
7997
- failure: ProviderFailure,
7998
- failureKey: string,
7999
- ): void {
8000
- const provider = failure.provider ?? "provider";
8001
- const outcome = providerRecovery.noteFailure(
8002
- {
8003
- failureKey,
8004
- sessionId: activeSessionId,
8005
- // The cycle is keyed by the id of the provider, so a cycle of
8006
- // "MiniMax" and a successful turn of "minimax" are the same
8007
- // cycle.
8008
- provider: provider.toLowerCase(),
8009
- kind: failure.kind,
8010
- ...(failure.window ? { window: failure.window } : {}),
8011
- ...(failure.retryAfterMs !== undefined
8012
- ? { retryAfterAt: Date.now() + failure.retryAfterMs }
8013
- : {}),
8014
- },
8015
- applicableResetEvidence(failure),
8016
- );
8017
-
8018
- if (outcome.outcome === "scheduled") {
8019
- logToFile(
8020
- "[pi-harness]",
8021
- `Provider recovery attempt ${outcome.attempt}/${MAX_RECOVERY_ATTEMPTS} at ${new Date(outcome.dueAt).toISOString()} (bound=${outcome.boundBy})`,
8022
- );
8023
- startProviderRecoveryAttempt(outcome.dueAt, outcome.attempt, failure);
8024
- return;
8025
- }
8026
-
8027
- if (outcome.outcome === "blocked") {
8028
- logToFile(
8029
- "[pi-harness]",
8030
- `Provider recovery exhausted after ${outcome.attempt} attempts`,
8031
- );
8032
- pendingActions.register({
8033
- id: PROVIDER_BLOCKED_ACTION_ID,
8034
- sessionId: activeSessionId,
8035
- owner: "provider",
8036
- kind: "retry",
8037
- state: "blocked",
8038
- ...(failure.provider ? { provider: failure.provider } : {}),
8039
- ...(failure.code ? { code: failure.code } : {}),
8040
- reason: `recovery attempts exhausted (${outcome.attempt}/${MAX_RECOVERY_ATTEMPTS})`,
8041
- });
8042
- return;
8043
- }
8044
-
8045
- // "already-scheduled" and "duplicate": the cycle does not move. The
8046
- // row of the pending attempt is already there.
8047
- logToFile(
8048
- "[pi-harness]",
8049
- `Provider recovery unchanged (${outcome.outcome}), attempt ${outcome.attempt}`,
8050
- );
8051
- }
8052
-
8053
- /**
8054
- * Start the timer of a recovery attempt.
8055
- *
8056
- * The timer is the executor, so it owns the deadline: the row of the
8057
- * pending action shows the deadline the timer really uses.
8058
- */
8059
- function startProviderRecoveryAttempt(
8060
- dueAt: number,
8061
- attempt: number,
8062
- failure: ProviderFailure,
8063
- ): void {
8064
- clearProviderRecoveryAttempt();
8065
- pendingActions.register({
8066
- id: PROVIDER_RECOVERY_ACTION_ID,
8067
- sessionId: activeSessionId,
8068
- owner: "provider-recovery",
8069
- kind: "retry",
8070
- state: "scheduled",
8071
- dueAt,
8072
- attempt,
8073
- maxAttempts: MAX_RECOVERY_ATTEMPTS,
8074
- ...(failure.provider ? { provider: failure.provider } : {}),
8075
- ...(failure.code ? { code: failure.code } : {}),
8076
- reason: failure.reason,
8077
- });
8078
- const delayMs = Math.max(0, dueAt - Date.now());
8079
- providerRecoveryTimer = setTimeout(() => {
8080
- providerRecoveryTimer = null;
8081
- // The row leaves when the attempt runs: a countdown must not stay
8082
- // at 00:00.
8083
- pendingActions.remove(PROVIDER_RECOVERY_ACTION_ID);
8084
- void queueAutoResume(
8085
- "provider-recovery",
8086
- PROVIDER_OVERLOAD_RESUME_PROMPT,
8087
- "followUp",
8088
- );
8089
- }, delayMs);
8090
- }
8091
-
8092
- function scheduleProviderOverloadResume(
8093
- hasPendingMessages: () => boolean,
8094
- ): void {
8095
- clearProviderOverloadResume();
8096
- const delayMs = getProviderOverloadResumeDelayMs();
8097
- const delayMinutes = Math.max(1, Math.round(delayMs / 60_000));
8098
- logToFile(
8099
- "[pi-harness]",
8100
- `Provider overloaded; scheduling resume in ${delayMinutes} min (${delayMs}ms) attempt=${providerOverloadResumeAttempts}`,
8101
- );
8102
- // The timer is the executor of the resume, so the timer owns the
8103
- // deadline: the row of the pending action shows the deadline the
8104
- // timer really uses, never another one.
8105
- const dueAt = Date.now() + delayMs;
8106
- pendingActions.register({
8107
- id: PROVIDER_OVERLOAD_ACTION_ID,
8108
- sessionId: activeSessionId,
8109
- owner: "provider-overload",
8110
- kind: "retry",
8111
- state: "scheduled",
8112
- dueAt,
8113
- attempt: providerOverloadResumeAttempts,
8114
- reason: "the provider is overloaded",
8115
- });
8116
- providerOverloadResumeTimer = setTimeout(() => {
8117
- providerOverloadResumeTimer = null;
8118
- // The action leaves the row when it fires: the countdown must
8119
- // not stay at 00:00.
8120
- pendingActions.remove(PROVIDER_OVERLOAD_ACTION_ID);
8121
- logToFile("[pi-harness]", 'Provider resume timer fired, sending "resume"');
8122
- if (hasPendingMessages()) {
8123
- logToFile("[pi-harness]", "Resume skipped: hasPendingMessages=true");
8124
- return;
8125
- }
8126
- void queueAutoResume(
8127
- "provider-overload",
8128
- PROVIDER_OVERLOAD_RESUME_PROMPT,
8129
- "followUp",
8130
- );
8131
- }, delayMs);
8132
- }
8133
-
8134
8050
  async function queueAutoResume(
8135
8051
  reason: string,
8136
8052
  content: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-harness-runtime",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "[BETA] Codex-style /usage status + autonomous coding harness for pi. Not production ready — expect breaking changes.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/agent-policy",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "Agent policy runtime for pi-harness - enforces mandatory rule delivery and mutation gating",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/auth",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "pi-harness-runtime — auth",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/autonomous-runtime",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "Autonomous Operations Runtime — task inbox, lease management, and worker lifecycle (RFC-0101)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/checkpoint",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "Enhanced checkpoint system with incremental snapshots, diff-based storage, and recovery strategies",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/clipboard",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/codex-watcher",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "Watches Codex CLI sessions and emits visible messages for PING-PONG monitoring",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/config-capture",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "Auto-capture API-fetched configuration values to AGENTS.md",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/contracts",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "type": "module",
5
5
  "description": "RPC schema definitions for pi-harness runtime",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/cookie-sanitizer",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "pi-harness-runtime — cookie sanitizer (provider-quota cookie file normaliser)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/evaluation-engine",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "Evaluation engine for pi-harness runtime (RFC-0057)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/event-bus",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/event-store",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/experience-replay",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "Experience replay for debugging and reproducibility (RFC-0059)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/file-copy-helper",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "description": "Injects cp/sudo cp rule when user asks to mimic/copy files",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/intent-analyzer",
3
- "version": "1.1.484",
3
+ "version": "1.1.486",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -210,6 +210,14 @@ export declare class TodoContinuationController {
210
210
  * User explicitly paused - only this clears on explicit resume
211
211
  */
212
212
  explicitPause(): void;
213
+ /**
214
+ * Whether the user paused the work explicitly.
215
+ *
216
+ * Only an explicit resume clears the pause. The harness reads the state
217
+ * before it injects a resume: the injected message is a resume, and a
218
+ * resume that ignores a pause overrides the decision of the user.
219
+ */
220
+ isExplicitlyPaused(): boolean;
213
221
  /**
214
222
  * Resume from explicit pause
215
223
  */