@loucompanion/forge-bridge 0.1.3-dev.fbe15023cdfe → 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 (332) hide show
  1. package/README.md +232 -5
  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 +13 -1
  15. package/dist/bridge/bridge.service.d.ts +169 -14
  16. package/dist/bridge/bridge.service.js +1868 -330
  17. package/dist/bridge/bridge.types.d.ts +73 -1
  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 +21 -1
  41. package/dist/cleanup/cleanup.service.js +185 -143
  42. package/dist/cleanup/cleanup.types.d.ts +6 -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/managed-branch-sweep.d.ts +27 -0
  48. package/dist/cleanup/managed-branch-sweep.js +111 -0
  49. package/dist/cli/cli.help.js +78 -16
  50. package/dist/cli/cli.service.d.ts +32 -15
  51. package/dist/cli/cli.service.js +206 -182
  52. package/dist/cli/idle-status.d.ts +84 -0
  53. package/dist/cli/idle-status.js +181 -0
  54. package/dist/cli/local-config.d.ts +7 -0
  55. package/dist/cli/local-config.js +36 -4
  56. package/dist/cli/provider-cli-detection.d.ts +10 -0
  57. package/dist/cli/provider-cli-detection.js +160 -0
  58. package/dist/runtime/aspnet-runtime-prebuild.d.ts +41 -0
  59. package/dist/runtime/aspnet-runtime-prebuild.js +474 -0
  60. package/dist/runtime/attempt-database-broker.d.ts +89 -0
  61. package/dist/runtime/attempt-database-broker.js +390 -0
  62. package/dist/runtime/attempt-node-runtime-launcher.d.ts +2 -1
  63. package/dist/runtime/attempt-node-runtime-launcher.js +57 -18
  64. package/dist/runtime/attempt-path-operation.d.ts +21 -0
  65. package/dist/runtime/attempt-path-operation.js +94 -0
  66. package/dist/runtime/attempt-private-directory.d.ts +6 -0
  67. package/dist/runtime/attempt-private-directory.js +54 -0
  68. package/dist/runtime/attempt-process-supervisor.d.ts +35 -0
  69. package/dist/runtime/attempt-process-supervisor.js +144 -23
  70. package/dist/runtime/canonical-source-file.d.ts +3 -0
  71. package/dist/runtime/canonical-source-file.js +54 -0
  72. package/dist/runtime/docker-engine-probe.d.ts +95 -0
  73. package/dist/runtime/docker-engine-probe.js +340 -0
  74. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  75. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  76. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  77. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  78. package/dist/runtime/generated-output-reset.d.ts +10 -0
  79. package/dist/runtime/generated-output-reset.js +62 -8
  80. package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
  81. package/dist/runtime/host-database-capability-boundary.js +63 -0
  82. package/dist/runtime/host-diagnostics.d.ts +11 -0
  83. package/dist/runtime/host-diagnostics.js +192 -0
  84. package/dist/runtime/host-execution-root.d.ts +4 -0
  85. package/dist/runtime/host-execution-root.js +39 -0
  86. package/dist/runtime/host-facts.d.ts +36 -0
  87. package/dist/runtime/host-facts.js +95 -0
  88. package/dist/runtime/host-listener-inspector.d.ts +8 -1
  89. package/dist/runtime/host-listener-inspector.js +121 -60
  90. package/dist/runtime/host-load-admission.d.ts +67 -0
  91. package/dist/runtime/host-load-admission.js +99 -0
  92. package/dist/runtime/host-load-child-environment.d.ts +27 -0
  93. package/dist/runtime/host-load-child-environment.js +76 -0
  94. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  95. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  96. package/dist/runtime/host-load-governor-config.d.ts +52 -0
  97. package/dist/runtime/host-load-governor-config.js +83 -0
  98. package/dist/runtime/host-load-governor.d.ts +186 -0
  99. package/dist/runtime/host-load-governor.js +632 -0
  100. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  101. package/dist/runtime/host-load-ledger-lock.js +187 -0
  102. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  103. package/dist/runtime/host-load-runtime-settings.js +80 -0
  104. package/dist/runtime/host-load-sampler.d.ts +156 -0
  105. package/dist/runtime/host-load-sampler.js +298 -0
  106. package/dist/runtime/host-load-step-class.d.ts +70 -0
  107. package/dist/runtime/host-load-step-class.js +161 -0
  108. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  109. package/dist/runtime/host-load-step-reaper.js +95 -0
  110. package/dist/runtime/host-load-step-run.d.ts +73 -0
  111. package/dist/runtime/host-load-step-run.js +102 -0
  112. package/dist/runtime/host-load-test-slot.d.ts +43 -0
  113. package/dist/runtime/host-load-test-slot.js +81 -0
  114. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  115. package/dist/runtime/host-load-token-ledger.js +453 -0
  116. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  117. package/dist/runtime/host-load-windows-cpu.js +85 -0
  118. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  119. package/dist/runtime/host-pressure-stall.js +168 -0
  120. package/dist/runtime/host-runtime-contract.d.ts +28 -1
  121. package/dist/runtime/host-runtime-contract.js +203 -57
  122. package/dist/runtime/host-runtime-lease.d.ts +163 -9
  123. package/dist/runtime/host-runtime-lease.js +1427 -124
  124. package/dist/runtime/host-runtime-promotion.d.ts +35 -3
  125. package/dist/runtime/host-runtime-promotion.js +107 -12
  126. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  127. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  128. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  129. package/dist/runtime/host-runtime-requirements.js +117 -0
  130. package/dist/runtime/managed-command-teardown.d.ts +62 -0
  131. package/dist/runtime/managed-command-teardown.js +596 -0
  132. package/dist/runtime/memory-capacity.d.ts +70 -0
  133. package/dist/runtime/memory-capacity.js +123 -0
  134. package/dist/runtime/native-test-postgres-fallback.d.ts +69 -0
  135. package/dist/runtime/native-test-postgres-fallback.js +143 -0
  136. package/dist/runtime/node-host-runtime-adapter.d.ts +3 -0
  137. package/dist/runtime/node-host-runtime-adapter.js +29 -11
  138. package/dist/runtime/pinned-directory-process.d.ts +9 -0
  139. package/dist/runtime/pinned-directory-process.js +61 -0
  140. package/dist/runtime/pinned-source-directory.d.ts +17 -0
  141. package/dist/runtime/pinned-source-directory.js +94 -0
  142. package/dist/runtime/playwright-browser-cache.d.ts +39 -0
  143. package/dist/runtime/playwright-browser-cache.js +227 -0
  144. package/dist/runtime/playwright-host-runtime-adapter.d.ts +19 -0
  145. package/dist/runtime/playwright-host-runtime-adapter.js +113 -59
  146. package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
  147. package/dist/runtime/prepared-runtime-identity.js +218 -0
  148. package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
  149. package/dist/runtime/prepared-runtime-readiness.js +285 -0
  150. package/dist/runtime/runner-settings.d.ts +104 -0
  151. package/dist/runtime/runner-settings.js +236 -0
  152. package/dist/runtime/runtime-isolation-lease.js +4 -1
  153. package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
  154. package/dist/runtime/workspace-resource-estimator.js +174 -0
  155. package/dist/sandbox/host-capacity-broker.d.ts +115 -0
  156. package/dist/sandbox/host-capacity-broker.js +336 -0
  157. package/dist/sandbox/managed-branch.d.ts +13 -0
  158. package/dist/sandbox/managed-branch.js +36 -0
  159. package/dist/sandbox/preflight.d.ts +31 -1
  160. package/dist/sandbox/preflight.js +237 -51
  161. package/dist/sandbox/provider-auth/codex.js +11 -11
  162. package/dist/sandbox/repository-lock.d.ts +2 -1
  163. package/dist/sandbox/repository-lock.js +19 -9
  164. package/dist/sandbox/runtime.d.ts +16 -2
  165. package/dist/sandbox/runtime.js +183 -114
  166. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  167. package/dist/sandbox/sandbox-cgroups.js +42 -0
  168. package/dist/sandbox/sandbox.types.d.ts +7 -0
  169. package/dist/sandbox/workspace.service.js +2 -0
  170. package/dist/session/architect-waits.d.ts +2 -0
  171. package/dist/session/architect-waits.js +138 -0
  172. package/dist/session/managed-attempt-tools.d.ts +37 -1
  173. package/dist/session/managed-attempt-tools.js +822 -84
  174. package/dist/session/managed-build-coordinator.d.ts +5 -0
  175. package/dist/session/managed-build-coordinator.js +109 -0
  176. package/dist/session/managed-build-receipt.d.ts +26 -0
  177. package/dist/session/managed-build-receipt.js +342 -0
  178. package/dist/session/managed-command-host-load.d.ts +47 -0
  179. package/dist/session/managed-command-host-load.js +83 -0
  180. package/dist/session/managed-verification-timeouts.d.ts +8 -0
  181. package/dist/session/managed-verification-timeouts.js +17 -0
  182. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  183. package/dist/session/mcp-argument-coercion.js +121 -0
  184. package/dist/session/phase-completion.artifacts.d.ts +24 -0
  185. package/dist/session/phase-completion.artifacts.js +321 -45
  186. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  187. package/dist/session/phase-completion.command-validation.js +77 -0
  188. package/dist/session/phase-completion.d.ts +23 -1
  189. package/dist/session/phase-completion.helpers.d.ts +5 -0
  190. package/dist/session/phase-completion.helpers.js +43 -19
  191. package/dist/session/phase-completion.js +19 -3
  192. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  193. package/dist/session/phase-completion.mcp-args.js +156 -0
  194. package/dist/session/phase-completion.prompts.js +22 -18
  195. package/dist/session/phase-completion.runtime.d.ts +6 -10
  196. package/dist/session/phase-completion.runtime.js +214 -224
  197. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  198. package/dist/session/phase-completion.schema-parts.js +188 -0
  199. package/dist/session/phase-completion.schemas.d.ts +3 -3
  200. package/dist/session/phase-completion.schemas.js +250 -226
  201. package/dist/session/phase-completion.validation.d.ts +3 -3
  202. package/dist/session/phase-completion.validation.js +135 -89
  203. package/dist/session/pre-publication-host-load.d.ts +27 -0
  204. package/dist/session/pre-publication-host-load.js +111 -0
  205. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  206. package/dist/session/pre-publication-native-postgres.js +111 -0
  207. package/dist/session/pre-publication-pass.d.ts +61 -0
  208. package/dist/session/pre-publication-pass.js +148 -0
  209. package/dist/session/pre-publication-process.d.ts +23 -0
  210. package/dist/session/pre-publication-process.js +109 -0
  211. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  212. package/dist/session/pre-publication-skipped-tests.js +109 -0
  213. package/dist/session/pre-publication-step-execution.d.ts +12 -0
  214. package/dist/session/pre-publication-step-execution.js +50 -0
  215. package/dist/session/pre-publication-validation.d.ts +91 -0
  216. package/dist/session/pre-publication-validation.js +670 -0
  217. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
  218. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
  219. package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
  220. package/dist/session/provider-cli/ci-repair-readiness.js +23 -3
  221. package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
  222. package/dist/session/provider-cli/claude-background-work.js +181 -0
  223. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  224. package/dist/session/provider-cli/host-build-lock.js +30 -0
  225. package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
  226. package/dist/session/provider-cli/pre-publication-repair.js +276 -0
  227. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +6 -3
  228. package/dist/session/provider-cli/provider-cli.artifacts.js +62 -22
  229. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  230. package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
  231. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  232. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  233. package/dist/session/provider-cli/provider-cli.deterministic.js +34 -2
  234. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  235. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  236. package/dist/session/provider-cli/provider-cli.process.d.ts +85 -19
  237. package/dist/session/provider-cli/provider-cli.process.js +566 -283
  238. package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -0
  239. package/dist/session/provider-cli/provider-cli.prompts.js +211 -36
  240. package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
  241. package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
  242. package/dist/session/provider-cli/provider-cli.runtime.d.ts +22 -1
  243. package/dist/session/provider-cli/provider-cli.runtime.js +83 -4
  244. package/dist/session/provider-cli/provider-cli.service.d.ts +36 -5
  245. package/dist/session/provider-cli/provider-cli.service.js +818 -99
  246. package/dist/session/provider-cli/provider-cli.types.d.ts +32 -0
  247. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  248. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  249. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  250. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  251. package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
  252. package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
  253. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  254. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  255. package/dist/session/provider-cli/provider-output-state.d.ts +18 -0
  256. package/dist/session/provider-cli/provider-output-state.js +376 -17
  257. package/dist/session/provider-cli/provider-usage.d.ts +9 -1
  258. package/dist/session/provider-cli/provider-usage.js +28 -5
  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/publishable-worktree-changes.d.ts +54 -0
  262. package/dist/session/publishable-worktree-changes.js +193 -0
  263. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  264. package/dist/session/qa-sidecar-validation.js +28 -0
  265. package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
  266. package/dist/session/sandbox-host-capacity-gate.js +257 -0
  267. package/dist/session/session-redaction.js +284 -9
  268. package/dist/session/session.base.d.ts +9 -1
  269. package/dist/session/session.service.d.ts +11 -2
  270. package/dist/session/session.service.js +301 -58
  271. package/dist/session/session.types.d.ts +150 -2
  272. package/dist/session/session.types.js +599 -7
  273. package/dist/session/sidecar-json-shape.d.ts +31 -0
  274. package/dist/session/sidecar-json-shape.js +217 -0
  275. package/dist/session/unreferenced-exports.d.ts +12 -0
  276. package/dist/session/unreferenced-exports.js +59 -0
  277. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  278. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  279. package/dist/shared/format/format-bytes.d.ts +1 -0
  280. package/dist/shared/format/format-bytes.js +9 -0
  281. package/dist/shared/fs/file-identity.d.ts +10 -0
  282. package/dist/shared/fs/file-identity.js +15 -0
  283. package/dist/shared/fs/replace-file.d.ts +7 -0
  284. package/dist/shared/fs/replace-file.js +33 -0
  285. package/dist/shared/git/git.js +2 -1
  286. package/dist/shared/path/path.d.ts +1 -0
  287. package/dist/shared/path/path.js +18 -0
  288. package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
  289. package/dist/shared/process/dotnet-toolchain.js +307 -0
  290. package/dist/shared/process/host-process-recovery.d.ts +14 -3
  291. package/dist/shared/process/host-process-recovery.js +26 -5
  292. package/dist/shared/process/host-process-supervisor.d.ts +16 -1
  293. package/dist/shared/process/host-process-supervisor.js +124 -23
  294. package/dist/shared/process/process-tree.d.ts +52 -0
  295. package/dist/shared/process/process-tree.js +144 -0
  296. package/dist/shared/process/process.d.ts +69 -0
  297. package/dist/shared/process/process.js +223 -16
  298. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  299. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  300. package/dist/shared/process/windows-launch.d.ts +18 -0
  301. package/dist/shared/process/windows-launch.js +68 -0
  302. package/dist/shared/provider-capabilities.d.ts +3 -0
  303. package/dist/shared/provider-capabilities.js +92 -0
  304. package/dist/shared/redaction/redaction.d.ts +1 -0
  305. package/dist/shared/redaction/redaction.js +39 -3
  306. package/dist/shared/time/monotonic.d.ts +1 -0
  307. package/dist/shared/time/monotonic.js +8 -0
  308. package/dist/version.d.ts +1 -1
  309. package/dist/version.js +1 -1
  310. package/dist/worktree/dependency-warmer.d.ts +66 -9
  311. package/dist/worktree/dependency-warmer.js +609 -24
  312. package/dist/worktree/index.d.ts +1 -1
  313. package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
  314. package/dist/worktree/story-qa-reference-hydrator.js +253 -0
  315. package/dist/worktree/wip-git.d.ts +33 -0
  316. package/dist/worktree/wip-git.js +122 -0
  317. package/dist/worktree/wip-refs.d.ts +62 -0
  318. package/dist/worktree/wip-refs.js +119 -0
  319. package/dist/worktree/wip-restore.d.ts +38 -0
  320. package/dist/worktree/wip-restore.js +190 -0
  321. package/dist/worktree/wip-snapshot.d.ts +50 -0
  322. package/dist/worktree/wip-snapshot.js +268 -0
  323. package/dist/worktree/worktree-wip-events.d.ts +18 -0
  324. package/dist/worktree/worktree-wip-events.js +98 -0
  325. package/dist/worktree/worktree-wip.d.ts +49 -0
  326. package/dist/worktree/worktree-wip.js +182 -0
  327. package/dist/worktree/worktree.base.d.ts +7 -1
  328. package/dist/worktree/worktree.service.d.ts +22 -2
  329. package/dist/worktree/worktree.service.js +302 -25
  330. package/dist/worktree/worktree.types.d.ts +36 -1
  331. package/package.json +8 -6
  332. package/runtime/windows-job-supervisor.ps1 +380 -14
@@ -1,3 +1,4 @@
1
+ import fs from "node:fs";
1
2
  import path from "node:path";
2
3
  export function buildWindowsCmdLaunch(command, args, comSpec = process.env.ComSpec) {
3
4
  const resolvedComSpec = comSpec?.trim();
@@ -39,3 +40,70 @@ function powershellExecutable() {
39
40
  ? path.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
40
41
  : "powershell.exe";
41
42
  }
43
+ /**
44
+ * Resolves Windows commands without spawning where.exe. Runtime launches can
45
+ * happen while the machine is under enough process pressure for where.exe to
46
+ * miss its timeout; returning the unresolved package-manager name in that case
47
+ * makes Node fall back to a shell shim that cannot survive Job Object wrapping.
48
+ */
49
+ export function resolveWindowsCommandFromPath(command, pathValue = process.env.PATH ?? "", pathExtValue = process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD", options = {}) {
50
+ if (!command || path.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
51
+ return null;
52
+ }
53
+ const hasExtension = path.extname(command).length > 0;
54
+ const extensions = hasExtension
55
+ ? [""]
56
+ : [...new Set([
57
+ "",
58
+ ".exe",
59
+ ".ps1",
60
+ ".cmd",
61
+ ".bat",
62
+ ...pathExtValue.split(";").map(value => value.trim().toLowerCase()).filter(Boolean),
63
+ ])];
64
+ for (const rawDirectory of pathValue.split(path.delimiter)) {
65
+ const directory = rawDirectory.trim().replace(/^"|"$/gu, "");
66
+ if (!directory)
67
+ continue;
68
+ const candidates = [];
69
+ for (const extension of extensions) {
70
+ const candidate = path.join(directory, `${command}${extension}`);
71
+ if (options.skipAppExecutionAliases && isWindowsAppExecutionAliasPath(candidate))
72
+ continue;
73
+ if (pathEntryExists(candidate))
74
+ candidates.push(candidate);
75
+ }
76
+ const resolved = chooseWindowsCommandCandidate(candidates);
77
+ if (resolved)
78
+ return resolved;
79
+ }
80
+ return null;
81
+ }
82
+ export function chooseWindowsCommandCandidate(candidates) {
83
+ const normalized = candidates
84
+ .map((candidate) => candidate.trim())
85
+ .filter((candidate) => candidate.length > 0);
86
+ if (normalized.length === 0) {
87
+ return null;
88
+ }
89
+ const preferredExtensions = [".exe", ".ps1", ".cmd", ".bat", ""];
90
+ for (const extension of preferredExtensions) {
91
+ const candidate = normalized.find((entry) => path.extname(entry).toLowerCase() === extension);
92
+ if (candidate) {
93
+ return candidate;
94
+ }
95
+ }
96
+ return normalized[0];
97
+ }
98
+ /** True for a path inside a `WindowsApps` directory, where Store app-execution aliases live. */
99
+ export function isWindowsAppExecutionAliasPath(candidate) {
100
+ return candidate.split(/[\\/]+/u).some(segment => segment.toLowerCase() === "windowsapps");
101
+ }
102
+ // An app-execution alias is a reparse point that stat() may not open, so an
103
+ // alias is also accepted when only lstat() can see it.
104
+ function pathEntryExists(candidate) {
105
+ if (fs.existsSync(candidate))
106
+ return true;
107
+ return isWindowsAppExecutionAliasPath(candidate)
108
+ && fs.lstatSync(candidate, { throwIfNoEntry: false }) !== undefined;
109
+ }
@@ -1 +1,4 @@
1
+ import { type BridgeChatCapability } from "../bridge/bridge-chat.types.js";
2
+ import type { BridgeProviderStatus } from "../bridge/bridge.types.js";
1
3
  export declare function supportsDraftImageAttachmentsFor(cliProviders: readonly string[]): boolean;
4
+ export declare function bridgeChatCapabilityFor(cliProviders: readonly string[], providerStatuses: Readonly<Record<string, BridgeProviderStatus>>, baseCapability?: BridgeChatCapability | null): BridgeChatCapability;
@@ -1,3 +1,95 @@
1
+ import { bridgeChatProtocolVersion, normalizeBridgeChatCapability, unavailableBridgeChatCapability, } from "../bridge/bridge-chat.types.js";
2
+ import { isProviderUserConfigIsolated, userConfigIsolatedProviders } from "../session/provider-cli/provider-user-config-isolation.js";
3
+ const defaultBridgeChatMaxMessageBytes = 128 * 1024;
4
+ const defaultBridgeChatMaxContextRefs = 8;
1
5
  export function supportsDraftImageAttachmentsFor(cliProviders) {
2
6
  return cliProviders.some((provider) => provider.trim().toLowerCase() === "codex");
3
7
  }
8
+ export function bridgeChatCapabilityFor(cliProviders, providerStatuses, baseCapability) {
9
+ const base = normalizeBridgeChatCapability(baseCapability ?? unavailableBridgeChatCapability());
10
+ if (base.protocolVersion !== bridgeChatProtocolVersion) {
11
+ return base;
12
+ }
13
+ const configuredProviders = chatProviderEntries(cliProviders, providerStatuses);
14
+ // Bridge Chat refuses a provider whose user configuration Forge can't keep out of the turn
15
+ // (cursor-agent, unknown CLIs), so it is never offered. The remaining providers decide
16
+ // availability: the server dispatches a turn only to a capability that is fully available.
17
+ const providers = configuredProviders.filter((provider) => isProviderUserConfigIsolated(provider.providerKind));
18
+ if (configuredProviders.length > 0 && providers.length === 0) {
19
+ return unavailableBridgeChatCapability(bridgeChatProtocolVersion, "no_isolated_cli_providers", `Bridge Chat runs only ${userConfigIsolatedProviders.join(" and ")}; Forge can't keep the host user's own configuration out of ${configuredProviders.map((provider) => provider.providerKind).join(", ")}.`);
20
+ }
21
+ const usableProviders = providers.filter((provider) => provider.status?.signedIn !== false);
22
+ if (usableProviders.length === 0) {
23
+ return unavailableBridgeChatCapability(bridgeChatProtocolVersion, providers.length === 0 ? "no_cli_providers" : "no_signed_in_cli_providers", providers.length === 0
24
+ ? "No CLI providers are configured for Bridge Chat."
25
+ : "No signed-in CLI providers are available for Bridge Chat.");
26
+ }
27
+ return normalizeBridgeChatCapability({
28
+ ...base,
29
+ availability: usableProviders.length === providers.length ? "available" : "degraded",
30
+ protocolVersion: bridgeChatProtocolVersion,
31
+ supportedProviders: usableProviders.map((provider) => provider.providerKind),
32
+ supportedModels: sortedUniqueStrings(usableProviders.flatMap((provider) => provider.status?.models ?? []), false),
33
+ supportsTextStreaming: true,
34
+ supportsCancel: true,
35
+ supportsResume: true,
36
+ supportsProviderThreadContinuity: true,
37
+ supportsAttachments: true,
38
+ supportsActionBrokerGrants: true,
39
+ maxMessageBytes: base.maxMessageBytes || defaultBridgeChatMaxMessageBytes,
40
+ maxContextRefs: base.maxContextRefs || defaultBridgeChatMaxContextRefs,
41
+ unavailableCode: null,
42
+ unavailableReason: null,
43
+ });
44
+ }
45
+ function chatProviderEntries(cliProviders, providerStatuses) {
46
+ const statuses = new Map();
47
+ for (const [provider, status] of Object.entries(providerStatuses)) {
48
+ const providerKind = provider.trim().toLowerCase();
49
+ if (providerKind.length === 0)
50
+ continue;
51
+ statuses.set(providerKind, { status });
52
+ }
53
+ // Only configured CLI providers can run a Bridge Chat turn. A status entry for a
54
+ // provider that is not in cliProviders (for example a leftover entry in
55
+ // bridge.json for a CLI that is no longer installed) annotates nothing and must
56
+ // not be advertised as a chat provider.
57
+ const providers = new Map();
58
+ for (const provider of cliProviders) {
59
+ const providerKind = provider.trim().toLowerCase();
60
+ if (providerKind.length === 0)
61
+ continue;
62
+ providers.set(providerKind, {
63
+ providerKind,
64
+ status: statuses.get(providerKind)?.status,
65
+ });
66
+ }
67
+ return [...providers.values()].sort((left, right) => compareStable(left.providerKind, right.providerKind));
68
+ }
69
+ function sortedUniqueStrings(values, lower) {
70
+ const byKey = new Map();
71
+ for (const value of values) {
72
+ const clean = value.trim();
73
+ if (clean.length === 0)
74
+ continue;
75
+ const normalized = lower ? clean.toLowerCase() : clean;
76
+ const key = normalized.toLowerCase();
77
+ if (!byKey.has(key)) {
78
+ byKey.set(key, normalized);
79
+ }
80
+ }
81
+ return [...byKey.values()].sort(compareStable);
82
+ }
83
+ function compareStable(left, right) {
84
+ const leftKey = left.toLowerCase();
85
+ const rightKey = right.toLowerCase();
86
+ if (leftKey < rightKey)
87
+ return -1;
88
+ if (leftKey > rightKey)
89
+ return 1;
90
+ if (left < right)
91
+ return -1;
92
+ if (left > right)
93
+ return 1;
94
+ return 0;
95
+ }
@@ -1,2 +1,3 @@
1
1
  export declare function redactSecrets<T>(value: T, exactSecrets?: readonly string[]): T;
2
+ export declare function shouldRedactJsonProperty(key: string): boolean;
2
3
  export declare function redactText(value: string, exactSecrets?: readonly string[]): string;
@@ -1,14 +1,41 @@
1
1
  const secretKeyPattern = /(api[_-]?key|authorization|bearer|client[_-]?secret|password|secret|token)/i;
2
+ // Serialized artifact keys follow the existing assignment policy, not the broad
3
+ // object redactor: tokenCount/maxTokens are evidence, not credential values.
4
+ const jsonCredentialKeyPattern = /(api[_-]?key|client[_-]?secret|password|secret|token)$/i;
2
5
  const attachmentContentKeyPattern = /^(textContent|contentBase64)$/i;
6
+ const bridgeChatHandoffGrantKeyPattern = /^(tempFileToken|grantNonce|nonce|handle|grantId|handoffId|attachmentId)$/i;
7
+ const sensitiveFilenameKeyPattern = /^(fileName|filename)$/i;
3
8
  const serializedAttachmentContentPattern = /("(?:textContent|contentBase64)"\s*:\s*")(?:(?:\\.)|[^"\\])*(")/gi;
9
+ const serializedBridgeChatHandoffGrantPattern = /("(?:tempFileToken|grantNonce|nonce|handle|grantId|handoffId|attachmentId)"\s*:\s*")(?:(?:\\.)|[^"\\])*(")/gi;
10
+ const serializedSensitiveFilenamePattern = /("(?:fileName|filename)"\s*:\s*")(?:(?:\\.)|[^"\\])*(")/gi;
4
11
  const authorizationCredentialPattern = /(\bauthorization\s*[:=]\s*(?:bearer|basic)?\s*)([^"',\s]+)/gi;
5
12
  const bearerCredentialPattern = /(\bbearer\s+)([^"',\s]+)/gi;
6
13
  const secretAssignmentPattern = /(api[_-]?key|client[_-]?secret|password|secret|token)(\s*["']?\s*[:=]\s*["']?\s*)([^"',\s]+)/gi;
14
+ // Keep this boundary in parity with Forge.Api's SecretRedactor. Without it, the
15
+ // `sk-` substring in a structural identifier such as `task-skill-contract`
16
+ // is mistaken for a provider credential and corrupts the artifact after it has
17
+ // already passed schema validation.
18
+ const providerKeyPattern = /(?<![a-zA-Z0-9])sk-[a-zA-Z0-9_-]{12,}/g;
7
19
  export function redactSecrets(value, exactSecrets = []) {
8
20
  return redactValue(value, exactSecrets);
9
21
  }
22
+ export function shouldRedactJsonProperty(key) {
23
+ // Assignment redaction already permits whitespace before the delimiter. Match
24
+ // that policy without normalizing the actual JSON property name on the wire.
25
+ const policyKey = key.trim();
26
+ return jsonCredentialKeyPattern.test(policyKey)
27
+ || /^(authorization|bearer)$/i.test(policyKey)
28
+ || attachmentContentKeyPattern.test(policyKey)
29
+ || bridgeChatHandoffGrantKeyPattern.test(policyKey)
30
+ || (redactSensitiveFilenames() && sensitiveFilenameKeyPattern.test(policyKey));
31
+ }
10
32
  export function redactText(value, exactSecrets = []) {
11
- let redacted = value.replace(serializedAttachmentContentPattern, "$1[REDACTED]$2");
33
+ let redacted = value
34
+ .replace(serializedAttachmentContentPattern, "$1[REDACTED]$2")
35
+ .replace(serializedBridgeChatHandoffGrantPattern, "$1[REDACTED]$2");
36
+ if (redactSensitiveFilenames()) {
37
+ redacted = redacted.replace(serializedSensitiveFilenamePattern, "$1[REDACTED]$2");
38
+ }
12
39
  for (const secret of exactSecrets) {
13
40
  if (secret.length > 0) {
14
41
  redacted = redacted.split(secret).join("[REDACTED]");
@@ -18,7 +45,7 @@ export function redactText(value, exactSecrets = []) {
18
45
  .replace(authorizationCredentialPattern, "$1[REDACTED]")
19
46
  .replace(bearerCredentialPattern, "$1[REDACTED]")
20
47
  .replace(secretAssignmentPattern, "$1$2[REDACTED]")
21
- .replace(/(sk-[a-zA-Z0-9_-]{12,})/g, "[REDACTED]");
48
+ .replace(providerKeyPattern, "[REDACTED]");
22
49
  }
23
50
  function redactValue(value, exactSecrets) {
24
51
  if (typeof value === "string") {
@@ -32,6 +59,15 @@ function redactValue(value, exactSecrets) {
32
59
  }
33
60
  return Object.fromEntries(Object.entries(value).map(([key, item]) => [
34
61
  key,
35
- secretKeyPattern.test(key) || attachmentContentKeyPattern.test(key) ? "[REDACTED]" : redactValue(item, exactSecrets)
62
+ secretKeyPattern.test(key)
63
+ || attachmentContentKeyPattern.test(key)
64
+ || bridgeChatHandoffGrantKeyPattern.test(key)
65
+ || (redactSensitiveFilenames() && sensitiveFilenameKeyPattern.test(key))
66
+ ? "[REDACTED]"
67
+ : redactValue(item, exactSecrets)
36
68
  ]));
37
69
  }
70
+ function redactSensitiveFilenames() {
71
+ const value = process.env.FORGE_REDACT_FILENAMES?.trim().toLowerCase();
72
+ return value === "1" || value === "true" || value === "yes";
73
+ }
@@ -0,0 +1 @@
1
+ export declare function monotonicNowMs(): number;
@@ -0,0 +1,8 @@
1
+ // Elapsed time and local deadlines use the monotonic clock. The wall clock can step:
2
+ // a WSL VM's clock is corrected in multi-second jumps, which would end a local wait
3
+ // early or count time that never passed. Timestamps that are persisted or compared
4
+ // across processes (lease expiry, receipts, file mtimes) stay on the wall clock.
5
+ // Read through the global so test fake timers that replace `performance` apply.
6
+ export function monotonicNowMs() {
7
+ return performance.now();
8
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const forgeBridgeVersion = "0.1.3-dev.fbe15023cdfe";
1
+ export declare const forgeBridgeVersion = "0.1.4-dev.0098fdb4e213";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const forgeBridgeVersion = "0.1.3-dev.fbe15023cdfe";
1
+ export const forgeBridgeVersion = "0.1.4-dev.0098fdb4e213";
@@ -1,3 +1,5 @@
1
+ import type { HostLoadStepGate } from "../runtime/host-load-governor.js";
2
+ import type { HostLoadTokenPriority } from "../runtime/host-load-token-ledger.js";
1
3
  export type DependencyEcosystem = "node" | "dotnet" | "python";
2
4
  export interface WarmPathEntry {
3
5
  readonly relativePath: string;
@@ -9,6 +11,25 @@ export interface WarmDependenciesRequest {
9
11
  readonly worktreePath: string;
10
12
  readonly allowedRoot: string;
11
13
  readonly warmPathOverrides?: readonly string[];
14
+ readonly preparationPolicy?: DependencyPreparationPolicy;
15
+ /** Install fallbacks wait for host capacity first (decision 0013). */
16
+ readonly hostLoad?: DependencyInstallHostLoad;
17
+ /**
18
+ * The attempt's cancellation: a queued install stops waiting and a running one
19
+ * is stopped (its whole process group) before its host capacity is returned.
20
+ */
21
+ readonly signal?: AbortSignal;
22
+ }
23
+ export interface DependencyInstallHostLoad {
24
+ readonly gate: HostLoadStepGate;
25
+ readonly dispatchAttemptId: string | null;
26
+ readonly priority: HostLoadTokenPriority;
27
+ }
28
+ export interface DependencyPreparationPolicy {
29
+ readonly isolation?: string;
30
+ readonly trustDomain?: string;
31
+ readonly invalidationEpoch?: string;
32
+ readonly toolchainVersions?: Readonly<Partial<Record<DependencyEcosystem | "npm" | "pnpm", string>>>;
12
33
  }
13
34
  export interface InstallFallbackResult {
14
35
  readonly ecosystem: DependencyEcosystem;
@@ -20,12 +41,33 @@ export interface WarmDependenciesResult {
20
41
  readonly linked: readonly string[];
21
42
  readonly skipped: readonly string[];
22
43
  readonly fallbacks: readonly InstallFallbackResult[];
44
+ readonly receipts: readonly DependencyPreparationReceiptResult[];
45
+ }
46
+ export interface DependencyPreparationReceiptResult {
47
+ readonly ecosystem: DependencyEcosystem;
48
+ readonly packageRoot: string;
49
+ readonly command: string;
50
+ readonly cacheHit: boolean;
51
+ readonly fingerprint: string;
52
+ readonly receiptPath: string;
53
+ /** End-to-end receipt lookup/preparation time, including coordinator wait. */
54
+ readonly durationMs: number;
23
55
  }
24
56
  export interface CommandExecutor {
25
57
  run(cwd: string, command: string, args: readonly string[], options?: CommandExecutionOptions): Promise<void>;
26
58
  }
27
59
  export interface CommandExecutionOptions {
28
60
  readonly env?: NodeJS.ProcessEnv;
61
+ readonly windowsVerbatimArguments?: boolean;
62
+ /** Stops the install (a reclaimed host load token, decision 0013). */
63
+ readonly signal?: AbortSignal;
64
+ /** Called with the install's pid once it starts, so its token records the process. */
65
+ readonly onSpawn?: (pid: number) => void;
66
+ /**
67
+ * Unix: the install leads its own process group, which is stopped as a whole
68
+ * (on abort, and anything left once the install exits) before the run settles.
69
+ */
70
+ readonly processGroup?: boolean;
29
71
  }
30
72
  export declare function detectWarmPaths(repoRoot: string, warmPathOverrides?: readonly string[]): Promise<WarmPathEntry[]>;
31
73
  export declare function warmWorktreeDependencies(request: WarmDependenciesRequest, executor?: CommandExecutor): Promise<WarmDependenciesResult>;
@@ -39,14 +81,29 @@ export interface NpmLaunchOptions {
39
81
  readonly platform?: NodeJS.Platform;
40
82
  readonly homeDir?: string;
41
83
  readonly candidates?: readonly string[];
84
+ readonly pathExists?: (candidate: string) => boolean;
85
+ }
86
+ export interface PackageManagerEnvironmentOptions {
87
+ readonly platform?: NodeJS.Platform;
88
+ readonly execPath?: string;
89
+ readonly pathExists?: (candidate: string) => boolean;
90
+ readonly maximumPathLength?: number;
91
+ readonly packageRoot?: string;
92
+ readonly requiredPathDirectories?: readonly string[];
93
+ }
94
+ export interface PackageManagerLaunch {
95
+ readonly command: string;
96
+ readonly args: readonly string[];
97
+ readonly requiredPathDirectories?: readonly string[];
98
+ readonly windowsVerbatimArguments?: boolean;
42
99
  }
43
- export declare function resolveNpmLaunch(args: readonly string[], options?: NpmLaunchOptions): {
44
- command: string;
45
- args: readonly string[];
46
- };
47
- export declare function resolvePnpmLaunch(args: readonly string[]): {
48
- command: string;
49
- args: readonly string[];
50
- };
100
+ export declare function resolveNpmLaunch(args: readonly string[], options?: NpmLaunchOptions): PackageManagerLaunch;
101
+ export declare function resolvePnpmLaunch(args: readonly string[], options?: NpmLaunchOptions): PackageManagerLaunch;
51
102
  export declare function formatCommandFailureOutput(stdout: string, stderr: string): string;
52
- export declare function unattendedPackageManagerEnvironment(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
103
+ export declare function unattendedPackageManagerEnvironment(env?: NodeJS.ProcessEnv, options?: PackageManagerEnvironmentOptions): NodeJS.ProcessEnv;
104
+ export declare function unattendedDependencyEnvironment(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
105
+ export declare function compactWindowsPackageManagerPath(pathValue: string, env?: NodeJS.ProcessEnv, options?: PackageManagerEnvironmentOptions): string;
106
+ export declare function windowsPackageManagerLifecyclePathPrefix(packageRoot: string): string;
107
+ export declare function windowsPackageManagerPathBudget(packageRoot: string): number;
108
+ /** Runs dependency installs; exported for tests. */
109
+ export declare const defaultCommandExecutor: CommandExecutor;