pi-better-harness 0.68.3 → 0.68.4

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 (148) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +15 -6
  3. package/bin/pi-better-doctor.mjs +23 -0
  4. package/docs/runtime-doctor.md +60 -0
  5. package/extensions/execution-policy.ts +1 -1
  6. package/extensions/minimal-output/index.ts +60 -47
  7. package/extensions/runtime-doctor/index.ts +67 -0
  8. package/extensions/settings/commands.ts +1 -1
  9. package/extensions/settings/copy.ts +1 -7
  10. package/extensions/settings/index.ts +2 -1
  11. package/extensions/settings/page.ts +9 -4
  12. package/extensions/settings/runtime-modes.ts +25 -0
  13. package/extensions/settings/supervisor.ts +1 -0
  14. package/extensions/shared-harness-settings.ts +5 -0
  15. package/extensions/shared-runtime-mode-settings.ts +25 -0
  16. package/extensions/shared-runtime-mode.ts +108 -0
  17. package/extensions/supervisor/commitments.ts +56 -18
  18. package/extensions/supervisor/delivery-progress.ts +50 -0
  19. package/extensions/supervisor/delivery.ts +146 -0
  20. package/extensions/supervisor/index.ts +41 -14
  21. package/extensions/supervisor/recipient.ts +291 -0
  22. package/extensions/tool-call-guard/waits.ts +1 -1
  23. package/lib/console-daemon.mjs +12 -1
  24. package/lib/console-icons.svg +4 -0
  25. package/lib/console-shell.mjs +40 -2
  26. package/lib/console-ui.mjs +92 -7
  27. package/lib/local-session-ui.mjs +15 -8
  28. package/lib/prompt-ui.mjs +6 -1
  29. package/lib/prompt-web.mjs +3 -2
  30. package/lib/prompt.css +31 -0
  31. package/lib/runtime-doctor.mjs +12 -0
  32. package/lib/supervisor-ui.mjs +324 -0
  33. package/node_modules/pi-better-background-tasks/README.md +12 -2
  34. package/node_modules/pi-better-background-tasks/package.json +4 -3
  35. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-arm64.json +1 -1
  36. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-x64.json +1 -1
  37. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-arm64.json +1 -1
  38. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-x64.json +1 -1
  39. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/win32-x64.json +1 -1
  40. package/node_modules/pi-better-background-tasks/runtime-client/scripts/private-runtime/format.mjs +1 -0
  41. package/node_modules/pi-better-background-tasks/runtime-client/src/runtime/client.mjs +34 -11
  42. package/node_modules/pi-better-background-tasks/runtime-client/src/runtime/root.mjs +38 -28
  43. package/node_modules/pi-better-background-tasks/runtime-client/src/runtime/startup-worker.mjs +4 -0
  44. package/node_modules/pi-better-background-tasks/runtime-client/src/runtime/windows-directory.mjs +73 -37
  45. package/node_modules/pi-better-background-tasks/runtime-client/src/runtime/work-client.mjs +4 -4
  46. package/node_modules/pi-better-background-tasks/runtime-client/src/startup/artifact.mjs +39 -10
  47. package/node_modules/pi-better-background-tasks/runtime-client/src/startup/stage-local.mjs +96 -42
  48. package/node_modules/pi-better-background-tasks/src/adapter-contract.ts +5 -4
  49. package/node_modules/pi-better-background-tasks/src/direct-frontend.ts +196 -0
  50. package/node_modules/pi-better-background-tasks/src/direct-windows-job.mjs +18 -0
  51. package/node_modules/pi-better-background-tasks/src/execution-mode.ts +16 -0
  52. package/node_modules/pi-better-background-tasks/src/goal-provider.ts +3 -1
  53. package/node_modules/pi-better-background-tasks/src/index.ts +13 -15
  54. package/node_modules/pi-better-background-tasks/src/managed-authority.ts +27 -1
  55. package/node_modules/pi-better-background-tasks/src/managed-client.ts +29 -8
  56. package/node_modules/pi-better-background-tasks/src/managed-frontend.ts +131 -8
  57. package/node_modules/pi-better-background-tasks/src/navigator-provider.ts +45 -10
  58. package/node_modules/pi-better-background-tasks/src/observed-waits.ts +9 -3
  59. package/node_modules/pi-better-background-tasks/src/output.ts +58 -16
  60. package/node_modules/pi-better-background-tasks/src/process.ts +85 -7
  61. package/node_modules/pi-better-background-tasks/src/prompt.ts +11 -6
  62. package/node_modules/pi-better-background-tasks/src/registry.ts +11 -1
  63. package/node_modules/pi-better-background-tasks/src/runtime.ts +105 -22
  64. package/node_modules/pi-better-background-tasks/src/shared-execution-policy.ts +1 -1
  65. package/node_modules/pi-better-background-tasks/src/shared-harness-commands.ts +1 -1
  66. package/node_modules/pi-better-background-tasks/src/shared-harness-copy.ts +1 -7
  67. package/node_modules/pi-better-background-tasks/src/shared-harness-page.ts +9 -4
  68. package/node_modules/pi-better-background-tasks/src/shared-harness-settings.ts +5 -0
  69. package/node_modules/pi-better-background-tasks/src/shared-navigator.ts +87 -39
  70. package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/index.ts +21 -0
  71. package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/errors.ts +6 -0
  72. package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/schema.ts +9 -0
  73. package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/store.ts +3 -0
  74. package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/supervisor-review-schema.ts +65 -0
  75. package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/supervisor-reviews.ts +534 -0
  76. package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/validate.ts +14 -5
  77. package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/waits.ts +2 -1
  78. package/node_modules/pi-better-background-tasks/src/shared-runtime-fallback-state.ts +45 -0
  79. package/node_modules/pi-better-background-tasks/src/shared-runtime-mode-settings.ts +25 -0
  80. package/node_modules/pi-better-background-tasks/src/shared-runtime-mode.ts +108 -0
  81. package/node_modules/pi-better-background-tasks/src/shared-sandbox-core.ts +2 -0
  82. package/node_modules/pi-better-background-tasks/src/shared-sandbox-diagnostics.ts +8 -5
  83. package/node_modules/pi-better-background-tasks/src/shared-work-client.mjs +4 -4
  84. package/node_modules/pi-better-background-tasks/src/stall.ts +2 -2
  85. package/node_modules/pi-better-background-tasks/src/supervisor/README.md +4 -4
  86. package/node_modules/pi-better-background-tasks/src/supervisor/emit-runner.mjs +34 -20
  87. package/node_modules/pi-better-background-tasks/src/supervisor/generated/direct-windows-job.mjs +20 -0
  88. package/node_modules/pi-better-background-tasks/src/supervisor/generated/process.mjs +119 -17
  89. package/node_modules/pi-better-background-tasks/src/tools.ts +44 -4
  90. package/node_modules/pi-better-background-tasks/src/types.ts +5 -0
  91. package/node_modules/pi-better-background-tasks/src/work-observation.ts +3 -1
  92. package/node_modules/pi-better-goal/src/shared-harness-commands.ts +1 -1
  93. package/node_modules/pi-better-goal/src/shared-harness-copy.ts +1 -7
  94. package/node_modules/pi-better-goal/src/shared-harness-page.ts +9 -4
  95. package/node_modules/pi-better-goal/src/shared-harness-settings.ts +5 -0
  96. package/node_modules/pi-better-sandbox/shared-harness-commands.ts +1 -1
  97. package/node_modules/pi-better-sandbox/shared-harness-copy.ts +1 -7
  98. package/node_modules/pi-better-sandbox/shared-harness-page.ts +9 -4
  99. package/node_modules/pi-better-sandbox/shared-harness-settings.ts +5 -0
  100. package/node_modules/pi-better-sandbox/shared-sandbox-core.ts +2 -0
  101. package/node_modules/pi-better-sandbox/shared-sandbox-diagnostics.ts +8 -5
  102. package/node_modules/pi-better-subagents/README.md +13 -9
  103. package/node_modules/pi-better-subagents/batch.mjs +32 -0
  104. package/node_modules/pi-better-subagents/catalog-host-admission.ts +32 -16
  105. package/node_modules/pi-better-subagents/child-operations.ts +8 -0
  106. package/node_modules/pi-better-subagents/config.ts +24 -14
  107. package/node_modules/pi-better-subagents/direct-owner.ts +9 -4
  108. package/node_modules/pi-better-subagents/effective-settings.ts +8 -4
  109. package/node_modules/pi-better-subagents/index.ts +102 -39
  110. package/node_modules/pi-better-subagents/managed-launch-client.ts +19 -5
  111. package/node_modules/pi-better-subagents/package.json +2 -2
  112. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-arm64.json +1 -1
  113. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-x64.json +1 -1
  114. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-arm64.json +1 -1
  115. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-x64.json +1 -1
  116. package/node_modules/pi-better-subagents/runtime-client/artifacts/win32-x64.json +1 -1
  117. package/node_modules/pi-better-subagents/runtime-client/scripts/private-runtime/format.mjs +1 -0
  118. package/node_modules/pi-better-subagents/runtime-client/src/runtime/client.mjs +34 -11
  119. package/node_modules/pi-better-subagents/runtime-client/src/runtime/root.mjs +38 -28
  120. package/node_modules/pi-better-subagents/runtime-client/src/runtime/startup-worker.mjs +4 -0
  121. package/node_modules/pi-better-subagents/runtime-client/src/runtime/windows-directory.mjs +73 -37
  122. package/node_modules/pi-better-subagents/runtime-client/src/runtime/work-client.mjs +4 -4
  123. package/node_modules/pi-better-subagents/runtime-client/src/startup/artifact.mjs +39 -10
  124. package/node_modules/pi-better-subagents/runtime-client/src/startup/stage-local.mjs +96 -42
  125. package/node_modules/pi-better-subagents/settings-page.ts +9 -7
  126. package/node_modules/pi-better-subagents/shared-catalog.ts +28 -7
  127. package/node_modules/pi-better-subagents/shared-execution-policy.ts +1 -1
  128. package/node_modules/pi-better-subagents/shared-harness-commands.ts +1 -1
  129. package/node_modules/pi-better-subagents/shared-harness-copy.ts +1 -7
  130. package/node_modules/pi-better-subagents/shared-harness-page.ts +9 -4
  131. package/node_modules/pi-better-subagents/shared-harness-settings.ts +5 -0
  132. package/node_modules/pi-better-subagents/shared-navigator.ts +87 -39
  133. package/node_modules/pi-better-subagents/shared-operation-coordinator/index.ts +21 -0
  134. package/node_modules/pi-better-subagents/shared-operation-coordinator/src/errors.ts +6 -0
  135. package/node_modules/pi-better-subagents/shared-operation-coordinator/src/schema.ts +9 -0
  136. package/node_modules/pi-better-subagents/shared-operation-coordinator/src/store.ts +3 -0
  137. package/node_modules/pi-better-subagents/shared-operation-coordinator/src/supervisor-review-schema.ts +65 -0
  138. package/node_modules/pi-better-subagents/shared-operation-coordinator/src/supervisor-reviews.ts +534 -0
  139. package/node_modules/pi-better-subagents/shared-operation-coordinator/src/validate.ts +14 -5
  140. package/node_modules/pi-better-subagents/shared-operation-coordinator/src/waits.ts +2 -1
  141. package/node_modules/pi-better-subagents/shared-runtime-fallback-state.ts +45 -0
  142. package/node_modules/pi-better-subagents/shared-runtime-mode-settings.ts +25 -0
  143. package/node_modules/pi-better-subagents/shared-runtime-mode.ts +108 -0
  144. package/node_modules/pi-better-subagents/shared-sandbox-core.ts +2 -0
  145. package/node_modules/pi-better-subagents/shared-sandbox-diagnostics.ts +8 -5
  146. package/node_modules/pi-better-subagents/shared-work-client.mjs +4 -4
  147. package/node_modules/pi-better-subagents/spawn.ts +16 -11
  148. package/package.json +12 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.68.4] - 2026-12-06
4
+
5
+ ### Changed
6
+
7
+ - Install the smaller shared Server package with Subagents and Background Tasks.
8
+
3
9
  ## [0.68.3] - 2026-12-05
4
10
 
5
11
  ### Changed
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <h1 align="center"><picture><source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/1aboveio/pi-better-harness/main/docs/images/brand/logo-on-charcoal.webp"><img src="https://raw.githubusercontent.com/1aboveio/pi-better-harness/main/docs/images/brand/logo.png" alt="" width="34" height="34" align="absmiddle"></picture> Pi Better Harness</h1>
2
2
 
3
- <p align="center">Track each step in <a href="https://pi.dev">Pi</a> and keep using the prompt while tests run or a second Pi reviews your code.</p>
3
+ <p align="center"><strong>Make <a href="https://pi.dev">Pi</a> a reliable coding agent.</strong> Track progress in Todo and keep using the prompt while tests run or a subagent reviews your code.</p>
4
4
 
5
5
  [Watch the terminal demo · MP4, 31s](https://cdn.jsdelivr.net/gh/1aboveio/pi-better-harness@readme-media-v1/csv-release-check.mp4) · The HD preview plays as it loads.
6
6
 
@@ -16,18 +16,27 @@
16
16
 
17
17
  ## Installation
18
18
 
19
- With Pi installed, run these commands in your project.
19
+ With [Pi](https://pi.dev) installed, choose either method and run it from your project. The Pi Package Catalog command installs Harness as one bundle.
20
+
21
+ ```sh
22
+ pi install npm:pi-better-harness
23
+ ```
24
+
25
+ Use the Harness installer to register its component extensions as separate Pi packages.
20
26
 
21
27
  ```sh
22
28
  npx pi-better-harness install
23
- pi
24
29
  ```
25
30
 
26
31
  Windows x64 supports managed tasks that can run without kernel sandboxing.
27
32
 
28
- In a project with tests, try this prompt.
33
+ ### Quick Start
34
+
35
+ Start `pi`. In a project with an npm test script, try this prompt.
36
+
37
+ > Run `npm test` in the background. Tell me when it starts so I can ask a question, then report whether it passed when it finishes.
29
38
 
30
- > Run npm test in the background. Tell me when it starts so I can ask a question.
39
+ For a longer task, save a Goal with acceptance criteria and start it with `/goal resume`. Pi can check the completed work against those criteria and show progress in Todo.
31
40
 
32
41
  [More installation options](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-harness/docs/usage.md#install) · [Settings](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-harness/README.md#harness-settings) · [Platform support](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-harness/README.md#compatibility)
33
42
 
@@ -74,7 +83,7 @@ Ask Pi a question while `npm test` runs. The task row shows elapsed time, and **
74
83
  | ![](https://raw.githubusercontent.com/1aboveio/pi-better-harness/c432f23d19d0f8dc97c99258f24e1be2d36f739c/docs/images/readme/background-tasks.svg) | **[Background tasks](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-background-tasks/docs/usage.md#tools)**<br> Run a build or test with `bg_task_spawn` and keep using the prompt. Pi receives a completion notice and can inspect the task's status and logs after `/reload`. |
75
84
  | ![](https://raw.githubusercontent.com/1aboveio/pi-better-harness/c432f23d19d0f8dc97c99258f24e1be2d36f739c/docs/images/readme/subagents.svg) | **[Subagents](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-subagents/docs/usage.md#tools)**<br> Delegate a review or run several workers in parallel. The parent can read each worker's findings with `subagent_result` and continue the same worker conversation for a follow-up. |
76
85
  | ![](https://raw.githubusercontent.com/1aboveio/pi-better-harness/c432f23d19d0f8dc97c99258f24e1be2d36f739c/docs/images/readme/goal-todo.svg) | **[Goal & Todo](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-goal/README.md#goal--todo-in-harness)**<br> The checklist survives reload and context compaction. An active Goal can resume when background work finishes. To mark it complete, the agent must close open Todo items and provide evidence for each recorded acceptance criterion. |
77
- | ![](https://raw.githubusercontent.com/1aboveio/pi-better-harness/c432f23d19d0f8dc97c99258f24e1be2d36f739c/docs/images/readme/sandbox.svg) | **[Sandbox](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-sandbox/README.md)**<br> Set file and network permissions separately for the main session, subagents, and local background tasks. For example, give a reviewer read-only project access while the main session edits. Each profile starts off in fresh settings. |
86
+ | ![](https://raw.githubusercontent.com/1aboveio/pi-better-harness/c432f23d19d0f8dc97c99258f24e1be2d36f739c/docs/images/readme/sandbox.svg) | **[Sandbox](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-sandbox/README.md)**<br> Opt in to separate file and network permissions for the main session, subagents, and local background tasks on supported platforms. For example, give a reviewer read-only project access while the main session edits. |
78
87
  | ![](https://raw.githubusercontent.com/1aboveio/pi-better-harness/c432f23d19d0f8dc97c99258f24e1be2d36f739c/docs/images/readme/prompt-manager.svg) | **[Prompt Manager](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-harness/README.md#try-a-prompt-edit)**<br> Edit and version Harness instructions in the Web console. Replay a captured request against two revisions and review the results before promoting a change. |
79
88
  | ![](https://raw.githubusercontent.com/1aboveio/pi-better-harness/c432f23d19d0f8dc97c99258f24e1be2d36f739c/docs/images/readme/visual.svg) | **[Visual task tracking](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-harness/README.md#harness-settings)**<br> Tree view groups background jobs under the agent that launched them, with status and logs for each job. In the transcript, consecutive tool calls fold into one row. Press Ctrl+O to inspect the original output. |
80
89
  | ![](https://raw.githubusercontent.com/1aboveio/pi-better-harness/c432f23d19d0f8dc97c99258f24e1be2d36f739c/docs/images/readme/openai.svg) | **[OpenAI Optimization](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-harness/README.md#openai-native-compaction)**<br> On supported OpenAI and Codex Responses routes, native compaction saves a context window Pi can reuse after restart. Separately, you can enable [official Codex instruction templates](https://github.com/1aboveio/pi-better-harness/blob/main/packages/pi-better-harness/README.md#official-codex-model-prompts) for matching models. |
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ import { runDoctor } from "../lib/runtime-doctor.mjs";
3
+
4
+ const usage = "Usage: pi-better-doctor [--json] [--probe]";
5
+ const args = process.argv.slice(2);
6
+ if (args.includes("--help")) console.log(usage);
7
+ else if (args.some(arg => arg !== "--json" && arg !== "--probe")) {
8
+ console.error(usage);
9
+ process.exitCode = 2;
10
+ } else {
11
+ const controller = new AbortController();
12
+ const cancel = () => controller.abort();
13
+ process.on("SIGINT", cancel).on("SIGTERM", cancel);
14
+ try {
15
+ const { report, text } = await runDoctor({ probe: args.includes("--probe"), signal: controller.signal });
16
+ console.log(args.includes("--json") ? JSON.stringify(report, null, 2) : text);
17
+ } catch {
18
+ console.error("Runtime Doctor could not load. Check the host Node version and reinstall matching Harness and Server packages.");
19
+ process.exitCode = 1;
20
+ } finally {
21
+ process.off("SIGINT", cancel).off("SIGTERM", cancel);
22
+ }
23
+ }
@@ -0,0 +1,60 @@
1
+ # Runtime Doctor
2
+
3
+ Run the Doctor included with `pi-better-harness` from a shell where your installed npm commands are on `PATH`. Use the same shell environment and account that launch Pi. The CLI needs a working host Node 22 or later. If the npm shim cannot locate Node, fix that launch first. Inside Pi, `/harness-doctor` opens a scrollable report with a copy action.
4
+
5
+ ```sh
6
+ pi-better-doctor
7
+ pi-better-doctor --json
8
+ pi-better-doctor --probe --json
9
+ ```
10
+
11
+ The default report observes the current machine. It checks packaged build pins and archives, the production cache candidates, existing registration, Windows directory security and, where verified, the existing service's local status handshake. It does not start the runtime, stage code, migrate settings, or upload the report. Windows policy evidence comes from at most 32 recent events per channel over five minutes and matches observed executable paths. A difference in event path representation, an inaccessible log, or no matching event leaves policy unknown.
12
+
13
+ Doctor reads the saved requested and effective execution modes for Subagents and Background Tasks. `modeSource` follows the settings UI and identifies a `component` override, the `global` choice, or the product `default`. The CLI has no live launch receipts. Inside Pi, Doctor can also report backend observations and confirmed Auto fallback from the current session. An untested backend or a missing fallback receipt stays unconfirmed, even when the filesystem and launcher checks pass.
14
+
15
+ `--probe` and `/harness-doctor --probe` opt into disposable storage checks and restricted process launches. The Managed process check runs a verified cached Node with `--version`. The Direct check uses the worker bootstrap with `--version` only when Doctor can identify and verify the SDK launcher. An OS execution refusal stops later launches, including the Windows policy-log reader. Each process check has a three-second deadline. Ctrl+C at the CLI or Esc in Pi cancels collection. Actual launch preflight depends on the requested tools, model, and permissions. Even two successful launcher probes do not establish that a public launch will succeed.
16
+
17
+ Treat `missing` as a path component or artifact that was absent. Treatments differ by stage. A fresh cache can be absent before the first Managed launch. An absent package pin or archive calls for checking the matching installed package set. `untrusted-allow` indicates that production refused a grant. `ancestor-up-1` identifies the candidate's immediate parent. Share the category, scope, and mask with IT when asking for an approved private cache. Keep registration and durable state separate from the executable cache.
18
+
19
+ ## Shareable reports
20
+
21
+ Both views use the same redacted report. Paths appear as fixed product-relative components, candidate roles, or ancestor distances. Report data omits account names, SIDs, command lines, credential values and event messages. Footprints are logical bytes and may be partial. On Windows, the CI fixture is a synthetic ordinary-user Windows Server environment. Its results do not describe a particular enterprise Windows 11 machine.
22
+
23
+ Illustrative excerpt:
24
+
25
+ ```text
26
+ Runtime Doctor v1 (passive, redacted)
27
+ Primary blockers: cache.configured-cache
28
+ [fail] cache.configured-cache (untrusted-allow) Production refused an untrusted Allow ACE. object=ancestor-up-1 principal=untrusted-or-unresolved rightsMask=0x1201bf scope=code-ancestor aceFlags=0x10 inherited=true inheritsToFiles=false inheritsToDirectories=false inheritOnly=false
29
+ [pass] direct.mode (mode-resolved) Saved Subagents execution mode. mode=auto source=product-default requestedMode=inherit effectiveMode=auto modeSource=default
30
+ [unknown] auto.fallback (no-launch-receipt) Auto can fall back only when Managed fails before submission. Doctor did not observe a public-tool launch receipt.
31
+ ```
32
+
33
+ JSON v1 fields:
34
+
35
+ - `schemaVersion` is `1`. `redacted` is `true`. `mode` is `passive` or `probe`.
36
+ - `primaryBlockers` lists check IDs for observed failures. An individual candidate refusal is primary only if all candidates are known to be blocked.
37
+ - `checks` contains `id`, `stage`, `status`, `severity`, `confidence`, `reason`, `detail`, `evidence`, and an optional `remedy`. Use `id` and `reason` for programmatic filtering and expect new checks and codes over time. `detail` and `remedy` are for display.
38
+ - `status` is `pass`, `fail`, `warn`, `unknown`, or `not-tested`. `severity` is `info`, `warning`, or `error`. `confidence` is `observed`, `inferred`, `unavailable`, or `not-probed`. Each check defines its evidence keys. Values contain only redacted strings, numbers, booleans, null, or arrays of strings.
39
+ - The CLI exits successfully when it produces a report, including when that report identifies blockers. It returns `2` for invalid arguments and `1` if it cannot load the report engine.
40
+
41
+ ```json
42
+ {
43
+ "schemaVersion": 1,
44
+ "redacted": true,
45
+ "mode": "passive",
46
+ "primaryBlockers": [],
47
+ "checks": [
48
+ {
49
+ "id": "probe",
50
+ "stage": "probe",
51
+ "status": "not-tested",
52
+ "severity": "info",
53
+ "confidence": "not-probed",
54
+ "reason": "opt-in-required",
55
+ "detail": "Active checks require an explicit --probe.",
56
+ "evidence": {}
57
+ }
58
+ ]
59
+ }
60
+ ```
@@ -27,7 +27,7 @@ export const EXECUTION_POLICY_TEXT: string = [
27
27
  "Serialize only for a concrete dependency, conflicting writes or ownership, resource or concurrency limit, documented rollout gate, or explicit availability requirement. Record the reason in the plan or explain it to the user. Do not invent a canary or host-by-host availability requirement.",
28
28
  "If concurrency raises an unresolved material operational trade-off, ask the user once before the affected operations and continue independent preparation meanwhile. Existing authorization, safety checks, workflow prerequisites, and human-approved rollout constraints remain binding; urgency does not waive them.",
29
29
  "Choose the execution mechanism after deciding what can run together: foreground tools for small, tightly coupled, or interactive work; subagents for bounded independent reasoning or implementation when the active delegation mode permits; background tasks for independent long-running commands or waits. Manual delegation forbids proactive subagents, not concurrent foreground tools or background commands. Inspect every launch receipt for failures or skipped work.",
30
- "Established command-only jobs and external waits belong to background operations, including in coordinator mode. Use bg_task_spawn for a long command, bg_task_watch for a repeated check, and watch_delivery for supported merge delivery. A subagent assignment must require reasoning or implementation beyond launching and waiting. Workers retain their assigned validation: launch or watch, continue independent work, then park with wait_for_operations and inspect the terminal evidence on continuation. Continue independent work while it runs; a task launch is not completion of the assignment.",
30
+ "Established command-only jobs and external waits belong to background operations, including in coordinator mode. Use bg_task_spawn for a long command, bg_task_watch for a repeated check, and watch_delivery for supported merge delivery. A subagent assignment must require reasoning or implementation beyond launching and waiting. Workers retain their assigned validation: continue independent work, then park with wait_for_operations when the operation supports durable waits. For live-session work, keep the owning session open and inspect status, logs, or the completion callback. A task launch is not completion of the assignment.",
31
31
  "If a worker hands back a command, launch it through bg_task_spawn or bg_task_watch with the supplied cwd, and inspect its terminal result before claiming verification.",
32
32
  "A unit waiting or failing does not block other ready independent units unless the evidence shows a shared blocker. Preserve each unit's guards and rollback boundary. Before completing verification, the plan, or the goal, inspect and integrate every relevant terminal result or failure; launch is not completion.",
33
33
  ].join("\n");
@@ -1,25 +1,32 @@
1
1
  import { withHarnessCommands } from "../settings/commands.ts";
2
2
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
3
+ import { registerNavigatorToolStyle } from "pi-better-background-tasks/src/shared-navigator.ts";
3
4
  import { installMinimalOutputHook, loadToolPrototype, loadCompactionPrototype, loadCustomMessagePrototype, type MinimalOutputHook } from "./hook.ts";
4
5
  import type { SettingsControl } from "../settings/registry.ts";
5
6
  import { readHarnessSetting, updateHarnessSetting } from "../shared-harness-settings.ts";
6
7
 
7
- const ENTRY = "pi-better-harness-tool-output";
8
+ const ENTRY = "pi-better-harness-tool-style";
9
+ const LEGACY_ENTRY = "pi-better-harness-tool-output";
10
+
11
+ function readEnabled(key: string): boolean | undefined {
12
+ const value = readHarnessSetting<{ version?: unknown; enabled?: unknown }>(key);
13
+ if (value !== undefined && (value?.version !== 1 || typeof value.enabled !== "boolean")) {
14
+ throw new Error(`Invalid ${key} default in global settings.json.`);
15
+ }
16
+ return value?.enabled as boolean | undefined;
17
+ }
8
18
 
9
19
  function minimalOutputExtension(pi: ExtensionAPI): void {
10
20
  let hook: MinimalOutputHook | undefined;
11
21
  let enabled = false;
12
22
  let running = false;
13
23
  let initialDefault: boolean | undefined;
14
- let motionEnabled = true;
24
+ let legacyMotion: boolean | undefined;
25
+ let navigator: ReturnType<typeof registerNavigatorToolStyle> | undefined;
15
26
 
16
27
  function defaultEnabled(): boolean {
17
28
  if (initialDefault !== undefined) return initialDefault;
18
- const value = readHarnessSetting<{ version?: unknown; enabled?: unknown }>("toolOutput");
19
- if (value !== undefined && (value?.version !== 1 || typeof value.enabled !== "boolean")) {
20
- throw new Error("Invalid tool-output default in global settings.json.");
21
- }
22
- return initialDefault = value?.enabled !== false;
29
+ return initialDefault = readEnabled("toolStyle") ?? (readEnabled("toolOutput") !== false && legacyMotion !== false);
23
30
  }
24
31
 
25
32
  function collapseTools(ctx: ExtensionContext): void {
@@ -50,39 +57,29 @@ function minimalOutputExtension(pi: ExtensionAPI): void {
50
57
  enabled = false;
51
58
  ctx.ui.notify(error instanceof Error ? error.message : String(error), "warning");
52
59
  }
53
- try {
54
- const motion = readHarnessSetting<{ version?: unknown; enabled?: unknown }>("toolAnimation");
55
- if (motion !== undefined && (motion?.version !== 1 || typeof motion.enabled !== "boolean")) {
56
- throw new Error("Invalid tool-animation default in global settings.json.");
57
- }
58
- motionEnabled = motion?.enabled !== false;
59
- } catch (error) {
60
- motionEnabled = false;
61
- ctx.ui.notify(error instanceof Error ? error.message : String(error), "warning");
62
- }
63
60
  for (const entry of ctx.sessionManager.getBranch()) {
64
- if (entry.type === "custom" && entry.customType === ENTRY) {
65
- const data = entry.data as { version?: unknown; enabled?: unknown } | undefined;
66
- if (data?.version === 1 && typeof data.enabled === "boolean") enabled = data.enabled;
67
- }
61
+ if (entry.type !== "custom" || (entry.customType !== ENTRY && entry.customType !== LEGACY_ENTRY)) continue;
62
+ const data = entry.data as { version?: unknown; enabled?: unknown } | undefined;
63
+ if (data?.version !== 1 || typeof data.enabled !== "boolean") continue;
64
+ enabled = data.enabled && (entry.customType === ENTRY || legacyMotion !== false);
68
65
  }
69
66
  // Observe transcript components from startup, so the toggle also redraws existing rows.
70
67
  if (await ensureHook(ctx)) {
71
- hook!.setAnimationEnabled(motionEnabled);
72
68
  hook!.restoreCompletedCalls(ctx.sessionManager.getBranch().flatMap(entry =>
73
69
  entry.type === "message" && entry.message.role === "toolResult" ? [entry.message.toolCallId] : []));
74
70
  if (enabled) collapseTools(ctx);
75
71
  hook!.setEnabled(enabled);
76
72
  } else enabled = false;
73
+ navigator?.refresh();
77
74
  }
78
75
 
79
76
  async function change(value: string, ctx: ExtensionContext): Promise<void> {
80
- if (value !== "Normal" && value !== "Minimal") throw new Error("Invalid tool output mode.");
81
- if (!await ensureHook(ctx)) throw new Error("Tool output settings are unavailable in this Pi runtime.");
82
- const data = { version: 1, enabled: value === "Minimal" };
77
+ if (value !== "Full" && value !== "Compact") throw new Error("Invalid tool style.");
78
+ if (!hook && !await ensureHook(ctx)) throw new Error("Tool style is unavailable in this Pi runtime.");
79
+ const data = { version: 1, enabled: value === "Compact" };
83
80
  try { pi.appendEntry(ENTRY, data); }
84
81
  catch (error) { data.version = 0; data.enabled = enabled; throw error; }
85
- try { updateHarnessSetting("toolOutput", () => ({ version: 1, enabled: data.enabled })); }
82
+ try { updateHarnessSetting("toolStyle", () => ({ version: 1, enabled: data.enabled })); }
86
83
  catch (error) {
87
84
  data.version = 0;
88
85
  data.enabled = enabled;
@@ -94,32 +91,41 @@ function minimalOutputExtension(pi: ExtensionAPI): void {
94
91
  if (enabled) collapseTools(ctx);
95
92
  hook!.setEnabled(enabled);
96
93
  if (enabled && !running) hook!.completeRun();
94
+ navigator?.refresh();
95
+ }
96
+
97
+ async function selectStyle(ctx: ExtensionContext, next = !enabled): Promise<void> {
98
+ try { await change(next ? "Compact" : "Full", ctx); }
99
+ catch (error) { ctx.ui.notify(error instanceof Error ? error.message : String(error), "warning"); }
97
100
  }
98
101
 
99
102
  const setting: SettingsControl = {
100
- id: "tool-output", label: "Tool output", values: ["Normal", "Minimal"],
101
- get: () => enabled ? "Minimal" : "Normal", change,
102
- };
103
- const animationSetting: SettingsControl = {
104
- id: "tool-animation", label: "Tool animation", values: ["Shimmer", "Off"],
105
- get: () => motionEnabled ? "Shimmer" : "Off",
106
- async change(value, ctx) {
107
- if (value !== "Shimmer" && value !== "Off") throw new Error("Invalid tool animation mode.");
108
- if (!await ensureHook(ctx)) throw new Error("Tool animation settings are unavailable in this Pi runtime.");
109
- updateHarnessSetting("toolAnimation", () => ({ version: 1, enabled: value === "Shimmer" }));
110
- motionEnabled = value === "Shimmer";
111
- hook!.setAnimationEnabled(motionEnabled);
112
- },
113
- };
114
- const register = () => {
115
- pi.events.emit("harness-settings:register", setting);
116
- pi.events.emit("harness-settings:register", animationSetting);
103
+ id: "tool-output", label: "Tool output", values: ["Full", "Compact"],
104
+ get: () => enabled ? "Compact" : "Full", change,
117
105
  };
106
+ const register = () => { pi.events.emit("harness-settings:register", setting); };
118
107
  let stopSettings: (() => void) | undefined;
119
108
  const subscribe = () => { stopSettings ??= pi.events.on("harness-settings:request", register); };
120
109
  subscribe();
121
110
  register();
122
- pi.on("session_start", async (_event, ctx) => { initialDefault = undefined; subscribe(); await restore(ctx); register(); });
111
+ pi.on("session_start", async (_event, ctx) => {
112
+ initialDefault = undefined;
113
+ if (ctx.mode === "tui") {
114
+ try { legacyMotion = readEnabled("toolAnimation"); }
115
+ catch (error) {
116
+ legacyMotion = false;
117
+ ctx.ui.notify(error instanceof Error ? error.message : String(error), "warning");
118
+ }
119
+ await restore(ctx);
120
+ navigator?.dispose();
121
+ if (hook) navigator = registerNavigatorToolStyle(ctx, {
122
+ enabled: () => enabled,
123
+ select: compact => { void selectStyle(ctx, compact); },
124
+ });
125
+ }
126
+ subscribe();
127
+ register();
128
+ });
123
129
  pi.on("session_tree", async (_event, ctx) => { await restore(ctx); });
124
130
  pi.on("agent_start", () => { running = true; });
125
131
  pi.on("agent_settled", (_event, ctx) => {
@@ -129,6 +135,8 @@ function minimalOutputExtension(pi: ExtensionAPI): void {
129
135
  });
130
136
 
131
137
  pi.on("session_shutdown", () => {
138
+ navigator?.dispose();
139
+ navigator = undefined;
132
140
  stopSettings?.();
133
141
  stopSettings = undefined;
134
142
  hook?.dispose();
@@ -136,11 +144,16 @@ function minimalOutputExtension(pi: ExtensionAPI): void {
136
144
  enabled = false;
137
145
  running = false;
138
146
  initialDefault = undefined;
139
- motionEnabled = true;
147
+ legacyMotion = undefined;
148
+ });
149
+
150
+ pi.registerShortcut?.("alt+t", {
151
+ description: "Switch between Compact and Full tool output",
152
+ handler: ctx => selectStyle(ctx),
140
153
  });
141
154
 
142
155
  pi.registerCommand("tool-output", {
143
- description: "[minimal|normal] — Fold tool output into single-line call headers, or restore normal output. No argument toggles. Display only.",
156
+ description: "[minimal|normal] - Switch between compact Harness tools with progress animation and the standard Pi tool display.",
144
157
  getArgumentCompletions: (argumentPrefix) => {
145
158
  const prefix = argumentPrefix.trimStart().toLowerCase();
146
159
  const matches = [
@@ -155,7 +168,7 @@ function minimalOutputExtension(pi: ExtensionAPI): void {
155
168
  ctx.ui.notify("Usage: /harness-settings tool-output [minimal|normal]", "warning");
156
169
  return;
157
170
  }
158
- try { await change((mode ? mode === "minimal" : !enabled) ? "Minimal" : "Normal", ctx); }
171
+ try { await change((mode ? mode === "minimal" : !enabled) ? "Compact" : "Full", ctx); }
159
172
  catch (error) { ctx.ui.notify(error instanceof Error ? error.message : String(error), "warning"); return; }
160
173
  ctx.ui.notify(enabled
161
174
  ? "Minimal tool output on. Compact call headers remain visible. Ctrl+O reveals results."
@@ -0,0 +1,67 @@
1
+ import { copyToClipboard, getAgentDir, getPackageDir, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import { Loader, Text } from "@earendil-works/pi-tui";
3
+ import { join } from "node:path";
4
+ import { runDoctor } from "../../lib/runtime-doctor.mjs";
5
+ import { RUNTIME_MODE_STATUS_REQUEST, type RuntimeModeStatus, type RuntimeModeStatusRequest } from "../shared-runtime-mode.ts";
6
+
7
+ export default function (pi: ExtensionAPI) {
8
+ pi.registerCommand("harness-doctor", {
9
+ description: "Diagnose Managed, Direct and Auto execution [--probe]",
10
+ handler: async (args, ctx) => {
11
+ if (!ctx.hasUI) return;
12
+ const flag = args.trim();
13
+ if (flag && flag !== "--probe") { ctx.ui.notify("Usage: /harness-doctor [--probe]", "warning"); return; }
14
+ const collect = async (signal?: AbortSignal) => {
15
+ try {
16
+ const runtimeModes: RuntimeModeStatus[] = [];
17
+ pi.events.emit(RUNTIME_MODE_STATUS_REQUEST, { reply: status => { runtimeModes.push(status); } } satisfies RuntimeModeStatusRequest);
18
+ const { text } = await runDoctor({ agentDir: getAgentDir(), piManifest: join(getPackageDir(), "package.json"),
19
+ probe: flag === "--probe", signal, runtimeModes });
20
+ return text as string;
21
+ } catch { return "Runtime Doctor could not load. Reinstall matching Harness and Server packages."; }
22
+ };
23
+ if (ctx.mode !== "tui") { ctx.ui.notify(await collect(ctx.signal), "info"); return; }
24
+ const text = await ctx.ui.custom<string | undefined>((tui, theme, keys, done) => {
25
+ const controller = new AbortController();
26
+ const loader = new Loader(tui, value => theme.fg("accent", value), value => theme.fg("muted", value), "Collecting Runtime Doctor report (Esc to cancel)");
27
+ void collect(controller.signal).then(report => done(controller.signal.aborted ? undefined : report));
28
+ return {
29
+ render: width => loader.render(width),
30
+ invalidate: () => loader.invalidate(),
31
+ handleInput: data => {
32
+ if (keys.matches(data, "tui.select.cancel")) controller.abort();
33
+ },
34
+ dispose: () => { controller.abort(); loader.stop(); },
35
+ };
36
+ });
37
+ if (!text) return;
38
+ await ctx.ui.custom<void>((tui, theme, keys, done) => {
39
+ const report = new Text(text, 1, 0);
40
+ const footer = new Text("Up/Down: scroll C: copy redacted report Esc: close", 1, 0);
41
+ let offset = 0;
42
+ return {
43
+ render(width) {
44
+ const lines = report.render(width);
45
+ const pageSize = Math.max(1, tui.terminal.rows - 5);
46
+ offset = Math.max(0, Math.min(offset, lines.length - pageSize));
47
+ return [...lines.slice(offset, offset + pageSize), ...footer.render(width)];
48
+ },
49
+ invalidate() { report.invalidate(); footer.invalidate(); },
50
+ handleInput(data) {
51
+ if (keys.matches(data, "tui.select.cancel")) return done();
52
+ if (keys.matches(data, "tui.select.up")) offset--;
53
+ if (keys.matches(data, "tui.select.down")) offset++;
54
+ if (data === "c") void copyToClipboard(text).then(() => {
55
+ footer.setText(theme.fg("success", "Redacted report copied. Esc: close"));
56
+ tui.requestRender();
57
+ }, () => {
58
+ footer.setText(theme.fg("warning", "Clipboard unavailable. Run pi-better-doctor --json to export."));
59
+ tui.requestRender();
60
+ });
61
+ tui.requestRender();
62
+ },
63
+ };
64
+ });
65
+ },
66
+ });
67
+ }
@@ -44,7 +44,7 @@ const features: Feature[] = [
44
44
  ["Enable diagnostics", "diagnostics on"], ["Disable diagnostics", "diagnostics off"], ["Export diagnostics", "diagnostics export"],
45
45
  ] } },
46
46
  { name: "better-activity", tab: "Background", label: "Inspect current activity" },
47
- { name: "tool-output", tab: "Display", label: "Tool output", link: "tool-output", operations: { "Transcript": [["Compact", "minimal"], ["Normal", "normal"]] } },
47
+ { name: "tool-output", tab: "Display", label: "Tool output", link: "tool-output", operations: { "Transcript": [["Compact", "minimal"], ["Full", "normal"]] } },
48
48
  { name: "supervisor-followup", tab: "Supervision", label: "Recovery commitments", operations: { "Commitments": [
49
49
  ["View commitments", ""], ["Schedule a reminder", "remind", "Commitment ID and minutes"],
50
50
  ] } },
@@ -39,13 +39,7 @@ export const controlCopy = new Map<string, SettingCopy>([
39
39
  description: "Keeps the work panels above the editor as the conversation scrolls. Off lets them scroll with the conversation on supported Pi versions.",
40
40
  }],
41
41
  ["tool-output", {
42
- description: "Normal shows the usual tool transcript. Compact groups completed calls and hides their details until you expand the group.",
43
- values: { Minimal: "Compact" },
44
- }],
45
- ["tool-animation", {
46
- label: "Tool progress animation",
47
- description: "Shows an animated shimmer on active tool calls. Turn it off to remove that animation.",
48
- values: { Shimmer: "On" },
42
+ description: "Compact groups completed calls and animates running calls in fullscreen Pi. Full uses the standard Pi tool transcript.",
49
43
  }],
50
44
  ]);
51
45
 
@@ -4,6 +4,7 @@ import registerNativeCompaction, { nativeCompactionSetting } from "../native-com
4
4
  import { availableActions, harnessMenu } from "./commands.ts";
5
5
  import { chooseHarnessSetting } from "./page.ts";
6
6
  import { createSettingsRegistry } from "./registry.ts";
7
+ import { runtimeModeControls } from "./runtime-modes.ts";
7
8
  import { changeCallbackSetting, getCallbackSettings, saveCallbackDefault } from "pi-better-background-tasks/src/shared-callback-batcher.ts";
8
9
 
9
10
  export default function harnessSettingsExtension(pi: ExtensionAPI): void {
@@ -42,7 +43,7 @@ export default function harnessSettingsExtension(pi: ExtensionAPI): void {
42
43
  get: readSettings,
43
44
  change: mode => changeCallbackSetting(pi, ctx, mode),
44
45
  save: () => saveCallbackDefault(readSettings().mode),
45
- }, [...controls, nativeCompactionSetting, supervisorMode], [
46
+ }, [...controls, nativeCompactionSetting, supervisorMode, ...runtimeModeControls()], [
46
47
  ...available,
47
48
  { id: "supervisor:scenarios", label: "Supervisor scenarios", kind: "page",
48
49
  description: "Choose which scenarios run when Supervisor mode is on." },
@@ -31,7 +31,7 @@ const groups: [string, string, string[]][] = [
31
31
  ["Background", "Waits and activity", ["setting:tool-call-guard", "setting:background-review-interval", "action:Inspect current activity"]],
32
32
  ["Background", "Results", [CALLBACK_SETTING_ID]],
33
33
  ["Display", "Work panels", ["setting:navigator-sticky", "setting:outcome-todo-display"]],
34
- ["Display", "Transcript", ["setting:tool-output", "setting:tool-animation", "action:Tool output"]],
34
+ ["Display", "Transcript", ["setting:tool-output", "action:Tool output"]],
35
35
  ["Supervision", "Scenarios", ["setting:supervisor-mode", "supervisor:scenarios"]],
36
36
  ["Supervision", "Recovery", ["action:Recovery commitments"]],
37
37
  ["OpenAI Optimization", "Context", ["setting:native-compaction"]],
@@ -40,6 +40,7 @@ const groups: [string, string, string[]][] = [
40
40
  ["Prompts", "Experiments", ["action:Capture next response", "action:Capture task", "action:Load evaluation cases", "action:Export reviewed replay", "action:Case-based proposals"]],
41
41
  ["Remote", "Sessions", ["action:Remote sessions", "action:Move session to host"]],
42
42
  ["Audio", "Playback", ["action:Read aloud", "action:Stop playback"]],
43
+ ["Runtime", "Execution modes", ["setting:runtime-mode", "setting:subagents-runtime-mode", "setting:background-runtime-mode"]],
43
44
  ];
44
45
 
45
46
  function groupSettings(items: MenuItem[]): MenuSection[] {
@@ -67,17 +68,20 @@ function presentControl(control: SettingsControl) {
67
68
  const copy = controlCopy.get(control.id);
68
69
  const labels = copy?.values;
69
70
  const display = (raw: string) => labels && Object.hasOwn(labels, raw) ? labels[raw]! : raw;
70
- const description = (typeof control.description === "string" && control.description.trim()) || copy?.description;
71
71
  const values = control.values.map(display);
72
+ const describe = () => {
73
+ const description = control.description?.trim() || copy?.description;
74
+ return [description ?? `Available values are ${values.join(", ")}.`, copy && "Saved as a user default."].filter(Boolean).join("\n");
75
+ };
72
76
  const raw = control.get();
73
77
  const item: MenuItem = {
74
78
  id: `setting:${control.id}`,
75
79
  label: copy?.label ?? control.label,
76
80
  kind: values.length === 2 && values.includes("On") && values.includes("Off") ? "toggle" : "choice",
77
81
  value: display(raw),
78
- description: [description ?? `Available values are ${values.join(", ")}.`, copy && "Saved as a user default."].filter(Boolean).join("\n"),
82
+ description: describe(),
79
83
  };
80
- return { control, item, raw, display };
84
+ return { control, item, raw, display, describe };
81
85
  }
82
86
 
83
87
  function presentLink(link: SettingsLink): MenuItem {
@@ -149,6 +153,7 @@ export async function chooseHarnessSetting(ctx: ExtensionCommandContext, links:
149
153
  }).then(() => {
150
154
  entry.raw = control.get();
151
155
  item.value = display(entry.raw);
156
+ for (const entry of entries) entry.item.description = entry.describe();
152
157
  report("Setting saved.");
153
158
  }).catch(error => report(error instanceof Error ? error.message : String(error), true))
154
159
  .finally(() => { changing = false; });
@@ -0,0 +1,25 @@
1
+ import { readRuntimeModes, writeRuntimeMode } from "../shared-runtime-mode-settings.ts";
2
+ import { EXECUTION_MODES, EXECUTION_OVERRIDES } from "../shared-runtime-mode.ts";
3
+ import type { SettingsControl } from "./registry.ts";
4
+
5
+ const label = (mode: string) => mode[0]!.toUpperCase() + mode.slice(1);
6
+
7
+ export function runtimeModeControls(): SettingsControl[] {
8
+ let modes = readRuntimeModes();
9
+ const source = { component: "component override", global: "global setting", default: "built-in default" };
10
+ return (["runtime", "subagents", "backgroundTasks"] as const).map(target => ({
11
+ id: { runtime: "runtime-mode", subagents: "subagents-runtime-mode", backgroundTasks: "background-runtime-mode" }[target],
12
+ label: { runtime: "Default execution mode", subagents: "Subagents override", backgroundTasks: "Background Tasks override" }[target],
13
+ values: (target === "runtime" ? EXECUTION_MODES : EXECUTION_OVERRIDES).map(label),
14
+ get description() {
15
+ if (target === "runtime") return "Default for new Subagents and Background Tasks work. Component overrides take precedence.";
16
+ const mode = modes[target];
17
+ return `Effective mode: ${label(mode.effectiveMode)} (${source[mode.source]}). Applies to new tasks.`;
18
+ },
19
+ get: () => label(target === "runtime" ? modes.global : modes[target].requestedMode),
20
+ change(value: string) {
21
+ writeRuntimeMode(target, value.toLowerCase());
22
+ modes = readRuntimeModes();
23
+ },
24
+ }));
25
+ }
@@ -11,6 +11,7 @@ const options = new Map([
11
11
  ["shared-fault", "Shared daemon fault diagnosis"],
12
12
  ["shared-decisions", "Consolidate authorization requests"],
13
13
  ["commitment-followup", "Follow up on recovery commitments"],
14
+ ["delivery-drift", "Review repeated merge-queue failures"],
14
15
  ]);
15
16
 
16
17
  function decode(raw: unknown): { enabled: boolean; scenarios: string[]; revision?: string } {
@@ -81,6 +81,11 @@ function mutate<T>(seams: HarnessSettingsSeams, change: (values: Record<string,
81
81
  }
82
82
  }
83
83
 
84
+ export function readHarnessSettings(seams: HarnessSettingsSeams = {}): Readonly<Record<string, unknown>> {
85
+ // Writers publish the entire document by rename. A snapshot needs no write lock.
86
+ return section(readSettings(harnessSettingsPath(seams)));
87
+ }
88
+
84
89
  export function readHarnessSetting<T = unknown>(
85
90
  key: string,
86
91
  seams: HarnessSettingsSeams = {},
@@ -0,0 +1,25 @@
1
+ // Generated from packages/harness-settings/runtime-mode-settings.ts. Do not edit directly.
2
+ import { readFileSync } from "node:fs";
3
+ import { dirname } from "node:path";
4
+ import { harnessSettingsPath, readHarnessSetting, updateHarnessSetting, type HarnessSettingsSeams } from "./shared-harness-settings.ts";
5
+ import { isExecutionMode, isExecutionOverride, legacySubagentsModePath, readRuntimeModeSnapshot, type RuntimeComponent } from "./shared-runtime-mode.ts";
6
+
7
+ function settingsObject(value: unknown): Record<string, unknown> {
8
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Runtime mode settings must be a JSON object.");
9
+ return value as Record<string, unknown>;
10
+ }
11
+
12
+ export function readRuntimeModes(seams: HarnessSettingsSeams = {}) {
13
+ const { global, subagents, backgroundTasks } = readRuntimeModeSnapshot(dirname(harnessSettingsPath(seams)), path => JSON.parse(readFileSync(path, "utf8")));
14
+ return { global, subagents, backgroundTasks };
15
+ }
16
+
17
+ /** For operator-facing commands and settings controls only. */
18
+ export function writeRuntimeMode(target: RuntimeComponent | "runtime", mode: unknown, seams: HarnessSettingsSeams = {}): void {
19
+ if (!(target === "runtime" ? isExecutionMode(mode) : isExecutionOverride(mode))) throw new Error("Invalid runtime execution mode.");
20
+ if (target === "subagents") {
21
+ // Preserve every legacy Subagents setting when persisting the override.
22
+ readHarnessSetting("subagents", seams, { path: legacySubagentsModePath(dirname(harnessSettingsPath(seams))), parse: settingsObject });
23
+ }
24
+ updateHarnessSetting(target, previous => ({ ...(previous === undefined ? {} : settingsObject(previous)), executionMode: mode }), seams);
25
+ }