pi-subagents 0.83.1 → 0.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-5YIITCPD.js → chunk-3UZ5FVVJ.js} +322 -110
  5. package/bundle/{chunk-F4ASL6OV.js → chunk-7MAE3DJV.js} +1 -1
  6. package/bundle/{chunk-YXFJVCOL.js → chunk-CS4O36CZ.js} +11 -156
  7. package/bundle/{chunk-AHIFYGR3.js → chunk-DV2NCNPR.js} +22 -11
  8. package/bundle/{chunk-G2Z6ZH26.js → chunk-GCSLVFCX.js} +1 -1
  9. package/bundle/{chunk-2S4K53MV.js → chunk-H2NLFTC5.js} +1 -1
  10. package/bundle/{chunk-MABL3FUM.js → chunk-HFTBF7SG.js} +2 -1
  11. package/bundle/chunk-HXRB42AF.js +108 -0
  12. package/bundle/{chunk-UFL7IYCW.js → chunk-IQIWF2VX.js} +190 -1177
  13. package/bundle/{chunk-NPIYWVOD.js → chunk-JNXT3MPI.js} +15 -6
  14. package/bundle/{chunk-C7JMPU5F.js → chunk-JO67XSKD.js} +59 -27
  15. package/bundle/{chunk-UUP372DR.js → chunk-JWYG26RE.js} +223 -93
  16. package/bundle/{chunk-C5P5CHYK.js → chunk-KDMFBYFM.js} +1 -1
  17. package/bundle/{chunk-V2BZYLEP.js → chunk-KEY3UQMQ.js} +7 -2
  18. package/bundle/{chunk-VLFZIN6D.js → chunk-KZ34KQQH.js} +9 -6
  19. package/bundle/{chunk-ZVOAMTUQ.js → chunk-L2ENOFVZ.js} +76 -58
  20. package/bundle/{chunk-RNIZLSEA.js → chunk-LGMILZNE.js} +323 -18
  21. package/bundle/{chunk-UYK5MZWE.js → chunk-LTPH2DXH.js} +247 -153
  22. package/bundle/{chunk-2D52JFLF.js → chunk-N7B2KD74.js} +41 -117
  23. package/bundle/{chunk-IPGZMQXV.js → chunk-O7CPL6H4.js} +183 -28
  24. package/bundle/{chunk-D3JAFGMO.js → chunk-PHZP3KHB.js} +1 -1
  25. package/bundle/{chunk-2DHZTCOL.js → chunk-PVIVCDG2.js} +2 -2
  26. package/bundle/{chunk-LFDBD4PW.js → chunk-QO75KJBT.js} +2 -2
  27. package/bundle/{chunk-SSG7IEP5.js → chunk-RQAUNAWG.js} +2 -2
  28. package/bundle/{chunk-QP5ZWNIS.js → chunk-RV5OGHLO.js} +6 -3
  29. package/bundle/chunk-T5V5BRCL.js +1067 -0
  30. package/bundle/{chunk-LNRJCP2Y.js → chunk-UX4SCV5N.js} +337 -207
  31. package/bundle/{chunk-F5DBXJ2G.js → chunk-WOVMHDES.js} +234 -182
  32. package/bundle/control-channel.js +2 -2
  33. package/bundle/index.js +1 -1
  34. package/bundle/intercom-bridge.js +2 -2
  35. package/bundle/preflight.js +8 -8
  36. package/bundle/project-panes.js +3 -3
  37. package/docs/agents.md +17 -2
  38. package/docs/configuration.md +2 -2
  39. package/docs/extension-api.md +16 -1
  40. package/docs/workflows.md +30 -2
  41. package/package.json +1 -1
  42. package/src/agents/agent-management.js +27 -11
  43. package/src/agents/agent-memory.d.ts +1 -4
  44. package/src/agents/agent-memory.js +1 -4
  45. package/src/agents/agents.d.ts +1 -3
  46. package/src/agents/agents.js +7 -6
  47. package/src/agents/frontmatter.js +1 -8
  48. package/src/agents/global-npm-root.d.ts +1 -0
  49. package/src/agents/global-npm-root.js +11 -3
  50. package/src/agents/skills.d.ts +0 -3
  51. package/src/agents/skills.js +0 -3
  52. package/src/extension/config.js +7 -1
  53. package/src/extension/herdr-pi-bridge.js +10 -2
  54. package/src/extension/index.d.ts +0 -13
  55. package/src/extension/index.js +43 -32
  56. package/src/extension/public-execution.d.ts +1 -0
  57. package/src/extension/public-execution.js +4 -0
  58. package/src/extension/reply-workflow-script.js +24 -4
  59. package/src/extension/schemas.d.ts +8 -3
  60. package/src/extension/schemas.js +5 -3
  61. package/src/extension/session-switch.d.ts +25 -0
  62. package/src/extension/session-switch.js +138 -0
  63. package/src/extension/subagent-guide.d.ts +1 -1
  64. package/src/extension/subagent-guide.js +1 -1
  65. package/src/extension/subagent-launch-tool.d.ts +25 -0
  66. package/src/extension/subagent-launch-tool.js +48 -0
  67. package/src/extension/tool-activation.js +25 -11
  68. package/src/extension/tool-description.js +6 -0
  69. package/src/inspectors/herdr/actions.d.ts +0 -1
  70. package/src/inspectors/herdr/actions.js +0 -1
  71. package/src/inspectors/session-roots-codec.d.ts +0 -1
  72. package/src/inspectors/session-roots-codec.js +0 -1
  73. package/src/inspectors/tmux/actions.d.ts +0 -1
  74. package/src/inspectors/tmux/actions.js +0 -1
  75. package/src/integrations/herdr-status.js +3 -8
  76. package/src/intercom/native-supervisor-channel.js +65 -9
  77. package/src/runs/background/async-execution.d.ts +8 -9
  78. package/src/runs/background/async-execution.js +77 -27
  79. package/src/runs/background/async-job-tracker.js +12 -0
  80. package/src/runs/background/async-resume.d.ts +2 -1
  81. package/src/runs/background/async-resume.js +112 -39
  82. package/src/runs/background/async-retention.d.ts +1 -0
  83. package/src/runs/background/async-retention.js +22 -11
  84. package/src/runs/background/auto-drain.js +2 -1
  85. package/src/runs/background/boot-id.d.ts +1 -3
  86. package/src/runs/background/boot-id.js +1 -3
  87. package/src/runs/background/completion-batcher.d.ts +3 -4
  88. package/src/runs/background/completion-batcher.js +2 -3
  89. package/src/runs/background/control-channel.d.ts +0 -6
  90. package/src/runs/background/control-channel.js +0 -6
  91. package/src/runs/background/fleet-view.js +2 -3
  92. package/src/runs/background/notify.d.ts +0 -2
  93. package/src/runs/background/notify.js +0 -2
  94. package/src/runs/background/result-watcher.d.ts +1 -0
  95. package/src/runs/background/result-watcher.js +59 -29
  96. package/src/runs/background/resume-guidance.js +4 -2
  97. package/src/runs/background/retained-children.js +2 -1
  98. package/src/runs/background/run-child-session.d.ts +2 -1
  99. package/src/runs/background/run-child-session.js +10 -2
  100. package/src/runs/background/run-status.js +4 -3
  101. package/src/runs/background/scheduled-runs.d.ts +3 -1
  102. package/src/runs/background/scheduled-runs.js +13 -16
  103. package/src/runs/background/subagent-runner.d.ts +2 -4
  104. package/src/runs/background/subagent-runner.js +10 -6
  105. package/src/runs/background/subagent-wait.js +12 -15
  106. package/src/runs/background/wait-config.d.ts +2 -0
  107. package/src/runs/background/wait-config.js +17 -3
  108. package/src/runs/background/wait-tool.js +4 -2
  109. package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
  110. package/src/runs/background/workflow-terminal-proof.js +0 -1
  111. package/src/runs/foreground/execution.d.ts +0 -3
  112. package/src/runs/foreground/execution.js +17 -9
  113. package/src/runs/foreground/subagent-executor.d.ts +3 -2
  114. package/src/runs/foreground/subagent-executor.js +112 -26
  115. package/src/runs/shared/child-commands.js +15 -2
  116. package/src/runs/shared/child-hooks.d.ts +1 -7
  117. package/src/runs/shared/child-hooks.js +13 -5
  118. package/src/runs/shared/child-launch.js +6 -2
  119. package/src/runs/shared/child-runtime-config.d.ts +0 -1
  120. package/src/runs/shared/child-session.d.ts +3 -1
  121. package/src/runs/shared/child-session.js +22 -2
  122. package/src/runs/shared/child-tool-plan.d.ts +0 -1
  123. package/src/runs/shared/child-tool-plan.js +0 -1
  124. package/src/runs/shared/claude-code-adapter.js +11 -0
  125. package/src/runs/shared/external-cli-runner.js +26 -6
  126. package/src/runs/shared/herdr-connection.js +2 -1
  127. package/src/runs/shared/herdr-pane-host.d.ts +2 -2
  128. package/src/runs/shared/herdr-pane-host.js +17 -1
  129. package/src/runs/shared/herdr-placed-run.js +48 -22
  130. package/src/runs/shared/lane-metadata.d.ts +0 -1
  131. package/src/runs/shared/lane-metadata.js +0 -1
  132. package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
  133. package/src/runs/shared/model-resolution-diagnostic.d.ts +11 -1
  134. package/src/runs/shared/model-resolution-diagnostic.js +25 -0
  135. package/src/runs/shared/model-resolution.d.ts +2 -2
  136. package/src/runs/shared/model-resolution.js +7 -1
  137. package/src/runs/shared/model-scope.d.ts +1 -5
  138. package/src/runs/shared/model-scope.js +1 -5
  139. package/src/runs/shared/mutation-evidence.d.ts +1 -1
  140. package/src/runs/shared/mutation-evidence.js +52 -7
  141. package/src/runs/shared/nested-events.d.ts +1 -0
  142. package/src/runs/shared/nested-events.js +1 -1
  143. package/src/runs/shared/parallel-utils.d.ts +2 -1
  144. package/src/runs/shared/permissions.js +5 -3
  145. package/src/runs/shared/placement-host.d.ts +5 -1
  146. package/src/runs/shared/rex-pane-host.d.ts +0 -1
  147. package/src/runs/shared/rex-pane-host.js +0 -2
  148. package/src/runs/shared/run-launch-folder.d.ts +12 -0
  149. package/src/runs/shared/run-launch-folder.js +21 -0
  150. package/src/runs/shared/runner-launcher.d.ts +12 -1
  151. package/src/runs/shared/runner-launcher.js +16 -0
  152. package/src/runs/shared/single-output.d.ts +3 -3
  153. package/src/runs/shared/single-output.js +5 -3
  154. package/src/runs/shared/structured-output.d.ts +8 -0
  155. package/src/runs/shared/structured-output.js +30 -2
  156. package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
  157. package/src/runs/shared/subagent-prompt-runtime.js +4 -2
  158. package/src/runs/shared/tool-timeout.js +2 -1
  159. package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
  160. package/src/runs/shared/worktree-cleanup-plan.js +0 -1
  161. package/src/runs/shared/worktree.d.ts +3 -0
  162. package/src/runs/shared/worktree.js +20 -0
  163. package/src/shared/capacity-resilient-json.d.ts +1 -1
  164. package/src/shared/child-cache-retention.d.ts +1 -2
  165. package/src/shared/child-cache-retention.js +1 -2
  166. package/src/shared/fleet-transcript-reader.d.ts +51 -0
  167. package/src/shared/fleet-transcript-reader.js +333 -0
  168. package/src/shared/formatters.d.ts +0 -18
  169. package/src/shared/formatters.js +0 -18
  170. package/src/shared/session-succession.d.ts +16 -1
  171. package/src/shared/session-succession.js +41 -2
  172. package/src/shared/session-warnings.d.ts +7 -0
  173. package/src/shared/session-warnings.js +26 -0
  174. package/src/shared/settings.d.ts +0 -23
  175. package/src/shared/settings.js +3 -35
  176. package/src/shared/types.d.ts +28 -11
  177. package/src/shared/types.js +0 -12
  178. package/src/shared/utils.d.ts +0 -14
  179. package/src/shared/utils.js +0 -22
  180. package/src/shared/wait-tool-name.d.ts +8 -0
  181. package/src/shared/wait-tool-name.js +13 -0
  182. package/src/slash/slash-commands.js +2 -1
  183. package/src/slash/subagent-cost.d.ts +3 -2
  184. package/src/slash/subagent-cost.js +22 -3
  185. package/src/slash/subagents-admin.js +0 -1
  186. package/src/tui/fleet-status.d.ts +0 -5
  187. package/src/tui/fleet-status.js +4 -24
  188. package/src/tui/fleet-transcript.d.ts +1 -44
  189. package/src/tui/fleet-transcript.js +1 -327
  190. package/src/tui/fleet.js +6 -4
  191. package/src/tui/render.d.ts +0 -9
  192. package/src/tui/render.js +81 -47
  193. package/src/tui/subagent-messages.js +3 -2
  194. package/src/watchdog/register-child.d.ts +2 -3
  195. package/src/watchdog/register-child.js +2 -3
  196. package/src/watchdog/turn-delta.js +2 -1
  197. package/src/workflows/scripted-workflow.js +243 -20
  198. package/src/workflows/workflow-launch-record.d.ts +15 -6
  199. package/src/workflows/workflow-launch-record.js +30 -12
  200. package/src/workflows/workflow-resume-claim.js +2 -2
  201. package/src/workflows/workflow-resume.d.ts +1 -1
  202. package/src/workflows/workflow-resume.js +11 -8
  203. package/src/workflows/workflow-script-worker.d.ts +13 -0
  204. package/src/workflows/workflow-script-worker.js +79 -0
  205. package/workflow-script-process.cjs +36 -0
  206. package/workflow-script-worker.cjs +453 -176
@@ -1,6 +1,9 @@
1
+ import {
2
+ agentDefinitionDigest
3
+ } from "./chunk-7F6RKT6W.js";
1
4
  import {
2
5
  PROJECT_SUBAGENTS_RELATIVE_DIR
3
- } from "./chunk-D3JAFGMO.js";
6
+ } from "./chunk-PHZP3KHB.js";
4
7
  import {
5
8
  DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
6
9
  DEFAULT_GLOBAL_CONCURRENCY_LIMIT,
@@ -22,7 +25,7 @@ import {
22
25
  withFileLease,
23
26
  writeAtomicJson,
24
27
  writePrivateAtomicJson
25
- } from "./chunk-LNRJCP2Y.js";
28
+ } from "./chunk-UX4SCV5N.js";
26
29
  import {
27
30
  DIRS,
28
31
  SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
@@ -1769,6 +1772,33 @@ function hostStepReportName(reportPath) {
1769
1772
  return reportPath.split(/[\\/]/).filter(Boolean).at(-1);
1770
1773
  }
1771
1774
 
1775
+ // src/runs/shared/runner-launcher.ts
1776
+ var REQUIRE_LAUNCHER_SHAPE_ERROR = "requireLauncher is supported only on a top-level single-agent call (agent + task); it cannot be combined with tasks, chain, workflow, an action, resume, or a workflow child.";
1777
+ function lookupRunnerLauncher(runnerLaunchers, name) {
1778
+ const argv = runnerLaunchers && Object.hasOwn(runnerLaunchers, name) ? runnerLaunchers[name] : void 0;
1779
+ return argv ? { name, argv: [...argv] } : void 0;
1780
+ }
1781
+ function runnerLauncherPlacementError(agent, machine) {
1782
+ if (agent.launcher === void 0) return void 0;
1783
+ const runnerType = agent.runner?.type === "external-cli" || agent.runner?.type === "external-job" ? agent.runner.type : void 0;
1784
+ if (!machine && !runnerType) return void 0;
1785
+ return `Agent '${agent.name}' uses launcher '${agent.launcher}', which wraps the local Pi background runner, so it cannot run ${machine ? `on machine '${machine}'` : `with runner.type='${runnerType}'`}.`;
1786
+ }
1787
+ function resolveAgentRunnerLauncher(agent, runnerLaunchers, machine) {
1788
+ if (agent.launcher === void 0) return {};
1789
+ const placementError = runnerLauncherPlacementError(agent, machine);
1790
+ if (placementError) return { error: placementError };
1791
+ const launcher = lookupRunnerLauncher(runnerLaunchers, agent.launcher);
1792
+ return launcher ? { launcher } : { error: `Agent '${agent.name}' uses launcher '${agent.launcher}', which is not defined in runnerLaunchers in the user subagent config.` };
1793
+ }
1794
+ function checkRequiredRunnerLauncher(agent, launcherName, required) {
1795
+ if (launcherName === void 0) return { error: `Agent '${agent.name}' has no launcher, but the call requires launcher '${required.name}'.` };
1796
+ if (launcherName !== required.name) return { error: `Agent '${agent.name}' uses launcher '${launcherName}', but the call requires launcher '${required.name}'.` };
1797
+ const definitionDigest = agentDefinitionDigest(agent);
1798
+ if (definitionDigest !== required.definitionDigest) return { error: `Agent '${agent.name}' definition digest is ${definitionDigest}, but the call requires ${required.definitionDigest}; the agent definition changed after it was checked.` };
1799
+ return { definitionDigest };
1800
+ }
1801
+
1772
1802
  // src/workflows/host-command.ts
1773
1803
  import { spawn } from "node:child_process";
1774
1804
  import { randomUUID as randomUUID3 } from "node:crypto";
@@ -1966,10 +1996,84 @@ async function executeWorkflowHostCommand(input) {
1966
1996
  }
1967
1997
 
1968
1998
  // src/workflows/scripted-workflow.ts
1969
- import { accessSync, constants as constants2, readFileSync as readFileSync6, realpathSync as realpathSync3, statSync as statSync4 } from "node:fs";
1999
+ import { accessSync, constants as constants2, readFileSync as readFileSync6, realpathSync as realpathSync4, statSync as statSync4 } from "node:fs";
1970
2000
  import { createRequire } from "node:module";
1971
- import { dirname as dirname6, resolve as resolvePath } from "node:path";
2001
+ import { dirname as dirname7, resolve as resolvePath } from "node:path";
2002
+
2003
+ // src/workflows/workflow-script-worker.ts
2004
+ import { fork } from "node:child_process";
2005
+ import { EventEmitter } from "node:events";
2006
+ import { realpathSync as realpathSync3 } from "node:fs";
2007
+ import { dirname as dirname6 } from "node:path";
2008
+ import { fileURLToPath } from "node:url";
1972
2009
  import { Worker } from "node:worker_threads";
2010
+ var WORKFLOW_WORKER_URL = new URL("../../workflow-script-worker.cjs", new URL("../src/workflows/workflow-script-worker.js", import.meta.url).href);
2011
+ var WORKFLOW_PROCESS_URL = new URL("../../workflow-script-process.cjs", new URL("../src/workflows/workflow-script-worker.js", import.meta.url).href);
2012
+ var WorkflowScriptProcess = class extends EventEmitter {
2013
+ child;
2014
+ exitCode;
2015
+ stopping = false;
2016
+ stderr = "";
2017
+ constructor(acornPath) {
2018
+ super();
2019
+ const acorn = realpathSync3(acornPath);
2020
+ this.child = fork(WORKFLOW_PROCESS_URL, [acorn], {
2021
+ // Under --permission, Node lets worker threads read everything under the process cwd, so the cwd must
2022
+ // hold only public files: acorn's own directory. It also never holds a caller's cwd open on Windows.
2023
+ cwd: dirname6(acorn),
2024
+ // No inherited execArgv or NODE_OPTIONS. Only the supervisor may create a worker.
2025
+ execArgv: [
2026
+ "--permission",
2027
+ "--allow-worker",
2028
+ `--allow-fs-read=${realpathSync3(fileURLToPath(WORKFLOW_PROCESS_URL))}`,
2029
+ `--allow-fs-read=${realpathSync3(fileURLToPath(WORKFLOW_WORKER_URL))}`,
2030
+ `--allow-fs-read=${acorn}`
2031
+ ],
2032
+ env: process.platform === "win32" && process.env.SystemRoot ? { SystemRoot: process.env.SystemRoot } : {},
2033
+ stdio: ["ignore", "ignore", "pipe", "ipc"]
2034
+ });
2035
+ this.child.stderr.on("data", (chunk) => {
2036
+ this.stderr = (this.stderr + chunk.toString("utf8")).slice(-4096);
2037
+ });
2038
+ this.child.on("error", (error) => this.emit("error", error));
2039
+ this.child.on("message", (json) => {
2040
+ if (this.stopping) return;
2041
+ try {
2042
+ if (typeof json !== "string") throw new Error("Workflow process sent a non-string IPC message.");
2043
+ const message = JSON.parse(json);
2044
+ if (!message || typeof message !== "object" || Array.isArray(message)) throw new Error("Workflow process sent an invalid IPC message.");
2045
+ this.emit("message", message);
2046
+ } catch (error) {
2047
+ this.emit("error", error);
2048
+ }
2049
+ });
2050
+ this.child.on("exit", (code) => {
2051
+ this.exitCode = code ?? 1;
2052
+ this.child.stderr.destroy();
2053
+ if (!this.stopping && code !== 0 && this.stderr.trim()) this.emit("error", new Error(this.stderr.trim()));
2054
+ this.emit("exit", this.exitCode);
2055
+ });
2056
+ }
2057
+ postMessage(message) {
2058
+ if (this.stopping || !this.child.connected) return;
2059
+ this.child.send(JSON.stringify(message), (error) => {
2060
+ if (error && !this.stopping) this.emit("error", error);
2061
+ });
2062
+ }
2063
+ async terminate() {
2064
+ if (this.exitCode !== void 0) return this.exitCode;
2065
+ this.stopping = true;
2066
+ return await new Promise((resolve6) => {
2067
+ this.once("exit", resolve6);
2068
+ this.child.kill("SIGKILL");
2069
+ });
2070
+ }
2071
+ };
2072
+ function createWorkflowScriptWorker(acornPath) {
2073
+ return typeof process.versions.bun === "string" ? new Worker(WORKFLOW_WORKER_URL, { workerData: { acornPath } }) : new WorkflowScriptProcess(acornPath);
2074
+ }
2075
+
2076
+ // src/workflows/scripted-workflow.ts
1973
2077
  var KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
1974
2078
  var BASE_REF_VALIDATION_ERROR = "baseRef must be a valid Git ref: use HEAD or a supported named ref (for example, refs/heads/main). Full 40/64-character commit IDs and revision expressions are unsupported.";
1975
2079
  function validGitRef(ref) {
@@ -1980,8 +2084,6 @@ function validGitRef(ref) {
1980
2084
  }
1981
2085
  var requireFromPackage = createRequire(new URL("../src/workflows/scripted-workflow.js", import.meta.url).href);
1982
2086
  var WORKFLOW_ASSEMBLY_FLUSH_TIMEOUT_MS = 5e3;
1983
- var WORKFLOW_WORKER_URL = new URL("../../workflow-script-worker.cjs", new URL("../src/workflows/scripted-workflow.js", import.meta.url).href);
1984
- var nodeWorkerSource;
1985
2087
  function isWorkflowScriptFailureKind(value) {
1986
2088
  return value === "validation" || value === "script" || value === "child" || value === "return-serialization" || value === "timeout" || value === "detached-child" || value === "runtime";
1987
2089
  }
@@ -2053,15 +2155,157 @@ var RECOVERY_REVIEW_NO_ANAPHORIC_MUTATION_CLAUSE_PATTERN = /\b(?:do not|don't|mu
2053
2155
  var RECOVERY_REVIEW_NO_DELEGATION_CLAUSE_PATTERN = /\b(?:do not|don't|must not)\s+(?:(?:launch|start|spawn|run)\b(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n])*(?:workers?|reviewers?|agents?|subagents?|children|child|runs?)|(?:get|let|request|hand\s+off|assign|use|have|tell)\b(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n])*(?:workers?|reviewers?|agents?|subagents?|children|child)|(?:get|let|have|tell|request)\b(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n])*(?:review|implementation|fix(?:es)?|changes?|follow-up)\b(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n])*\b(?:from|with|via|by)\b(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n])*(?:workers?|reviewers?|agents?|subagents?|children|child)|ask\b(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n])*(?:(?:workers?|reviewers?|agents?|subagents?|children|child)\b(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n])*\b(?:continue|implement|review|fix|edit|write|modify|change|patch|update|delete|remove|create|follow-up)|(?:review|implementation|fix(?:es)?|changes?|follow-up)\b(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n])*\b(?:from|via)\b(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n])*(?:workers?|reviewers?|agents?|subagents?|children|child)))\b/gi;
2054
2156
  var RECOVERY_REVIEW_DELEGATION_PATTERN = /\b(?:launch|start|spawn|run)\b[^,.;!?\n]*(?:workers?|reviewers?|agents?|subagents?|children|child|runs?)\b|\b(?:delegate|hand\s+off|assign)\s+(?:remediation|implementation(?:\s+follow-up)?|changes?|fix(?:es)?|follow-up)\s+to\s+(?:(?:a|an|the)\s+)?(?:workers?|reviewers?|agents?|subagents?|children|child)\b|\b(?:get|let|have|tell|request)\b[^,.;!?\n]*(?:workers?|reviewers?|agents?|subagents?|children|child)\b[^,.;!?\n]*\b(?:continue|implement|review|fix|edit|write|modify|change|patch|update|delete|remove|create|follow-up)\b|\b(?:get|let|have|tell|request)\b[^,.;!?\n]*(?:review|implementation|fix(?:es)?|changes?|follow-up)\b[^,.;!?\n]*\b(?:from|with|via|by)\b[^,.;!?\n]*(?:workers?|reviewers?|agents?|subagents?|children|child)\b|\bask\b[^,.;!?\n]*(?:(?:workers?|reviewers?|agents?|subagents?|children|child)\b[^,.;!?\n]*\b(?:continue|implement|review|fix|edit|write|modify|change|patch|update|delete|remove|create|follow-up)|(?:review|implementation|fix(?:es)?|changes?|follow-up)\b[^,.;!?\n]*\b(?:from|via)\b[^,.;!?\n]*(?:workers?|reviewers?|agents?|subagents?|children|child))\b|\buse\b[^,.;!?\n]*(?:workers?|reviewers?|agents?|subagents?|children|child|runs?)\s+(?:for|to)\s+(?:implementation|follow-up|remediation|fix|edit|write|modify|change|patch|update|delete|remove|create)\b/i;
2055
2157
  var RECOVERY_REVIEW_ANAPHORIC_MUTATION_PATTERN = /\b(?:do|run|execute|perform|apply)\s+(?:it|that|this|(?:the\s+)?(?:(?:\d+(?:st|nd|rd|th)|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|last|next|previous(?:ly)?|prior|above|quoted|blocked)\s+){0,4}(?:command|example|operation|action|phrase|instruction|request|one))(?!(?:\s+(?:(?:now|still|also|already)\s+)*(?:is|are|remains?)\s+blocked\b))(?:(?:[\s,]+\w+){0,4}[\s,]+anyway|(?:(?!\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b)[^,.;!?\n]){0,80})(?=\s*(?:[,.;!?\n)]|\b(?:and|but|then|however|nevertheless|nonetheless|yet)\b|$))/i;
2056
- var RECOVERY_REVIEW_DESTRUCTIVE_COMMAND_PATTERN = /(?:^|[\s;,.`'"([{])(?:\S*\/)?(?:rm|rmdir|unlink|truncate|mv|cp|chmod|chown)\b|\bgit\b(?:\s+(?:-[A-Za-z](?:\s+(?:"[^"\n]*"|'[^'\n]*'|\S+))?|--(?:git-dir|work-tree|namespace|exec-path|config-env)(?:=(?:"[^"\n]*"|'[^'\n]*'|\S+)|\s+(?:"[^"\n]*"|'[^'\n]*'|\S+))|--[A-Za-z0-9-]+(?:=(?:"[^"\n]*"|'[^'\n]*'|\S+))?))*\s+(?:add|branch|cherry-pick|clean|commit|merge|rebase|reset|restore|revert|stash|tag|checkout|switch)\b/i;
2057
- var RECOVERY_REVIEW_DASH_LIVE_ACTION_PATTERN = /(?:[—–]|--|\s-\s|:|\s\/\s)\s*(?:then\s+)?(?:(?:add|append|apply|change|cherry[ -]pick|clean|commit|copy|create|delete|edit|fix|implement|insert|make|merge|move|modify|mutate|open|patch|prepend|push|rebase|refactor|remove|rename|replace|revert|revise|rewrite|save|stage|stash|tag|touch|update|write)\b|(?:launch|start|spawn|run)\b[^,.;!?\n]*(?:workers?|reviewers?|agents?|subagents?|children|child|runs?)\b|(?:\S*\/)?(?:rm|rmdir|unlink|truncate|mv|cp|chmod|chown)\b|git\b[^,.;!?\n]*\b(?:add|branch|cherry-pick|clean|commit|merge|rebase|reset|restore|revert|stash|tag|checkout|switch)\b)/i;
2158
+ var RECOVERY_REVIEW_MUTATING_PATH_COMMAND_PATTERN = /(?:^|[\s;,.`'"([{])(?:[^\s;,.`'"([{]*\/)?(?:rm|rmdir|unlink|truncate|mv|cp|chmod|chown)\b/i;
2159
+ var RECOVERY_REVIEW_WORD_CHARACTER_PATTERN = /^\w$/;
2160
+ var RECOVERY_REVIEW_DASH_SEPARATOR_AT_PATTERN = /(?:[—–]|--|\s-\s|:|\s\/\s)/iy;
2161
+ var RECOVERY_REVIEW_DASH_SEPARATOR_EXISTS_PATTERN = /(?:[—–]|--|\s-\s|:|\s\/\s)/i;
2162
+ var RECOVERY_REVIEW_DASH_ACTION_AT_PATTERN = /(?:add|append|apply|change|cherry[ -]pick|clean|commit|copy|create|delete|edit|fix|implement|insert|make|merge|move|modify|mutate|open|patch|prepend|push|rebase|refactor|remove|rename|replace|revert|revise|rewrite|save|stage|stash|tag|touch|update|write)\b/iy;
2163
+ var RECOVERY_REVIEW_DASH_LAUNCH_AT_PATTERN = /(?:launch|start|spawn|run)\b/iy;
2164
+ var RECOVERY_REVIEW_DASH_WORKER_AT_PATTERN = /(?:workers?|reviewers?|agents?|subagents?|children|child|runs?)\b/iy;
2165
+ var RECOVERY_REVIEW_DASH_GIT_AT_PATTERN = /git\b/iy;
2166
+ var RECOVERY_REVIEW_DASH_GIT_COMMAND_AT_PATTERN = /\b(?:add|branch|cherry-pick|clean|commit|merge|rebase|reset|restore|revert|stash|tag|checkout|switch)\b/iy;
2167
+ var RECOVERY_REVIEW_DASH_FILE_COMMAND_AT_PATTERN = /(?:rm|rmdir|unlink|truncate|mv|cp|chmod|chown)\b/iy;
2168
+ var RECOVERY_REVIEW_DASH_THEN_AT_PATTERN = /then/iy;
2169
+ var RECOVERY_REVIEW_DASH_LINE_STOP_CHARACTERS = ",.;!?\n";
2170
+ var RECOVERY_REVIEW_WHITESPACE_CHARACTER_PATTERN = /^\s$/;
2171
+ function matchesDashBranchAt(pattern, text, index) {
2172
+ pattern.lastIndex = index;
2173
+ return pattern.test(text);
2174
+ }
2175
+ function dashBranchLengthAt(pattern, text, index) {
2176
+ pattern.lastIndex = index;
2177
+ const match = pattern.exec(text);
2178
+ return match === null ? 0 : match[0].length;
2179
+ }
2180
+ function skipDashSeparatorWhitespace(text, index) {
2181
+ while (index < text.length && RECOVERY_REVIEW_WHITESPACE_CHARACTER_PATTERN.test(text.charAt(index))) index++;
2182
+ return index;
2183
+ }
2184
+ function acceptsDashLiveActionAt(text, index, workerAhead, gitCommandAhead, pathCommandAhead) {
2185
+ if (matchesDashBranchAt(RECOVERY_REVIEW_DASH_ACTION_AT_PATTERN, text, index)) return true;
2186
+ const launchLength = dashBranchLengthAt(RECOVERY_REVIEW_DASH_LAUNCH_AT_PATTERN, text, index);
2187
+ if (launchLength > 0 && workerAhead[index + launchLength] === 1) return true;
2188
+ if (matchesDashBranchAt(RECOVERY_REVIEW_DASH_FILE_COMMAND_AT_PATTERN, text, index) || pathCommandAhead[index] === 1) return true;
2189
+ return matchesDashBranchAt(RECOVERY_REVIEW_DASH_GIT_AT_PATTERN, text, index) && gitCommandAhead[index + 3] === 1;
2190
+ }
2191
+ function mentionsDashLiveAction(text) {
2192
+ if (!RECOVERY_REVIEW_DASH_SEPARATOR_EXISTS_PATTERN.test(text)) return false;
2193
+ const workerAhead = new Uint8Array(text.length + 1);
2194
+ const gitCommandAhead = new Uint8Array(text.length + 1);
2195
+ const pathCommandAhead = new Uint8Array(text.length + 1);
2196
+ for (let index = text.length - 1; index >= 0; index--) {
2197
+ const character = text.charAt(index);
2198
+ const lineCharacter = !RECOVERY_REVIEW_DASH_LINE_STOP_CHARACTERS.includes(character);
2199
+ const pathCharacter = !RECOVERY_REVIEW_WHITESPACE_CHARACTER_PATTERN.test(character);
2200
+ workerAhead[index] = matchesDashBranchAt(RECOVERY_REVIEW_DASH_WORKER_AT_PATTERN, text, index) || lineCharacter && workerAhead[index + 1] === 1 ? 1 : 0;
2201
+ gitCommandAhead[index] = matchesDashBranchAt(RECOVERY_REVIEW_DASH_GIT_COMMAND_AT_PATTERN, text, index) || lineCharacter && gitCommandAhead[index + 1] === 1 ? 1 : 0;
2202
+ pathCommandAhead[index] = character === "/" && matchesDashBranchAt(RECOVERY_REVIEW_DASH_FILE_COMMAND_AT_PATTERN, text, index + 1) || pathCharacter && pathCommandAhead[index + 1] === 1 ? 1 : 0;
2203
+ }
2204
+ for (let index = 0; index < text.length; index++) {
2205
+ const separatorLength = dashBranchLengthAt(RECOVERY_REVIEW_DASH_SEPARATOR_AT_PATTERN, text, index);
2206
+ if (separatorLength === 0) continue;
2207
+ const anchor = skipDashSeparatorWhitespace(text, index + separatorLength);
2208
+ if (acceptsDashLiveActionAt(text, anchor, workerAhead, gitCommandAhead, pathCommandAhead)) return true;
2209
+ if (!matchesDashBranchAt(RECOVERY_REVIEW_DASH_THEN_AT_PATTERN, text, anchor)) continue;
2210
+ const afterThen = skipDashSeparatorWhitespace(text, anchor + 4);
2211
+ if (afterThen > anchor + 4 && acceptsDashLiveActionAt(text, afterThen, workerAhead, gitCommandAhead, pathCommandAhead)) return true;
2212
+ }
2213
+ return false;
2214
+ }
2215
+ function createMutatingGitStates() {
2216
+ const state = () => ({ edges: [], epsilon: [] });
2217
+ const edge = (from, character, next) => {
2218
+ from.edges.push({ character, next });
2219
+ };
2220
+ const literal = (from, word, end) => {
2221
+ for (let index = 0; index < word.length; index++) {
2222
+ const next = index === word.length - 1 ? end : state();
2223
+ edge(from, new RegExp(word.charAt(index), "i"), next);
2224
+ from = next;
2225
+ }
2226
+ };
2227
+ const start = state();
2228
+ const accept = state();
2229
+ const afterOption = state();
2230
+ const afterSpace = state();
2231
+ literal(start, "git", afterOption);
2232
+ edge(afterOption, /\s/, afterSpace);
2233
+ edge(afterSpace, /\s/, afterSpace);
2234
+ for (const command of ["add", "branch", "cherry-pick", "clean", "commit", "merge", "rebase", "reset", "restore", "revert", "stash", "tag", "checkout", "switch"]) {
2235
+ literal(afterSpace, command, accept);
2236
+ }
2237
+ const value = state();
2238
+ const beforeSeparatedValue = state();
2239
+ const separatedValue = state();
2240
+ edge(beforeSeparatedValue, /\s/, separatedValue);
2241
+ edge(separatedValue, /\s/, separatedValue);
2242
+ separatedValue.epsilon.push(value);
2243
+ const shortDash = state();
2244
+ const shortOption = state();
2245
+ literal(afterSpace, "-", shortDash);
2246
+ edge(shortDash, /[A-Za-z]/, shortOption);
2247
+ shortOption.epsilon.push(afterOption, beforeSeparatedValue);
2248
+ const longStart = state();
2249
+ const longName = state();
2250
+ literal(shortDash, "-", longStart);
2251
+ edge(longStart, /[A-Za-z0-9-]/, longName);
2252
+ edge(longName, /[A-Za-z0-9-]/, longName);
2253
+ longName.epsilon.push(afterOption);
2254
+ edge(longName, /=/, value);
2255
+ for (const option of ["git-dir", "work-tree", "namespace", "exec-path", "config-env"]) {
2256
+ const specialOption = state();
2257
+ literal(longStart, option, specialOption);
2258
+ edge(specialOption, /=/, value);
2259
+ specialOption.epsilon.push(beforeSeparatedValue);
2260
+ }
2261
+ for (const [quote, body] of [[/"/, /[^"\n]/], [/'/, /[^'\n]/]]) {
2262
+ const quotedValue = state();
2263
+ edge(value, quote, quotedValue);
2264
+ edge(quotedValue, body, quotedValue);
2265
+ edge(quotedValue, quote, afterOption);
2266
+ }
2267
+ const plainValue = state();
2268
+ edge(value, /\S/, plainValue);
2269
+ edge(plainValue, /\S/, plainValue);
2270
+ plainValue.epsilon.push(afterOption);
2271
+ return { start, accept };
2272
+ }
2273
+ var MUTATING_GIT_STATES = createMutatingGitStates();
2274
+ function mentionsMutatingGitCommand(text) {
2275
+ let active = /* @__PURE__ */ new Set();
2276
+ let next = /* @__PURE__ */ new Set();
2277
+ const addState = (states, state) => {
2278
+ if (states.has(state)) return;
2279
+ states.add(state);
2280
+ for (const reachable of state.epsilon) addState(states, reachable);
2281
+ };
2282
+ for (let position = 0; position <= text.length; position++) {
2283
+ const character = text.charAt(position);
2284
+ const previousIsWord = RECOVERY_REVIEW_WORD_CHARACTER_PATTERN.test(text.charAt(position - 1));
2285
+ const currentIsWord = RECOVERY_REVIEW_WORD_CHARACTER_PATTERN.test(character);
2286
+ if (active.has(MUTATING_GIT_STATES.accept) && previousIsWord !== currentIsWord) return true;
2287
+ if (!previousIsWord) addState(active, MUTATING_GIT_STATES.start);
2288
+ if (position === text.length) break;
2289
+ next.clear();
2290
+ for (const state of active) {
2291
+ for (const edge of state.edges) {
2292
+ if (edge.character.test(character)) addState(next, edge.next);
2293
+ }
2294
+ }
2295
+ [active, next] = [next, active];
2296
+ }
2297
+ return false;
2298
+ }
2299
+ function mentionsMutatingCommand(text) {
2300
+ return RECOVERY_REVIEW_MUTATING_PATH_COMMAND_PATTERN.test(text) || mentionsMutatingGitCommand(text);
2301
+ }
2058
2302
  function isExplicitReadOnlyRecoveryReview(params) {
2059
2303
  const agent = typeof params.agent === "string" ? params.agent.trim() : "";
2060
2304
  const task = typeof params.task === "string" ? params.task.trim() : "";
2061
2305
  const taskDestructiveCommandText = task.replace(RECOVERY_REVIEW_BLOCKED_CONTEXT_FRAGMENT_PATTERN, " ").replace(RECOVERY_REVIEW_REGRESSION_EVIDENCE_PATTERN, " ").replace(RECOVERY_REVIEW_BLOCKED_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_CONTEXT_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_LISTED_BLOCKED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_BLOCKS_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_EXAMPLES_LIKE_BLOCKED_PATTERN, " ").replace(RECOVERY_REVIEW_QUOTED_VISIBLE_BLOCKED_PATTERN, " ").replace(RECOVERY_REVIEW_PROMPTS_LIKE_BLOCKED_PATTERN, " ").replace(RECOVERY_REVIEW_GIT_MUTATIONS_BROADER_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_GIT_COVERAGE_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_REGRESSION_FOLLOWED_BY_NAMED_RM_PATTERN, " ");
2062
2306
  const taskDashLiveActionText = task.replace(RECOVERY_REVIEW_DELIVERABLE_PATTERN, " ").replace(RECOVERY_REVIEW_CONTEXT_OBJECT_PATTERN, " ").replace(RECOVERY_REVIEW_MUTATION_NOUN_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_PRIOR_FIX_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_DETECTION_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_PATTERN_CHANGE_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_GIT_PATTERN_CHANGE_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_VALIDATION_EVIDENCE_PATTERN, " ").replace(RECOVERY_REVIEW_CONTRACT_PROHIBITION_PATTERN, " ").replace(RECOVERY_REVIEW_ONLY_REVIEW_CONTRACT_PATTERN, " ").replace(RECOVERY_REVIEW_BLOCKED_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_CONTEXT_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_LISTED_BLOCKED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_BLOCKS_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_EXAMPLES_LIKE_BLOCKED_PATTERN, " ").replace(RECOVERY_REVIEW_QUOTED_VISIBLE_BLOCKED_PATTERN, " ").replace(RECOVERY_REVIEW_PROMPTS_LIKE_BLOCKED_PATTERN, " ").replace(RECOVERY_REVIEW_GIT_MUTATIONS_BROADER_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_GIT_COVERAGE_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_REGRESSION_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_REGRESSION_ANAPHORIC_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_REGRESSION_FOLLOWED_BY_ANAPHORIC_PATTERN, " ").replace(RECOVERY_REVIEW_BLOCKED_LIVE_VARIANT_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_ANAPHORIC_REFERENCES_CONTEXT_PATTERN, " ");
2063
2307
  const taskMutationText = task.replace(RECOVERY_REVIEW_DELIVERABLE_PATTERN, " ").replace(RECOVERY_REVIEW_CONTEXT_OBJECT_PATTERN, " ").replace(RECOVERY_REVIEW_MUTATION_NOUN_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_PRIOR_FIX_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_DETECTION_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_PATTERN_CHANGE_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_GIT_PATTERN_CHANGE_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_VALIDATION_EVIDENCE_PATTERN, " ").replace(RECOVERY_REVIEW_CONTRACT_PROHIBITION_PATTERN, " ").replace(RECOVERY_REVIEW_ONLY_REVIEW_CONTRACT_PATTERN, " ").replace(RECOVERY_REVIEW_BLOCKED_CONTEXT_FRAGMENT_PATTERN, " ").replace(RECOVERY_REVIEW_REGRESSION_EVIDENCE_PATTERN, " ").replace(RECOVERY_REVIEW_BLOCKED_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_CONTEXT_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_LISTED_BLOCKED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_BLOCKS_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_EXAMPLES_LIKE_BLOCKED_PATTERN, " ").replace(RECOVERY_REVIEW_QUOTED_VISIBLE_BLOCKED_PATTERN, " ").replace(RECOVERY_REVIEW_PROMPTS_LIKE_BLOCKED_PATTERN, " ").replace(RECOVERY_REVIEW_GIT_MUTATIONS_BROADER_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_GIT_COVERAGE_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_REGRESSION_QUOTED_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_REGRESSION_ANAPHORIC_EXAMPLE_PATTERN, " ").replace(RECOVERY_REVIEW_REGRESSION_FOLLOWED_BY_ANAPHORIC_PATTERN, " ").replace(RECOVERY_REVIEW_BLOCKED_LIVE_VARIANT_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_ANAPHORIC_REFERENCES_CONTEXT_PATTERN, " ").replace(RECOVERY_REVIEW_NO_ANAPHORIC_MUTATION_CLAUSE_PATTERN, " ").replace(RECOVERY_REVIEW_NO_DELEGATION_CLAUSE_PATTERN, " ").replace(RECOVERY_REVIEW_NO_MUTATION_CLAUSE_PATTERN, " ").replace(new RegExp(RECOVERY_REVIEW_READ_ONLY_PATTERN.source, "gi"), " ");
2064
- return params.acceptance === false && agent !== "" && /\b(?:advisor|oracle|review|reviewer)\b/i.test(agent) && RECOVERY_REVIEW_READ_ONLY_PATTERN.test(task) && !RECOVERY_REVIEW_DESTRUCTIVE_COMMAND_PATTERN.test(taskDestructiveCommandText) && !RECOVERY_REVIEW_MUTATION_VERB_PATTERN.test(taskMutationText) && !RECOVERY_REVIEW_DELEGATION_PATTERN.test(taskMutationText) && !RECOVERY_REVIEW_ANAPHORIC_MUTATION_PATTERN.test(taskMutationText) && !RECOVERY_REVIEW_DESTRUCTIVE_COMMAND_PATTERN.test(taskMutationText) && !RECOVERY_REVIEW_DASH_LIVE_ACTION_PATTERN.test(taskDashLiveActionText);
2308
+ return params.acceptance === false && agent !== "" && /\b(?:advisor|oracle|review|reviewer)\b/i.test(agent) && RECOVERY_REVIEW_READ_ONLY_PATTERN.test(task) && !mentionsMutatingCommand(taskDestructiveCommandText) && !RECOVERY_REVIEW_MUTATION_VERB_PATTERN.test(taskMutationText) && !RECOVERY_REVIEW_DELEGATION_PATTERN.test(taskMutationText) && !RECOVERY_REVIEW_ANAPHORIC_MUTATION_PATTERN.test(taskMutationText) && !mentionsMutatingCommand(taskMutationText) && !mentionsDashLiveAction(taskDashLiveActionText);
2065
2309
  }
2066
2310
  function recoveryBarrierMessage(sourceKey, target) {
2067
2311
  return `Run '${target}' cannot launch after run '${sourceKey}' returned rejected acceptance recovery; only explicit read-only review children with acceptance:false may follow.`;
@@ -2391,6 +2635,30 @@ function directRunsAllKeys(call) {
2391
2635
  return keyNode && key !== void 0 ? [{ key, node: keyNode }] : [];
2392
2636
  });
2393
2637
  }
2638
+ function keylessRunsAllItems(call) {
2639
+ const args = Array.isArray(call.arguments) ? call.arguments : [];
2640
+ const items = args[0];
2641
+ if (!astNode(items)) return [];
2642
+ if (items.type === "ArrayExpression" && Array.isArray(items.elements)) {
2643
+ return items.elements.flatMap((item, index) => keylessItemLiteral(item) ? [{ node: item, index }] : []);
2644
+ }
2645
+ const callee = items.type === "CallExpression" && astNode(items.callee) && items.callee.type === "MemberExpression" && items.callee.computed !== true ? items.callee : void 0;
2646
+ if (!callee || !astNode(callee.property) || callee.property.type !== "Identifier" || callee.property.name !== "map") return [];
2647
+ const callback = Array.isArray(items.arguments) ? items.arguments[0] : void 0;
2648
+ if (!astNode(callback) || callback.type !== "ArrowFunctionExpression" && callback.type !== "FunctionExpression" || !astNode(callback.body)) return [];
2649
+ let result = callback.body;
2650
+ if (callback.body.type === "BlockStatement" && Array.isArray(callback.body.body)) {
2651
+ const returns = [];
2652
+ walkAst(callback.body, (node) => {
2653
+ if (node.type === "ReturnStatement") returns.push(node);
2654
+ }, false);
2655
+ result = returns.length === 1 && returns[0] === callback.body.body.at(-1) ? returns[0].argument : void 0;
2656
+ }
2657
+ return keylessItemLiteral(result) ? [{ node: result }] : [];
2658
+ }
2659
+ function keylessItemLiteral(node) {
2660
+ return astNode(node) && node.type === "ObjectExpression" && Array.isArray(node.properties) && node.properties.every((property) => astNode(property) && property.type === "Property" && property.kind === "init" && property.computed !== true && staticPropertyKey(property) !== "__proto__") && !directObjectPropertyValue(node, "key") && !directObjectPropertyValue(node, "then");
2661
+ }
2394
2662
  function containsWorkflowLaunch(node) {
2395
2663
  let found = false;
2396
2664
  walkAst(node, (candidate) => {
@@ -2506,7 +2774,9 @@ ${script}
2506
2774
  })()`, { ecmaVersion: "latest", sourceType: "script", locations: true });
2507
2775
  } catch (error) {
2508
2776
  const location = error && typeof error === "object" && "loc" in error && error.loc && typeof error.loc === "object" ? error.loc : void 0;
2509
- const message = (error instanceof Error ? error.message : String(error)).replace(/\s+\(\d+:\d+\)$/, "");
2777
+ const parserMessage = (error instanceof Error ? error.message : String(error)).replace(/\s+\(\d+:\d+\)$/, "");
2778
+ const source = script.trim();
2779
+ const message = /^\S+$/.test(source) && (/^(?:~|\.{1,2})?\//.test(source) || /\.(?:[cm]?[jt]s|json)$/.test(source)) ? `${parserMessage}. The script looks like a file path ('${source}'): options.script takes the script's source text; pass a script file as workflow: "${source}".` : parserMessage;
2510
2780
  return { ok: false, errors: [{ message, ...typeof location?.line === "number" ? { line: Math.max(1, location.line - 1) } : {}, ...typeof location?.column === "number" ? { column: location.column + 1 } : {} }] };
2511
2781
  }
2512
2782
  const wrapper = astNode(root.body) ? void 0 : Array.isArray(root.body) && astNode(root.body[0]) && astNode(root.body[0].expression) && astNode(root.body[0].expression.callee) ? root.body[0].expression.callee : void 0;
@@ -2517,6 +2787,7 @@ ${script}
2517
2787
  if (node !== wrapper && node.async === true && (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression")) {
2518
2788
  errors.push({ message: "workflowScript does not support nested async functions. Use top-level await, plain helper functions that return runs.run(...), or explicit Promise chains.", ...nodeLocation(node) });
2519
2789
  }
2790
+ if (node.type === "ImportExpression") errors.push({ message: "workflowScript cannot load modules with import().", ...nodeLocation(node) });
2520
2791
  if (directRunsCall(node, "run")) {
2521
2792
  const args = Array.isArray(node.arguments) ? node.arguments : [];
2522
2793
  const keyNode = astNode(args[0]) ? args[0] : void 0;
@@ -2531,6 +2802,10 @@ ${script}
2531
2802
  }
2532
2803
  if (directRunsCall(node, "all")) {
2533
2804
  for (const entry of directRunsAllKeys(node)) if (!KEY_PATTERN.test(entry.key)) errors.push({ message: "runs.all item key must be 1-128 characters using letters, numbers, '.', '_' or '-', and start with a letter or number.", ...nodeLocation(entry.node) });
2805
+ if (!runsRebound) for (const item of keylessRunsAllItems(node)) {
2806
+ const subject = item.index === void 0 ? "runs.all items built by this map(...) callback have no key" : `runs.all item ${item.index} has no key`;
2807
+ errors.push({ message: `${subject}; every runs.all item needs a stable key, for example runs.all([{ key: "review", agent, task }]).`, ...nodeLocation(item.node) });
2808
+ }
2534
2809
  const args = Array.isArray(node.arguments) ? node.arguments : [];
2535
2810
  if (astNode(args[0]) && args[0].type === "ArrayExpression" && Array.isArray(args[0].elements)) {
2536
2811
  for (const item of args[0].elements) if (astNode(item)) {
@@ -2613,7 +2888,7 @@ function resolveWorkflowParserEntry() {
2613
2888
  const manifestPath = requireFromPackage.resolve("acorn/package.json");
2614
2889
  const manifest = JSON.parse(readFileSync6(manifestPath, "utf8"));
2615
2890
  const entry = typeof manifest.main === "string" && manifest.main ? manifest.main : "./dist/acorn.js";
2616
- return resolvePath(dirname6(manifestPath), entry);
2891
+ return resolvePath(dirname7(manifestPath), entry);
2617
2892
  } catch {
2618
2893
  throw primaryError;
2619
2894
  }
@@ -2658,7 +2933,7 @@ async function runWorkflowScript(options) {
2658
2933
  if (options.processCwd !== void 0) {
2659
2934
  let staleCwd = false;
2660
2935
  try {
2661
- realpathSync3(process.cwd());
2936
+ realpathSync4(process.cwd());
2662
2937
  } catch (error) {
2663
2938
  const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
2664
2939
  if (code !== "ENOENT") throw new WorkflowScriptError("Workflow current cwd could not be validated.", emptyPartial(), "runtime", { cause: error });
@@ -2667,7 +2942,7 @@ async function runWorkflowScript(options) {
2667
2942
  try {
2668
2943
  if (staleCwd) process.chdir(options.processCwd);
2669
2944
  else {
2670
- const target = realpathSync3(options.processCwd);
2945
+ const target = realpathSync4(options.processCwd);
2671
2946
  if (!statSync4(target).isDirectory()) {
2672
2947
  const error = new Error(`ENOTDIR: not a directory, access '${target}'`);
2673
2948
  error.code = "ENOTDIR";
@@ -2688,8 +2963,7 @@ async function runWorkflowScript(options) {
2688
2963
  }
2689
2964
  let worker;
2690
2965
  try {
2691
- const bun = typeof process.versions.bun === "string";
2692
- worker = bun ? new Worker(WORKFLOW_WORKER_URL, { workerData: { acornPath } }) : new Worker(nodeWorkerSource ??= readFileSync6(WORKFLOW_WORKER_URL, "utf8"), { eval: true, workerData: { acornPath } });
2966
+ worker = createWorkflowScriptWorker(acornPath);
2693
2967
  } catch (error) {
2694
2968
  throw new WorkflowScriptError(`Workflow worker could not start: ${error instanceof Error ? error.message : String(error)}`, emptyPartial(), "runtime", { cause: error });
2695
2969
  }
@@ -2862,7 +3136,7 @@ async function runWorkflowScript(options) {
2862
3136
  if (options.signal?.aborted) return onAbort();
2863
3137
  worker.on("error", (error) => finish({ error: taggedWorkflowError(`Workflow worker failed: ${error instanceof Error ? error.message : String(error)}`, "runtime") }));
2864
3138
  worker.on("exit", (code) => {
2865
- if (!settled && code !== 0) finish({ error: taggedWorkflowError(`Workflow worker exited with code ${code}.`, "runtime") });
3139
+ if (!settled && !finishing) finish({ error: taggedWorkflowError(`Workflow worker exited before returning a result (code ${code}).`, "runtime") });
2866
3140
  });
2867
3141
  worker.on("message", (message) => {
2868
3142
  if (settled) return;
@@ -3086,8 +3360,11 @@ async function runWorkflowScript(options) {
3086
3360
  if (existing) {
3087
3361
  if (existing.fingerprint !== fingerprint) return respond(Promise.reject(new Error(`Duplicate workflow key '${key}' used with incompatible launch params.`)));
3088
3362
  if (callObserved) existing.observed = true;
3089
- trace.push({ operation: "run", key, state: "reused", ...workflowStringMetadata(params), ...existing.generatedLaneKey ? { generatedLaneKey: existing.generatedLaneKey } : {} });
3090
- traceChanged();
3363
+ if (!existing.reuseTraced) {
3364
+ existing.reuseTraced = true;
3365
+ trace.push({ operation: "run", key, state: "reused", ...workflowStringMetadata(params), ...existing.generatedLaneKey ? { generatedLaneKey: existing.generatedLaneKey } : {} });
3366
+ traceChanged();
3367
+ }
3091
3368
  return respond(deliver(existing.promise), `runs.run('${key}') result`, (error) => children.set(key, responseBoundaryFailure(key, error)));
3092
3369
  }
3093
3370
  const permitError = options.oneUsePermit?.claim(key);
@@ -3095,6 +3372,7 @@ async function runWorkflowScript(options) {
3095
3372
  if (options.oneUsePermit && message.args.batch !== void 0) return respond(Promise.reject(new Error("Workflow child permit does not support runs.all.")));
3096
3373
  if (options.oneUsePermit && params.resume !== void 0) return respond(Promise.reject(new Error("Workflow child permit does not support retained resume.")));
3097
3374
  if (params.action !== void 0) return respond(Promise.reject(new Error(`runs.run('${key}') accepts execution params only; management action is not allowed.`)));
3375
+ if (params.requireLauncher !== void 0) return respond(Promise.reject(new Error(`runs.run('${key}'): ${REQUIRE_LAUNCHER_SHAPE_ERROR}`)));
3098
3376
  if (params.workflowScript !== void 0) return respond(Promise.reject(new Error(`runs.run('${key}') cannot start a nested workflow script.`)));
3099
3377
  if (params.tasks !== void 0 || params.chain !== void 0 || params.parallel !== void 0 || params.concurrency !== void 0 || params.chainDir !== void 0) {
3100
3378
  return respond(Promise.reject(new Error(`runs.run('${key}') accepts one child via { agent, task }; use runs.all(...) and JavaScript control flow for orchestration.`)));
@@ -6099,6 +6377,23 @@ function runGitChecked(cwd, args) {
6099
6377
  }
6100
6378
  return result.stdout;
6101
6379
  }
6380
+ function findListedWorktreeOnBranch(repoCwd, branch) {
6381
+ let current;
6382
+ for (const line of runGitChecked(repoCwd, ["worktree", "list", "--porcelain"]).split("\n")) {
6383
+ if (line.startsWith("worktree ")) current = line.slice("worktree ".length);
6384
+ else if (line === `branch refs/heads/${branch}` && current) return normalizeComparableCwd(current);
6385
+ }
6386
+ return void 0;
6387
+ }
6388
+ function findListedWorktreeAgentCwd(repoCwd, branch) {
6389
+ const worktree = findListedWorktreeOnBranch(repoCwd, branch);
6390
+ if (!worktree) return void 0;
6391
+ const cwdRelative = resolveRepoCwdRelative(repoCwd);
6392
+ return cwdRelative ? path16.join(worktree, cwdRelative) : worktree;
6393
+ }
6394
+ function isComparablePathInside(parent, child) {
6395
+ return isPathInside(normalizeComparableCwd(parent), normalizeComparableCwd(child));
6396
+ }
6102
6397
  function validateWorktreePatch(worktreePath, patchPath) {
6103
6398
  const result = runGit(worktreePath, [...PATCH_VALIDATION_OPTIONS, patchPath]);
6104
6399
  if (result.status === 0) return void 0;
@@ -7202,6 +7497,7 @@ export {
7202
7497
  buildNestedRouteIndex,
7203
7498
  projectNestedRegistryForRoot,
7204
7499
  retainNestedLookupRoute,
7500
+ collectNestedRuns,
7205
7501
  findNestedRunMatchesById,
7206
7502
  projectNestedEvents,
7207
7503
  writeNestedEvent,
@@ -7234,6 +7530,11 @@ export {
7234
7530
  upsertHostStep,
7235
7531
  hostStepVerdictLabel,
7236
7532
  hostStepReportName,
7533
+ REQUIRE_LAUNCHER_SHAPE_ERROR,
7534
+ lookupRunnerLauncher,
7535
+ runnerLauncherPlacementError,
7536
+ resolveAgentRunnerLauncher,
7537
+ checkRequiredRunnerLauncher,
7237
7538
  resolveWorkflowHostOutputClaimPath,
7238
7539
  executeWorkflowHostCommand,
7239
7540
  WorkflowScriptError,
@@ -7303,10 +7604,14 @@ export {
7303
7604
  WORKTREE_AGENT_CWD_PLACEHOLDER,
7304
7605
  MACHINE_DIFF_OPTIONS,
7305
7606
  withWorktreeTransaction,
7607
+ findListedWorktreeOnBranch,
7608
+ findListedWorktreeAgentCwd,
7609
+ isComparablePathInside,
7306
7610
  validateWorktreePatchRepresentsCurrentWorktree,
7307
7611
  preflightWorktreeSource,
7308
7612
  normalizeWorktreeBaseRef,
7309
7613
  normalizeWorktreeBranchPrefix,
7614
+ buildWorktreeNaming,
7310
7615
  resolveWorktreeProvider,
7311
7616
  shouldDeferWorktreeCwd,
7312
7617
  resolveExpectedWorktreeAgentCwd,