@loucompanion/forge-bridge 0.1.3-dev.f66395c3ac21 → 0.1.4-dev.0098fdb4e213

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 (381) hide show
  1. package/README.md +306 -1
  2. package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
  3. package/dist/bridge/bridge-chat-provider-command.js +132 -0
  4. package/dist/bridge/bridge-chat.types.d.ts +121 -0
  5. package/dist/bridge/bridge-chat.types.js +416 -0
  6. package/dist/bridge/bridge-state-file.d.ts +161 -0
  7. package/dist/bridge/bridge-state-file.js +376 -0
  8. package/dist/bridge/bridge-state-io.d.ts +11 -0
  9. package/dist/bridge/bridge-state-io.js +50 -0
  10. package/dist/bridge/bridge-state-lock.d.ts +11 -0
  11. package/dist/bridge/bridge-state-lock.js +102 -0
  12. package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
  13. package/dist/bridge/bridge-state-unpublished.js +111 -0
  14. package/dist/bridge/bridge.base.d.ts +18 -1
  15. package/dist/bridge/bridge.service.d.ts +216 -4
  16. package/dist/bridge/bridge.service.js +2574 -90
  17. package/dist/bridge/bridge.types.d.ts +245 -2
  18. package/dist/bridge/dispatch-result-outbox.d.ts +35 -0
  19. package/dist/bridge/dispatch-result-outbox.js +87 -0
  20. package/dist/bridge/dispatch-result-worker.d.ts +2 -0
  21. package/dist/bridge/dispatch-result-worker.js +122 -0
  22. package/dist/bridge/in-flight-registry.d.ts +62 -0
  23. package/dist/bridge/in-flight-registry.js +207 -0
  24. package/dist/bridge/internals.d.ts +2 -0
  25. package/dist/bridge/internals.js +1 -0
  26. package/dist/bridge/local-yield-flag.d.ts +6 -0
  27. package/dist/bridge/local-yield-flag.js +34 -0
  28. package/dist/bridge/readiness-result-outbox.d.ts +25 -0
  29. package/dist/bridge/readiness-result-outbox.js +74 -0
  30. package/dist/bridge/readiness-result-worker.d.ts +2 -0
  31. package/dist/bridge/readiness-result-worker.js +121 -0
  32. package/dist/bridge/runner-host-capabilities.d.ts +20 -0
  33. package/dist/bridge/runner-host-capabilities.js +110 -0
  34. package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
  35. package/dist/bridge/sandbox-resource-accounting.js +150 -0
  36. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  37. package/dist/bridge/test-postgres-capability.js +120 -0
  38. package/dist/cleanup/cleanup-wip.d.ts +12 -0
  39. package/dist/cleanup/cleanup-wip.js +66 -0
  40. package/dist/cleanup/cleanup.service.d.ts +33 -2
  41. package/dist/cleanup/cleanup.service.js +477 -3
  42. package/dist/cleanup/cleanup.types.d.ts +16 -0
  43. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  44. package/dist/cleanup/forge-owned-paths.js +53 -0
  45. package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
  46. package/dist/cleanup/host-runtime-ledger.js +130 -0
  47. package/dist/cleanup/index.d.ts +1 -1
  48. package/dist/cleanup/index.js +1 -1
  49. package/dist/cleanup/internals.d.ts +2 -2
  50. package/dist/cleanup/internals.js +1 -1
  51. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  52. package/dist/cleanup/managed-branch-sweep.js +111 -0
  53. package/dist/cli/cli.help.d.ts +2 -0
  54. package/dist/cli/cli.help.js +279 -0
  55. package/dist/cli/cli.service.d.ts +69 -12
  56. package/dist/cli/cli.service.js +557 -382
  57. package/dist/cli/idle-status.d.ts +84 -0
  58. package/dist/cli/idle-status.js +181 -0
  59. package/dist/cli/local-config.d.ts +13 -0
  60. package/dist/cli/local-config.js +82 -6
  61. package/dist/cli/provider-cli-detection.d.ts +10 -0
  62. package/dist/cli/provider-cli-detection.js +160 -0
  63. package/dist/runtime/aspnet-runtime-prebuild.d.ts +41 -0
  64. package/dist/runtime/aspnet-runtime-prebuild.js +474 -0
  65. package/dist/runtime/attempt-database-broker.d.ts +89 -0
  66. package/dist/runtime/attempt-database-broker.js +390 -0
  67. package/dist/runtime/attempt-node-runtime-launcher.d.ts +18 -0
  68. package/dist/runtime/attempt-node-runtime-launcher.js +140 -0
  69. package/dist/runtime/attempt-path-operation.d.ts +21 -0
  70. package/dist/runtime/attempt-path-operation.js +94 -0
  71. package/dist/runtime/attempt-private-directory.d.ts +6 -0
  72. package/dist/runtime/attempt-private-directory.js +54 -0
  73. package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
  74. package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
  75. package/dist/runtime/attempt-process-supervisor.d.ts +121 -0
  76. package/dist/runtime/attempt-process-supervisor.js +471 -0
  77. package/dist/runtime/canonical-source-file.d.ts +3 -0
  78. package/dist/runtime/canonical-source-file.js +54 -0
  79. package/dist/runtime/docker-engine-probe.d.ts +95 -0
  80. package/dist/runtime/docker-engine-probe.js +340 -0
  81. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  82. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  83. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  84. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  85. package/dist/runtime/generated-output-reset.d.ts +20 -0
  86. package/dist/runtime/generated-output-reset.js +157 -0
  87. package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
  88. package/dist/runtime/host-database-capability-boundary.js +63 -0
  89. package/dist/runtime/host-diagnostics.d.ts +11 -0
  90. package/dist/runtime/host-diagnostics.js +192 -0
  91. package/dist/runtime/host-execution-root.d.ts +4 -0
  92. package/dist/runtime/host-execution-root.js +39 -0
  93. package/dist/runtime/host-facts.d.ts +36 -0
  94. package/dist/runtime/host-facts.js +95 -0
  95. package/dist/runtime/host-listener-inspector.d.ts +51 -0
  96. package/dist/runtime/host-listener-inspector.js +385 -0
  97. package/dist/runtime/host-load-admission.d.ts +67 -0
  98. package/dist/runtime/host-load-admission.js +99 -0
  99. package/dist/runtime/host-load-child-environment.d.ts +27 -0
  100. package/dist/runtime/host-load-child-environment.js +76 -0
  101. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  102. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  103. package/dist/runtime/host-load-governor-config.d.ts +52 -0
  104. package/dist/runtime/host-load-governor-config.js +83 -0
  105. package/dist/runtime/host-load-governor.d.ts +186 -0
  106. package/dist/runtime/host-load-governor.js +632 -0
  107. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  108. package/dist/runtime/host-load-ledger-lock.js +187 -0
  109. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  110. package/dist/runtime/host-load-runtime-settings.js +80 -0
  111. package/dist/runtime/host-load-sampler.d.ts +156 -0
  112. package/dist/runtime/host-load-sampler.js +298 -0
  113. package/dist/runtime/host-load-step-class.d.ts +70 -0
  114. package/dist/runtime/host-load-step-class.js +161 -0
  115. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  116. package/dist/runtime/host-load-step-reaper.js +95 -0
  117. package/dist/runtime/host-load-step-run.d.ts +73 -0
  118. package/dist/runtime/host-load-step-run.js +102 -0
  119. package/dist/runtime/host-load-test-slot.d.ts +43 -0
  120. package/dist/runtime/host-load-test-slot.js +81 -0
  121. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  122. package/dist/runtime/host-load-token-ledger.js +453 -0
  123. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  124. package/dist/runtime/host-load-windows-cpu.js +85 -0
  125. package/dist/runtime/host-port-broker.d.ts +76 -0
  126. package/dist/runtime/host-port-broker.js +333 -0
  127. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  128. package/dist/runtime/host-pressure-stall.js +168 -0
  129. package/dist/runtime/host-runtime-contract.d.ts +74 -0
  130. package/dist/runtime/host-runtime-contract.js +846 -0
  131. package/dist/runtime/host-runtime-lease.d.ts +287 -0
  132. package/dist/runtime/host-runtime-lease.js +2763 -0
  133. package/dist/runtime/host-runtime-promotion.d.ts +55 -0
  134. package/dist/runtime/host-runtime-promotion.js +254 -0
  135. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  136. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  137. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  138. package/dist/runtime/host-runtime-requirements.js +117 -0
  139. package/dist/runtime/managed-command-teardown.d.ts +62 -0
  140. package/dist/runtime/managed-command-teardown.js +596 -0
  141. package/dist/runtime/memory-capacity.d.ts +70 -0
  142. package/dist/runtime/memory-capacity.js +123 -0
  143. package/dist/runtime/native-test-postgres-fallback.d.ts +69 -0
  144. package/dist/runtime/native-test-postgres-fallback.js +143 -0
  145. package/dist/runtime/node-host-runtime-adapter.d.ts +54 -0
  146. package/dist/runtime/node-host-runtime-adapter.js +286 -0
  147. package/dist/runtime/pinned-directory-process.d.ts +9 -0
  148. package/dist/runtime/pinned-directory-process.js +61 -0
  149. package/dist/runtime/pinned-source-directory.d.ts +17 -0
  150. package/dist/runtime/pinned-source-directory.js +94 -0
  151. package/dist/runtime/playwright-browser-cache.d.ts +39 -0
  152. package/dist/runtime/playwright-browser-cache.js +227 -0
  153. package/dist/runtime/playwright-host-runtime-adapter.d.ts +39 -0
  154. package/dist/runtime/playwright-host-runtime-adapter.js +274 -0
  155. package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
  156. package/dist/runtime/prepared-runtime-identity.js +218 -0
  157. package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
  158. package/dist/runtime/prepared-runtime-readiness.js +285 -0
  159. package/dist/runtime/runner-settings.d.ts +104 -0
  160. package/dist/runtime/runner-settings.js +236 -0
  161. package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
  162. package/dist/runtime/runtime-isolation-lease.js +161 -0
  163. package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
  164. package/dist/runtime/workspace-resource-estimator.js +174 -0
  165. package/dist/sandbox/command-runner.d.ts +4 -0
  166. package/dist/sandbox/command-runner.js +47 -0
  167. package/dist/sandbox/contract.d.ts +5 -0
  168. package/dist/sandbox/contract.js +276 -0
  169. package/dist/sandbox/event-budget.d.ts +11 -0
  170. package/dist/sandbox/event-budget.js +27 -0
  171. package/dist/sandbox/host-capacity-broker.d.ts +115 -0
  172. package/dist/sandbox/host-capacity-broker.js +336 -0
  173. package/dist/sandbox/image-policy.d.ts +35 -0
  174. package/dist/sandbox/image-policy.js +247 -0
  175. package/dist/sandbox/index.d.ts +5 -0
  176. package/dist/sandbox/index.js +5 -0
  177. package/dist/sandbox/lease-watchdog.d.ts +18 -0
  178. package/dist/sandbox/lease-watchdog.js +67 -0
  179. package/dist/sandbox/managed-branch.d.ts +13 -0
  180. package/dist/sandbox/managed-branch.js +36 -0
  181. package/dist/sandbox/preflight.d.ts +84 -0
  182. package/dist/sandbox/preflight.js +521 -0
  183. package/dist/sandbox/process.d.ts +20 -0
  184. package/dist/sandbox/process.js +209 -0
  185. package/dist/sandbox/provider-auth/codex.d.ts +26 -0
  186. package/dist/sandbox/provider-auth/codex.js +212 -0
  187. package/dist/sandbox/repository-lock.d.ts +6 -0
  188. package/dist/sandbox/repository-lock.js +129 -0
  189. package/dist/sandbox/runtime.d.ts +311 -0
  190. package/dist/sandbox/runtime.js +2407 -0
  191. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  192. package/dist/sandbox/sandbox-cgroups.js +42 -0
  193. package/dist/sandbox/sandbox.types.d.ts +93 -0
  194. package/dist/sandbox/sandbox.types.js +1 -0
  195. package/dist/sandbox/smoke.d.ts +76 -0
  196. package/dist/sandbox/smoke.js +380 -0
  197. package/dist/sandbox/worker-supervisor.d.ts +13 -0
  198. package/dist/sandbox/worker-supervisor.js +36 -0
  199. package/dist/sandbox/worker.d.ts +1 -0
  200. package/dist/sandbox/worker.js +225 -0
  201. package/dist/sandbox/workspace.service.d.ts +13 -0
  202. package/dist/sandbox/workspace.service.js +74 -0
  203. package/dist/session/architect-waits.d.ts +2 -0
  204. package/dist/session/architect-waits.js +138 -0
  205. package/dist/session/managed-attempt-tools.d.ts +48 -0
  206. package/dist/session/managed-attempt-tools.js +1299 -0
  207. package/dist/session/managed-build-coordinator.d.ts +5 -0
  208. package/dist/session/managed-build-coordinator.js +109 -0
  209. package/dist/session/managed-build-receipt.d.ts +26 -0
  210. package/dist/session/managed-build-receipt.js +342 -0
  211. package/dist/session/managed-command-host-load.d.ts +47 -0
  212. package/dist/session/managed-command-host-load.js +83 -0
  213. package/dist/session/managed-verification-timeouts.d.ts +8 -0
  214. package/dist/session/managed-verification-timeouts.js +17 -0
  215. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  216. package/dist/session/mcp-argument-coercion.js +121 -0
  217. package/dist/session/phase-completion.artifacts.d.ts +34 -0
  218. package/dist/session/phase-completion.artifacts.js +903 -0
  219. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  220. package/dist/session/phase-completion.command-validation.js +77 -0
  221. package/dist/session/phase-completion.d.ts +65 -42
  222. package/dist/session/phase-completion.helpers.d.ts +117 -0
  223. package/dist/session/phase-completion.helpers.js +708 -0
  224. package/dist/session/phase-completion.js +130 -3007
  225. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  226. package/dist/session/phase-completion.mcp-args.js +156 -0
  227. package/dist/session/phase-completion.prompts.d.ts +14 -0
  228. package/dist/session/phase-completion.prompts.js +238 -0
  229. package/dist/session/phase-completion.runtime.d.ts +43 -0
  230. package/dist/session/phase-completion.runtime.js +721 -0
  231. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  232. package/dist/session/phase-completion.schema-parts.js +188 -0
  233. package/dist/session/phase-completion.schemas.d.ts +3 -0
  234. package/dist/session/phase-completion.schemas.js +836 -0
  235. package/dist/session/phase-completion.validation.d.ts +37 -0
  236. package/dist/session/phase-completion.validation.js +874 -0
  237. package/dist/session/pre-publication-host-load.d.ts +27 -0
  238. package/dist/session/pre-publication-host-load.js +111 -0
  239. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  240. package/dist/session/pre-publication-native-postgres.js +111 -0
  241. package/dist/session/pre-publication-pass.d.ts +61 -0
  242. package/dist/session/pre-publication-pass.js +148 -0
  243. package/dist/session/pre-publication-process.d.ts +23 -0
  244. package/dist/session/pre-publication-process.js +109 -0
  245. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  246. package/dist/session/pre-publication-skipped-tests.js +109 -0
  247. package/dist/session/pre-publication-step-execution.d.ts +12 -0
  248. package/dist/session/pre-publication-step-execution.js +50 -0
  249. package/dist/session/pre-publication-validation.d.ts +91 -0
  250. package/dist/session/pre-publication-validation.js +670 -0
  251. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
  252. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
  253. package/dist/session/provider-cli/ci-repair-readiness.d.ts +16 -0
  254. package/dist/session/provider-cli/ci-repair-readiness.js +110 -0
  255. package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
  256. package/dist/session/provider-cli/claude-background-work.js +181 -0
  257. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  258. package/dist/session/provider-cli/host-build-lock.js +30 -0
  259. package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
  260. package/dist/session/provider-cli/pre-publication-repair.js +276 -0
  261. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +96 -0
  262. package/dist/session/provider-cli/provider-cli.artifacts.js +818 -0
  263. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  264. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  265. package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
  266. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  267. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  268. package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
  269. package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
  270. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
  271. package/dist/session/provider-cli/provider-cli.deterministic.js +407 -0
  272. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  273. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  274. package/dist/session/provider-cli/provider-cli.process.d.ts +114 -0
  275. package/dist/session/provider-cli/provider-cli.process.js +757 -0
  276. package/dist/session/provider-cli/provider-cli.prompts.d.ts +62 -0
  277. package/dist/session/provider-cli/provider-cli.prompts.js +770 -0
  278. package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
  279. package/dist/session/provider-cli/provider-cli.qa-sidecars.js +66 -0
  280. package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
  281. package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
  282. package/dist/session/provider-cli/provider-cli.runtime.d.ts +30 -0
  283. package/dist/session/provider-cli/provider-cli.runtime.js +120 -0
  284. package/dist/session/provider-cli/provider-cli.service.d.ts +53 -53
  285. package/dist/session/provider-cli/provider-cli.service.js +1299 -2523
  286. package/dist/session/provider-cli/provider-cli.types.d.ts +38 -0
  287. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  288. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  289. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  290. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  291. package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
  292. package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
  293. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  294. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  295. package/dist/session/provider-cli/provider-output-state.d.ts +40 -0
  296. package/dist/session/provider-cli/provider-output-state.js +832 -0
  297. package/dist/session/provider-cli/provider-usage.d.ts +9 -1
  298. package/dist/session/provider-cli/provider-usage.js +28 -5
  299. package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
  300. package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
  301. package/dist/session/publishable-worktree-changes.d.ts +54 -0
  302. package/dist/session/publishable-worktree-changes.js +193 -0
  303. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  304. package/dist/session/qa-sidecar-validation.js +28 -0
  305. package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
  306. package/dist/session/sandbox-host-capacity-gate.js +257 -0
  307. package/dist/session/session-redaction.d.ts +3 -0
  308. package/dist/session/session-redaction.js +298 -0
  309. package/dist/session/session.base.d.ts +14 -1
  310. package/dist/session/session.service.d.ts +17 -2
  311. package/dist/session/session.service.js +708 -60
  312. package/dist/session/session.types.d.ts +327 -3
  313. package/dist/session/session.types.js +951 -10
  314. package/dist/session/sidecar-json-shape.d.ts +31 -0
  315. package/dist/session/sidecar-json-shape.js +217 -0
  316. package/dist/session/unreferenced-exports.d.ts +12 -0
  317. package/dist/session/unreferenced-exports.js +59 -0
  318. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  319. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  320. package/dist/shared/format/format-bytes.d.ts +1 -0
  321. package/dist/shared/format/format-bytes.js +9 -0
  322. package/dist/shared/fs/file-identity.d.ts +10 -0
  323. package/dist/shared/fs/file-identity.js +15 -0
  324. package/dist/shared/fs/replace-file.d.ts +7 -0
  325. package/dist/shared/fs/replace-file.js +33 -0
  326. package/dist/shared/git/git.js +2 -1
  327. package/dist/shared/path/path.d.ts +1 -0
  328. package/dist/shared/path/path.js +21 -1
  329. package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
  330. package/dist/shared/process/dotnet-toolchain.js +307 -0
  331. package/dist/shared/process/host-process-recovery.d.ts +23 -0
  332. package/dist/shared/process/host-process-recovery.js +99 -0
  333. package/dist/shared/process/host-process-supervisor.d.ts +72 -0
  334. package/dist/shared/process/host-process-supervisor.js +383 -0
  335. package/dist/shared/process/process-tree.d.ts +52 -0
  336. package/dist/shared/process/process-tree.js +144 -0
  337. package/dist/shared/process/process.d.ts +70 -0
  338. package/dist/shared/process/process.js +224 -16
  339. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  340. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  341. package/dist/shared/process/windows-launch.d.ts +26 -0
  342. package/dist/shared/process/windows-launch.js +109 -0
  343. package/dist/shared/provider-capabilities.d.ts +4 -0
  344. package/dist/shared/provider-capabilities.js +95 -0
  345. package/dist/shared/redaction/redaction.d.ts +1 -0
  346. package/dist/shared/redaction/redaction.js +47 -4
  347. package/dist/shared/time/monotonic.d.ts +1 -0
  348. package/dist/shared/time/monotonic.js +8 -0
  349. package/dist/version.d.ts +1 -1
  350. package/dist/version.js +1 -1
  351. package/dist/worktree/artifact-injector.d.ts +3 -2
  352. package/dist/worktree/artifact-injector.js +82 -10
  353. package/dist/worktree/dependency-warmer.d.ts +78 -1
  354. package/dist/worktree/dependency-warmer.js +731 -13
  355. package/dist/worktree/index.d.ts +2 -1
  356. package/dist/worktree/index.js +1 -0
  357. package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
  358. package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
  359. package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
  360. package/dist/worktree/story-qa-reference-hydrator.js +253 -0
  361. package/dist/worktree/wip-git.d.ts +33 -0
  362. package/dist/worktree/wip-git.js +122 -0
  363. package/dist/worktree/wip-refs.d.ts +62 -0
  364. package/dist/worktree/wip-refs.js +119 -0
  365. package/dist/worktree/wip-restore.d.ts +38 -0
  366. package/dist/worktree/wip-restore.js +190 -0
  367. package/dist/worktree/wip-snapshot.d.ts +50 -0
  368. package/dist/worktree/wip-snapshot.js +268 -0
  369. package/dist/worktree/worktree-paths.d.ts +4 -0
  370. package/dist/worktree/worktree-paths.js +30 -0
  371. package/dist/worktree/worktree-wip-events.d.ts +18 -0
  372. package/dist/worktree/worktree-wip-events.js +98 -0
  373. package/dist/worktree/worktree-wip.d.ts +49 -0
  374. package/dist/worktree/worktree-wip.js +182 -0
  375. package/dist/worktree/worktree.base.d.ts +10 -1
  376. package/dist/worktree/worktree.service.d.ts +30 -4
  377. package/dist/worktree/worktree.service.js +379 -54
  378. package/dist/worktree/worktree.types.d.ts +38 -1
  379. package/package.json +12 -7
  380. package/runtime/windows-job-supervisor.ps1 +722 -0
  381. package/runtime/windows-listener-owner.ps1 +33 -0
@@ -0,0 +1,84 @@
1
+ import { type BridgeIdleEvaluation, type BridgeStateRead } from "../bridge/bridge-state-file.js";
2
+ import { type InFlightEntry } from "../bridge/in-flight-registry.js";
3
+ import type { BridgeServiceConfig } from "../bridge/bridge.types.js";
4
+ import type { CliIo } from "./cli.base.js";
5
+ export interface IdleStatusOptions {
6
+ readonly json: boolean;
7
+ /** Seconds to keep polling while the bridge is busy, stale or not yet yielding; 0 (or no --wait) checks once. */
8
+ readonly waitSeconds: number;
9
+ /** Idle counts only once the bridge itself reports yield (exit 5 until then). */
10
+ readonly requireYield: boolean;
11
+ }
12
+ export type StatusArgs = {
13
+ readonly ok: true;
14
+ readonly command: "status";
15
+ readonly config: BridgeServiceConfig;
16
+ readonly checkUpdates: boolean;
17
+ readonly idle: IdleStatusOptions | null;
18
+ } | {
19
+ readonly ok: false;
20
+ readonly error: string;
21
+ };
22
+ export declare function parseStatusArgs(argv: readonly string[], config: () => BridgeServiceConfig): StatusArgs;
23
+ export interface IdleStatusDependencies {
24
+ readonly statePath: string;
25
+ readonly now: () => number;
26
+ readonly pidAlive: (pid: number) => boolean;
27
+ readonly read: (statePath: string) => Promise<BridgeStateRead>;
28
+ readonly localYield: () => Promise<boolean>;
29
+ readonly sleep: (ms: number) => Promise<void>;
30
+ readonly pollMs: number;
31
+ }
32
+ export declare function defaultIdleStatusDependencies(): IdleStatusDependencies;
33
+ export declare function runIdleStatusCommand(options: IdleStatusOptions, io: CliIo, deps?: IdleStatusDependencies): Promise<number>;
34
+ /** One line for plain `forge-bridge status`. */
35
+ export declare function idleSummaryLine(deps?: IdleStatusDependencies): Promise<string>;
36
+ export declare function idleStatusJson(evaluation: BridgeIdleEvaluation, deps: Pick<IdleStatusDependencies, "statePath" | "now">, localYield: boolean): {
37
+ pid: null;
38
+ runnerId: null;
39
+ runnerInstanceId: null;
40
+ version: null;
41
+ state: null;
42
+ startedAt: null;
43
+ updatedAt: null;
44
+ connected: null;
45
+ yielding: null;
46
+ yieldApplied: null;
47
+ conflict: null;
48
+ inFlight: readonly InFlightEntry[];
49
+ schemaVersion: number;
50
+ verdict: import("../bridge/bridge-state-file.js").BridgeIdleVerdict;
51
+ idle: boolean;
52
+ exitCode: number;
53
+ reason: string;
54
+ statePath: string;
55
+ checkedAt: string;
56
+ pidAlive: boolean | null;
57
+ heartbeatAgeMs: number | null;
58
+ staleAfterMs: number;
59
+ localYield: boolean;
60
+ } | {
61
+ pid: number;
62
+ runnerId: string;
63
+ runnerInstanceId: string;
64
+ version: string;
65
+ state: "running" | "stopped";
66
+ startedAt: string;
67
+ updatedAt: string;
68
+ connected: boolean;
69
+ yielding: boolean;
70
+ yieldApplied: boolean;
71
+ conflict: import("../bridge/bridge-state-file.js").BridgeStateConflict | null;
72
+ inFlight: readonly InFlightEntry[];
73
+ schemaVersion: number;
74
+ verdict: import("../bridge/bridge-state-file.js").BridgeIdleVerdict;
75
+ idle: boolean;
76
+ exitCode: number;
77
+ reason: string;
78
+ statePath: string;
79
+ checkedAt: string;
80
+ pidAlive: boolean | null;
81
+ heartbeatAgeMs: number | null;
82
+ staleAfterMs: number;
83
+ localYield: boolean;
84
+ };
@@ -0,0 +1,181 @@
1
+ import { evaluateBridgeIdle, formatAge, isProcessAlive, readBridgeStateFile, } from "../bridge/bridge-state-file.js";
2
+ import { describeInFlightIds } from "../bridge/in-flight-registry.js";
3
+ import { readLocalYieldFlag } from "../bridge/local-yield-flag.js";
4
+ import { resolveBridgeStatePath, resolveLocalYieldFlagPath } from "./local-config.js";
5
+ const statusUsage = "Usage: forge-bridge status [--check-updates] | forge-bridge status --idle [--require-yield] [--json] [--wait <seconds>]";
6
+ export function parseStatusArgs(argv, config) {
7
+ // --wait is tracked apart from its value: `--wait 0` without --idle is the same usage error as `--wait 5`.
8
+ const flags = { checkUpdates: false, idle: false, json: false, requireYield: false, waitSeconds: null };
9
+ const switches = {
10
+ "--check-updates": "checkUpdates", "--idle": "idle", "--json": "json", "--require-yield": "requireYield",
11
+ };
12
+ for (let index = 1; index < argv.length; index += 1) {
13
+ const arg = argv[index];
14
+ if (Object.hasOwn(switches, arg)) {
15
+ flags[switches[arg]] = true;
16
+ }
17
+ else if (arg === "--wait") {
18
+ const seconds = Number(argv[++index]);
19
+ if (!Number.isFinite(seconds) || seconds < 0)
20
+ return { ok: false, error: "--wait requires a number of seconds (0 or more)." };
21
+ flags.waitSeconds = seconds;
22
+ }
23
+ else {
24
+ return { ok: false, error: `Unknown argument: ${arg}\n${statusUsage}` };
25
+ }
26
+ }
27
+ if (!flags.idle && (flags.json || flags.requireYield || flags.waitSeconds !== null)) {
28
+ return { ok: false, error: `--json, --require-yield and --wait apply to --idle.\n${statusUsage}` };
29
+ }
30
+ if (flags.idle && flags.checkUpdates) {
31
+ return { ok: false, error: `--check-updates cannot be combined with --idle.\n${statusUsage}` };
32
+ }
33
+ return {
34
+ ok: true,
35
+ command: "status",
36
+ config: config(),
37
+ checkUpdates: flags.checkUpdates,
38
+ idle: flags.idle ? { json: flags.json, waitSeconds: flags.waitSeconds ?? 0, requireYield: flags.requireYield } : null,
39
+ };
40
+ }
41
+ export function defaultIdleStatusDependencies() {
42
+ return {
43
+ statePath: resolveBridgeStatePath(),
44
+ now: () => Date.now(),
45
+ pidAlive: isProcessAlive,
46
+ read: readBridgeStateFile,
47
+ localYield: () => readLocalYieldFlag(resolveLocalYieldFlagPath()),
48
+ sleep: ms => new Promise(resolve => setTimeout(resolve, ms)),
49
+ pollMs: 2_000,
50
+ };
51
+ }
52
+ export async function runIdleStatusCommand(options, io, deps = defaultIdleStatusDependencies()) {
53
+ const check = async () => evaluateBridgeIdle(await deps.read(deps.statePath), {
54
+ now: deps.now(),
55
+ pidAlive: deps.pidAlive,
56
+ requireYield: options.requireYield,
57
+ });
58
+ let evaluation = await check();
59
+ const deadline = deps.now() + options.waitSeconds * 1000;
60
+ if (worthWaiting(evaluation) && deps.now() < deadline && !options.json) {
61
+ io.stderr.write(`Waiting up to ${options.waitSeconds}s for the bridge to become idle (${evaluation.verdict})...\n`);
62
+ }
63
+ while (worthWaiting(evaluation) && deps.now() < deadline) {
64
+ await deps.sleep(Math.max(1, Math.min(deps.pollMs, deadline - deps.now())));
65
+ evaluation = await check();
66
+ }
67
+ const localYield = await deps.localYield().catch(() => false);
68
+ if (options.json) {
69
+ io.stdout.write(`${JSON.stringify(idleStatusJson(evaluation, deps, localYield), null, 2)}\n`);
70
+ }
71
+ else {
72
+ io.stdout.write(idleStatusText(evaluation, deps, localYield));
73
+ }
74
+ return evaluation.exitCode;
75
+ }
76
+ /** One line for plain `forge-bridge status`. */
77
+ export async function idleSummaryLine(deps = defaultIdleStatusDependencies()) {
78
+ const evaluation = evaluateBridgeIdle(await deps.read(deps.statePath), { now: deps.now(), pidAlive: deps.pidAlive });
79
+ return `${verdictTitles[evaluation.verdict]}: ${evaluation.reason} Details: forge-bridge status --idle`;
80
+ }
81
+ /**
82
+ * Busy work finishes, yield reaches Forge within a heartbeat, a stale heartbeat can recover and an
83
+ * unreadable or missing file can be a reader holding it (antivirus, the indexer) or a bridge
84
+ * starting. Only a dead bridge process will not change by waiting.
85
+ */
86
+ function worthWaiting(evaluation) {
87
+ return evaluation.verdict !== "idle" && evaluation.verdict !== "not_running";
88
+ }
89
+ export function idleStatusJson(evaluation, deps, localYield) {
90
+ return {
91
+ schemaVersion: 1,
92
+ verdict: evaluation.verdict,
93
+ idle: evaluation.verdict === "idle",
94
+ exitCode: evaluation.exitCode,
95
+ reason: evaluation.reason,
96
+ statePath: deps.statePath,
97
+ checkedAt: new Date(deps.now()).toISOString(),
98
+ pidAlive: evaluation.pidAlive,
99
+ heartbeatAgeMs: evaluation.heartbeatAgeMs,
100
+ staleAfterMs: evaluation.staleAfterMs,
101
+ localYield,
102
+ ...publishedStateFields(evaluation.state),
103
+ };
104
+ }
105
+ function publishedStateFields(state) {
106
+ if (!state) {
107
+ return {
108
+ pid: null, runnerId: null, runnerInstanceId: null, version: null, state: null, startedAt: null,
109
+ updatedAt: null, connected: null, yielding: null, yieldApplied: null, conflict: null, inFlight: [],
110
+ };
111
+ }
112
+ return {
113
+ pid: state.pid,
114
+ runnerId: state.runnerId,
115
+ runnerInstanceId: state.runnerInstanceId,
116
+ version: state.version,
117
+ state: state.state,
118
+ startedAt: state.startedAt,
119
+ updatedAt: state.updatedAt,
120
+ connected: state.connected,
121
+ yielding: state.yielding,
122
+ yieldApplied: state.yieldApplied ?? state.yielding,
123
+ conflict: state.conflict ?? null,
124
+ inFlight: state.inFlight,
125
+ };
126
+ }
127
+ const verdictTitles = {
128
+ idle: "Bridge idle",
129
+ busy: "Bridge busy",
130
+ not_yielding: "Bridge idle but not yielding",
131
+ stale: "Bridge state stale",
132
+ unknown: "Bridge state unknown",
133
+ not_running: "Bridge not running",
134
+ };
135
+ function idleStatusText(evaluation, deps, localYield) {
136
+ const state = evaluation.state;
137
+ const lines = [`${verdictTitles[evaluation.verdict]}: ${evaluation.reason}`, `State file: ${deps.statePath}`];
138
+ if (state) {
139
+ lines.push(`Process: pid ${state.pid} (${evaluation.pidAlive ? "running" : "not running"}), runner ${state.runnerId || "unknown"}, instance ${state.runnerInstanceId}, bridge ${state.version}`, `Heartbeat: ${state.updatedAt} (${formatAge(evaluation.heartbeatAgeMs ?? Number.NaN)} ago, stale after ${formatAge(evaluation.staleAfterMs)}); connected to Forge: ${state.connected ? "yes" : "no"}`, `Yield: ${yieldLine(state)} (local flag ${localYield ? "on" : "off"})`);
140
+ lines.push(...inFlightLines(state.inFlight, deps.now()));
141
+ }
142
+ lines.push(nextStep(evaluation, localYield));
143
+ return `${lines.join("\n")}\n`;
144
+ }
145
+ function inFlightLines(entries, now) {
146
+ if (entries.length === 0)
147
+ return ["In flight: nothing"];
148
+ return ["In flight:", ...entries.map(entry => {
149
+ const phaseAge = entry.phaseSince ? ` for ${formatAge(now - Date.parse(entry.phaseSince))}` : "";
150
+ const since = entry.since ? `, since ${entry.since}` : "";
151
+ return ` - ${entry.kind}: phase ${entry.phase}${phaseAge}${since}; ${describeInFlightIds(entry.ids)}`;
152
+ })];
153
+ }
154
+ function nextStep(evaluation, localYield) {
155
+ switch (evaluation.verdict) {
156
+ case "idle":
157
+ return evaluation.state?.yielding ? "Safe to restart now. After the new bridge connects, run `forge-bridge yield off` so it takes work again." : idleWithoutYieldStep(localYield);
158
+ case "not_yielding":
159
+ return evaluation.state?.yieldApplied
160
+ ? "The bridge applies yield but Forge has not acknowledged it yet (at most one heartbeat). Check again before restarting."
161
+ : idleWithoutYieldStep(localYield);
162
+ case "busy":
163
+ return "Do not restart. Run `forge-bridge yield on`, then `forge-bridge status --idle --require-yield --wait <seconds>` until it exits 0.";
164
+ case "not_running":
165
+ return "Nothing to interrupt, but confirm no other bridge process serves this runner before starting one.";
166
+ default:
167
+ return "Do not restart on this result: idle could not be confirmed.";
168
+ }
169
+ }
170
+ function yieldLine(state) {
171
+ if (state.yielding)
172
+ return "on and acknowledged by Forge, no new attempts";
173
+ return state.yieldApplied ? "applied, waiting for Forge to acknowledge it" : "off, Forge can still send new work";
174
+ }
175
+ // The bridge's own report is what counts: a flag written from another environment
176
+ // (another user, FORGE_BRIDGE_CONFIG, or a sandbox that virtualizes %APPDATA%) never reaches it.
177
+ function idleWithoutYieldStep(localYield) {
178
+ return localYield
179
+ ? "The local yield flag is on but the bridge has not reported yield yet. It picks the flag up within one heartbeat; if it never does, this flag file is not the one the bridge reads. Check again before restarting."
180
+ : "Idle now, but yield is off: run `forge-bridge yield on` and check again with --require-yield so no new work starts before the restart.";
181
+ }
@@ -7,6 +7,9 @@ export interface BridgeLocalConfig {
7
7
  readonly deviceName?: string;
8
8
  readonly defaultRepoRoot?: string;
9
9
  readonly cleanupWorktrees?: boolean;
10
+ readonly dockerEnabled?: boolean;
11
+ readonly dockerDesktopRecoveryEnabled?: boolean;
12
+ readonly allowOpenPublicSandbox?: boolean;
10
13
  readonly cliProviders?: readonly string[];
11
14
  readonly providerStatuses?: Readonly<Record<string, BridgeProviderStatus>>;
12
15
  readonly projectLabels?: readonly string[];
@@ -17,6 +20,8 @@ export interface BridgeLocalConfig {
17
20
  readonly supportsManagedForgeArtifacts?: boolean;
18
21
  readonly supportsRunnerAuthoredPhaseArtifacts?: boolean;
19
22
  readonly supportsDraftRunOnce?: boolean;
23
+ readonly supportsDraftAttachments?: boolean;
24
+ readonly supportsDraftImageAttachments?: boolean;
20
25
  }
21
26
  export interface LocalRepoMapping extends BridgeRepoMapping {
22
27
  readonly label: string;
@@ -25,11 +30,19 @@ export interface LocalRepoMapping extends BridgeRepoMapping {
25
30
  export declare function resolveLocalConfigPath(): string;
26
31
  export declare function readLocalConfig(): Promise<BridgeLocalConfig>;
27
32
  export declare function readLocalConfigSync(): BridgeLocalConfig;
33
+ /** Decision 0014 §5: `bridge.json` holds the device token, so only its owner may read it. */
34
+ export declare const localConfigFileMode = 384;
28
35
  export declare function writeLocalConfig(config: BridgeLocalConfig): Promise<void>;
29
36
  export declare function applyLocalConfigDefaults(config: BridgeServiceConfig, local: BridgeLocalConfig): BridgeServiceConfig;
37
+ /** Where `forge-bridge connect` publishes whether it is idle: `bridge.state.json` beside the config. */
38
+ export declare function resolveBridgeStatePath(): string;
39
+ /** Decision 0014: the `forge-bridge yield` flag, beside the bridge config and never inside it. */
40
+ export declare function resolveLocalYieldFlagPath(): string;
30
41
  export declare function addRepoMapping(label: string, repoPath: string): Promise<BridgeLocalConfig>;
31
42
  export declare function removeRepoMapping(label: string): Promise<{
32
43
  readonly config: BridgeLocalConfig;
33
44
  readonly removed: boolean;
34
45
  }>;
46
+ export declare function setServerUrl(serverUrl: string): Promise<BridgeLocalConfig>;
47
+ export declare function setSandboxPolicy(dockerEnabled: boolean, allowOpenPublicSandbox: boolean): Promise<BridgeLocalConfig>;
35
48
  export declare function providerStatusesFor(providers: readonly string[]): Readonly<Record<string, BridgeProviderStatus>>;
@@ -2,6 +2,8 @@ import fs from "node:fs/promises";
2
2
  import fsSync from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
+ import { localYieldFlagPathFor } from "../bridge/local-yield-flag.js";
6
+ import { bridgeStatePathFor } from "../bridge/bridge-state-file.js";
5
7
  export function resolveLocalConfigPath() {
6
8
  if (process.env.FORGE_BRIDGE_CONFIG?.trim()) {
7
9
  return path.resolve(process.env.FORGE_BRIDGE_CONFIG);
@@ -28,12 +30,28 @@ export function readLocalConfigSync() {
28
30
  }
29
31
  return parseLocalConfig(fsSync.readFileSync(configPath, "utf8"));
30
32
  }
33
+ /** Decision 0014 §5: `bridge.json` holds the device token, so only its owner may read it. */
34
+ export const localConfigFileMode = 0o600;
35
+ const localConfigDirectoryMode = 0o700;
31
36
  export async function writeLocalConfig(config) {
32
37
  const configPath = resolveLocalConfigPath();
33
- await fs.mkdir(path.dirname(configPath), { recursive: true });
38
+ await fs.mkdir(path.dirname(configPath), { recursive: true, mode: localConfigDirectoryMode });
34
39
  const tempPath = `${configPath}.${process.pid}.${Date.now()}.tmp`;
35
- await fs.writeFile(tempPath, `${JSON.stringify(normalizeLocalConfig(config), null, 2)}\n`, "utf8");
36
- await fs.rename(tempPath, configPath);
40
+ try {
41
+ await fs.writeFile(tempPath, `${JSON.stringify(normalizeLocalConfig(config), null, 2)}\n`, {
42
+ encoding: "utf8",
43
+ mode: localConfigFileMode
44
+ });
45
+ if (process.platform !== "win32") {
46
+ // The create mode is masked by the umask; set it exactly before the file becomes visible.
47
+ await fs.chmod(tempPath, localConfigFileMode);
48
+ }
49
+ await fs.rename(tempPath, configPath);
50
+ }
51
+ catch (error) {
52
+ await fs.rm(tempPath, { force: true }).catch(() => undefined);
53
+ throw error;
54
+ }
37
55
  }
38
56
  export function applyLocalConfigDefaults(config, local) {
39
57
  const cliProviders = local.cliProviders && local.cliProviders.length > 0 ? [...local.cliProviders] : config.cliProviders;
@@ -45,6 +63,15 @@ export function applyLocalConfigDefaults(config, local) {
45
63
  deviceName: process.env.FORGE_DEVICE_NAME ?? local.deviceName ?? config.deviceName,
46
64
  defaultRepoRoot: process.env.FORGE_REPO_ROOT ?? local.defaultRepoRoot ?? config.defaultRepoRoot,
47
65
  cleanupWorktrees: local.cleanupWorktrees ?? config.cleanupWorktrees,
66
+ dockerEnabled: process.env.FORGE_DOCKER_SANDBOX === undefined
67
+ ? local.dockerEnabled ?? config.dockerEnabled
68
+ : config.dockerEnabled,
69
+ dockerDesktopRecoveryEnabled: process.env.FORGE_DOCKER_DESKTOP_AUTO_RECOVERY === undefined
70
+ ? local.dockerDesktopRecoveryEnabled ?? config.dockerDesktopRecoveryEnabled
71
+ : config.dockerDesktopRecoveryEnabled,
72
+ allowOpenPublicSandbox: process.env.FORGE_ALLOW_OPEN_PUBLIC_SANDBOX === undefined
73
+ ? local.allowOpenPublicSandbox ?? config.allowOpenPublicSandbox
74
+ : config.allowOpenPublicSandbox,
48
75
  cliProviders,
49
76
  providerStatuses: normalizeProviderStatuses(local.providerStatuses) ?? providerStatusesFor(cliProviders),
50
77
  projectLabels: local.projectLabels ?? config.projectLabels,
@@ -54,9 +81,21 @@ export function applyLocalConfigDefaults(config, local) {
54
81
  supportsManagedWorktrees: local.supportsManagedWorktrees ?? config.supportsManagedWorktrees,
55
82
  supportsManagedForgeArtifacts: local.supportsManagedForgeArtifacts ?? config.supportsManagedForgeArtifacts,
56
83
  supportsRunnerAuthoredPhaseArtifacts: local.supportsRunnerAuthoredPhaseArtifacts ?? config.supportsRunnerAuthoredPhaseArtifacts,
57
- supportsDraftRunOnce: local.supportsDraftRunOnce ?? config.supportsDraftRunOnce
84
+ supportsDraftRunOnce: local.supportsDraftRunOnce ?? config.supportsDraftRunOnce,
85
+ supportsDraftAttachments: local.supportsDraftAttachments ?? config.supportsDraftAttachments,
86
+ supportsDraftImageAttachments: local.supportsDraftImageAttachments ?? config.supportsDraftImageAttachments,
87
+ localYieldFlagPath: resolveLocalYieldFlagPath(),
88
+ bridgeStatePath: resolveBridgeStatePath()
58
89
  };
59
90
  }
91
+ /** Where `forge-bridge connect` publishes whether it is idle: `bridge.state.json` beside the config. */
92
+ export function resolveBridgeStatePath() {
93
+ return bridgeStatePathFor(resolveLocalConfigPath());
94
+ }
95
+ /** Decision 0014: the `forge-bridge yield` flag, beside the bridge config and never inside it. */
96
+ export function resolveLocalYieldFlagPath() {
97
+ return localYieldFlagPathFor(resolveLocalConfigPath());
98
+ }
60
99
  export async function addRepoMapping(label, repoPath) {
61
100
  const normalizedLabel = normalizeLabel(label);
62
101
  const localPath = path.resolve(repoPath);
@@ -86,6 +125,19 @@ export async function removeRepoMapping(label) {
86
125
  await writeLocalConfig(next);
87
126
  return { config: next, removed: after.length !== before.length };
88
127
  }
128
+ export async function setServerUrl(serverUrl) {
129
+ const normalized = normalizeServerUrl(serverUrl);
130
+ const current = await readLocalConfig();
131
+ const next = normalizeLocalConfig({ ...current, serverUrl: normalized });
132
+ await writeLocalConfig(next);
133
+ return next;
134
+ }
135
+ export async function setSandboxPolicy(dockerEnabled, allowOpenPublicSandbox) {
136
+ const current = await readLocalConfig();
137
+ const next = normalizeLocalConfig({ ...current, dockerEnabled, allowOpenPublicSandbox });
138
+ await writeLocalConfig(next);
139
+ return next;
140
+ }
89
141
  export function providerStatusesFor(providers) {
90
142
  return Object.fromEntries(providers.map((provider) => [provider, { signedIn: true, version: "", models: configuredModelsFor(provider) }]));
91
143
  }
@@ -104,6 +156,9 @@ function normalizeLocalConfig(config) {
104
156
  deviceName: cleanString(config.deviceName),
105
157
  defaultRepoRoot: cleanString(config.defaultRepoRoot),
106
158
  cleanupWorktrees: config.cleanupWorktrees,
159
+ dockerEnabled: config.dockerEnabled,
160
+ dockerDesktopRecoveryEnabled: config.dockerDesktopRecoveryEnabled,
161
+ allowOpenPublicSandbox: config.allowOpenPublicSandbox,
107
162
  cliProviders: cleanList(config.cliProviders),
108
163
  providerStatuses: normalizeProviderStatuses(config.providerStatuses),
109
164
  projectLabels: cleanList(config.projectLabels),
@@ -113,7 +168,9 @@ function normalizeLocalConfig(config) {
113
168
  supportsManagedWorktrees: config.supportsManagedWorktrees,
114
169
  supportsManagedForgeArtifacts: config.supportsManagedForgeArtifacts,
115
170
  supportsRunnerAuthoredPhaseArtifacts: config.supportsRunnerAuthoredPhaseArtifacts,
116
- supportsDraftRunOnce: config.supportsDraftRunOnce
171
+ supportsDraftRunOnce: config.supportsDraftRunOnce,
172
+ supportsDraftAttachments: config.supportsDraftAttachments,
173
+ supportsDraftImageAttachments: config.supportsDraftImageAttachments
117
174
  };
118
175
  }
119
176
  function emptyConfig() {
@@ -196,10 +253,11 @@ function normalizeQaAppLaunchTarget(value) {
196
253
  command: cleanString(value.command),
197
254
  working_directory: cleanString(value.working_directory),
198
255
  ready_url: cleanString(value.ready_url),
256
+ managed_runtime_port: cleanString(value.managed_runtime_port),
199
257
  routes,
200
258
  notes: cleanString(value.notes)
201
259
  };
202
- return normalized.url || normalized.command || normalized.ready_url || routes?.length
260
+ return normalized.url || normalized.command || normalized.ready_url || normalized.managed_runtime_port
203
261
  ? normalized
204
262
  : undefined;
205
263
  }
@@ -207,6 +265,24 @@ function cleanString(value) {
207
265
  const clean = value?.trim();
208
266
  return clean ? clean : undefined;
209
267
  }
268
+ function normalizeServerUrl(value) {
269
+ const clean = value.trim();
270
+ let parsed;
271
+ try {
272
+ parsed = new URL(clean);
273
+ }
274
+ catch {
275
+ throw new Error(`Invalid Forge server URL: ${value}`);
276
+ }
277
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
278
+ throw new Error("Forge server URL must use http or https.");
279
+ }
280
+ if (parsed.username || parsed.password || parsed.search || parsed.hash) {
281
+ throw new Error("Forge server URL cannot include credentials, a query string, or a fragment.");
282
+ }
283
+ parsed.pathname = parsed.pathname.replace(/\/+$/u, "") || "/";
284
+ return parsed.toString().replace(/\/$/u, "");
285
+ }
210
286
  function cleanList(values) {
211
287
  const clean = [...new Set((values ?? []).map((value) => value.trim()).filter(Boolean))];
212
288
  return clean.length > 0 ? clean : undefined;
@@ -0,0 +1,10 @@
1
+ export interface CliProviderDetection {
2
+ readonly provider: string;
3
+ readonly found: boolean;
4
+ readonly version: string;
5
+ readonly models: readonly string[];
6
+ }
7
+ export declare function detectCliProviders(providers: readonly string[]): Promise<CliProviderDetection[]>;
8
+ export declare const claudeDefaultModels: readonly string[];
9
+ export declare function parseCodexModelCatalog(raw: string): string[];
10
+ export declare function parseCursorModelList(raw: string): string[];
@@ -0,0 +1,160 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { resolveCursorAgentDirectLaunch } from "../shared/cursor-agent/cursor-agent.launch.js";
4
+ import { buildWindowsCmdLaunch } from "../shared/process/windows-launch.js";
5
+ // Provider CLI detection probes for `forge-bridge status`, `connect` and `pair`: which
6
+ // provider CLIs are installed, their versions and the models they list. Split out of
7
+ // cli.service.ts (file-size inventory plan).
8
+ const execFileAsync = promisify(execFile);
9
+ export async function detectCliProviders(providers) {
10
+ const results = [];
11
+ for (const provider of providers) {
12
+ let detected = null;
13
+ for (const probe of cliProbeCommandsFor(provider)) {
14
+ try {
15
+ detected = await execVersionCommand(probe, probe.timeoutMs);
16
+ break;
17
+ }
18
+ catch {
19
+ // Try the next provider-specific probe.
20
+ }
21
+ }
22
+ results.push({
23
+ provider,
24
+ found: detected !== null,
25
+ version: detected ? versionLine(`${detected.stdout || detected.stderr}`) : "",
26
+ models: detected ? await detectCliModels(provider) : []
27
+ });
28
+ }
29
+ return results;
30
+ }
31
+ function cliProbeCommandsFor(provider) {
32
+ const normalized = provider.toLowerCase();
33
+ if (normalized === "codex") {
34
+ return [
35
+ { command: "codex", args: ["-V"] },
36
+ { command: "codex", args: ["--version"] }
37
+ ];
38
+ }
39
+ if (normalized === "claude") {
40
+ return [
41
+ // Claude Code's Node startup can exceed the default 2s probe on a cold Windows host.
42
+ { command: "claude", args: ["--version"], timeoutMs: 8000 },
43
+ { command: "claude", args: ["-v"], timeoutMs: 8000 }
44
+ ];
45
+ }
46
+ if (normalized === "cursor") {
47
+ return [
48
+ { command: "cursor-agent", args: ["-v"] },
49
+ { command: "agent", args: ["-v"] },
50
+ { command: "cursor-agent", args: ["--version"] },
51
+ { command: "agent", args: ["--version"] }
52
+ ];
53
+ }
54
+ return [
55
+ { command: provider, args: ["--version"] },
56
+ { command: provider, args: ["-V"] }
57
+ ];
58
+ }
59
+ async function execVersionCommand(probe, timeout = 2000, maxBuffer) {
60
+ const directLaunch = process.platform === "win32"
61
+ ? await resolveCursorAgentDirectLaunch(probe.command, probe.args)
62
+ : null;
63
+ if (directLaunch) {
64
+ return await execFileAsync(directLaunch.command, [...directLaunch.args], { timeout, maxBuffer });
65
+ }
66
+ try {
67
+ return await execFileAsync(probe.command, probe.args, { timeout, maxBuffer });
68
+ }
69
+ catch (error) {
70
+ if (process.platform !== "win32") {
71
+ throw error;
72
+ }
73
+ const launch = buildWindowsCmdLaunch(probe.command, probe.args);
74
+ return await execFileAsync(launch.command, [...launch.args], { timeout, maxBuffer });
75
+ }
76
+ }
77
+ function versionLine(output) {
78
+ const lines = output
79
+ .trim()
80
+ .split(/\r?\n/)
81
+ .map((line) => line.trim())
82
+ .filter((line) => line.length > 0);
83
+ return lines.at(-1) ?? "";
84
+ }
85
+ async function detectCliModels(provider) {
86
+ const normalized = provider.toLowerCase();
87
+ try {
88
+ if (normalized === "codex") {
89
+ // Windows installs codex as a .cmd shim, which execFile cannot launch directly.
90
+ const result = await execVersionCommand({ command: "codex", args: ["debug", "models"] }, 10_000, 10 * 1024 * 1024);
91
+ return parseCodexModelCatalog(result.stdout);
92
+ }
93
+ if (normalized === "cursor") {
94
+ const result = await execVersionCommand({ command: "cursor-agent", args: ["models"] }, 10_000);
95
+ return parseCursorModelList(`${result.stdout || result.stderr}`);
96
+ }
97
+ if (normalized === "claude") {
98
+ // Claude Code has no model-listing command; it accepts these aliases and full model IDs.
99
+ const configured = (process.env.FORGE_CLAUDE_MODELS ?? "").split(",").map(model => model.trim()).filter(Boolean);
100
+ return configured.length > 0 ? configured : [...claudeDefaultModels];
101
+ }
102
+ }
103
+ catch {
104
+ return [];
105
+ }
106
+ return [];
107
+ }
108
+ export const claudeDefaultModels = ["sonnet", "opus", "haiku"];
109
+ export function parseCodexModelCatalog(raw) {
110
+ try {
111
+ const parsed = JSON.parse(raw);
112
+ if (!isRecord(parsed) || !Array.isArray(parsed.models)) {
113
+ return [];
114
+ }
115
+ const entries = parsed.models
116
+ .map((entry, index) => {
117
+ if (!isRecord(entry) || typeof entry.slug !== "string") {
118
+ return null;
119
+ }
120
+ const visibility = typeof entry.visibility === "string" ? entry.visibility.toLowerCase() : "list";
121
+ if (visibility !== "list") {
122
+ return null;
123
+ }
124
+ const priority = typeof entry.priority === "number" && Number.isFinite(entry.priority) ? entry.priority : index;
125
+ return { slug: entry.slug, priority, index };
126
+ })
127
+ .filter((entry) => entry !== null)
128
+ .sort((left, right) => left.priority - right.priority || left.index - right.index)
129
+ .map((entry) => entry.slug);
130
+ return uniqueModels(entries);
131
+ }
132
+ catch {
133
+ return [];
134
+ }
135
+ }
136
+ export function parseCursorModelList(raw) {
137
+ return uniqueModels(raw
138
+ .split(/\r?\n/)
139
+ .map((line) => line.trim())
140
+ .filter((line) => line.length > 0 && !line.toLowerCase().startsWith("available models"))
141
+ .map((line) => line.split(/\s+-\s+/, 1)[0]?.trim() ?? "")
142
+ .filter((model) => model.length > 0));
143
+ }
144
+ function uniqueModels(models) {
145
+ const seen = new Set();
146
+ const result = [];
147
+ for (const model of models) {
148
+ const trimmed = model.trim();
149
+ const key = trimmed.toLowerCase();
150
+ if (!trimmed || seen.has(key)) {
151
+ continue;
152
+ }
153
+ seen.add(key);
154
+ result.push(trimmed);
155
+ }
156
+ return result;
157
+ }
158
+ function isRecord(value) {
159
+ return typeof value === "object" && value !== null;
160
+ }
@@ -0,0 +1,41 @@
1
+ import type { AttemptProcessSupervisor } from "./attempt-process-supervisor.js";
2
+ export interface AspNetRuntimePrebuildPlan {
3
+ readonly fingerprint: string;
4
+ readonly receiptPath: string;
5
+ readonly command: string;
6
+ readonly args: readonly string[];
7
+ readonly cwd: string;
8
+ readonly environment: Readonly<Record<string, string>>;
9
+ readonly projectPath: string;
10
+ readonly worktreePath: string;
11
+ readonly inputCommitSha: string;
12
+ }
13
+ export interface AspNetRuntimePrebuildResult {
14
+ readonly cacheHit: boolean;
15
+ readonly receiptPath: string;
16
+ readonly fingerprint: string;
17
+ }
18
+ export interface AspNetRuntimeBuildExecutionResult {
19
+ readonly exitCode: number;
20
+ readonly stdoutTail: string;
21
+ readonly stderrTail: string;
22
+ readonly stdoutLogPath: string;
23
+ readonly stderrLogPath: string;
24
+ }
25
+ export type AspNetRuntimeBuildExecutor = (plan: AspNetRuntimePrebuildPlan, signal?: AbortSignal) => Promise<AspNetRuntimeBuildExecutionResult>;
26
+ /** Runs one ASP.NET runtime build under the attempt's supervisor, logging only redacted output. */
27
+ export declare function executeAspNetRuntimeBuild(supervisor: AttemptProcessSupervisor, logDirectory: string, plan: AspNetRuntimePrebuildPlan, signal?: AbortSignal, exactSecrets?: readonly string[],
28
+ /** Once the build's supervised tree is up: records it on the build's host load token. */
29
+ onStarted?: (metadataPath: string) => Promise<void>): Promise<AspNetRuntimeBuildExecutionResult>;
30
+ export declare function createAspNetRuntimePrebuildPlan(options: {
31
+ readonly command: string;
32
+ readonly args: readonly string[];
33
+ readonly cwd: string;
34
+ readonly worktreePath: string;
35
+ readonly environment?: Readonly<Record<string, string>>;
36
+ readonly inputCommitSha: string;
37
+ readonly runtimeContractFingerprint: string;
38
+ }): AspNetRuntimePrebuildPlan | null;
39
+ export declare function ensureAspNetRuntimePrebuilt(plan: AspNetRuntimePrebuildPlan, execute: AspNetRuntimeBuildExecutor, signal?: AbortSignal): Promise<AspNetRuntimePrebuildResult>;
40
+ export declare function withAspNetPrebuiltRunArguments(command: string, args: readonly string[]): readonly string[];
41
+ export declare function resolveWorktreeCommitSha(worktreePath: string, supplied?: string | null): Promise<string>;