pi-harness-runtime 1.1.485 → 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 (51) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/harness/provider-failure.ts +3 -0
  3. package/harness/provider-recovery-runtime.ts +480 -0
  4. package/index.ts +138 -231
  5. package/package.json +1 -1
  6. package/packages/agent-policy/package.json +1 -1
  7. package/packages/auth/package.json +1 -1
  8. package/packages/autonomous-runtime/package.json +1 -1
  9. package/packages/checkpoint/package.json +1 -1
  10. package/packages/clipboard/package.json +1 -1
  11. package/packages/codex-watcher/package.json +1 -1
  12. package/packages/config-capture/package.json +1 -1
  13. package/packages/contracts/package.json +1 -1
  14. package/packages/cookie-sanitizer/package.json +1 -1
  15. package/packages/evaluation-engine/package.json +1 -1
  16. package/packages/event-bus/package.json +1 -1
  17. package/packages/event-store/package.json +1 -1
  18. package/packages/experience-replay/package.json +1 -1
  19. package/packages/file-copy-helper/package.json +1 -1
  20. package/packages/intent-analyzer/package.json +1 -1
  21. package/packages/jev-judge/dist/continuation-controller.d.ts +8 -0
  22. package/packages/jev-judge/dist/continuation-controller.d.ts.map +1 -1
  23. package/packages/jev-judge/dist/continuation-controller.js +10 -0
  24. package/packages/jev-judge/dist/continuation-controller.js.map +1 -1
  25. package/packages/jev-judge/package.json +1 -1
  26. package/packages/jev-judge/src/continuation-controller.ts +11 -0
  27. package/packages/knowledge-retrieval/package.json +1 -1
  28. package/packages/learning-engine/package.json +1 -1
  29. package/packages/logging/package.json +1 -1
  30. package/packages/memory-engine/package.json +1 -1
  31. package/packages/notification/package.json +1 -1
  32. package/packages/paperclip-integration/package.json +1 -1
  33. package/packages/performance-optimizer/package.json +1 -1
  34. package/packages/privilege-broker/package.json +1 -1
  35. package/packages/prompt-compiler/package.json +1 -1
  36. package/packages/providers/package.json +1 -1
  37. package/packages/qdrant-skills/package.json +1 -1
  38. package/packages/quota-manager/package.json +1 -1
  39. package/packages/relay/package.json +1 -1
  40. package/packages/skill-mcp-client/package.json +1 -1
  41. package/packages/skills/package.json +1 -1
  42. package/packages/todo-bd-sync/package.json +1 -1
  43. package/packages/token-estimation/package.json +1 -1
  44. package/packages/tooling-preference/package.json +1 -1
  45. package/packages/trajectory/package.json +1 -1
  46. package/packages/tui/package.json +1 -1
  47. package/packages/two-phase-review/package.json +1 -1
  48. package/packages/types/package.json +1 -1
  49. package/packages/webmcp-tester/package.json +1 -1
  50. package/packages/wiki/package.json +1 -1
  51. package/packages/write-review/package.json +1 -1
package/index.ts CHANGED
@@ -60,6 +60,7 @@ import {
60
60
  createPendingActionTicker,
61
61
  } from "./harness/pending-actions.ts";
62
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,6 +109,7 @@ 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,
@@ -381,41 +383,47 @@ const PROVIDER_RECOVERY_ACTION_ID = "provider-recovery";
381
383
  const PROVIDER_BLOCKED_ACTION_ID = "provider-blocked";
382
384
 
383
385
  /**
384
- * The controller of the bounded recovery cycles.
386
+ * The runtime of the automatic resumes after a provider failure.
385
387
  *
386
- * The controller decides the deadlines of the attempts; the executor that
387
- * 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.
388
392
  */
389
- const providerRecovery = createProviderRecoveryController();
393
+ let providerRecoveryRuntime: ProviderRecoveryRuntime | null = null;
390
394
 
391
395
  /**
392
- * The timer of the pending recovery attempt.
396
+ * The continuation controller of the todos.
393
397
  *
394
- * 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.
395
401
  */
396
- let providerRecoveryTimer: ReturnType<typeof setTimeout> | null = null;
402
+ let todoContinuationHandle: { isExplicitlyPaused(): boolean } | null = null;
397
403
 
398
404
  /**
399
- * The counter of the failures that carry no identity.
405
+ * The context of the running extension.
400
406
  *
401
- * A failure without a response id still needs its own identity, so a copy
402
- * 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.
403
409
  */
404
- let providerFailureCounter = 0;
410
+ let activeExtensionContext: ExtensionContext | null = null;
405
411
 
406
412
  /**
407
- * Cancel a pending recovery attempt.
413
+ * The controller of the bounded recovery cycles.
408
414
  *
409
- * The cycle ends with it: a cancelled attempt is not an attempt of the
410
- * budget.
415
+ * The controller decides the deadlines of the attempts; the executor that
416
+ * owns the resume stays the only owner of the execution.
411
417
  */
412
- function clearProviderRecoveryAttempt(): void {
413
- if (providerRecoveryTimer) {
414
- clearTimeout(providerRecoveryTimer);
415
- providerRecoveryTimer = null;
416
- }
417
- pendingActions.remove(PROVIDER_RECOVERY_ACTION_ID);
418
- }
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;
419
427
 
420
428
  /**
421
429
  * The identity of the pending action of the decision of the judge.
@@ -1570,6 +1578,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1570
1578
 
1571
1579
  // Capture UI context from session_start
1572
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;
1573
1584
  // The session of the runtime: the countdown of a question belongs
1574
1585
  // to the session that asked it.
1575
1586
  const sessionId = (
@@ -1632,7 +1643,10 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1632
1643
  pendingActionTicker.stop();
1633
1644
  pendingActions.clear();
1634
1645
  providerRecovery.clear();
1635
- 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();
1636
1650
  setPendingActionsStatus?.(undefined);
1637
1651
  setPendingActionsStatus = null;
1638
1652
  activeSessionId = "";
@@ -1946,6 +1960,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1946
1960
  // so nothing but an explicit resume directive clears
1947
1961
  // it.
1948
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();
1949
1966
  logToFile(
1950
1967
  "[auto-continue]",
1951
1968
  "The reply declined the proposal; the work is paused",
@@ -2471,6 +2488,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2471
2488
  validationLedger,
2472
2489
  }
2473
2490
  );
2491
+ // The runtime of the provider recovery reads the pause state
2492
+ // of the user through this handle.
2493
+ todoContinuationHandle = todoContinuationController;
2474
2494
  logToFile("[auto-continue]", "Todo continuation controller initialized");
2475
2495
  } catch (err) {
2476
2496
  logToFile("[auto-continue]", "Failed to create todo continuation controller:", String(err));
@@ -2483,6 +2503,7 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2483
2503
  // keep a timer alive nor block a later continuation.
2484
2504
  todoContinuationController?.dispose?.();
2485
2505
  todoContinuationController = null;
2506
+ todoContinuationHandle = null;
2486
2507
  sharedState.validationLedger = null;
2487
2508
  });
2488
2509
 
@@ -2555,6 +2576,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2555
2576
  todoContinuationController.explicitPause();
2556
2577
  logToFile("[auto-continue]", "Explicit pause/stop detected");
2557
2578
  }
2579
+ // The user took over: a pending resume would inject
2580
+ // itself against the decision of the user.
2581
+ providerRecoveryRuntime?.cancel();
2558
2582
  // Invalidate any pending Jev evaluations to prevent late dispatch
2559
2583
  if (taskIntakeController) {
2560
2584
  taskIntakeController.invalidatePending();
@@ -6379,7 +6403,61 @@ Run \`bd ready\` to see current bd issues.
6379
6403
  });
6380
6404
 
6381
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
+
6382
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;
6383
6461
  if (isOutputLimitResumePromptMessage(event.message)) {
6384
6462
  pendingOutputLimitResumeAfterSettled = false;
6385
6463
  return;
@@ -6424,23 +6502,39 @@ Run \`bd ready\` to see current bd issues.
6424
6502
  })();
6425
6503
 
6426
6504
  if (providerFailure) {
6427
- // The bounded recovery cycle owns the rate limit and the exhausted
6428
- // plan. An overload keeps its own executor, so one failure never
6429
- // ends up with two resume loops.
6430
- if (usesBoundedRecovery(providerFailure)) {
6431
- // The bounded recovery cycle decides the deadline of the next
6432
- // attempt. The identity of the failure keeps a repeated copy
6433
- // of the same error from starting a second cycle.
6434
- let failureKey =
6435
- typeof m.responseId === "string" && m.responseId.length > 0
6436
- ? m.responseId
6437
- : "";
6438
- if (!failureKey) {
6439
- providerFailureCounter += 1;
6440
- failureKey = `${activeSessionId}:${providerFailureCounter}`;
6441
- }
6442
- scheduleProviderRecovery(providerFailure, failureKey);
6443
- } 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 {
6444
6538
  // No automatic retry can fix this failure: the row says that
6445
6539
  // nothing is scheduled.
6446
6540
  pendingActions.register({
@@ -6476,46 +6570,16 @@ Run \`bd ready\` to see current bd issues.
6476
6570
  requirement: "Session output",
6477
6571
  error: `Attempt ${outputLimitResumeAttempts}`,
6478
6572
  });
6479
- } else if (
6480
- shouldQueueProviderOverloadResume(
6481
- m,
6482
- providerOverloadResumeAttempts,
6483
- ctx.hasPendingMessages(),
6484
- {
6485
- // The classification may know an overload that the text
6486
- // of the answer does not repeat. A report of exhausted
6487
- // retries of the SDK is not a fresh failure.
6488
- detected:
6489
- providerFailure?.kind === "overload" &&
6490
- !isProviderRetryFailedReport(readMessageText(event.message)),
6491
- },
6492
- )
6493
- ) {
6494
- providerOverloadResumeAttempts += 1;
6495
- logToFile("[pi-harness]", `Scheduling provider overload resume #${providerOverloadResumeAttempts}`);
6496
- scheduleProviderOverloadResume(() => ctx.hasPendingMessages());
6497
6573
  } else if (m.stopReason === "stop") {
6498
6574
  outputLimitResumeAttempts = 0;
6499
6575
  pendingOutputLimitResumeAfterSettled = false;
6500
- if (providerOverloadResumeAttempts > 0) {
6501
- logToFile("[pi-harness]", `Counter reset (stopReason=stop), was=${providerOverloadResumeAttempts}`);
6502
- }
6503
- providerOverloadResumeAttempts = 0;
6504
- clearProviderOverloadResume();
6505
6576
  // The turn completed: the provider works again. The recovery
6506
6577
  // cycle ends with it, so the next failure starts at the first
6507
- // attempt, and a pending attempt of the cycle is cancelled.
6508
- if (typeof m.provider === "string" && m.provider.length > 0) {
6509
- providerRecovery.noteSuccess({
6510
- sessionId: activeSessionId,
6511
- provider: m.provider.toLowerCase(),
6512
- });
6513
- }
6514
- clearProviderRecoveryAttempt();
6515
- // The turn completed: a provider that was blocked is not blocked
6516
- // any more. The row of the blocked provider leaves with it.
6517
- pendingActions.removeWhere(
6518
- (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,
6519
6583
  );
6520
6584
 
6521
6585
  // --- Auto-Continue: Check todos and keep going -------------------------------
@@ -6737,8 +6801,6 @@ Run \`bd ready\` to see current bd issues.
6737
6801
  let outputLimitResumeAttempts = 0;
6738
6802
  let pendingOutputLimitResumeAfterCompact = false;
6739
6803
  let pendingOutputLimitResumeAfterSettled = false;
6740
- let providerOverloadResumeAttempts = 0;
6741
- let providerOverloadResumeTimer: ReturnType<typeof setTimeout> | null = null;
6742
6804
 
6743
6805
  // --- Context-usage escalating warning tiers -----------------------------
6744
6806
  // Amber at 75%, red at 85%. No notify above 90% (proactive compact handles it).
@@ -7951,16 +8013,6 @@ Run \`bd ready\` to see current bd issues.
7951
8013
  }
7952
8014
  }, MINIMAX_REFRESH_MIN_INTERVAL_MS);
7953
8015
 
7954
- function clearProviderOverloadResume(): void {
7955
- if (providerOverloadResumeTimer) {
7956
- clearTimeout(providerOverloadResumeTimer);
7957
- providerOverloadResumeTimer = null;
7958
- }
7959
- // The pending action goes with the timer: a cancelled resume has no
7960
- // countdown any more.
7961
- pendingActions.remove(PROVIDER_OVERLOAD_ACTION_ID);
7962
- }
7963
-
7964
8016
  /**
7965
8017
  * The reset of the provider that applies to a failure.
7966
8018
  *
@@ -7995,151 +8047,6 @@ Run \`bd ready\` to see current bd issues.
7995
8047
  };
7996
8048
  }
7997
8049
 
7998
- /**
7999
- * React to a provider failure that the bounded recovery may retry.
8000
- *
8001
- * The cycle decides the deadline of the attempt; the existing
8002
- * auto-resume executor sends the resume, so there is no second resume
8003
- * loop. The pending action shows the exact deadline the executor uses.
8004
- */
8005
- function scheduleProviderRecovery(
8006
- failure: ProviderFailure,
8007
- failureKey: string,
8008
- ): void {
8009
- const provider = failure.provider ?? "provider";
8010
- const outcome = providerRecovery.noteFailure(
8011
- {
8012
- failureKey,
8013
- sessionId: activeSessionId,
8014
- // The cycle is keyed by the id of the provider, so a cycle of
8015
- // "MiniMax" and a successful turn of "minimax" are the same
8016
- // cycle.
8017
- provider: provider.toLowerCase(),
8018
- kind: failure.kind,
8019
- ...(failure.window ? { window: failure.window } : {}),
8020
- ...(failure.retryAfterMs !== undefined
8021
- ? { retryAfterAt: Date.now() + failure.retryAfterMs }
8022
- : {}),
8023
- },
8024
- applicableResetEvidence(failure),
8025
- );
8026
-
8027
- if (outcome.outcome === "scheduled") {
8028
- logToFile(
8029
- "[pi-harness]",
8030
- `Provider recovery attempt ${outcome.attempt}/${MAX_RECOVERY_ATTEMPTS} at ${new Date(outcome.dueAt).toISOString()} (bound=${outcome.boundBy})`,
8031
- );
8032
- startProviderRecoveryAttempt(outcome.dueAt, outcome.attempt, failure);
8033
- return;
8034
- }
8035
-
8036
- if (outcome.outcome === "blocked") {
8037
- logToFile(
8038
- "[pi-harness]",
8039
- `Provider recovery exhausted after ${outcome.attempt} attempts`,
8040
- );
8041
- pendingActions.register({
8042
- id: PROVIDER_BLOCKED_ACTION_ID,
8043
- sessionId: activeSessionId,
8044
- owner: "provider",
8045
- kind: "retry",
8046
- state: "blocked",
8047
- ...(failure.provider ? { provider: failure.provider } : {}),
8048
- ...(failure.code ? { code: failure.code } : {}),
8049
- reason: `recovery attempts exhausted (${outcome.attempt}/${MAX_RECOVERY_ATTEMPTS})`,
8050
- });
8051
- return;
8052
- }
8053
-
8054
- // "already-scheduled" and "duplicate": the cycle does not move. The
8055
- // row of the pending attempt is already there.
8056
- logToFile(
8057
- "[pi-harness]",
8058
- `Provider recovery unchanged (${outcome.outcome}), attempt ${outcome.attempt}`,
8059
- );
8060
- }
8061
-
8062
- /**
8063
- * Start the timer of a recovery attempt.
8064
- *
8065
- * The timer is the executor, so it owns the deadline: the row of the
8066
- * pending action shows the deadline the timer really uses.
8067
- */
8068
- function startProviderRecoveryAttempt(
8069
- dueAt: number,
8070
- attempt: number,
8071
- failure: ProviderFailure,
8072
- ): void {
8073
- clearProviderRecoveryAttempt();
8074
- pendingActions.register({
8075
- id: PROVIDER_RECOVERY_ACTION_ID,
8076
- sessionId: activeSessionId,
8077
- owner: "provider-recovery",
8078
- kind: "retry",
8079
- state: "scheduled",
8080
- dueAt,
8081
- attempt,
8082
- maxAttempts: MAX_RECOVERY_ATTEMPTS,
8083
- ...(failure.provider ? { provider: failure.provider } : {}),
8084
- ...(failure.code ? { code: failure.code } : {}),
8085
- reason: failure.reason,
8086
- });
8087
- const delayMs = Math.max(0, dueAt - Date.now());
8088
- providerRecoveryTimer = setTimeout(() => {
8089
- providerRecoveryTimer = null;
8090
- // The row leaves when the attempt runs: a countdown must not stay
8091
- // at 00:00.
8092
- pendingActions.remove(PROVIDER_RECOVERY_ACTION_ID);
8093
- void queueAutoResume(
8094
- "provider-recovery",
8095
- PROVIDER_OVERLOAD_RESUME_PROMPT,
8096
- "followUp",
8097
- );
8098
- }, delayMs);
8099
- }
8100
-
8101
- function scheduleProviderOverloadResume(
8102
- hasPendingMessages: () => boolean,
8103
- ): void {
8104
- clearProviderOverloadResume();
8105
- const delayMs = getProviderOverloadResumeDelayMs();
8106
- const delayMinutes = Math.max(1, Math.round(delayMs / 60_000));
8107
- logToFile(
8108
- "[pi-harness]",
8109
- `Provider overloaded; scheduling resume in ${delayMinutes} min (${delayMs}ms) attempt=${providerOverloadResumeAttempts}`,
8110
- );
8111
- // The timer is the executor of the resume, so the timer owns the
8112
- // deadline: the row of the pending action shows the deadline the
8113
- // timer really uses, never another one.
8114
- const dueAt = Date.now() + delayMs;
8115
- pendingActions.register({
8116
- id: PROVIDER_OVERLOAD_ACTION_ID,
8117
- sessionId: activeSessionId,
8118
- owner: "provider-overload",
8119
- kind: "retry",
8120
- state: "scheduled",
8121
- dueAt,
8122
- attempt: providerOverloadResumeAttempts,
8123
- reason: "the provider is overloaded",
8124
- });
8125
- providerOverloadResumeTimer = setTimeout(() => {
8126
- providerOverloadResumeTimer = null;
8127
- // The action leaves the row when it fires: the countdown must
8128
- // not stay at 00:00.
8129
- pendingActions.remove(PROVIDER_OVERLOAD_ACTION_ID);
8130
- logToFile("[pi-harness]", 'Provider resume timer fired, sending "resume"');
8131
- if (hasPendingMessages()) {
8132
- logToFile("[pi-harness]", "Resume skipped: hasPendingMessages=true");
8133
- return;
8134
- }
8135
- void queueAutoResume(
8136
- "provider-overload",
8137
- PROVIDER_OVERLOAD_RESUME_PROMPT,
8138
- "followUp",
8139
- );
8140
- }, delayMs);
8141
- }
8142
-
8143
8050
  async function queueAutoResume(
8144
8051
  reason: string,
8145
8052
  content: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-harness-runtime",
3
- "version": "1.1.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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.485",
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
  */