@telora/daemon 0.19.47 → 0.19.82

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 (597) hide show
  1. package/build-info.json +8 -3
  2. package/dist/assembly-engine.d.ts +9 -0
  3. package/dist/assembly-engine.d.ts.map +1 -1
  4. package/dist/assembly-engine.js.map +1 -1
  5. package/dist/audit-hooks.js +1 -1
  6. package/dist/branch-status.js +2 -2
  7. package/dist/branch-status.js.map +1 -1
  8. package/dist/ci-sensor-loop.d.ts +47 -0
  9. package/dist/ci-sensor-loop.d.ts.map +1 -0
  10. package/dist/ci-sensor-loop.js +116 -0
  11. package/dist/ci-sensor-loop.js.map +1 -0
  12. package/dist/ci-status-git.d.ts +52 -0
  13. package/dist/ci-status-git.d.ts.map +1 -0
  14. package/dist/ci-status-git.js +86 -0
  15. package/dist/ci-status-git.js.map +1 -0
  16. package/dist/ci-status.d.ts +122 -0
  17. package/dist/ci-status.d.ts.map +1 -0
  18. package/dist/ci-status.js +114 -0
  19. package/dist/ci-status.js.map +1 -0
  20. package/dist/cli/connect/agents.d.ts +24 -0
  21. package/dist/cli/connect/agents.d.ts.map +1 -0
  22. package/dist/cli/connect/agents.js +65 -0
  23. package/dist/cli/connect/agents.js.map +1 -0
  24. package/dist/cli/connect/claude.d.ts +31 -0
  25. package/dist/cli/connect/claude.d.ts.map +1 -0
  26. package/dist/cli/connect/claude.js +104 -0
  27. package/dist/cli/connect/claude.js.map +1 -0
  28. package/dist/cli/connect/cline.d.ts +37 -0
  29. package/dist/cli/connect/cline.d.ts.map +1 -0
  30. package/dist/cli/connect/cline.js +115 -0
  31. package/dist/cli/connect/cline.js.map +1 -0
  32. package/dist/cli/connect/codex.d.ts +44 -0
  33. package/dist/cli/connect/codex.d.ts.map +1 -0
  34. package/dist/cli/connect/codex.js +111 -0
  35. package/dist/cli/connect/codex.js.map +1 -0
  36. package/dist/cli/connect/ide.d.ts +69 -0
  37. package/dist/cli/connect/ide.d.ts.map +1 -0
  38. package/dist/cli/connect/ide.js +134 -0
  39. package/dist/cli/connect/ide.js.map +1 -0
  40. package/dist/cli/connect/scaffolding.d.ts +31 -0
  41. package/dist/cli/connect/scaffolding.d.ts.map +1 -0
  42. package/dist/cli/connect/scaffolding.js +52 -0
  43. package/dist/cli/connect/scaffolding.js.map +1 -0
  44. package/dist/cli/connect/shared.d.ts +30 -0
  45. package/dist/cli/connect/shared.d.ts.map +1 -0
  46. package/dist/cli/connect/shared.js +11 -0
  47. package/dist/cli/connect/shared.js.map +1 -0
  48. package/dist/cli/connect.d.ts +9 -210
  49. package/dist/cli/connect.d.ts.map +1 -1
  50. package/dist/cli/connect.js +10 -526
  51. package/dist/cli/connect.js.map +1 -1
  52. package/dist/cli/open.js +2 -2
  53. package/dist/completion/event.d.ts +2 -0
  54. package/dist/completion/event.d.ts.map +1 -1
  55. package/dist/completion/event.js +19 -2
  56. package/dist/completion/event.js.map +1 -1
  57. package/dist/completion/merge-phase.d.ts +3 -0
  58. package/dist/completion/merge-phase.d.ts.map +1 -1
  59. package/dist/completion/merge-phase.js +35 -3
  60. package/dist/completion/merge-phase.js.map +1 -1
  61. package/dist/completion/read-only-pristine.d.ts +1 -1
  62. package/dist/completion/read-only-pristine.d.ts.map +1 -1
  63. package/dist/completion/read-only-pristine.js +1 -1
  64. package/dist/completion/read-only-pristine.js.map +1 -1
  65. package/dist/completion/review-exit-phase.d.ts +30 -3
  66. package/dist/completion/review-exit-phase.d.ts.map +1 -1
  67. package/dist/completion/review-exit-phase.js +203 -15
  68. package/dist/completion/review-exit-phase.js.map +1 -1
  69. package/dist/completion/status-advance-phase.js +1 -1
  70. package/dist/completion/status-advance-phase.js.map +1 -1
  71. package/dist/completion/team-completion.d.ts.map +1 -1
  72. package/dist/completion/team-completion.js +22 -2
  73. package/dist/completion/team-completion.js.map +1 -1
  74. package/dist/completion/team-lifecycle.js +1 -1
  75. package/dist/completion/terminated-work-reconcile.js +1 -1
  76. package/dist/completion/terminated-work-reconcile.js.map +1 -1
  77. package/dist/condition-evaluators.d.ts +41 -2
  78. package/dist/condition-evaluators.d.ts.map +1 -1
  79. package/dist/condition-evaluators.js +37 -288
  80. package/dist/condition-evaluators.js.map +1 -1
  81. package/dist/config.d.ts.map +1 -1
  82. package/dist/config.js +23 -0
  83. package/dist/config.js.map +1 -1
  84. package/dist/context-audit.d.ts +1 -1
  85. package/dist/context-audit.d.ts.map +1 -1
  86. package/dist/context-lock.d.ts +1 -1
  87. package/dist/context-lock.d.ts.map +1 -1
  88. package/dist/control-state.d.ts +2 -2
  89. package/dist/control-state.d.ts.map +1 -1
  90. package/dist/control-state.js +4 -3
  91. package/dist/control-state.js.map +1 -1
  92. package/dist/daemon-process.d.ts +1 -1
  93. package/dist/daemon-process.d.ts.map +1 -1
  94. package/dist/delivery-advance-block.d.ts +1 -1
  95. package/dist/delivery-advance-block.d.ts.map +1 -1
  96. package/dist/delivery-advance-block.js +1 -1
  97. package/dist/delivery-advance-block.js.map +1 -1
  98. package/dist/delivery-lifecycle.js +1 -1
  99. package/dist/delivery-reconciler-shadow.d.ts +1 -1
  100. package/dist/delivery-reconciler-shadow.d.ts.map +1 -1
  101. package/dist/delivery-reconciler-shadow.js +1 -1
  102. package/dist/delivery-reconciler-shadow.js.map +1 -1
  103. package/dist/directive-executor.js +1 -1
  104. package/dist/directive-executor.js.map +1 -1
  105. package/dist/drift-eval-loop.d.ts.map +1 -1
  106. package/dist/drift-eval-loop.js +6 -14
  107. package/dist/drift-eval-loop.js.map +1 -1
  108. package/dist/escalations.d.ts +1 -1
  109. package/dist/escalations.d.ts.map +1 -1
  110. package/dist/escalations.js +1 -1
  111. package/dist/escalations.js.map +1 -1
  112. package/dist/evaluation-context.d.ts +2 -33
  113. package/dist/evaluation-context.d.ts.map +1 -1
  114. package/dist/evaluation-context.js +2 -56
  115. package/dist/evaluation-context.js.map +1 -1
  116. package/dist/focus-engine.d.ts +14 -5
  117. package/dist/focus-engine.d.ts.map +1 -1
  118. package/dist/focus-engine.js +35 -289
  119. package/dist/focus-engine.js.map +1 -1
  120. package/dist/focus-executor.d.ts +10 -791
  121. package/dist/focus-executor.d.ts.map +1 -1
  122. package/dist/focus-executor.js +81 -1572
  123. package/dist/focus-executor.js.map +1 -1
  124. package/dist/focus-lifecycle.js +2 -2
  125. package/dist/focus-lifecycle.js.map +1 -1
  126. package/dist/focus-loop-registry.d.ts +52 -0
  127. package/dist/focus-loop-registry.d.ts.map +1 -0
  128. package/dist/focus-loop-registry.js +328 -0
  129. package/dist/focus-loop-registry.js.map +1 -0
  130. package/dist/focus-merge.d.ts +1 -1
  131. package/dist/focus-merge.d.ts.map +1 -1
  132. package/dist/focus-merge.js +6 -6
  133. package/dist/focus-merge.js.map +1 -1
  134. package/dist/focus-phase.d.ts +4 -0
  135. package/dist/focus-phase.d.ts.map +1 -1
  136. package/dist/focus-phase.js +3 -3
  137. package/dist/focus-phase.js.map +1 -1
  138. package/dist/focus-prompt-builder.d.ts.map +1 -1
  139. package/dist/focus-prompt-builder.js +4 -1
  140. package/dist/focus-prompt-builder.js.map +1 -1
  141. package/dist/focus-stage-lifecycle/planning-release.d.ts +197 -0
  142. package/dist/focus-stage-lifecycle/planning-release.d.ts.map +1 -0
  143. package/dist/focus-stage-lifecycle/planning-release.js +312 -0
  144. package/dist/focus-stage-lifecycle/planning-release.js.map +1 -0
  145. package/dist/focus-stage-lifecycle/review-convergence.d.ts +133 -0
  146. package/dist/focus-stage-lifecycle/review-convergence.d.ts.map +1 -0
  147. package/dist/focus-stage-lifecycle/review-convergence.js +235 -0
  148. package/dist/focus-stage-lifecycle/review-convergence.js.map +1 -0
  149. package/dist/focus-stage-lifecycle/wedge-watchdog.d.ts +133 -0
  150. package/dist/focus-stage-lifecycle/wedge-watchdog.d.ts.map +1 -0
  151. package/dist/focus-stage-lifecycle/wedge-watchdog.js +365 -0
  152. package/dist/focus-stage-lifecycle/wedge-watchdog.js.map +1 -0
  153. package/dist/focus-stage-lifecycle.d.ts +22 -421
  154. package/dist/focus-stage-lifecycle.d.ts.map +1 -1
  155. package/dist/focus-stage-lifecycle.js +24 -832
  156. package/dist/focus-stage-lifecycle.js.map +1 -1
  157. package/dist/{git-activity.d.ts → git/activity.d.ts} +1 -1
  158. package/dist/git/activity.d.ts.map +1 -0
  159. package/dist/{git-activity.js → git/activity.js} +2 -2
  160. package/dist/git/activity.js.map +1 -0
  161. package/dist/{git-branch.d.ts → git/branch.d.ts} +2 -2
  162. package/dist/git/branch.d.ts.map +1 -0
  163. package/dist/{git-branch.js → git/branch.js} +2 -2
  164. package/dist/git/branch.js.map +1 -0
  165. package/dist/{git-fetch.d.ts → git/fetch.d.ts} +2 -2
  166. package/dist/git/fetch.d.ts.map +1 -0
  167. package/dist/{git-fetch.js → git/fetch.js} +1 -1
  168. package/dist/git/fetch.js.map +1 -0
  169. package/dist/{git-genesis.d.ts → git/genesis.d.ts} +3 -3
  170. package/dist/git/genesis.d.ts.map +1 -0
  171. package/dist/{git-genesis.js → git/genesis.js} +5 -5
  172. package/dist/git/genesis.js.map +1 -0
  173. package/dist/git/index.d.ts +36 -0
  174. package/dist/git/index.d.ts.map +1 -0
  175. package/dist/git/index.js +36 -0
  176. package/dist/git/index.js.map +1 -0
  177. package/dist/{git-integration.d.ts → git/integration.d.ts} +2 -2
  178. package/dist/git/integration.d.ts.map +1 -0
  179. package/dist/{git-integration.js → git/integration.js} +4 -4
  180. package/dist/git/integration.js.map +1 -0
  181. package/dist/{git-merge-helpers.d.ts → git/merge-helpers.d.ts} +3 -3
  182. package/dist/git/merge-helpers.d.ts.map +1 -0
  183. package/dist/{git-merge-helpers.js → git/merge-helpers.js} +3 -3
  184. package/dist/git/merge-helpers.js.map +1 -0
  185. package/dist/{git-merge-lock.d.ts → git/merge-lock.d.ts} +1 -1
  186. package/dist/git/merge-lock.d.ts.map +1 -0
  187. package/dist/{git-merge-lock.js → git/merge-lock.js} +1 -1
  188. package/dist/git/merge-lock.js.map +1 -0
  189. package/dist/{git-merge-strategies.d.ts → git/merge-strategies.d.ts} +2 -2
  190. package/dist/git/merge-strategies.d.ts.map +1 -0
  191. package/dist/{git-merge-strategies.js → git/merge-strategies.js} +3 -3
  192. package/dist/git/merge-strategies.js.map +1 -0
  193. package/dist/{git-merge.d.ts → git/merge.d.ts} +4 -4
  194. package/dist/git/merge.d.ts.map +1 -0
  195. package/dist/{git-merge.js → git/merge.js} +4 -4
  196. package/dist/git/merge.js.map +1 -0
  197. package/dist/{git-state-detector.d.ts → git/state-detector.d.ts} +2 -2
  198. package/dist/git/state-detector.d.ts.map +1 -0
  199. package/dist/{git-state-detector.js → git/state-detector.js} +7 -7
  200. package/dist/git/state-detector.js.map +1 -0
  201. package/dist/{git-types.d.ts → git/types.d.ts} +2 -2
  202. package/dist/git/types.d.ts.map +1 -0
  203. package/dist/{git-types.js → git/types.js} +1 -1
  204. package/dist/git/types.js.map +1 -0
  205. package/dist/{git-utils.d.ts → git/utils.d.ts} +1 -1
  206. package/dist/git/utils.d.ts.map +1 -0
  207. package/dist/{git-utils.js → git/utils.js} +2 -2
  208. package/dist/git/utils.js.map +1 -0
  209. package/dist/git.d.ts +5 -5
  210. package/dist/git.d.ts.map +1 -1
  211. package/dist/git.js +10 -10
  212. package/dist/git.js.map +1 -1
  213. package/dist/guard-engine.d.ts +3 -2
  214. package/dist/guard-engine.d.ts.map +1 -1
  215. package/dist/guard-engine.js +2 -2
  216. package/dist/guard-engine.js.map +1 -1
  217. package/dist/install-probe-tick.d.ts +63 -0
  218. package/dist/install-probe-tick.d.ts.map +1 -0
  219. package/dist/install-probe-tick.js +137 -0
  220. package/dist/install-probe-tick.js.map +1 -0
  221. package/dist/install-probe.d.ts +115 -0
  222. package/dist/install-probe.d.ts.map +1 -0
  223. package/dist/install-probe.js +197 -0
  224. package/dist/install-probe.js.map +1 -0
  225. package/dist/listener-auto-advance.d.ts.map +1 -1
  226. package/dist/listener-auto-advance.js +31 -0
  227. package/dist/listener-auto-advance.js.map +1 -1
  228. package/dist/listener.js +5 -5
  229. package/dist/listener.js.map +1 -1
  230. package/dist/{loop-context-audit-pass.d.ts → loops/context-audit-pass.d.ts} +4 -4
  231. package/dist/loops/context-audit-pass.d.ts.map +1 -0
  232. package/dist/{loop-context-audit-pass.js → loops/context-audit-pass.js} +7 -7
  233. package/dist/loops/context-audit-pass.js.map +1 -0
  234. package/dist/{loop-engine-types.d.ts → loops/engine-types.d.ts} +1 -1
  235. package/dist/loops/engine-types.d.ts.map +1 -0
  236. package/dist/{loop-engine-types.js → loops/engine-types.js} +1 -1
  237. package/dist/loops/engine-types.js.map +1 -0
  238. package/dist/{loop-engine.d.ts → loops/engine.d.ts} +6 -6
  239. package/dist/loops/engine.d.ts.map +1 -0
  240. package/dist/{loop-engine.js → loops/engine.js} +13 -13
  241. package/dist/loops/engine.js.map +1 -0
  242. package/dist/{loop-event-bus.d.ts → loops/event-bus.d.ts} +1 -1
  243. package/dist/loops/event-bus.d.ts.map +1 -0
  244. package/dist/{loop-event-bus.js → loops/event-bus.js} +1 -1
  245. package/dist/loops/event-bus.js.map +1 -0
  246. package/dist/loops/index.d.ts +33 -0
  247. package/dist/loops/index.d.ts.map +1 -0
  248. package/dist/loops/index.js +32 -0
  249. package/dist/loops/index.js.map +1 -0
  250. package/dist/{loop-llm-client.d.ts → loops/llm-client.d.ts} +3 -3
  251. package/dist/loops/llm-client.d.ts.map +1 -0
  252. package/dist/{loop-llm-client.js → loops/llm-client.js} +3 -3
  253. package/dist/loops/llm-client.js.map +1 -0
  254. package/dist/{loop-llm-flag.d.ts → loops/llm-flag.d.ts} +1 -1
  255. package/dist/loops/llm-flag.d.ts.map +1 -0
  256. package/dist/{loop-llm-flag.js → loops/llm-flag.js} +1 -1
  257. package/dist/loops/llm-flag.js.map +1 -0
  258. package/dist/{loop-operational-block.d.ts → loops/operational-block.d.ts} +1 -1
  259. package/dist/loops/operational-block.d.ts.map +1 -0
  260. package/dist/{loop-operational-block.js → loops/operational-block.js} +1 -1
  261. package/dist/loops/operational-block.js.map +1 -0
  262. package/dist/{loop-prompt-builder.d.ts → loops/prompt-builder.d.ts} +2 -2
  263. package/dist/loops/prompt-builder.d.ts.map +1 -0
  264. package/dist/{loop-prompt-builder.js → loops/prompt-builder.js} +1 -1
  265. package/dist/loops/prompt-builder.js.map +1 -0
  266. package/dist/{loop-variance.d.ts → loops/variance.d.ts} +1 -1
  267. package/dist/loops/variance.d.ts.map +1 -0
  268. package/dist/{loop-variance.js → loops/variance.js} +1 -1
  269. package/dist/loops/variance.js.map +1 -0
  270. package/dist/merge-back-loop.d.ts.map +1 -1
  271. package/dist/merge-back-loop.js +4 -3
  272. package/dist/merge-back-loop.js.map +1 -1
  273. package/dist/merge-detector.js +2 -2
  274. package/dist/merge-detector.js.map +1 -1
  275. package/dist/{nexus-endpoint-clearance.d.ts → nexus/endpoint-clearance.d.ts} +2 -2
  276. package/dist/nexus/endpoint-clearance.d.ts.map +1 -0
  277. package/dist/{nexus-endpoint-clearance.js → nexus/endpoint-clearance.js} +2 -2
  278. package/dist/nexus/endpoint-clearance.js.map +1 -0
  279. package/dist/{nexus-escalation-bridge.d.ts → nexus/escalation-bridge.d.ts} +1 -1
  280. package/dist/nexus/escalation-bridge.d.ts.map +1 -0
  281. package/dist/{nexus-escalation-bridge.js → nexus/escalation-bridge.js} +2 -2
  282. package/dist/nexus/escalation-bridge.js.map +1 -0
  283. package/dist/{nexus-incoming.d.ts → nexus/incoming.d.ts} +2 -2
  284. package/dist/nexus/incoming.d.ts.map +1 -0
  285. package/dist/{nexus-incoming.js → nexus/incoming.js} +2 -2
  286. package/dist/nexus/incoming.js.map +1 -0
  287. package/dist/nexus/index.d.ts +20 -0
  288. package/dist/nexus/index.d.ts.map +1 -0
  289. package/dist/nexus/index.js +20 -0
  290. package/dist/nexus/index.js.map +1 -0
  291. package/dist/{nexus-intake-spawn.d.ts → nexus/intake-spawn.d.ts} +3 -3
  292. package/dist/nexus/intake-spawn.d.ts.map +1 -0
  293. package/dist/{nexus-intake-spawn.js → nexus/intake-spawn.js} +1 -1
  294. package/dist/nexus/intake-spawn.js.map +1 -0
  295. package/dist/{nexus-intake.d.ts → nexus/intake.d.ts} +2 -2
  296. package/dist/nexus/intake.d.ts.map +1 -0
  297. package/dist/{nexus-intake.js → nexus/intake.js} +4 -4
  298. package/dist/nexus/intake.js.map +1 -0
  299. package/dist/{nexus-return.d.ts → nexus/return.d.ts} +3 -3
  300. package/dist/nexus/return.d.ts.map +1 -0
  301. package/dist/{nexus-return.js → nexus/return.js} +4 -4
  302. package/dist/nexus/return.js.map +1 -0
  303. package/dist/otlp/index.d.ts +19 -0
  304. package/dist/otlp/index.d.ts.map +1 -0
  305. package/dist/otlp/index.js +19 -0
  306. package/dist/otlp/index.js.map +1 -0
  307. package/dist/{otlp-log-parser.d.ts → otlp/log-parser.d.ts} +2 -2
  308. package/dist/otlp/log-parser.d.ts.map +1 -0
  309. package/dist/{otlp-log-parser.js → otlp/log-parser.js} +5 -6
  310. package/dist/otlp/log-parser.js.map +1 -0
  311. package/dist/{otlp-metric-parser.d.ts → otlp/metric-parser.d.ts} +2 -2
  312. package/dist/otlp/metric-parser.d.ts.map +1 -0
  313. package/dist/{otlp-metric-parser.js → otlp/metric-parser.js} +4 -5
  314. package/dist/otlp/metric-parser.js.map +1 -0
  315. package/dist/{otlp-port-manager.d.ts → otlp/port-manager.d.ts} +1 -1
  316. package/dist/otlp/port-manager.d.ts.map +1 -0
  317. package/dist/{otlp-port-manager.js → otlp/port-manager.js} +1 -1
  318. package/dist/otlp/port-manager.js.map +1 -0
  319. package/dist/{otlp-receiver.d.ts → otlp/receiver.d.ts} +2 -2
  320. package/dist/otlp/receiver.d.ts.map +1 -0
  321. package/dist/{otlp-receiver.js → otlp/receiver.js} +5 -33
  322. package/dist/otlp/receiver.js.map +1 -0
  323. package/dist/{otlp-types.d.ts → otlp/types.d.ts} +1 -9
  324. package/dist/otlp/types.d.ts.map +1 -0
  325. package/dist/{otlp-types.js → otlp/types.js} +1 -27
  326. package/dist/otlp/types.js.map +1 -0
  327. package/dist/pipeline-config.d.ts +1 -1
  328. package/dist/{prd-controller.d.ts → prd/controller.d.ts} +7 -7
  329. package/dist/prd/controller.d.ts.map +1 -0
  330. package/dist/{prd-controller.js → prd/controller.js} +11 -11
  331. package/dist/prd/controller.js.map +1 -0
  332. package/dist/{prd-divergence.d.ts → prd/divergence.d.ts} +2 -2
  333. package/dist/prd/divergence.d.ts.map +1 -0
  334. package/dist/{prd-divergence.js → prd/divergence.js} +1 -1
  335. package/dist/prd/divergence.js.map +1 -0
  336. package/dist/{prd-focus-pushdown.d.ts → prd/focus-pushdown.d.ts} +2 -2
  337. package/dist/prd/focus-pushdown.d.ts.map +1 -0
  338. package/dist/{prd-focus-pushdown.js → prd/focus-pushdown.js} +3 -3
  339. package/dist/prd/focus-pushdown.js.map +1 -0
  340. package/dist/{prd-frontier.d.ts → prd/frontier.d.ts} +2 -2
  341. package/dist/prd/frontier.d.ts.map +1 -0
  342. package/dist/{prd-frontier.js → prd/frontier.js} +1 -1
  343. package/dist/prd/frontier.js.map +1 -0
  344. package/dist/prd/index.d.ts +26 -0
  345. package/dist/prd/index.d.ts.map +1 -0
  346. package/dist/prd/index.js +25 -0
  347. package/dist/prd/index.js.map +1 -0
  348. package/dist/{prd-steward.d.ts → prd/steward.d.ts} +4 -4
  349. package/dist/prd/steward.d.ts.map +1 -0
  350. package/dist/{prd-steward.js → prd/steward.js} +4 -4
  351. package/dist/prd/steward.js.map +1 -0
  352. package/dist/{prd-viability.d.ts → prd/viability.d.ts} +2 -2
  353. package/dist/prd/viability.d.ts.map +1 -0
  354. package/dist/{prd-viability.js → prd/viability.js} +1 -1
  355. package/dist/prd/viability.js.map +1 -0
  356. package/dist/product-scaffold.js +2 -2
  357. package/dist/product-scaffold.js.map +1 -1
  358. package/dist/prompt-contradictions.d.ts +55 -0
  359. package/dist/prompt-contradictions.d.ts.map +1 -0
  360. package/dist/prompt-contradictions.js +114 -0
  361. package/dist/prompt-contradictions.js.map +1 -0
  362. package/dist/prompt-listing.d.ts +19 -0
  363. package/dist/prompt-listing.d.ts.map +1 -1
  364. package/dist/prompt-listing.js +49 -0
  365. package/dist/prompt-listing.js.map +1 -1
  366. package/dist/prompt-sections/execution-sections.d.ts +3 -2
  367. package/dist/prompt-sections/execution-sections.d.ts.map +1 -1
  368. package/dist/prompt-sections/execution-sections.js +70 -97
  369. package/dist/prompt-sections/execution-sections.js.map +1 -1
  370. package/dist/prompt-sections/persona-sections.d.ts +12 -0
  371. package/dist/prompt-sections/persona-sections.d.ts.map +1 -1
  372. package/dist/prompt-sections/persona-sections.js +29 -2
  373. package/dist/prompt-sections/persona-sections.js.map +1 -1
  374. package/dist/prompt-sections/role-sections.js +2 -2
  375. package/dist/prompt-sections/role-sections.js.map +1 -1
  376. package/dist/queries/context-assembly.d.ts +14 -4
  377. package/dist/queries/context-assembly.d.ts.map +1 -1
  378. package/dist/queries/context-assembly.js +14 -4
  379. package/dist/queries/context-assembly.js.map +1 -1
  380. package/dist/queries/context-lock-queries.js +1 -1
  381. package/dist/queries/context-lock-queries.js.map +1 -1
  382. package/dist/queries/deliveries.d.ts +45 -0
  383. package/dist/queries/deliveries.d.ts.map +1 -1
  384. package/dist/queries/deliveries.js +2 -0
  385. package/dist/queries/deliveries.js.map +1 -1
  386. package/dist/queries/focuses.d.ts +17 -7
  387. package/dist/queries/focuses.d.ts.map +1 -1
  388. package/dist/queries/focuses.js +27 -9
  389. package/dist/queries/focuses.js.map +1 -1
  390. package/dist/queries/index.d.ts +1 -1
  391. package/dist/queries/index.d.ts.map +1 -1
  392. package/dist/queries/index.js +1 -1
  393. package/dist/queries/index.js.map +1 -1
  394. package/dist/queries/schemas.d.ts +4 -0
  395. package/dist/queries/schemas.d.ts.map +1 -1
  396. package/dist/queries/schemas.js +8 -0
  397. package/dist/queries/schemas.js.map +1 -1
  398. package/dist/reality-pole.js +1 -1
  399. package/dist/resolvers/escalation-answers.d.ts +40 -0
  400. package/dist/resolvers/escalation-answers.d.ts.map +1 -1
  401. package/dist/resolvers/escalation-answers.js +54 -35
  402. package/dist/resolvers/escalation-answers.js.map +1 -1
  403. package/dist/resolvers/git-diff-against-base.d.ts.map +1 -1
  404. package/dist/resolvers/git-diff-against-base.js +4 -1
  405. package/dist/resolvers/git-diff-against-base.js.map +1 -1
  406. package/dist/resolvers/prd-context.js +1 -1
  407. package/dist/resolvers/shared/wiki.d.ts +27 -0
  408. package/dist/resolvers/shared/wiki.d.ts.map +1 -1
  409. package/dist/resolvers/shared/wiki.js +39 -0
  410. package/dist/resolvers/shared/wiki.js.map +1 -1
  411. package/dist/sensor-sweep.js +1 -1
  412. package/dist/spawn/delivered-manifest.d.ts +42 -0
  413. package/dist/spawn/delivered-manifest.d.ts.map +1 -0
  414. package/dist/spawn/delivered-manifest.js +64 -0
  415. package/dist/spawn/delivered-manifest.js.map +1 -0
  416. package/dist/spawn/model-routing.d.ts +277 -0
  417. package/dist/spawn/model-routing.d.ts.map +1 -0
  418. package/dist/spawn/model-routing.js +464 -0
  419. package/dist/spawn/model-routing.js.map +1 -0
  420. package/dist/spawn/process-spawn.d.ts +137 -0
  421. package/dist/spawn/process-spawn.d.ts.map +1 -0
  422. package/dist/spawn/process-spawn.js +385 -0
  423. package/dist/spawn/process-spawn.js.map +1 -0
  424. package/dist/spawn/prompt-assembly.d.ts +170 -0
  425. package/dist/spawn/prompt-assembly.d.ts.map +1 -0
  426. package/dist/spawn/prompt-assembly.js +272 -0
  427. package/dist/spawn/prompt-assembly.js.map +1 -0
  428. package/dist/spawn/shared.d.ts +96 -0
  429. package/dist/spawn/shared.d.ts.map +1 -0
  430. package/dist/spawn/shared.js +14 -0
  431. package/dist/spawn/shared.js.map +1 -0
  432. package/dist/spawn/spawn-decision.d.ts +239 -0
  433. package/dist/spawn/spawn-decision.d.ts.map +1 -0
  434. package/dist/spawn/spawn-decision.js +437 -0
  435. package/dist/spawn/spawn-decision.js.map +1 -0
  436. package/dist/spawn/worktree-session.d.ts +105 -0
  437. package/dist/spawn/worktree-session.d.ts.map +1 -0
  438. package/dist/spawn/worktree-session.js +216 -0
  439. package/dist/spawn/worktree-session.js.map +1 -0
  440. package/dist/spawner/lifecycle.js +5 -5
  441. package/dist/spawner/lifecycle.js.map +1 -1
  442. package/dist/spawner/resolution.js +4 -4
  443. package/dist/spawner/resolution.js.map +1 -1
  444. package/dist/stall-detector-config.d.ts +4 -0
  445. package/dist/stall-detector-config.d.ts.map +1 -1
  446. package/dist/stall-detector-config.js +6 -0
  447. package/dist/stall-detector-config.js.map +1 -1
  448. package/dist/state-cascade.js +1 -1
  449. package/dist/state-cascade.js.map +1 -1
  450. package/dist/trigger-executor.d.ts +5 -9
  451. package/dist/trigger-executor.d.ts.map +1 -1
  452. package/dist/trigger-executor.js +14 -36
  453. package/dist/trigger-executor.js.map +1 -1
  454. package/dist/types/config.d.ts +44 -0
  455. package/dist/types/config.d.ts.map +1 -1
  456. package/dist/types/focus.d.ts +13 -0
  457. package/dist/types/focus.d.ts.map +1 -1
  458. package/dist/types/workflow.d.ts +1 -3
  459. package/dist/types/workflow.d.ts.map +1 -1
  460. package/dist/unified-engine-lifecycle.js +1 -1
  461. package/dist/unified-init.d.ts +3 -3
  462. package/dist/unified-init.d.ts.map +1 -1
  463. package/dist/unified-init.js +9 -25
  464. package/dist/unified-init.js.map +1 -1
  465. package/dist/unified-shell.d.ts +3 -3
  466. package/dist/unified-shell.js +4 -4
  467. package/dist/unified-shell.js.map +1 -1
  468. package/dist/verification-baseline.d.ts +112 -0
  469. package/dist/verification-baseline.d.ts.map +1 -0
  470. package/dist/verification-baseline.js +264 -0
  471. package/dist/verification-baseline.js.map +1 -0
  472. package/dist/verification-config.d.ts +53 -0
  473. package/dist/verification-config.d.ts.map +1 -0
  474. package/dist/verification-config.js +72 -0
  475. package/dist/verification-config.js.map +1 -0
  476. package/dist/verification-default-on.d.ts +87 -0
  477. package/dist/verification-default-on.d.ts.map +1 -0
  478. package/dist/verification-default-on.js +186 -0
  479. package/dist/verification-default-on.js.map +1 -0
  480. package/dist/verification-deterministic.d.ts +56 -0
  481. package/dist/verification-deterministic.d.ts.map +1 -0
  482. package/dist/verification-deterministic.js +123 -0
  483. package/dist/verification-deterministic.js.map +1 -0
  484. package/dist/verification-engine.d.ts +22 -15
  485. package/dist/verification-engine.d.ts.map +1 -1
  486. package/dist/verification-engine.js +94 -65
  487. package/dist/verification-engine.js.map +1 -1
  488. package/dist/verification-failure-parser.d.ts +48 -0
  489. package/dist/verification-failure-parser.d.ts.map +1 -0
  490. package/dist/verification-failure-parser.js +102 -0
  491. package/dist/verification-failure-parser.js.map +1 -0
  492. package/dist/verification-feedback.d.ts +58 -0
  493. package/dist/verification-feedback.d.ts.map +1 -0
  494. package/dist/verification-feedback.js +110 -0
  495. package/dist/verification-feedback.js.map +1 -0
  496. package/dist/{worktree-focus.d.ts → worktree/focus.d.ts} +2 -2
  497. package/dist/worktree/focus.d.ts.map +1 -0
  498. package/dist/{worktree-focus.js → worktree/focus.js} +7 -7
  499. package/dist/worktree/focus.js.map +1 -0
  500. package/dist/worktree/index.d.ts +16 -0
  501. package/dist/worktree/index.d.ts.map +1 -0
  502. package/dist/worktree/index.js +16 -0
  503. package/dist/worktree/index.js.map +1 -0
  504. package/dist/{worktree-safety.d.ts → worktree/safety.d.ts} +1 -1
  505. package/dist/worktree/safety.d.ts.map +1 -0
  506. package/dist/{worktree-safety.js → worktree/safety.js} +2 -2
  507. package/dist/worktree/safety.js.map +1 -0
  508. package/dist/{worktree-state.d.ts → worktree/state.d.ts} +1 -1
  509. package/dist/worktree/state.d.ts.map +1 -0
  510. package/dist/{worktree-state.js → worktree/state.js} +6 -6
  511. package/dist/worktree/state.js.map +1 -0
  512. package/dist/worktree.d.ts +1 -1
  513. package/dist/worktree.js +5 -5
  514. package/dist/worktree.js.map +1 -1
  515. package/package.json +5 -4
  516. package/dist/git-activity.d.ts.map +0 -1
  517. package/dist/git-activity.js.map +0 -1
  518. package/dist/git-branch.d.ts.map +0 -1
  519. package/dist/git-branch.js.map +0 -1
  520. package/dist/git-fetch.d.ts.map +0 -1
  521. package/dist/git-fetch.js.map +0 -1
  522. package/dist/git-genesis.d.ts.map +0 -1
  523. package/dist/git-genesis.js.map +0 -1
  524. package/dist/git-integration.d.ts.map +0 -1
  525. package/dist/git-integration.js.map +0 -1
  526. package/dist/git-merge-helpers.d.ts.map +0 -1
  527. package/dist/git-merge-helpers.js.map +0 -1
  528. package/dist/git-merge-lock.d.ts.map +0 -1
  529. package/dist/git-merge-lock.js.map +0 -1
  530. package/dist/git-merge-strategies.d.ts.map +0 -1
  531. package/dist/git-merge-strategies.js.map +0 -1
  532. package/dist/git-merge.d.ts.map +0 -1
  533. package/dist/git-merge.js.map +0 -1
  534. package/dist/git-state-detector.d.ts.map +0 -1
  535. package/dist/git-state-detector.js.map +0 -1
  536. package/dist/git-types.d.ts.map +0 -1
  537. package/dist/git-types.js.map +0 -1
  538. package/dist/git-utils.d.ts.map +0 -1
  539. package/dist/git-utils.js.map +0 -1
  540. package/dist/loop-context-audit-pass.d.ts.map +0 -1
  541. package/dist/loop-context-audit-pass.js.map +0 -1
  542. package/dist/loop-engine-types.d.ts.map +0 -1
  543. package/dist/loop-engine-types.js.map +0 -1
  544. package/dist/loop-engine.d.ts.map +0 -1
  545. package/dist/loop-engine.js.map +0 -1
  546. package/dist/loop-event-bus.d.ts.map +0 -1
  547. package/dist/loop-event-bus.js.map +0 -1
  548. package/dist/loop-llm-client.d.ts.map +0 -1
  549. package/dist/loop-llm-client.js.map +0 -1
  550. package/dist/loop-llm-flag.d.ts.map +0 -1
  551. package/dist/loop-llm-flag.js.map +0 -1
  552. package/dist/loop-operational-block.d.ts.map +0 -1
  553. package/dist/loop-operational-block.js.map +0 -1
  554. package/dist/loop-prompt-builder.d.ts.map +0 -1
  555. package/dist/loop-prompt-builder.js.map +0 -1
  556. package/dist/loop-variance.d.ts.map +0 -1
  557. package/dist/loop-variance.js.map +0 -1
  558. package/dist/nexus-endpoint-clearance.d.ts.map +0 -1
  559. package/dist/nexus-endpoint-clearance.js.map +0 -1
  560. package/dist/nexus-escalation-bridge.d.ts.map +0 -1
  561. package/dist/nexus-escalation-bridge.js.map +0 -1
  562. package/dist/nexus-incoming.d.ts.map +0 -1
  563. package/dist/nexus-incoming.js.map +0 -1
  564. package/dist/nexus-intake-spawn.d.ts.map +0 -1
  565. package/dist/nexus-intake-spawn.js.map +0 -1
  566. package/dist/nexus-intake.d.ts.map +0 -1
  567. package/dist/nexus-intake.js.map +0 -1
  568. package/dist/nexus-return.d.ts.map +0 -1
  569. package/dist/nexus-return.js.map +0 -1
  570. package/dist/otlp-log-parser.d.ts.map +0 -1
  571. package/dist/otlp-log-parser.js.map +0 -1
  572. package/dist/otlp-metric-parser.d.ts.map +0 -1
  573. package/dist/otlp-metric-parser.js.map +0 -1
  574. package/dist/otlp-port-manager.d.ts.map +0 -1
  575. package/dist/otlp-port-manager.js.map +0 -1
  576. package/dist/otlp-receiver.d.ts.map +0 -1
  577. package/dist/otlp-receiver.js.map +0 -1
  578. package/dist/otlp-types.d.ts.map +0 -1
  579. package/dist/otlp-types.js.map +0 -1
  580. package/dist/prd-controller.d.ts.map +0 -1
  581. package/dist/prd-controller.js.map +0 -1
  582. package/dist/prd-divergence.d.ts.map +0 -1
  583. package/dist/prd-divergence.js.map +0 -1
  584. package/dist/prd-focus-pushdown.d.ts.map +0 -1
  585. package/dist/prd-focus-pushdown.js.map +0 -1
  586. package/dist/prd-frontier.d.ts.map +0 -1
  587. package/dist/prd-frontier.js.map +0 -1
  588. package/dist/prd-steward.d.ts.map +0 -1
  589. package/dist/prd-steward.js.map +0 -1
  590. package/dist/prd-viability.d.ts.map +0 -1
  591. package/dist/prd-viability.js.map +0 -1
  592. package/dist/worktree-focus.d.ts.map +0 -1
  593. package/dist/worktree-focus.js.map +0 -1
  594. package/dist/worktree-safety.d.ts.map +0 -1
  595. package/dist/worktree-safety.js.map +0 -1
  596. package/dist/worktree-state.d.ts.map +0 -1
  597. package/dist/worktree-state.js.map +0 -1
@@ -0,0 +1,464 @@
1
+ /**
2
+ * Model routing seam for the focus-team spawn path.
3
+ *
4
+ * Extracted verbatim from focus-executor.ts (behavior-preserving): the pure
5
+ * model/engine selection helpers, the per-pass local-model routing + host-control
6
+ * swap decisioning, the single-host GPU conflict surfacing, and the CLI-arg
7
+ * builder they feed. focus-executor.ts re-exports this surface for backward
8
+ * compatibility, so external importers keep resolving these symbols from
9
+ * '../focus-executor.js'.
10
+ *
11
+ * Cycle rule: this module must NOT import from '../focus-executor.js'.
12
+ */
13
+ import { loadEnvConfig, ESCALATION_REASONS } from '@telora/daemon-core';
14
+ import { createEscalation } from '../queries/issues.js';
15
+ import { resolveTeamModel, resolveLocalModelRefPrecedence } from '../model-resolution.js';
16
+ import { getLocalModel, getLocalModelSecret } from '../queries/local-models.js';
17
+ import { codexSafeModelAlias, writeLocalModelCodexHome, TELORA_LOCAL_API_KEY_ENV, } from '../cli/codex-provision.js';
18
+ import { startCodexMcpProxy, shouldRouteLocalModelThroughProxy, } from '../backends/codex/codex-mcp-proxy.js';
19
+ import { detectHostCapability, ensureLoaded, resolveSafeLoadOptions, getStatus, decideSwap, hostRootFromBaseUrl, observeHostSwap, claimResidentHost, detectSingleHostModelConflict, shouldSurfaceHostConflictOnce, } from '../host-control/index.js';
20
+ import { hasActiveTeam } from '../focus-team-state.js';
21
+ /**
22
+ * Resolve the isolated CODEX_HOME to set on a spawn, or undefined when none
23
+ * applies. Pure + testable: only a codex-engine spawn against a product that
24
+ * carries a provisioned codexHome gets the override; every other case (claude
25
+ * engine, or a cloud product with no codexHome) returns undefined so the spawn
26
+ * environment is byte-for-byte unchanged.
27
+ */
28
+ export function codexHomeForSpawn(engineId, config) {
29
+ return engineId === 'codex' && config.codexHome ? config.codexHome : undefined;
30
+ }
31
+ /**
32
+ * Select the per-pass local model ref to resolve for this spawn, or null.
33
+ *
34
+ * Pure + testable. A ref applies ONLY to a codex-engine spawn. The ref resolves
35
+ * under the unified Focus > Workflow > Default precedence (single-sourced in
36
+ * model-resolution.resolveLocalModelRefPrecedence): the focus's per-pass
37
+ * localModelOverride entry wins; absent that, the stage directive's localModel
38
+ * is inherited; absent both, null (the pass runs on the engine's default model).
39
+ * A claude engine or a blank ref returns null so the spawn keeps its
40
+ * per-product / engine-default behavior unchanged.
41
+ */
42
+ export function selectLocalModelRef(engineId, pass, localModelOverride, stageDirectiveLocalModel) {
43
+ if (engineId !== 'codex')
44
+ return null;
45
+ return resolveLocalModelRefPrecedence(localModelOverride?.[pass], stageDirectiveLocalModel);
46
+ }
47
+ export function decideLocalModelRouting(ref, coords, apiKey) {
48
+ if (!ref)
49
+ return { kind: 'none' };
50
+ if (!coords)
51
+ return { kind: 'fallback' };
52
+ return { kind: 'route', coords, apiKey: apiKey?.trim() ? apiKey : null };
53
+ }
54
+ /**
55
+ * Pure gate: should the daemon perform a host-control model swap before this
56
+ * spawn? (Local model host control, D2.) True ONLY when routing resolved a local
57
+ * model for this pass AND the host advertises the optional control capability.
58
+ * A non-controllable host (today's behavior: the operator pre-loads the model in
59
+ * the studio) yields false -> NO swap, spawn proceeds unchanged. A pass with no
60
+ * routed local model (claude, no override) also yields false. Exported so the
61
+ * load-or-skip decision is unit-testable with NO HTTP.
62
+ */
63
+ export function shouldSwapForPass(input) {
64
+ return input.routing.kind === 'route' && input.capability.controllable;
65
+ }
66
+ /**
67
+ * Resolve the effective model id for a spawn, applying the single team-model
68
+ * precedence (focus override -> stage directive -> CLI default) via
69
+ * resolveTeamModel. This is the SAME helper used at stage respawn, so the two
70
+ * paths can never diverge on ordering.
71
+ *
72
+ * The focus-override slot folds in the selected local-Codex model: when this
73
+ * pass routes to a controllable Codex home, `codexModel` IS the focus's
74
+ * explicit pick and must win exactly like a focus pipeline_config.model would.
75
+ * `directiveModel` has already been filtered through
76
+ * selectDirectiveModelForSpawn() (nulled when the backend cannot run it, or
77
+ * when a focus override is present), so it only ever reaches here as a
78
+ * legitimate stage fallback.
79
+ *
80
+ * Pure + testable. Used by spawnFocusTeam to produce effectivePipelineConfig.model.
81
+ */
82
+ export function resolveEffectiveModel(directiveModel, spawnCodexHome, codexModel, pipelineModel) {
83
+ const focusOverrideModel = (spawnCodexHome && codexModel ? codexModel : null) ?? pipelineModel ?? null;
84
+ return resolveTeamModel(focusOverrideModel, directiveModel);
85
+ }
86
+ /**
87
+ * A cloud model id the Claude backend can run: the full claude-* ids
88
+ * (claude-opus-4-8, claude-sonnet-4-6, ...) AND the bare aliases Claude Code
89
+ * accepts (opus, sonnet, haiku, fable -- used across the daemon, e.g.
90
+ * audit-phase's AUDIT_DEFAULT_MODEL='opus'). Anything else (gpt-5-codex,
91
+ * gemma-4-12b, ...) is treated as not-Claude so it cannot reach the claude CLI.
92
+ */
93
+ const CLAUDE_MODEL_PREFIXES = ['claude', 'opus', 'sonnet', 'haiku', 'fable'];
94
+ export function isClaudeModelId(model) {
95
+ if (typeof model !== 'string')
96
+ return false;
97
+ const normalized = model.trim().toLowerCase();
98
+ return CLAUDE_MODEL_PREFIXES.some((prefix) => normalized.startsWith(prefix));
99
+ }
100
+ /**
101
+ * Select the pipeline model fallback to feed into resolveEffectiveModel().
102
+ *
103
+ * Hosted Codex runs through the user's Codex account. Some registry labels
104
+ * exposed in the UI (for example gpt-5-codex) are not valid `codex exec
105
+ * --model` values for every account, and passing them fails the run before the
106
+ * agent starts. Local-model Codex still needs an explicit model, and Claude
107
+ * keeps the existing pipeline model behavior.
108
+ *
109
+ * Engine-compat (the per-pass bleed guard): product_focuses.pipeline_config.model
110
+ * is a SINGLE focus-wide value shared across passes, but each pass resolves its
111
+ * own engine. A pass whose engine resolved to claude can only run a claude-family
112
+ * model -- so a coding-pass codex model (e.g. gpt-5-codex) selected on the focus
113
+ * must NOT bleed into a claude review pass. When it would, null it so the claude
114
+ * backend picks its own default rather than receiving `--model gpt-5-codex` and
115
+ * erroring out. (The symmetric codex case is handled above + by spawnCodexModel
116
+ * routing; local-codex models reach the spawn via spawnCodexModel, not here.)
117
+ */
118
+ export function selectPipelineModelForSpawn(engineId, spawnCodexHome, pipelineModel) {
119
+ if (engineId === 'codex' && !spawnCodexHome)
120
+ return null;
121
+ if (engineId === 'claude' && !isClaudeModelId(pipelineModel))
122
+ return null;
123
+ return pipelineModel ?? null;
124
+ }
125
+ /**
126
+ * Select whether a workflow directive's model may reach the backend.
127
+ *
128
+ * The focus pass selection is the source of truth for team launches. Stage
129
+ * directives contribute prompt/context; their model field is only a legacy
130
+ * fallback when the focus/pass has no selected model and the backend can run
131
+ * that model. In particular, never pass a Claude directive model to Codex.
132
+ */
133
+ export function selectDirectiveModelForSpawn(engineId, directiveModel, focusSelectedModel) {
134
+ if (!directiveModel)
135
+ return null;
136
+ if (focusSelectedModel)
137
+ return null;
138
+ if (engineId === 'codex')
139
+ return null;
140
+ return directiveModel;
141
+ }
142
+ /**
143
+ * Build CLI args for the team lead via the selected backend.
144
+ *
145
+ * Engine-specific flag construction lives in the backend; resume uses the
146
+ * backend's dedicated resume-arg builder. Exported for the spawner barrel
147
+ * surface (legacy ./team-spawner.js consumers).
148
+ */
149
+ export function buildAgentArgs(backend, config, worktreePath, pipelineConfig, resumeSessionId, allowedTools, readOnly) {
150
+ // allowedTools comes from the focus role's agent_roles.allowed_tools. The
151
+ // backend applies least-privilege scoping when non-empty; empty/absent =>
152
+ // engine default tool set (documented default policy).
153
+ const base = { config, worktreePath, model: pipelineConfig?.model ?? null, allowedTools, readOnly };
154
+ return resumeSessionId
155
+ ? backend.buildResumeArgs({ ...base, resumeSessionId })
156
+ : backend.buildSpawnArgs(base);
157
+ }
158
+ /**
159
+ * Phase: resolve the per-pass local-model routing for a codex spawn.
160
+ *
161
+ * Wraps the fetch (getLocalModel / getLocalModelSecret) + the pure decision
162
+ * (selectLocalModelRef -> decideLocalModelRouting) and, on 'route', provisions
163
+ * the per-model CODEX_HOME (writeLocalModelCodexHome) -- returning the codexHome
164
+ * the caller points the spawn at. The key VALUE comes from Telora (D8), never a
165
+ * host env var. Behavior byte-identical to the original inline block; only the
166
+ * apply-side (session-terminal write on skip, env injection on route) stays in
167
+ * the caller.
168
+ */
169
+ export async function resolveLocalModelConfig(args, deps = {}) {
170
+ const getModel = deps.getLocalModel ?? getLocalModel;
171
+ const getSecret = deps.getLocalModelSecret ?? getLocalModelSecret;
172
+ const writeCodexHome = deps.writeLocalModelCodexHome ?? writeLocalModelCodexHome;
173
+ const localModelRef = selectLocalModelRef(args.engineId, args.enginePass, args.localModelOverride, args.stageDirectiveLocalModel);
174
+ // getLocalModel + getLocalModelSecret (the DB calls) run only when a ref
175
+ // exists; decideLocalModelRouting is the pure decision over their results.
176
+ const coords = localModelRef ? await getModel(localModelRef) : null;
177
+ const apiKey = localModelRef ? await getSecret(localModelRef) : null;
178
+ const routing = decideLocalModelRouting(localModelRef, coords, apiKey);
179
+ switch (routing.kind) {
180
+ case 'none':
181
+ return { kind: 'none' };
182
+ case 'fallback':
183
+ return { kind: 'fallback', ref: localModelRef };
184
+ case 'route': {
185
+ const { codexHome } = writeCodexHome(routing.coords.id, {
186
+ baseUrl: routing.coords.baseUrl,
187
+ model: routing.coords.model,
188
+ wireApi: routing.coords.wireApi ?? undefined,
189
+ requiresApiKey: routing.apiKey !== null,
190
+ });
191
+ return {
192
+ kind: 'route',
193
+ codexHome,
194
+ codexModel: codexSafeModelAlias(routing.coords.model),
195
+ apiKey: routing.apiKey,
196
+ coords: routing.coords,
197
+ };
198
+ }
199
+ }
200
+ }
201
+ /**
202
+ * Surface (do NOT silently swap) two DIFFERENT local models bound to the coding
203
+ * vs review pass of one focus that share a single GPU host (#9). On a single
204
+ * card the two bindings force an evict+load swap on every pass alternation and
205
+ * fight over the GPU (the live incident: 0/56 routing attempts succeeded). The
206
+ * daemon must make the conflict VISIBLE rather than thrash silently.
207
+ *
208
+ * Cheap early-out: only when the focus pins a local model for BOTH passes and
209
+ * the two refs differ do we resolve coordinates (two getLocalModel reads) and run
210
+ * the pure detector. A conflict (same host root, different served models) is
211
+ * raised ONCE per focus per daemon run (shouldSurfaceHostConflictOnce) as a log
212
+ * line + a single escalation -- never re-raised every poll. Returns whether a new
213
+ * surfacing was raised this call. Best-effort: an escalation-create failure is
214
+ * logged, never fatal to the spawn.
215
+ */
216
+ export async function surfaceSingleHostModelConflict(args, deps = {}) {
217
+ const getModel = deps.getLocalModel ?? getLocalModel;
218
+ const makeEscalation = deps.createEscalation ?? createEscalation;
219
+ const codingRef = args.localModelOverride?.coding?.trim() || null;
220
+ const reviewRef = args.localModelOverride?.review?.trim() || null;
221
+ // The conflict needs a distinct local model pinned on BOTH passes.
222
+ if (!codingRef || !reviewRef || codingRef === reviewRef)
223
+ return { surfaced: false };
224
+ const [codingCoords, reviewCoords] = await Promise.all([getModel(codingRef), getModel(reviewRef)]);
225
+ if (!codingCoords || !reviewCoords)
226
+ return { surfaced: false };
227
+ const bindings = [
228
+ { pass: 'coding', modelId: codingCoords.model, baseUrl: codingCoords.baseUrl },
229
+ { pass: 'review', modelId: reviewCoords.model, baseUrl: reviewCoords.baseUrl },
230
+ ];
231
+ const result = detectSingleHostModelConflict(bindings);
232
+ if (!result.conflict)
233
+ return { surfaced: false };
234
+ if (!shouldSurfaceHostConflictOnce(args.focusId))
235
+ return { surfaced: false };
236
+ const detail = `Focus "${args.focusName}" pins two different local models to one GPU host ` +
237
+ `(${result.root}): coding="${codingCoords.name}" (${codingCoords.model}) vs ` +
238
+ `review="${reviewCoords.name}" (${reviewCoords.model}). On a single GPU these force an ` +
239
+ `evict+load swap on every pass alternation and fight over the card. Pin both passes to the ` +
240
+ `same local model, or move one pass to a different host / a cloud engine.`;
241
+ console.warn(`[focus-executor] Host-control: ${detail}`);
242
+ try {
243
+ await makeEscalation({
244
+ organizationId: args.organizationId,
245
+ issueId: null,
246
+ reasonType: ESCALATION_REASONS.BLOCKED_BY_EXTERNAL,
247
+ description: detail,
248
+ whatWasTried: 'Detected at spawn that the coding and review passes resolve to different local models on the same GPU host.',
249
+ helpNeeded: 'Pin both passes to one local model, or route one pass to a separate host or a cloud engine, so the single GPU is not swapped on every pass.',
250
+ escalationKind: 'single_host_model_conflict',
251
+ ...(args.productId ? { productId: args.productId } : {}),
252
+ focusId: args.focusId,
253
+ metadata: {
254
+ host_root: result.root,
255
+ coding_model: codingCoords.model,
256
+ review_model: reviewCoords.model,
257
+ },
258
+ });
259
+ }
260
+ catch (err) {
261
+ console.warn(`[focus-executor] Failed to file single_host_model_conflict escalation for "${args.focusName}":`, err.message);
262
+ }
263
+ return { surfaced: true };
264
+ }
265
+ /**
266
+ * Phase: resolve the per-product CODEX_HOME default, apply per-pass local-model
267
+ * routing (fallback / route), select the effective model, and build the CLI
268
+ * args. Returns 'ready' with the args + the model/env bits the spawn needs.
269
+ */
270
+ export async function resolveSpawnModel(args) {
271
+ const { resolvedEngine, enginePass, localModelOverride, stageDirectiveLocalModel, config, directiveModel, pendingFocusOverrideModel, pipelineConfig, backend, worktreePath, resumeId, role, readOnly, focusName, focusId, } = args;
272
+ // Single source of truth for the focus override at this spawn: a respawn's
273
+ // snapshot wins over the live pipeline_config.model; otherwise the live config
274
+ // carries it. Both initial spawn and respawn funnel through resolveTeamModel
275
+ // below, so the precedence (focus override -> stage -> CLI) is identical.
276
+ const focusOverrideModel = pendingFocusOverrideModel ?? pipelineConfig?.model ?? null;
277
+ // Resolve the per-product isolated CODEX_HOME for this spawn (undefined for
278
+ // claude engines and cloud products with no provisioned codexHome -- those
279
+ // spawns are byte-for-byte unaffected).
280
+ let spawnCodexHome = codexHomeForSpawn(resolvedEngine.engineId, config);
281
+ let spawnCodexModel = config.codexModel;
282
+ let isLocalModelPass = false;
283
+ // Per-pass local model routing: if this codex pass selected a registered local
284
+ // model, resolve it to coordinates, provision a per-model CODEX_HOME, and route
285
+ // the spawn there -- overriding the per-product codexHome/codexModel for this
286
+ // pass only. Absent ref => the per-product default above is kept.
287
+ const localModelConfig = await resolveLocalModelConfig({
288
+ engineId: resolvedEngine.engineId,
289
+ enginePass,
290
+ localModelOverride,
291
+ stageDirectiveLocalModel,
292
+ });
293
+ // The Telora-resolved key VALUE injected into the spawn env (under the fixed
294
+ // TELORA_LOCAL_API_KEY name) for a routed local-model pass; null otherwise.
295
+ let spawnLocalModelKey = null;
296
+ if (localModelConfig.kind === 'fallback') {
297
+ console.warn(`[focus-executor] Focus "${focusName}" ${enginePass} pass selected local model ` +
298
+ `${(localModelConfig.ref ?? '').slice(0, 8)} but it is not in the registry; falling back to the ` +
299
+ `per-product default model.`);
300
+ }
301
+ else if (localModelConfig.kind === 'route') {
302
+ const { codexHome, codexModel, apiKey, coords } = localModelConfig;
303
+ spawnCodexHome = codexHome;
304
+ spawnCodexModel = codexModel;
305
+ spawnLocalModelKey = apiKey;
306
+ isLocalModelPass = true;
307
+ console.log(`[focus-executor] Routing "${focusName}" ${enginePass} pass to local model ` +
308
+ `"${coords.name}" (${coords.model} @ ${coords.baseUrl}); CODEX_HOME=${codexHome}, ` +
309
+ (apiKey
310
+ ? `key from Telora (env ${TELORA_LOCAL_API_KEY_ENV}).`
311
+ : 'unauthenticated endpoint.'));
312
+ // Host-control swap (D2): on a CONTROLLABLE host, load/unload the selected
313
+ // per-pass model around this pass -- a sequential single-GPU swap (one model
314
+ // resident at a time) so the coding-vs-review model runs end-to-end with NO
315
+ // manual studio swap. On a non-controllable host this is a no-op (today's
316
+ // behavior: the operator pre-loads the model). A swap FAILURE must NOT spawn
317
+ // against a not-yet-loaded model: skip this tick (the 30s poll re-attempts).
318
+ const capability = await detectHostCapability(coords.baseUrl, apiKey);
319
+ if (shouldSwapForPass({ routing: { kind: 'route', coords, apiKey }, capability })) {
320
+ const root = hostRootFromBaseUrl(coords.baseUrl);
321
+ // Fast inline path (#1): if the target is ALREADY resident + ready, spawn
322
+ // THIS tick -- no detour through the detached swap. A single bounded
323
+ // /v1/status read; org-prefix-tolerant via decideSwap/modelIdsMatch.
324
+ let alreadyResident = false;
325
+ try {
326
+ const status = await getStatus(coords.baseUrl, apiKey);
327
+ alreadyResident =
328
+ decideSwap({
329
+ current: { modelId: status.loadedModelId, ready: status.ready },
330
+ target: coords.model,
331
+ }).action === 'noop';
332
+ }
333
+ catch {
334
+ // Transient status-read failure -> fall through to the managed async
335
+ // swap, which retries the load + readiness off the poll-critical path.
336
+ }
337
+ if (alreadyResident) {
338
+ // Claim the per-host residency lock (#4) so a second focus on this host
339
+ // cannot start a swap that evicts our resident model mid-pass.
340
+ const claim = claimResidentHost({
341
+ root,
342
+ targetModel: coords.model,
343
+ focusId,
344
+ isFocusActive: (id) => hasActiveTeam(id),
345
+ });
346
+ if (claim.status === 'busy_other') {
347
+ console.log(`[focus-executor] Host-control: host for "${coords.name}" is held by another ` +
348
+ `focus's running pass; deferring "${focusName}" ${enginePass} pass to avoid eviction.`);
349
+ return { kind: 'still_loading', coords, reason: 'host_busy_other_focus' };
350
+ }
351
+ console.log(`[focus-executor] Host-control: model "${coords.name}" (${coords.model}) already ` +
352
+ `resident + ready for "${focusName}" ${enginePass} pass.`);
353
+ }
354
+ else {
355
+ // A load is needed. Run it OFF the serial poll loop via the swap manager
356
+ // (#3) so a cold load (up to the 180s budget) does not stall every other
357
+ // focus/product. The manager also enforces the per-host residency lock
358
+ // (#4): a second focus on this host defers rather than evicting an
359
+ // in-flight model. The load is detached -- never awaited here.
360
+ const loadTimeoutMs = loadEnvConfig().TELORA_HOST_CONTROL_LOAD_TIMEOUT_MS;
361
+ const observation = observeHostSwap({
362
+ root,
363
+ targetModel: coords.model,
364
+ focusId,
365
+ isFocusActive: (id) => hasActiveTeam(id),
366
+ runLoad: async () => {
367
+ // D3 sizing seam: hardware-aware safe context that RESERVES the
368
+ // candidate model's weights before sizing the KV cache. The weights
369
+ // size + native context come from the registry coordinates (the
370
+ // local_models sizing-metadata columns); when unset the sizer
371
+ // degrades safely (no reservation / ceiling clamp). FAIL-SAFE to the
372
+ // fixed DEFAULT_MAX_SEQ_LENGTH when host hardware data is unavailable.
373
+ const sizing = await resolveSafeLoadOptions(coords.baseUrl, coords.model, { modelSizeMb: coords.modelSizeMb, nativeContext: coords.nativeContext }, apiKey);
374
+ if (sizing.source === 'fallback') {
375
+ console.warn(`[focus-executor] Host-control sizing unavailable for "${coords.name}" ` +
376
+ `(${coords.model}); falling back to the fixed default context ` +
377
+ `${sizing.maxSeqLength}. Check the host's /api/system/hardware endpoint.`);
378
+ }
379
+ else {
380
+ console.log(`[focus-executor] Host-control sizing for "${coords.name}" (${coords.model}): ` +
381
+ `max_seq_length=${sizing.maxSeqLength}` +
382
+ (sizing.cacheTypeKv ? `, cache_type_kv=${sizing.cacheTypeKv}` : '') +
383
+ (sizing.quantRequired ? ' (quant-required, marginal headroom)' : '') +
384
+ (sizing.marginal && !sizing.quantRequired ? ' (marginal headroom)' : '') + '.');
385
+ }
386
+ // Load-scoped POST timeout: a host that blocks /v1/load until the cold
387
+ // load completes must not be cut by the generic 5s fetch timeout.
388
+ await ensureLoaded(coords.baseUrl, coords.model, {
389
+ maxSeqLength: sizing.maxSeqLength,
390
+ loadTimeoutMs,
391
+ ...(sizing.cacheTypeKv !== undefined ? { cacheTypeKv: sizing.cacheTypeKv } : {}),
392
+ }, apiKey);
393
+ console.log(`[focus-executor] Host-control: local model "${coords.name}" (${coords.model}) ` +
394
+ `loaded + ready (off-loop swap complete).`);
395
+ },
396
+ });
397
+ if (observation.status === 'loading') {
398
+ console.log(`[focus-executor] Host-control: model "${coords.name}" (${coords.model}) is loading ` +
399
+ `for "${focusName}" ${enginePass} pass; deferring spawn (load runs off the poll loop).`);
400
+ return { kind: 'still_loading', coords, reason: 'model_loading' };
401
+ }
402
+ if (observation.status === 'busy_other') {
403
+ console.log(`[focus-executor] Host-control: host for "${coords.name}" is held by another ` +
404
+ `focus's running pass; deferring "${focusName}" ${enginePass} pass to avoid eviction.`);
405
+ return { kind: 'still_loading', coords, reason: 'host_busy_other_focus' };
406
+ }
407
+ if (observation.status === 'failed') {
408
+ console.error(`[focus-executor] Host-control swap to load "${coords.name}" (${coords.model}) for ` +
409
+ `"${focusName}" ${enginePass} pass FAILED: ${observation.error}. Not spawning against ` +
410
+ `an unloaded model; will re-attempt next poll.`);
411
+ return { kind: 'skip_load', coords, dbMessage: observation.error };
412
+ }
413
+ // observation.status === 'ready' -- the detached load completed on a
414
+ // prior tick; the model is resident and residency is held. Proceed.
415
+ console.log(`[focus-executor] Host-control: model "${coords.name}" (${coords.model}) ready for ` +
416
+ `"${focusName}" ${enginePass} pass (off-loop swap complete).`);
417
+ }
418
+ }
419
+ }
420
+ // Model selection: ONE precedence (focus override -> stage directive -> CLI),
421
+ // applied identically at initial spawn and at stage respawn. The engine-compat
422
+ // prefilters below null out an input the resolved backend cannot run; the
423
+ // surviving inputs funnel through resolveEffectiveModel -> resolveTeamModel.
424
+ const focusSelectedModel = selectPipelineModelForSpawn(resolvedEngine.engineId, spawnCodexHome, focusOverrideModel);
425
+ const effectiveDirectiveModel = selectDirectiveModelForSpawn(resolvedEngine.engineId, directiveModel, spawnCodexModel ?? focusSelectedModel);
426
+ const effectiveModel = resolveEffectiveModel(effectiveDirectiveModel, spawnCodexHome, spawnCodexModel, focusSelectedModel);
427
+ const effectivePipelineConfig = effectiveModel !== (pipelineConfig?.model ?? null)
428
+ ? { ...pipelineConfig, model: effectiveModel }
429
+ : pipelineConfig;
430
+ const args2 = buildAgentArgs(backend, config, worktreePath, effectivePipelineConfig, resumeId, role.allowed_tools, readOnly);
431
+ // Capability-driven (no operator flag): for a registered local-model route
432
+ // whose endpoint drops Codex's namespace tools (backendDropsNamespaceTools),
433
+ // insert a localhost translating proxy between Codex and the inference server
434
+ // so the OSS server still receives the Telora tool schemas. Started LAST --
435
+ // after every host-control early return -- so a deferred spawn never leaks a
436
+ // proxy. Points the provisioned CODEX_HOME's base_url at the proxy; the proxy
437
+ // forwards to the model's real coords.baseUrl. Non-local / native-Responses
438
+ // passes never route => mcpProxy stays null and the spawn is byte-identical.
439
+ let mcpProxy = null;
440
+ if (localModelConfig.kind === 'route' &&
441
+ shouldRouteLocalModelThroughProxy(isLocalModelPass, localModelConfig.coords)) {
442
+ const { coords, apiKey } = localModelConfig;
443
+ try {
444
+ mcpProxy = await startCodexMcpProxy({ upstreamBaseUrl: coords.baseUrl });
445
+ writeLocalModelCodexHome(coords.id, {
446
+ baseUrl: mcpProxy.url,
447
+ model: coords.model,
448
+ wireApi: coords.wireApi ?? undefined,
449
+ requiresApiKey: apiKey !== null,
450
+ });
451
+ console.log(`[focus-executor] Local-model MCP proxy engaged for "${coords.name}": ` +
452
+ `Codex base_url -> ${mcpProxy.url} -> upstream ${coords.baseUrl}.`);
453
+ }
454
+ catch (err) {
455
+ // Best-effort: a proxy that cannot start must not block the spawn; fall
456
+ // back to the direct (namespace-dropping) path. The fail-loud reception
457
+ // check only applies when a proxy is present.
458
+ console.warn(`[focus-executor] Local-model MCP proxy failed to start; spawning direct: ${err.message}`);
459
+ mcpProxy = null;
460
+ }
461
+ }
462
+ return { kind: 'ready', args: args2, effectiveModel, spawnCodexHome, spawnLocalModelKey, isLocalModelPass, mcpProxy };
463
+ }
464
+ //# sourceMappingURL=model-routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-routing.js","sourceRoot":"","sources":["../../src/spawn/model-routing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAA8B,MAAM,4BAA4B,CAAC;AAC5G,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,iCAAiC,GAElC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,sBAAsB,EACtB,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,iBAAiB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AC;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC;AACxH,CAAC"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Process-spawn seam for the focus-team spawn path.
3
+ *
4
+ * Extracted verbatim from focus-executor.ts (behavior-preserving): the final
5
+ * phase that takes a fully-resolved spawn (env constituents, args, message,
6
+ * session, backend) and actually launches the team-lead child process, plus its
7
+ * fail-closed backend/sandbox/governor gates, the crash-isolated spawn wrapper,
8
+ * and the terminal session-update payload builders. focus-executor.ts re-exports
9
+ * this surface for backward compatibility, so external importers keep resolving
10
+ * these symbols from '../focus-executor.js'.
11
+ *
12
+ * Cycle rule: this module must NOT import from '../focus-executor.js'. The two
13
+ * symbols this seam would otherwise reach back for -- the resource governor and
14
+ * the orchestrator spawnFocusTeam (staying in focus-executor.ts) -- are threaded
15
+ * in via SpawnTeamProcessArgs instead.
16
+ */
17
+ import { spawn, type ChildProcessWithoutNullStreams, type SpawnOptionsWithoutStdio } from 'node:child_process';
18
+ import { type ResourceGovernor } from '@telora/daemon-core';
19
+ import type { DaemonConfig, FocusTeamState } from '../types.js';
20
+ import { createSession } from '../supabase.js';
21
+ import { consumePendingSpawnDirective } from '../directive-executor.js';
22
+ import { type AssemblyManifestEntry } from '../assembly-engine.js';
23
+ import { type AgentBackend } from '../backends/index.js';
24
+ import { setupTeamLogStreams } from '../spawner/helpers.js';
25
+ import type { SpawnFocusTeamParams } from './spawn-decision.js';
26
+ /**
27
+ * The terminal session-update payload written when the resource governor denies a
28
+ * slot for this spawn. Pure -- the caller adds `ended_at` and calls updateSession.
29
+ * Exported so the governor-denied exit_category contract is unit-pinned (the
30
+ * apply-side -- updateSession + governor.releaseSlot + activeTeams.delete -- stays
31
+ * in spawnTeamProcess, exercised by spawn-path-unified.test.ts).
32
+ */
33
+ export declare function governorDeniedSessionUpdate(): {
34
+ status: string;
35
+ exit_reason: string;
36
+ exit_category: string;
37
+ };
38
+ /**
39
+ * The terminal session-update payload written when a required OS sandbox cannot
40
+ * initialize and the spawn is refused (fail-closed). Pure -- the caller adds
41
+ * `ended_at` and calls updateSession. Exported so the sandbox-unavailable
42
+ * exit_category contract is unit-pinned.
43
+ */
44
+ export declare function sandboxUnavailableSessionUpdate(message: string): {
45
+ status: string;
46
+ exit_reason: string;
47
+ exit_category: string;
48
+ };
49
+ /**
50
+ * Inputs to spawnTeamProcess -- the final phase that takes a fully-resolved
51
+ * spawn (env constituents, args, message, session, backend) and actually
52
+ * launches the team-lead child process.
53
+ */
54
+ export interface SpawnTeamProcessArgs {
55
+ config: DaemonConfig;
56
+ focusId: string;
57
+ focusName: string;
58
+ session: Awaited<ReturnType<typeof createSession>>;
59
+ teamState: FocusTeamState;
60
+ backend: AgentBackend;
61
+ args: string[];
62
+ /** Composed prompt on a fresh spawn, or the resume-delta when resuming. */
63
+ messageToSend: string;
64
+ /**
65
+ * Escalation ids whose answered-directed section was composed into
66
+ * `messageToSend` (every shape carries it). Stamped consumed ONLY after the
67
+ * stdin write below succeeds -- the post-dispatch closure that keeps answered
68
+ * intent from being lost when a spawn tears down before dispatch. [] when
69
+ * there were no answered escalations. Optional (defaults to []) so
70
+ * spawn-process unit tests need not thread it; the production path always does.
71
+ */
72
+ answeredEscalationIds?: string[];
73
+ logs: ReturnType<typeof setupTeamLogStreams>;
74
+ worktreePath: string;
75
+ resumeId: string | null;
76
+ assemblyManifest: AssemblyManifestEntry[];
77
+ spawnCodexHome: string | undefined;
78
+ spawnLocalModelKey: string | null;
79
+ isLocalModelPass: boolean;
80
+ effectiveModel: string | null;
81
+ pendingDirective: ReturnType<typeof consumePendingSpawnDirective>;
82
+ spawnStageName: string | null;
83
+ params: SpawnFocusTeamParams;
84
+ /**
85
+ * The resource governor (or null when none is injected). Threaded in from the
86
+ * orchestrator because the governor state binding lives in focus-executor.ts;
87
+ * this seam must not import it back (cycle rule).
88
+ */
89
+ governor: ResourceGovernor | null;
90
+ /**
91
+ * The orchestrator spawnFocusTeam, threaded in so the resume-failure respawn
92
+ * (handleTeamProcessClose) can re-enter the spawn path. spawnFocusTeam stays in
93
+ * focus-executor.ts; threading it here avoids a back-edge import (cycle rule).
94
+ */
95
+ spawnFocusTeam: (params: SpawnFocusTeamParams) => Promise<void>;
96
+ }
97
+ export interface BackendSpawnGateResult {
98
+ allowed: boolean;
99
+ reason?: string;
100
+ }
101
+ /**
102
+ * Local-model passes depend on a host CLI, so refuse the process launch when
103
+ * the backend's existing availability probe says it cannot run. Cloud passes
104
+ * retain their existing behavior because their authentication can be supplied
105
+ * by the per-spawn environment after the host-level probe runs.
106
+ */
107
+ export declare function gateLocalModelBackendSpawn(backend: AgentBackend, config: DaemonConfig, isLocalModelPass: boolean, host?: string): Promise<BackendSpawnGateResult>;
108
+ export declare function backendUnavailableSessionUpdate(reason: string, category?: string): {
109
+ status: string;
110
+ exit_reason: string;
111
+ exit_category: string;
112
+ };
113
+ /** Attach the error listener in the same synchronous stack frame as spawn(). */
114
+ export declare function spawnCrashIsolated(command: string, args: readonly string[], options: SpawnOptionsWithoutStdio, onError: (error: Error) => void, spawnFn?: typeof spawn): ChildProcessWithoutNullStreams;
115
+ /** Ensure a terminal spawn failure is persisted after any in-flight running transition. */
116
+ export declare function persistSpawnFailureAfterRunning(runningTransition: Promise<unknown> | null, persistFailure: () => Promise<unknown>): Promise<void>;
117
+ /**
118
+ * Final phase: build the levered spawn environment, persist the assembly
119
+ * manifest, write the session lifecycle (starting -> running), acquire the
120
+ * governor slot, wrap the command in the sandbox (fail-closed), spawn the
121
+ * child, write its stdin, and attach the completion/close/error handlers.
122
+ *
123
+ * Owns ALL of its early-return cleanups so the team-state map and governor slot
124
+ * never leak: governor-denied (exit_category 'governor_denied') and
125
+ * sandbox-unavailable (exit_category 'sandbox_unavailable') both mark the
126
+ * session terminal, release the governor slot where one was held, remove the
127
+ * team from activeTeams, and return without spawning. Behavior byte-identical
128
+ * to the original inline tail of spawnFocusTeam.
129
+ */
130
+ /**
131
+ * Close a team's local-model translating proxy if one is engaged, and null it so
132
+ * the call is idempotent across the multiple teardown paths. No-op for every
133
+ * hosted/Claude/flag-off team (mcpProxy undefined/null).
134
+ */
135
+ export declare function closeTeamProxyQuietly(teamState: FocusTeamState): void;
136
+ export declare function spawnTeamProcess(spec: SpawnTeamProcessArgs): Promise<void>;
137
+ //# sourceMappingURL=process-spawn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-spawn.d.ts","sourceRoot":"","sources":["../../src/spawn/process-spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,8BAA8B,EAAE,KAAK,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE/G,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EAEd,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAKnE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EACL,mBAAmB,EAGpB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,2BAA2B,IAAI;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAM5G;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,GACd;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAA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