@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.0f07274d438b

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 (329) hide show
  1. package/README.md +183 -4
  2. package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
  3. package/dist/bridge/bridge-chat-giphy-look.js +55 -0
  4. package/dist/bridge/bridge-chat-provider-command.d.ts +40 -0
  5. package/dist/bridge/bridge-chat-provider-command.js +230 -0
  6. package/dist/bridge/bridge-chat.types.d.ts +20 -0
  7. package/dist/bridge/bridge-chat.types.js +28 -1
  8. package/dist/bridge/bridge-state-file.d.ts +161 -0
  9. package/dist/bridge/bridge-state-file.js +376 -0
  10. package/dist/bridge/bridge-state-io.d.ts +15 -0
  11. package/dist/bridge/bridge-state-io.js +68 -0
  12. package/dist/bridge/bridge-state-lock.d.ts +11 -0
  13. package/dist/bridge/bridge-state-lock.js +102 -0
  14. package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
  15. package/dist/bridge/bridge-state-unpublished.js +111 -0
  16. package/dist/bridge/bridge.base.d.ts +9 -0
  17. package/dist/bridge/bridge.service.d.ts +102 -14
  18. package/dist/bridge/bridge.service.js +499 -471
  19. package/dist/bridge/bridge.types.d.ts +37 -0
  20. package/dist/bridge/bridge.types.js +2 -1
  21. package/dist/bridge/default-session-service.d.ts +13 -0
  22. package/dist/bridge/default-session-service.js +22 -0
  23. package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
  24. package/dist/bridge/dispatch-offer-policy.js +58 -0
  25. package/dist/bridge/in-flight-registry.d.ts +62 -0
  26. package/dist/bridge/in-flight-registry.js +207 -0
  27. package/dist/bridge/local-yield-flag.d.ts +6 -0
  28. package/dist/bridge/local-yield-flag.js +34 -0
  29. package/dist/bridge/readiness-result-outbox.d.ts +5 -1
  30. package/dist/bridge/readiness-result-outbox.js +20 -0
  31. package/dist/bridge/runner-host-capabilities.d.ts +5 -0
  32. package/dist/bridge/runner-host-capabilities.js +31 -1
  33. package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
  34. package/dist/bridge/sandbox-resource-accounting.js +150 -0
  35. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  36. package/dist/bridge/test-postgres-capability.js +120 -0
  37. package/dist/bridge/windows-bash-resolution.d.ts +31 -0
  38. package/dist/bridge/windows-bash-resolution.js +153 -0
  39. package/dist/cleanup/cleanup-wip.d.ts +12 -0
  40. package/dist/cleanup/cleanup-wip.js +66 -0
  41. package/dist/cleanup/cleanup.service.d.ts +20 -1
  42. package/dist/cleanup/cleanup.service.js +150 -169
  43. package/dist/cleanup/cleanup.types.d.ts +6 -0
  44. package/dist/cleanup/forge-owned-paths.d.ts +11 -0
  45. package/dist/cleanup/forge-owned-paths.js +62 -0
  46. package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
  47. package/dist/cleanup/host-runtime-ledger.js +130 -0
  48. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  49. package/dist/cleanup/managed-branch-sweep.js +111 -0
  50. package/dist/cli/cli.help.js +75 -13
  51. package/dist/cli/cli.service.d.ts +19 -10
  52. package/dist/cli/cli.service.js +161 -228
  53. package/dist/cli/idle-status.d.ts +84 -0
  54. package/dist/cli/idle-status.js +181 -0
  55. package/dist/cli/local-config.d.ts +18 -1
  56. package/dist/cli/local-config.js +67 -5
  57. package/dist/cli/provider-cli-advertising.d.ts +24 -0
  58. package/dist/cli/provider-cli-advertising.js +88 -0
  59. package/dist/cli/provider-cli-detection.d.ts +10 -0
  60. package/dist/cli/provider-cli-detection.js +160 -0
  61. package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
  62. package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
  63. package/dist/runtime/attempt-database-broker.d.ts +1 -1
  64. package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
  65. package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
  66. package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
  67. package/dist/runtime/attempt-process-supervisor.js +12 -6
  68. package/dist/runtime/docker-engine-probe.d.ts +5 -0
  69. package/dist/runtime/docker-engine-probe.js +7 -0
  70. package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
  71. package/dist/runtime/dotnet-build-outputs.js +402 -0
  72. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  73. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  74. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  75. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  76. package/dist/runtime/host-facts.d.ts +2 -1
  77. package/dist/runtime/host-listener-inspector.d.ts +26 -0
  78. package/dist/runtime/host-listener-inspector.js +84 -3
  79. package/dist/runtime/host-load-admission.d.ts +72 -0
  80. package/dist/runtime/host-load-admission.js +99 -0
  81. package/dist/runtime/host-load-capacity.d.ts +198 -0
  82. package/dist/runtime/host-load-capacity.js +353 -0
  83. package/dist/runtime/host-load-child-environment.d.ts +40 -0
  84. package/dist/runtime/host-load-child-environment.js +110 -0
  85. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  86. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  87. package/dist/runtime/host-load-governor-config.d.ts +82 -0
  88. package/dist/runtime/host-load-governor-config.js +104 -0
  89. package/dist/runtime/host-load-governor.d.ts +273 -0
  90. package/dist/runtime/host-load-governor.js +831 -0
  91. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  92. package/dist/runtime/host-load-ledger-lock.js +187 -0
  93. package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
  94. package/dist/runtime/host-load-live-test-slots.js +193 -0
  95. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  96. package/dist/runtime/host-load-runtime-settings.js +80 -0
  97. package/dist/runtime/host-load-sampler.d.ts +92 -2
  98. package/dist/runtime/host-load-sampler.js +166 -8
  99. package/dist/runtime/host-load-step-class.d.ts +70 -0
  100. package/dist/runtime/host-load-step-class.js +161 -0
  101. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  102. package/dist/runtime/host-load-step-reaper.js +95 -0
  103. package/dist/runtime/host-load-step-run.d.ts +107 -0
  104. package/dist/runtime/host-load-step-run.js +158 -0
  105. package/dist/runtime/host-load-test-slot.d.ts +46 -0
  106. package/dist/runtime/host-load-test-slot.js +100 -0
  107. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  108. package/dist/runtime/host-load-token-ledger.js +453 -0
  109. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  110. package/dist/runtime/host-load-windows-cpu.js +85 -0
  111. package/dist/runtime/host-pressure-stall.d.ts +21 -1
  112. package/dist/runtime/host-pressure-stall.js +48 -1
  113. package/dist/runtime/host-runtime-contract.d.ts +15 -0
  114. package/dist/runtime/host-runtime-contract.js +39 -6
  115. package/dist/runtime/host-runtime-lease.d.ts +101 -6
  116. package/dist/runtime/host-runtime-lease.js +408 -294
  117. package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
  118. package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
  119. package/dist/runtime/host-runtime-promotion.d.ts +101 -2
  120. package/dist/runtime/host-runtime-promotion.js +355 -14
  121. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  122. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  123. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  124. package/dist/runtime/host-runtime-requirements.js +117 -0
  125. package/dist/runtime/managed-command-teardown.js +5 -16
  126. package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
  127. package/dist/runtime/native-test-postgres-fallback.js +60 -8
  128. package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
  129. package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
  130. package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
  131. package/dist/runtime/prepared-runtime-identity.js +130 -9
  132. package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
  133. package/dist/runtime/prepared-runtime-readiness.js +89 -18
  134. package/dist/runtime/runner-settings.d.ts +104 -0
  135. package/dist/runtime/runner-settings.js +236 -0
  136. package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
  137. package/dist/runtime/supervised-runtime-build-guard.js +112 -0
  138. package/dist/sandbox/host-capacity-broker.d.ts +115 -0
  139. package/dist/sandbox/host-capacity-broker.js +336 -0
  140. package/dist/sandbox/managed-branch.d.ts +13 -0
  141. package/dist/sandbox/managed-branch.js +90 -0
  142. package/dist/sandbox/provider-auth/codex.js +11 -11
  143. package/dist/sandbox/runtime.d.ts +11 -3
  144. package/dist/sandbox/runtime.js +53 -20
  145. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  146. package/dist/sandbox/sandbox-cgroups.js +42 -0
  147. package/dist/sandbox/sandbox-input.d.ts +22 -0
  148. package/dist/sandbox/sandbox-input.js +49 -0
  149. package/dist/sandbox/workspace.service.js +15 -2
  150. package/dist/session/architect-waits.d.ts +2 -0
  151. package/dist/session/architect-waits.js +138 -0
  152. package/dist/session/managed-attempt-tools.d.ts +2 -7
  153. package/dist/session/managed-attempt-tools.js +204 -141
  154. package/dist/session/managed-build-coordinator.d.ts +16 -0
  155. package/dist/session/managed-build-coordinator.js +10 -0
  156. package/dist/session/managed-build-receipt.d.ts +7 -0
  157. package/dist/session/managed-build-receipt.js +11 -3
  158. package/dist/session/managed-command-environment.d.ts +8 -0
  159. package/dist/session/managed-command-environment.js +28 -0
  160. package/dist/session/managed-command-host-load.d.ts +52 -0
  161. package/dist/session/managed-command-host-load.js +87 -0
  162. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  163. package/dist/session/mcp-argument-coercion.js +121 -0
  164. package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
  165. package/dist/session/phase-completion.artifact-bundle.js +167 -0
  166. package/dist/session/phase-completion.artifacts.d.ts +9 -17
  167. package/dist/session/phase-completion.artifacts.js +158 -190
  168. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  169. package/dist/session/phase-completion.command-validation.js +77 -0
  170. package/dist/session/phase-completion.d.ts +31 -2
  171. package/dist/session/phase-completion.helpers.js +18 -65
  172. package/dist/session/phase-completion.js +19 -32
  173. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  174. package/dist/session/phase-completion.mcp-args.js +195 -0
  175. package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
  176. package/dist/session/phase-completion.phase-aliases.js +43 -0
  177. package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
  178. package/dist/session/phase-completion.pr-review-schema.js +75 -0
  179. package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
  180. package/dist/session/phase-completion.pr-review-validation.js +212 -0
  181. package/dist/session/phase-completion.pr-review.d.ts +36 -0
  182. package/dist/session/phase-completion.pr-review.js +294 -0
  183. package/dist/session/phase-completion.prompts.d.ts +1 -1
  184. package/dist/session/phase-completion.prompts.js +20 -1
  185. package/dist/session/phase-completion.runtime.d.ts +13 -12
  186. package/dist/session/phase-completion.runtime.js +113 -214
  187. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  188. package/dist/session/phase-completion.schema-parts.js +188 -0
  189. package/dist/session/phase-completion.schemas.d.ts +3 -3
  190. package/dist/session/phase-completion.schemas.js +219 -232
  191. package/dist/session/phase-completion.validation.d.ts +3 -3
  192. package/dist/session/phase-completion.validation.js +58 -94
  193. package/dist/session/pr-review-diff-base.d.ts +18 -0
  194. package/dist/session/pr-review-diff-base.js +44 -0
  195. package/dist/session/pr-review-placement.d.ts +50 -0
  196. package/dist/session/pr-review-placement.js +91 -0
  197. package/dist/session/pre-publication-change-set.d.ts +62 -0
  198. package/dist/session/pre-publication-change-set.js +166 -0
  199. package/dist/session/pre-publication-host-load.d.ts +27 -0
  200. package/dist/session/pre-publication-host-load.js +112 -0
  201. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  202. package/dist/session/pre-publication-native-postgres.js +111 -0
  203. package/dist/session/pre-publication-pass.d.ts +61 -0
  204. package/dist/session/pre-publication-pass.js +148 -0
  205. package/dist/session/pre-publication-process.d.ts +3 -0
  206. package/dist/session/pre-publication-process.js +32 -19
  207. package/dist/session/pre-publication-step-execution.d.ts +12 -0
  208. package/dist/session/pre-publication-step-execution.js +50 -0
  209. package/dist/session/pre-publication-validation.d.ts +39 -22
  210. package/dist/session/pre-publication-validation.js +241 -207
  211. package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
  212. package/dist/session/provider-cli/claude-background-work.js +181 -0
  213. package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
  214. package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
  215. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  216. package/dist/session/provider-cli/host-build-lock.js +30 -0
  217. package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
  218. package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
  219. package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
  220. package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
  221. package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
  222. package/dist/session/provider-cli/pr-review-prompt.js +119 -0
  223. package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
  224. package/dist/session/provider-cli/pre-publication-repair.js +281 -0
  225. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  226. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  227. package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
  228. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  229. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  230. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
  231. package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
  232. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
  233. package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
  234. package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
  235. package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
  236. package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
  237. package/dist/session/provider-cli/provider-cli.process.js +41 -432
  238. package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -3
  239. package/dist/session/provider-cli/provider-cli.prompts.js +183 -90
  240. package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
  241. package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
  242. package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
  243. package/dist/session/provider-cli/provider-cli.runtime.js +43 -1
  244. package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
  245. package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
  246. package/dist/session/provider-cli/provider-cli.service.d.ts +18 -18
  247. package/dist/session/provider-cli/provider-cli.service.js +127 -317
  248. package/dist/session/provider-cli/provider-cli.types.d.ts +35 -0
  249. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  250. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  251. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  252. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  253. package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
  254. package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
  255. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  256. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  257. package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
  258. package/dist/session/provider-cli/provider-output-state.js +6 -0
  259. package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
  260. package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
  261. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  262. package/dist/session/qa-sidecar-validation.js +28 -0
  263. package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
  264. package/dist/session/sandbox-host-capacity-gate.js +279 -0
  265. package/dist/session/session-host-project.d.ts +22 -0
  266. package/dist/session/session-host-project.js +98 -0
  267. package/dist/session/session-redaction.js +31 -181
  268. package/dist/session/session.base.d.ts +9 -1
  269. package/dist/session/session.parse-helpers.d.ts +10 -0
  270. package/dist/session/session.parse-helpers.js +84 -0
  271. package/dist/session/session.runtime-refresh.d.ts +46 -0
  272. package/dist/session/session.runtime-refresh.js +116 -0
  273. package/dist/session/session.service.d.ts +16 -2
  274. package/dist/session/session.service.js +208 -155
  275. package/dist/session/session.types.d.ts +8 -0
  276. package/dist/session/session.types.js +13 -83
  277. package/dist/session/session.types.pr-review.d.ts +48 -0
  278. package/dist/session/session.types.pr-review.js +51 -0
  279. package/dist/session/sidecar-json-shape.d.ts +31 -0
  280. package/dist/session/sidecar-json-shape.js +217 -0
  281. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  282. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  283. package/dist/shared/fs/file-identity.d.ts +10 -0
  284. package/dist/shared/fs/file-identity.js +15 -0
  285. package/dist/shared/fs/replace-file.d.ts +7 -0
  286. package/dist/shared/fs/replace-file.js +33 -0
  287. package/dist/shared/process/host-process-recovery.d.ts +14 -3
  288. package/dist/shared/process/host-process-recovery.js +23 -3
  289. package/dist/shared/process/host-process-supervisor.d.ts +14 -1
  290. package/dist/shared/process/host-process-supervisor.js +67 -15
  291. package/dist/shared/process/process-tree.d.ts +52 -0
  292. package/dist/shared/process/process-tree.js +144 -0
  293. package/dist/shared/process/process.d.ts +67 -0
  294. package/dist/shared/process/process.js +213 -11
  295. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  296. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  297. package/dist/shared/process/windows-launch.d.ts +18 -0
  298. package/dist/shared/process/windows-launch.js +68 -0
  299. package/dist/shared/provider-capabilities.d.ts +2 -0
  300. package/dist/shared/provider-capabilities.js +23 -7
  301. package/dist/version.d.ts +1 -1
  302. package/dist/version.js +1 -1
  303. package/dist/worktree/artifact-injector.js +24 -0
  304. package/dist/worktree/dependency-warmer.d.ts +25 -0
  305. package/dist/worktree/dependency-warmer.js +46 -10
  306. package/dist/worktree/orphan-relink.d.ts +19 -0
  307. package/dist/worktree/orphan-relink.js +106 -0
  308. package/dist/worktree/wip-git.d.ts +58 -0
  309. package/dist/worktree/wip-git.js +182 -0
  310. package/dist/worktree/wip-refs.d.ts +85 -0
  311. package/dist/worktree/wip-refs.js +169 -0
  312. package/dist/worktree/wip-restore.d.ts +51 -0
  313. package/dist/worktree/wip-restore.js +324 -0
  314. package/dist/worktree/wip-snapshot.d.ts +53 -0
  315. package/dist/worktree/wip-snapshot.js +270 -0
  316. package/dist/worktree/worktree-inputs.d.ts +8 -0
  317. package/dist/worktree/worktree-inputs.js +134 -0
  318. package/dist/worktree/worktree-origin-sync.d.ts +35 -0
  319. package/dist/worktree/worktree-origin-sync.js +128 -0
  320. package/dist/worktree/worktree-wip-events.d.ts +20 -0
  321. package/dist/worktree/worktree-wip-events.js +148 -0
  322. package/dist/worktree/worktree-wip.d.ts +57 -0
  323. package/dist/worktree/worktree-wip.js +200 -0
  324. package/dist/worktree/worktree.base.d.ts +7 -1
  325. package/dist/worktree/worktree.service.d.ts +58 -5
  326. package/dist/worktree/worktree.service.js +237 -161
  327. package/dist/worktree/worktree.types.d.ts +54 -0
  328. package/package.json +2 -2
  329. package/runtime/windows-listener-owner.ps1 +12 -1
@@ -1,17 +1,17 @@
1
- import { execFile, execFileSync, spawn } from "node:child_process";
2
- import { randomUUID } from "node:crypto";
1
+ import { execFileSync, spawn } from "node:child_process";
3
2
  import fs from "node:fs";
4
- import os from "node:os";
5
3
  import path from "node:path";
6
- import readline from "node:readline";
7
- import { promisify } from "node:util";
8
- import { resolveCursorAgentDirectLaunch } from "../../shared/cursor-agent/cursor-agent.launch.js";
9
4
  import { persistHostProcessSupervisorMetadata, resolveHostProcessSupervisedLaunch, terminateHostProcessTree, } from "../../shared/process/host-process-supervisor.js";
10
- import { buildWindowsLaunchCommand } from "../../shared/process/windows-launch.js";
5
+ import { buildProviderChildEnvironment } from "./provider-cli.child-environment.js";
6
+ import { resolveWindowsProviderLaunch } from "./provider-cli.windows-launch.js";
7
+ import { isCodexModelsCacheSchemaFailure, quarantineIncompatibleCodexModelsCache } from "./provider-cli.codex-models-cache.js";
11
8
  import { assertHostDatabaseCapabilityBoundary } from "../../runtime/host-database-capability-boundary.js";
12
9
  import { ForgeFailureError } from "../session.types.js";
13
- import { hasNonterminalManagedCommand } from "./provider-in-flight-work.js";
14
- const execFileAsync = promisify(execFile);
10
+ import { BackgroundWorkStopFailingRunner, ClaudeBackgroundTurnEndWatch, providerTurnEndedWithBackgroundWorkFailure } from "./claude-background-work.js";
11
+ import { hasNonterminalManagedCommand, isProviderTerminalFailure, isProviderTerminalSuccess, isProviderTurnActivity } from "./provider-in-flight-work.js";
12
+ import { OutputPipeRelease, readProcessLines, PROVIDER_OUTPUT_PIPE_RELEASE_GRACE_MS } from "./provider-output-pipes.js";
13
+ export { chooseWindowsCommandCandidate, resolveWindowsCommandFromPath } from "../../shared/process/windows-launch.js";
14
+ export { buildProviderChildEnvironment } from "./provider-cli.child-environment.js";
15
15
  // Provider processes can emit many gigabytes over a long-running session. The
16
16
  // line handlers stream that output to Forge as it arrives; the completed result
17
17
  // only needs a bounded diagnostic tail for failure classification.
@@ -23,11 +23,12 @@ const PROVIDER_TERMINAL_EXIT_GRACE_MS = 15_000;
23
23
  const PROVIDER_TERMINAL_SUCCESS_CEILING_MS = 10 * 60_000;
24
24
  // How often the end-of-turn timers re-check whether supervised work is still in flight.
25
25
  const PROVIDER_TERMINAL_WORK_POLL_MS = 1_000;
26
- const maximumRecoverableCodexModelsCacheBytes = 16 * 1024 * 1024;
26
+ export { resolveClaudeNpmDirectLaunch, resolveCodexNpmDirectLaunch, resolvePackageManagerDirectLaunch } from "./provider-cli.windows-launch.js";
27
27
  /** Recovery must wrap the attempt coordinator, never its raw OS runner. Each
28
- * relaunch needs a new fenced child generation and exclusive launch files. */
28
+ * relaunch needs a new fenced child generation and exclusive launch files. The outer
29
+ * layer fails any run Forge stopped because its turn ended with background work live. */
29
30
  export function recoveringProviderProcessRunner(inner) {
30
- return new CodexResumeRecoveringProcessRunner(new CodexModelsCacheRecoveringProcessRunner(inner));
31
+ return new BackgroundWorkStopFailingRunner(new CodexResumeRecoveringProcessRunner(new CodexModelsCacheRecoveringProcessRunner(inner)));
31
32
  }
32
33
  /**
33
34
  * Codex Desktop and an independently installed Codex CLI can briefly disagree
@@ -121,216 +122,16 @@ function codexFreshTurnRequest(request) {
121
122
  function isCodexCommand(command) {
122
123
  return path.parse(command).name.toLowerCase() === "codex";
123
124
  }
124
- function isCodexModelsCacheSchemaFailure(result) {
125
- const output = `${result.stderr}\n${result.stdout}`.toLowerCase();
126
- return output.includes("base_instructions")
127
- && output.includes("missing field")
128
- && (output.includes("models_cache") || output.includes("models cache") || output.includes("model cache"));
129
- }
130
- async function quarantineIncompatibleCodexModelsCache(requestEnv) {
131
- const configuredHome = readEnvironmentValue(requestEnv ?? {}, "CODEX_HOME")
132
- ?? readEnvironmentValue(process.env, "CODEX_HOME")
133
- ?? readEnvironmentValue(process.env, "FORGE_CODEX_HOME");
134
- const codexHome = path.resolve(configuredHome ?? path.join(os.homedir(), ".codex"));
135
- if (!path.isAbsolute(codexHome) || codexHome === path.parse(codexHome).root)
136
- return false;
137
- const cachePath = path.join(codexHome, "models_cache.json");
138
- const cacheStat = await fs.promises.lstat(cachePath).catch(error => {
139
- if (error.code === "ENOENT")
140
- return null;
141
- throw error;
142
- });
143
- if (!cacheStat
144
- || !cacheStat.isFile()
145
- || cacheStat.isSymbolicLink()
146
- || cacheStat.nlink !== 1
147
- || cacheStat.size <= 0
148
- || cacheStat.size > maximumRecoverableCodexModelsCacheBytes) {
149
- return false;
150
- }
151
- const quarantinePath = path.join(codexHome, `models_cache.forge-incompatible-${Date.now()}-${randomUUID()}.json`);
152
- await fs.promises.rename(cachePath, quarantinePath);
153
- return true;
154
- }
155
- const allowedProviderParentEnvNames = [
156
- "PATH",
157
- "HOME",
158
- "USERPROFILE",
159
- "TMPDIR",
160
- "TEMP",
161
- "TMP",
162
- "LANG",
163
- "CLAUDE_CONFIG_DIR"
164
- ];
165
- const windowsAllowedProviderParentEnvNames = [
166
- "SystemRoot",
167
- "SystemDrive",
168
- "ComSpec",
169
- "PATHEXT",
170
- "APPDATA",
171
- "LOCALAPPDATA",
172
- "USERNAME",
173
- "USERDOMAIN",
174
- "HOMEDRIVE",
175
- "HOMEPATH",
176
- "ProgramData",
177
- "ProgramFiles",
178
- "ProgramFiles(x86)",
179
- "ProgramW6432",
180
- "DOTNET_ROOT",
181
- "DOTNET_ROOT(x86)",
182
- "DOTNET_CLI_HOME",
183
- "NUGET_PACKAGES",
184
- "NUGET_HTTP_CACHE_PATH",
185
- "CLAUDE_CODE_GIT_BASH_PATH"
186
- ];
187
- export function buildProviderChildEnvironment(requestEnv, options = {}) {
188
- const parentEnv = options.parentEnv ?? process.env;
189
- const platform = options.platform ?? process.platform;
190
- const env = {};
191
- for (const [key, value] of Object.entries(parentEnv)) {
192
- if (typeof value === "string" && isAllowedProviderParentEnv(key, platform)) {
193
- env[key] = value;
194
- }
195
- }
196
- if (requestEnv) {
197
- for (const [key, value] of Object.entries(requestEnv)) {
198
- const trimmedKey = key.trim();
199
- if (trimmedKey.length > 0) {
200
- env[trimmedKey] = value;
201
- }
202
- }
203
- }
204
- if (platform === "win32") {
205
- normalizeWindowsDotNetEnvironment(env, parentEnv, options.homeDir ?? os.homedir());
206
- }
207
- normalizeProviderBuildEnvironment(env);
208
- return env;
209
- }
210
- function normalizeProviderBuildEnvironment(env) {
211
- // Provider sessions are long lived and commonly run many dotnet builds. Persistent
212
- // MSBuild and Roslyn compiler servers otherwise survive individual commands and can
213
- // retain more memory than the active Forge lane. Keep those caches process-scoped by
214
- // default on every runner OS; an explicitly supplied request value still wins.
215
- setCanonicalProviderBuildEnvironmentValue(env, "DOTNET_CLI_USE_MSBUILD_SERVER", "0");
216
- setCanonicalProviderBuildEnvironmentValue(env, "MSBUILDDISABLENODEREUSE", "1");
217
- setCanonicalProviderBuildEnvironmentValue(env, "UseSharedCompilation", "false");
218
- }
219
- function setCanonicalProviderBuildEnvironmentValue(env, name, value) {
220
- // The dotnet CLI uses case-sensitive environment lookup on POSIX, while MSBuild
221
- // property names are case-insensitive on every OS. Collapse request aliases to
222
- // one canonical key so the explicit value wins without producing ambiguity.
223
- const exact = env[name];
224
- const alias = Object.entries(env).find(([key, candidate]) => key !== name
225
- && key.toLowerCase() === name.toLowerCase()
226
- && typeof candidate === "string"
227
- && candidate.trim().length > 0)?.[1];
228
- const resolved = typeof exact === "string" && exact.trim().length > 0
229
- ? exact
230
- : alias ?? value;
231
- for (const key of Object.keys(env)) {
232
- if (key !== name && key.toLowerCase() === name.toLowerCase()) {
233
- delete env[key];
234
- }
235
- }
236
- env[name] = resolved;
237
- }
238
- function isAllowedProviderParentEnv(key, platform = process.platform) {
239
- return isAllowedProviderParentEnvName(key, allowedProviderParentEnvNames)
240
- || key.toUpperCase().startsWith("LC_")
241
- || (platform === "win32" && isAllowedProviderParentEnvName(key, windowsAllowedProviderParentEnvNames));
242
- }
243
- function isAllowedProviderParentEnvName(key, allowedNames) {
244
- return allowedNames.some((allowed) => allowed.toLowerCase() === key.toLowerCase());
245
- }
246
- function normalizeWindowsDotNetEnvironment(env, parentEnv, homeDir) {
247
- const systemRoot = readEnvironmentValue(env, "SystemRoot") ?? readEnvironmentValue(parentEnv, "SystemRoot") ?? "C:\\Windows";
248
- const systemDrive = path.win32.parse(systemRoot).root.replace(/\\$/, "") || "C:";
249
- setEnvironmentValueIfMissing(env, "SystemRoot", systemRoot);
250
- setEnvironmentValueIfMissing(env, "SystemDrive", readEnvironmentValue(parentEnv, "SystemDrive") ?? systemDrive);
251
- setEnvironmentValueIfMissing(env, "ComSpec", readEnvironmentValue(parentEnv, "ComSpec") ?? path.win32.join(systemRoot, "System32", "cmd.exe"));
252
- setEnvironmentValueIfMissing(env, "PATHEXT", readEnvironmentValue(parentEnv, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL");
253
- const resolvedSystemDrive = readEnvironmentValue(env, "SystemDrive") ?? systemDrive;
254
- const defaultProgramFiles = path.win32.join(`${resolvedSystemDrive}\\`, "Program Files");
255
- const defaultProgramFilesX86 = path.win32.join(`${resolvedSystemDrive}\\`, "Program Files (x86)");
256
- const defaultProgramData = path.win32.join(`${resolvedSystemDrive}\\`, "ProgramData");
257
- const programFiles = readEnvironmentValue(env, "ProgramFiles")
258
- ?? readEnvironmentValue(parentEnv, "ProgramFiles")
259
- ?? defaultProgramFiles;
260
- setEnvironmentValueIfMissing(env, "ProgramFiles", programFiles);
261
- setEnvironmentValueIfMissing(env, "ProgramW6432", readEnvironmentValue(parentEnv, "ProgramW6432") ?? defaultProgramFiles);
262
- setEnvironmentValueIfMissing(env, "ProgramFiles(x86)", readEnvironmentValue(parentEnv, "ProgramFiles(x86)") ?? defaultProgramFilesX86);
263
- setEnvironmentValueIfMissing(env, "ProgramData", readEnvironmentValue(parentEnv, "ProgramData") ?? defaultProgramData);
264
- const userProfile = resolveWindowsUserProfile(env, parentEnv, homeDir);
265
- if (userProfile) {
266
- setEnvironmentValueIfMissing(env, "USERPROFILE", userProfile);
267
- setEnvironmentValueIfMissing(env, "HOME", userProfile);
268
- setEnvironmentValueIfMissing(env, "DOTNET_CLI_HOME", userProfile);
269
- setEnvironmentValueIfMissing(env, "NUGET_PACKAGES", path.win32.join(userProfile, ".nuget", "packages"));
270
- const parsed = path.win32.parse(userProfile);
271
- if (parsed.root) {
272
- setEnvironmentValueIfMissing(env, "HOMEDRIVE", parsed.root.replace(/\\$/, ""));
273
- setEnvironmentValueIfMissing(env, "HOMEPATH", userProfile.slice(parsed.root.length - (parsed.root.endsWith("\\") ? 1 : 0)) || "\\");
274
- }
275
- }
276
- const appData = readEnvironmentValue(env, "APPDATA")
277
- ?? readEnvironmentValue(parentEnv, "APPDATA")
278
- ?? (userProfile ? path.win32.join(userProfile, "AppData", "Roaming") : undefined);
279
- const localAppData = readEnvironmentValue(env, "LOCALAPPDATA")
280
- ?? readEnvironmentValue(parentEnv, "LOCALAPPDATA")
281
- ?? (userProfile ? path.win32.join(userProfile, "AppData", "Local") : undefined);
282
- if (appData) {
283
- setEnvironmentValueIfMissing(env, "APPDATA", appData);
284
- }
285
- if (localAppData) {
286
- setEnvironmentValueIfMissing(env, "LOCALAPPDATA", localAppData);
287
- setEnvironmentValueIfMissing(env, "NUGET_HTTP_CACHE_PATH", path.win32.join(localAppData, "NuGet", "v3-cache"));
288
- }
289
- setEnvironmentValueIfMissing(env, "DOTNET_NOLOGO", "1");
290
- setEnvironmentValueIfMissing(env, "DOTNET_CLI_TELEMETRY_OPTOUT", "1");
291
- setEnvironmentValueIfMissing(env, "DOTNET_SKIP_FIRST_TIME_EXPERIENCE", "1");
292
- setEnvironmentValueIfMissing(env, "NUGET_XMLDOC_MODE", "skip");
293
- }
294
- function resolveWindowsUserProfile(env, parentEnv, homeDir) {
295
- const existing = readEnvironmentValue(env, "USERPROFILE") ?? readEnvironmentValue(parentEnv, "USERPROFILE");
296
- if (existing) {
297
- return existing;
298
- }
299
- const home = readEnvironmentValue(env, "HOME") ?? readEnvironmentValue(parentEnv, "HOME");
300
- if (home && path.win32.isAbsolute(home)) {
301
- return home;
302
- }
303
- const homeDrive = readEnvironmentValue(env, "HOMEDRIVE") ?? readEnvironmentValue(parentEnv, "HOMEDRIVE");
304
- const homePath = readEnvironmentValue(env, "HOMEPATH") ?? readEnvironmentValue(parentEnv, "HOMEPATH");
305
- if (homeDrive && homePath) {
306
- return `${homeDrive}${homePath}`;
307
- }
308
- if (homeDir && path.win32.isAbsolute(homeDir)) {
309
- return homeDir;
310
- }
311
- const systemDrive = readEnvironmentValue(env, "SystemDrive") ?? readEnvironmentValue(parentEnv, "SystemDrive") ?? "C:";
312
- const username = readEnvironmentValue(env, "USERNAME") ?? readEnvironmentValue(parentEnv, "USERNAME");
313
- return username ? path.win32.join(systemDrive, "Users", username) : undefined;
314
- }
315
- function readEnvironmentValue(env, name) {
316
- const entry = Object.entries(env).find(([key]) => key.toLowerCase() === name.toLowerCase());
317
- const value = entry?.[1];
318
- return typeof value === "string" && value.trim().length > 0 ? value : undefined;
319
- }
320
- function setEnvironmentValueIfMissing(env, name, value) {
321
- if (readEnvironmentValue(env, name)) {
322
- return;
323
- }
324
- env[name] = value;
325
- }
326
125
  export class StreamingProviderProcessRunner {
327
126
  terminalExitGraceMs;
328
127
  terminalSuccessCeilingMs;
329
128
  terminalWorkPollMs;
330
- constructor(terminalExitGraceMs = PROVIDER_TERMINAL_EXIT_GRACE_MS, terminalSuccessCeilingMs = PROVIDER_TERMINAL_SUCCESS_CEILING_MS, terminalWorkPollMs = PROVIDER_TERMINAL_WORK_POLL_MS) {
129
+ outputPipeReleaseGraceMs;
130
+ constructor(terminalExitGraceMs = PROVIDER_TERMINAL_EXIT_GRACE_MS, terminalSuccessCeilingMs = PROVIDER_TERMINAL_SUCCESS_CEILING_MS, terminalWorkPollMs = PROVIDER_TERMINAL_WORK_POLL_MS, outputPipeReleaseGraceMs = PROVIDER_OUTPUT_PIPE_RELEASE_GRACE_MS) {
331
131
  this.terminalExitGraceMs = terminalExitGraceMs;
332
132
  this.terminalSuccessCeilingMs = terminalSuccessCeilingMs;
333
133
  this.terminalWorkPollMs = terminalWorkPollMs;
134
+ this.outputPipeReleaseGraceMs = outputPipeReleaseGraceMs;
334
135
  }
335
136
  async run(request, handlers = {}, signal) {
336
137
  assertHostDatabaseCapabilityBoundary();
@@ -379,11 +180,12 @@ export class StreamingProviderProcessRunner {
379
180
  const childStderr = child.stderr;
380
181
  if (!childStdout || !childStderr) {
381
182
  const pipeError = new Error("Provider process stdout/stderr streams were not piped.");
382
- void terminate().then(() => reject(pipeError), terminationError => reject(new AggregateError([pipeError, terminationError], "Provider launch failed and its process tree could not be proven stopped.")));
183
+ void terminate().then(() => reject(pipeError), terminationError => reject(new AggregateError([pipeError, terminationError], "host_process_supervisor_termination_failed: Provider launch failed and its process tree could not be proven stopped.")));
383
184
  return;
384
185
  }
385
186
  const stdout = new BoundedOutputTail(PROVIDER_OUTPUT_CAPTURE_LIMIT_CHARS);
386
187
  const stderr = new BoundedOutputTail(PROVIDER_OUTPUT_CAPTURE_LIMIT_CHARS);
188
+ const outputPipes = new OutputPipeRelease(child, this.outputPipeReleaseGraceMs, message => stderr.appendLine(message));
387
189
  let settled = false;
388
190
  let closed = false;
389
191
  let cancellationRequested = false;
@@ -401,8 +203,10 @@ export class StreamingProviderProcessRunner {
401
203
  let terminalWorkTickRunning = false;
402
204
  let latestTurnFailed = false;
403
205
  let readiness = null;
206
+ const backgroundTurnEnd = new ClaudeBackgroundTurnEndWatch(request.command, this.terminalExitGraceMs, () => finishAfterTerminalSuccess("turn_ended_with_background_work"));
404
207
  const cleanup = () => {
405
208
  stopTerminalWorkTimer();
209
+ backgroundTurnEnd.stop();
406
210
  graceIdleMs = null;
407
211
  ceilingIdleMs = null;
408
212
  signal?.removeEventListener("abort", abort);
@@ -415,7 +219,7 @@ export class StreamingProviderProcessRunner {
415
219
  cleanup();
416
220
  // Do not release the caller's reservation/worktree/port ownership until
417
221
  // descendant termination has completed (or failed with explicit proof).
418
- void terminate().then(() => reject(error), terminationError => reject(new AggregateError([error, terminationError], "Provider process failed and its process tree could not be proven stopped.")));
222
+ void terminate().then(() => reject(error), terminationError => reject(new AggregateError([error, terminationError], "host_process_supervisor_termination_failed: Provider process failed and its process tree could not be proven stopped.")));
419
223
  };
420
224
  const abort = () => {
421
225
  if (!closed)
@@ -426,12 +230,10 @@ export class StreamingProviderProcessRunner {
426
230
  // termination; only a failed termination proof rejects the run.
427
231
  void terminate().catch(fail);
428
232
  };
429
- if (signal?.aborted) {
233
+ if (signal?.aborted)
430
234
  abort();
431
- }
432
- else {
235
+ else
433
236
  signal?.addEventListener("abort", abort, { once: true });
434
- }
435
237
  child.on("error", fail);
436
238
  const startGrant = startGated ? child.stdio[3] : null;
437
239
  if (startGated && !startGrant) {
@@ -514,16 +316,6 @@ export class StreamingProviderProcessRunner {
514
316
  stopTerminalWorkTimer();
515
317
  void terminate().catch(fail);
516
318
  };
517
- const workInFlight = async () => {
518
- try {
519
- if (handlers.isToolCallInFlight?.())
520
- return true;
521
- }
522
- catch {
523
- // A failing probe must not keep the provider open or stop it early on its own.
524
- }
525
- return await hasNonterminalManagedCommand(request.env?.FORGE_LOG_DIR).catch(() => false);
526
- };
527
319
  // The grace and the ceiling only count time in which no supervised work is in flight:
528
320
  // a provider waiting on an MCP tool call or on a managed command it started is not
529
321
  // finished, even when its turn has ended. The grace restarts once that work is done.
@@ -532,7 +324,7 @@ export class StreamingProviderProcessRunner {
532
324
  return;
533
325
  terminalWorkTickRunning = true;
534
326
  try {
535
- const inFlight = await workInFlight();
327
+ const inFlight = await providerWorkInFlight(handlers, request.env?.FORGE_LOG_DIR);
536
328
  const now = performance.now();
537
329
  const elapsed = Math.max(0, now - terminalWorkTickAt);
538
330
  terminalWorkTickAt = now;
@@ -586,6 +378,7 @@ export class StreamingProviderProcessRunner {
586
378
  if (request.captureOutput !== false)
587
379
  stdout.appendLine(line);
588
380
  const handled = handlers.onStdoutLine?.(line);
381
+ backgroundTurnEnd.consume(line);
589
382
  if (!terminalTerminationStarted) {
590
383
  if (isProviderTerminalSuccess(line)) {
591
384
  latestTurnFailed = false;
@@ -666,68 +459,36 @@ export class StreamingProviderProcessRunner {
666
459
  ...(memory ?? {}),
667
460
  ...(cancelledBeforeClose ? { cancelled: true } : {}),
668
461
  ...(terminalStopReason && !cancellationRequested ? { terminalStopReason } : {}),
462
+ ...outputPipes.resultFields(),
669
463
  });
670
464
  }).catch(fail);
671
465
  });
672
466
  });
673
467
  }
674
468
  }
469
+ async function providerWorkInFlight(handlers, logDirectory) {
470
+ try {
471
+ if (handlers.isToolCallInFlight?.())
472
+ return true;
473
+ }
474
+ catch {
475
+ // A failing probe must not keep the provider open or stop it early on its own.
476
+ }
477
+ return await hasNonterminalManagedCommand(logDirectory).catch(() => false);
478
+ }
675
479
  /**
676
480
  * The typed failure for a provider run that ended without calling its required Forge
677
- * completion tool. A run Forge stopped at the success ceiling is reported as such, so it
678
- * is not mistaken for an agent that simply ended its turn.
481
+ * completion tool. A run Forge stopped at the success ceiling or for background work is
482
+ * reported as such, so it is not mistaken for an agent that simply ended its turn.
679
483
  */
680
484
  export function providerCompletionToolMissingFailure(message, result) {
485
+ if (result?.terminalStopReason === "turn_ended_with_background_work")
486
+ return providerTurnEndedWithBackgroundWorkFailure(message);
681
487
  if (result?.terminalStopReason === "success_ceiling") {
682
488
  return new ForgeFailureError("provider_terminated_at_turn_ceiling", `${message} Forge stopped the provider at its post-turn success ceiling while it was still working.`);
683
489
  }
684
490
  return new ForgeFailureError("provider_completion_tool_missing", message);
685
491
  }
686
- /** A stream event that shows the provider is working on a turn: model output or a tool result. */
687
- function isProviderTurnActivity(line) {
688
- const trimmed = line.trim();
689
- if (!trimmed.startsWith("{"))
690
- return false;
691
- try {
692
- const event = JSON.parse(trimmed);
693
- return event.type === "assistant"
694
- || event.type === "user"
695
- || (event.type === "system" && event.subtype === "init")
696
- || event.type === "turn.started"
697
- || event.type === "item.started";
698
- }
699
- catch {
700
- return false;
701
- }
702
- }
703
- function isProviderTerminalFailure(line) {
704
- const trimmed = line.trim();
705
- if (!trimmed.startsWith("{"))
706
- return false;
707
- try {
708
- const event = JSON.parse(trimmed);
709
- // The same events the output parsers report as provider errors.
710
- return event.type === "turn.failed"
711
- || event.type === "error"
712
- || (event.type === "result" && (event.subtype !== "success" || event.is_error === true));
713
- }
714
- catch {
715
- return false;
716
- }
717
- }
718
- function isProviderTerminalSuccess(line) {
719
- const trimmed = line.trim();
720
- if (!trimmed.startsWith("{"))
721
- return false;
722
- try {
723
- const event = JSON.parse(trimmed);
724
- return event.type === "turn.completed"
725
- || (event.type === "result" && event.subtype === "success" && event.is_error !== true);
726
- }
727
- catch {
728
- return false;
729
- }
730
- }
731
492
  class HostProcessTreeMemoryObserver {
732
493
  launch;
733
494
  processGroupId;
@@ -885,18 +646,7 @@ async function resolveProviderProcessLaunch(command, args) {
885
646
  if (process.platform !== "win32") {
886
647
  return { command, args };
887
648
  }
888
- const cursorDirect = await resolveCursorAgentDirectLaunch(command, args);
889
- if (cursorDirect) {
890
- return cursorDirect;
891
- }
892
- const resolved = await resolveWindowsCommand(command);
893
- if (!resolved) {
894
- return { command, args };
895
- }
896
- return resolveCodexNpmDirectLaunch(resolved, args)
897
- ?? resolveClaudeNpmDirectLaunch(resolved, args)
898
- ?? resolvePackageManagerDirectLaunch(resolved, args)
899
- ?? buildWindowsLaunchCommand(resolved, args);
649
+ return await resolveWindowsProviderLaunch(command, args);
900
650
  }
901
651
  const UNIX_PROVIDER_START_GATE_SHELL = "/bin/sh";
902
652
  const UNIX_PROVIDER_START_GATE_NAME = "forge-provider-start-gate";
@@ -1005,144 +755,3 @@ async function waitForWindowsProviderReady(launch, signal, isClosed) {
1005
755
  await new Promise(resolve => setTimeout(resolve, 25));
1006
756
  }
1007
757
  }
1008
- export function resolveCodexNpmDirectLaunch(commandPath, args) {
1009
- const extension = path.extname(commandPath).toLowerCase();
1010
- if ((extension !== ".cmd" && extension !== ".ps1")
1011
- || path.basename(commandPath, extension).toLowerCase() !== "codex") {
1012
- return null;
1013
- }
1014
- const entryPoint = path.join(path.dirname(commandPath), "node_modules", "@openai", "codex", "bin", "codex.js");
1015
- return fs.existsSync(entryPoint)
1016
- ? { command: process.execPath, args: [entryPoint, ...args] }
1017
- : null;
1018
- }
1019
- /**
1020
- * npm installs of Claude Code (`npm i -g @anthropic-ai/claude-code`) put a `claude.cmd` shim on
1021
- * PATH; launch its cli.js directly for the same Job Object reasons as Codex. The native installer
1022
- * ships `claude.exe`, which is preferred by PATH resolution and needs no rewrite.
1023
- */
1024
- export function resolveClaudeNpmDirectLaunch(commandPath, args) {
1025
- const extension = path.extname(commandPath).toLowerCase();
1026
- if ((extension !== ".cmd" && extension !== ".ps1")
1027
- || path.basename(commandPath, extension).toLowerCase() !== "claude") {
1028
- return null;
1029
- }
1030
- const entryPoint = path.join(path.dirname(commandPath), "node_modules", "@anthropic-ai", "claude-code", "cli.js");
1031
- return fs.existsSync(entryPoint)
1032
- ? { command: process.execPath, args: [entryPoint, ...args] }
1033
- : null;
1034
- }
1035
- /**
1036
- * Avoids cmd.exe's nested-quote handling for package-manager shims. That
1037
- * quoting loses executable paths containing spaces after the command is
1038
- * wrapped by the Windows Job Object supervisor.
1039
- */
1040
- export function resolvePackageManagerDirectLaunch(commandPath, args) {
1041
- const extension = path.extname(commandPath).toLowerCase();
1042
- if (extension !== ".cmd" && extension !== ".ps1")
1043
- return null;
1044
- const packageManager = path.basename(commandPath, extension).toLowerCase();
1045
- if (!["corepack", "npm", "npx", "pnpm", "pnpx", "yarn", "yarnpkg"].includes(packageManager))
1046
- return null;
1047
- const root = path.dirname(commandPath);
1048
- const candidates = [
1049
- path.join(root, "node_modules", "corepack", "dist", packageManager === "corepack" ? "corepack.js" : `${packageManager}.js`),
1050
- ...(packageManager === "npm" || packageManager === "npx"
1051
- ? [path.join(root, "node_modules", "npm", "bin", `${packageManager}-cli.js`)]
1052
- : []),
1053
- ...(packageManager === "pnpm" || packageManager === "pnpx"
1054
- ? [path.join(root, "node_modules", "pnpm", "bin", `${packageManager}.cjs`)]
1055
- : []),
1056
- ...(packageManager === "yarn" || packageManager === "yarnpkg"
1057
- ? [path.join(root, "node_modules", "yarn", "bin", "yarn.js")]
1058
- : []),
1059
- ];
1060
- const entryPoint = candidates.find(candidate => fs.existsSync(candidate));
1061
- if (!entryPoint)
1062
- return null;
1063
- const adjacentNode = path.join(root, "node.exe");
1064
- return {
1065
- command: fs.existsSync(adjacentNode) ? adjacentNode : process.execPath,
1066
- args: [entryPoint, ...args],
1067
- };
1068
- }
1069
- async function resolveWindowsCommand(command) {
1070
- if (path.isAbsolute(command)) {
1071
- return command;
1072
- }
1073
- const resolvedFromPath = resolveWindowsCommandFromPath(command);
1074
- if (resolvedFromPath) {
1075
- return resolvedFromPath;
1076
- }
1077
- try {
1078
- const result = await execFileAsync("where.exe", [command], { timeout: 2000 });
1079
- return chooseWindowsCommandCandidate(result.stdout.split(/\r?\n/));
1080
- }
1081
- catch {
1082
- return null;
1083
- }
1084
- }
1085
- /**
1086
- * Resolves Windows commands without spawning where.exe. Runtime launches can
1087
- * happen while the machine is under enough process pressure for where.exe to
1088
- * miss its timeout; returning the unresolved package-manager name in that case
1089
- * makes Node fall back to a shell shim that cannot survive Job Object wrapping.
1090
- */
1091
- export function resolveWindowsCommandFromPath(command, pathValue = process.env.PATH ?? "", pathExtValue = process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD") {
1092
- if (!command || path.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
1093
- return null;
1094
- }
1095
- const hasExtension = path.extname(command).length > 0;
1096
- const extensions = hasExtension
1097
- ? [""]
1098
- : [...new Set([
1099
- "",
1100
- ".exe",
1101
- ".ps1",
1102
- ".cmd",
1103
- ".bat",
1104
- ...pathExtValue.split(";").map(value => value.trim().toLowerCase()).filter(Boolean),
1105
- ])];
1106
- for (const rawDirectory of pathValue.split(path.delimiter)) {
1107
- const directory = rawDirectory.trim().replace(/^"|"$/gu, "");
1108
- if (!directory)
1109
- continue;
1110
- const candidates = [];
1111
- for (const extension of extensions) {
1112
- const candidate = path.join(directory, `${command}${extension}`);
1113
- if (fs.existsSync(candidate))
1114
- candidates.push(candidate);
1115
- }
1116
- const resolved = chooseWindowsCommandCandidate(candidates);
1117
- if (resolved)
1118
- return resolved;
1119
- }
1120
- return null;
1121
- }
1122
- export function chooseWindowsCommandCandidate(candidates) {
1123
- const normalized = candidates
1124
- .map((candidate) => candidate.trim())
1125
- .filter((candidate) => candidate.length > 0);
1126
- if (normalized.length === 0) {
1127
- return null;
1128
- }
1129
- const preferredExtensions = [".exe", ".ps1", ".cmd", ".bat", ""];
1130
- for (const extension of preferredExtensions) {
1131
- const candidate = normalized.find((entry) => path.extname(entry).toLowerCase() === extension);
1132
- if (candidate) {
1133
- return candidate;
1134
- }
1135
- }
1136
- return normalized[0];
1137
- }
1138
- async function readProcessLines(stream, onLine) {
1139
- const reader = readline.createInterface({ input: stream });
1140
- try {
1141
- for await (const line of reader) {
1142
- await onLine(line);
1143
- }
1144
- }
1145
- finally {
1146
- reader.close();
1147
- }
1148
- }
@@ -15,7 +15,7 @@ export declare function isDecomposeDraftDispatch(dispatch: RunOnceDispatchPacket
15
15
  export declare function formatProviderCliCommand(command: ProviderCliCommand): string;
16
16
  export declare function formatProviderCliCommandForCheckpoint(command: ProviderCliCommand): string;
17
17
  export declare function singleLine(value: string): string;
18
- export declare function buildProviderCliCommand(dispatch: RunOnceDispatchPacket, run?: {
18
+ type ProviderCliRun = {
19
19
  readonly prompt?: string;
20
20
  readonly promptFromStdin?: boolean;
21
21
  readonly worktreePath?: string;
@@ -23,17 +23,27 @@ export declare function buildProviderCliCommand(dispatch: RunOnceDispatchPacket,
23
23
  readonly skipGitRepoCheck?: boolean;
24
24
  readonly imagePaths?: readonly string[];
25
25
  readonly runtimeEnvironment?: Readonly<Record<string, string>>;
26
- }): ProviderCliCommand;
26
+ /** Review-only launch: the provider is started without the tools that change or publish the checkout. */
27
+ readonly reviewOnly?: boolean;
28
+ };
29
+ export declare function buildProviderCliCommand(dispatch: RunOnceDispatchPacket, run?: ProviderCliRun): ProviderCliCommand;
27
30
  /**
28
31
  * Returns the effort level to pass to the provider CLI, or null to keep Forge's provider default.
29
32
  * Values the provider does not accept are dropped rather than failing the attempt; Forge validates on save.
30
33
  */
31
34
  export declare function providerEffort(provider: string, effort: string | null | undefined): string | null;
32
- export declare function buildProviderCliPrompt(dispatch: RunOnceDispatchPacket, prompt: string, runtimeEnvironment?: Readonly<Record<string, string>>): string;
35
+ /** Whether the provider reads its prompt from stdin rather than the command line. */
36
+ export declare function shouldPipePromptToStdin(provider: string, prompt: string, force?: boolean): boolean;
37
+ export declare function usesManagedWindowsHost(dispatch: RunOnceDispatchPacket): boolean;
38
+ export declare function buildProviderCliPrompt(dispatch: RunOnceDispatchPacket, prompt: string, runtimeEnvironment?: Readonly<Record<string, string>>, options?: {
39
+ readonly reviewOnly?: boolean;
40
+ }): string;
33
41
  export declare function codexSandboxModeForPlatform(platform?: NodeJS.Platform, executionMode?: string): "workspace-write" | "danger-full-access";
34
42
  export declare function buildArchitectPrompt(dispatch: RunOnceDispatchPacket): string;
35
43
  export declare function architectDependencyInstruction(dispatch: RunOnceDispatchPacket): string;
36
44
  export declare function designerRefInstruction(dispatch: RunOnceDispatchPacket): string;
45
+ export declare function designerRefBuildInstruction(dispatch: RunOnceDispatchPacket): string;
46
+ export declare function designerRefQaInstruction(dispatch: RunOnceDispatchPacket): string;
37
47
  export declare function architectRevisionInstruction(dispatch: RunOnceDispatchPacket): string;
38
48
  /**
39
49
  * Headless providers must not end a turn to wait: Forge stops the provider shortly after
@@ -50,8 +60,10 @@ export declare function phaseWorkInstruction(phase: ReturnType<typeof completion
50
60
  export declare function qaBrowserInstruction(dispatch: RunOnceDispatchPacket): string;
51
61
  export declare function storyQaInstruction(dispatch: RunOnceDispatchPacket): string;
52
62
  export declare function buildQaPrompt(dispatch: RunOnceDispatchPacket, laneSpec: string): string;
63
+ export { buildPrReviewPrompt } from "./pr-review-prompt.js";
53
64
  export declare function buildConflictResolvePrompt(dispatch: RunOnceDispatchPacket, branchName: string): string;
54
65
  export declare function buildPullRequestCheckRepairPrompt(dispatch: RunOnceDispatchPacket, branchName: string): string;
55
66
  export declare function buildPullRequestCommentsPrompt(dispatch: RunOnceDispatchPacket, branchName: string): string;
56
67
  export declare function isPullRequestCheckRepairDispatch(dispatch: RunOnceDispatchPacket): boolean;
57
68
  export declare function isPullRequestCommentsDispatch(dispatch: RunOnceDispatchPacket): boolean;
69
+ export { reapplyConflictInstruction, withReapplyConflictInstruction, withRemainingReapplyConflictInstruction, } from "./provider-cli.reapply-conflicts.js";