@openrig/cli 0.7.10 → 0.7.11

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 (699) hide show
  1. package/README.md +5 -5
  2. package/daemon/assets/claude-permission-policies.cjs +41 -0
  3. package/daemon/assets/claude-permission-policies.d.cts +3 -0
  4. package/daemon/assets/claude-team-permissions.cjs +13 -3
  5. package/daemon/assets/openshell/README.md +1 -1
  6. package/daemon/assets/pi-account-lock.cjs +39 -0
  7. package/daemon/assets/plugins/openrig/.claude-plugin/marketplace.json +15 -0
  8. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +32 -0
  9. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +39 -0
  10. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +6 -0
  11. package/daemon/assets/plugins/openrig/LICENSE +200 -0
  12. package/daemon/assets/plugins/openrig/README.md +106 -0
  13. package/daemon/assets/plugins/openrig/assets/logo.svg +1 -0
  14. package/daemon/assets/plugins/openrig/mcp.json +10 -0
  15. package/daemon/assets/plugins/openrig/plugin.json +14 -0
  16. package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +90 -0
  17. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  18. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  19. package/daemon/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs +20 -0
  20. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +7 -0
  21. package/daemon/assets/plugins/openrig-core/skills/openrig-skills/SKILL.md +1 -0
  22. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +24 -8
  23. package/daemon/assets/plugins/openrig-core/skills/refocusing/SKILL.md +5 -0
  24. package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +26 -4
  25. package/daemon/context-packs/help/manifest.yaml +1 -1
  26. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  27. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +72 -9
  28. package/daemon/context-packs/reference/acp-agents.md +68 -0
  29. package/daemon/context-packs/reference/getting-started.md +3 -2
  30. package/daemon/context-packs/reference/manifest.yaml +4 -1
  31. package/daemon/context-packs/reference/rig-spec.md +63 -6
  32. package/daemon/context-packs/reference/tmux-servers.md +214 -0
  33. package/daemon/context-packs/reference/whats-new.md +271 -21
  34. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/cross-host-rig-commands/SKILL.md +7 -0
  41. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/core/openrig-skills/SKILL.md +1 -0
  48. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/core/working-with-an-openrig-team/SKILL.md +90 -0
  58. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +10 -0
  59. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/openrig-user/SKILL.md +24 -8
  65. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  78. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  79. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  83. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  84. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  85. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  86. package/daemon/context-packs/skills/refocusing/SKILL.md +5 -0
  87. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  88. package/daemon/context-packs/skills/refocusing/scripts/trace-to-root.py +26 -4
  89. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  90. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  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 +3 -1
  96. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  97. package/daemon/dist/adapters/claude-code-adapter.js +41 -12
  98. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  99. package/daemon/dist/adapters/claude-resume.d.ts +1 -1
  100. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  101. package/daemon/dist/adapters/claude-resume.js +17 -3
  102. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  103. package/daemon/dist/adapters/codex-resume.d.ts +1 -1
  104. package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
  105. package/daemon/dist/adapters/codex-resume.js +6 -2
  106. package/daemon/dist/adapters/codex-resume.js.map +1 -1
  107. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +2 -0
  108. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  109. package/daemon/dist/adapters/codex-runtime-adapter.js +36 -11
  110. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  111. package/daemon/dist/adapters/kernel-authority.d.ts +2 -4
  112. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  113. package/daemon/dist/adapters/kernel-authority.js +10 -41
  114. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  115. package/daemon/dist/adapters/openshell-podman-observer.d.ts.map +1 -1
  116. package/daemon/dist/adapters/openshell-podman-observer.js +5 -3
  117. package/daemon/dist/adapters/openshell-podman-observer.js.map +1 -1
  118. package/daemon/dist/adapters/pi-resume.d.ts +4 -1
  119. package/daemon/dist/adapters/pi-resume.d.ts.map +1 -1
  120. package/daemon/dist/adapters/pi-resume.js +38 -9
  121. package/daemon/dist/adapters/pi-resume.js.map +1 -1
  122. package/daemon/dist/adapters/pi-runner-protocol.d.ts +4 -0
  123. package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -1
  124. package/daemon/dist/adapters/pi-runner-protocol.js +7 -0
  125. package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -1
  126. package/daemon/dist/adapters/pi-runner.d.ts +5 -0
  127. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  128. package/daemon/dist/adapters/pi-runner.js +79 -8
  129. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  130. package/daemon/dist/adapters/pi-runtime-adapter.d.ts +6 -0
  131. package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -1
  132. package/daemon/dist/adapters/pi-runtime-adapter.js +58 -23
  133. package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -1
  134. package/daemon/dist/adapters/tmux-control.d.ts +32 -1
  135. package/daemon/dist/adapters/tmux-control.d.ts.map +1 -1
  136. package/daemon/dist/adapters/tmux-control.js +149 -9
  137. package/daemon/dist/adapters/tmux-control.js.map +1 -1
  138. package/daemon/dist/adapters/tmux-server.d.ts +9 -0
  139. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  140. package/daemon/dist/adapters/tmux-server.js +12 -0
  141. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  142. package/daemon/dist/adapters/tmux.d.ts +18 -0
  143. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  144. package/daemon/dist/adapters/tmux.js +164 -12
  145. package/daemon/dist/adapters/tmux.js.map +1 -1
  146. package/daemon/dist/build-info.js +3 -3
  147. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  148. package/daemon/dist/db/all-migrations.js +10 -0
  149. package/daemon/dist/db/all-migrations.js.map +1 -1
  150. package/daemon/dist/db/migrations/150_node_launch_wrapper.d.ts +3 -0
  151. package/daemon/dist/db/migrations/150_node_launch_wrapper.d.ts.map +1 -0
  152. package/daemon/dist/db/migrations/150_node_launch_wrapper.js +5 -0
  153. package/daemon/dist/db/migrations/150_node_launch_wrapper.js.map +1 -0
  154. package/daemon/dist/db/migrations/151_pi_account_switches.d.ts +4 -0
  155. package/daemon/dist/db/migrations/151_pi_account_switches.d.ts.map +1 -0
  156. package/daemon/dist/db/migrations/151_pi_account_switches.js +44 -0
  157. package/daemon/dist/db/migrations/151_pi_account_switches.js.map +1 -0
  158. package/daemon/dist/db/migrations/152_workflow_instance_spec.d.ts +8 -0
  159. package/daemon/dist/db/migrations/152_workflow_instance_spec.d.ts.map +1 -0
  160. package/daemon/dist/db/migrations/152_workflow_instance_spec.js +13 -0
  161. package/daemon/dist/db/migrations/152_workflow_instance_spec.js.map +1 -0
  162. package/daemon/dist/db/migrations/153_events_retention_marks.d.ts +7 -0
  163. package/daemon/dist/db/migrations/153_events_retention_marks.d.ts.map +1 -0
  164. package/daemon/dist/db/migrations/153_events_retention_marks.js +17 -0
  165. package/daemon/dist/db/migrations/153_events_retention_marks.js.map +1 -0
  166. package/daemon/dist/db/migrations/154_workflow_instance_root_objective.d.ts +7 -0
  167. package/daemon/dist/db/migrations/154_workflow_instance_root_objective.d.ts.map +1 -0
  168. package/daemon/dist/db/migrations/154_workflow_instance_root_objective.js +11 -0
  169. package/daemon/dist/db/migrations/154_workflow_instance_root_objective.js.map +1 -0
  170. package/daemon/dist/domain/activity-taxonomy.d.ts +9 -0
  171. package/daemon/dist/domain/activity-taxonomy.d.ts.map +1 -1
  172. package/daemon/dist/domain/activity-taxonomy.js.map +1 -1
  173. package/daemon/dist/domain/agent-manifest.d.ts.map +1 -1
  174. package/daemon/dist/domain/agent-manifest.js +11 -1
  175. package/daemon/dist/domain/agent-manifest.js.map +1 -1
  176. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +43 -3
  177. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  178. package/daemon/dist/domain/claude-compaction-enforcer.js +306 -22
  179. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  180. package/daemon/dist/domain/claude-managed-launch.d.ts +2 -0
  181. package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
  182. package/daemon/dist/domain/claude-managed-launch.js +12 -2
  183. package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
  184. package/daemon/dist/domain/context-monitor.d.ts.map +1 -1
  185. package/daemon/dist/domain/context-monitor.js +3 -0
  186. package/daemon/dist/domain/context-monitor.js.map +1 -1
  187. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  188. package/daemon/dist/domain/context-usage-store.js +10 -1
  189. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  190. package/daemon/dist/domain/desired-claude-activity-hooks.d.ts +4 -3
  191. package/daemon/dist/domain/desired-claude-activity-hooks.d.ts.map +1 -1
  192. package/daemon/dist/domain/desired-claude-activity-hooks.js +49 -15
  193. package/daemon/dist/domain/desired-claude-activity-hooks.js.map +1 -1
  194. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
  195. package/daemon/dist/domain/draft-aware-delivery.js +5 -1
  196. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  197. package/daemon/dist/domain/event-bus.d.ts +31 -0
  198. package/daemon/dist/domain/event-bus.d.ts.map +1 -1
  199. package/daemon/dist/domain/event-bus.js +87 -1
  200. package/daemon/dist/domain/event-bus.js.map +1 -1
  201. package/daemon/dist/domain/execution-view.d.ts +9 -0
  202. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  203. package/daemon/dist/domain/execution-view.js +13 -0
  204. package/daemon/dist/domain/execution-view.js.map +1 -1
  205. package/daemon/dist/domain/gateway/connections-projection.d.ts +13 -1
  206. package/daemon/dist/domain/gateway/connections-projection.d.ts.map +1 -1
  207. package/daemon/dist/domain/gateway/connections-projection.js +38 -10
  208. package/daemon/dist/domain/gateway/connections-projection.js.map +1 -1
  209. package/daemon/dist/domain/gateway/dispatcher.d.ts +2 -0
  210. package/daemon/dist/domain/gateway/dispatcher.d.ts.map +1 -1
  211. package/daemon/dist/domain/gateway/dispatcher.js +14 -1
  212. package/daemon/dist/domain/gateway/dispatcher.js.map +1 -1
  213. package/daemon/dist/domain/gateway/gateway-subsystem.d.ts +2 -0
  214. package/daemon/dist/domain/gateway/gateway-subsystem.d.ts.map +1 -1
  215. package/daemon/dist/domain/gateway/gateway-subsystem.js +1 -0
  216. package/daemon/dist/domain/gateway/gateway-subsystem.js.map +1 -1
  217. package/daemon/dist/domain/gateway/human-readiness.d.ts +7 -0
  218. package/daemon/dist/domain/gateway/human-readiness.d.ts.map +1 -1
  219. package/daemon/dist/domain/gateway/human-readiness.js +45 -0
  220. package/daemon/dist/domain/gateway/human-readiness.js.map +1 -1
  221. package/daemon/dist/domain/gateway/human-registry.d.ts +23 -3
  222. package/daemon/dist/domain/gateway/human-registry.d.ts.map +1 -1
  223. package/daemon/dist/domain/gateway/human-registry.js +66 -34
  224. package/daemon/dist/domain/gateway/human-registry.js.map +1 -1
  225. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
  226. package/daemon/dist/domain/gateway/operator-delivery-engine.js +8 -2
  227. package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
  228. package/daemon/dist/domain/gateway/relay-config.d.ts +80 -0
  229. package/daemon/dist/domain/gateway/relay-config.d.ts.map +1 -0
  230. package/daemon/dist/domain/gateway/relay-config.js +290 -0
  231. package/daemon/dist/domain/gateway/relay-config.js.map +1 -0
  232. package/daemon/dist/domain/gateway/relay-inbound.d.ts +74 -0
  233. package/daemon/dist/domain/gateway/relay-inbound.d.ts.map +1 -0
  234. package/daemon/dist/domain/gateway/relay-inbound.js +739 -0
  235. package/daemon/dist/domain/gateway/relay-inbound.js.map +1 -0
  236. package/daemon/dist/domain/gateway/relay-outbound.d.ts +215 -0
  237. package/daemon/dist/domain/gateway/relay-outbound.d.ts.map +1 -0
  238. package/daemon/dist/domain/gateway/relay-outbound.js +770 -0
  239. package/daemon/dist/domain/gateway/relay-outbound.js.map +1 -0
  240. package/daemon/dist/domain/gateway/slack/open-asks.d.ts.map +1 -1
  241. package/daemon/dist/domain/gateway/slack/open-asks.js +14 -1
  242. package/daemon/dist/domain/gateway/slack/open-asks.js.map +1 -1
  243. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
  244. package/daemon/dist/domain/gateway/slack/slack-subsystem.js +224 -32
  245. package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
  246. package/daemon/dist/domain/hosts/pairing-ask.d.ts +10 -0
  247. package/daemon/dist/domain/hosts/pairing-ask.d.ts.map +1 -0
  248. package/daemon/dist/domain/hosts/pairing-ask.js +9 -0
  249. package/daemon/dist/domain/hosts/pairing-ask.js.map +1 -0
  250. package/daemon/dist/domain/launch-wrapper.d.ts +28 -0
  251. package/daemon/dist/domain/launch-wrapper.d.ts.map +1 -0
  252. package/daemon/dist/domain/launch-wrapper.js +93 -0
  253. package/daemon/dist/domain/launch-wrapper.js.map +1 -0
  254. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +1 -1
  255. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  256. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +85 -28
  257. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  258. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts.map +1 -1
  259. package/daemon/dist/domain/model-divergence/current-model-reader.js +14 -3
  260. package/daemon/dist/domain/model-divergence/current-model-reader.js.map +1 -1
  261. package/daemon/dist/domain/native-process-lineage.d.ts.map +1 -1
  262. package/daemon/dist/domain/native-process-lineage.js +32 -9
  263. package/daemon/dist/domain/native-process-lineage.js.map +1 -1
  264. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  265. package/daemon/dist/domain/node-inventory.js +7 -0
  266. package/daemon/dist/domain/node-inventory.js.map +1 -1
  267. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  268. package/daemon/dist/domain/node-launcher.js +9 -2
  269. package/daemon/dist/domain/node-launcher.js.map +1 -1
  270. package/daemon/dist/domain/outbox-handler.d.ts +53 -3
  271. package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
  272. package/daemon/dist/domain/outbox-handler.js +101 -6
  273. package/daemon/dist/domain/outbox-handler.js.map +1 -1
  274. package/daemon/dist/domain/parent-session-env.d.ts +2 -1
  275. package/daemon/dist/domain/parent-session-env.d.ts.map +1 -1
  276. package/daemon/dist/domain/parent-session-env.js +9 -1
  277. package/daemon/dist/domain/parent-session-env.js.map +1 -1
  278. package/daemon/dist/domain/parked-query.d.ts +6 -0
  279. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  280. package/daemon/dist/domain/parked-query.js +1 -0
  281. package/daemon/dist/domain/parked-query.js.map +1 -1
  282. package/daemon/dist/domain/pi-account-state.d.ts +6 -0
  283. package/daemon/dist/domain/pi-account-state.d.ts.map +1 -0
  284. package/daemon/dist/domain/pi-account-state.js +14 -0
  285. package/daemon/dist/domain/pi-account-state.js.map +1 -0
  286. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +6 -0
  287. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
  288. package/daemon/dist/domain/policies/parked-owner-consumer.js +10 -1
  289. package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
  290. package/daemon/dist/domain/policies/quiet-release.d.ts.map +1 -1
  291. package/daemon/dist/domain/policies/quiet-release.js +6 -3
  292. package/daemon/dist/domain/policies/quiet-release.js.map +1 -1
  293. package/daemon/dist/domain/projection-planner.d.ts +4 -1
  294. package/daemon/dist/domain/projection-planner.d.ts.map +1 -1
  295. package/daemon/dist/domain/projection-planner.js +3 -0
  296. package/daemon/dist/domain/projection-planner.js.map +1 -1
  297. package/daemon/dist/domain/queue-pickup.d.ts +20 -1
  298. package/daemon/dist/domain/queue-pickup.d.ts.map +1 -1
  299. package/daemon/dist/domain/queue-pickup.js +38 -6
  300. package/daemon/dist/domain/queue-pickup.js.map +1 -1
  301. package/daemon/dist/domain/queue-recovery.d.ts +14 -0
  302. package/daemon/dist/domain/queue-recovery.d.ts.map +1 -1
  303. package/daemon/dist/domain/queue-recovery.js +33 -1
  304. package/daemon/dist/domain/queue-recovery.js.map +1 -1
  305. package/daemon/dist/domain/queue-repository.d.ts +76 -10
  306. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  307. package/daemon/dist/domain/queue-repository.js +351 -44
  308. package/daemon/dist/domain/queue-repository.js.map +1 -1
  309. package/daemon/dist/domain/queue-retention.d.ts +68 -0
  310. package/daemon/dist/domain/queue-retention.d.ts.map +1 -1
  311. package/daemon/dist/domain/queue-retention.js +133 -0
  312. package/daemon/dist/domain/queue-retention.js.map +1 -1
  313. package/daemon/dist/domain/queue-stuck-sweep.d.ts +22 -1
  314. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  315. package/daemon/dist/domain/queue-stuck-sweep.js +577 -158
  316. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  317. package/daemon/dist/domain/queue-transition-log.d.ts +49 -1
  318. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  319. package/daemon/dist/domain/queue-transition-log.js +216 -3
  320. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  321. package/daemon/dist/domain/queue-waiting.d.ts +1 -1
  322. package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
  323. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  324. package/daemon/dist/domain/queue-wake-ladder.js +7 -2
  325. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  326. package/daemon/dist/domain/quiet-hold-custody.d.ts.map +1 -1
  327. package/daemon/dist/domain/quiet-hold-custody.js +7 -3
  328. package/daemon/dist/domain/quiet-hold-custody.js.map +1 -1
  329. package/daemon/dist/domain/restore-orchestrator.d.ts +13 -2
  330. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  331. package/daemon/dist/domain/restore-orchestrator.js +63 -26
  332. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  333. package/daemon/dist/domain/rig-repository.d.ts +3 -0
  334. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  335. package/daemon/dist/domain/rig-repository.js +46 -1
  336. package/daemon/dist/domain/rig-repository.js.map +1 -1
  337. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  338. package/daemon/dist/domain/rigspec-codec.js +4 -0
  339. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  340. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  341. package/daemon/dist/domain/rigspec-exporter.js +5 -0
  342. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  343. package/daemon/dist/domain/rigspec-instantiator.d.ts +17 -1
  344. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  345. package/daemon/dist/domain/rigspec-instantiator.js +68 -20
  346. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  347. package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
  348. package/daemon/dist/domain/rigspec-preflight.js +10 -0
  349. package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
  350. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  351. package/daemon/dist/domain/rigspec-schema.js +26 -1
  352. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  353. package/daemon/dist/domain/runtime-adapter.d.ts +1 -0
  354. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  355. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  356. package/daemon/dist/domain/runtime-switch-materials.d.ts +1 -1
  357. package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -1
  358. package/daemon/dist/domain/runtime-switch-materials.js +2 -2
  359. package/daemon/dist/domain/runtime-switch-materials.js.map +1 -1
  360. package/daemon/dist/domain/seat-activity-service.d.ts +38 -1
  361. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  362. package/daemon/dist/domain/seat-activity-service.js +59 -1
  363. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  364. package/daemon/dist/domain/seat-attention-reconciler.d.ts +13 -0
  365. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  366. package/daemon/dist/domain/seat-attention-reconciler.js +45 -1
  367. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  368. package/daemon/dist/domain/seat-handover-service.d.ts +1 -0
  369. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  370. package/daemon/dist/domain/seat-handover-service.js +38 -11
  371. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  372. package/daemon/dist/domain/seat-launch-environment.d.ts +10 -0
  373. package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
  374. package/daemon/dist/domain/seat-launch-environment.js +62 -15
  375. package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
  376. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  377. package/daemon/dist/domain/seat-lifecycle-service.js +7 -3
  378. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  379. package/daemon/dist/domain/seat-restart-in-place.d.ts +2 -1
  380. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  381. package/daemon/dist/domain/seat-restart-in-place.js +19 -1
  382. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  383. package/daemon/dist/domain/seat-runtime-home.d.ts +4 -1
  384. package/daemon/dist/domain/seat-runtime-home.d.ts.map +1 -1
  385. package/daemon/dist/domain/seat-runtime-home.js +6 -4
  386. package/daemon/dist/domain/seat-runtime-home.js.map +1 -1
  387. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  388. package/daemon/dist/domain/seat-runtime-switch-service.js +73 -10
  389. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  390. package/daemon/dist/domain/seat-skill-storage.d.ts +57 -4
  391. package/daemon/dist/domain/seat-skill-storage.d.ts.map +1 -1
  392. package/daemon/dist/domain/seat-skill-storage.js +338 -8
  393. package/daemon/dist/domain/seat-skill-storage.js.map +1 -1
  394. package/daemon/dist/domain/seat-status-service.d.ts +2 -2
  395. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  396. package/daemon/dist/domain/seat-status-service.js +3 -2
  397. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  398. package/daemon/dist/domain/self-attach-service.d.ts.map +1 -1
  399. package/daemon/dist/domain/self-attach-service.js +11 -4
  400. package/daemon/dist/domain/self-attach-service.js.map +1 -1
  401. package/daemon/dist/domain/session-transport.d.ts +25 -2
  402. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  403. package/daemon/dist/domain/session-transport.js +199 -30
  404. package/daemon/dist/domain/session-transport.js.map +1 -1
  405. package/daemon/dist/domain/skill-catalog.d.ts +37 -0
  406. package/daemon/dist/domain/skill-catalog.d.ts.map +1 -1
  407. package/daemon/dist/domain/skill-catalog.js +152 -3
  408. package/daemon/dist/domain/skill-catalog.js.map +1 -1
  409. package/daemon/dist/domain/slices/slice-detail-projector.d.ts +1 -1
  410. package/daemon/dist/domain/slices/slice-detail-projector.d.ts.map +1 -1
  411. package/daemon/dist/domain/slices/slice-detail-projector.js +11 -13
  412. package/daemon/dist/domain/slices/slice-detail-projector.js.map +1 -1
  413. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  414. package/daemon/dist/domain/startup-orchestrator.js +7 -1
  415. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  416. package/daemon/dist/domain/successor-session-launcher.d.ts +1 -0
  417. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  418. package/daemon/dist/domain/successor-session-launcher.js +1 -0
  419. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  420. package/daemon/dist/domain/terminal/earlier-tile-attach-0711.d.ts +2 -0
  421. package/daemon/dist/domain/terminal/earlier-tile-attach-0711.d.ts.map +1 -0
  422. package/daemon/dist/domain/terminal/earlier-tile-attach-0711.js +146 -0
  423. package/daemon/dist/domain/terminal/earlier-tile-attach-0711.js.map +1 -0
  424. package/daemon/dist/domain/terminal/earlier-tile-attach.d.ts +1 -0
  425. package/daemon/dist/domain/terminal/earlier-tile-attach.d.ts.map +1 -1
  426. package/daemon/dist/domain/terminal/earlier-tile-attach.js +42 -1
  427. package/daemon/dist/domain/terminal/earlier-tile-attach.js.map +1 -1
  428. package/daemon/dist/domain/terminal/herdr-follow-view.d.ts.map +1 -1
  429. package/daemon/dist/domain/terminal/herdr-follow-view.js +43 -19
  430. package/daemon/dist/domain/terminal/herdr-follow-view.js.map +1 -1
  431. package/daemon/dist/domain/terminal/herdr-viewer.d.ts +7 -4
  432. package/daemon/dist/domain/terminal/herdr-viewer.d.ts.map +1 -1
  433. package/daemon/dist/domain/terminal/herdr-viewer.js +101 -47
  434. package/daemon/dist/domain/terminal/herdr-viewer.js.map +1 -1
  435. package/daemon/dist/domain/terminal/terminal-following.js +3 -3
  436. package/daemon/dist/domain/terminal/terminal-following.js.map +1 -1
  437. package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
  438. package/daemon/dist/domain/terminal/terminal-service.js +16 -1
  439. package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
  440. package/daemon/dist/domain/terminal/tile-attach.d.ts +6 -3
  441. package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -1
  442. package/daemon/dist/domain/terminal/tile-attach.js +11 -46
  443. package/daemon/dist/domain/terminal/tile-attach.js.map +1 -1
  444. package/daemon/dist/domain/tmux-server-selection.d.ts.map +1 -1
  445. package/daemon/dist/domain/tmux-server-selection.js +8 -2
  446. package/daemon/dist/domain/tmux-server-selection.js.map +1 -1
  447. package/daemon/dist/domain/types.d.ts +18 -1
  448. package/daemon/dist/domain/types.d.ts.map +1 -1
  449. package/daemon/dist/domain/types.js.map +1 -1
  450. package/daemon/dist/domain/user-settings/settings-store.d.ts +1 -1
  451. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  452. package/daemon/dist/domain/user-settings/settings-store.js +48 -0
  453. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  454. package/daemon/dist/domain/view-event-bridge.js +1 -1
  455. package/daemon/dist/domain/view-event-bridge.js.map +1 -1
  456. package/daemon/dist/domain/view-projector.d.ts +4 -1
  457. package/daemon/dist/domain/view-projector.d.ts.map +1 -1
  458. package/daemon/dist/domain/view-projector.js +9 -4
  459. package/daemon/dist/domain/view-projector.js.map +1 -1
  460. package/daemon/dist/domain/wake-recovery.d.ts.map +1 -1
  461. package/daemon/dist/domain/wake-recovery.js +9 -2
  462. package/daemon/dist/domain/wake-recovery.js.map +1 -1
  463. package/daemon/dist/domain/workflow-exception-escalation.d.ts +3 -2
  464. package/daemon/dist/domain/workflow-exception-escalation.d.ts.map +1 -1
  465. package/daemon/dist/domain/workflow-exception-escalation.js +1 -1
  466. package/daemon/dist/domain/workflow-exception-escalation.js.map +1 -1
  467. package/daemon/dist/domain/workflow-instance-store.d.ts +8 -1
  468. package/daemon/dist/domain/workflow-instance-store.d.ts.map +1 -1
  469. package/daemon/dist/domain/workflow-instance-store.js +21 -3
  470. package/daemon/dist/domain/workflow-instance-store.js.map +1 -1
  471. package/daemon/dist/domain/workflow-reconciliation.d.ts.map +1 -1
  472. package/daemon/dist/domain/workflow-reconciliation.js +2 -1
  473. package/daemon/dist/domain/workflow-reconciliation.js.map +1 -1
  474. package/daemon/dist/domain/workflow-runtime.d.ts +4 -1
  475. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  476. package/daemon/dist/domain/workflow-runtime.js +20 -7
  477. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  478. package/daemon/dist/domain/workflow-spec-cache.d.ts +24 -4
  479. package/daemon/dist/domain/workflow-spec-cache.d.ts.map +1 -1
  480. package/daemon/dist/domain/workflow-spec-cache.js +87 -7
  481. package/daemon/dist/domain/workflow-spec-cache.js.map +1 -1
  482. package/daemon/dist/domain/workflow-spec-unregister.d.ts +36 -0
  483. package/daemon/dist/domain/workflow-spec-unregister.d.ts.map +1 -0
  484. package/daemon/dist/domain/workflow-spec-unregister.js +105 -0
  485. package/daemon/dist/domain/workflow-spec-unregister.js.map +1 -0
  486. package/daemon/dist/domain/workflow-types.d.ts +14 -0
  487. package/daemon/dist/domain/workflow-types.d.ts.map +1 -1
  488. package/daemon/dist/index.d.ts +2 -1
  489. package/daemon/dist/index.d.ts.map +1 -1
  490. package/daemon/dist/index.js +23 -5
  491. package/daemon/dist/index.js.map +1 -1
  492. package/daemon/dist/learned-host-bindings-surface.d.ts +2 -0
  493. package/daemon/dist/learned-host-bindings-surface.d.ts.map +1 -0
  494. package/daemon/dist/learned-host-bindings-surface.js +4 -0
  495. package/daemon/dist/learned-host-bindings-surface.js.map +1 -0
  496. package/daemon/dist/routes/activity.d.ts.map +1 -1
  497. package/daemon/dist/routes/activity.js +37 -2
  498. package/daemon/dist/routes/activity.js.map +1 -1
  499. package/daemon/dist/routes/adapters.d.ts.map +1 -1
  500. package/daemon/dist/routes/adapters.js +4 -0
  501. package/daemon/dist/routes/adapters.js.map +1 -1
  502. package/daemon/dist/routes/compaction.js +2 -0
  503. package/daemon/dist/routes/compaction.js.map +1 -1
  504. package/daemon/dist/routes/events.js +4 -0
  505. package/daemon/dist/routes/events.js.map +1 -1
  506. package/daemon/dist/routes/gateway.d.ts +3 -0
  507. package/daemon/dist/routes/gateway.d.ts.map +1 -1
  508. package/daemon/dist/routes/gateway.js +58 -8
  509. package/daemon/dist/routes/gateway.js.map +1 -1
  510. package/daemon/dist/routes/hosts.d.ts.map +1 -1
  511. package/daemon/dist/routes/hosts.js +298 -35
  512. package/daemon/dist/routes/hosts.js.map +1 -1
  513. package/daemon/dist/routes/queue.d.ts.map +1 -1
  514. package/daemon/dist/routes/queue.js +10 -3
  515. package/daemon/dist/routes/queue.js.map +1 -1
  516. package/daemon/dist/routes/seat.d.ts.map +1 -1
  517. package/daemon/dist/routes/seat.js +4 -3
  518. package/daemon/dist/routes/seat.js.map +1 -1
  519. package/daemon/dist/routes/terminal-ws.d.ts +1 -0
  520. package/daemon/dist/routes/terminal-ws.d.ts.map +1 -1
  521. package/daemon/dist/routes/terminal-ws.js +1 -1
  522. package/daemon/dist/routes/terminal-ws.js.map +1 -1
  523. package/daemon/dist/routes/workflow.d.ts.map +1 -1
  524. package/daemon/dist/routes/workflow.js +24 -0
  525. package/daemon/dist/routes/workflow.js.map +1 -1
  526. package/daemon/dist/server.d.ts +2 -0
  527. package/daemon/dist/server.d.ts.map +1 -1
  528. package/daemon/dist/server.js +7 -2
  529. package/daemon/dist/server.js.map +1 -1
  530. package/daemon/dist/startup.d.ts.map +1 -1
  531. package/daemon/dist/startup.js +65 -15
  532. package/daemon/dist/startup.js.map +1 -1
  533. package/daemon/dist/terminal/TerminalSessionBroker.d.ts +18 -13
  534. package/daemon/dist/terminal/TerminalSessionBroker.d.ts.map +1 -1
  535. package/daemon/dist/terminal/TerminalSessionBroker.js +113 -76
  536. package/daemon/dist/terminal/TerminalSessionBroker.js.map +1 -1
  537. package/daemon/dist/terminal/window-pin.d.ts +3 -3
  538. package/daemon/dist/terminal/window-pin.d.ts.map +1 -1
  539. package/daemon/dist/terminal/window-pin.js +2 -2
  540. package/daemon/dist/terminal/window-pin.js.map +1 -1
  541. package/daemon/docs/reference/acp-agents.md +68 -0
  542. package/daemon/docs/reference/agent-spec.md +53 -1
  543. package/daemon/docs/reference/agent-startup-guide.md +28 -0
  544. package/daemon/docs/reference/agent-state-taxonomy.md +7 -0
  545. package/daemon/docs/reference/daemon-http-clients.md +16 -7
  546. package/daemon/docs/reference/gateway-participants.md +4 -1
  547. package/daemon/docs/reference/gateway-relay.md +239 -0
  548. package/daemon/docs/reference/getting-started.md +3 -2
  549. package/daemon/docs/reference/hosted-members.md +38 -1
  550. package/daemon/docs/reference/project-workspace.md +4 -0
  551. package/daemon/docs/reference/quickstart.md +1 -1
  552. package/daemon/docs/reference/reconstructions.md +90 -0
  553. package/daemon/docs/reference/rig-spec.md +63 -6
  554. package/daemon/docs/reference/seat-delivery.md +20 -0
  555. package/daemon/docs/reference/terminal-sessions.md +88 -26
  556. package/daemon/docs/reference/tmux-servers.md +48 -0
  557. package/daemon/docs/reference/whats-new.md +271 -21
  558. package/daemon/specs/agents/shared/skills/core/cross-host-rig-commands/SKILL.md +7 -0
  559. package/daemon/specs/agents/shared/skills/core/openrig-skills/SKILL.md +1 -0
  560. package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +90 -0
  561. package/dist/acp/agent-server.d.ts +126 -0
  562. package/dist/acp/agent-server.d.ts.map +1 -0
  563. package/dist/acp/agent-server.js +449 -0
  564. package/dist/acp/agent-server.js.map +1 -0
  565. package/dist/acp/json-rpc-stdio.d.ts +24 -10
  566. package/dist/acp/json-rpc-stdio.d.ts.map +1 -1
  567. package/dist/acp/json-rpc-stdio.js +58 -36
  568. package/dist/acp/json-rpc-stdio.js.map +1 -1
  569. package/dist/bin-wrapper.d.ts.map +1 -1
  570. package/dist/bin-wrapper.js +3 -1
  571. package/dist/bin-wrapper.js.map +1 -1
  572. package/dist/build-info.js +3 -3
  573. package/dist/client.d.ts +4 -0
  574. package/dist/client.d.ts.map +1 -1
  575. package/dist/client.js +7 -0
  576. package/dist/client.js.map +1 -1
  577. package/dist/commands/acp.d.ts +14 -0
  578. package/dist/commands/acp.d.ts.map +1 -1
  579. package/dist/commands/acp.js +189 -2
  580. package/dist/commands/acp.js.map +1 -1
  581. package/dist/commands/attach.js +1 -1
  582. package/dist/commands/attach.js.map +1 -1
  583. package/dist/commands/capture.js +6 -6
  584. package/dist/commands/capture.js.map +1 -1
  585. package/dist/commands/compact.d.ts.map +1 -1
  586. package/dist/commands/compact.js +14 -2
  587. package/dist/commands/compact.js.map +1 -1
  588. package/dist/commands/config.d.ts.map +1 -1
  589. package/dist/commands/config.js +35 -6
  590. package/dist/commands/config.js.map +1 -1
  591. package/dist/commands/context-reconstruction.d.ts +5 -0
  592. package/dist/commands/context-reconstruction.d.ts.map +1 -0
  593. package/dist/commands/context-reconstruction.js +69 -0
  594. package/dist/commands/context-reconstruction.js.map +1 -0
  595. package/dist/commands/context.d.ts.map +1 -1
  596. package/dist/commands/context.js +2 -0
  597. package/dist/commands/context.js.map +1 -1
  598. package/dist/commands/daemon.d.ts.map +1 -1
  599. package/dist/commands/daemon.js +5 -2
  600. package/dist/commands/daemon.js.map +1 -1
  601. package/dist/commands/doctor.d.ts.map +1 -1
  602. package/dist/commands/doctor.js +61 -0
  603. package/dist/commands/doctor.js.map +1 -1
  604. package/dist/commands/gateway.d.ts.map +1 -1
  605. package/dist/commands/gateway.js +15 -7
  606. package/dist/commands/gateway.js.map +1 -1
  607. package/dist/commands/host.d.ts.map +1 -1
  608. package/dist/commands/host.js +59 -12
  609. package/dist/commands/host.js.map +1 -1
  610. package/dist/commands/mcp.d.ts.map +1 -1
  611. package/dist/commands/mcp.js +29 -5
  612. package/dist/commands/mcp.js.map +1 -1
  613. package/dist/commands/provider.d.ts.map +1 -1
  614. package/dist/commands/provider.js +4 -1
  615. package/dist/commands/provider.js.map +1 -1
  616. package/dist/commands/ps.d.ts +2 -0
  617. package/dist/commands/ps.d.ts.map +1 -1
  618. package/dist/commands/ps.js +3 -1
  619. package/dist/commands/ps.js.map +1 -1
  620. package/dist/commands/queue.d.ts +3 -0
  621. package/dist/commands/queue.d.ts.map +1 -1
  622. package/dist/commands/queue.js +203 -67
  623. package/dist/commands/queue.js.map +1 -1
  624. package/dist/commands/seat.d.ts.map +1 -1
  625. package/dist/commands/seat.js +15 -3
  626. package/dist/commands/seat.js.map +1 -1
  627. package/dist/commands/stream.d.ts.map +1 -1
  628. package/dist/commands/stream.js +24 -1
  629. package/dist/commands/stream.js.map +1 -1
  630. package/dist/commands/terminal.js +1 -1
  631. package/dist/commands/workflow-render.d.ts +4 -0
  632. package/dist/commands/workflow-render.d.ts.map +1 -1
  633. package/dist/commands/workflow-render.js +7 -0
  634. package/dist/commands/workflow-render.js.map +1 -1
  635. package/dist/commands/workflow.d.ts.map +1 -1
  636. package/dist/commands/workflow.js +69 -1
  637. package/dist/commands/workflow.js.map +1 -1
  638. package/dist/config-store.d.ts +8 -1
  639. package/dist/config-store.d.ts.map +1 -1
  640. package/dist/config-store.js +52 -1
  641. package/dist/config-store.js.map +1 -1
  642. package/dist/daemon-lifecycle.d.ts +2 -0
  643. package/dist/daemon-lifecycle.d.ts.map +1 -1
  644. package/dist/daemon-lifecycle.js +38 -5
  645. package/dist/daemon-lifecycle.js.map +1 -1
  646. package/dist/daemon-reachability.d.ts +1 -1
  647. package/dist/daemon-reachability.d.ts.map +1 -1
  648. package/dist/daemon-reachability.js +4 -2
  649. package/dist/daemon-reachability.js.map +1 -1
  650. package/dist/lib/reconstruction-reader.d.ts +122 -0
  651. package/dist/lib/reconstruction-reader.d.ts.map +1 -0
  652. package/dist/lib/reconstruction-reader.js +481 -0
  653. package/dist/lib/reconstruction-reader.js.map +1 -0
  654. package/dist/lib/work-install.d.ts +28 -0
  655. package/dist/lib/work-install.d.ts.map +1 -1
  656. package/dist/lib/work-install.js +80 -20
  657. package/dist/lib/work-install.js.map +1 -1
  658. package/dist/mcp-http.d.ts +7 -0
  659. package/dist/mcp-http.d.ts.map +1 -1
  660. package/dist/mcp-http.js +30 -6
  661. package/dist/mcp-http.js.map +1 -1
  662. package/dist/mcp-server.d.ts +33 -3
  663. package/dist/mcp-server.d.ts.map +1 -1
  664. package/dist/mcp-server.js +443 -52
  665. package/dist/mcp-server.js.map +1 -1
  666. package/dist/queue-artifact.d.ts +57 -0
  667. package/dist/queue-artifact.d.ts.map +1 -0
  668. package/dist/queue-artifact.js +70 -0
  669. package/dist/queue-artifact.js.map +1 -0
  670. package/dist/queue-receipt.d.ts.map +1 -1
  671. package/dist/queue-receipt.js +4 -3
  672. package/dist/queue-receipt.js.map +1 -1
  673. package/dist/system-preflight.d.ts.map +1 -1
  674. package/dist/system-preflight.js +15 -7
  675. package/dist/system-preflight.js.map +1 -1
  676. package/dist/terminal-window.d.ts.map +1 -1
  677. package/dist/terminal-window.js +13 -10
  678. package/dist/terminal-window.js.map +1 -1
  679. package/package.json +1 -1
  680. package/tui/dist/attention/attention-model.d.ts +2 -1
  681. package/tui/dist/attention/attention-model.d.ts.map +1 -1
  682. package/tui/dist/attention/attention-model.js +18 -4
  683. package/tui/dist/attention/attention-model.js.map +1 -1
  684. package/tui/dist/config/config-model.d.ts.map +1 -1
  685. package/tui/dist/config/config-model.js +2 -1
  686. package/tui/dist/config/config-model.js.map +1 -1
  687. package/tui/dist/daemon-client.d.ts +7 -0
  688. package/tui/dist/daemon-client.d.ts.map +1 -1
  689. package/tui/dist/daemon-client.js +15 -4
  690. package/tui/dist/daemon-client.js.map +1 -1
  691. package/tui/dist/demo-data.js +2 -2
  692. package/tui/dist/demo-data.js.map +1 -1
  693. package/tui/dist/main.js +5 -1
  694. package/tui/dist/main.js.map +1 -1
  695. package/ui/dist/assets/index-BOYrLyfQ.js +623 -0
  696. package/ui/dist/assets/index-DqSRu4OY.css +32 -0
  697. package/ui/dist/index.html +2 -2
  698. package/ui/dist/assets/index-BFOs3ejL.css +0 -32
  699. package/ui/dist/assets/index-CdkFwtld.js +0 -623
@@ -5,8 +5,14 @@ import { createHash } from "node:crypto";
5
5
  import { loadHumanRegistry, registeredPeople, resolveRegisteredHumanAddress, slackSubscriptionFor, withHumanAlertTag } from "./gateway/human-registry.js";
6
6
  import { sharedChannelAddresses } from "./gateway/participants.js";
7
7
  import { resolveExternal } from "./gateway/external-admission.js";
8
- import { QueueTransitionLog } from "./queue-transition-log.js";
8
+ import { QueueTransitionLog, RELAY_OWNER_NOTIFICATION_ACCEPTED_PREFIX, RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX, formatRelayOwnerNotificationAccepted, formatRelayOwnerNotificationTransportFailed, parseRelayOwnerNotificationAccepted, parseRelayOwnerNotificationTransportFailed, } from "./queue-transition-log.js";
9
+ export { RELAY_OWNER_NOTIFICATION_ACCEPTED_PREFIX, RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX, formatRelayOwnerNotificationAccepted, formatRelayOwnerNotificationTransportFailed, parseRelayOwnerNotificationAccepted, parseRelayOwnerNotificationTransportFailed, };
10
+ export const MC_OPERATION_TAG_PREFIX = "mc-operation:";
11
+ export function mcOperationTag(operation) {
12
+ return `${MC_OPERATION_TAG_PREFIX}${operation}`;
13
+ }
9
14
  import { WAKE_INTENT_PREFIX } from "./outbox-handler.js";
15
+ import { physicalSessionName } from "./session-registry.js";
10
16
  import { derivePickup } from "./queue-pickup.js";
11
17
  import { withRecoveryIndex } from "./queue-recovery.js";
12
18
  import { lastMeaningfulTransition, readWaitingView } from "./queue-waiting.js";
@@ -16,6 +22,7 @@ import { renderQueueHandoffNudge } from "./queue-nudge-text.js";
16
22
  import { getSelfHostId } from "./hosts/fanout-contract.js";
17
23
  import { parseSessionName, isHumanSeatSessionRef } from "./session-name.js";
18
24
  import { runnerPermissionOrigin } from "./runner-permissions.js";
25
+ import { isHostPairingAsk } from "./hosts/pairing-ask.js";
19
26
  import { parseReplyToChoice, parseReplyToThreadMissing, formatReplyToChoice, describeReplyToFallback, REPLY_TO_CHOICE_ACTOR } from "./reply-to-choice.js";
20
27
  import { classifyDestination } from "./gateway/destination-resolver.js";
21
28
  import { join } from "node:path";
@@ -83,6 +90,10 @@ const AUTO_UNPARK_WAKE_TAG = "queue:auto-unpark:blocker";
83
90
  * handoff: it keeps that source when it's replayed later. Send, broadcast, queue create and the cross-host forward never
84
91
  * set it from a request; the trusted local outbox recorder (/api/queue/outbox/record) accepts caller tags by design. */
85
92
  const WAKE_TRIGGER_OPENRIG_TAG = "queue:wake-trigger:openrig";
93
+ /** The wake telling a claimer that a cross-host handoff overrode its claim (#2631): it's about a row closed by design. */
94
+ const CLAIM_OVERRIDDEN_WAKE_PREFIX = `${WAKE_INTENT_PREFIX}claim-overridden-`;
95
+ /** The first id after every such wake's, so a range on the outbox's primary key finds them all and nothing else. */
96
+ const CLAIM_OVERRIDDEN_WAKE_END = `${WAKE_INTENT_PREFIX}claim-overridden.`;
86
97
  /** On a wake intent whose ring a hosted member's trigger accepted: recovery doesn't ring that intent again. */
87
98
  const HOSTED_WAKE_ACCEPTED_TAG = "queue:hosted-wake-accepted";
88
99
  const AUTO_UNPARK_BLOCKER_TAG_PREFIX = "queue:auto-unpark:blocker-ref:";
@@ -277,6 +288,8 @@ export function matchesRecordedHandoffTarget(qitemId, handedOffTo, closureTarget
277
288
  * Throws on database/query errors so callers can handle lookup failures with their own policies.
278
289
  */
279
290
  export function hasLinkedSuccessor(db, sourceQitemId, target) {
291
+ if (successorScope?.db === db && successorScope.covers(sourceQitemId))
292
+ return successorScope.has(sourceQitemId, target);
280
293
  const successor = db
281
294
  .prepare(`SELECT 1 FROM queue_items s
282
295
  WHERE (s.qitem_id = ? OR s.destination_session = ?) AND s.qitem_id != ?
@@ -290,6 +303,57 @@ export function hasLinkedSuccessor(db, sourceQitemId, target) {
290
303
  .get(target, target, sourceQitemId, sourceQitemId, sourceQitemId);
291
304
  return Boolean(successor);
292
305
  }
306
+ /** The linked-successor index lent to hasLinkedSuccessor by createLinkedSuccessorLookup's run(), for one synchronous call. */
307
+ let successorScope = null;
308
+ /** hasLinkedSuccessor for a whole set of sources in one read, for a pass that asks it once per row (the stuck sweep's
309
+ * custody loop, and the handoff advisory of each row it reads). The read keeps the per-row query's own predicates: a
310
+ * successor is a row whose handed_off_from is the source, or whose chain_of_record is valid JSON with the source among
311
+ * its json_each values (compared as `value IN (...)` compares, like `value = ?`: a number or a nested value never
312
+ * equals a text id); has() then checks qitem_id or destination_session against the target and that the successor is
313
+ * not the source itself. A snapshot from its first has() until invalidate(): the caller invalidates it whenever other
314
+ * code could have run. run(fn) lends it, for the synchronous fn only, to the hasLinkedSuccessor calls made inside fn
315
+ * for a covered source; any other source keeps the per-row query. */
316
+ export function createLinkedSuccessorLookup(db, sourceQitemIds) {
317
+ const sources = new Set(sourceQitemIds);
318
+ let bySource = null;
319
+ const build = () => {
320
+ const map = new Map();
321
+ const ids = JSON.stringify([...sources]);
322
+ const rows = db.prepare(`SELECT s.qitem_id, s.destination_session, s.handed_off_from AS source FROM queue_items s
323
+ WHERE s.handed_off_from IN (SELECT value FROM json_each(?))
324
+ UNION
325
+ SELECT s.qitem_id, s.destination_session, j.value AS source FROM queue_items s, json_each(s.chain_of_record) j
326
+ WHERE s.chain_of_record IS NOT NULL AND json_valid(s.chain_of_record)
327
+ AND j.value IN (SELECT value FROM json_each(?))`).all(ids, ids);
328
+ for (const r of rows) {
329
+ const list = map.get(r.source);
330
+ const entry = { qitemId: r.qitem_id, destination: r.destination_session };
331
+ if (list)
332
+ list.push(entry);
333
+ else
334
+ map.set(r.source, [entry]);
335
+ }
336
+ return map;
337
+ };
338
+ const has = (sourceQitemId, target) => (bySource ??= build()).get(sourceQitemId)?.some((s) => s.qitemId !== sourceQitemId && (s.qitemId === target || s.destination === target)) ?? false;
339
+ const own = { db, covers: (source) => sources.has(source), has };
340
+ return {
341
+ has,
342
+ run: (fn) => {
343
+ if (successorScope?.db === db)
344
+ return fn();
345
+ const previous = successorScope;
346
+ successorScope = own;
347
+ try {
348
+ return fn();
349
+ }
350
+ finally {
351
+ successorScope = previous;
352
+ }
353
+ },
354
+ invalidate: () => { bySource = null; },
355
+ };
356
+ }
293
357
  /** PL-007 — defensive column probe. Older test fixtures bypass the
294
358
  * canonical migration list, so target_repo may be absent. Mirrors
295
359
  * the `hasNodeColumn` pattern in rig-repository.ts. */
@@ -475,6 +539,7 @@ export class QueueRepository {
475
539
  promptClearRetries = new Map();
476
540
  resolveOccupantGeneration;
477
541
  resolveSessionAddresses;
542
+ hasPendingPostCompactStage;
478
543
  wakeRepo;
479
544
  watchdogJobsRepo;
480
545
  /** PL-007 Workspace Primitive — true when migration 038 has applied the
@@ -517,6 +582,7 @@ export class QueueRepository {
517
582
  this.workflowFrontierPredicate = opts?.workflowFrontierPredicate;
518
583
  this.resolveOccupantGeneration = opts?.resolveOccupantGeneration;
519
584
  this.resolveSessionAddresses = opts?.resolveSessionAddresses ?? ((name) => [name]);
585
+ this.hasPendingPostCompactStage = opts?.hasPendingPostCompactStage;
520
586
  this.loadHumanRegistryFn = opts?.loadHumanRegistry ?? (() => loadHumanRegistry());
521
587
  this.sharedChannelsFn = opts?.sharedChannels ?? (() => sharedChannelAddresses());
522
588
  this.hostedWakeFn = opts?.hostedWake ?? defaultHostedWake;
@@ -599,6 +665,19 @@ export class QueueRepository {
599
665
  }
600
666
  currentWakeIntent(entry) {
601
667
  const row = entry.auditPointer ? this.db.prepare("SELECT state, destination_session FROM queue_items WHERE qitem_id=?").get(entry.auditPointer) : undefined;
668
+ // That notice stays current while the row stays closed by the close that made it; every other wake, while its row
669
+ // waits on its destination. A reopen and another close end it: its text names the earlier successor.
670
+ if (entry.outboxId.startsWith(CLAIM_OVERRIDDEN_WAKE_PREFIX)) {
671
+ if (row === undefined || !isTerminalState(row.state) || row.destination_session !== entry.destinationSession)
672
+ return false;
673
+ const closed = TERMINAL_QUEUE_STATES.map(() => "?").join(",");
674
+ const close = this.db.prepare(`SELECT transition_id FROM (
675
+ SELECT transition_id, state, LAG(state) OVER (ORDER BY transition_id) AS previous_state
676
+ FROM queue_transitions WHERE qitem_id=?)
677
+ WHERE state IN (${closed}) AND (previous_state IS NULL OR previous_state NOT IN (${closed})) ORDER BY transition_id DESC LIMIT 1`)
678
+ .get(entry.auditPointer, ...TERMINAL_QUEUE_STATES, ...TERMINAL_QUEUE_STATES);
679
+ return Number(entry.outboxId.slice(CLAIM_OVERRIDDEN_WAKE_PREFIX.length)) === close?.transition_id;
680
+ }
602
681
  if (row?.state !== "pending" || row.destination_session !== entry.destinationSession)
603
682
  return false;
604
683
  const prefix = `${WAKE_INTENT_PREFIX}blocker-`;
@@ -674,10 +753,15 @@ export class QueueRepository {
674
753
  // isn't echoed back. A later park of it on a person is a new ask, classified (and posted) on that update.
675
754
  if (input.gatewayInbound)
676
755
  return { kind: "human-required", level: "RECORD" };
677
- // The person's Slack subscription decides: `every-ask` (the default) posts every ask (ALERT); `urgent-only` posts only
678
- // one marked --alert, and a plain ask lands on Steering and the TUI (RECORD: below the posting dial, so no post is owed).
756
+ // Slack subscription filters only apply when Slack is the primary connector. When a person's primary connector
757
+ // is relay (or by default when no Slack subscription restricts it), plain asks post by default (`every-ask`),
758
+ // so ordinary relay asks post (ALERT) independently of any retained Slack-specific subscription.
679
759
  const person = people.find((entity) => entity.address === destinationHuman);
680
- const posts = input.humanAlert === true || slackSubscriptionFor(person).preset === "every-ask";
760
+ const primaryBinding = person?.connectorBindings.find((b) => b.role === "primary");
761
+ const posts = input.humanAlert === true
762
+ || (primaryBinding?.kind === "relay"
763
+ ? true
764
+ : slackSubscriptionFor(person).preset === "every-ask");
681
765
  return input.humanIntent === "update"
682
766
  ? { kind: "human-update", level: "NOTICE" }
683
767
  : { kind: "human-required", level: posts ? "ALERT" : "RECORD" };
@@ -766,8 +850,10 @@ export class QueueRepository {
766
850
  // Draft-aware wakes remain pending until the transport owns their bounded
767
851
  // retry. Manual retention is deliberately never drained.
768
852
  const draftTarget = this.transport?.draftAwareTarget?.(input.toSession);
853
+ // The same rule as a held message (#2430): the sender's own held messages there count as room, since this wake
854
+ // coalesces them if it settles as held.
769
855
  if (draftTarget)
770
- this.outbox.assertRetentionCapacity(draftTarget.nodeId, frozenEnvelope);
856
+ this.outbox.assertRetentionCapacity(draftTarget.nodeId, frozenEnvelope, input.fromSession, [input.outboxId]);
771
857
  this.outbox.record(record);
772
858
  const binding = this.transport?.deliveryTarget?.(input.toSession);
773
859
  if (binding)
@@ -1036,36 +1122,60 @@ export class QueueRepository {
1036
1122
  }
1037
1123
  /** Recover current notifications once per pass. A snapshot horizon and seek cursor
1038
1124
  * prevent new arrivals or persistent failures from making this pass unbounded. `stopRequested` is checked before
1039
- * each delivery: a stopped pass leaves the notifications it has not attempted as they are, for the next start. */
1125
+ * each delivery: a stopped pass leaves the notifications it has not attempted as they are, for the next start.
1126
+ * A notification already tried for a seat that still has no session or transport would only fail again, so it isn't
1127
+ * claimed, alone or in a group: it stays as it is, its row stays owed, and the pass reports it as waiting. The
1128
+ * receiver is read at each claim, so a seat that starts during the pass gets its later notifications. */
1040
1129
  async drainPendingWakeIntents(opts) {
1041
1130
  const tally = { delivered: 0, indeterminate: 0, failed: 0, retained: 0 };
1042
1131
  if (!this.outbox || !this.transport)
1043
1132
  return tally;
1133
+ const attempted = new Set();
1134
+ // Notifications left alone for want of a receiver; one a later claim in this pass attempted isn't waiting.
1135
+ const skipped = new Map();
1136
+ const result = () => {
1137
+ const waitingBySeat = new Map();
1138
+ for (const [outboxId, seat] of skipped)
1139
+ if (!attempted.has(outboxId))
1140
+ waitingBySeat.set(seat, (waitingBySeat.get(seat) ?? 0) + 1);
1141
+ if (waitingBySeat.size)
1142
+ tally.waiting = { notifications: [...waitingBySeat.values()].reduce((a, b) => a + b, 0), seats: [...waitingBySeat.keys()] };
1143
+ return tally;
1144
+ };
1044
1145
  const BATCH = 200;
1045
1146
  const horizon = this.db.prepare("SELECT COALESCE(MAX(rowid),0) AS id FROM outbox_entries").get().id;
1046
1147
  // Retire never-attempted obsolete notifications without materializing historical intents.
1047
1148
  tally.failed += this.db.prepare(`UPDATE outbox_entries AS o SET delivery_state = 'failed',
1048
1149
  tags = json_insert(COALESCE(tags, '[]'), '$[#]', 'queue:wake-superseded')
1049
1150
  WHERE delivery_state = 'pending' AND rowid <= ? AND substr(outbox_id, 1, ?) = ?
1151
+ AND substr(outbox_id, 1, ?) != ?
1050
1152
  AND NOT EXISTS (SELECT 1 FROM queue_items q WHERE q.qitem_id = o.audit_pointer
1051
1153
  AND q.state = 'pending' AND q.destination_session = o.destination_session)`)
1052
- .run(horizon, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX).changes;
1053
- const attempted = new Set();
1154
+ .run(horizon, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, CLAIM_OVERRIDDEN_WAKE_PREFIX.length, CLAIM_OVERRIDDEN_WAKE_PREFIX).changes;
1054
1155
  // A stop also refuses every later claim inside a delivery: coalesced peers and members it releases for their own send.
1055
- const eligible = () => !opts?.stopRequested?.();
1156
+ // So does a missing receiver, for a notification already tried. One never tried still gets its attempt, so its row
1157
+ // records why it didn't land.
1158
+ const eligible = (entry) => {
1159
+ if (opts?.stopRequested?.())
1160
+ return false;
1161
+ if (entry.deliveryState === "pending" || !this.wakeHasNoReceiver(entry.destinationSession))
1162
+ return true;
1163
+ skipped.set(entry.outboxId, entry.destinationSession);
1164
+ return false;
1165
+ };
1056
1166
  let cursor = 0;
1057
1167
  for (;;) {
1058
1168
  const pending = this.db.prepare(`SELECT o.rowid AS id, o.outbox_id FROM outbox_entries o
1059
- JOIN queue_items q ON q.qitem_id = o.audit_pointer AND q.state = 'pending'
1169
+ JOIN queue_items q ON q.qitem_id = o.audit_pointer AND (q.state = 'pending' OR substr(o.outbox_id, 1, ?) = ?)
1060
1170
  AND q.destination_session = o.destination_session
1061
1171
  WHERE o.rowid > ? AND o.rowid <= ? AND substr(o.outbox_id, 1, ?) = ?
1062
1172
  AND o.delivery_state IN ('pending','failed','indeterminate') ORDER BY o.rowid LIMIT ?`)
1063
- .all(cursor, horizon, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, BATCH);
1173
+ .all(CLAIM_OVERRIDDEN_WAKE_PREFIX.length, CLAIM_OVERRIDDEN_WAKE_PREFIX, cursor, horizon, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, BATCH);
1064
1174
  if (pending.length === 0)
1065
1175
  break;
1066
1176
  for (const intent of pending) {
1067
1177
  if (opts?.stopRequested?.())
1068
- return tally;
1178
+ return result();
1069
1179
  cursor = intent.id;
1070
1180
  const outcome = await this.deliverWakeIntent(intent.outbox_id, attempted, eligible);
1071
1181
  if (outcome !== "skipped")
@@ -1074,7 +1184,25 @@ export class QueueRepository {
1074
1184
  if (pending.length < BATCH)
1075
1185
  break; // served short batch ⇒ drained
1076
1186
  }
1077
- return tally;
1187
+ return result();
1188
+ }
1189
+ /** Positive evidence only that a wake can't land now: no transport can hold the address, or the newest session
1190
+ * under the name the transport sends to has stopped (exited, or detached because its tmux session is gone). A
1191
+ * canonical address resolves to its current physical session first. Anything unknown may have a receiver. */
1192
+ wakeHasNoReceiver(destinationSession) {
1193
+ try {
1194
+ const destClass = this.classifyDestinationOf(destinationSession).class;
1195
+ if (destClass === "unroutable")
1196
+ return true;
1197
+ if (destClass !== "pane-bound")
1198
+ return false;
1199
+ const newest = this.db.prepare("SELECT status FROM sessions WHERE session_name = ? ORDER BY id DESC LIMIT 1")
1200
+ .get(physicalSessionName(this.db, destinationSession));
1201
+ return newest?.status === "exited" || newest?.status === "detached";
1202
+ }
1203
+ catch {
1204
+ return false;
1205
+ }
1078
1206
  }
1079
1207
  /**
1080
1208
  * Issue a default nudge to the destination after a create / handoff /
@@ -1131,6 +1259,10 @@ export class QueueRepository {
1131
1259
  return;
1132
1260
  if (addresses.every(address => this.promptRecoveryState.get(address) === false))
1133
1261
  return;
1262
+ // A compaction's "Compacted" is also a clear. While its turn boundary, restore or audit is still owed, a retried wake
1263
+ // would reach the agent before its restore (#2575): stay armed, and the next clear after those steps retries it.
1264
+ if ([sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address)))
1265
+ return;
1134
1266
  for (const address of addresses)
1135
1267
  this.promptRecoveryState.set(address, false);
1136
1268
  // Correlation may expand the group or release members for separate sends. Each claim must
@@ -1139,13 +1271,22 @@ export class QueueRepository {
1139
1271
  if (entry.deliveryState !== "failed" || !entry.auditPointer)
1140
1272
  return false;
1141
1273
  const current = this.getById(entry.auditPointer), refusal = current?.lastNudgeWireResult;
1142
- return current?.state === "pending" && addresses.includes(current.destinationSession)
1274
+ const notice = entry.outboxId.startsWith(CLAIM_OVERRIDDEN_WAKE_PREFIX);
1275
+ return (current?.state === "pending" || notice) && addresses.includes(current?.destinationSession ?? "")
1143
1276
  && (refusal === "failed:target_needs_input" || (refusal?.startsWith("failed:Refused:") === true && refusal.includes("interactive prompt")));
1144
1277
  };
1278
+ const seats = addresses.map(() => "?").join(",");
1279
+ const refused = (q) => `(${q}last_nudge_result LIKE 'failed:Refused:%interactive prompt%' OR ${q}last_nudge_result = 'failed:target_needs_input')`;
1280
+ // A closed row is here only for a failed override notice, found from the notice by its id range, so this never
1281
+ // reads the host's other failed history.
1145
1282
  const rows = this.db.prepare(`SELECT qitem_id, destination_session, source_session, last_nudge_result
1146
- FROM queue_items WHERE state = 'pending' AND destination_session IN (${addresses.map(() => "?").join(",")})
1147
- AND (last_nudge_result LIKE 'failed:Refused:%interactive prompt%' OR last_nudge_result = 'failed:target_needs_input')`)
1148
- .all(...addresses);
1283
+ FROM queue_items WHERE state = 'pending' AND destination_session IN (${seats}) AND ${refused("")}
1284
+ UNION
1285
+ SELECT q.qitem_id, q.destination_session, q.source_session, q.last_nudge_result
1286
+ FROM outbox_entries o JOIN queue_items q ON q.qitem_id = o.audit_pointer AND q.destination_session = o.destination_session
1287
+ WHERE o.outbox_id >= ? AND o.outbox_id < ? AND +o.delivery_state = 'failed' AND +o.destination_session IN (${seats})
1288
+ AND ${refused("q.")}`)
1289
+ .all(...addresses, CLAIM_OVERRIDDEN_WAKE_PREFIX, CLAIM_OVERRIDDEN_WAKE_END, ...addresses);
1149
1290
  const attempted = new Set();
1150
1291
  // Reserve the whole selection before awaiting: a correlated send can include several rows.
1151
1292
  // Its refusal stays durable, but must not re-arm this same clear-triggered pass.
@@ -1311,9 +1452,10 @@ export class QueueRepository {
1311
1452
  async createHumanAnswer(input) {
1312
1453
  const { episodeKey, ...create } = input;
1313
1454
  // A runner's permission request is answered in its ask, and the runner reads the answer back. No reply row: it
1314
- // would wake the runner's terminal, where typed text reads as a prompt to its agent.
1455
+ // would wake the runner's terminal, where typed text reads as a prompt to its agent. A host pairing request is
1456
+ // answered in its ask too: the pairing poll reads it there, and nothing reads a reply.
1315
1457
  const ask = this.getById(input.inboundReplyTo);
1316
- if (ask && runnerPermissionOrigin(ask))
1458
+ if (ask && (runnerPermissionOrigin(ask) || isHostPairingAsk(ask)))
1317
1459
  return ask;
1318
1460
  const qitemId = humanAnswerId(input.inboundReplyTo, episodeKey);
1319
1461
  const existing = episodeKey ? this.getById(qitemId) : this.getHumanAnswer(input.inboundReplyTo, input.sourceSession);
@@ -2009,6 +2151,9 @@ export class QueueRepository {
2009
2151
  }
2010
2152
  const ts = new Date().toISOString();
2011
2153
  const events = [];
2154
+ const overriddenClaim = input.claimedAtBeforeForward !== undefined && source.claimedAt != null
2155
+ && source.claimedAt !== input.claimedAtBeforeForward ? source.claimedAt : null;
2156
+ let overrideWake = null;
2012
2157
  const txn = this.db.transaction(() => {
2013
2158
  this.db
2014
2159
  .prepare(`UPDATE queue_items
@@ -2019,18 +2164,42 @@ export class QueueRepository {
2019
2164
  closure_target = ?
2020
2165
  WHERE qitem_id = ?`)
2021
2166
  .run(input.terminalState, ts, input.toSession, input.closureTarget, input.qitemId);
2022
- this.transitionLog.append({
2167
+ const note = input.transitionNote ?? `cross-host handoff to ${input.toSession}`;
2168
+ const closeTransition = this.transitionLog.append({
2023
2169
  qitemId: input.qitemId,
2024
2170
  state: input.terminalState,
2025
2171
  actorSession: input.fromSession,
2026
2172
  // BR-1: the minted note carries the TWO-PART toSession only — the
2027
2173
  // host-qualified successor key is allowed in closure_target and nowhere
2028
2174
  // else, and transition_note is a durable carrier.
2029
- transitionNote: input.transitionNote ?? `cross-host handoff to ${input.toSession}`,
2175
+ transitionNote: overriddenClaim
2176
+ ? `${note} (this overrode ${source.destinationSession}'s claim made at ${overriddenClaim}, while the handoff was forwarded)`
2177
+ : note,
2030
2178
  closureReason: "handed_off_to",
2031
2179
  closureTarget: input.closureTarget,
2032
2180
  identityProvenance: input.identityProvenance ?? null,
2033
2181
  });
2182
+ if (overriddenClaim && source.destinationSession !== input.fromSession) {
2183
+ const successor = input.successorQitemId ? ` as ${input.successorQitemId}` : "";
2184
+ try {
2185
+ overrideWake = this.db.transaction(() => this.recordWakeIntent({
2186
+ outboxId: `${CLAIM_OVERRIDDEN_WAKE_PREFIX}${closeTransition.transitionId}`,
2187
+ auditPointer: input.qitemId,
2188
+ qitemId: input.qitemId,
2189
+ fromSession: input.fromSession,
2190
+ toSession: source.destinationSession,
2191
+ identityProvenance: sideEffectProvenance(input.identityProvenance),
2192
+ bareBody: `${input.qitemId} was handed off to ${input.toSession}${successor} while you claimed it, so your claim is superseded and that seat has the work. Stop work on ${input.qitemId}; to carry on with it, coordinate with ${input.toSession}.`,
2193
+ tags: [WAKE_TRIGGER_OPENRIG_TAG],
2194
+ }))();
2195
+ }
2196
+ catch (err) {
2197
+ // As a handoff's own wake: a full held-message quota doesn't undo a close whose successor already exists.
2198
+ if (err.code !== "retained_quota_full")
2199
+ throw err;
2200
+ this.recordNudgeAttempt(input.qitemId, `${WAKE_NOT_RETAINED}${err.message}`);
2201
+ }
2202
+ }
2034
2203
  // OPR.0.5.8.1 S1b — third member of the handoff family, same bypass.
2035
2204
  this.retireParkGeneratedTimer(input.qitemId, `park_ended:${input.terminalState}`);
2036
2205
  const handoffEvent = this.eventBus.persistWithinTransaction({
@@ -2061,6 +2230,8 @@ export class QueueRepository {
2061
2230
  for (const e of events) {
2062
2231
  this.eventBus.notifySubscribers(e);
2063
2232
  }
2233
+ if (overrideWake)
2234
+ this.deliverWakeIntentAfterCommit(overrideWake);
2064
2235
  return { item: this.getByIdOrThrow(input.qitemId), absorbed: false };
2065
2236
  }
2066
2237
  /**
@@ -3035,8 +3206,10 @@ export class QueueRepository {
3035
3206
  })();
3036
3207
  if (!result)
3037
3208
  return false;
3038
- for (const event of result.persistedEvents)
3039
- this.eventBus.notifySubscribers(event);
3209
+ for (const event of result.persistedEvents) {
3210
+ if (!this.eventBus.registerPersistedWithinActiveEnvelope(event))
3211
+ this.eventBus.notifySubscribers(event);
3212
+ }
3040
3213
  return mine;
3041
3214
  }
3042
3215
  /** Another person's committed return to this ask: its shared reply (for a park's question, `episodeKey`'s). It's the
@@ -3161,10 +3334,20 @@ export class QueueRepository {
3161
3334
  /** The opaque revision of what a person decides on (#2446): the question (body, intent, questions) and its decision state
3162
3335
  * (open, blocked or terminal; who it's addressed to or parked on; its answers, a decision made for them, the current park,
3163
3336
  * and the replies returned). A label, a wake, a claim or a note on a park doesn't change it; a new park does, on any blocker. */
3164
- decisionRevision(item) {
3337
+ decisionRevision(item, opts) {
3165
3338
  const phase = item.state === "blocked" ? "blocked" : item.state === "pending" || item.state === "in-progress" ? "open" : item.state;
3166
- const replies = this.hasReplyToColumn ? this.db.prepare("SELECT qitem_id FROM queue_items WHERE reply_to = ? ORDER BY ts_created, rowid")
3167
- .all(item.qitemId).map((row) => row.qitem_id) : [];
3339
+ const excludeOp = typeof opts?.excludeOperationReply === "string" && opts.excludeOperationReply.length > 0
3340
+ ? mcOperationTag(opts.excludeOperationReply)
3341
+ : null;
3342
+ const replies = this.hasReplyToColumn
3343
+ ? (excludeOp
3344
+ ? this.db
3345
+ .prepare("SELECT qitem_id FROM queue_items WHERE reply_to = ? AND NOT (tags IS NOT NULL AND json_valid(tags) AND EXISTS (SELECT 1 FROM json_each(tags) WHERE value = ?)) ORDER BY ts_created, rowid")
3346
+ .all(item.qitemId, excludeOp)
3347
+ : this.db
3348
+ .prepare("SELECT qitem_id FROM queue_items WHERE reply_to = ? ORDER BY ts_created, rowid")
3349
+ .all(item.qitemId)).map((row) => row.qitem_id)
3350
+ : [];
3168
3351
  // The park this is: the transition into blocked from another state (a later blocked-to-blocked note stays this park).
3169
3352
  const transitions = item.state === "blocked" ? this.transitionLog.listForQitem(item.qitemId) : [];
3170
3353
  let parkEntry = null;
@@ -3176,6 +3359,79 @@ export class QueueRepository {
3176
3359
  item.humanAnswers ?? null, item.delegatedDecision ?? null, this.currentHumanRequiredEpisode(item.qitemId)?.key ?? null, parkEntry, replies];
3177
3360
  return `dr1-${createHash("sha256").update(JSON.stringify(decision)).digest("hex").slice(0, 24)}`;
3178
3361
  }
3362
+ listRelayOwnerNotificationReceipts(qitemId) {
3363
+ return this.transitionLog.listRelayOwnerNotificationReceipts(qitemId);
3364
+ }
3365
+ getRelayOwnerNotificationReceipt(qitemId, notificationKey) {
3366
+ return this.transitionLog.getRelayOwnerNotificationReceipt(qitemId, notificationKey);
3367
+ }
3368
+ hasRelayOwnerNotificationReceipt(qitemId, notificationKey) {
3369
+ return this.transitionLog.hasRelayOwnerNotificationReceipt(qitemId, notificationKey);
3370
+ }
3371
+ findRelayOwnerNotificationReceiptByReplyRef(replyRef) {
3372
+ return this.transitionLog.findRelayOwnerNotificationReceiptByReplyRef(replyRef);
3373
+ }
3374
+ recordRelayOwnerNotificationTransportFailed(input) {
3375
+ const current = this.getByIdOrThrow(input.qitemId);
3376
+ const key = typeof input.notificationKey === "string" && input.notificationKey.trim().length > 0
3377
+ ? input.notificationKey.trim()
3378
+ : input.qitemId;
3379
+ const normalizedConnectorRef = typeof input.connectorRef === "string" && input.connectorRef.trim().length > 0
3380
+ ? input.connectorRef.trim()
3381
+ : null;
3382
+ const previousFailure = this.transitionLog
3383
+ .listForQitem(input.qitemId)
3384
+ .filter((transition) => (transition.transitionNote?.startsWith("slack-owner-notification-transport-failed ") ||
3385
+ transition.transitionNote?.startsWith(`${RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX} `)) &&
3386
+ transition.transitionNote.split(/\s+/).includes(`notification_key=${key}`))
3387
+ .at(-1);
3388
+ if (previousFailure?.transitionNote?.startsWith(`${RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX} `)) {
3389
+ const parsedPrevious = parseRelayOwnerNotificationTransportFailed(previousFailure.transitionNote);
3390
+ if (parsedPrevious && parsedPrevious.connectorRef === normalizedConnectorRef) {
3391
+ return current;
3392
+ }
3393
+ }
3394
+ const note = formatRelayOwnerNotificationTransportFailed({
3395
+ notificationKey: key,
3396
+ connectorRef: normalizedConnectorRef,
3397
+ failureClass: input.failureClass,
3398
+ detail: input.detail,
3399
+ });
3400
+ return this.update({
3401
+ qitemId: input.qitemId,
3402
+ actorSession: input.actorSession ?? "daemon@kernel",
3403
+ transitionNote: note,
3404
+ });
3405
+ }
3406
+ recordRelayOwnerNotificationAccepted(input) {
3407
+ const current = this.getByIdOrThrow(input.qitemId);
3408
+ const isUpdate = current.humanIntent === "update" &&
3409
+ current.state !== "blocked" &&
3410
+ !current.blockedOn &&
3411
+ this.isPersonAddress(current.destinationSession);
3412
+ const shouldCloseUpdate = isUpdate && input.closeUpdate !== false && isBlockerLive(current.state);
3413
+ if (this.transitionLog.hasRelayOwnerNotificationReceipt(input.qitemId, input.notificationKey)) {
3414
+ if (shouldCloseUpdate) {
3415
+ return this.update({
3416
+ qitemId: input.qitemId,
3417
+ actorSession: input.actorSession ?? "daemon@kernel",
3418
+ state: "done",
3419
+ closureReason: "no-follow-on",
3420
+ });
3421
+ }
3422
+ return current;
3423
+ }
3424
+ const note = formatRelayOwnerNotificationAccepted({
3425
+ ...input,
3426
+ revision: input.revision ?? this.decisionRevision(current),
3427
+ });
3428
+ return this.update({
3429
+ qitemId: input.qitemId,
3430
+ actorSession: input.actorSession ?? "daemon@kernel",
3431
+ ...(shouldCloseUpdate ? { state: "done", closureReason: "no-follow-on" } : {}),
3432
+ transitionNote: note,
3433
+ });
3434
+ }
3179
3435
  currentHumanRequiredEpisode(qitemId) {
3180
3436
  const episode = this.transitionLog.listForQitem(qitemId).filter((transition) => transition.ownerNotificationKind === "human-required").at(-1);
3181
3437
  if (!episode)
@@ -3291,7 +3547,7 @@ export class QueueRepository {
3291
3547
  return {
3292
3548
  ...item,
3293
3549
  deliveryOutcome: ledger?.outcome ?? null,
3294
- ...(ledger && ledger.outcome !== "posted" ? { deliveryFailureDetail: ledger.detail } : {}),
3550
+ ...(ledger && ledger.outcome !== "posted" && ledger.outcome !== "accepted" ? { deliveryFailureDetail: ledger.detail } : {}),
3295
3551
  ...(item.replyTo ? { replyToFallback: this.replyToFallbackFor(item.qitemId) } : {}),
3296
3552
  };
3297
3553
  }
@@ -3429,7 +3685,7 @@ export class QueueRepository {
3429
3685
  return {
3430
3686
  ...item,
3431
3687
  deliveryOutcome: ledger?.outcome ?? null,
3432
- ...(ledger && ledger.outcome !== "posted" ? { deliveryFailureDetail: ledger.detail } : {}),
3688
+ ...(ledger && ledger.outcome !== "posted" && ledger.outcome !== "accepted" ? { deliveryFailureDetail: ledger.detail } : {}),
3433
3689
  };
3434
3690
  });
3435
3691
  return opts?.compact ? items.map(compactRow) : items;
@@ -3475,10 +3731,20 @@ export class QueueRepository {
3475
3731
  SELECT q.*, r.ts AS delivered_at, r.transition_note AS delivery_receipt
3476
3732
  FROM queue_items q JOIN (${receipts}) r ON r.qitem_id = q.qitem_id
3477
3733
  WHERE q.human_intent = 'update' AND is_human_seat_session(q.destination_session) = 1
3478
- AND r.transition_note LIKE 'slack-owner-notification-posted %'
3734
+ AND (r.transition_note LIKE 'slack-owner-notification-posted %' OR r.transition_note LIKE 'relay-owner-notification-accepted %')
3479
3735
  ORDER BY r.ts DESC, q.qitem_id DESC LIMIT ?
3480
3736
  `).all(limit);
3481
- return rows.map((row) => ({ ...this.rowToItem(row), deliveredAt: row.delivered_at, deliveryReceipt: row.delivery_receipt }));
3737
+ return rows.map((row) => {
3738
+ const deliveryOutcome = row.delivery_receipt.startsWith(`${RELAY_OWNER_NOTIFICATION_ACCEPTED_PREFIX} `)
3739
+ ? "accepted"
3740
+ : "posted";
3741
+ return {
3742
+ ...this.rowToItem(row),
3743
+ deliveryOutcome,
3744
+ deliveredAt: row.delivered_at,
3745
+ deliveryReceipt: row.delivery_receipt,
3746
+ };
3747
+ });
3482
3748
  }
3483
3749
  /** Current explicit human FYIs; delivery receipts are not required for local visibility.
3484
3750
  * Filter before the bounded window so agent and malformed destinations cannot hide updates. */
@@ -3571,6 +3837,10 @@ export class QueueRepository {
3571
3837
  const cutoff = opts?.now ?? new Date().toISOString();
3572
3838
  const conditions = ["state = 'in-progress'", "closure_required_at IS NOT NULL", "closure_required_at <= ?"];
3573
3839
  const params = [cutoff];
3840
+ if (opts?.qitemId !== undefined) {
3841
+ conditions.push("qitem_id = ?");
3842
+ params.push(opts.qitemId);
3843
+ }
3574
3844
  if (opts?.rig) {
3575
3845
  const escaped = opts.rig.replace(/%/g, "\\%").replace(/_/g, "\\_");
3576
3846
  conditions.push("(destination_session LIKE ? ESCAPE '\\' OR source_session LIKE ? ESCAPE '\\')");
@@ -3658,9 +3928,15 @@ export class QueueRepository {
3658
3928
  OR EXISTS (SELECT 1 FROM queue_transitions receipt
3659
3929
  WHERE receipt.qitem_id = queue_items.qitem_id
3660
3930
  AND (receipt.transition_note LIKE 'slack-owner-notification-posted %'
3661
- OR receipt.transition_note LIKE 'slack-owner-notification-transport-failed %')))`,
3931
+ OR receipt.transition_note LIKE 'relay-owner-notification-accepted %'
3932
+ OR receipt.transition_note LIKE 'slack-owner-notification-transport-failed %'
3933
+ OR receipt.transition_note LIKE 'relay-owner-notification-transport-failed %')))`,
3662
3934
  ];
3663
3935
  const params = [];
3936
+ if (opts?.qitemId !== undefined) {
3937
+ conditions.push("qitem_id = ?");
3938
+ params.push(opts.qitemId);
3939
+ }
3664
3940
  if (opts?.rig) {
3665
3941
  const escaped = opts.rig.replace(/%/g, "\\%").replace(/_/g, "\\_");
3666
3942
  conditions.push("(destination_session LIKE ? ESCAPE '\\' OR source_session LIKE ? ESCAPE '\\')");
@@ -3673,7 +3949,7 @@ export class QueueRepository {
3673
3949
  for (const r of rows) {
3674
3950
  const item = this.rowToItem(r, !opts?.compact);
3675
3951
  const ledger = this.deliveryOutcomeFor(item.qitemId);
3676
- if (ledger?.outcome === "posted")
3952
+ if (ledger?.outcome === "posted" || ledger?.outcome === "accepted")
3677
3953
  continue; // the receipt wins, always
3678
3954
  if (ledger?.outcome === "transport-failed") {
3679
3955
  out.push({
@@ -3851,20 +4127,28 @@ export class QueueRepository {
3851
4127
  const ledger = this.deliveryLedger(qitemId);
3852
4128
  return ledger ? { outcome: ledger.outcome, detail: ledger.detail } : null;
3853
4129
  }
3854
- /** #514 — true only when this row's CURRENT human-notification episode (OWNER history addressed
3855
- * to a registered human, aliases included) has a POSTED receipt. Legacy rows with no OWNER
4130
+ /** OPR.0.5.6.14 + #514 — true when the row's CURRENT ask episode (create-time pending ask
4131
+ * to a registered human, aliases included) has a POSTED or ACCEPTED receipt. Legacy rows with no OWNER
3856
4132
  * history, inactive episodes, never-posted and transport-failed all read false. Same derivation
3857
4133
  * as deliveryOutcomeFor; it reads row fields, never the waiting view. */
3858
4134
  humanNotificationPostedThisEpisode(qitemId, listed) {
4135
+ return this.humanNotificationDeliveryThisEpisode(qitemId, listed) !== null;
4136
+ }
4137
+ humanNotificationDeliveryThisEpisode(qitemId, listed) {
3859
4138
  if (!this.hasQueueTransitionsTable)
3860
- return false;
4139
+ return null;
3861
4140
  const owners = listed?.owners ?? this.transitionLog.ownerNotificationsForQitems([qitemId]).get(qitemId) ?? [];
3862
4141
  const owner = this.currentAskNotification(qitemId, owners);
3863
4142
  if (!owner)
3864
- return false;
4143
+ return null;
3865
4144
  // The ledger's episode exists only when the destination resolves to a registered human (aliases included).
3866
4145
  const ledger = listed ? listed.ledger : this.deliveryLedger(qitemId, owners);
3867
- return ledger !== null && ledger.outcome === "posted" && ledger.episode?.notificationKey === `${qitemId}:${owner.transitionId}`;
4146
+ if (ledger !== null &&
4147
+ (ledger.outcome === "posted" || ledger.outcome === "accepted") &&
4148
+ ledger.episode?.notificationKey === `${qitemId}:${owner.transitionId}`) {
4149
+ return ledger.outcome;
4150
+ }
4151
+ return null;
3868
4152
  }
3869
4153
  /** The ask's own notification while it still binds its recipient. Only that notification does: create writes it in
3870
4154
  * state pending, to the destination of that moment. A park notice (its recipient is not retained), a resolution notice,
@@ -3946,7 +4230,9 @@ export class QueueRepository {
3946
4230
  receiptNotesFor(qitemIds) {
3947
4231
  this.receiptNotesStatement ??= this.db.prepare(`SELECT qitem_id, transition_note FROM queue_transitions
3948
4232
  WHERE qitem_id IN (SELECT value FROM json_each(?)) AND (transition_note LIKE 'slack-owner-notification-posted %'
3949
- OR transition_note LIKE 'slack-owner-notification-transport-failed %')
4233
+ OR transition_note LIKE 'relay-owner-notification-accepted %'
4234
+ OR transition_note LIKE 'slack-owner-notification-transport-failed %'
4235
+ OR transition_note LIKE 'relay-owner-notification-transport-failed %')
3950
4236
  ORDER BY transition_id DESC`);
3951
4237
  const notes = new Map();
3952
4238
  for (const row of this.receiptNotesStatement.all(JSON.stringify(qitemIds))) {
@@ -3966,7 +4252,11 @@ export class QueueRepository {
3966
4252
  const posted = currentNotes.find((note) => note.startsWith("slack-owner-notification-posted "));
3967
4253
  if (posted)
3968
4254
  return { outcome: "posted", detail: posted, episode };
3969
- const failed = currentNotes.find((note) => note.startsWith("slack-owner-notification-transport-failed "));
4255
+ const accepted = currentNotes.find((note) => note.startsWith("relay-owner-notification-accepted "));
4256
+ if (accepted)
4257
+ return { outcome: "accepted", detail: accepted, episode };
4258
+ const failed = currentNotes.find((note) => note.startsWith("slack-owner-notification-transport-failed ") ||
4259
+ note.startsWith(`${RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX} `));
3970
4260
  if (failed)
3971
4261
  return { outcome: "transport-failed", detail: failed, episode };
3972
4262
  if (episode?.quiet)
@@ -4227,6 +4517,19 @@ export class QueueRepository {
4227
4517
  }
4228
4518
  activityReader;
4229
4519
  attachActivityReader(reader) { this.activityReader = reader; }
4520
+ /** #2661 (c): since when (ISO) the daemon owes a seat its managed post-compaction stages, or null. */
4521
+ compactionReader;
4522
+ attachCompactionReader(reader) { this.compactionReader = reader; }
4523
+ compactionOwedSince(session) {
4524
+ if (!session)
4525
+ return null;
4526
+ try {
4527
+ return this.compactionReader?.(session) ?? null;
4528
+ }
4529
+ catch {
4530
+ return null;
4531
+ }
4532
+ }
4230
4533
  workflowGuidance;
4231
4534
  attachWorkflowGuidance(reader) { this.workflowGuidance = reader; }
4232
4535
  evaluateWaitReminder(input) {
@@ -4260,7 +4563,8 @@ export class QueueRepository {
4260
4563
  if (view && ["pending", "in-progress"].includes(view.state)) {
4261
4564
  // #514 — the unclaimed sweep skips a pending ask already posted to its human in the current
4262
4565
  // episode (same predicate as runStuckSweep), so the view must not promise that sweep.
4263
- const posted = view.state === "pending" && this.humanNotificationPostedThisEpisode(qitemId, listed);
4566
+ const episodeDelivery = view.state === "pending" ? this.humanNotificationDeliveryThisEpisode(qitemId, listed) : null;
4567
+ const posted = episodeDelivery !== null;
4264
4568
  const onSteering = !posted && view.state === "pending" && this.humanAskWithoutAlert(qitemId, listed);
4265
4569
  const row = view.state === "pending" && !onSteering
4266
4570
  ? this.db.prepare(`SELECT state, ${this.hasHumanIntentColumn ? "human_intent" : "NULL AS human_intent"}, destination_session, last_nudge_result FROM queue_items WHERE qitem_id = ?`).get(qitemId)
@@ -4271,13 +4575,14 @@ export class QueueRepository {
4271
4575
  && this.isLocalHumanDecisionWithoutGateway({ state: row.state, humanIntent: row.human_intent, destinationSession: row.destination_session, lastNudgeResult: row.last_nudge_result });
4272
4576
  const awaitingHuman = posted || onSteering || localOnly;
4273
4577
  if (awaitingHuman || humanUpdate) {
4578
+ const deliveryPhrase = episodeDelivery === "accepted" ? "accepted by the bridge" : "posted to the human";
4274
4579
  view.nextBackstop = { owner: view.owner, mechanism: localOnly ? "local attention feed (no registered human gateway)" : onSteering
4275
4580
  ? "none (on Steering for the human, with no Slack alert; awaiting their decision)"
4276
4581
  : humanUpdate
4277
4582
  ? posted
4278
- ? "none (posted to the human; informational correspondence requires no claim)"
4583
+ ? `none (${deliveryPhrase}; informational correspondence requires no claim)`
4279
4584
  : "none (informational correspondence to the human; no claim required)"
4280
- : "none (posted to the human; awaiting their decision)", dueAt: null, intervalSeconds: null };
4585
+ : `none (${deliveryPhrase}; awaiting their decision)`, dueAt: null, intervalSeconds: null };
4281
4586
  }
4282
4587
  // Quiet hours: a held ask is owned by its window's release job until it posts.
4283
4588
  const quiet = awaitingHuman ? null : quietCustodyBackstop(view.owner, quietHoldCustody(this.db, qitemId));
@@ -4333,8 +4638,8 @@ export class QueueRepository {
4333
4638
  target,
4334
4639
  reason: "no-live-local-successor",
4335
4640
  message: foreignTarget
4336
- ? `Successor custody for '${target}' is unverified on this daemon: the successor is named on that host, and this daemon cannot read its custody. This closure records a handoff claim, not proof of transfer or pickup. Use 'rig queue handoff' or 'handoff-and-complete': a local handoff is atomic, across hosts the successor is created first and the source closed after, and an uncertain result is reconciled by its exact id, since re-running the same handoff is idempotent.`
4337
- : `Successor custody for '${target}' is unverified on this daemon: no local row with this source's lineage was found. A successor may exist on another host. This closure records a handoff claim, not proof of transfer or pickup; reconcile the successor by ID. Use 'rig queue handoff' or 'handoff-and-complete': a local handoff is atomic, across hosts the successor is created first and the source closed after, and an uncertain result is reconciled by its exact id, since re-running the same handoff is idempotent.`,
4641
+ ? `Successor custody for '${target}' is unverified on this daemon: the successor is named on that host, and this daemon cannot read its custody. This closure records a handoff claim, not proof of transfer or pickup. Use 'rig queue handoff' or 'handoff-and-complete' with '--to <seat@rig>'; add '--host <registered-host>' for another host instead of manually closing to the successor ID; a local handoff is atomic, across hosts the successor is created first and the source closed after, and an uncertain result is reconciled by its exact id, since re-running the same handoff is idempotent.`
4642
+ : `Successor custody for '${target}' is unverified on this daemon: no local row with this source's lineage was found. A successor may exist on another host. This closure records a handoff claim, not proof of transfer or pickup; reconcile the successor by ID. Use 'rig queue handoff' or 'handoff-and-complete' with '--to <seat@rig>'; add '--host <registered-host>' for another host instead of manually closing to the successor ID; a local handoff is atomic, across hosts the successor is created first and the source closed after, and an uncertain result is reconciled by its exact id, since re-running the same handoff is idempotent.`,
4338
4643
  };
4339
4644
  }
4340
4645
  rowToItem(row, includeWaiting = true, listed) {
@@ -4349,6 +4654,8 @@ export class QueueRepository {
4349
4654
  activity: activity?.activity,
4350
4655
  needsInput: activity?.needsInput.count,
4351
4656
  needsInputReason: activity?.needsInput.reason,
4657
+ backgroundWork: activity?.backgroundWork ?? null,
4658
+ compactionOwedSince: this.compactionOwedSince(row.destination_session),
4352
4659
  claimedAt: row.claimed_at,
4353
4660
  lastHeartbeat: row.last_heartbeat,
4354
4661
  postClaimMotionCount: 0, // this reader supplies the current meaningful timestamp