@openrig/cli 0.7.24 → 0.7.26

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 (1037) hide show
  1. package/README.md +7 -7
  2. package/daemon/assets/claude-hook-bridge.cjs +151 -37
  3. package/daemon/assets/claude-hook-bridge.d.cts +9 -2
  4. package/daemon/assets/claude-permission-policies.cjs +22 -1
  5. package/daemon/assets/claude-permission-policies.d.cts +2 -0
  6. package/daemon/assets/claude-statusline-context.cjs +14 -0
  7. package/daemon/assets/claude-team-permissions.cjs +54 -6
  8. package/daemon/assets/guidance/openrig-context-entry.md +4 -5
  9. package/daemon/assets/guidance/openrig-start.md +3 -0
  10. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +2 -2
  11. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +1 -1
  12. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
  13. package/daemon/assets/plugins/openrig/README.md +33 -18
  14. package/daemon/assets/plugins/openrig/hooks/scripts/claude-hook-bridge.cjs +151 -37
  15. package/daemon/assets/plugins/openrig/plugin.json +1 -1
  16. package/daemon/assets/plugins/openrig/scripts/run-rig.cjs +16 -13
  17. package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +32 -19
  18. package/daemon/assets/plugins/openrig-codex/.codex-plugin/plugin.json +1 -1
  19. package/daemon/assets/plugins/openrig-codex/hooks/scripts/claude-hook-bridge.cjs +151 -37
  20. package/daemon/assets/plugins/openrig-codex/skills/working-with-an-openrig-team/SKILL.md +32 -19
  21. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  22. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  23. package/daemon/assets/plugins/openrig-core/hooks/scripts/permission-answer.cjs +3 -2
  24. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +47 -14
  25. package/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore/SKILL.md +5 -2
  26. package/daemon/assets/skills/rigs/SKILL.md +99 -34
  27. package/daemon/assets/skills/rigs/references/installing-for-someone.md +1 -1
  28. package/daemon/context-packs/help/help.md +9 -0
  29. package/daemon/context-packs/help/manifest.yaml +1 -1
  30. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  31. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +179 -25
  32. package/daemon/context-packs/reference/getting-started.md +73 -11
  33. package/daemon/context-packs/reference/manifest.yaml +1 -1
  34. package/daemon/context-packs/reference/rig-spec.md +218 -23
  35. package/daemon/context-packs/reference/whats-new.md +190 -14
  36. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/cross-host-rig-commands/SKILL.md +9 -1
  43. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/core/working-with-an-openrig-team/SKILL.md +32 -19
  59. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/openrig-user/SKILL.md +47 -14
  66. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  78. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  79. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  83. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  84. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  85. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  86. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  87. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  88. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  89. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  90. package/daemon/context-packs/skills/session-compaction-and-restore/SKILL.md +5 -2
  91. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  92. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  93. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  94. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  95. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  96. package/daemon/dist/adapters/claude-code-adapter.js +25 -8
  97. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  98. package/daemon/dist/adapters/claude-resume.d.ts +2 -0
  99. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  100. package/daemon/dist/adapters/claude-resume.js +44 -8
  101. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  102. package/daemon/dist/adapters/codex-resume.d.ts +3 -0
  103. package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
  104. package/daemon/dist/adapters/codex-resume.js +7 -3
  105. package/daemon/dist/adapters/codex-resume.js.map +1 -1
  106. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +49 -4
  107. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  108. package/daemon/dist/adapters/codex-runtime-adapter.js +238 -25
  109. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  110. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +12 -5
  111. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
  112. package/daemon/dist/adapters/community-harness-runtime-adapter.js +15 -5
  113. package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
  114. package/daemon/dist/adapters/kernel-authority.d.ts +2 -2
  115. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  116. package/daemon/dist/adapters/kernel-authority.js +5 -3
  117. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  118. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  119. package/daemon/dist/adapters/pi-runner.js +9 -0
  120. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  121. package/daemon/dist/adapters/pi-session-cwd.d.ts +26 -0
  122. package/daemon/dist/adapters/pi-session-cwd.d.ts.map +1 -0
  123. package/daemon/dist/adapters/pi-session-cwd.js +89 -0
  124. package/daemon/dist/adapters/pi-session-cwd.js.map +1 -0
  125. package/daemon/dist/adapters/shell-quote.d.ts +2 -0
  126. package/daemon/dist/adapters/shell-quote.d.ts.map +1 -1
  127. package/daemon/dist/adapters/shell-quote.js +43 -0
  128. package/daemon/dist/adapters/shell-quote.js.map +1 -1
  129. package/daemon/dist/adapters/tmux-credential-env.d.ts +15 -2
  130. package/daemon/dist/adapters/tmux-credential-env.d.ts.map +1 -1
  131. package/daemon/dist/adapters/tmux-credential-env.js +82 -2
  132. package/daemon/dist/adapters/tmux-credential-env.js.map +1 -1
  133. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  134. package/daemon/dist/adapters/tmux-exec.js +2 -6
  135. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  136. package/daemon/dist/adapters/tmux.d.ts +31 -1
  137. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  138. package/daemon/dist/adapters/tmux.js +104 -8
  139. package/daemon/dist/adapters/tmux.js.map +1 -1
  140. package/daemon/dist/attention-surface.d.ts +5 -0
  141. package/daemon/dist/attention-surface.d.ts.map +1 -1
  142. package/daemon/dist/attention-surface.js.map +1 -1
  143. package/daemon/dist/bind-plan-surface.d.ts +3 -0
  144. package/daemon/dist/bind-plan-surface.d.ts.map +1 -0
  145. package/daemon/dist/bind-plan-surface.js +5 -0
  146. package/daemon/dist/bind-plan-surface.js.map +1 -0
  147. package/daemon/dist/build-info.js +3 -3
  148. package/daemon/dist/db/all-migrations.d.ts +4 -1
  149. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  150. package/daemon/dist/db/all-migrations.js +30 -393
  151. package/daemon/dist/db/all-migrations.js.map +1 -1
  152. package/daemon/dist/db/migrations/187_provider_account_refs.d.ts +8 -0
  153. package/daemon/dist/db/migrations/187_provider_account_refs.d.ts.map +1 -0
  154. package/daemon/dist/db/migrations/187_provider_account_refs.js +25 -0
  155. package/daemon/dist/db/migrations/187_provider_account_refs.js.map +1 -0
  156. package/daemon/dist/db/migrations/188_provider_account_assignments.d.ts +14 -0
  157. package/daemon/dist/db/migrations/188_provider_account_assignments.d.ts.map +1 -0
  158. package/daemon/dist/db/migrations/188_provider_account_assignments.js +45 -0
  159. package/daemon/dist/db/migrations/188_provider_account_assignments.js.map +1 -0
  160. package/daemon/dist/db/migrations/191_queue_transfer_activation.d.ts +3 -0
  161. package/daemon/dist/db/migrations/191_queue_transfer_activation.d.ts.map +1 -0
  162. package/daemon/dist/db/migrations/191_queue_transfer_activation.js +49 -0
  163. package/daemon/dist/db/migrations/191_queue_transfer_activation.js.map +1 -0
  164. package/daemon/dist/db/migrations/191_seat_reap_state.d.ts +3 -0
  165. package/daemon/dist/db/migrations/191_seat_reap_state.d.ts.map +1 -0
  166. package/daemon/dist/db/migrations/191_seat_reap_state.js +19 -0
  167. package/daemon/dist/db/migrations/191_seat_reap_state.js.map +1 -0
  168. package/daemon/dist/db/migrations/197_session_agent_activity_hooks.d.ts +3 -0
  169. package/daemon/dist/db/migrations/197_session_agent_activity_hooks.d.ts.map +1 -0
  170. package/daemon/dist/db/migrations/197_session_agent_activity_hooks.js +9 -0
  171. package/daemon/dist/db/migrations/197_session_agent_activity_hooks.js.map +1 -0
  172. package/daemon/dist/db/migrations/200_context_configured_budget.d.ts +3 -0
  173. package/daemon/dist/db/migrations/200_context_configured_budget.d.ts.map +1 -0
  174. package/daemon/dist/db/migrations/200_context_configured_budget.js +5 -0
  175. package/daemon/dist/db/migrations/200_context_configured_budget.js.map +1 -0
  176. package/daemon/dist/db/migrations/200_seat_cold_start_standby_stop.d.ts +3 -0
  177. package/daemon/dist/db/migrations/200_seat_cold_start_standby_stop.d.ts.map +1 -0
  178. package/daemon/dist/db/migrations/200_seat_cold_start_standby_stop.js +5 -0
  179. package/daemon/dist/db/migrations/200_seat_cold_start_standby_stop.js.map +1 -0
  180. package/daemon/dist/db/migrations/200_sessions_earlier_handover_origin.d.ts +11 -0
  181. package/daemon/dist/db/migrations/200_sessions_earlier_handover_origin.d.ts.map +1 -0
  182. package/daemon/dist/db/migrations/200_sessions_earlier_handover_origin.js +34 -0
  183. package/daemon/dist/db/migrations/200_sessions_earlier_handover_origin.js.map +1 -0
  184. package/daemon/dist/db/migrations/201_queue_transitions_archive_actor_index.d.ts +7 -0
  185. package/daemon/dist/db/migrations/201_queue_transitions_archive_actor_index.d.ts.map +1 -0
  186. package/daemon/dist/db/migrations/201_queue_transitions_archive_actor_index.js +12 -0
  187. package/daemon/dist/db/migrations/201_queue_transitions_archive_actor_index.js.map +1 -0
  188. package/daemon/dist/db/migrations/201_roster_event_index.d.ts +4 -0
  189. package/daemon/dist/db/migrations/201_roster_event_index.d.ts.map +1 -0
  190. package/daemon/dist/db/migrations/201_roster_event_index.js +9 -0
  191. package/daemon/dist/db/migrations/201_roster_event_index.js.map +1 -0
  192. package/daemon/dist/db/migrations/202_network_requester_questions.d.ts +4 -0
  193. package/daemon/dist/db/migrations/202_network_requester_questions.d.ts.map +1 -0
  194. package/daemon/dist/db/migrations/202_network_requester_questions.js +10 -0
  195. package/daemon/dist/db/migrations/202_network_requester_questions.js.map +1 -0
  196. package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.d.ts +3 -0
  197. package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.d.ts.map +1 -0
  198. package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.js +22 -0
  199. package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.js.map +1 -0
  200. package/daemon/dist/domain/activity-taxonomy.d.ts +16 -5
  201. package/daemon/dist/domain/activity-taxonomy.d.ts.map +1 -1
  202. package/daemon/dist/domain/activity-taxonomy.js +30 -5
  203. package/daemon/dist/domain/activity-taxonomy.js.map +1 -1
  204. package/daemon/dist/domain/agent-activity-store.d.ts +4 -0
  205. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  206. package/daemon/dist/domain/agent-activity-store.js +21 -0
  207. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  208. package/daemon/dist/domain/agent-images/agent-image-destination.d.ts +15 -0
  209. package/daemon/dist/domain/agent-images/agent-image-destination.d.ts.map +1 -0
  210. package/daemon/dist/domain/agent-images/agent-image-destination.js +79 -0
  211. package/daemon/dist/domain/agent-images/agent-image-destination.js.map +1 -0
  212. package/daemon/dist/domain/agent-images/agent-image-library-service.d.ts.map +1 -1
  213. package/daemon/dist/domain/agent-images/agent-image-library-service.js +9 -1
  214. package/daemon/dist/domain/agent-images/agent-image-library-service.js.map +1 -1
  215. package/daemon/dist/domain/bootstrap-orchestrator.d.ts +4 -3
  216. package/daemon/dist/domain/bootstrap-orchestrator.d.ts.map +1 -1
  217. package/daemon/dist/domain/bootstrap-orchestrator.js +55 -11
  218. package/daemon/dist/domain/bootstrap-orchestrator.js.map +1 -1
  219. package/daemon/dist/domain/bundle-content-routing.d.ts +7 -0
  220. package/daemon/dist/domain/bundle-content-routing.d.ts.map +1 -1
  221. package/daemon/dist/domain/bundle-content-routing.js +20 -15
  222. package/daemon/dist/domain/bundle-content-routing.js.map +1 -1
  223. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +40 -1
  224. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  225. package/daemon/dist/domain/claude-compaction-enforcer.js +101 -11
  226. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  227. package/daemon/dist/domain/claude-continuation-launch.d.ts +19 -2
  228. package/daemon/dist/domain/claude-continuation-launch.d.ts.map +1 -1
  229. package/daemon/dist/domain/claude-continuation-launch.js +143 -3
  230. package/daemon/dist/domain/claude-continuation-launch.js.map +1 -1
  231. package/daemon/dist/domain/claude-managed-launch.d.ts +22 -5
  232. package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
  233. package/daemon/dist/domain/claude-managed-launch.js +41 -5
  234. package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
  235. package/daemon/dist/domain/claude-permission-rules.d.ts +3 -1
  236. package/daemon/dist/domain/claude-permission-rules.d.ts.map +1 -1
  237. package/daemon/dist/domain/claude-permission-rules.js +8 -7
  238. package/daemon/dist/domain/claude-permission-rules.js.map +1 -1
  239. package/daemon/dist/domain/claude-seat-token.d.ts +25 -1
  240. package/daemon/dist/domain/claude-seat-token.d.ts.map +1 -1
  241. package/daemon/dist/domain/claude-seat-token.js +56 -9
  242. package/daemon/dist/domain/claude-seat-token.js.map +1 -1
  243. package/daemon/dist/domain/codex-auth.d.ts +34 -0
  244. package/daemon/dist/domain/codex-auth.d.ts.map +1 -1
  245. package/daemon/dist/domain/codex-auth.js +212 -0
  246. package/daemon/dist/domain/codex-auth.js.map +1 -1
  247. package/daemon/dist/domain/codex-member-permissions.d.ts +17 -0
  248. package/daemon/dist/domain/codex-member-permissions.d.ts.map +1 -1
  249. package/daemon/dist/domain/codex-member-permissions.js +80 -0
  250. package/daemon/dist/domain/codex-member-permissions.js.map +1 -1
  251. package/daemon/dist/domain/community-harness-launch-result.d.ts +9 -0
  252. package/daemon/dist/domain/community-harness-launch-result.d.ts.map +1 -1
  253. package/daemon/dist/domain/community-harness-launch-result.js +14 -2
  254. package/daemon/dist/domain/community-harness-launch-result.js.map +1 -1
  255. package/daemon/dist/domain/community-harness-presets.d.ts +15 -0
  256. package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
  257. package/daemon/dist/domain/community-harness-presets.js +82 -48
  258. package/daemon/dist/domain/community-harness-presets.js.map +1 -1
  259. package/daemon/dist/domain/compaction-restore-notice.d.ts +33 -5
  260. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -1
  261. package/daemon/dist/domain/compaction-restore-notice.js +221 -48
  262. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -1
  263. package/daemon/dist/domain/context-usage-store.d.ts +1 -0
  264. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  265. package/daemon/dist/domain/context-usage-store.js +34 -3
  266. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  267. package/daemon/dist/domain/crash-cart-detect.d.ts +7 -0
  268. package/daemon/dist/domain/crash-cart-detect.d.ts.map +1 -1
  269. package/daemon/dist/domain/crash-cart-detect.js +10 -5
  270. package/daemon/dist/domain/crash-cart-detect.js.map +1 -1
  271. package/daemon/dist/domain/crash-cart-discovery.d.ts +9 -16
  272. package/daemon/dist/domain/crash-cart-discovery.d.ts.map +1 -1
  273. package/daemon/dist/domain/crash-cart-discovery.js +22 -40
  274. package/daemon/dist/domain/crash-cart-discovery.js.map +1 -1
  275. package/daemon/dist/domain/crash-cart-emit.d.ts +1 -1
  276. package/daemon/dist/domain/crash-cart-emit.d.ts.map +1 -1
  277. package/daemon/dist/domain/crash-cart-emit.js +4 -0
  278. package/daemon/dist/domain/crash-cart-emit.js.map +1 -1
  279. package/daemon/dist/domain/current-park-arm.d.ts +2 -0
  280. package/daemon/dist/domain/current-park-arm.d.ts.map +1 -1
  281. package/daemon/dist/domain/current-park-arm.js +5 -0
  282. package/daemon/dist/domain/current-park-arm.js.map +1 -1
  283. package/daemon/dist/domain/current-work.d.ts +16 -4
  284. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  285. package/daemon/dist/domain/current-work.js +3 -6
  286. package/daemon/dist/domain/current-work.js.map +1 -1
  287. package/daemon/dist/domain/cwd-resolution.d.ts +12 -1
  288. package/daemon/dist/domain/cwd-resolution.d.ts.map +1 -1
  289. package/daemon/dist/domain/cwd-resolution.js +39 -2
  290. package/daemon/dist/domain/cwd-resolution.js.map +1 -1
  291. package/daemon/dist/domain/draft-aware-delivery.d.ts +17 -2
  292. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
  293. package/daemon/dist/domain/draft-aware-delivery.js +98 -9
  294. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  295. package/daemon/dist/domain/draft-held-reoffer.d.ts +61 -0
  296. package/daemon/dist/domain/draft-held-reoffer.d.ts.map +1 -0
  297. package/daemon/dist/domain/draft-held-reoffer.js +143 -0
  298. package/daemon/dist/domain/draft-held-reoffer.js.map +1 -0
  299. package/daemon/dist/domain/execution-view.d.ts +20 -0
  300. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  301. package/daemon/dist/domain/execution-view.js +50 -16
  302. package/daemon/dist/domain/execution-view.js.map +1 -1
  303. package/daemon/dist/domain/gateway/destination-resolver.d.ts +10 -2
  304. package/daemon/dist/domain/gateway/destination-resolver.d.ts.map +1 -1
  305. package/daemon/dist/domain/gateway/destination-resolver.js +26 -3
  306. package/daemon/dist/domain/gateway/destination-resolver.js.map +1 -1
  307. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  308. package/daemon/dist/domain/gateway/slack/inbound.js +5 -4
  309. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  310. package/daemon/dist/domain/gateway/slack/queue-access.js +1 -1
  311. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  312. package/daemon/dist/domain/generated-file-hygiene.d.ts.map +1 -1
  313. package/daemon/dist/domain/generated-file-hygiene.js +35 -2
  314. package/daemon/dist/domain/generated-file-hygiene.js.map +1 -1
  315. package/daemon/dist/domain/graph-projection.d.ts +7 -1
  316. package/daemon/dist/domain/graph-projection.d.ts.map +1 -1
  317. package/daemon/dist/domain/graph-projection.js +2 -0
  318. package/daemon/dist/domain/graph-projection.js.map +1 -1
  319. package/daemon/dist/domain/health-context-samples.d.ts +23 -0
  320. package/daemon/dist/domain/health-context-samples.d.ts.map +1 -0
  321. package/daemon/dist/domain/health-context-samples.js +113 -0
  322. package/daemon/dist/domain/health-context-samples.js.map +1 -0
  323. package/daemon/dist/domain/health-detectors.d.ts +3 -0
  324. package/daemon/dist/domain/health-detectors.d.ts.map +1 -1
  325. package/daemon/dist/domain/health-detectors.js +8 -7
  326. package/daemon/dist/domain/health-detectors.js.map +1 -1
  327. package/daemon/dist/domain/home-isolation.d.ts.map +1 -1
  328. package/daemon/dist/domain/home-isolation.js +21 -8
  329. package/daemon/dist/domain/home-isolation.js.map +1 -1
  330. package/daemon/dist/domain/hook-bridge.d.ts +7 -5
  331. package/daemon/dist/domain/hook-bridge.d.ts.map +1 -1
  332. package/daemon/dist/domain/hook-bridge.js +12 -11
  333. package/daemon/dist/domain/hook-bridge.js.map +1 -1
  334. package/daemon/dist/domain/kernel-boot-tracker.d.ts +7 -5
  335. package/daemon/dist/domain/kernel-boot-tracker.d.ts.map +1 -1
  336. package/daemon/dist/domain/kernel-boot-tracker.js +11 -6
  337. package/daemon/dist/domain/kernel-boot-tracker.js.map +1 -1
  338. package/daemon/dist/domain/kernel-boot.d.ts.map +1 -1
  339. package/daemon/dist/domain/kernel-boot.js +6 -2
  340. package/daemon/dist/domain/kernel-boot.js.map +1 -1
  341. package/daemon/dist/domain/kernel-hook-review.d.ts +10 -2
  342. package/daemon/dist/domain/kernel-hook-review.d.ts.map +1 -1
  343. package/daemon/dist/domain/kernel-hook-review.js +18 -4
  344. package/daemon/dist/domain/kernel-hook-review.js.map +1 -1
  345. package/daemon/dist/domain/managed-restore-read-access.d.ts +6 -2
  346. package/daemon/dist/domain/managed-restore-read-access.d.ts.map +1 -1
  347. package/daemon/dist/domain/managed-restore-read-access.js +35 -4
  348. package/daemon/dist/domain/managed-restore-read-access.js.map +1 -1
  349. package/daemon/dist/domain/mission-control/audit-browse.d.ts.map +1 -1
  350. package/daemon/dist/domain/mission-control/audit-browse.js +1 -0
  351. package/daemon/dist/domain/mission-control/audit-browse.js.map +1 -1
  352. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts +3 -1
  353. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts.map +1 -1
  354. package/daemon/dist/domain/mission-control/mission-control-action-log.js +7 -0
  355. package/daemon/dist/domain/mission-control/mission-control-action-log.js.map +1 -1
  356. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +3 -0
  357. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  358. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +56 -13
  359. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  360. package/daemon/dist/domain/mission-control/notification-adapter-from-env.d.ts +8 -0
  361. package/daemon/dist/domain/mission-control/notification-adapter-from-env.d.ts.map +1 -0
  362. package/daemon/dist/domain/mission-control/notification-adapter-from-env.js +17 -0
  363. package/daemon/dist/domain/mission-control/notification-adapter-from-env.js.map +1 -0
  364. package/daemon/dist/domain/model-divergence/codex-thread-homes.d.ts +12 -0
  365. package/daemon/dist/domain/model-divergence/codex-thread-homes.d.ts.map +1 -0
  366. package/daemon/dist/domain/model-divergence/codex-thread-homes.js +19 -0
  367. package/daemon/dist/domain/model-divergence/codex-thread-homes.js.map +1 -0
  368. package/daemon/dist/domain/native-process-arguments.d.ts +6 -3
  369. package/daemon/dist/domain/native-process-arguments.d.ts.map +1 -1
  370. package/daemon/dist/domain/native-process-arguments.js +56 -23
  371. package/daemon/dist/domain/native-process-arguments.js.map +1 -1
  372. package/daemon/dist/domain/native-resume-probe.d.ts +9 -0
  373. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  374. package/daemon/dist/domain/native-resume-probe.js +15 -1
  375. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  376. package/daemon/dist/domain/network/hub-client.d.ts +14 -4
  377. package/daemon/dist/domain/network/hub-client.d.ts.map +1 -1
  378. package/daemon/dist/domain/network/hub-client.js +26 -9
  379. package/daemon/dist/domain/network/hub-client.js.map +1 -1
  380. package/daemon/dist/domain/network/network-connector.d.ts +2 -0
  381. package/daemon/dist/domain/network/network-connector.d.ts.map +1 -1
  382. package/daemon/dist/domain/network/network-connector.js +162 -16
  383. package/daemon/dist/domain/network/network-connector.js.map +1 -1
  384. package/daemon/dist/domain/network/network-requests.d.ts +4 -1
  385. package/daemon/dist/domain/network/network-requests.d.ts.map +1 -1
  386. package/daemon/dist/domain/network/network-requests.js +141 -14
  387. package/daemon/dist/domain/network/network-requests.js.map +1 -1
  388. package/daemon/dist/domain/node-inventory.d.ts +47 -0
  389. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  390. package/daemon/dist/domain/node-inventory.js +270 -158
  391. package/daemon/dist/domain/node-inventory.js.map +1 -1
  392. package/daemon/dist/domain/node-launcher.d.ts +1 -0
  393. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  394. package/daemon/dist/domain/node-launcher.js +13 -5
  395. package/daemon/dist/domain/node-launcher.js.map +1 -1
  396. package/daemon/dist/domain/outbox-handler.d.ts +66 -0
  397. package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
  398. package/daemon/dist/domain/outbox-handler.js +117 -8
  399. package/daemon/dist/domain/outbox-handler.js.map +1 -1
  400. package/daemon/dist/domain/pane-cutover.d.ts +6 -2
  401. package/daemon/dist/domain/pane-cutover.d.ts.map +1 -1
  402. package/daemon/dist/domain/pane-cutover.js +14 -4
  403. package/daemon/dist/domain/pane-cutover.js.map +1 -1
  404. package/daemon/dist/domain/parked-owner-escalation.d.ts +1 -0
  405. package/daemon/dist/domain/parked-owner-escalation.d.ts.map +1 -1
  406. package/daemon/dist/domain/parked-owner-escalation.js +3 -1
  407. package/daemon/dist/domain/parked-owner-escalation.js.map +1 -1
  408. package/daemon/dist/domain/parked-query.js +1 -1
  409. package/daemon/dist/domain/parked-query.js.map +1 -1
  410. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  411. package/daemon/dist/domain/permission-account.js +20 -1
  412. package/daemon/dist/domain/permission-account.js.map +1 -1
  413. package/daemon/dist/domain/policies/idle-gate-qitem.d.ts +1 -0
  414. package/daemon/dist/domain/policies/idle-gate-qitem.d.ts.map +1 -1
  415. package/daemon/dist/domain/policies/idle-gate-qitem.js +1 -0
  416. package/daemon/dist/domain/policies/idle-gate-qitem.js.map +1 -1
  417. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +21 -0
  418. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
  419. package/daemon/dist/domain/policies/parked-owner-consumer.js +185 -26
  420. package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
  421. package/daemon/dist/domain/policies/seat-pool.d.ts +2 -1
  422. package/daemon/dist/domain/policies/seat-pool.d.ts.map +1 -1
  423. package/daemon/dist/domain/policies/seat-pool.js.map +1 -1
  424. package/daemon/dist/domain/policies/workflow-keepalive.d.ts +1 -0
  425. package/daemon/dist/domain/policies/workflow-keepalive.d.ts.map +1 -1
  426. package/daemon/dist/domain/policies/workflow-keepalive.js +4 -1
  427. package/daemon/dist/domain/policies/workflow-keepalive.js.map +1 -1
  428. package/daemon/dist/domain/profile-resolver.d.ts +2 -0
  429. package/daemon/dist/domain/profile-resolver.d.ts.map +1 -1
  430. package/daemon/dist/domain/profile-resolver.js +10 -4
  431. package/daemon/dist/domain/profile-resolver.js.map +1 -1
  432. package/daemon/dist/domain/project-lifecycle-compiler.d.ts.map +1 -1
  433. package/daemon/dist/domain/project-lifecycle-compiler.js +35 -1
  434. package/daemon/dist/domain/project-lifecycle-compiler.js.map +1 -1
  435. package/daemon/dist/domain/proof/judgments.d.ts +7 -0
  436. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  437. package/daemon/dist/domain/proof/judgments.js +18 -10
  438. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  439. package/daemon/dist/domain/provider/assignment-apply.d.ts +85 -0
  440. package/daemon/dist/domain/provider/assignment-apply.d.ts.map +1 -0
  441. package/daemon/dist/domain/provider/assignment-apply.js +270 -0
  442. package/daemon/dist/domain/provider/assignment-apply.js.map +1 -0
  443. package/daemon/dist/domain/provider/assignment-plan.d.ts +150 -0
  444. package/daemon/dist/domain/provider/assignment-plan.d.ts.map +1 -0
  445. package/daemon/dist/domain/provider/assignment-plan.js +218 -0
  446. package/daemon/dist/domain/provider/assignment-plan.js.map +1 -0
  447. package/daemon/dist/domain/provider/claude-seat-switch.d.ts +1 -1
  448. package/daemon/dist/domain/provider/claude-seat-switch.d.ts.map +1 -1
  449. package/daemon/dist/domain/provider/claude-seat-switch.js +37 -6
  450. package/daemon/dist/domain/provider/claude-seat-switch.js.map +1 -1
  451. package/daemon/dist/domain/provider/provider-account-assignments.d.ts +64 -0
  452. package/daemon/dist/domain/provider/provider-account-assignments.d.ts.map +1 -0
  453. package/daemon/dist/domain/provider/provider-account-assignments.js +75 -0
  454. package/daemon/dist/domain/provider/provider-account-assignments.js.map +1 -0
  455. package/daemon/dist/domain/provider/provider-account-refs.d.ts +91 -0
  456. package/daemon/dist/domain/provider/provider-account-refs.d.ts.map +1 -0
  457. package/daemon/dist/domain/provider/provider-account-refs.js +164 -0
  458. package/daemon/dist/domain/provider/provider-account-refs.js.map +1 -0
  459. package/daemon/dist/domain/provider/provider-collect.d.ts +3 -1
  460. package/daemon/dist/domain/provider/provider-collect.d.ts.map +1 -1
  461. package/daemon/dist/domain/provider/provider-collect.js +2 -0
  462. package/daemon/dist/domain/provider/provider-collect.js.map +1 -1
  463. package/daemon/dist/domain/provider/provider-service-impl.d.ts +43 -1
  464. package/daemon/dist/domain/provider/provider-service-impl.d.ts.map +1 -1
  465. package/daemon/dist/domain/provider/provider-service-impl.js +376 -20
  466. package/daemon/dist/domain/provider/provider-service-impl.js.map +1 -1
  467. package/daemon/dist/domain/provider/provider-service.d.ts +82 -6
  468. package/daemon/dist/domain/provider/provider-service.d.ts.map +1 -1
  469. package/daemon/dist/domain/provider/provider-types.d.ts +40 -1
  470. package/daemon/dist/domain/provider/provider-types.d.ts.map +1 -1
  471. package/daemon/dist/domain/provider/usage-across-hosts.d.ts.map +1 -1
  472. package/daemon/dist/domain/provider/usage-across-hosts.js +13 -1
  473. package/daemon/dist/domain/provider/usage-across-hosts.js.map +1 -1
  474. package/daemon/dist/domain/ps-projection.d.ts +5 -3
  475. package/daemon/dist/domain/ps-projection.d.ts.map +1 -1
  476. package/daemon/dist/domain/ps-projection.js +10 -3
  477. package/daemon/dist/domain/ps-projection.js.map +1 -1
  478. package/daemon/dist/domain/queue-display.d.ts +7 -0
  479. package/daemon/dist/domain/queue-display.d.ts.map +1 -0
  480. package/daemon/dist/domain/queue-display.js +20 -0
  481. package/daemon/dist/domain/queue-display.js.map +1 -0
  482. package/daemon/dist/domain/queue-owner.d.ts +4 -2
  483. package/daemon/dist/domain/queue-owner.d.ts.map +1 -1
  484. package/daemon/dist/domain/queue-owner.js +7 -5
  485. package/daemon/dist/domain/queue-owner.js.map +1 -1
  486. package/daemon/dist/domain/queue-repository.d.ts +104 -24
  487. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  488. package/daemon/dist/domain/queue-repository.js +600 -89
  489. package/daemon/dist/domain/queue-repository.js.map +1 -1
  490. package/daemon/dist/domain/queue-stuck-sweep.d.ts +4 -0
  491. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  492. package/daemon/dist/domain/queue-stuck-sweep.js +1890 -1817
  493. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  494. package/daemon/dist/domain/queue-transfer-activation.d.ts +28 -0
  495. package/daemon/dist/domain/queue-transfer-activation.d.ts.map +1 -0
  496. package/daemon/dist/domain/queue-transfer-activation.js +187 -0
  497. package/daemon/dist/domain/queue-transfer-activation.js.map +1 -0
  498. package/daemon/dist/domain/queue-transfer-mapping.d.ts +31 -0
  499. package/daemon/dist/domain/queue-transfer-mapping.d.ts.map +1 -0
  500. package/daemon/dist/domain/queue-transfer-mapping.js +33 -0
  501. package/daemon/dist/domain/queue-transfer-mapping.js.map +1 -0
  502. package/daemon/dist/domain/queue-transfer-operation.d.ts +24 -0
  503. package/daemon/dist/domain/queue-transfer-operation.d.ts.map +1 -0
  504. package/daemon/dist/domain/queue-transfer-operation.js +41 -0
  505. package/daemon/dist/domain/queue-transfer-operation.js.map +1 -0
  506. package/daemon/dist/domain/queue-transfer-parse.d.ts +8 -0
  507. package/daemon/dist/domain/queue-transfer-parse.d.ts.map +1 -1
  508. package/daemon/dist/domain/queue-transfer-parse.js +16 -6
  509. package/daemon/dist/domain/queue-transfer-parse.js.map +1 -1
  510. package/daemon/dist/domain/queue-transfer-records.d.ts +160 -0
  511. package/daemon/dist/domain/queue-transfer-records.d.ts.map +1 -0
  512. package/daemon/dist/domain/queue-transfer-records.js +94 -0
  513. package/daemon/dist/domain/queue-transfer-records.js.map +1 -0
  514. package/daemon/dist/domain/queue-transfer-recovery.d.ts +40 -0
  515. package/daemon/dist/domain/queue-transfer-recovery.d.ts.map +1 -0
  516. package/daemon/dist/domain/queue-transfer-recovery.js +136 -0
  517. package/daemon/dist/domain/queue-transfer-recovery.js.map +1 -0
  518. package/daemon/dist/domain/queue-transfer-relinquish.d.ts +70 -0
  519. package/daemon/dist/domain/queue-transfer-relinquish.d.ts.map +1 -0
  520. package/daemon/dist/domain/queue-transfer-relinquish.js +204 -0
  521. package/daemon/dist/domain/queue-transfer-relinquish.js.map +1 -0
  522. package/daemon/dist/domain/queue-transfer-review.d.ts +1 -0
  523. package/daemon/dist/domain/queue-transfer-review.d.ts.map +1 -1
  524. package/daemon/dist/domain/queue-transfer-review.js +15 -13
  525. package/daemon/dist/domain/queue-transfer-review.js.map +1 -1
  526. package/daemon/dist/domain/queue-transfer-staging.d.ts +14 -0
  527. package/daemon/dist/domain/queue-transfer-staging.d.ts.map +1 -1
  528. package/daemon/dist/domain/queue-transfer-staging.js +9 -1
  529. package/daemon/dist/domain/queue-transfer-staging.js.map +1 -1
  530. package/daemon/dist/domain/queue-transfer-write.d.ts +14 -0
  531. package/daemon/dist/domain/queue-transfer-write.d.ts.map +1 -0
  532. package/daemon/dist/domain/queue-transfer-write.js +42 -0
  533. package/daemon/dist/domain/queue-transfer-write.js.map +1 -0
  534. package/daemon/dist/domain/queue-transition-log.d.ts +8 -0
  535. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  536. package/daemon/dist/domain/queue-transition-log.js +27 -14
  537. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  538. package/daemon/dist/domain/queue-waiting.d.ts +10 -1
  539. package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
  540. package/daemon/dist/domain/queue-waiting.js +20 -14
  541. package/daemon/dist/domain/queue-waiting.js.map +1 -1
  542. package/daemon/dist/domain/queue-wake-ladder.d.ts +10 -3
  543. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  544. package/daemon/dist/domain/queue-wake-ladder.js +60 -23
  545. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  546. package/daemon/dist/domain/queue-wake-repository.d.ts +1 -0
  547. package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
  548. package/daemon/dist/domain/queue-wake-repository.js +21 -19
  549. package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
  550. package/daemon/dist/domain/receiver-context.d.ts +3 -2
  551. package/daemon/dist/domain/receiver-context.d.ts.map +1 -1
  552. package/daemon/dist/domain/receiver-context.js +5 -4
  553. package/daemon/dist/domain/receiver-context.js.map +1 -1
  554. package/daemon/dist/domain/reconciler.d.ts +2 -0
  555. package/daemon/dist/domain/reconciler.d.ts.map +1 -1
  556. package/daemon/dist/domain/reconciler.js +17 -1
  557. package/daemon/dist/domain/reconciler.js.map +1 -1
  558. package/daemon/dist/domain/relayed-answers.d.ts +1 -0
  559. package/daemon/dist/domain/relayed-answers.d.ts.map +1 -1
  560. package/daemon/dist/domain/relayed-answers.js.map +1 -1
  561. package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
  562. package/daemon/dist/domain/restore-check-service.js +9 -3
  563. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  564. package/daemon/dist/domain/restore-orchestrator.d.ts +7 -0
  565. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  566. package/daemon/dist/domain/restore-orchestrator.js +54 -14
  567. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  568. package/daemon/dist/domain/return-route.d.ts +4 -0
  569. package/daemon/dist/domain/return-route.d.ts.map +1 -1
  570. package/daemon/dist/domain/return-route.js +13 -0
  571. package/daemon/dist/domain/return-route.js.map +1 -1
  572. package/daemon/dist/domain/rig-mode/operating-posture.d.ts +3 -0
  573. package/daemon/dist/domain/rig-mode/operating-posture.d.ts.map +1 -1
  574. package/daemon/dist/domain/rig-mode/operating-posture.js +27 -8
  575. package/daemon/dist/domain/rig-mode/operating-posture.js.map +1 -1
  576. package/daemon/dist/domain/rig-status-compose.d.ts +3 -0
  577. package/daemon/dist/domain/rig-status-compose.d.ts.map +1 -1
  578. package/daemon/dist/domain/rig-status-compose.js +4 -1
  579. package/daemon/dist/domain/rig-status-compose.js.map +1 -1
  580. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  581. package/daemon/dist/domain/rig-teardown.js +3 -2
  582. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  583. package/daemon/dist/domain/rigspec-exporter.d.ts +2 -0
  584. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  585. package/daemon/dist/domain/rigspec-exporter.js +38 -2
  586. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  587. package/daemon/dist/domain/rigspec-instantiator.d.ts +4 -1
  588. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  589. package/daemon/dist/domain/rigspec-instantiator.js +32 -13
  590. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  591. package/daemon/dist/domain/rigspec-preflight.d.ts +3 -0
  592. package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
  593. package/daemon/dist/domain/rigspec-preflight.js +25 -7
  594. package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
  595. package/daemon/dist/domain/roster-ready-notice.d.ts +1 -1
  596. package/daemon/dist/domain/roster-ready-notice.d.ts.map +1 -1
  597. package/daemon/dist/domain/roster-ready-notice.js +2 -1
  598. package/daemon/dist/domain/roster-ready-notice.js.map +1 -1
  599. package/daemon/dist/domain/runner-permissions.d.ts +3 -2
  600. package/daemon/dist/domain/runner-permissions.d.ts.map +1 -1
  601. package/daemon/dist/domain/runner-permissions.js +30 -19
  602. package/daemon/dist/domain/runner-permissions.js.map +1 -1
  603. package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
  604. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  605. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  606. package/daemon/dist/domain/scope/manifest-editor.d.ts +35 -0
  607. package/daemon/dist/domain/scope/manifest-editor.d.ts.map +1 -0
  608. package/daemon/dist/domain/scope/manifest-editor.js +197 -0
  609. package/daemon/dist/domain/scope/manifest-editor.js.map +1 -0
  610. package/daemon/dist/domain/scope/mission-frontmatter.d.ts +9 -0
  611. package/daemon/dist/domain/scope/mission-frontmatter.d.ts.map +1 -0
  612. package/daemon/dist/domain/scope/mission-frontmatter.js +36 -0
  613. package/daemon/dist/domain/scope/mission-frontmatter.js.map +1 -0
  614. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  615. package/daemon/dist/domain/seat-activity-service.js +53 -20
  616. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  617. package/daemon/dist/domain/seat-cold-start.d.ts +8 -2
  618. package/daemon/dist/domain/seat-cold-start.d.ts.map +1 -1
  619. package/daemon/dist/domain/seat-cold-start.js +75 -19
  620. package/daemon/dist/domain/seat-cold-start.js.map +1 -1
  621. package/daemon/dist/domain/seat-delivery-guard.d.ts +6 -1
  622. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  623. package/daemon/dist/domain/seat-delivery-guard.js +23 -2
  624. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  625. package/daemon/dist/domain/seat-evidence.d.ts +13 -0
  626. package/daemon/dist/domain/seat-evidence.d.ts.map +1 -0
  627. package/daemon/dist/domain/seat-evidence.js +29 -0
  628. package/daemon/dist/domain/seat-evidence.js.map +1 -0
  629. package/daemon/dist/domain/seat-handover-service.d.ts +5 -1
  630. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  631. package/daemon/dist/domain/seat-handover-service.js +49 -35
  632. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  633. package/daemon/dist/domain/seat-lifecycle-service.d.ts +26 -6
  634. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  635. package/daemon/dist/domain/seat-lifecycle-service.js +108 -17
  636. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  637. package/daemon/dist/domain/seat-pool-dispatch-guard.d.ts +28 -0
  638. package/daemon/dist/domain/seat-pool-dispatch-guard.d.ts.map +1 -0
  639. package/daemon/dist/domain/seat-pool-dispatch-guard.js +123 -0
  640. package/daemon/dist/domain/seat-pool-dispatch-guard.js.map +1 -0
  641. package/daemon/dist/domain/seat-pool-executor.d.ts +64 -3
  642. package/daemon/dist/domain/seat-pool-executor.d.ts.map +1 -1
  643. package/daemon/dist/domain/seat-pool-executor.js +993 -102
  644. package/daemon/dist/domain/seat-pool-executor.js.map +1 -1
  645. package/daemon/dist/domain/seat-pool-slots.d.ts +90 -2
  646. package/daemon/dist/domain/seat-pool-slots.d.ts.map +1 -1
  647. package/daemon/dist/domain/seat-pool-slots.js +88 -3
  648. package/daemon/dist/domain/seat-pool-slots.js.map +1 -1
  649. package/daemon/dist/domain/seat-pool-spec.d.ts +4 -1
  650. package/daemon/dist/domain/seat-pool-spec.d.ts.map +1 -1
  651. package/daemon/dist/domain/seat-pool-spec.js +14 -2
  652. package/daemon/dist/domain/seat-pool-spec.js.map +1 -1
  653. package/daemon/dist/domain/seat-reaper-eligibility.d.ts +34 -0
  654. package/daemon/dist/domain/seat-reaper-eligibility.d.ts.map +1 -0
  655. package/daemon/dist/domain/seat-reaper-eligibility.js +30 -0
  656. package/daemon/dist/domain/seat-reaper-eligibility.js.map +1 -0
  657. package/daemon/dist/domain/seat-reaper-events.d.ts +31 -0
  658. package/daemon/dist/domain/seat-reaper-events.d.ts.map +1 -0
  659. package/daemon/dist/domain/seat-reaper-events.js +2 -0
  660. package/daemon/dist/domain/seat-reaper-events.js.map +1 -0
  661. package/daemon/dist/domain/seat-reaper-service.d.ts +59 -0
  662. package/daemon/dist/domain/seat-reaper-service.d.ts.map +1 -0
  663. package/daemon/dist/domain/seat-reaper-service.js +311 -0
  664. package/daemon/dist/domain/seat-reaper-service.js.map +1 -0
  665. package/daemon/dist/domain/seat-reaper-settings.d.ts +14 -0
  666. package/daemon/dist/domain/seat-reaper-settings.d.ts.map +1 -0
  667. package/daemon/dist/domain/seat-reaper-settings.js +32 -0
  668. package/daemon/dist/domain/seat-reaper-settings.js.map +1 -0
  669. package/daemon/dist/domain/seat-reaper-store.d.ts +19 -0
  670. package/daemon/dist/domain/seat-reaper-store.d.ts.map +1 -0
  671. package/daemon/dist/domain/seat-reaper-store.js +45 -0
  672. package/daemon/dist/domain/seat-reaper-store.js.map +1 -0
  673. package/daemon/dist/domain/seat-reaper-workspace.d.ts +4 -0
  674. package/daemon/dist/domain/seat-reaper-workspace.d.ts.map +1 -0
  675. package/daemon/dist/domain/seat-reaper-workspace.js +43 -0
  676. package/daemon/dist/domain/seat-reaper-workspace.js.map +1 -0
  677. package/daemon/dist/domain/seat-restart-in-place.d.ts +11 -3
  678. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  679. package/daemon/dist/domain/seat-restart-in-place.js +39 -48
  680. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  681. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  682. package/daemon/dist/domain/seat-runtime-switch-service.js +5 -7
  683. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  684. package/daemon/dist/domain/seat-skill-storage.d.ts.map +1 -1
  685. package/daemon/dist/domain/seat-skill-storage.js +27 -5
  686. package/daemon/dist/domain/seat-skill-storage.js.map +1 -1
  687. package/daemon/dist/domain/seat-standby.d.ts +13 -0
  688. package/daemon/dist/domain/seat-standby.d.ts.map +1 -0
  689. package/daemon/dist/domain/seat-standby.js +21 -0
  690. package/daemon/dist/domain/seat-standby.js.map +1 -0
  691. package/daemon/dist/domain/seat-startup-text.d.ts +159 -0
  692. package/daemon/dist/domain/seat-startup-text.d.ts.map +1 -0
  693. package/daemon/dist/domain/seat-startup-text.js +200 -0
  694. package/daemon/dist/domain/seat-startup-text.js.map +1 -0
  695. package/daemon/dist/domain/seat-status-service.d.ts +18 -0
  696. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  697. package/daemon/dist/domain/seat-status-service.js +25 -5
  698. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  699. package/daemon/dist/domain/seat-structural-activity-service.d.ts +7 -0
  700. package/daemon/dist/domain/seat-structural-activity-service.d.ts.map +1 -1
  701. package/daemon/dist/domain/seat-structural-activity-service.js +16 -1
  702. package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
  703. package/daemon/dist/domain/session-registry.d.ts +15 -3
  704. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  705. package/daemon/dist/domain/session-registry.js +52 -5
  706. package/daemon/dist/domain/session-registry.js.map +1 -1
  707. package/daemon/dist/domain/session-transport.d.ts +12 -5
  708. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  709. package/daemon/dist/domain/session-transport.js +129 -18
  710. package/daemon/dist/domain/session-transport.js.map +1 -1
  711. package/daemon/dist/domain/shared-conversation.d.ts.map +1 -1
  712. package/daemon/dist/domain/shared-conversation.js +3 -1
  713. package/daemon/dist/domain/shared-conversation.js.map +1 -1
  714. package/daemon/dist/domain/slices/slice-indexer.d.ts +2 -2
  715. package/daemon/dist/domain/slices/slice-indexer.d.ts.map +1 -1
  716. package/daemon/dist/domain/slices/slice-indexer.js +4 -15
  717. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  718. package/daemon/dist/domain/snapshot-capture.d.ts +4 -1
  719. package/daemon/dist/domain/snapshot-capture.d.ts.map +1 -1
  720. package/daemon/dist/domain/snapshot-capture.js +14 -18
  721. package/daemon/dist/domain/snapshot-capture.js.map +1 -1
  722. package/daemon/dist/domain/snapshot-repository.d.ts +37 -0
  723. package/daemon/dist/domain/snapshot-repository.d.ts.map +1 -1
  724. package/daemon/dist/domain/snapshot-repository.js +68 -0
  725. package/daemon/dist/domain/snapshot-repository.js.map +1 -1
  726. package/daemon/dist/domain/startup-orchestrator.d.ts +8 -20
  727. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  728. package/daemon/dist/domain/startup-orchestrator.js +94 -27
  729. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  730. package/daemon/dist/domain/startup-submission-evidence.d.ts +4 -1
  731. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  732. package/daemon/dist/domain/startup-submission-evidence.js +12 -1
  733. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  734. package/daemon/dist/domain/successor-session-launcher.d.ts +9 -5
  735. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  736. package/daemon/dist/domain/successor-session-launcher.js +17 -6
  737. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  738. package/daemon/dist/domain/terminal/earlier-tile-attach-0724.d.ts +2 -0
  739. package/daemon/dist/domain/terminal/earlier-tile-attach-0724.d.ts.map +1 -0
  740. package/daemon/dist/domain/terminal/earlier-tile-attach-0724.js +54 -0
  741. package/daemon/dist/domain/terminal/earlier-tile-attach-0724.js.map +1 -0
  742. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts +28 -3
  743. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts.map +1 -1
  744. package/daemon/dist/domain/terminal/herdr-app-provider.js +216 -52
  745. package/daemon/dist/domain/terminal/herdr-app-provider.js.map +1 -1
  746. package/daemon/dist/domain/terminal/herdr-app-state.d.ts +7 -2
  747. package/daemon/dist/domain/terminal/herdr-app-state.d.ts.map +1 -1
  748. package/daemon/dist/domain/terminal/herdr-app-state.js.map +1 -1
  749. package/daemon/dist/domain/terminal/terminal-provider.d.ts +17 -0
  750. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  751. package/daemon/dist/domain/terminal/tile-attach.d.ts +4 -4
  752. package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -1
  753. package/daemon/dist/domain/terminal/tile-attach.js +14 -8
  754. package/daemon/dist/domain/terminal/tile-attach.js.map +1 -1
  755. package/daemon/dist/domain/types.d.ts +71 -4
  756. package/daemon/dist/domain/types.d.ts.map +1 -1
  757. package/daemon/dist/domain/types.js.map +1 -1
  758. package/daemon/dist/domain/usage-samples-store.d.ts.map +1 -1
  759. package/daemon/dist/domain/usage-samples-store.js.map +1 -1
  760. package/daemon/dist/domain/user-settings/settings-store.d.ts +1 -1
  761. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  762. package/daemon/dist/domain/user-settings/settings-store.js +45 -2
  763. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  764. package/daemon/dist/domain/view-projector.d.ts.map +1 -1
  765. package/daemon/dist/domain/view-projector.js +5 -2
  766. package/daemon/dist/domain/view-projector.js.map +1 -1
  767. package/daemon/dist/domain/watchdog-delivery.d.ts +3 -0
  768. package/daemon/dist/domain/watchdog-delivery.d.ts.map +1 -1
  769. package/daemon/dist/domain/watchdog-delivery.js +26 -4
  770. package/daemon/dist/domain/watchdog-delivery.js.map +1 -1
  771. package/daemon/dist/domain/watchdog-history-log.d.ts +10 -0
  772. package/daemon/dist/domain/watchdog-history-log.d.ts.map +1 -1
  773. package/daemon/dist/domain/watchdog-history-log.js +35 -1
  774. package/daemon/dist/domain/watchdog-history-log.js.map +1 -1
  775. package/daemon/dist/domain/watchdog-job-update.d.ts.map +1 -1
  776. package/daemon/dist/domain/watchdog-job-update.js +29 -4
  777. package/daemon/dist/domain/watchdog-job-update.js.map +1 -1
  778. package/daemon/dist/domain/watchdog-policy-engine.d.ts.map +1 -1
  779. package/daemon/dist/domain/watchdog-policy-engine.js +4 -1
  780. package/daemon/dist/domain/watchdog-policy-engine.js.map +1 -1
  781. package/daemon/dist/domain/watchdog-scheduler.d.ts +4 -0
  782. package/daemon/dist/domain/watchdog-scheduler.d.ts.map +1 -1
  783. package/daemon/dist/domain/watchdog-scheduler.js +14 -0
  784. package/daemon/dist/domain/watchdog-scheduler.js.map +1 -1
  785. package/daemon/dist/domain/workflow-role-context.d.ts.map +1 -1
  786. package/daemon/dist/domain/workflow-role-context.js +1 -0
  787. package/daemon/dist/domain/workflow-role-context.js.map +1 -1
  788. package/daemon/dist/domain/workflow-role-resolver.d.ts +3 -0
  789. package/daemon/dist/domain/workflow-role-resolver.d.ts.map +1 -1
  790. package/daemon/dist/domain/workflow-role-resolver.js +12 -6
  791. package/daemon/dist/domain/workflow-role-resolver.js.map +1 -1
  792. package/daemon/dist/domain/workspace/project-catalog.d.ts +7 -0
  793. package/daemon/dist/domain/workspace/project-catalog.d.ts.map +1 -1
  794. package/daemon/dist/domain/workspace/project-catalog.js +16 -9
  795. package/daemon/dist/domain/workspace/project-catalog.js.map +1 -1
  796. package/daemon/dist/domain/workspace/project-registration.d.ts +5 -1
  797. package/daemon/dist/domain/workspace/project-registration.d.ts.map +1 -1
  798. package/daemon/dist/domain/workspace/project-registration.js +11 -7
  799. package/daemon/dist/domain/workspace/project-registration.js.map +1 -1
  800. package/daemon/dist/index.d.ts +3 -0
  801. package/daemon/dist/index.d.ts.map +1 -1
  802. package/daemon/dist/index.js +14 -4
  803. package/daemon/dist/index.js.map +1 -1
  804. package/daemon/dist/middleware/auth-bearer-token.d.ts +8 -12
  805. package/daemon/dist/middleware/auth-bearer-token.d.ts.map +1 -1
  806. package/daemon/dist/middleware/auth-bearer-token.js +18 -36
  807. package/daemon/dist/middleware/auth-bearer-token.js.map +1 -1
  808. package/daemon/dist/queue-transfer-records-surface.d.ts +6 -0
  809. package/daemon/dist/queue-transfer-records-surface.d.ts.map +1 -0
  810. package/daemon/dist/queue-transfer-records-surface.js +6 -0
  811. package/daemon/dist/queue-transfer-records-surface.js.map +1 -0
  812. package/daemon/dist/rig-lookup-surface.d.ts +2 -0
  813. package/daemon/dist/rig-lookup-surface.d.ts.map +1 -0
  814. package/daemon/dist/rig-lookup-surface.js +5 -0
  815. package/daemon/dist/rig-lookup-surface.js.map +1 -0
  816. package/daemon/dist/routes/activity.d.ts.map +1 -1
  817. package/daemon/dist/routes/activity.js +4 -3
  818. package/daemon/dist/routes/activity.js.map +1 -1
  819. package/daemon/dist/routes/attention.d.ts.map +1 -1
  820. package/daemon/dist/routes/attention.js +3 -1
  821. package/daemon/dist/routes/attention.js.map +1 -1
  822. package/daemon/dist/routes/compaction.d.ts.map +1 -1
  823. package/daemon/dist/routes/compaction.js +2 -0
  824. package/daemon/dist/routes/compaction.js.map +1 -1
  825. package/daemon/dist/routes/mission-control.d.ts.map +1 -1
  826. package/daemon/dist/routes/mission-control.js +2 -1
  827. package/daemon/dist/routes/mission-control.js.map +1 -1
  828. package/daemon/dist/routes/missions.d.ts +3 -6
  829. package/daemon/dist/routes/missions.d.ts.map +1 -1
  830. package/daemon/dist/routes/missions.js +42 -76
  831. package/daemon/dist/routes/missions.js.map +1 -1
  832. package/daemon/dist/routes/network.d.ts.map +1 -1
  833. package/daemon/dist/routes/network.js +19 -1
  834. package/daemon/dist/routes/network.js.map +1 -1
  835. package/daemon/dist/routes/provider.d.ts.map +1 -1
  836. package/daemon/dist/routes/provider.js +156 -5
  837. package/daemon/dist/routes/provider.js.map +1 -1
  838. package/daemon/dist/routes/queue-transfer.d.ts +9 -0
  839. package/daemon/dist/routes/queue-transfer.d.ts.map +1 -0
  840. package/daemon/dist/routes/queue-transfer.js +109 -0
  841. package/daemon/dist/routes/queue-transfer.js.map +1 -0
  842. package/daemon/dist/routes/queue.d.ts.map +1 -1
  843. package/daemon/dist/routes/queue.js +80 -51
  844. package/daemon/dist/routes/queue.js.map +1 -1
  845. package/daemon/dist/routes/rigs.js +3 -0
  846. package/daemon/dist/routes/rigs.js.map +1 -1
  847. package/daemon/dist/routes/rigspec.d.ts.map +1 -1
  848. package/daemon/dist/routes/rigspec.js +4 -0
  849. package/daemon/dist/routes/rigspec.js.map +1 -1
  850. package/daemon/dist/routes/seat.d.ts.map +1 -1
  851. package/daemon/dist/routes/seat.js +19 -3
  852. package/daemon/dist/routes/seat.js.map +1 -1
  853. package/daemon/dist/routes/terminal-ws.d.ts +0 -5
  854. package/daemon/dist/routes/terminal-ws.d.ts.map +1 -1
  855. package/daemon/dist/routes/terminal-ws.js +0 -6
  856. package/daemon/dist/routes/terminal-ws.js.map +1 -1
  857. package/daemon/dist/routes/transport.js +1 -1
  858. package/daemon/dist/routes/transport.js.map +1 -1
  859. package/daemon/dist/scope-manifest-surface.d.ts +4 -0
  860. package/daemon/dist/scope-manifest-surface.d.ts.map +1 -0
  861. package/daemon/dist/scope-manifest-surface.js +4 -0
  862. package/daemon/dist/scope-manifest-surface.js.map +1 -0
  863. package/daemon/dist/server.d.ts +2 -1
  864. package/daemon/dist/server.d.ts.map +1 -1
  865. package/daemon/dist/server.js +6 -6
  866. package/daemon/dist/server.js.map +1 -1
  867. package/daemon/dist/startup.d.ts.map +1 -1
  868. package/daemon/dist/startup.js +126 -61
  869. package/daemon/dist/startup.js.map +1 -1
  870. package/daemon/docs/reference/agent-startup-guide.md +26 -4
  871. package/daemon/docs/reference/agent-state-taxonomy.md +22 -1
  872. package/daemon/docs/reference/claude-status-line.md +28 -0
  873. package/daemon/docs/reference/community-harness-examples/hermes/hermes.yaml +3 -0
  874. package/daemon/docs/reference/community-harness-examples/hermes/openrig-hermes-launch +10 -0
  875. package/daemon/docs/reference/community-harness-presets.md +79 -8
  876. package/daemon/docs/reference/daemon-http-clients.md +49 -2
  877. package/daemon/docs/reference/getting-started.md +73 -11
  878. package/daemon/docs/reference/harness-runner-contract.md +12 -4
  879. package/daemon/docs/reference/help.md +9 -0
  880. package/daemon/docs/reference/herdr-app.md +45 -4
  881. package/daemon/docs/reference/hosted-members.md +1 -1
  882. package/daemon/docs/reference/network-connector.md +66 -1
  883. package/daemon/docs/reference/pi-tool-selection-recovery.md +13 -29
  884. package/daemon/docs/reference/queue-transfer-activation.md +89 -0
  885. package/daemon/docs/reference/queue-transfer-staging.md +1 -1
  886. package/daemon/docs/reference/quickstart.md +4 -4
  887. package/daemon/docs/reference/refocus-channel.md +21 -0
  888. package/daemon/docs/reference/rig-bundle.md +25 -0
  889. package/daemon/docs/reference/rig-spec.md +218 -23
  890. package/daemon/docs/reference/scoped-operating-posture.md +6 -1
  891. package/daemon/docs/reference/sdlc-conventions.md +10 -4
  892. package/daemon/docs/reference/seat-delivery.md +108 -12
  893. package/daemon/docs/reference/seat-node-targeting.md +2 -2
  894. package/daemon/docs/reference/seat-pools.md +181 -18
  895. package/daemon/docs/reference/seat-scaling.md +137 -0
  896. package/daemon/docs/reference/whats-new.md +190 -14
  897. package/daemon/specs/agents/development/implementer/guidance/role.md +11 -0
  898. package/daemon/specs/agents/development/qa/guidance/role.md +5 -0
  899. package/daemon/specs/agents/shared/skills/core/cross-host-rig-commands/SKILL.md +9 -1
  900. package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +32 -19
  901. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +8 -3
  902. package/dist/build-info.js +3 -3
  903. package/dist/cli-error.d.ts +2 -0
  904. package/dist/cli-error.d.ts.map +1 -1
  905. package/dist/cli-error.js +25 -8
  906. package/dist/cli-error.js.map +1 -1
  907. package/dist/client.d.ts +1 -0
  908. package/dist/client.d.ts.map +1 -1
  909. package/dist/client.js +13 -0
  910. package/dist/client.js.map +1 -1
  911. package/dist/commands/auth.d.ts.map +1 -1
  912. package/dist/commands/auth.js +52 -1
  913. package/dist/commands/auth.js.map +1 -1
  914. package/dist/commands/config.d.ts.map +1 -1
  915. package/dist/commands/config.js +3 -0
  916. package/dist/commands/config.js.map +1 -1
  917. package/dist/commands/crash-cart.d.ts.map +1 -1
  918. package/dist/commands/crash-cart.js +65 -17
  919. package/dist/commands/crash-cart.js.map +1 -1
  920. package/dist/commands/daemon.d.ts +7 -20
  921. package/dist/commands/daemon.d.ts.map +1 -1
  922. package/dist/commands/daemon.js +117 -46
  923. package/dist/commands/daemon.js.map +1 -1
  924. package/dist/commands/doctor.d.ts +26 -0
  925. package/dist/commands/doctor.d.ts.map +1 -1
  926. package/dist/commands/doctor.js +148 -2
  927. package/dist/commands/doctor.js.map +1 -1
  928. package/dist/commands/import.d.ts +5 -0
  929. package/dist/commands/import.d.ts.map +1 -1
  930. package/dist/commands/import.js +24 -4
  931. package/dist/commands/import.js.map +1 -1
  932. package/dist/commands/mcp.d.ts.map +1 -1
  933. package/dist/commands/mcp.js +4 -2
  934. package/dist/commands/mcp.js.map +1 -1
  935. package/dist/commands/network.d.ts +4 -0
  936. package/dist/commands/network.d.ts.map +1 -1
  937. package/dist/commands/network.js +78 -10
  938. package/dist/commands/network.js.map +1 -1
  939. package/dist/commands/provider.d.ts +5 -1
  940. package/dist/commands/provider.d.ts.map +1 -1
  941. package/dist/commands/provider.js +427 -17
  942. package/dist/commands/provider.js.map +1 -1
  943. package/dist/commands/ps.d.ts +16 -1
  944. package/dist/commands/ps.d.ts.map +1 -1
  945. package/dist/commands/ps.js +35 -4
  946. package/dist/commands/ps.js.map +1 -1
  947. package/dist/commands/queue-transfer.d.ts +10 -0
  948. package/dist/commands/queue-transfer.d.ts.map +1 -0
  949. package/dist/commands/queue-transfer.js +140 -0
  950. package/dist/commands/queue-transfer.js.map +1 -0
  951. package/dist/commands/queue.d.ts.map +1 -1
  952. package/dist/commands/queue.js +20 -6
  953. package/dist/commands/queue.js.map +1 -1
  954. package/dist/commands/scope.d.ts.map +1 -1
  955. package/dist/commands/scope.js +258 -17
  956. package/dist/commands/scope.js.map +1 -1
  957. package/dist/commands/seat.d.ts.map +1 -1
  958. package/dist/commands/seat.js +132 -23
  959. package/dist/commands/seat.js.map +1 -1
  960. package/dist/commands/setup.d.ts +34 -0
  961. package/dist/commands/setup.d.ts.map +1 -1
  962. package/dist/commands/setup.js +111 -18
  963. package/dist/commands/setup.js.map +1 -1
  964. package/dist/commands/terminal.d.ts +11 -0
  965. package/dist/commands/terminal.d.ts.map +1 -1
  966. package/dist/commands/terminal.js +10 -7
  967. package/dist/commands/terminal.js.map +1 -1
  968. package/dist/config-store.d.ts +9 -1
  969. package/dist/config-store.d.ts.map +1 -1
  970. package/dist/config-store.js +46 -0
  971. package/dist/config-store.js.map +1 -1
  972. package/dist/daemon-lifecycle.d.ts +53 -2
  973. package/dist/daemon-lifecycle.d.ts.map +1 -1
  974. package/dist/daemon-lifecycle.js +500 -192
  975. package/dist/daemon-lifecycle.js.map +1 -1
  976. package/dist/daemon-reachability.js +2 -2
  977. package/dist/daemon-reachability.js.map +1 -1
  978. package/dist/daemon-start-lock.d.ts +28 -0
  979. package/dist/daemon-start-lock.d.ts.map +1 -1
  980. package/dist/daemon-start-lock.js +107 -13
  981. package/dist/daemon-start-lock.js.map +1 -1
  982. package/dist/lib/seat-activity.d.ts +4 -1
  983. package/dist/lib/seat-activity.d.ts.map +1 -1
  984. package/dist/lib/seat-activity.js +4 -3
  985. package/dist/lib/seat-activity.js.map +1 -1
  986. package/dist/mcp-server.d.ts +2 -2
  987. package/dist/mcp-server.d.ts.map +1 -1
  988. package/dist/mcp-server.js +126 -27
  989. package/dist/mcp-server.js.map +1 -1
  990. package/dist/process-liveness.d.ts +21 -0
  991. package/dist/process-liveness.d.ts.map +1 -0
  992. package/dist/process-liveness.js +43 -0
  993. package/dist/process-liveness.js.map +1 -0
  994. package/dist/remote-host-ops.d.ts +1 -1
  995. package/dist/remote-host-ops.d.ts.map +1 -1
  996. package/dist/remote-host-ops.js +3 -14
  997. package/dist/remote-host-ops.js.map +1 -1
  998. package/dist/system-preflight.d.ts +9 -0
  999. package/dist/system-preflight.d.ts.map +1 -1
  1000. package/dist/system-preflight.js +27 -8
  1001. package/dist/system-preflight.js.map +1 -1
  1002. package/dist/tmux-health.d.ts +10 -1
  1003. package/dist/tmux-health.d.ts.map +1 -1
  1004. package/dist/tmux-health.js +31 -2
  1005. package/dist/tmux-health.js.map +1 -1
  1006. package/package.json +4 -2
  1007. package/scripts/check-abi.mjs +18 -2
  1008. package/tui/dist/attention/attention-model.d.ts +1 -1
  1009. package/tui/dist/attention/attention-model.d.ts.map +1 -1
  1010. package/tui/dist/attention/attention-model.js +6 -0
  1011. package/tui/dist/attention/attention-model.js.map +1 -1
  1012. package/tui/dist/daemon-client.d.ts +21 -2
  1013. package/tui/dist/daemon-client.d.ts.map +1 -1
  1014. package/tui/dist/daemon-client.js +36 -5
  1015. package/tui/dist/daemon-client.js.map +1 -1
  1016. package/tui/dist/hydrate.d.ts.map +1 -1
  1017. package/tui/dist/hydrate.js +6 -2
  1018. package/tui/dist/hydrate.js.map +1 -1
  1019. package/tui/dist/main.js +11 -8
  1020. package/tui/dist/main.js.map +1 -1
  1021. package/tui/dist/terminals/open-window.d.ts +9 -3
  1022. package/tui/dist/terminals/open-window.d.ts.map +1 -1
  1023. package/tui/dist/terminals/open-window.js +22 -4
  1024. package/tui/dist/terminals/open-window.js.map +1 -1
  1025. package/tui/dist/terminals/terminal-model.d.ts +3 -0
  1026. package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
  1027. package/tui/dist/terminals/terminal-model.js +6 -1
  1028. package/tui/dist/terminals/terminal-model.js.map +1 -1
  1029. package/tui/dist/topology/glyphs.d.ts.map +1 -1
  1030. package/tui/dist/topology/glyphs.js +11 -1
  1031. package/tui/dist/topology/glyphs.js.map +1 -1
  1032. package/tui/dist/topology/graph-types.d.ts +8 -0
  1033. package/tui/dist/topology/graph-types.d.ts.map +1 -1
  1034. package/tui/dist/types.d.ts +3 -2
  1035. package/tui/dist/types.d.ts.map +1 -1
  1036. package/ui/dist/assets/{index-DG_7XFcL.js → index-D7OUklzs.js} +148 -148
  1037. package/ui/dist/index.html +1 -1
@@ -1,9 +1,11 @@
1
1
  import path from "node:path";
2
2
  import { existsSync } from "node:fs";
3
+ import { createServer } from "node:net";
3
4
  import { DaemonClient, ForeignLocalDaemonError, connectionErrorCode, formatDaemonHostForUrl } from "./client.js";
4
5
  import { daemonFetch, SandboxProxyError } from "./daemon-transport.js";
5
6
  import { blockedConnectionGuidance, daemonMayAnswer, isBlockedConnectionCode } from "./daemon-reachability.js";
6
7
  export { daemonMayAnswer } from "./daemon-reachability.js";
8
+ import { observeStartReservation } from "./daemon-start-lock.js";
7
9
  import { DAEMON_START_READINESS_WAIT_MS as STARTUP_READINESS_DEADLINE_MS, DAEMON_START_PROBE_TIMEOUT_MS as STARTUP_PROBE_TIMEOUT_MS, DAEMON_STOP_WAIT_MS, DAEMON_SHUTDOWN_RECEIPT, occupiedPortGuidance } from "../daemon/dist/daemon-shutdown.js";
8
10
  import { ConfigStore } from "./config-store.js";
9
11
  import { OPENRIG_HOME, LEGACY_RIGGED_HOME, readOpenRigEnv, readOpenRigUrl } from "./openrig-compat.js";
@@ -91,12 +93,24 @@ export function daemonStatusGuard(status, opts) {
91
93
  process.exitCode = 1;
92
94
  return false;
93
95
  }
96
+ /** #4101: the guard's stable code for a `--json` caller, one per case of {@link statusGuardMessage}. The guard stops
97
+ * before the command makes its request, so its outcome is always `not_delivered`. */
98
+ export function statusGuardCode(status) {
99
+ if (status.state === "stopped" || status.state === "stale")
100
+ return "daemon_not_running";
101
+ if (isBlockedConnectionCode(status.probeErrorCode))
102
+ return "daemon_connection_blocked";
103
+ if (status.startPending)
104
+ return "daemon_starting";
105
+ return "daemon_unreachable";
106
+ }
94
107
  /** The guard's words for a daemon that can't answer, without failing the command: for one that goes on anyway, as
95
108
  * `rig mcp serve` over stdio does when an app starts it before the daemon. */
96
109
  export function printStatusGuard(status, opts) {
97
110
  const err = statusGuardMessage(status);
98
111
  if (opts?.json) {
99
- console.log(JSON.stringify({ error: err }));
112
+ // The transport errors' shape (#4101), with `message` as in every other CLI error: a script branches on `code`.
113
+ console.log(JSON.stringify({ ok: false, error: { code: statusGuardCode(status), outcome: "not_delivered", message: err.fact, ...err } }));
100
114
  }
101
115
  else {
102
116
  console.error(`Error: ${err.fact}`);
@@ -476,10 +490,147 @@ class StartupIdentityError extends Error {
476
490
  }
477
491
  class StartupChildPendingError extends Error {
478
492
  }
493
+ /** A port the OS reports free on `host` now: listen on port 0, read the port it gave, close. */
494
+ function pickFreePort(host) {
495
+ return new Promise((resolve, reject) => {
496
+ const server = createServer();
497
+ server.once("error", reject);
498
+ server.listen({ host, port: 0, exclusive: true }, () => {
499
+ const address = server.address();
500
+ const port = typeof address === "object" && address ? address.port : 0;
501
+ server.close(() => port > 0 ? resolve(port) : reject(new Error(`Could not find a free port on ${host}`)));
502
+ });
503
+ });
504
+ }
505
+ /** #1786, #1743 — the readiness a start requires of the child it owns, within one elapsed budget: the health endpoint at
506
+ * the launch address names the child's PID, and so does every required listener its bind reports
507
+ * (verifyRequiredListeners); only listeners other than the launch endpoint may stay uncertain, for
508
+ * STARTUP_SECONDARY_GRACE_MS. `assertChild` throws once the child is gone or is no longer that process, `failed`
509
+ * rejects when it fails, and `childFailed` says it already has. The start that spawned the child and a later start
510
+ * that finishes it both wait for this. Throws StartupIdentityError when another process answers or the listener gate
511
+ * fails. */
512
+ async function awaitOwnedReadiness(input) {
513
+ const { deps, pid, port, probeHost, assertChild } = input;
514
+ const failed = input.failed ?? new Promise(() => { });
515
+ const healthzUrl = `http://${formatDaemonHostForUrl(probeHost)}:${port}/healthz`;
516
+ const readinessStartedAt = Date.now();
517
+ const deadline = readinessStartedAt + input.waitMs;
518
+ const remaining = () => Math.max(0, deadline - Date.now());
519
+ const readOwnedHealth = async (url) => {
520
+ assertChild();
521
+ // No new primary or listener fetch once the deadline has passed: a 0ms timer would still start one.
522
+ if (remaining() <= 0)
523
+ throw new HealthProbeTimeoutError(url);
524
+ let timer;
525
+ try {
526
+ return await Promise.race([
527
+ failed,
528
+ new Promise((_, reject) => {
529
+ timer = setTimeout(() => reject(new HealthProbeTimeoutError(url)), Math.min(STARTUP_PROBE_TIMEOUT_MS, remaining()));
530
+ }),
531
+ (async () => {
532
+ const res = await deps.fetch(url);
533
+ if (!res.ok)
534
+ return null;
535
+ let body;
536
+ try {
537
+ body = res.json ? await res.json() : null;
538
+ }
539
+ catch {
540
+ throw new StartupIdentityError(`Daemon startup identity unavailable at ${url}: expected child PID ${pid}; invalid health response`);
541
+ }
542
+ if (body?.pid !== pid) {
543
+ throw new StartupIdentityError(`Daemon startup identity mismatch at ${url}: expected child PID ${pid}, observed ${typeof body?.pid === "number" ? body.pid : "unknown"}; state not published`);
544
+ }
545
+ assertChild();
546
+ return body;
547
+ })(),
548
+ ]);
549
+ }
550
+ finally {
551
+ if (timer)
552
+ clearTimeout(timer);
553
+ }
554
+ };
555
+ let healthy = false;
556
+ let verified = [];
557
+ let databaseWarnings = [];
558
+ let lastProbe = "health endpoint not responding";
559
+ let unverified = null;
560
+ let nextProgressAt = readinessStartedAt + STARTUP_PROGRESS_INTERVAL_MS;
561
+ // Since when only listeners other than the probed one have been uncertain, round after round.
562
+ let secondaryOnlySince = null;
563
+ while (remaining() > 0) {
564
+ unverified = null;
565
+ try {
566
+ const body = await readOwnedHealth(healthzUrl);
567
+ if (body) {
568
+ databaseWarnings = readDatabaseWarnings(body.databaseWarnings);
569
+ const bind = body.bind;
570
+ if (!bind || !["explicit", "default"].includes(bind.mode) || !Array.isArray(bind.hosts)
571
+ || bind.hosts.length === 0 || !bind.hosts.every((host) => typeof host === "string" && host.length > 0)
572
+ || typeof bind.tailscaleDetected !== "boolean") {
573
+ throw new StartupIdentityError(`Daemon startup listener identity unavailable for child PID ${pid}; state not published`);
574
+ }
575
+ const gate = await verifyRequiredListeners({ bind, port, probe: async (url) => {
576
+ try {
577
+ return await readOwnedHealth(url) ? "healthy" : "unhealthy";
578
+ }
579
+ catch (error) {
580
+ if (error instanceof StartupIdentityError || input.childFailed?.())
581
+ throw error;
582
+ const code = error.code
583
+ ?? error.cause?.code;
584
+ return code === "ECONNREFUSED" ? "unhealthy" : "indeterminate";
585
+ }
586
+ } });
587
+ if (gate.ok === false)
588
+ throw new StartupIdentityError(`Daemon child ${pid} FAILED the listener adoption gate: ${gate.reason}`);
589
+ if (gate.ok === true) {
590
+ healthy = true;
591
+ verified = gate.verified;
592
+ break;
593
+ }
594
+ unverified = gate.hosts;
595
+ lastProbe = gate.reason;
596
+ }
597
+ }
598
+ catch (error) {
599
+ assertChild();
600
+ if (error instanceof StartupIdentityError)
601
+ throw error;
602
+ lastProbe = error instanceof Error ? error.message : String(error);
603
+ }
604
+ // A clear answer may still come in the next few rounds; past the grace, start and say which is unverified.
605
+ if (unverified === null || unverified.some((host) => formatDaemonHostForUrl(host) === formatDaemonHostForUrl(probeHost)))
606
+ secondaryOnlySince = null;
607
+ else if (Date.now() - (secondaryOnlySince ??= Date.now()) >= STARTUP_SECONDARY_GRACE_MS)
608
+ break;
609
+ if (remaining() > 0 && Date.now() >= nextProgressAt) {
610
+ console.error(input.progress(Math.floor((Date.now() - readinessStartedAt) / 1000)));
611
+ nextProgressAt = Date.now() + STARTUP_PROGRESS_INTERVAL_MS;
612
+ }
613
+ await Promise.race([new Promise((resolve) => setTimeout(resolve, Math.min(HEALTHZ_DELAY_MS, remaining()))), failed]);
614
+ }
615
+ return { healthy, verified, unverified, lastProbe, databaseWarnings };
616
+ }
479
617
  export async function startDaemon(opts, deps) {
480
618
  if (!deps.acquireStartLock)
481
619
  throw new Error("Daemon startup requires a local launch reservation");
482
- const lock = deps.acquireStartLock();
620
+ // A start that ended pending left its child running and its reservation naming it: finish that start first.
621
+ const finish = await finishPendingStart(opts, deps);
622
+ if (typeof finish === "object")
623
+ return finish;
624
+ let lock;
625
+ try {
626
+ lock = deps.acquireStartLock();
627
+ }
628
+ catch (error) {
629
+ // Its reservation still refuses this start; say why this start didn't finish it.
630
+ if (finish && error instanceof Error)
631
+ throw new Error(`${error.message} ${finish}`, { cause: error });
632
+ throw error;
633
+ }
483
634
  let preserve = false;
484
635
  try {
485
636
  return await startOwnedDaemon(opts, deps, lock);
@@ -493,7 +644,6 @@ export async function startDaemon(opts, deps) {
493
644
  }
494
645
  }
495
646
  async function startOwnedDaemon(opts, deps, lock) {
496
- const port = opts.port ?? DEFAULT_PORT;
497
647
  const db = opts.db ?? DEFAULT_DB;
498
648
  // bug-fix slice auth-bearer-tailscale-trust: preserve the
499
649
  // user-explicit-vs-default distinction. `opts.host` is undefined when
@@ -503,6 +653,9 @@ async function startOwnedDaemon(opts, deps, lock) {
503
653
  // (loopback + tailscale auto-detect).
504
654
  const explicitHost = opts.host;
505
655
  const probeHost = explicitHost ?? DEFAULT_HOST;
656
+ // Port 0 (--port 0 or daemon.port 0) means any free port. Choose it here, so the child, the readiness probes and
657
+ // daemon.json all name the port the daemon listens on; a child given 0 would pick one this launcher can't see.
658
+ const port = opts.port === 0 ? await (deps.pickFreePort ?? pickFreePort)(probeHost) : opts.port ?? DEFAULT_PORT;
506
659
  const readinessWaitMs = opts.readinessWaitSeconds !== undefined ? opts.readinessWaitSeconds * 1000 : STARTUP_READINESS_DEADLINE_MS;
507
660
  // Check if already running
508
661
  const existing = readState(deps);
@@ -539,7 +692,10 @@ async function startOwnedDaemon(opts, deps, lock) {
539
692
  }
540
693
  // WSL2 can silently drop probes to an unused port. A slow live daemon can
541
694
  // also time out: do not run a second child's initialization against its DB.
542
- if (error instanceof HealthProbeTimeoutError && await deps.isPortOccupied?.(probeHost, port)) {
695
+ // Only a refusal says nothing listens. Any other failure (a timeout, a listener that resets the connection, a
696
+ // blocked probe) gets the bind check, so a positively occupied endpoint never reaches a spawn: not even after a
697
+ // start reservation whose child died was reclaimed, once start's preflight let that child's port through.
698
+ if (!isRefusedError(error) && await deps.isPortOccupied?.(probeHost, port)) {
543
699
  throw new Error(occupiedPortGuidance(port));
544
700
  }
545
701
  }
@@ -622,107 +778,14 @@ async function startOwnedDaemon(opts, deps, lock) {
622
778
  throw new Error(`Daemon child ${pid} exited before startup completed`);
623
779
  };
624
780
  const healthzUrl = `http://${formatDaemonHostForUrl(probeHost)}:${port}/healthz`;
625
- let deadline = Number.POSITIVE_INFINITY;
626
- const remaining = () => Math.max(0, deadline - Date.now());
627
- const readOwnedHealth = async (url) => {
628
- assertChild();
629
- // No new primary or listener fetch once the deadline has passed: a 0ms timer would still start one.
630
- if (remaining() <= 0)
631
- throw new HealthProbeTimeoutError(url);
632
- let timer;
633
- try {
634
- return await Promise.race([
635
- failed,
636
- new Promise((_, reject) => {
637
- timer = setTimeout(() => reject(new HealthProbeTimeoutError(url)), Math.min(STARTUP_PROBE_TIMEOUT_MS, remaining()));
638
- }),
639
- (async () => {
640
- const res = await deps.fetch(url);
641
- if (!res.ok)
642
- return null;
643
- let body;
644
- try {
645
- body = res.json ? await res.json() : null;
646
- }
647
- catch {
648
- throw new StartupIdentityError(`Daemon startup identity unavailable at ${url}: expected child PID ${pid}; invalid health response`);
649
- }
650
- if (body?.pid !== pid) {
651
- throw new StartupIdentityError(`Daemon startup identity mismatch at ${url}: expected child PID ${pid}, observed ${typeof body?.pid === "number" ? body.pid : "unknown"}; state not published`);
652
- }
653
- assertChild();
654
- return body;
655
- })(),
656
- ]);
657
- }
658
- finally {
659
- if (timer)
660
- clearTimeout(timer);
661
- }
662
- };
663
781
  try {
664
782
  assertChild();
665
- lock.recordChild(pid, { startToken: deps.processStartToken?.(pid), pidNamespace: deps.pidNamespace?.(), host: probeHost, port });
666
- let healthy = false;
667
- let databaseWarnings = [];
668
- let lastProbe = "health endpoint not responding";
669
- let unverified = null;
670
- const readinessStartedAt = Date.now();
671
- deadline = readinessStartedAt + readinessWaitMs;
672
- let nextProgressAt = readinessStartedAt + STARTUP_PROGRESS_INTERVAL_MS;
673
- // Since when only listeners other than the probed one have been uncertain, round after round.
674
- let secondaryOnlySince = null;
675
- while (remaining() > 0) {
676
- unverified = null;
677
- try {
678
- const body = await readOwnedHealth(healthzUrl);
679
- if (body) {
680
- databaseWarnings = readDatabaseWarnings(body.databaseWarnings);
681
- const bind = body.bind;
682
- if (!bind || !["explicit", "default"].includes(bind.mode) || !Array.isArray(bind.hosts)
683
- || bind.hosts.length === 0 || !bind.hosts.every((host) => typeof host === "string" && host.length > 0)
684
- || typeof bind.tailscaleDetected !== "boolean") {
685
- throw new StartupIdentityError(`Daemon startup listener identity unavailable for child PID ${pid}; state not published`);
686
- }
687
- const gate = await verifyRequiredListeners({ bind, port, probe: async (url) => {
688
- try {
689
- return await readOwnedHealth(url) ? "healthy" : "unhealthy";
690
- }
691
- catch (error) {
692
- if (error instanceof StartupIdentityError || childFailure)
693
- throw error;
694
- const code = error.code
695
- ?? error.cause?.code;
696
- return code === "ECONNREFUSED" ? "unhealthy" : "indeterminate";
697
- }
698
- } });
699
- if (gate.ok === false)
700
- throw new StartupIdentityError(`Daemon child ${pid} FAILED the listener adoption gate: ${gate.reason}`);
701
- if (gate.ok === true) {
702
- healthy = true;
703
- break;
704
- }
705
- unverified = gate.hosts;
706
- lastProbe = gate.reason;
707
- }
708
- }
709
- catch (error) {
710
- assertChild();
711
- if (error instanceof StartupIdentityError)
712
- throw error;
713
- lastProbe = error instanceof Error ? error.message : String(error);
714
- }
715
- // A clear answer may still come in the next few rounds; past the grace, start and say which is unverified.
716
- if (unverified === null || unverified.some((host) => formatDaemonHostForUrl(host) === formatDaemonHostForUrl(probeHost)))
717
- secondaryOnlySince = null;
718
- else if (Date.now() - (secondaryOnlySince ??= Date.now()) >= STARTUP_SECONDARY_GRACE_MS)
719
- break;
720
- if (remaining() > 0 && Date.now() >= nextProgressAt) {
721
- console.error(`Waiting for daemon child ${pid} readiness (${Math.floor((Date.now() - readinessStartedAt) / 1000)}s elapsed; ${readinessWaitMs / 1000}s limit). This start has not published readiness.`);
722
- nextProgressAt = Date.now() + STARTUP_PROGRESS_INTERVAL_MS;
723
- }
724
- await Promise.race([new Promise((resolve) => setTimeout(resolve, Math.min(HEALTHZ_DELAY_MS, remaining()))), failed]);
725
- }
783
+ lock.recordChild(pid, { startToken: deps.processStartToken?.(pid), pidNamespace: deps.pidNamespace?.(), host: probeHost, port, db });
784
+ const { healthy, databaseWarnings, lastProbe, unverified } = await awaitOwnedReadiness({
785
+ deps, pid: pid, port, probeHost, waitMs: readinessWaitMs, assertChild, failed,
786
+ childFailed: () => childFailure !== undefined,
787
+ progress: (elapsed) => `Waiting for daemon child ${pid} readiness (${elapsed}s elapsed; ${readinessWaitMs / 1000}s limit). This start has not published readiness.`,
788
+ });
726
789
  // In the last round the child's own endpoint named its PID, and only another listener's check stayed
727
790
  // uncertain: start, and say which listener is unverified.
728
791
  const unverifiedSecondary = unverified !== null
@@ -736,7 +799,7 @@ async function startOwnedDaemon(opts, deps, lock) {
736
799
  assertChild();
737
800
  if (deps.isProcessAlive(pid)) {
738
801
  assertChild();
739
- throw new StartupChildPendingError(`Daemon startup is pending after the readiness deadline (child PID ${pid}). Readiness is not confirmed; child left running and startup reservation retained. Last probe: ${lastProbe}. Launch endpoint: ${healthzUrl}. Inspect that URL and ${LOG_FILE}; this check does not publish readiness, adopt the child or release the reservation. To restart manually, stop child PID ${pid} and wait for exit; inspect ${path.join(OPENRIG_DIR, "daemon-start.lock")}, and only after both recorded launcher and child PIDs are absent, archive it and run 'rig daemon start'. Once this launcher has exited, 'rig daemon stop' can check this child against this reservation (when its start token and pid namespace were recorded) and, if it is confirmed, stop it and release the reservation; until then another start remains blocked by it.`);
802
+ throw new StartupChildPendingError(`Daemon startup is pending after the readiness deadline (child PID ${pid}). Readiness is not confirmed; child left running and startup reservation retained. Last probe: ${lastProbe}. Launch endpoint: ${healthzUrl}. Inspect that URL and ${LOG_FILE}; this check does not publish readiness, adopt the child or release the reservation. To restart manually, stop child PID ${pid} and wait for exit; inspect ${path.join(OPENRIG_DIR, "daemon-start.lock")}, and only after both recorded launcher and child PIDs are absent, archive it and run 'rig daemon start'. Once child PID ${pid} is ready, run 'rig daemon start' again to finish this start: it checks this child against this reservation, publishes daemon.json for it and retires the reservation, without starting another daemon. Once this launcher has exited, 'rig daemon stop' can check this child against this reservation (when its start token and pid namespace were recorded) and, if it is confirmed, stop it and release the reservation; until one of them does, another start remains blocked by it.`);
740
803
  }
741
804
  throw new Error(`${summarizeDaemonStartFailure(healthzUrl, deps.readFile(resolveLifecycleFile(deps, "daemon.log")))}. Last probe: ${lastProbe}`);
742
805
  }
@@ -833,12 +896,17 @@ function sharesPidNamespace(state, deps) {
833
896
  return own === state.pidNamespace;
834
897
  return own === "host" || own === INITIAL_PID_NAMESPACE;
835
898
  }
836
- function removeMatchingState(deps, stateFile, state) {
899
+ /** Removes daemon.json while it still names exactly `state`, or, given `restore`, writes those bytes back in its place. */
900
+ function removeMatchingState(deps, stateFile, state, restore) {
837
901
  // A concurrent start/rebind must not have its state removed by an old stop/status.
838
902
  const current = readState(deps);
839
903
  if (current?.pid === state.pid && current.startedAt === state.startedAt && current.port === state.port
840
- && current.host === state.host && current.db === state.db)
841
- deps.removeFile(stateFile);
904
+ && current.host === state.host && current.db === state.db) {
905
+ if (restore === undefined)
906
+ deps.removeFile(stateFile);
907
+ else
908
+ deps.writeFile(stateFile, restore);
909
+ }
842
910
  }
843
911
  /** #3315 — the strict read stop acts on: exactly the launcher record and the one child record startDaemon writes,
844
912
  * then only the retention records an earlier stop appended (#3637). */
@@ -880,6 +948,204 @@ function readStartReservation(deps, file) {
880
948
  return {
881
949
  raw, launcherPid: head.launcherPid, bootId: text(head.bootId), childPid: child.childPid,
882
950
  startToken: text(child.startToken), pidNamespace: text(child.pidNamespace), endpoint,
951
+ host, port, db: text(child.db), retained: lines.length > 2,
952
+ };
953
+ }
954
+ /** #3315 — whether a start reservation still names its child, as stop and a finishing start both check it: the same
955
+ * boot, the child's pid namespace (this shell's), the launcher gone (that start can no longer publish), and the child
956
+ * alive with its recorded start token (a reused PID matches only within the OS start-time resolution). Returns why
957
+ * not, or `recheck`, which reads liveness and the token again right before acting. Userspace checks, not atomic with
958
+ * what follows them. */
959
+ function reservedChildIdentity(deps, r, liveness) {
960
+ const ownBoot = deps.bootId?.();
961
+ if (!r.bootId || !ownBoot || r.bootId !== ownBoot)
962
+ return { refusal: "its boot ID is not this boot's" };
963
+ // An unknown namespace is no evidence of the host's: the record must name one, and this shell must read the same.
964
+ if (!r.pidNamespace)
965
+ return { refusal: "it records no pid namespace for its child" };
966
+ const ownNamespace = deps.pidNamespace?.();
967
+ if (!ownNamespace)
968
+ return { refusal: "this shell's pid namespace is unknown" };
969
+ if (ownNamespace !== r.pidNamespace)
970
+ return { refusal: "its PIDs are numbered in another pid namespace than this shell's" };
971
+ const launcher = liveness(r.launcherPid);
972
+ if (launcher !== "dead") {
973
+ return { refusal: `launcher PID ${r.launcherPid} is ${launcher === "alive" ? "alive; startup may still be in progress" : "of unknown liveness"}` };
974
+ }
975
+ const recheck = (when) => {
976
+ const child = liveness(r.childPid);
977
+ if (child !== "alive")
978
+ return `child PID ${r.childPid} is ${child === "dead" ? "absent" : "of unknown liveness"}${when}`;
979
+ const token = deps.processStartToken?.(r.childPid);
980
+ if (token === r.startToken)
981
+ return undefined;
982
+ return token === undefined
983
+ ? `child PID ${r.childPid} start identity is unavailable${when}`
984
+ : `PID ${r.childPid} is now another process than the reserved child (start ${token}, reserved ${r.startToken})${when}`;
985
+ };
986
+ const before = recheck("");
987
+ return before ? { refusal: before } : { recheck };
988
+ }
989
+ /** Where a daemon.json already present fails to describe the reserved launch in full, apart from its database. */
990
+ function descriptorMismatch(state, r) {
991
+ if (state.pid !== r.childPid)
992
+ return `daemon.json names PID ${state.pid}, not child PID ${r.childPid}`;
993
+ if (state.port !== r.port)
994
+ return `daemon.json names port ${state.port}, not the launch's port ${r.port}`;
995
+ if ((state.host ?? DEFAULT_HOST) !== r.host)
996
+ return `daemon.json names host ${state.host}, not the launch's host ${r.host}`;
997
+ // A start records the namespace only when it isn't "host" (an OS without pid namespaces).
998
+ if ((state.pidNamespace ?? "host") !== r.pidNamespace) {
999
+ return `daemon.json names pid namespace ${state.pidNamespace ?? "host"}, not the launch's ${r.pidNamespace}`;
1000
+ }
1001
+ if (typeof state.db !== "string" || !state.db)
1002
+ return "daemon.json names no database";
1003
+ if (typeof state.startedAt !== "string" || !Number.isFinite(Date.parse(state.startedAt)))
1004
+ return "daemon.json has no valid start time";
1005
+ return undefined;
1006
+ }
1007
+ /** A start that ended pending (StartupChildPendingError) left its child running and its reservation naming it, and only
1008
+ * that start could have published daemon.json. A later start finishes it: once the reservation still names that child
1009
+ * (reservedChildIdentity, as stop checks it) and the child passes this start's own readiness, it publishes daemon.json
1010
+ * for exactly that child, or keeps a daemon.json that already describes it in full, and then retires that launch's
1011
+ * reservation, under the claim every remover takes. The database is the one the launch recorded; an older CLI's
1012
+ * reservation records none, so then it is the one daemon.json names (or this start's), only while the child holds that
1013
+ * file open. It never spawns or signals a process, and the only file it replaces is a daemon.json whose PID is
1014
+ * positively gone (an earlier daemon's leftover), while its bytes are unchanged. Returns undefined when there is no such start, why it
1015
+ * didn't finish one (that reservation then refuses this start, as before), or what it finished. */
1016
+ async function finishPendingStart(opts, deps) {
1017
+ if (!deps.finishStartReservation)
1018
+ return undefined;
1019
+ const file = path.join(deps.homeDir ?? OPENRIG_DIR, "daemon-start.lock");
1020
+ const r = readStartReservation(deps, file);
1021
+ if (r === "absent" || r === "malformed")
1022
+ return undefined;
1023
+ const not = (why) => `This start did not finish the earlier start of child PID ${r.childPid}: ${why}. Nothing was published or retired.`;
1024
+ if (r.retained)
1025
+ return not("a 'rig daemon stop' kept it after a shutdown it couldn't verify");
1026
+ if (!r.startToken || !r.host || !r.port)
1027
+ return not("its reservation records no child identity (an older CLI's, or one whose start couldn't identify its child)");
1028
+ const liveness = (pid) => deps.processLiveness
1029
+ ? deps.processLiveness(pid)
1030
+ : deps.isProcessAlive(pid) ? "alive" : "dead";
1031
+ const identity = reservedChildIdentity(deps, r, liveness);
1032
+ if ("refusal" in identity)
1033
+ return not(identity.refusal);
1034
+ // A daemon.json already present must describe this launch in full: someone may have published it by hand.
1035
+ const stateFile = resolveLifecycleFile(deps, "daemon.json");
1036
+ const existingRaw = deps.exists(stateFile) ? deps.readFile(stateFile) : null;
1037
+ if (existingRaw === null && deps.exists(stateFile))
1038
+ return not("daemon.json is present but unreadable");
1039
+ let existing;
1040
+ // A daemon.json naming another process that is positively gone, numbered in this shell's pid namespace, is an earlier
1041
+ // daemon's leftover (a crash, a kill, a power loss), not a step this launch completed: as an ordinary start does, the
1042
+ // finish publishes over it, and only while its bytes are still the ones read here. A live or uninspectable PID, or
1043
+ // one from another namespace, still declines.
1044
+ let leftover;
1045
+ if (existingRaw !== null) {
1046
+ try {
1047
+ existing = JSON.parse(existingRaw);
1048
+ }
1049
+ catch {
1050
+ return not("daemon.json is present but unreadable");
1051
+ }
1052
+ if (existing && typeof existing === "object" && existing.pid !== r.childPid && Number.isSafeInteger(existing.pid)
1053
+ && existing.pid > 0 && liveness(existing.pid) === "dead" && sharesPidNamespace(existing, deps)) {
1054
+ leftover = existing;
1055
+ existing = undefined;
1056
+ }
1057
+ else {
1058
+ const mismatch = existing && typeof existing === "object" ? descriptorMismatch(existing, r) : "daemon.json is present but unreadable";
1059
+ if (mismatch)
1060
+ return not(mismatch);
1061
+ }
1062
+ }
1063
+ let db = r.db;
1064
+ if (!db) {
1065
+ const candidate = existing?.db ?? opts.db ?? DEFAULT_DB;
1066
+ const held = deps.databaseHeldBy?.(r.childPid, candidate) ?? { failure: "which files a process holds open can't be read here" };
1067
+ if (held !== true) {
1068
+ return not(`its reservation records no database (an older CLI's), and ${held === false
1069
+ ? `child PID ${r.childPid} does not hold ${candidate} open`
1070
+ : `whether child PID ${r.childPid} holds ${candidate} open couldn't be read: ${held.failure}`}`);
1071
+ }
1072
+ db = candidate;
1073
+ }
1074
+ if (existing && existing.db !== db)
1075
+ return not(`daemon.json names database ${existing.db}, not the launch's ${db}`);
1076
+ const waitMs = opts.readinessWaitSeconds !== undefined ? opts.readinessWaitSeconds * 1000 : STARTUP_READINESS_DEADLINE_MS;
1077
+ const endpoint = `http://${formatDaemonHostForUrl(r.host)}:${r.port}/healthz`;
1078
+ console.error(`An earlier start's child PID ${r.childPid} is reserved: waiting up to ${waitMs / 1000}s for its readiness at ${endpoint} to finish that start, not starting another daemon.`);
1079
+ let readiness;
1080
+ try {
1081
+ readiness = await awaitOwnedReadiness({
1082
+ deps, pid: r.childPid, port: r.port, probeHost: r.host, waitMs,
1083
+ assertChild: () => { const why = identity.recheck(" during the readiness check"); if (why)
1084
+ throw new Error(why); },
1085
+ progress: (elapsed) => `Waiting for daemon child ${r.childPid} of an earlier start to become ready (${elapsed}s elapsed; ${waitMs / 1000}s limit). Nothing is published yet.`,
1086
+ });
1087
+ }
1088
+ catch (error) {
1089
+ return not(error instanceof Error ? error.message : String(error));
1090
+ }
1091
+ const unverifiedSecondary = readiness.unverified !== null
1092
+ && !readiness.unverified.some((host) => formatDaemonHostForUrl(host) === formatDaemonHostForUrl(r.host));
1093
+ if (!readiness.healthy && !unverifiedSecondary) {
1094
+ return not(`its readiness is not confirmed at ${endpoint} within ${waitMs / 1000}s (last probe: ${readiness.lastProbe}); child PID ${r.childPid} was left running`);
1095
+ }
1096
+ let published;
1097
+ const publish = () => {
1098
+ const why = identity.recheck(" at publication");
1099
+ if (why)
1100
+ throw new Error(why);
1101
+ if (existing) {
1102
+ if ((deps.exists(stateFile) ? deps.readFile(stateFile) : null) !== existingRaw)
1103
+ throw new Error("daemon.json changed while this start checked the child");
1104
+ published = { state: existing, publication: "already-correct" };
1105
+ return;
1106
+ }
1107
+ const now = deps.exists(stateFile) ? deps.readFile(stateFile) : undefined;
1108
+ if (leftover ? now !== existingRaw : now !== undefined) {
1109
+ throw new Error(leftover ? "daemon.json changed while this start checked the child" : "a daemon.json appeared while this start checked the child");
1110
+ }
1111
+ const state = {
1112
+ pid: r.childPid, port: r.port, host: r.host, db: db, startedAt: new Date().toISOString(),
1113
+ ...(r.pidNamespace !== "host" ? { pidNamespace: r.pidNamespace } : {}),
1114
+ };
1115
+ try {
1116
+ deps.writeFile(STATE_FILE, JSON.stringify(state, null, 2));
1117
+ // As a start does: check the child on the other side of publication.
1118
+ const after = identity.recheck(" at publication");
1119
+ if (after)
1120
+ throw new Error(`${after}; startup not accepted`);
1121
+ }
1122
+ catch (error) {
1123
+ // Take back only what this attempt wrote: a leftover it replaced in this path goes back as it was, so nothing has
1124
+ // changed. One read from the legacy home was never touched, so only the attempted daemon.json is removed.
1125
+ removeMatchingState(deps, STATE_FILE, state, leftover && stateFile === STATE_FILE ? existingRaw : undefined);
1126
+ throw error;
1127
+ }
1128
+ published = { state, publication: "written" };
1129
+ };
1130
+ let retired;
1131
+ try {
1132
+ retired = deps.finishStartReservation(file, r.raw, publish);
1133
+ }
1134
+ catch (error) {
1135
+ return not(`its publication failed: ${error instanceof Error ? error.message : String(error)}`);
1136
+ }
1137
+ if (!published)
1138
+ return not("its reservation is held by another operation, or it changed while this start checked it");
1139
+ for (const warning of readiness.databaseWarnings)
1140
+ console.error(`Warning: ${warning}`);
1141
+ return {
1142
+ ...published.state,
1143
+ finished: {
1144
+ publication: published.publication,
1145
+ ...(leftover && published.publication === "written" ? { replacedPid: leftover.pid } : {}),
1146
+ reservation: retired ? { retired } : { kept: `it couldn't be moved; inspect ${file}, and run 'rig daemon start' again to retire it` },
1147
+ readiness: readiness.healthy ? { verified: readiness.verified } : { unverified: readiness.unverified },
1148
+ },
883
1149
  };
884
1150
  }
885
1151
  /** #3315 — with no recorded state, a start that ended pending (StartupChildPendingError) leaves its child running and
@@ -902,44 +1168,24 @@ async function stopReservedChild(deps, ctx) {
902
1168
  if (deps.exists(resolveLifecycleFile(deps, "daemon.json"))) {
903
1169
  return refuse("a daemon.json is present but unreadable, and nothing ties it to the reserved child");
904
1170
  }
1171
+ const liveness = (pid) => deps.processLiveness
1172
+ ? deps.processLiveness(pid)
1173
+ : deps.isProcessAlive(pid) ? "alive" : "dead";
905
1174
  if (!r.startToken || !r.endpoint) {
906
- return refuse("it records no child identity (an older CLI's reservation, or one whose start could not identify the child)");
1175
+ // #3953: with its launcher gone, no start is in progress, so stop may still identify the daemon another way.
1176
+ const launcherLiveness = liveness(r.launcherPid);
1177
+ const starting = launcherLiveness === "dead" ? ""
1178
+ : `; launcher PID ${r.launcherPid} is ${launcherLiveness === "alive" ? "alive" : "of unknown liveness"}, so a start may be in progress`;
1179
+ return { ...refuse(`it records no child identity (an older CLI's reservation, or one whose start could not identify the child)${starting}`),
1180
+ ...(launcherLiveness === "dead" ? { olderLock: true } : {}) };
907
1181
  }
908
1182
  if (new URL(ctx.target).origin !== r.endpoint) {
909
1183
  return refuse(`its child was launched to listen at ${r.endpoint}, not at the checked ${ctx.check} (set OPENRIG_URL=${r.endpoint} to check it)`);
910
1184
  }
911
- const ownBoot = deps.bootId?.();
912
- if (!r.bootId || !ownBoot || r.bootId !== ownBoot)
913
- return refuse("its boot ID is not this boot's");
914
- // An unknown namespace is no evidence of the host's: the record must name one, and this shell must read the same.
915
- if (!r.pidNamespace)
916
- return refuse("it records no pid namespace for its child");
917
- const ownNamespace = deps.pidNamespace?.();
918
- if (!ownNamespace)
919
- return refuse("this shell's pid namespace is unknown");
920
- if (ownNamespace !== r.pidNamespace)
921
- return refuse("its PIDs are numbered in another pid namespace than this shell's");
922
- const liveness = (pid) => deps.processLiveness
923
- ? deps.processLiveness(pid)
924
- : deps.isProcessAlive(pid) ? "alive" : "dead";
925
- const launcher = liveness(r.launcherPid);
926
- if (launcher !== "dead") {
927
- return refuse(`launcher PID ${r.launcherPid} is ${launcher === "alive" ? "alive; startup may still be in progress" : "of unknown liveness"}`);
928
- }
929
- const childIdentity = (when) => {
930
- const child = liveness(r.childPid);
931
- if (child !== "alive")
932
- return `child PID ${r.childPid} is ${child === "dead" ? "absent" : "of unknown liveness"}${when}`;
933
- const token = deps.processStartToken?.(r.childPid);
934
- if (token === r.startToken)
935
- return undefined;
936
- return token === undefined
937
- ? `child PID ${r.childPid} start identity is unavailable${when}`
938
- : `PID ${r.childPid} is now another process than the reserved child (start ${token}, reserved ${r.startToken})${when}`;
939
- };
940
- const before = childIdentity("");
941
- if (before)
942
- return refuse(before);
1185
+ const identity = reservedChildIdentity(deps, r, liveness);
1186
+ if ("refusal" in identity)
1187
+ return refuse(identity.refusal);
1188
+ const childIdentity = identity.recheck;
943
1189
  // The whole identity read is bounded, the body included: an answer with no readable PID in time is no identity.
944
1190
  // At the deadline this check's own request and body are aborted, so nothing it opened outlives the decision.
945
1191
  const probe = new AbortController();
@@ -995,7 +1241,9 @@ async function stopReservedChild(deps, ctx) {
995
1241
  if ("written" in mark)
996
1242
  current = mark.written;
997
1243
  else {
998
- // A claim that is not this stop's may be a removal in progress, which only follows a dead child: check it again.
1244
+ // A claim that is not this stop's may be a removal in progress, which only follows a dead child, or a start finishing
1245
+ // this launch, whose child is alive and which holds it for its publication only. Either way the stop checks the
1246
+ // child again and goes on: a person asked for it, and a claim an interrupted operation left must not block every stop.
999
1247
  const again = childIdentity(" after the stopping mark");
1000
1248
  if (again) {
1001
1249
  mark.release?.();
@@ -1064,8 +1312,51 @@ async function stopReservedChild(deps, ctx) {
1064
1312
  verified();
1065
1313
  }
1066
1314
  }
1315
+ /** #3953 — with no daemon record and no start reservation stop can act on, the daemon this home started, identified as
1316
+ * the daemon identifies a database's holder (daemon-db-path.ts): the listener at the checked endpoint names its PID, and
1317
+ * that PID's stdout and stderr are this home's daemon.log, as every start launches its daemon. A process that only owns
1318
+ * the port, or only appears in a lock, is never chosen. */
1319
+ async function identifyLoggingDaemon(deps, check) {
1320
+ const log = resolveLifecycleFile(deps, "daemon.log");
1321
+ if (!deps.writesOutputTo)
1322
+ return { why: "this CLI can't read which file a process writes" };
1323
+ let pid;
1324
+ // The whole identity read is bounded, the body included, as stopReservedChild's is: a listener that sends its headers
1325
+ // and then stalls is no identity. At the deadline the request is aborted, so nothing it opened outlives the decision.
1326
+ const probe = new AbortController();
1327
+ let timer;
1328
+ try {
1329
+ pid = await Promise.race([
1330
+ (async () => {
1331
+ const res = await deps.fetch(check, { signal: probe.signal });
1332
+ return (await res.json?.())?.pid;
1333
+ })(),
1334
+ new Promise((_, reject) => {
1335
+ timer = setTimeout(() => {
1336
+ probe.abort(new HealthProbeTimeoutError(check));
1337
+ reject(new HealthProbeTimeoutError(check));
1338
+ }, HEALTHZ_PROBE_TIMEOUT_MS);
1339
+ }),
1340
+ ]);
1341
+ }
1342
+ catch (error) {
1343
+ return { why: `the listener at ${check} gave no readable answer (${error instanceof Error ? error.message : String(error)})` };
1344
+ }
1345
+ finally {
1346
+ if (timer)
1347
+ clearTimeout(timer);
1348
+ }
1349
+ if (!Number.isSafeInteger(pid) || pid <= 0)
1350
+ return { why: `the listener at ${check} names no PID` };
1351
+ const writes = deps.writesOutputTo(pid, log);
1352
+ if (typeof writes === "object")
1353
+ return { why: `whether PID ${pid} writes ${log} couldn't be read (${writes.failure})` };
1354
+ if (!writes)
1355
+ return { why: `the listener at ${check} is PID ${pid}, which doesn't write ${log}, so it isn't shown to be this home's daemon` };
1356
+ return { pid: pid, log };
1357
+ }
1067
1358
  export async function stopDaemon(deps) {
1068
- const state = readState(deps);
1359
+ let state = readState(deps);
1069
1360
  const configured = resolveConfiguredDaemonTarget();
1070
1361
  const explicitUrl = readOpenRigUrl();
1071
1362
  const stateUrl = state ? `http://${formatDaemonHostForUrl(state.host ?? DEFAULT_HOST)}:${state.port}` : undefined;
@@ -1083,6 +1374,8 @@ export async function stopDaemon(deps) {
1083
1374
  return isRefusedError(error) ? "refused" : "unavailable";
1084
1375
  }
1085
1376
  };
1377
+ // Set when the daemon was identified without its record (#3953): there is no state to preserve or remove.
1378
+ let identified;
1086
1379
  if (!state) {
1087
1380
  const effect = await listener();
1088
1381
  const sibling = findSiblingHome(deps);
@@ -1090,10 +1383,21 @@ export async function stopDaemon(deps) {
1090
1383
  const reserved = sibling ? undefined : await stopReservedChild(deps, { target, check, listener });
1091
1384
  if (reserved === "stopped")
1092
1385
  return reserved;
1093
- throw new Error(`Daemon state is missing — cannot stop safely. Checked ${check}; listener ${effect}.` +
1094
- (sibling ? ` Resolved home ${sibling.resolvedHome}; live sibling ${sibling.siblingHome}.` : "") +
1095
- (reserved ? ` ${reserved.refusal}` : ""));
1386
+ // #3953: no record (not an unreadable one), and no reservation stop can act on or a start in progress.
1387
+ const found = !sibling && effect === "responding" && !deps.exists(resolveLifecycleFile(deps, "daemon.json"))
1388
+ && (!reserved || reserved.olderLock) ? await identifyLoggingDaemon(deps, check) : undefined;
1389
+ if (!found || "why" in found) {
1390
+ throw new Error(`Daemon state is missing — cannot stop safely. Checked ${check}; listener ${effect}.` +
1391
+ (sibling ? ` Resolved home ${sibling.resolvedHome}; live sibling ${sibling.siblingHome}.` : "") +
1392
+ (reserved ? ` ${reserved.refusal}` : "") + (found ? ` Not identified as this home's daemon: ${found.why}; no signal sent.` : ""));
1393
+ }
1394
+ identified = found;
1395
+ const { hostname, port } = new URL(target);
1396
+ // Not a record: what this stop identified, now; the checks below run on it as on a recorded daemon.
1397
+ state = { pid: found.pid, port: Number(port) || 80, host: hostname.replace(/^\[|\]$/g, ""), db: "", startedAt: new Date().toISOString() };
1096
1398
  }
1399
+ }
1400
+ if (!state) {
1097
1401
  const stateFile = resolveLifecycleFile(deps, "daemon.json");
1098
1402
  if (deps.exists(stateFile)) {
1099
1403
  throw new Error(`Daemon target state is unreadable; drain completion unverified. Checked ${check}; listener refused; no signal sent. Inspect ${stateFile}.`);
@@ -1106,25 +1410,47 @@ export async function stopDaemon(deps) {
1106
1410
  return "no-target";
1107
1411
  }
1108
1412
  const stateFile = resolveLifecycleFile(deps, "daemon.json");
1413
+ const preserved = identified ? "no daemon.json was recorded" : "state preserved";
1109
1414
  const liveness = deps.processLiveness
1110
1415
  ? deps.processLiveness(state.pid)
1111
1416
  : deps.isProcessAlive(state.pid) ? "alive" : "dead";
1112
1417
  if (liveness === "unknown") {
1113
- throw new Error(`Cannot stop safely: PID ${state.pid} liveness is unknown; no signal sent, state preserved.`);
1418
+ throw new Error(`Cannot stop safely: PID ${state.pid} liveness is unknown; no signal sent, ${preserved}.`);
1114
1419
  }
1115
1420
  const pidState = await checkPid(state, deps, liveness);
1116
1421
  if (typeof pidState === "object") {
1117
- throw new Error(`Cannot stop safely: the identity probe was blocked (${pidState.blocked}); no signal sent, state preserved.`);
1422
+ throw new Error(`Cannot stop safely: the identity probe was blocked (${pidState.blocked}); no signal sent, ${preserved}.`);
1118
1423
  }
1119
1424
  if (pidState === "not_openrig") {
1120
- throw new Error(`Cannot stop safely: PID ${state.pid} is present but identity is not confirmed at ${check}; no signal sent, state preserved.`);
1425
+ throw new Error(`Cannot stop safely: PID ${state.pid} is present but identity is not confirmed at ${check}; no signal sent, ${preserved}.`);
1121
1426
  }
1122
1427
  let notBefore = Date.parse(state.startedAt);
1123
1428
  // Only a signalling stop names a request time: this process's clock just before kill, not delivery.
1124
1429
  let requested = "";
1125
- if (pidState !== "dead") {
1430
+ let signal = pidState !== "dead";
1431
+ // Set when the check below couldn't read: the stop goes ahead as identified, and its report says so.
1432
+ let unread = "";
1433
+ if (signal && identified) {
1434
+ // A daemon identified without its record is checked again just before the signal: its PID came from an answer a
1435
+ // moment ago, and a process given that PID since wouldn't write this home's log. That narrows the gap without
1436
+ // closing it, since nothing binds a PID to one process atomically. Only a live PID shown to write elsewhere is
1437
+ // refused: one that's gone has stopped (the judgment below reads it), and an unreadable check is no evidence of
1438
+ // another process.
1439
+ const writes = deps.writesOutputTo?.(state.pid, identified.log);
1440
+ if (writes !== true) {
1441
+ if (!deps.isProcessAlive(state.pid))
1442
+ signal = false;
1443
+ else if (writes === false) {
1444
+ throw new Error(`Cannot stop safely: PID ${state.pid} no longer shows as writing ${identified.log}; no signal sent, ${preserved}.`);
1445
+ }
1446
+ else {
1447
+ unread = `; whether it still writes ${identified.log} couldn't be read again just before the signal (${writes?.failure ?? "no probe"}), so it was signalled as identified`;
1448
+ }
1449
+ }
1450
+ }
1451
+ if (signal) {
1126
1452
  notBefore = Date.now();
1127
- requested = `; SIGTERM requested at ${new Date(notBefore).toISOString()}`;
1453
+ requested = `; SIGTERM requested at ${new Date(notBefore).toISOString()}${unread}`;
1128
1454
  deps.kill(state.pid, "SIGTERM");
1129
1455
  // One signal. An already-exited target goes straight to the same judgment.
1130
1456
  const deadline = Date.now() + DAEMON_STOP_WAIT_MS;
@@ -1137,18 +1463,21 @@ export async function stopDaemon(deps) {
1137
1463
  const observation = `targeted ${target}; checked ${check}; PID ${state.pid} ${present ? "present" : "absent"}; listener ${effect}${requested}`;
1138
1464
  if (present) {
1139
1465
  throw new Error(`Daemon did not exit after SIGTERM within ${DAEMON_STOP_WAIT_MS}ms; ${observation}` +
1140
- (effect === "responding" ? " (still listening)" : "") + "; state file preserved.");
1466
+ (effect === "responding" ? " (still listening)" : "") + `; ${identified ? preserved : "state file preserved"}.`);
1141
1467
  }
1142
1468
  if (effect !== "refused")
1143
- throw new Error(`Daemon stop verification is unverified: ${observation}; state preserved.`);
1469
+ throw new Error(`Daemon stop verification is unverified: ${observation}; ${preserved}.`);
1144
1470
  const { receipt, receiptPath } = readShutdownReceipt(deps, stateFile);
1145
1471
  if (!receiptMatchesState(receipt, state, notBefore)) {
1146
- throw new Error(`Daemon process stopped; ${observation}; drain completion unverified (no matching shutdown receipt); state preserved. Inspect ${path.join(path.dirname(stateFile), "daemon.log")}.`);
1472
+ throw new Error(`Daemon process stopped; ${observation}; drain completion unverified (no matching shutdown receipt); ${preserved}. Inspect ${path.join(path.dirname(stateFile), "daemon.log")}.`);
1147
1473
  }
1148
1474
  if (!isCleanShutdown(receipt)) {
1149
- throw new Error(`Daemon stopped with incomplete shutdown: ${receipt.outcome}; phase=${receipt.phase}; ${observation}. Pending effects are unverified; state preserved; inspect ${receiptPath}.`);
1475
+ throw new Error(`Daemon stopped with incomplete shutdown: ${receipt.outcome}; phase=${receipt.phase}; ${observation}. Pending effects are unverified; ${preserved}; inspect ${receiptPath}.`);
1150
1476
  }
1151
1477
  removeMatchingState(deps, stateFile, state);
1478
+ if (identified) {
1479
+ console.warn(`daemon.json was missing, so this stop identified the daemon: PID ${identified.pid} answered ${check} with its PID and writes ${identified.log}${unread}. It stopped cleanly; 'rig daemon start' records a new daemon.json.`);
1480
+ }
1152
1481
  return "stopped";
1153
1482
  }
1154
1483
  /** RULING 1ae863d2 — positive-down evidence classifier (lockstep with the daemon's
@@ -1208,44 +1537,23 @@ function findSiblingHome(deps) {
1208
1537
  /** T2 — read-only: the live launcher (else child) PID named by a start reservation, or undefined
1209
1538
  * when there is no reservation, it is unreadable, or every PID it names is dead. */
1210
1539
  function liveStartReservation(deps) {
1211
- try {
1212
- const file = path.join(deps.homeDir ?? OPENRIG_DIR, "daemon-start.lock");
1213
- const raw = deps.exists(file) ? deps.readFile(file) : null;
1214
- if (!raw)
1215
- return undefined;
1216
- let launcherPid;
1217
- let childPid;
1218
- let since;
1219
- for (const line of raw.split("\n")) {
1220
- if (!line.trim())
1221
- continue;
1222
- try {
1223
- const rec = JSON.parse(line);
1224
- if (typeof rec.launcherPid === "number")
1225
- launcherPid = rec.launcherPid;
1226
- if (typeof rec.childPid === "number")
1227
- childPid = rec.childPid;
1228
- if (typeof rec.startedAt === "string")
1229
- since = rec.startedAt;
1230
- }
1231
- catch {
1232
- // partial line: keep whatever parsed
1233
- }
1234
- }
1235
- for (const pid of [launcherPid, childPid]) {
1236
- if (pid === undefined)
1237
- continue;
1238
- const liveness = deps.processLiveness
1239
- ? deps.processLiveness(pid)
1240
- : deps.isProcessAlive(pid) ? "alive" : "dead";
1241
- if (liveness !== "dead")
1242
- return { pid, ...(since ? { since } : {}) };
1243
- }
1244
- }
1245
- catch {
1246
- // best-effort only: a status read must never fail on the reservation
1247
- }
1248
- return undefined;
1540
+ const reservation = pendingStartEndpoint(deps);
1541
+ return reservation && { pid: reservation.pid, ...(reservation.since ? { since: reservation.since } : {}) };
1542
+ }
1543
+ /** The same read, with the endpoint the reservation's child was launched at: start's preflight lets that child hold
1544
+ * that port, since the start then checks it against the reservation before anything else. */
1545
+ export function pendingStartEndpoint(deps) {
1546
+ const reservation = observeStartReservation({
1547
+ home: deps.homeDir ?? OPENRIG_DIR,
1548
+ bootId: deps.bootId?.(),
1549
+ readFile: (file) => deps.exists(file) ? deps.readFile(file) : null,
1550
+ processLiveness: (pid) => deps.processLiveness
1551
+ ? deps.processLiveness(pid) : deps.isProcessAlive(pid) ? "alive" : "dead",
1552
+ });
1553
+ if (!reservation || reservation.liveness === "dead" || reservation.pid === undefined)
1554
+ return undefined;
1555
+ return { pid: reservation.pid, ...(reservation.since ? { since: reservation.since } : {}),
1556
+ ...(reservation.host ? { host: reservation.host } : {}), ...(reservation.port ? { port: reservation.port } : {}) };
1249
1557
  }
1250
1558
  export async function getDaemonStatus(deps, options = {}) {
1251
1559
  // If OPENRIG_URL is set, bypass daemon.json and probe that URL directly. Commands reach