@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
package/README.md CHANGED
@@ -23,6 +23,16 @@ forge-bridge status
23
23
  forge-bridge connect --server <forge-url> --runner-id <runner-id> --device-token <device-token>
24
24
  ```
25
25
 
26
+ To pair, open **Settings → Runners → Connect a bridge** in Forge and run the command it shows:
27
+
28
+ ```bash
29
+ forge-bridge pair <code> --server <forge-url>
30
+ ```
31
+
32
+ The runner name, provider CLIs and repo folder chosen in that dialog come back with the claim
33
+ and are saved to `bridge.json`; `--repo-root` and `--cli-provider` on the command line win over
34
+ them. `bridge.json` holds the device token, so the bridge writes it with mode `0600`.
35
+
26
36
  The bridge can also read connection settings from environment variables:
27
37
 
28
38
  - `FORGE_URL`
@@ -45,7 +55,7 @@ a parent containing unrelated maintenance checkouts and generated projects.
45
55
 
46
56
  ## Provider CLIs
47
57
 
48
- The bridge auto-detects these provider CLIs on `PATH` and advertises the ones it finds:
58
+ The bridge auto-detects these provider CLIs on `PATH` and advertises the ones it finds. `pair` and every `connect` probe all of them, not only the providers saved in `bridge.json`, so a CLI installed after pairing is advertised on the next `connect`. A saved provider whose CLI is no longer found stays advertised; detection only adds providers. Advertising cursor doesn't make it runnable: the bridge still refuses to launch it, because Forge can't keep `cursor-agent`'s own configuration out of the session.
49
59
 
50
60
  | Provider | CLI | Sign-in | Headless invocation |
51
61
  | --- | --- | --- | --- |
@@ -55,11 +65,13 @@ The bridge auto-detects these provider CLIs on `PATH` and advertises the ones it
55
65
 
56
66
  Claude Code notes:
57
67
 
58
- - Install with the native installer or `npm install -g @anthropic-ai/claude-code`. On Windows, Claude Code needs Git for Windows; set `CLAUDE_CODE_GIT_BASH_PATH` if `bash.exe` is not on `PATH`. `CLAUDE_CONFIG_DIR` is passed through if you keep config outside `~/.claude`.
68
+ - Install with the native installer or `npm install -g @anthropic-ai/claude-code`. On Windows, Claude Code needs Git for Windows; set `CLAUDE_CODE_GIT_BASH_PATH` if `bash.exe` is not on `PATH`. Forge doesn't pass `CLAUDE_CONFIG_DIR` to Claude Code, so it signs in from `~/.claude` (`%USERPROFILE%\.claude` on Windows) or with an Anthropic API key Forge grants; sign in there, not in a custom config directory.
59
69
  - Forge pipes the prompt on stdin, runs with `--permission-mode bypassPermissions` inside the managed worktree, and registers its completion MCP server through a temporary `--mcp-config` file outside the worktree with `--strict-mcp-config`, so user-level MCP servers are not loaded into unattended runs. Forge tools appear to the model as `mcp__forge__<tool>`.
60
70
  - Claude Code has no model-listing command, so the bridge advertises the `sonnet`, `opus`, and `haiku` aliases. Set `FORGE_CLAUDE_MODELS` to advertise specific model ids instead.
61
71
  - Claude runs in host mode only. Docker sandbox placement currently supports Codex only.
62
72
 
73
+ On Windows the bridge's `bash` capability is Git for Windows' `bash.exe`, resolved to an absolute path: `FORGE_BRIDGE_BASH_PATH` (then `CLAUDE_CODE_GIT_BASH_PATH`) if set, otherwise the Git install found from `git --exec-path` or `git.exe` on `PATH`, then `bash.exe` on `PATH`, then the standard Program Files locations. WSL's `System32\bash.exe` and Store aliases are never accepted. A bare `bash` is not used because Windows' executable search checks the current directory before `PATH`, and a scheduled task with no working directory starts in `System32`.
74
+
63
75
  Show or change the saved server without editing `bridge.json`:
64
76
 
65
77
  ```bash
@@ -129,6 +141,157 @@ enters a ten-minute cooldown after an unsuccessful attempt. Remote `DOCKER_HOST`
129
141
  restarted. Operators can tune the bounded policy with `FORGE_DOCKER_RECOVERY_FAILURE_THRESHOLD`,
130
142
  `FORGE_DOCKER_RECOVERY_COOLDOWN_MS`, and `FORGE_DOCKER_RECOVERY_STARTUP_TIMEOUT_MS`.
131
143
 
144
+ ## Runner limits and yield
145
+
146
+ Forge owns each runner's limits (Settings → Runners → Limits) and pushes them to the bridge, which
147
+ applies them without a restart and without stopping admitted work: max attempts and the memory reserve
148
+ apply at the next attempt admission, the CPU budget, yield budget and max heavy steps at the next heavy
149
+ step. Host env vars only bound the server's values and are reported back to Forge: a ceiling on
150
+ capacity (`FORGE_HOST_MAX_CONCURRENT_ATTEMPTS`, `FORGE_HOST_CPU_BUDGET_PERCENT`,
151
+ `FORGE_HOST_LOAD_CPU_BUDGET_FRACTION`, `FORGE_HOST_MAX_HEAVY_STEPS`) and a floor on the reserve
152
+ (`FORGE_HOST_MEMORY_RESERVE_BYTES`). Without a server value, the env var or the bridge default applies.
153
+ The CPU budget, yield budget and heavy-step limit take effect only with `FORGE_HOST_LOAD_GOVERNOR=on`.
154
+ They gate on Linux PSI. Windows has no PSI, so a Windows bridge estimates CPU pressure from whole-host
155
+ CPU use and reports it with `pressureSource: "windows_estimate"` (decision 0021). Forge's Load column
156
+ and the budgets then work there too. Without either signal, the governor falls back to one heavy step at a time.
157
+
158
+ Two or more attempts on one host take turns at the host test slot (decision 0018): builds, test runs,
159
+ Playwright, pre-publication checks and the ASP.NET runtime build each wait for it in one host-wide queue,
160
+ foreground first, then first come, first served, across the bridge and every completion MCP server. Plain
161
+ managed commands and dependency installs never wait for it. A waiting step reports who holds the slot
162
+ (`prepublication_host_capacity_waiting`, `host_runtime_build_waiting_for_host_capacity`, or
163
+ `host_load_wait_detail` on a managed command's receipt), and its own timeout starts only once it runs.
164
+ A holder that crashes or stalls keeps the slot only until the host load ledger takes its token back (its
165
+ process tree stopped, its lease fenced, or attempt teardown).
166
+
167
+ How many run at once is sized from the host, with nothing to set: `min(floor((CPUs - reserve) / 6),
168
+ floor((memory - reserve) / 4 GiB))`, from 1 to 4, where the reserve kept for the system and the person using
169
+ the machine is a quarter of the CPUs (at least 2) and a quarter of the memory (at least 4 GiB). One heavy step
170
+ is planned at 6 cores and 4 GiB: a Forge .NET suite averages about 1.6 cores with peaks well above, and about
171
+ 2.2 GB for the test host and its PostgreSQL. A 24-CPU, 64 GB host runs 3; an 8-CPU, 16 GB or a 4-CPU, 8 GB host
172
+ runs 1. A bridge under a CPU quota or memory limit (a systemd unit, a container, a pod) is sized within it.
173
+ While the bridge runs, the count drops when other work on the machine needs it (two readings in a
174
+ row, about 10 seconds) and comes back one slot at a time after the host has stayed clear for 2 minutes;
175
+ running steps are never stopped. Each reading is judged with the heavy steps running when it was taken, so
176
+ suites that have since finished are not other work. Without a measured Forge share (Windows, or no
177
+ dedicated cgroup), CPU never lowers the count while a heavy step runs (one build can use every core), and
178
+ each running step is taken to use at least its planned memory. On macOS, whose free-memory figure leaves
179
+ out inactive and purgeable memory, memory readings are not used. The bridge and every completion MCP
180
+ server admit against the lowest count any of them has in force; a lowered count lapses 90 seconds after
181
+ its governor stops reading the host, and is ignored once its process exits. With more than one slot, each step gets
182
+ `FORGE_TEST_MAX_PARALLEL_CLASSES` for its share of the
183
+ machine unless it is already set. The bridge logs the count and how it was chosen at startup (`Host test
184
+ slots: …`), and a waiting step says when the count is lowered and why. `FORGE_HOST_LOAD_TEST_SLOTS` is the
185
+ operator's override (`0` turns the slot off; live adjustment only lowers it), and
186
+ `FORGE_HOST_LOAD_LIVE_SLOTS=off` turns live adjustment off.
187
+
188
+ Yield this machine to foreground work (for example while gaming) from the host itself:
189
+
190
+ ```bash
191
+ forge-bridge yield on
192
+ forge-bridge yield status
193
+ forge-bridge yield off
194
+ ```
195
+
196
+ While yielding, the bridge takes no new attempts and heavy steps of running attempts use the yield CPU
197
+ budget. Yield is on when this local flag or the runner's Yield toggle in Forge is on. The flag is stored
198
+ in `bridge.yield.json` next to `bridge.json`, and a running bridge notices it within one heartbeat.
199
+
200
+ ## Restarting or updating the bridge safely
201
+
202
+ Restarting `forge-bridge connect` kills everything it is running, including work that has no agent
203
+ process yet: an accepted offer waiting for Start, host-runtime admission, worktree and dependency
204
+ preparation, prepared-runtime probes, pre-publication validation and teardown. Forge then records the
205
+ attempt's outcome as unknown. Checking for agent processes is not enough, so the running bridge
206
+ publishes its in-flight work to `bridge.state.json` next to `bridge.json` (pid, runner instance, a
207
+ heartbeat refreshed every 5 seconds, and each in-flight item with its ids, phase and start time), and
208
+ `forge-bridge status --idle` reads it. Each bridge reads and rewrites the file while it holds a lock
209
+ the operating system owns and frees when the bridge exits (an abstract socket on Linux, a named pipe
210
+ on Windows, a flock on `bridge.state.json.lock` on macOS), so a second bridge on the same config always
211
+ sees the first one's record and reports the conflict, and a stopping bridge never writes its "stopped"
212
+ record over a newer bridge's. A bridge that can't publish (a failed write, or the lock held by another
213
+ process for more than 5 seconds) leaves `bridge.state.json.unpublished.<id>.json` instead of touching
214
+ the shared record, and a record missing any field reads as unknown, so neither can read as idle:
215
+
216
+ | Exit code | Verdict | Meaning |
217
+ |---:|---|---|
218
+ | 0 | `idle` | A live bridge reported a fresh heartbeat with nothing in flight. |
219
+ | 1 | `busy` | Work is in flight; restarting now would kill it. |
220
+ | 2 | | Usage error. |
221
+ | 3 | `stale` / `unknown` | Old heartbeat (hung bridge or reused pid), missing or unreadable state file, two bridge processes publishing to one config, or the bridge is shutting down. Idle can't be confirmed. A bridge older than this check writes no state file, so it reads as `unknown`. |
222
+ | 4 | `not_running` | The recorded bridge process has exited. Nothing to interrupt, but it is not an idle report. |
223
+ | 5 | `not_yielding` | With `--require-yield`: nothing in flight, but Forge has not acknowledged yield from this bridge, so placement can still pick it. |
224
+
225
+ `--json` prints the verdict, the reason, the heartbeat age, the pid check, the yield state (`yielding`:
226
+ acknowledged by Forge; `yieldApplied`: applied by the bridge) and the in-flight list. `--wait <seconds>`
227
+ keeps checking until the bridge is idle, its process has exited, or the time is up, so a file briefly
228
+ held by antivirus or the indexer doesn't end the wait; `--wait 0` checks once, like no `--wait`.
229
+ Against a bridge older than this check (no state file) it waits out the full time; check once without
230
+ `--wait` first.
231
+
232
+ What yield does and doesn't stop:
233
+
234
+ - It stops new attempts: the bridge refuses Offers while yielding (Forge re-places them), and Forge
235
+ stops placing work on the runner once it has acknowledged the yield (the next heartbeat or settings
236
+ report, at most about 30 seconds). `--require-yield` waits for that acknowledgement.
237
+ - It defers background runtime-readiness probes; Forge retries them after yield is off.
238
+ - It doesn't stop a Bridge Chat turn whose chat lease is already bound to this runner: Forge has no
239
+ retry for a refused turn, so the bridge runs it, and `status --idle` reports it as busy until it ends.
240
+ - It doesn't stop a legacy `Dispatch`, which Forge sends only to protocol-1 bridges. This bridge
241
+ registers a newer protocol, so it receives Offer and Start instead. A legacy dispatch is still
242
+ counted as busy.
243
+ - Attempts already running finish normally.
244
+
245
+ Restart procedure: yield, wait for idle, restart, then turn yield off once the new bridge has connected
246
+ (the flag file survives the restart, so the new bridge starts yielded and takes no work until then).
247
+ If the wait fails, turn yield off again so the runner doesn't stay out of placement, or leave it on
248
+ deliberately and retry later.
249
+ Run the commands as the same user and with the same `FORGE_BRIDGE_CONFIG` as the bridge so they use its
250
+ `bridge.json`, `bridge.yield.json` and `bridge.state.json`. On Windows, a shell inside an MSIX-packaged
251
+ app can have `%APPDATA%` writes virtualized away from the bridge; `--require-yield` catches that, because
252
+ the yield has to be applied by the bridge and acknowledged by Forge.
253
+
254
+ Linux or macOS:
255
+
256
+ ```bash
257
+ forge-bridge yield on
258
+ if forge-bridge status --idle --require-yield --wait 3600; then
259
+ # Stop forge-bridge connect, update it (npm install -g @loucompanion/forge-bridge@next), start it again.
260
+ forge-bridge yield off # once the new bridge has connected
261
+ else
262
+ code=$?
263
+ forge-bridge yield off # don't leave the runner out of placement
264
+ echo "Bridge is not idle (exit $code); not restarting." >&2
265
+ fi
266
+ ```
267
+
268
+ Windows PowerShell:
269
+
270
+ ```powershell
271
+ forge-bridge yield on
272
+ forge-bridge status --idle --require-yield --wait 3600
273
+ $code = $LASTEXITCODE
274
+ if ($code -eq 0) {
275
+ # Stop forge-bridge connect, update it (npm install -g @loucompanion/forge-bridge@next), start it again.
276
+ forge-bridge yield off # once the new bridge has connected
277
+ } else {
278
+ forge-bridge yield off # don't leave the runner out of placement
279
+ Write-Error "Bridge is not idle (exit $code); not restarting."
280
+ }
281
+ ```
282
+
283
+ The bridge also logs each accepted offer, each accepted dispatch and the start and end of each run,
284
+ with the dispatch attempt, lease, session and cycle ids.
285
+
286
+ ## Pre-publication repair
287
+
288
+ Before Forge commits and pushes an agent's work, the bridge runs the CI parity checks in
289
+ `.forge/validation/ci-parity.v1.json`. A failed check does not stop the pass: the other checks still
290
+ run, except those that need what failed (the OpenAPI export and E2E after a .NET compile failure, E2E
291
+ after a failed runtime restart). The provider thread then gets one in-place repair turn that lists
292
+ every failed check. A Work Order holds after `FORGE_PREPUBLICATION_REPAIR_TURNS` repair turns (a whole
293
+ number from 1, capped at 10; default 4) if validation still fails.
294
+
132
295
  ## Docker sandbox runners
133
296
 
134
297
  Protocol-v2 bridges preflight Docker before advertising the `docker` sandbox runtime. Validate a repository contract and the local runner before enabling a project's `sandbox_required` policy:
@@ -190,9 +353,25 @@ Production shared runners require a Linux rootless Docker daemon. Docker Desktop
190
353
 
191
354
  Before selecting `sandbox_required`, save the full approved 40- or 64-character Git commit SHA in the project's Sandbox policy dialog. The server persists that SHA on the immutable attempt and the bridge reads `.forge/forge.sandbox.yml`, `.forge/Dockerfile`, and the tracked build context only from that commit. API-key dispatches carry an opaque one-time grant handle; the authenticated current runner instance redeems it after reservation, and plaintext stays out of offers, database payloads, Docker metadata, and host-persisted control files.
192
355
 
193
- Temporary host fallback for `sandbox_preferred` requires both sides to opt in: a project owner must save a reason and future expiry (maximum 30 days), and an operator must enable **Host fallback** for the runner in Profile Settings. Either missing or expired authorization fails closed. `sandbox_required` never falls back.
356
+ Temporary host fallback for `sandbox_preferred` requires both sides to opt in: a project owner must save a reason and future expiry (maximum 30 days), and an operator must enable **Host fallback** for the runner in Settings › Runners. Either missing or expired authorization fails closed. `sandbox_required` never falls back.
357
+
358
+ ### Forge PR reviews run only in the Docker sandbox
359
+
360
+ A Forge PR review reads code its author controls, so it runs only where the bridge isolates it, and today that means the Docker sandbox. Forge decides where a review runs before it offers it to any runner. It places the review in a runner's Docker sandbox when that sandbox can take it, and gives it no publication grant. The sandbox can take it when the project runs in a sandbox (`sandbox_preferred` or `sandbox_required`, so it has the `.forge/forge.sandbox.yml` contract the container is built from; a `host_allowed` project never ran in one, and most have no contract) and the provider can reach its API from it. Either the project's network policy allows the provider's hosts (`public_allowlist`), or the runner approves open public networking (`forge-bridge sandbox on --allow-open-public`), which a review outside `sandbox_required` then uses. The container gets the dispatched head as a bundle with no remote, no git credential and no GitHub token. The review diffs against the merge base of the pull request's base and head, which is always in that bundle; the bridge resolves it with its own git, fetching the base by SHA when needed. Codex runs a review with `danger-full-access` in the container, as every other Docker lane does, because its own Linux sandbox cannot be relied on inside the hardened container; the container is the boundary. On a host, Codex runs a review `read-only`. The bridge does not set up Claude Code's own OS sandbox. If a bridge cannot build the sandbox for a review it was offered anyway, it refuses with the non-retryable `pr_review.sandbox_unavailable`, and Forge does not offer that head to the same runner again.
361
+
362
+ On a plain host the provider runs as your user, next to your git credential store, your GitHub CLI login and every file in your home directory. The review guardrails still apply: the git and `gh` environment, the tool deny list, and the checks that the worktree, the local refs and the pull request branch on `origin` haven't changed. They are defence in depth, though, not a boundary. A push to another remote, or anything read and sent elsewhere, would go unnoticed. So a bridge refuses a review placed on its host with the non-retryable `pr_review.unsandboxed_host` before any provider starts. Forge does not offer that head to the same runner again.
363
+
364
+ If no runner can take the review in its sandbox and none has opted in (below), Forge doesn't run it. The pull request's Forge review status becomes `unavailable`, the timeline records `pr_review.no_isolated_runner`, and the bounded review wait releases the head the same way it releases any review that can't run.
365
+
366
+ To accept unsandboxed reviews on a machine anyway, set this in its `bridge.json` and restart the bridge:
367
+
368
+ ```json
369
+ { "allowUnsandboxedPrReview": true }
370
+ ```
371
+
372
+ The setting defaults to `false` and has no environment override. With it set, the bridge advertises the `pr_review_unsandboxed_host` facility, and Forge places a review on that host when its Docker sandbox can't take it and the project's policy lets work run on the host. The server's Local Runner has no Docker sandbox: it runs a review only in its container sandbox or when it advertises the same facility, and refuses any other review with `pr_review.unsandboxed_host`, as `forge-bridge run-once` does. Each such review logs a warning, emits a `pr_review_unsandboxed_host_warning` event and notes the warning in its session result. Turn it on only on a machine whose credentials and files you are willing to expose to the code under review, such as a disposable VM or a host with no credentials worth stealing.
194
373
 
195
- The bridge reaps exact-labeled orphan resources before connecting and every minute afterward. Connected passes reconcile current-instance ledgers against an authoritative, instance-scoped server attempt snapshot; startup does not adopt old-instance resources and terminates them before advertising capacity. Per-resource removal outcomes are written mode-0600 under `FORGE_SANDBOX_STATE_ROOT/cleanup-reports` before transmission, replayed after reconnect, acknowledged by report ID, and persisted by the API only when attempt, fence, resource runner instance, and current reporting runner match. Fenced dispatch events also persist image/cache status, build/agent-start/import/teardown timestamps, and a validated inventory of created agent/sidecar containers, networks, volumes, and published ports. Selected-session diagnostics expose that lifecycle data and recent cleanup actions while retaining cleanup-pending state after the agent outcome is terminal. Install `forge-bridge sandbox reap` as an independently supervised OS timer with the same `FORGE_RUNNER_ID`, Docker context, and state root so resources are reconciled while the bridge is down; the Docker-context ownership lock makes an overlapping pass fail safely. A non-zero `degradedReservationCount` means teardown has not completed; the affected capacity remains unavailable until a successful reaper pass. Drain a runner from Profile Settings before upgrades or Docker maintenance, wait for active/starting counts to reach zero, then restart the bridge. Profile Settings also exposes a scoped **Reap** action; the API delivers it only to the currently established protocol-v2 runner instance. Image GC runs only while disk pressure is latched, shares the build lock, preserves active image digests, and prunes only expired images beyond the per-project retention count. Lease renewals are HMAC-bound to the attempt and fence and advance an in-container monotonic deadline; lease, hard-wall, and idle expiry produce distinct failure codes.
374
+ The bridge reaps exact-labeled orphan resources before connecting and every minute afterward. Connected passes reconcile current-instance ledgers against an authoritative, instance-scoped server attempt snapshot; startup does not adopt old-instance resources and terminates them before advertising capacity. Per-resource removal outcomes are written mode-0600 under `FORGE_SANDBOX_STATE_ROOT/cleanup-reports` before transmission, replayed after reconnect, acknowledged by report ID, and persisted by the API only when attempt, fence, resource runner instance, and current reporting runner match. Fenced dispatch events also persist image/cache status, build/agent-start/import/teardown timestamps, and a validated inventory of created agent/sidecar containers, networks, volumes, and published ports. Selected-session diagnostics expose that lifecycle data and recent cleanup actions while retaining cleanup-pending state after the agent outcome is terminal. Install `forge-bridge sandbox reap` as an independently supervised OS timer with the same `FORGE_RUNNER_ID`, Docker context, and state root so resources are reconciled while the bridge is down; the Docker-context ownership lock makes an overlapping pass fail safely. A non-zero `degradedReservationCount` means teardown has not completed; the affected capacity remains unavailable until a successful reaper pass. Drain a runner from Settings › Runners before upgrades or Docker maintenance, wait for active/starting counts to reach zero, then restart the bridge. Settings › Runners also exposes a scoped **Reap** action; the API delivers it only to the currently established protocol-v2 runner instance. Image GC runs only while disk pressure is latched, shares the build lock, preserves active image digests, and prunes only expired images beyond the per-project retention count. Lease renewals are HMAC-bound to the attempt and fence and advance an in-container monotonic deadline; lease, hard-wall, and idle expiry produce distinct failure codes.
196
375
 
197
376
  Every attempt-owned container (including short-lived initialization helpers), network, and volume carries `dev.forge.resource-lease-id` equal to the dispatch execution lease. Ledger schema v2 persists the same `resourceLeaseId`; teardown compares the complete expected label set, and orphan reaping fails closed unless the managed, resource-lease, execution-lease, attempt, runner, runner-instance, and fencing identities are all present and consistent.
198
377
 
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The AI's one look at the GIFs a user sent (GIPHY in Chat). Frames never ride in the dispatch packet,
3
+ * which goes through Forge's database outbox: at turn start the bridge takes them once from the API's
4
+ * in-memory store, shows them to a throwaway Claude call that keeps no session and has no tools, and gives
5
+ * the main turn only that call's short description. The main turn never gets the frames, and nothing the
6
+ * look call saw is written to disk by the bridge. The look call is built and run with the other provider
7
+ * launches, in `bridge-chat-provider-command.ts`.
8
+ */
9
+ import type { ProviderProcessRunner } from "../session/provider-cli/provider-cli.process.js";
10
+ /** The hub method that hands a turn its GIF frames, once. */
11
+ export declare const chatTurnGiphyFramesMethod = "ChatTurnGiphyFrames";
12
+ /** The API hands out at most four stills a GIF; any more are ignored. */
13
+ export declare const maxChatGiphyLookFrames = 4;
14
+ export interface ChatTurnGiphyFrameSet {
15
+ readonly giphyId: string;
16
+ readonly title: string;
17
+ readonly altText?: string | null;
18
+ /** Base64 JPEG stills. */
19
+ readonly frames: readonly string[];
20
+ }
21
+ export interface ChatTurnGiphyFramesResponse {
22
+ readonly accepted: boolean;
23
+ readonly gifs?: readonly ChatTurnGiphyFrameSet[] | null;
24
+ readonly code?: string | null;
25
+ }
26
+ export interface ChatGiphyLook {
27
+ readonly title: string;
28
+ readonly description: string;
29
+ }
30
+ export interface ChatGiphyLookDependencies {
31
+ /** Calls the hub's frames method. */
32
+ readonly takeFrames: (request: {
33
+ leaseId: string;
34
+ fencingToken: string;
35
+ turnId: string;
36
+ /** The packet's `giphyFramesThroughSeq`: frames only for GIFs sent at or before it. */
37
+ throughSeq: number;
38
+ }) => Promise<ChatTurnGiphyFramesResponse>;
39
+ readonly runner: ProviderProcessRunner;
40
+ readonly signal?: AbortSignal;
41
+ readonly log?: (message: string) => void;
42
+ }
43
+ /** One stream-json user message: what to do, then the frames as base64 JPEG image blocks. */
44
+ export declare function chatGiphyLookStdin(title: string, altText: string | null, frames: readonly string[]): string;
45
+ /** The look call's answer, from its stream-json `result` event, as one short line. */
46
+ export declare function chatGiphyLookDescription(stdoutLines: readonly string[]): string | null;
47
+ /** What the main turn reads about the GIFs, after the conversation. It never gets the frames. */
48
+ export declare function chatGiphyLookPromptSection(looks: readonly ChatGiphyLook[]): string;
@@ -0,0 +1,55 @@
1
+ /** The hub method that hands a turn its GIF frames, once. */
2
+ export const chatTurnGiphyFramesMethod = "ChatTurnGiphyFrames";
3
+ const maxDescriptionChars = 600;
4
+ /** The API hands out at most four stills a GIF; any more are ignored. */
5
+ export const maxChatGiphyLookFrames = 4;
6
+ /** One stream-json user message: what to do, then the frames as base64 JPEG image blocks. */
7
+ export function chatGiphyLookStdin(title, altText, frames) {
8
+ const about = altText ? `"${oneLine(title)}" (alt text: "${oneLine(altText)}")` : `"${oneLine(title)}"`;
9
+ const text = `These are ${frames.length} evenly spaced frames of a GIF from GIPHY, ${about}, that a user sent in a chat. `
10
+ + "Describe what happens in the GIF in one or two plain sentences, for someone who can't see it. "
11
+ + "Reply with the description only.";
12
+ return `${JSON.stringify({
13
+ type: "user",
14
+ message: {
15
+ role: "user",
16
+ content: [
17
+ { type: "text", text },
18
+ ...frames.map(data => ({ type: "image", source: { type: "base64", media_type: "image/jpeg", data } })),
19
+ ],
20
+ },
21
+ })}\n`;
22
+ }
23
+ /** The look call's answer, from its stream-json `result` event, as one short line. */
24
+ export function chatGiphyLookDescription(stdoutLines) {
25
+ for (const line of [...stdoutLines].reverse()) {
26
+ if (!line.trim().startsWith("{"))
27
+ continue;
28
+ try {
29
+ const event = JSON.parse(line);
30
+ if (event.type !== "result")
31
+ continue;
32
+ if (event.is_error === true || typeof event.result !== "string")
33
+ return null;
34
+ const text = oneLine(event.result);
35
+ return text ? clip(text, maxDescriptionChars) : null;
36
+ }
37
+ catch {
38
+ continue;
39
+ }
40
+ }
41
+ return null;
42
+ }
43
+ /** What the main turn reads about the GIFs, after the conversation. It never gets the frames. */
44
+ export function chatGiphyLookPromptSection(looks) {
45
+ if (looks.length === 0)
46
+ return "";
47
+ const lines = looks.map(look => `- "${oneLine(look.title)}": ${look.description}`);
48
+ return `\n\n# What the sent GIFs show\n\nA separate look at frames of the GIFs sent since your last reply:\n${lines.join("\n")}`;
49
+ }
50
+ function oneLine(value) {
51
+ return value.replace(/\s+/g, " ").replaceAll("\"", "'").trim();
52
+ }
53
+ function clip(value, max) {
54
+ return value.length <= max ? value : `${value.slice(0, max - 1).trimEnd()}…`;
55
+ }
@@ -0,0 +1,40 @@
1
+ import type { ProviderCliCommand, ProviderProcessRunResult } from "../session/provider-cli/provider-cli.process.js";
2
+ import { type ChatGiphyLook, type ChatGiphyLookDependencies } from "./bridge-chat-giphy-look.js";
3
+ export { chatTurnGiphyFramesMethod, type ChatGiphyLook, type ChatTurnGiphyFramesResponse } from "./bridge-chat-giphy-look.js";
4
+ import { type ChatTurnDispatchPacket } from "./bridge-chat.types.js";
5
+ /** The turn-scoped handoff metadata file the bridge writes into the chat workspace. */
6
+ export declare const chatTurnMetadataFileName = "forge-chat-metadata.json";
7
+ /**
8
+ * Fails a Bridge Chat turn Forge stopped because it ended with background work still live: the
9
+ * turn never delivered its answer, so it must not be reported as one.
10
+ */
11
+ export declare function assertChatTurnFinished(result: Pick<ProviderProcessRunResult, "terminalStopReason">): void;
12
+ export interface ChatProviderCommandPlan {
13
+ readonly command: ProviderCliCommand;
14
+ readonly stdin?: string;
15
+ /**
16
+ * Provider environment: the host's .NET build lock (host-build-lock.ts), Codex's own home, and
17
+ * the headless background-work restrictions for Claude.
18
+ */
19
+ readonly env?: Readonly<Record<string, string>>;
20
+ }
21
+ /** `giphyLooks` are the descriptions of the turn's sent GIFs from the look call; never their frames. */
22
+ export declare function buildChatProviderCommand(packet: ChatTurnDispatchPacket, cwd: string, giphyLooks?: readonly ChatGiphyLook[]): ChatProviderCommandPlan;
23
+ /** Writes the turn-scoped handoff metadata file: opaque handles only, no attachment content or grant nonces. */
24
+ export declare function materializeChatTurnMetadata(packet: ChatTurnDispatchPacket, workspacePath: string): Promise<void>;
25
+ /**
26
+ * Looks at the turn's sent GIFs. Returns no looks, so the turn goes ahead with the GIFs as text only, when
27
+ * none are waiting, the turn's provider is not Claude (Codex has no image input over stdin), the frames are
28
+ * gone, or a look fails.
29
+ */
30
+ export declare function lookAtChatGiphyFrames(packet: ChatTurnDispatchPacket, cwd: string, dependencies: ChatGiphyLookDependencies): Promise<readonly ChatGiphyLook[]>;
31
+ /**
32
+ * `claude -p` that keeps no session (`--no-session-persistence`), reads one stream-json user message with
33
+ * the frames as image blocks on stdin, and has no tools (`--tools ""`), no MCP servers and none of the host
34
+ * user's settings.
35
+ */
36
+ export declare function buildChatGiphyLookCommand(model: string, cwd: string): {
37
+ readonly command: string;
38
+ readonly args: readonly string[];
39
+ readonly env: Readonly<Record<string, string>>;
40
+ };
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Builds the provider command for a Bridge Chat turn: the CLI invocation for the turn's provider
3
+ * and the prompt that carries the conversation, its context references and its bounded handoff
4
+ * metadata.
5
+ */
6
+ import fs from "node:fs";
7
+ import path from "node:path";
8
+ import { claudeHeadlessEnvironment, providerTurnEndedWithBackgroundWorkFailure } from "../session/provider-cli/claude-background-work.js";
9
+ import { hostDotnetBuildLockEnvironment, hostDotnetBuildLockInstruction } from "../session/provider-cli/host-build-lock.js";
10
+ import { claudeIsolatedLaunchArgs, providerUserConfigIsolationUnsupported, providerUserConfigIsolationEnv } from "../session/provider-cli/provider-user-config-isolation.js";
11
+ import { codexSandboxModeForPlatform, providerEffort } from "../session/provider-cli/provider-cli.prompts.js";
12
+ import { chatGiphyLookDescription, chatGiphyLookPromptSection, chatGiphyLookStdin, maxChatGiphyLookFrames, } from "./bridge-chat-giphy-look.js";
13
+ export { chatTurnGiphyFramesMethod } from "./bridge-chat-giphy-look.js";
14
+ import { chatProviderKind } from "./bridge-chat.types.js";
15
+ /** The turn-scoped handoff metadata file the bridge writes into the chat workspace. */
16
+ export const chatTurnMetadataFileName = "forge-chat-metadata.json";
17
+ /**
18
+ * Fails a Bridge Chat turn Forge stopped because it ended with background work still live: the
19
+ * turn never delivered its answer, so it must not be reported as one.
20
+ */
21
+ export function assertChatTurnFinished(result) {
22
+ if (result.terminalStopReason === "turn_ended_with_background_work") {
23
+ throw providerTurnEndedWithBackgroundWorkFailure("The Bridge Chat turn did not finish.");
24
+ }
25
+ }
26
+ /** `giphyLooks` are the descriptions of the turn's sent GIFs from the look call; never their frames. */
27
+ export function buildChatProviderCommand(packet, cwd, giphyLooks = []) {
28
+ // The provider kind picks the CLI and its effort levels; an auth-path suffix such as `:bridge` does not.
29
+ const provider = chatProviderKind(packet.providerKind);
30
+ const model = packet.model.trim();
31
+ const prompt = buildChatPrompt(packet, giphyLooks);
32
+ const resumeThreadId = packet.providerThreadId?.trim() || null;
33
+ // Levels the provider does not accept are dropped, so the CLI keeps its own default.
34
+ const effort = providerEffort(provider, packet.effort);
35
+ if (provider === "codex") {
36
+ const args = ["-s", codexSandboxModeForPlatform(process.platform, "host"), "-a", "never", "exec"];
37
+ if (resumeThreadId) {
38
+ args.push("--cd", cwd, "resume");
39
+ }
40
+ args.push("--model", model);
41
+ if (effort) {
42
+ args.push("-c", `model_reasoning_effort=${JSON.stringify(effort)}`);
43
+ }
44
+ args.push("--json");
45
+ if (!resumeThreadId) {
46
+ args.push("--cd", cwd);
47
+ }
48
+ args.push("--skip-git-repo-check");
49
+ if (resumeThreadId) {
50
+ args.push(resumeThreadId);
51
+ }
52
+ args.push("-");
53
+ // Codex runs with Forge's own CODEX_HOME, not the user's ~/.codex (provider-user-config-isolation.ts).
54
+ return { command: { command: "codex", args }, stdin: prompt, env: { ...hostDotnetBuildLockEnvironment(), ...providerUserConfigIsolationEnv("codex") } };
55
+ }
56
+ if (provider === "claude") {
57
+ const args = ["-p", "--output-format", "stream-json", "--verbose", "--model", model];
58
+ if (effort) {
59
+ args.push("--effort", effort);
60
+ }
61
+ // Only Forge's context and no MCP servers (provider-user-config-isolation.ts).
62
+ args.push("--permission-mode", "bypassPermissions", ...claudeIsolatedLaunchArgs({ workingDirectory: cwd, forgeMcpConfigPath: null, headless: true }));
63
+ if (resumeThreadId) {
64
+ args.push("--resume", resumeThreadId);
65
+ }
66
+ return { command: { command: "claude", args }, stdin: prompt, env: { ...hostDotnetBuildLockEnvironment(), ...claudeHeadlessEnvironment } };
67
+ }
68
+ // cursor-agent and other CLIs can't be kept from the host user's own configuration.
69
+ throw providerUserConfigIsolationUnsupported(packet.providerKind);
70
+ }
71
+ function buildChatPrompt(packet, giphyLooks) {
72
+ const messages = packet.messages
73
+ .map((message, index) => {
74
+ const role = message.role.trim() || `message-${index + 1}`;
75
+ return `[${role}]\n${message.content}`;
76
+ })
77
+ .join("\n\n");
78
+ const contextRefs = packet.contextRefs.length === 0
79
+ ? ""
80
+ : `\n\n# Context References\n\n${packet.contextRefs.map((ref, index) => {
81
+ const title = ref.title?.trim() ? `\nTitle: ${ref.title.trim()}` : "";
82
+ const summary = ref.summary?.trim() ? `\nSummary: ${ref.summary.trim()}` : "";
83
+ return `${index + 1}. ${ref.kind}:${ref.refId}${title}${summary}`;
84
+ }).join("\n\n")}`;
85
+ const continuation = packet.providerThreadId
86
+ ? "\n\nContinue the existing provider thread identified by the bridge; do not restart the conversation context."
87
+ : "";
88
+ const boundedMetadata = buildChatBoundedMetadataPrompt(packet);
89
+ // Chat turns run on the bridge's host, so they follow its .NET build lock like session turns.
90
+ const buildLock = hostDotnetBuildLockInstruction(process.env, "chat");
91
+ const hostRules = buildLock ? `\n\n# Host rules\n${buildLock}` : "";
92
+ return `You are handling a Forge Bridge Chat turn.
93
+
94
+ Conversation ID: ${packet.conversationId}
95
+ Turn ID: ${packet.turnId}
96
+ Provider: ${packet.providerKind}
97
+ Model: ${packet.model}${continuation}${boundedMetadata}${hostRules}
98
+
99
+ # Conversation
100
+
101
+ ${messages}${chatGiphyLookPromptSection(giphyLooks)}${contextRefs}
102
+ `;
103
+ }
104
+ function buildChatBoundedMetadataPrompt(packet) {
105
+ if (packet.attachmentHandoffs.length === 0 && packet.actionBrokerGrants.length === 0) {
106
+ return "";
107
+ }
108
+ const sections = [
109
+ `\n\n# Bounded Handoff Metadata\n\nMetadata file: ${chatTurnMetadataFileName}\n\nThe metadata file is turn-scoped and cleaned up by the bridge when the turn ends. It contains opaque handles only; attachment content, raw paths, and grant nonces are not included.`,
110
+ ];
111
+ if (packet.attachmentHandoffs.length > 0) {
112
+ sections.push(`Attachment handoffs:\n${packet.attachmentHandoffs.map((handoff, index) => [
113
+ `${index + 1}. turnId: ${handoff.turnId}`,
114
+ ` attachmentId: ${handoff.attachmentId}`,
115
+ ` tempFileToken: ${handoff.tempFileToken}`,
116
+ ` mimeType: ${handoff.mimeType}`,
117
+ ` sizeBytes: ${handoff.sizeBytes}`,
118
+ ` sha256: ${handoff.sha256}`,
119
+ ` fileNameDisplay: ${handoff.fileNameDisplay}`,
120
+ ` expiresAt: ${handoff.expiresAt}`,
121
+ ` status: ${handoff.status}`,
122
+ ].join("\n")).join("\n\n")}`);
123
+ }
124
+ if (packet.actionBrokerGrants.length > 0) {
125
+ sections.push(`Action-broker grants:\n${packet.actionBrokerGrants.map((grant, index) => [
126
+ `${index + 1}. grantId: ${grant.grantId}`,
127
+ ` turnId: ${grant.turnId}`,
128
+ ` leaseId: ${grant.leaseId}`,
129
+ ` fencingToken: ${grant.fencingToken}`,
130
+ ` allowedScopes: ${grant.allowedScopes.join(", ")}`,
131
+ ` expiresAt: ${grant.expiresAt}`,
132
+ ` redactionStatus: ${grant.redactionStatus}`,
133
+ " nonce: held by bridge",
134
+ ].join("\n")).join("\n\n")}`);
135
+ }
136
+ return sections.join("\n\n");
137
+ }
138
+ /** Writes the turn-scoped handoff metadata file: opaque handles only, no attachment content or grant nonces. */
139
+ export async function materializeChatTurnMetadata(packet, workspacePath) {
140
+ if (packet.attachmentHandoffs.length === 0 && packet.actionBrokerGrants.length === 0) {
141
+ return;
142
+ }
143
+ await fs.promises.writeFile(path.join(workspacePath, chatTurnMetadataFileName), `${JSON.stringify({
144
+ schemaVersion: 1,
145
+ attachmentHandoffs: packet.attachmentHandoffs.map((handoff) => ({
146
+ turnId: handoff.turnId,
147
+ attachmentId: handoff.attachmentId,
148
+ tempFileToken: handoff.tempFileToken,
149
+ mimeType: handoff.mimeType,
150
+ sizeBytes: handoff.sizeBytes,
151
+ sha256: handoff.sha256,
152
+ fileNameDisplay: handoff.fileNameDisplay,
153
+ expiresAt: handoff.expiresAt,
154
+ status: handoff.status,
155
+ })),
156
+ actionBrokerGrants: packet.actionBrokerGrants.map((grant) => ({
157
+ grantId: grant.grantId,
158
+ turnId: grant.turnId,
159
+ leaseId: grant.leaseId,
160
+ fencingToken: grant.fencingToken,
161
+ allowedScopes: grant.allowedScopes,
162
+ expiresAt: grant.expiresAt,
163
+ redactionStatus: grant.redactionStatus,
164
+ nonceHeldByBridge: true,
165
+ })),
166
+ }, null, 2)}\n`, "utf8");
167
+ }
168
+ /**
169
+ * Looks at the turn's sent GIFs. Returns no looks, so the turn goes ahead with the GIFs as text only, when
170
+ * none are waiting, the turn's provider is not Claude (Codex has no image input over stdin), the frames are
171
+ * gone, or a look fails.
172
+ */
173
+ export async function lookAtChatGiphyFrames(packet, cwd, dependencies) {
174
+ if (!packet.giphyFramesPending || packet.giphyFramesThroughSeq === undefined || chatProviderKind(packet.providerKind) !== "claude") {
175
+ return [];
176
+ }
177
+ let response;
178
+ try {
179
+ response = await dependencies.takeFrames({
180
+ leaseId: packet.leaseId,
181
+ fencingToken: packet.fencingToken,
182
+ turnId: packet.turnId,
183
+ throughSeq: packet.giphyFramesThroughSeq,
184
+ });
185
+ }
186
+ catch (error) {
187
+ dependencies.log?.(`GIF frames for turn ${packet.turnId} were not available: ${error instanceof Error ? error.message : String(error)}`);
188
+ return [];
189
+ }
190
+ const looks = [];
191
+ for (const gif of response.accepted ? response.gifs ?? [] : []) {
192
+ if (dependencies.signal?.aborted)
193
+ break;
194
+ const frames = gif.frames.slice(0, maxChatGiphyLookFrames);
195
+ if (frames.length === 0)
196
+ continue;
197
+ const plan = buildChatGiphyLookCommand(packet.model, cwd);
198
+ const lines = [];
199
+ const result = await dependencies.runner.run({ command: plan.command, args: plan.args, cwd, env: plan.env, stdin: chatGiphyLookStdin(gif.title, gif.altText ?? null, frames), captureOutput: false }, { onStdoutLine: line => { lines.push(line); } }, dependencies.signal).catch(() => null);
200
+ const description = result?.exitCode === 0 ? chatGiphyLookDescription(lines) : null;
201
+ if (description) {
202
+ looks.push({ title: gif.title, description });
203
+ }
204
+ else {
205
+ dependencies.log?.(`The look at a GIF for turn ${packet.turnId} gave no description; it stays text only.`);
206
+ }
207
+ }
208
+ return looks;
209
+ }
210
+ /**
211
+ * `claude -p` that keeps no session (`--no-session-persistence`), reads one stream-json user message with
212
+ * the frames as image blocks on stdin, and has no tools (`--tools ""`), no MCP servers and none of the host
213
+ * user's settings.
214
+ */
215
+ export function buildChatGiphyLookCommand(model, cwd) {
216
+ return {
217
+ command: "claude",
218
+ args: [
219
+ "-p",
220
+ "--no-session-persistence",
221
+ "--input-format", "stream-json",
222
+ "--output-format", "stream-json",
223
+ "--verbose",
224
+ "--model", model.trim(),
225
+ "--tools", "",
226
+ ...claudeIsolatedLaunchArgs({ workingDirectory: cwd, forgeMcpConfigPath: null, headless: true }),
227
+ ],
228
+ env: { ...claudeHeadlessEnvironment },
229
+ };
230
+ }
@@ -35,10 +35,25 @@ export interface ChatTurnDispatchPacket {
35
35
  readonly contextRefs: readonly ChatTurnContextRef[];
36
36
  readonly idempotencyKey: string;
37
37
  readonly providerThreadId?: string | null;
38
+ /**
39
+ * The Chat role's reasoning effort for this provider and model, or null for the provider default.
40
+ * Older servers omit it. The command builder drops levels the provider does not accept.
41
+ */
42
+ readonly effort?: string | null;
38
43
  readonly protocolVersion: typeof bridgeChatProtocolVersion;
39
44
  readonly requestedCapabilities: readonly BridgeChatRequestedCapability[];
40
45
  readonly attachmentHandoffs: readonly ChatAttachmentHandoffHandle[];
41
46
  readonly actionBrokerGrants: readonly ChatActionBrokerGrant[];
47
+ /**
48
+ * How many sent GIFs have frames waiting for the AI's one look; absent when none or from older servers.
49
+ * The frames never ride in the packet: the bridge takes them once through the hub's `ChatTurnGiphyFrames`.
50
+ */
51
+ readonly giphyFramesPending?: number;
52
+ /**
53
+ * The newest message `Seq` the packet's messages read, present with `giphyFramesPending`. It goes back with
54
+ * `ChatTurnGiphyFrames` so the API hands out only frames of GIFs this turn's messages include.
55
+ */
56
+ readonly giphyFramesThroughSeq?: number;
42
57
  }
43
58
  export interface ChatTurnMessage {
44
59
  readonly role: string;
@@ -107,5 +122,10 @@ export interface ChatTurnCancelPacket {
107
122
  export declare function unavailableBridgeChatCapability(protocolVersion?: string, unavailableCode?: string | null, unavailableReason?: string | null): BridgeChatCapability;
108
123
  export declare function normalizeBridgeChatCapability(value: BridgeChatCapability | null | undefined): BridgeChatCapability;
109
124
  export declare function parseChatTurnDispatchPacket(value: unknown, capability?: BridgeChatCapability): ChatTurnDispatchPacket;
125
+ /**
126
+ * The provider kind of a saved provider selection: `codex:bridge` and `codex` are both `codex`.
127
+ * Forge stores the Chat role's provider with its auth-path suffix and may send it as is.
128
+ */
129
+ export declare function chatProviderKind(provider: string): string;
110
130
  export declare function isTerminalChatTurnCallbackKind(kind: ChatTurnCallbackKind): boolean;
111
131
  export declare function assertBridgeChatCallbackPayload(value: unknown, label?: string): void;