@xzzpig/pi-subagents 0.24.1 → 0.25.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 (263) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/bundle/agent-management.js +4 -4
  3. package/bundle/agents.js +3 -3
  4. package/bundle/child-tool-plan.js +2 -2
  5. package/bundle/chunk-34TUUBRN.js +1107 -0
  6. package/bundle/{chunk-SW2VMNIU.js → chunk-5OD3OWTE.js} +2 -2
  7. package/bundle/{chunk-ZWXU5SPQ.js → chunk-5YEOWNSD.js} +371 -135
  8. package/bundle/{chunk-EUPJB4S7.js → chunk-5Z7JAORM.js} +196 -1219
  9. package/bundle/{chunk-LCDJWBVM.js → chunk-66JNFRFS.js} +1 -1
  10. package/bundle/{chunk-6BJUEES3.js → chunk-6MNRKUHY.js} +23 -12
  11. package/bundle/{chunk-ED55MIC2.js → chunk-CGFF4WA3.js} +42 -19
  12. package/bundle/{chunk-TMHVDPYW.js → chunk-DLVPMML3.js} +263 -154
  13. package/bundle/chunk-HXRB42AF.js +108 -0
  14. package/bundle/{chunk-355ECEP2.js → chunk-IH7LQVEE.js} +29 -14
  15. package/bundle/{chunk-SLNMBXLL.js → chunk-IJWITCC6.js} +411 -249
  16. package/bundle/{chunk-RU522D5W.js → chunk-IKFKH5EL.js} +369 -50
  17. package/bundle/{chunk-Z6TFJ6BR.js → chunk-INWSUNI6.js} +1 -1
  18. package/bundle/{chunk-JEA2ZKUA.js → chunk-IUDEI6FJ.js} +35 -200
  19. package/bundle/{chunk-WW76JRIX.js → chunk-JAXVBXGF.js} +1 -1
  20. package/bundle/{chunk-ICNYIALB.js → chunk-JH5H4CYJ.js} +784 -474
  21. package/bundle/{chunk-35GII5EF.js → chunk-JWFLPSTP.js} +41 -117
  22. package/bundle/{chunk-LMGQAJ3O.js → chunk-KCJFGKVK.js} +350 -123
  23. package/bundle/{chunk-RB4GELQA.js → chunk-LPJEKHOY.js} +1 -1
  24. package/bundle/chunk-LYKG4FKH.js +523 -0
  25. package/bundle/{chunk-X6LOM3Z4.js → chunk-LZ3HBDTR.js} +161 -78
  26. package/bundle/{chunk-FG6SQJAR.js → chunk-OGPOCGWX.js} +24 -6
  27. package/bundle/{chunk-Y6H2G6KX.js → chunk-OSVXFWPG.js} +67 -30
  28. package/bundle/{chunk-FJWI64H7.js → chunk-RMSABUN3.js} +27 -13
  29. package/bundle/{chunk-H36HBZB2.js → chunk-SJPABBZG.js} +2 -2
  30. package/bundle/{chunk-3U633XDZ.js → chunk-U3ZDUUTM.js} +11 -3
  31. package/bundle/{chunk-LVWU2HOO.js → chunk-ULGMXABL.js} +16 -7
  32. package/bundle/{chunk-WPW4V6HM.js → chunk-W7ZA6TYD.js} +2 -2
  33. package/bundle/{chunk-V2KFIGFH.js → chunk-XAC2XNAP.js} +503 -304
  34. package/bundle/{chunk-TGLFTQWJ.js → chunk-YWXILP5N.js} +5 -4
  35. package/bundle/control-channel.js +2 -2
  36. package/bundle/index.js +1 -1
  37. package/bundle/intercom-bridge.js +2 -2
  38. package/bundle/preflight.js +12 -10
  39. package/bundle/project-panes.js +3 -3
  40. package/bundle/workflow-resources.js +1 -1
  41. package/docs/agents.md +27 -6
  42. package/docs/configuration.md +20 -8
  43. package/docs/extension-api.md +18 -1
  44. package/docs/models.md +6 -2
  45. package/docs/observability.md +2 -0
  46. package/docs/tool-reference.md +7 -1
  47. package/docs/workflows.md +30 -2
  48. package/node_modules/@xzzpig/pi-components/CHANGELOG.md +12 -0
  49. package/node_modules/@xzzpig/pi-components/README.md +94 -0
  50. package/node_modules/@xzzpig/pi-components/dist/src/transcript-presenter.d.ts +186 -0
  51. package/node_modules/@xzzpig/pi-components/dist/src/transcript-presenter.js +693 -0
  52. package/node_modules/@xzzpig/pi-components/package.json +5 -1
  53. package/package.json +4 -4
  54. package/skills/pi-subagents/SKILL.md +15 -6
  55. package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
  56. package/src/agents/agent-management.d.ts +1 -0
  57. package/src/agents/agent-management.js +46 -18
  58. package/src/agents/agent-memory.d.ts +1 -4
  59. package/src/agents/agent-memory.js +1 -4
  60. package/src/agents/agent-serializer.d.ts +2 -0
  61. package/src/agents/agent-serializer.js +1 -1
  62. package/src/agents/agents.d.ts +2 -3
  63. package/src/agents/agents.js +46 -20
  64. package/src/agents/frontmatter.js +1 -8
  65. package/src/agents/global-npm-root.d.ts +1 -0
  66. package/src/agents/global-npm-root.js +11 -3
  67. package/src/agents/skills.d.ts +0 -3
  68. package/src/agents/skills.js +0 -3
  69. package/src/api/preflight.d.ts +3 -1
  70. package/src/api/preflight.js +2 -0
  71. package/src/extension/config.d.ts +1 -0
  72. package/src/extension/config.js +13 -1
  73. package/src/extension/herdr-pi-bridge.js +10 -2
  74. package/src/extension/index.d.ts +0 -13
  75. package/src/extension/index.js +51 -37
  76. package/src/extension/public-execution.d.ts +1 -0
  77. package/src/extension/public-execution.js +4 -0
  78. package/src/extension/reply-workflow-script.js +24 -4
  79. package/src/extension/schemas.d.ts +12 -3
  80. package/src/extension/schemas.js +7 -3
  81. package/src/extension/session-switch.d.ts +25 -0
  82. package/src/extension/session-switch.js +138 -0
  83. package/src/extension/subagent-guide.d.ts +1 -1
  84. package/src/extension/subagent-guide.js +1 -1
  85. package/src/extension/subagent-launch-tool.d.ts +25 -0
  86. package/src/extension/subagent-launch-tool.js +48 -0
  87. package/src/extension/tool-activation.js +55 -15
  88. package/src/extension/tool-description.d.ts +1 -1
  89. package/src/extension/tool-description.js +14 -8
  90. package/src/inspectors/herdr/actions.d.ts +0 -1
  91. package/src/inspectors/herdr/actions.js +0 -1
  92. package/src/inspectors/session-roots-codec.d.ts +0 -1
  93. package/src/inspectors/session-roots-codec.js +0 -1
  94. package/src/inspectors/tmux/actions.d.ts +0 -1
  95. package/src/inspectors/tmux/actions.js +0 -1
  96. package/src/integrations/herdr-status.js +3 -8
  97. package/src/intercom/native-supervisor-channel.js +65 -9
  98. package/src/runs/background/async-execution.d.ts +7 -10
  99. package/src/runs/background/async-execution.js +66 -29
  100. package/src/runs/background/async-job-tracker.js +12 -0
  101. package/src/runs/background/async-resume.d.ts +2 -1
  102. package/src/runs/background/async-resume.js +114 -40
  103. package/src/runs/background/async-retention.d.ts +0 -2
  104. package/src/runs/background/async-retention.js +17 -6
  105. package/src/runs/background/async-status.d.ts +2 -0
  106. package/src/runs/background/async-status.js +4 -0
  107. package/src/runs/background/auto-drain.js +2 -1
  108. package/src/runs/background/boot-id.d.ts +1 -3
  109. package/src/runs/background/boot-id.js +1 -3
  110. package/src/runs/background/completion-batcher.d.ts +3 -4
  111. package/src/runs/background/completion-batcher.js +2 -3
  112. package/src/runs/background/control-channel.d.ts +0 -6
  113. package/src/runs/background/control-channel.js +0 -6
  114. package/src/runs/background/fleet-view.js +2 -3
  115. package/src/runs/background/notify.d.ts +0 -2
  116. package/src/runs/background/notify.js +0 -2
  117. package/src/runs/background/result-watcher.d.ts +1 -0
  118. package/src/runs/background/result-watcher.js +59 -29
  119. package/src/runs/background/resume-guidance.js +4 -2
  120. package/src/runs/background/retained-children.js +2 -1
  121. package/src/runs/background/run-child-session.d.ts +2 -3
  122. package/src/runs/background/run-child-session.js +5 -8
  123. package/src/runs/background/run-status.js +9 -7
  124. package/src/runs/background/runner-aliases.js +15 -0
  125. package/src/runs/background/scheduled-runs.d.ts +3 -1
  126. package/src/runs/background/scheduled-runs.js +13 -16
  127. package/src/runs/background/steering.d.ts +2 -11
  128. package/src/runs/background/steering.js +11 -6
  129. package/src/runs/background/subagent-runner.d.ts +2 -6
  130. package/src/runs/background/subagent-runner.js +88 -70
  131. package/src/runs/background/subagent-wait.js +12 -15
  132. package/src/runs/background/wait-config.d.ts +2 -0
  133. package/src/runs/background/wait-config.js +17 -3
  134. package/src/runs/background/wait-subscriptions.js +124 -12
  135. package/src/runs/background/wait-tool.js +4 -2
  136. package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
  137. package/src/runs/background/workflow-terminal-proof.js +0 -1
  138. package/src/runs/foreground/async-steering-action.js +24 -9
  139. package/src/runs/foreground/async-stop-action.d.ts +1 -1
  140. package/src/runs/foreground/async-stop-action.js +9 -1
  141. package/src/runs/foreground/execution.d.ts +0 -3
  142. package/src/runs/foreground/execution.js +56 -24
  143. package/src/runs/foreground/prompt-audit.js +1 -0
  144. package/src/runs/foreground/subagent-executor.d.ts +5 -10
  145. package/src/runs/foreground/subagent-executor.js +164 -49
  146. package/src/runs/shared/acceptance.js +69 -26
  147. package/src/runs/shared/async-status-projection.d.ts +2 -0
  148. package/src/runs/shared/async-status-projection.js +10 -0
  149. package/src/runs/shared/child-commands.js +15 -2
  150. package/src/runs/shared/child-hooks.d.ts +1 -7
  151. package/src/runs/shared/child-hooks.js +13 -5
  152. package/src/runs/shared/child-launch.js +6 -2
  153. package/src/runs/shared/child-runtime-config.d.ts +0 -1
  154. package/src/runs/shared/child-session.d.ts +6 -5
  155. package/src/runs/shared/child-session.js +85 -38
  156. package/src/runs/shared/child-tool-plan.d.ts +0 -1
  157. package/src/runs/shared/child-tool-plan.js +0 -1
  158. package/src/runs/shared/claude-code-adapter.js +11 -0
  159. package/src/runs/shared/external-cli-contract.d.ts +49 -0
  160. package/src/runs/shared/external-cli-contract.js +18 -13
  161. package/src/runs/shared/external-cli-runner.js +26 -6
  162. package/src/runs/shared/herdr-connection.js +2 -1
  163. package/src/runs/shared/herdr-pane-host.d.ts +2 -2
  164. package/src/runs/shared/herdr-pane-host.js +17 -1
  165. package/src/runs/shared/herdr-placed-run.js +51 -24
  166. package/src/runs/shared/lane-metadata.d.ts +0 -1
  167. package/src/runs/shared/lane-metadata.js +0 -1
  168. package/src/runs/shared/mcp-config-sources.d.ts +4 -1
  169. package/src/runs/shared/mcp-config-sources.js +1 -1
  170. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
  171. package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
  172. package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
  173. package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
  174. package/src/runs/shared/model-resolution.d.ts +20 -5
  175. package/src/runs/shared/model-resolution.js +55 -50
  176. package/src/runs/shared/model-scope.d.ts +1 -5
  177. package/src/runs/shared/model-scope.js +1 -5
  178. package/src/runs/shared/mutation-evidence.d.ts +1 -1
  179. package/src/runs/shared/mutation-evidence.js +52 -7
  180. package/src/runs/shared/nested-events.d.ts +1 -0
  181. package/src/runs/shared/nested-events.js +1 -1
  182. package/src/runs/shared/parallel-utils.d.ts +0 -1
  183. package/src/runs/shared/permissions.js +5 -3
  184. package/src/runs/shared/placement-host.d.ts +5 -1
  185. package/src/runs/shared/rex-pane-host.d.ts +0 -1
  186. package/src/runs/shared/rex-pane-host.js +0 -2
  187. package/src/runs/shared/run-launch-folder.d.ts +12 -0
  188. package/src/runs/shared/run-launch-folder.js +21 -0
  189. package/src/runs/shared/runner-launcher.d.ts +12 -1
  190. package/src/runs/shared/runner-launcher.js +16 -0
  191. package/src/runs/shared/single-output.d.ts +3 -3
  192. package/src/runs/shared/single-output.js +5 -3
  193. package/src/runs/shared/structured-output.d.ts +8 -0
  194. package/src/runs/shared/structured-output.js +40 -5
  195. package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
  196. package/src/runs/shared/subagent-prompt-runtime.js +18 -4
  197. package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
  198. package/src/runs/shared/supervisor-wait-timer.js +61 -0
  199. package/src/runs/shared/tool-timeout.js +2 -1
  200. package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
  201. package/src/runs/shared/worktree-cleanup-plan.js +0 -1
  202. package/src/runs/shared/worktree.d.ts +3 -0
  203. package/src/runs/shared/worktree.js +20 -0
  204. package/src/shared/artifacts.d.ts +1 -0
  205. package/src/shared/artifacts.js +132 -22
  206. package/src/shared/capacity-resilient-json.d.ts +1 -1
  207. package/src/shared/child-cache-retention.d.ts +1 -2
  208. package/src/shared/child-cache-retention.js +1 -2
  209. package/src/shared/fleet-transcript-reader.d.ts +51 -0
  210. package/src/shared/fleet-transcript-reader.js +333 -0
  211. package/src/shared/formatters.d.ts +0 -18
  212. package/src/shared/formatters.js +0 -18
  213. package/src/shared/pruned-fork.js +2 -2
  214. package/src/shared/reported-progress.d.ts +1 -0
  215. package/src/shared/reported-progress.js +12 -0
  216. package/src/shared/session-succession.d.ts +16 -1
  217. package/src/shared/session-succession.js +41 -2
  218. package/src/shared/session-warnings.d.ts +7 -0
  219. package/src/shared/session-warnings.js +26 -0
  220. package/src/shared/settings.d.ts +0 -23
  221. package/src/shared/settings.js +3 -35
  222. package/src/shared/status-format.d.ts +1 -0
  223. package/src/shared/status-format.js +1 -1
  224. package/src/shared/types.d.ts +108 -59
  225. package/src/shared/types.js +0 -12
  226. package/src/shared/utils.d.ts +3 -15
  227. package/src/shared/utils.js +4 -22
  228. package/src/shared/wait-tool-name.d.ts +8 -0
  229. package/src/shared/wait-tool-name.js +13 -0
  230. package/src/slash/slash-commands.js +2 -1
  231. package/src/slash/subagent-cost.d.ts +3 -2
  232. package/src/slash/subagent-cost.js +22 -3
  233. package/src/slash/subagents-admin.js +0 -1
  234. package/src/tui/fleet-status.d.ts +0 -5
  235. package/src/tui/fleet-status.js +4 -24
  236. package/src/tui/fleet.js +6 -4
  237. package/src/tui/render.d.ts +0 -9
  238. package/src/tui/render.js +194 -68
  239. package/src/tui/subagent-messages.js +3 -2
  240. package/src/watchdog/model-selection.js +2 -2
  241. package/src/watchdog/permission-arbiter.js +1 -0
  242. package/src/watchdog/register-child.d.ts +2 -3
  243. package/src/watchdog/register-child.js +2 -3
  244. package/src/watchdog/review.d.ts +0 -5
  245. package/src/watchdog/review.js +4 -3
  246. package/src/watchdog/turn-delta.js +2 -1
  247. package/src/workflows/scripted-workflow.d.ts +2 -0
  248. package/src/workflows/scripted-workflow.js +344 -59
  249. package/src/workflows/structured-workflow-scripts.d.ts +4 -3
  250. package/src/workflows/structured-workflow-scripts.js +32 -11
  251. package/src/workflows/workflow-launch-record.d.ts +15 -6
  252. package/src/workflows/workflow-launch-record.js +30 -12
  253. package/src/workflows/workflow-receipt.js +36 -53
  254. package/src/workflows/workflow-resources.js +4 -4
  255. package/src/workflows/workflow-resume-claim.d.ts +2 -0
  256. package/src/workflows/workflow-resume-claim.js +3 -3
  257. package/src/workflows/workflow-resume.d.ts +1 -1
  258. package/src/workflows/workflow-resume.js +13 -8
  259. package/src/workflows/workflow-script-worker.d.ts +13 -0
  260. package/src/workflows/workflow-script-worker.js +81 -0
  261. package/workflow-script-process.cjs +36 -0
  262. package/workflow-script-worker.cjs +4 -1
  263. package/bundle/chunk-U4ODUYAG.js +0 -235
@@ -1,89 +1,22 @@
1
1
  import {
2
2
  CODE_OWNED_EXTERNAL_CLI_ADAPTER_IDS,
3
+ REX_LOCAL_MACHINE,
3
4
  getAgentDir,
4
- getProjectConfigDir
5
- } from "./chunk-V2KFIGFH.js";
6
-
7
- // src/runs/shared/rex-machine.ts
8
- import { spawnSync } from "node:child_process";
9
- import * as fs from "node:fs";
10
- import * as os from "node:os";
11
- import * as path from "node:path";
12
- var REX_LOCAL_MACHINE = "local";
13
- var REX_EXIT_GONE = 3;
14
- var REX_EXIT_UNREACHABLE = 4;
15
- function isRexLocalMachine(machine) {
16
- return machine?.provider === "rex" && !("target" in machine);
17
- }
18
- var REX_BUNDLE_BIN = "Library/Application Support/com.superlogical.rex/RexServer/Versions/Current/Rex Server.app/Contents/MacOS/rex";
19
- var REX_CALL_TIMEOUT_MS = 15e3;
20
- var REX_MAX_OUTPUT = 1024 * 1024;
21
- function rexGlobalArgs(server) {
22
- return server ? ["--autostart=false", "-S", server] : ["--autostart=false"];
23
- }
24
- function executable(file) {
25
- try {
26
- fs.accessSync(file, fs.constants.X_OK);
27
- return fs.statSync(file).isFile();
28
- } catch {
29
- return false;
30
- }
31
- }
32
- function resolveRexBinary(env = process.env) {
33
- const fromDir = env.REX_BIN_DIR ? [path.join(env.REX_BIN_DIR, "rex")] : [];
34
- const fromPath = (env.PATH ?? "").split(path.delimiter).filter((dir) => path.isAbsolute(dir)).map((dir) => path.join(dir, "rex"));
35
- const found = [...fromDir, ...fromPath, path.join(os.homedir(), REX_BUNDLE_BIN)].find(executable);
36
- if (!found) throw new Error("The Rex CLI was not found: set REX_BIN_DIR, put rex on PATH, or install Rex.");
37
- return found;
38
- }
39
- function rexCommandEnv(source = process.env) {
40
- const { REX_SESSION: _session, REX_BLOCK: _block, REX_SERVER: _server, ...env } = source;
41
- return env;
42
- }
43
- function sessionConfirmed(stdout, session) {
44
- try {
45
- const parsed = JSON.parse(stdout);
46
- return parsed?.session_id === session;
47
- } catch {
48
- return false;
49
- }
50
- }
51
- function resolveRexLocalPlacement(input) {
52
- if (process.platform === "win32") throw new Error("Machine 'local' runs the child in a Rex pane, which is not supported on Windows.");
53
- const env = input.env ?? process.env, session = env.REX_SESSION?.trim(), server = env.REX_SERVER?.trim();
54
- if (!session) throw new Error("Machine 'local' opens the child in a new tab of this Rex session, but this Pi is not running inside Rex (REX_SESSION is not set).");
55
- const result = spawnSync(resolveRexBinary(env), [...rexGlobalArgs(server), "session", "inspect", session, "--json"], { encoding: "utf8", env: rexCommandEnv(env), timeout: REX_CALL_TIMEOUT_MS, maxBuffer: REX_MAX_OUTPUT, windowsHide: true });
56
- if (result.error) throw new Error(`Could not ask Rex about this session: ${result.error.message}`, { cause: result.error });
57
- if (result.status === REX_EXIT_GONE) throw new Error(`Machine 'local' needs this Pi's Rex session, but the Rex server does not know session ${session}.`);
58
- if (result.status === REX_EXIT_UNREACHABLE) throw new Error("Machine 'local' needs the Rex server, but it is unreachable.");
59
- if (result.status !== 0) throw new Error(`rex session inspect exited with code ${result.status}: ${(result.stderr || result.stdout).trim().slice(0, 512)}`);
60
- if (!sessionConfirmed(result.stdout, session)) throw new Error(`The Rex server did not confirm session ${session}.`);
61
- const stepCwd = input.stepCwd?.trim();
62
- const home = stepCwd === "~" || stepCwd?.startsWith("~/") ? path.join(os.homedir(), stepCwd.slice(1)) : void 0;
63
- const requested = home ?? (stepCwd ? path.resolve(input.cwd, stepCwd) : input.cwd);
64
- let cwd;
65
- try {
66
- cwd = fs.realpathSync(requested);
67
- } catch (error) {
68
- throw new Error(`Machine 'local' cwd does not exist: ${requested}.`, { cause: error });
69
- }
70
- if (!fs.statSync(cwd).isDirectory()) throw new Error(`Machine 'local' cwd is not a directory: ${requested}.`);
71
- const machine = { provider: "rex", id: REX_LOCAL_MACHINE, session, cwd };
72
- if (server) machine.server = server;
73
- return machine;
74
- }
5
+ getProjectConfigDir,
6
+ resolveRexLocalPlacement
7
+ } from "./chunk-XAC2XNAP.js";
75
8
 
76
9
  // src/runs/shared/herdr-machine.ts
77
- import { spawnSync as spawnSync3 } from "node:child_process";
78
- import * as fs3 from "node:fs";
79
- import * as path3 from "node:path";
10
+ import { spawnSync as spawnSync2 } from "node:child_process";
11
+ import * as fs2 from "node:fs";
12
+ import * as path2 from "node:path";
80
13
 
81
14
  // src/runs/shared/herdr-connection.ts
82
- import { spawn, spawnSync as spawnSync2 } from "node:child_process";
83
- import * as fs2 from "node:fs";
15
+ import { spawn, spawnSync } from "node:child_process";
16
+ import * as fs from "node:fs";
84
17
  import * as net from "node:net";
85
- import * as os2 from "node:os";
86
- import * as path2 from "node:path";
18
+ import * as os from "node:os";
19
+ import * as path from "node:path";
87
20
  var MAX_DISCOVERY_BYTES = 256 * 1024;
88
21
  var MAX_RPC_BYTES = 4 * 1024 * 1024;
89
22
  var SUBSCRIPTION_ACK_TIMEOUT_MS = 15e3;
@@ -132,13 +65,13 @@ function sshEnvCommand(session, command) {
132
65
  return `/usr/bin/env -u HERDR_SOCKET_PATH -u HERDR_SESSION${assignment} ${remoteShellCommand(command)}`;
133
66
  }
134
67
  function runHerdrRemoteCommand(machine, command, options = {}) {
135
- return spawnSync2(options.sshBin ?? "ssh", [...herdrSshArgs(options.env), machine.target, command], { encoding: "utf8", env: hardenedSshEnv(options.env), timeout: options.timeout ?? 15e3, maxBuffer: options.maxBuffer ?? MAX_DISCOVERY_BYTES, windowsHide: true });
68
+ return spawnSync(options.sshBin ?? "ssh", [...herdrSshArgs(options.env), machine.target, command], { encoding: "utf8", env: hardenedSshEnv(options.env), timeout: options.timeout ?? 15e3, maxBuffer: options.maxBuffer ?? MAX_DISCOVERY_BYTES, windowsHide: true });
136
69
  }
137
70
  function runHerdrRemoteCommandAsync(machine, command, options = {}) {
138
71
  return runBoundedCommand(options.sshBin ?? "ssh", [...herdrSshArgs(options.env), machine.target, command], { env: hardenedSshEnv(options.env), timeout: options.timeout, maxBuffer: options.maxBuffer });
139
72
  }
140
73
  function runBoundedCommand(file, args, options) {
141
- return new Promise((resolve3) => {
74
+ return new Promise((resolve2) => {
142
75
  const child = spawn(file, args, { env: options.env, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
143
76
  const stdout = [], stderr = [], maxBuffer = options.maxBuffer ?? MAX_DISCOVERY_BYTES;
144
77
  let stdoutBytes = 0, stderrBytes = 0, error, settled = false, escalation;
@@ -147,7 +80,7 @@ function runBoundedCommand(file, args, options) {
147
80
  settled = true;
148
81
  clearTimeout(timer);
149
82
  if (escalation) clearTimeout(escalation);
150
- resolve3({ status, stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8"), ...spawnError ? { error: spawnError } : {} });
83
+ resolve2({ status, stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8"), ...spawnError ? { error: spawnError } : {} });
151
84
  };
152
85
  const terminate = () => {
153
86
  child.kill("SIGTERM");
@@ -183,7 +116,7 @@ function parseHerdrEndpoint(value, expectedSession) {
183
116
  }
184
117
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("Remote Herdr endpoint discovery returned no endpoint.");
185
118
  const p = parsed;
186
- if (typeof p.socket !== "string" || !path2.posix.isAbsolute(p.socket) || typeof p.version !== "string" || typeof p.protocol !== "number") throw new Error("Remote Herdr endpoint discovery returned incomplete identity.");
119
+ if (typeof p.socket !== "string" || !path.posix.isAbsolute(p.socket) || typeof p.version !== "string" || typeof p.protocol !== "number") throw new Error("Remote Herdr endpoint discovery returned incomplete identity.");
187
120
  const session = canonicalHerdrSession(typeof p.session === "string" ? p.session : null), expected = canonicalHerdrSession(expectedSession);
188
121
  if (expected !== session) throw new Error(`Remote Herdr session identity mismatch: expected ${expected ?? "default"}, received ${session ?? "default"}.`);
189
122
  if (p.running !== true || p.compatible !== true || p.endpoint_compatible === false) throw new Error("The selected remote Herdr session is stopped or incompatible.");
@@ -205,7 +138,7 @@ var SocketRpcClient = class {
205
138
  this.#subscriptionAckTimeoutMs = subscriptionAckTimeoutMs;
206
139
  }
207
140
  call(method, params = {}, timeoutMs = 15e3) {
208
- return new Promise((resolve3, reject) => {
141
+ return new Promise((resolve2, reject) => {
209
142
  const socket = net.createConnection(this.#socketPath);
210
143
  let bytes = 0;
211
144
  let data = Buffer.alloc(0);
@@ -218,7 +151,7 @@ var SocketRpcClient = class {
218
151
  finished = true;
219
152
  clearTimeout(timer);
220
153
  socket.destroy();
221
- error ? reject(error) : resolve3(value);
154
+ error ? reject(error) : resolve2(value);
222
155
  };
223
156
  socket.on("connect", () => socket.write(`${JSON.stringify({ id, method, params })}
224
157
  `));
@@ -255,8 +188,8 @@ var SocketRpcClient = class {
255
188
  const id = String(++this.#next);
256
189
  let buffer = Buffer.alloc(0), bytes = 0, acknowledged = false, intentional = false, notified = false, settled = false;
257
190
  let resolveAck, rejectAck;
258
- const acknowledgement = new Promise((resolve3, reject) => {
259
- resolveAck = resolve3;
191
+ const acknowledgement = new Promise((resolve2, reject) => {
192
+ resolveAck = resolve2;
260
193
  rejectAck = reject;
261
194
  });
262
195
  const failHandshake = (error) => {
@@ -343,19 +276,19 @@ async function waitForSocket(socketPath, child) {
343
276
  for (let attempt = 0; attempt < 100; attempt++) {
344
277
  if (child.exitCode !== null) throw new Error(`SSH StreamLocal forwarding exited with code ${child.exitCode}.`);
345
278
  try {
346
- const stat = fs2.lstatSync(socketPath);
279
+ const stat = fs.lstatSync(socketPath);
347
280
  if (stat.isSocket()) {
348
- fs2.chmodSync(socketPath, 384);
281
+ fs.chmodSync(socketPath, 384);
349
282
  return;
350
283
  }
351
284
  } catch {
352
285
  }
353
- await new Promise((resolve3) => setTimeout(resolve3, 25));
286
+ await new Promise((resolve2) => setTimeout(resolve2, 25));
354
287
  }
355
288
  throw new Error("SSH StreamLocal forwarding did not create its local socket.");
356
289
  }
357
290
  async function terminateChild(child) {
358
- const wait = (ms) => child.exitCode !== null || child.signalCode !== null ? Promise.resolve() : Promise.race([new Promise((resolve3) => child.once("exit", () => resolve3())), new Promise((resolve3) => setTimeout(resolve3, ms))]);
291
+ const wait = (ms) => child.exitCode !== null || child.signalCode !== null ? Promise.resolve() : Promise.race([new Promise((resolve2) => child.once("exit", () => resolve2())), new Promise((resolve2) => setTimeout(resolve2, ms))]);
359
292
  if (child.exitCode === null && child.signalCode === null) child.kill("SIGTERM");
360
293
  await wait(1e3);
361
294
  if (child.exitCode === null && child.signalCode === null) {
@@ -364,19 +297,19 @@ async function terminateChild(child) {
364
297
  }
365
298
  }
366
299
  function openSshSockets(machine, options) {
367
- const dir = fs2.mkdtempSync(path2.join(os2.tmpdir(), "pi-subagents-herdr-"));
368
- fs2.chmodSync(dir, 448);
300
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-herdr-"));
301
+ fs.chmodSync(dir, 448);
369
302
  const children = /* @__PURE__ */ new Set();
370
303
  const forward = async (remotePath, name) => {
371
- if (!path2.posix.isAbsolute(remotePath)) throw new Error("Remote socket path must be absolute.");
372
- const local = path2.join(dir, `${name}.sock`);
373
- const child = spawn(options.sshBin ?? "ssh", [...herdrSshArgs(options.env), "-N", "-o", "StreamLocalBindUnlink=yes", "-L", `${local}:${remotePath}`, machine.target], { env: hardenedSshEnv(options.env), stdio: "ignore", windowsHide: true });
304
+ if (!path.posix.isAbsolute(remotePath)) throw new Error("Remote socket path must be absolute.");
305
+ const local = path.join(dir, `${name}.sock`);
306
+ const child = spawn(options.sshBin ?? "ssh", [...herdrSshArgs(options.env), "-o", "StreamLocalBindUnlink=yes", "-L", `${local}:${remotePath}`, machine.target, remoteShellCommand("exec cat >/dev/null")], { env: hardenedSshEnv(options.env), stdio: ["pipe", "ignore", "ignore"], windowsHide: true });
374
307
  children.add(child);
375
308
  const stop = async () => {
376
309
  await terminateChild(child);
377
310
  children.delete(child);
378
311
  try {
379
- fs2.rmSync(local, { force: true });
312
+ fs.rmSync(local, { force: true });
380
313
  } catch {
381
314
  }
382
315
  };
@@ -391,7 +324,7 @@ function openSshSockets(machine, options) {
391
324
  return { forwardRemoteSocket: forward, close: async () => {
392
325
  await Promise.all([...children].map(terminateChild));
393
326
  children.clear();
394
- fs2.rmSync(dir, { recursive: true, force: true });
327
+ fs.rmSync(dir, { recursive: true, force: true });
395
328
  } };
396
329
  }
397
330
  function sshMachineAccess(machine, options = {}) {
@@ -460,7 +393,7 @@ function parseMachineCatalog(json) {
460
393
  });
461
394
  }
462
395
  function readHerdrMachineCatalog(env, herdrBin) {
463
- const result = spawnSync3(herdrBin, ["machine", "list", "--json"], {
396
+ const result = spawnSync2(herdrBin, ["machine", "list", "--json"], {
464
397
  env,
465
398
  encoding: "utf-8",
466
399
  maxBuffer: MAX_HERDR_MACHINE_LIST_BYTES,
@@ -488,10 +421,10 @@ function selectMachine(catalog, requested) {
488
421
  return machine;
489
422
  }
490
423
  function readJsonObject(filePath) {
491
- if (!fs3.existsSync(filePath)) return {};
424
+ if (!fs2.existsSync(filePath)) return {};
492
425
  let parsed;
493
426
  try {
494
- parsed = JSON.parse(fs3.readFileSync(filePath, "utf-8"));
427
+ parsed = JSON.parse(fs2.readFileSync(filePath, "utf-8"));
495
428
  } catch (error) {
496
429
  throw new Error(`Failed to read settings file '${filePath}': ${error instanceof Error ? error.message : String(error)}`);
497
430
  }
@@ -530,8 +463,8 @@ function machineSettingsFrom(settings, keys, filePath) {
530
463
  return entry;
531
464
  }
532
465
  function readMachineSettings(cwd, keys) {
533
- const userPath = path3.join(getAgentDir(), "settings.json");
534
- const projectPath = path3.join(getProjectConfigDir(findProjectRootForSettings(cwd)), "settings.json");
466
+ const userPath = path2.join(getAgentDir(), "settings.json");
467
+ const projectPath = path2.join(getProjectConfigDir(findProjectRootForSettings(cwd)), "settings.json");
535
468
  const user = machineSettingsFrom(readJsonObject(userPath), keys, userPath);
536
469
  const project = projectPath === userPath ? void 0 : machineSettingsFrom(readJsonObject(projectPath), keys, projectPath);
537
470
  if (project?.rex) throw new Error(`Project settings '${projectPath}' set a Rex SSH host in 'machines'. Move the rex entry to your user settings '${userPath}'; only user settings choose which host a task runs on.`);
@@ -539,15 +472,15 @@ function readMachineSettings(cwd, keys) {
539
472
  return { ...user, ...project };
540
473
  }
541
474
  function userRexMachine(machine) {
542
- const userPath = path3.join(getAgentDir(), "settings.json");
475
+ const userPath = path2.join(getAgentDir(), "settings.json");
543
476
  return machineSettingsFrom(readJsonObject(userPath), [machine], userPath)?.rex !== void 0;
544
477
  }
545
478
  function findProjectRootForSettings(cwd) {
546
- let current = path3.resolve(cwd);
479
+ let current = path2.resolve(cwd);
547
480
  while (true) {
548
- if (fs3.existsSync(path3.join(getProjectConfigDir(current), "settings.json"))) return current;
549
- const parent = path3.dirname(current);
550
- if (parent === current) return path3.resolve(cwd);
481
+ if (fs2.existsSync(path2.join(getProjectConfigDir(current), "settings.json"))) return current;
482
+ const parent = path2.dirname(current);
483
+ if (parent === current) return path2.resolve(cwd);
551
484
  current = parent;
552
485
  }
553
486
  }
@@ -555,7 +488,7 @@ function remoteMachineCwd(stepCwd, root, name) {
555
488
  const step = stepCwd?.trim();
556
489
  if (step && isRemoteAbsolute(step)) return step;
557
490
  if (!root) throw new Error(`No root for ${name} in this repo. Set subagents.machines.${name}.cwd in .pi/settings.json or pass an absolute cwd on that machine.`);
558
- return step ? path3.posix.join(root, step) : root;
491
+ return step ? path2.posix.join(root, step) : root;
559
492
  }
560
493
  function resolveHerdrMachinePlacement(input) {
561
494
  const requested = validateMachineName(input.machine);
@@ -622,15 +555,6 @@ export {
622
555
  runBoundedCommand,
623
556
  sshMachineAccess,
624
557
  connectHerdrMachine,
625
- REX_EXIT_GONE,
626
- REX_EXIT_UNREACHABLE,
627
- isRexLocalMachine,
628
- REX_BUNDLE_BIN,
629
- REX_CALL_TIMEOUT_MS,
630
- REX_MAX_OUTPUT,
631
- rexGlobalArgs,
632
- resolveRexBinary,
633
- rexCommandEnv,
634
558
  resolveMachinePlacement,
635
559
  PLACED_RESTORE_UNSUPPORTED,
636
560
  formatHerdrMachineRunnerUnsupported