@openrig/cli 0.7.11 → 0.7.12

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 (772) hide show
  1. package/README.md +9 -6
  2. package/daemon/assets/guidance/openrig-context-entry.md +8 -0
  3. package/daemon/assets/herdr-app/mods/rig-cell-header/main.js +15 -0
  4. package/daemon/assets/herdr-app/mods/rig-cell-header/mod.json +1 -0
  5. package/daemon/assets/herdr-app/mods/rig-ended/main.js +14 -0
  6. package/daemon/assets/herdr-app/mods/rig-ended/mod.json +1 -0
  7. package/daemon/assets/herdr-app/mods/rig-pad/main.js +10 -0
  8. package/daemon/assets/herdr-app/mods/rig-pad/mod.json +1 -0
  9. package/daemon/assets/herdr-app/mods/rig-strip/main.js +153 -0
  10. package/daemon/assets/herdr-app/mods/rig-strip/mod.json +1 -0
  11. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  12. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  13. package/daemon/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs +15 -0
  14. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus-state.cjs +103 -0
  15. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +170 -86
  16. package/daemon/assets/plugins/openrig-core/skills/agent-operated-software/SKILL.md +5 -1
  17. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/SKILL.md +3 -2
  18. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +1 -1
  19. package/daemon/assets/plugins/openrig-core/skills/retiring-and-inheriting-a-seat/SKILL.md +1 -1
  20. package/daemon/assets/plugins/openrig-core/skills/seat-continuity-and-handover/SKILL.md +10 -6
  21. package/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore/SKILL.md +1 -1
  22. package/daemon/assets/skills/rigs/SKILL.md +37 -2
  23. package/daemon/context-packs/help/help.md +18 -0
  24. package/daemon/context-packs/help/manifest.yaml +1 -1
  25. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  26. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +48 -21
  27. package/daemon/context-packs/reference/getting-started.md +18 -3
  28. package/daemon/context-packs/reference/manifest.yaml +1 -1
  29. package/daemon/context-packs/reference/rig-spec.md +15 -9
  30. package/daemon/context-packs/reference/tmux-servers.md +2 -2
  31. package/daemon/context-packs/reference/whats-new.md +141 -121
  32. package/daemon/context-packs/skills/agent-operated-software/SKILL.md +5 -1
  33. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/claude-compaction-restore/SKILL.md +3 -2
  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/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/core/openrig-herdr/SKILL.md +1 -0
  46. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/openrig-user/SKILL.md +1 -1
  63. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/pods/review-team/SKILL.md +2 -0
  76. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  78. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  79. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  83. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  84. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  85. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  86. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/SKILL.md +1 -1
  87. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  88. package/daemon/context-packs/skills/seat-continuity-and-handover/SKILL.md +10 -6
  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 +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.map +1 -1
  96. package/daemon/dist/adapters/claude-code-adapter.js +18 -3
  97. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  98. package/daemon/dist/adapters/claude-resume.d.ts +2 -1
  99. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  100. package/daemon/dist/adapters/claude-resume.js +13 -5
  101. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  102. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  103. package/daemon/dist/adapters/codex-runtime-adapter.js +18 -2
  104. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  105. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +10 -6
  106. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
  107. package/daemon/dist/adapters/community-harness-runtime-adapter.js +78 -24
  108. package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
  109. package/daemon/dist/adapters/pi-community-runtime-adapter.d.ts +27 -0
  110. package/daemon/dist/adapters/pi-community-runtime-adapter.d.ts.map +1 -0
  111. package/daemon/dist/adapters/pi-community-runtime-adapter.js +38 -0
  112. package/daemon/dist/adapters/pi-community-runtime-adapter.js.map +1 -0
  113. package/daemon/dist/adapters/pi-runner-protocol.d.ts +5 -3
  114. package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -1
  115. package/daemon/dist/adapters/pi-runner-protocol.js +6 -1
  116. package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -1
  117. package/daemon/dist/adapters/pi-runner.d.ts +9 -4
  118. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  119. package/daemon/dist/adapters/pi-runner.js +104 -30
  120. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  121. package/daemon/dist/adapters/pi-runtime-adapter.d.ts +32 -15
  122. package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -1
  123. package/daemon/dist/adapters/pi-runtime-adapter.js +41 -10
  124. package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -1
  125. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  126. package/daemon/dist/adapters/tmux-exec.js +13 -4
  127. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  128. package/daemon/dist/adapters/tmux-server.d.ts +2 -0
  129. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  130. package/daemon/dist/adapters/tmux-server.js +1 -1
  131. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  132. package/daemon/dist/adapters/tmux.d.ts +14 -1
  133. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  134. package/daemon/dist/adapters/tmux.js +77 -15
  135. package/daemon/dist/adapters/tmux.js.map +1 -1
  136. package/daemon/dist/attention-surface.d.ts +7 -0
  137. package/daemon/dist/attention-surface.d.ts.map +1 -1
  138. package/daemon/dist/attention-surface.js.map +1 -1
  139. package/daemon/dist/build-info.js +3 -3
  140. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  141. package/daemon/dist/db/all-migrations.js +10 -0
  142. package/daemon/dist/db/all-migrations.js.map +1 -1
  143. package/daemon/dist/db/migrations/155_queue_erasure.d.ts +12 -0
  144. package/daemon/dist/db/migrations/155_queue_erasure.d.ts.map +1 -0
  145. package/daemon/dist/db/migrations/155_queue_erasure.js +28 -0
  146. package/daemon/dist/db/migrations/155_queue_erasure.js.map +1 -0
  147. package/daemon/dist/db/migrations/156_queue_erasure_link_indexes.d.ts +4 -0
  148. package/daemon/dist/db/migrations/156_queue_erasure_link_indexes.d.ts.map +1 -0
  149. package/daemon/dist/db/migrations/156_queue_erasure_link_indexes.js +14 -0
  150. package/daemon/dist/db/migrations/156_queue_erasure_link_indexes.js.map +1 -0
  151. package/daemon/dist/db/migrations/157_queue_erasure_batches.d.ts +9 -0
  152. package/daemon/dist/db/migrations/157_queue_erasure_batches.d.ts.map +1 -0
  153. package/daemon/dist/db/migrations/157_queue_erasure_batches.js +18 -0
  154. package/daemon/dist/db/migrations/157_queue_erasure_batches.js.map +1 -0
  155. package/daemon/dist/db/migrations/158_queue_inbox_checkins.d.ts +8 -0
  156. package/daemon/dist/db/migrations/158_queue_inbox_checkins.d.ts.map +1 -0
  157. package/daemon/dist/db/migrations/158_queue_inbox_checkins.js +15 -0
  158. package/daemon/dist/db/migrations/158_queue_inbox_checkins.js.map +1 -0
  159. package/daemon/dist/db/migrations/159_queue_items_handed_off_from_index.d.ts +5 -0
  160. package/daemon/dist/db/migrations/159_queue_items_handed_off_from_index.d.ts.map +1 -0
  161. package/daemon/dist/db/migrations/159_queue_items_handed_off_from_index.js +9 -0
  162. package/daemon/dist/db/migrations/159_queue_items_handed_off_from_index.js.map +1 -0
  163. package/daemon/dist/domain/agent-activity-store.d.ts +4 -2
  164. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  165. package/daemon/dist/domain/agent-activity-store.js +11 -7
  166. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  167. package/daemon/dist/domain/builtin-startup-files.d.ts +8 -0
  168. package/daemon/dist/domain/builtin-startup-files.d.ts.map +1 -1
  169. package/daemon/dist/domain/builtin-startup-files.js +37 -11
  170. package/daemon/dist/domain/builtin-startup-files.js.map +1 -1
  171. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +30 -17
  172. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  173. package/daemon/dist/domain/claude-compaction-enforcer.js +140 -66
  174. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  175. package/daemon/dist/domain/claude-continuation-launch.d.ts +16 -0
  176. package/daemon/dist/domain/claude-continuation-launch.d.ts.map +1 -0
  177. package/daemon/dist/domain/claude-continuation-launch.js +110 -0
  178. package/daemon/dist/domain/claude-continuation-launch.js.map +1 -0
  179. package/daemon/dist/domain/claude-git-trust-root.d.ts +11 -0
  180. package/daemon/dist/domain/claude-git-trust-root.d.ts.map +1 -0
  181. package/daemon/dist/domain/claude-git-trust-root.js +72 -0
  182. package/daemon/dist/domain/claude-git-trust-root.js.map +1 -0
  183. package/daemon/dist/domain/claude-managed-launch.d.ts +1 -0
  184. package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
  185. package/daemon/dist/domain/claude-managed-launch.js +5 -5
  186. package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
  187. package/daemon/dist/domain/community-harness-presets.d.ts +5 -0
  188. package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
  189. package/daemon/dist/domain/community-harness-presets.js +33 -6
  190. package/daemon/dist/domain/community-harness-presets.js.map +1 -1
  191. package/daemon/dist/domain/compaction-restore-notice.d.ts +3 -1
  192. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -1
  193. package/daemon/dist/domain/compaction-restore-notice.js +37 -6
  194. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -1
  195. package/daemon/dist/domain/current-work.d.ts +52 -0
  196. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  197. package/daemon/dist/domain/current-work.js +215 -0
  198. package/daemon/dist/domain/current-work.js.map +1 -1
  199. package/daemon/dist/domain/default-receiver.d.ts +40 -0
  200. package/daemon/dist/domain/default-receiver.d.ts.map +1 -0
  201. package/daemon/dist/domain/default-receiver.js +70 -0
  202. package/daemon/dist/domain/default-receiver.js.map +1 -0
  203. package/daemon/dist/domain/draft-aware-delivery.js +1 -1
  204. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  205. package/daemon/dist/domain/escalation-owner.d.ts.map +1 -1
  206. package/daemon/dist/domain/escalation-owner.js +8 -3
  207. package/daemon/dist/domain/escalation-owner.js.map +1 -1
  208. package/daemon/dist/domain/event-bus.d.ts +16 -8
  209. package/daemon/dist/domain/event-bus.d.ts.map +1 -1
  210. package/daemon/dist/domain/event-bus.js +50 -16
  211. package/daemon/dist/domain/event-bus.js.map +1 -1
  212. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  213. package/daemon/dist/domain/execution-view.js +28 -3
  214. package/daemon/dist/domain/execution-view.js.map +1 -1
  215. package/daemon/dist/domain/gateway/gateway-subsystem.d.ts +3 -0
  216. package/daemon/dist/domain/gateway/gateway-subsystem.d.ts.map +1 -1
  217. package/daemon/dist/domain/gateway/gateway-subsystem.js +9 -0
  218. package/daemon/dist/domain/gateway/gateway-subsystem.js.map +1 -1
  219. package/daemon/dist/domain/gateway/human-quiet-windows.d.ts +2 -1
  220. package/daemon/dist/domain/gateway/human-quiet-windows.d.ts.map +1 -1
  221. package/daemon/dist/domain/gateway/human-quiet-windows.js +2 -1
  222. package/daemon/dist/domain/gateway/human-quiet-windows.js.map +1 -1
  223. package/daemon/dist/domain/gateway/human-registry.d.ts +12 -1
  224. package/daemon/dist/domain/gateway/human-registry.d.ts.map +1 -1
  225. package/daemon/dist/domain/gateway/human-registry.js +64 -8
  226. package/daemon/dist/domain/gateway/human-registry.js.map +1 -1
  227. package/daemon/dist/domain/gateway/relay-config.d.ts +5 -2
  228. package/daemon/dist/domain/gateway/relay-config.d.ts.map +1 -1
  229. package/daemon/dist/domain/gateway/relay-config.js +34 -3
  230. package/daemon/dist/domain/gateway/relay-config.js.map +1 -1
  231. package/daemon/dist/domain/gateway/relay-inbound.d.ts +11 -0
  232. package/daemon/dist/domain/gateway/relay-inbound.d.ts.map +1 -1
  233. package/daemon/dist/domain/gateway/relay-inbound.js +283 -41
  234. package/daemon/dist/domain/gateway/relay-inbound.js.map +1 -1
  235. package/daemon/dist/domain/gateway/relay-outbound.d.ts +5 -2
  236. package/daemon/dist/domain/gateway/relay-outbound.d.ts.map +1 -1
  237. package/daemon/dist/domain/gateway/relay-outbound.js +37 -6
  238. package/daemon/dist/domain/gateway/relay-outbound.js.map +1 -1
  239. package/daemon/dist/domain/gateway/slack/config.d.ts +21 -0
  240. package/daemon/dist/domain/gateway/slack/config.d.ts.map +1 -1
  241. package/daemon/dist/domain/gateway/slack/config.js +30 -3
  242. package/daemon/dist/domain/gateway/slack/config.js.map +1 -1
  243. package/daemon/dist/domain/gateway/slack/message.d.ts +4 -0
  244. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  245. package/daemon/dist/domain/gateway/slack/message.js +7 -2
  246. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  247. package/daemon/dist/domain/gateway/slack/open-asks.d.ts +13 -1
  248. package/daemon/dist/domain/gateway/slack/open-asks.d.ts.map +1 -1
  249. package/daemon/dist/domain/gateway/slack/open-asks.js +58 -7
  250. package/daemon/dist/domain/gateway/slack/open-asks.js.map +1 -1
  251. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts +9 -0
  252. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts.map +1 -1
  253. package/daemon/dist/domain/gateway/slack/outbound-driver.js.map +1 -1
  254. package/daemon/dist/domain/gateway/slack/settled-asks.d.ts.map +1 -1
  255. package/daemon/dist/domain/gateway/slack/settled-asks.js +19 -1
  256. package/daemon/dist/domain/gateway/slack/settled-asks.js.map +1 -1
  257. package/daemon/dist/domain/gateway/slack/slack-api.d.ts +3 -0
  258. package/daemon/dist/domain/gateway/slack/slack-api.d.ts.map +1 -1
  259. package/daemon/dist/domain/gateway/slack/slack-api.js +12 -4
  260. package/daemon/dist/domain/gateway/slack/slack-api.js.map +1 -1
  261. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts +2 -0
  262. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
  263. package/daemon/dist/domain/gateway/slack/slack-delivery.js +38 -12
  264. package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
  265. package/daemon/dist/domain/gateway/slack/slack-recovery.d.ts +12 -1
  266. package/daemon/dist/domain/gateway/slack/slack-recovery.d.ts.map +1 -1
  267. package/daemon/dist/domain/gateway/slack/slack-recovery.js +68 -10
  268. package/daemon/dist/domain/gateway/slack/slack-recovery.js.map +1 -1
  269. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
  270. package/daemon/dist/domain/gateway/slack/slack-subsystem.js +151 -47
  271. package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
  272. package/daemon/dist/domain/gateway/slack/socket-inbound.d.ts +1 -0
  273. package/daemon/dist/domain/gateway/slack/socket-inbound.d.ts.map +1 -1
  274. package/daemon/dist/domain/gateway/slack/socket-inbound.js +5 -0
  275. package/daemon/dist/domain/gateway/slack/socket-inbound.js.map +1 -1
  276. package/daemon/dist/domain/gateway/slack/state-store.d.ts +4 -0
  277. package/daemon/dist/domain/gateway/slack/state-store.d.ts.map +1 -1
  278. package/daemon/dist/domain/gateway/slack/state-store.js +4 -1
  279. package/daemon/dist/domain/gateway/slack/state-store.js.map +1 -1
  280. package/daemon/dist/domain/gateway/slack/thread-recovery.d.ts +23 -3
  281. package/daemon/dist/domain/gateway/slack/thread-recovery.d.ts.map +1 -1
  282. package/daemon/dist/domain/gateway/slack/thread-recovery.js +52 -10
  283. package/daemon/dist/domain/gateway/slack/thread-recovery.js.map +1 -1
  284. package/daemon/dist/domain/gateway/slack/thread-seat-map.d.ts +4 -1
  285. package/daemon/dist/domain/gateway/slack/thread-seat-map.d.ts.map +1 -1
  286. package/daemon/dist/domain/gateway/slack/thread-seat-map.js +7 -4
  287. package/daemon/dist/domain/gateway/slack/thread-seat-map.js.map +1 -1
  288. package/daemon/dist/domain/guidance-projection.d.ts +39 -0
  289. package/daemon/dist/domain/guidance-projection.d.ts.map +1 -0
  290. package/daemon/dist/domain/guidance-projection.js +91 -0
  291. package/daemon/dist/domain/guidance-projection.js.map +1 -0
  292. package/daemon/dist/domain/health-passive-ceremony.d.ts.map +1 -1
  293. package/daemon/dist/domain/health-passive-ceremony.js +31 -12
  294. package/daemon/dist/domain/health-passive-ceremony.js.map +1 -1
  295. package/daemon/dist/domain/hosted-wake.d.ts +5 -1
  296. package/daemon/dist/domain/hosted-wake.d.ts.map +1 -1
  297. package/daemon/dist/domain/hosted-wake.js +13 -3
  298. package/daemon/dist/domain/hosted-wake.js.map +1 -1
  299. package/daemon/dist/domain/launch-wrapper.d.ts +2 -1
  300. package/daemon/dist/domain/launch-wrapper.d.ts.map +1 -1
  301. package/daemon/dist/domain/launch-wrapper.js +6 -2
  302. package/daemon/dist/domain/launch-wrapper.js.map +1 -1
  303. package/daemon/dist/domain/managed-blocks.d.ts +3 -0
  304. package/daemon/dist/domain/managed-blocks.d.ts.map +1 -1
  305. package/daemon/dist/domain/managed-blocks.js +5 -0
  306. package/daemon/dist/domain/managed-blocks.js.map +1 -1
  307. package/daemon/dist/domain/markdown-address.d.ts.map +1 -1
  308. package/daemon/dist/domain/markdown-address.js +12 -1
  309. package/daemon/dist/domain/markdown-address.js.map +1 -1
  310. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  311. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +37 -6
  312. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  313. package/daemon/dist/domain/native-process-arguments.d.ts +5 -0
  314. package/daemon/dist/domain/native-process-arguments.d.ts.map +1 -1
  315. package/daemon/dist/domain/native-process-arguments.js +60 -5
  316. package/daemon/dist/domain/native-process-arguments.js.map +1 -1
  317. package/daemon/dist/domain/node-inventory.js +3 -3
  318. package/daemon/dist/domain/node-inventory.js.map +1 -1
  319. package/daemon/dist/domain/package-manifest.d.ts.map +1 -1
  320. package/daemon/dist/domain/package-manifest.js +10 -5
  321. package/daemon/dist/domain/package-manifest.js.map +1 -1
  322. package/daemon/dist/domain/policies/delivery-digest-flush.d.ts.map +1 -1
  323. package/daemon/dist/domain/policies/delivery-digest-flush.js +9 -1
  324. package/daemon/dist/domain/policies/delivery-digest-flush.js.map +1 -1
  325. package/daemon/dist/domain/policies/mode-scheduled-end.d.ts +4 -1
  326. package/daemon/dist/domain/policies/mode-scheduled-end.d.ts.map +1 -1
  327. package/daemon/dist/domain/policies/mode-scheduled-end.js +19 -10
  328. package/daemon/dist/domain/policies/mode-scheduled-end.js.map +1 -1
  329. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
  330. package/daemon/dist/domain/policies/parked-owner-consumer.js +3 -2
  331. package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
  332. package/daemon/dist/domain/policies/quiet-release.d.ts +19 -6
  333. package/daemon/dist/domain/policies/quiet-release.d.ts.map +1 -1
  334. package/daemon/dist/domain/policies/quiet-release.js +44 -7
  335. package/daemon/dist/domain/policies/quiet-release.js.map +1 -1
  336. package/daemon/dist/domain/proof/judgments.d.ts +11 -0
  337. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  338. package/daemon/dist/domain/proof/judgments.js +61 -38
  339. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  340. package/daemon/dist/domain/queue-blocker.d.ts +5 -0
  341. package/daemon/dist/domain/queue-blocker.d.ts.map +1 -0
  342. package/daemon/dist/domain/queue-blocker.js +12 -0
  343. package/daemon/dist/domain/queue-blocker.js.map +1 -0
  344. package/daemon/dist/domain/queue-erasure.d.ts +173 -0
  345. package/daemon/dist/domain/queue-erasure.d.ts.map +1 -0
  346. package/daemon/dist/domain/queue-erasure.js +885 -0
  347. package/daemon/dist/domain/queue-erasure.js.map +1 -0
  348. package/daemon/dist/domain/queue-owner.d.ts +6 -0
  349. package/daemon/dist/domain/queue-owner.d.ts.map +1 -1
  350. package/daemon/dist/domain/queue-owner.js +13 -4
  351. package/daemon/dist/domain/queue-owner.js.map +1 -1
  352. package/daemon/dist/domain/queue-repository.d.ts +160 -20
  353. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  354. package/daemon/dist/domain/queue-repository.js +449 -61
  355. package/daemon/dist/domain/queue-repository.js.map +1 -1
  356. package/daemon/dist/domain/queue-retention.d.ts +15 -1
  357. package/daemon/dist/domain/queue-retention.d.ts.map +1 -1
  358. package/daemon/dist/domain/queue-retention.js +35 -0
  359. package/daemon/dist/domain/queue-retention.js.map +1 -1
  360. package/daemon/dist/domain/queue-stuck-sweep.d.ts +17 -4
  361. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  362. package/daemon/dist/domain/queue-stuck-sweep.js +246 -92
  363. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  364. package/daemon/dist/domain/queue-transition-log.d.ts +5 -2
  365. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  366. package/daemon/dist/domain/queue-transition-log.js +30 -5
  367. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  368. package/daemon/dist/domain/queue-waiting.d.ts +48 -2
  369. package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
  370. package/daemon/dist/domain/queue-waiting.js +73 -13
  371. package/daemon/dist/domain/queue-waiting.js.map +1 -1
  372. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  373. package/daemon/dist/domain/queue-wake-ladder.js +79 -28
  374. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  375. package/daemon/dist/domain/rebuild-priming-chain.d.ts +3 -1
  376. package/daemon/dist/domain/rebuild-priming-chain.d.ts.map +1 -1
  377. package/daemon/dist/domain/rebuild-priming-chain.js +3 -1
  378. package/daemon/dist/domain/rebuild-priming-chain.js.map +1 -1
  379. package/daemon/dist/domain/refocus-record.d.ts +17 -0
  380. package/daemon/dist/domain/refocus-record.d.ts.map +1 -0
  381. package/daemon/dist/domain/refocus-record.js +94 -0
  382. package/daemon/dist/domain/refocus-record.js.map +1 -0
  383. package/daemon/dist/domain/restore-check-service.js +1 -1
  384. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  385. package/daemon/dist/domain/restore-guidance.d.ts.map +1 -1
  386. package/daemon/dist/domain/restore-guidance.js +5 -6
  387. package/daemon/dist/domain/restore-guidance.js.map +1 -1
  388. package/daemon/dist/domain/restore-orchestrator.d.ts +2 -0
  389. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  390. package/daemon/dist/domain/restore-orchestrator.js +39 -18
  391. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  392. package/daemon/dist/domain/restore-plan-preview.d.ts.map +1 -1
  393. package/daemon/dist/domain/restore-plan-preview.js +2 -1
  394. package/daemon/dist/domain/restore-plan-preview.js.map +1 -1
  395. package/daemon/dist/domain/resume-token-validation.d.ts +7 -0
  396. package/daemon/dist/domain/resume-token-validation.d.ts.map +1 -1
  397. package/daemon/dist/domain/resume-token-validation.js +13 -3
  398. package/daemon/dist/domain/resume-token-validation.js.map +1 -1
  399. package/daemon/dist/domain/rig-repository.js +3 -3
  400. package/daemon/dist/domain/rig-repository.js.map +1 -1
  401. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  402. package/daemon/dist/domain/rig-teardown.js +2 -1
  403. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  404. package/daemon/dist/domain/rigs-being-built.d.ts +5 -0
  405. package/daemon/dist/domain/rigs-being-built.d.ts.map +1 -0
  406. package/daemon/dist/domain/rigs-being-built.js +18 -0
  407. package/daemon/dist/domain/rigs-being-built.js.map +1 -0
  408. package/daemon/dist/domain/rigspec-instantiator.d.ts +3 -0
  409. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  410. package/daemon/dist/domain/rigspec-instantiator.js +32 -2
  411. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  412. package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
  413. package/daemon/dist/domain/rigspec-preflight.js +4 -1
  414. package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
  415. package/daemon/dist/domain/rigspec-schema.js +2 -2
  416. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  417. package/daemon/dist/domain/runner-permissions.d.ts +16 -0
  418. package/daemon/dist/domain/runner-permissions.d.ts.map +1 -1
  419. package/daemon/dist/domain/runner-permissions.js +95 -14
  420. package/daemon/dist/domain/runner-permissions.js.map +1 -1
  421. package/daemon/dist/domain/runtime-adapter.d.ts +1 -0
  422. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  423. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  424. package/daemon/dist/domain/scope/logical-checkbox.d.ts.map +1 -1
  425. package/daemon/dist/domain/scope/logical-checkbox.js +14 -0
  426. package/daemon/dist/domain/scope/logical-checkbox.js.map +1 -1
  427. package/daemon/dist/domain/seat-activity-service.d.ts +12 -0
  428. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  429. package/daemon/dist/domain/seat-activity-service.js +85 -4
  430. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  431. package/daemon/dist/domain/seat-handover-service.d.ts +7 -0
  432. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  433. package/daemon/dist/domain/seat-handover-service.js +23 -8
  434. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  435. package/daemon/dist/domain/seat-kinds.d.ts +21 -0
  436. package/daemon/dist/domain/seat-kinds.d.ts.map +1 -0
  437. package/daemon/dist/domain/seat-kinds.js +27 -0
  438. package/daemon/dist/domain/seat-kinds.js.map +1 -0
  439. package/daemon/dist/domain/seat-launch-environment.d.ts +4 -0
  440. package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
  441. package/daemon/dist/domain/seat-launch-environment.js +7 -6
  442. package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
  443. package/daemon/dist/domain/seat-lifecycle-service.d.ts +12 -0
  444. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  445. package/daemon/dist/domain/seat-lifecycle-service.js +52 -11
  446. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  447. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  448. package/daemon/dist/domain/seat-runtime-switch-service.js +23 -12
  449. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  450. package/daemon/dist/domain/seat-skill-apply.d.ts +2 -0
  451. package/daemon/dist/domain/seat-skill-apply.d.ts.map +1 -1
  452. package/daemon/dist/domain/seat-skill-apply.js +5 -2
  453. package/daemon/dist/domain/seat-skill-apply.js.map +1 -1
  454. package/daemon/dist/domain/seat-skill-storage.js +1 -1
  455. package/daemon/dist/domain/seat-skill-storage.js.map +1 -1
  456. package/daemon/dist/domain/seat-status-service.d.ts +10 -0
  457. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  458. package/daemon/dist/domain/seat-status-service.js +36 -2
  459. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  460. package/daemon/dist/domain/seat-structural-activity-service.d.ts +8 -0
  461. package/daemon/dist/domain/seat-structural-activity-service.d.ts.map +1 -1
  462. package/daemon/dist/domain/seat-structural-activity-service.js +8 -2
  463. package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
  464. package/daemon/dist/domain/session-jsonl.d.ts +4 -2
  465. package/daemon/dist/domain/session-jsonl.d.ts.map +1 -1
  466. package/daemon/dist/domain/session-jsonl.js +56 -22
  467. package/daemon/dist/domain/session-jsonl.js.map +1 -1
  468. package/daemon/dist/domain/session-registry.d.ts +20 -3
  469. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  470. package/daemon/dist/domain/session-registry.js +39 -3
  471. package/daemon/dist/domain/session-registry.js.map +1 -1
  472. package/daemon/dist/domain/session-transport.d.ts +28 -4
  473. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  474. package/daemon/dist/domain/session-transport.js +236 -56
  475. package/daemon/dist/domain/session-transport.js.map +1 -1
  476. package/daemon/dist/domain/slices/slice-indexer.d.ts +41 -0
  477. package/daemon/dist/domain/slices/slice-indexer.d.ts.map +1 -1
  478. package/daemon/dist/domain/slices/slice-indexer.js +463 -22
  479. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  480. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  481. package/daemon/dist/domain/startup-orchestrator.js +5 -2
  482. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  483. package/daemon/dist/domain/startup-submission-evidence.d.ts +1 -0
  484. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  485. package/daemon/dist/domain/startup-submission-evidence.js +18 -4
  486. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  487. package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -1
  488. package/daemon/dist/domain/terminal/herdr-adapter.js +3 -2
  489. package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -1
  490. package/daemon/dist/domain/terminal/herdr-app-install.d.ts +28 -0
  491. package/daemon/dist/domain/terminal/herdr-app-install.d.ts.map +1 -0
  492. package/daemon/dist/domain/terminal/herdr-app-install.js +170 -0
  493. package/daemon/dist/domain/terminal/herdr-app-install.js.map +1 -0
  494. package/daemon/dist/domain/terminal/herdr-app-layout.d.ts +79 -0
  495. package/daemon/dist/domain/terminal/herdr-app-layout.d.ts.map +1 -0
  496. package/daemon/dist/domain/terminal/herdr-app-layout.js +134 -0
  497. package/daemon/dist/domain/terminal/herdr-app-layout.js.map +1 -0
  498. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts +123 -0
  499. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts.map +1 -0
  500. package/daemon/dist/domain/terminal/herdr-app-provider.js +681 -0
  501. package/daemon/dist/domain/terminal/herdr-app-provider.js.map +1 -0
  502. package/daemon/dist/domain/terminal/herdr-app-state.d.ts +91 -0
  503. package/daemon/dist/domain/terminal/herdr-app-state.d.ts.map +1 -0
  504. package/daemon/dist/domain/terminal/herdr-app-state.js +140 -0
  505. package/daemon/dist/domain/terminal/herdr-app-state.js.map +1 -0
  506. package/daemon/dist/domain/terminal/herdr-app-transport.d.ts +68 -0
  507. package/daemon/dist/domain/terminal/herdr-app-transport.d.ts.map +1 -0
  508. package/daemon/dist/domain/terminal/herdr-app-transport.js +133 -0
  509. package/daemon/dist/domain/terminal/herdr-app-transport.js.map +1 -0
  510. package/daemon/dist/domain/terminal/terminal-provider.d.ts +18 -0
  511. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  512. package/daemon/dist/domain/terminal/terminal-service.d.ts +28 -3
  513. package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
  514. package/daemon/dist/domain/terminal/terminal-service.js +41 -8
  515. package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
  516. package/daemon/dist/domain/terminal/view-composer.d.ts.map +1 -1
  517. package/daemon/dist/domain/terminal/view-composer.js +1 -0
  518. package/daemon/dist/domain/terminal/view-composer.js.map +1 -1
  519. package/daemon/dist/domain/time-bound-advisory.js +3 -3
  520. package/daemon/dist/domain/time-bound-advisory.js.map +1 -1
  521. package/daemon/dist/domain/types.d.ts +51 -0
  522. package/daemon/dist/domain/types.d.ts.map +1 -1
  523. package/daemon/dist/domain/types.js.map +1 -1
  524. package/daemon/dist/domain/user-settings/settings-browser.d.ts +2 -1
  525. package/daemon/dist/domain/user-settings/settings-browser.d.ts.map +1 -1
  526. package/daemon/dist/domain/user-settings/settings-browser.js +22 -3
  527. package/daemon/dist/domain/user-settings/settings-browser.js.map +1 -1
  528. package/daemon/dist/domain/user-settings/settings-store.d.ts +1 -1
  529. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  530. package/daemon/dist/domain/user-settings/settings-store.js +35 -0
  531. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  532. package/daemon/dist/domain/wake-recovery.d.ts.map +1 -1
  533. package/daemon/dist/domain/wake-recovery.js +3 -2
  534. package/daemon/dist/domain/wake-recovery.js.map +1 -1
  535. package/daemon/dist/domain/whoami-service.d.ts +6 -0
  536. package/daemon/dist/domain/whoami-service.d.ts.map +1 -1
  537. package/daemon/dist/domain/whoami-service.js +9 -1
  538. package/daemon/dist/domain/whoami-service.js.map +1 -1
  539. package/daemon/dist/domain/workflow-projector.js +1 -1
  540. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  541. package/daemon/dist/domain/workflow-runtime.js +4 -4
  542. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  543. package/daemon/dist/domain/workflow-spec-cache.d.ts +14 -0
  544. package/daemon/dist/domain/workflow-spec-cache.d.ts.map +1 -1
  545. package/daemon/dist/domain/workflow-spec-cache.js +28 -7
  546. package/daemon/dist/domain/workflow-spec-cache.js.map +1 -1
  547. package/daemon/dist/index.d.ts +2 -1
  548. package/daemon/dist/index.d.ts.map +1 -1
  549. package/daemon/dist/index.js +9 -1
  550. package/daemon/dist/index.js.map +1 -1
  551. package/daemon/dist/lib/pane-envelope.d.ts +3 -0
  552. package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
  553. package/daemon/dist/lib/pane-envelope.js +3 -1
  554. package/daemon/dist/lib/pane-envelope.js.map +1 -1
  555. package/daemon/dist/routes/activity.d.ts.map +1 -1
  556. package/daemon/dist/routes/activity.js +110 -23
  557. package/daemon/dist/routes/activity.js.map +1 -1
  558. package/daemon/dist/routes/attention.d.ts.map +1 -1
  559. package/daemon/dist/routes/attention.js +2 -0
  560. package/daemon/dist/routes/attention.js.map +1 -1
  561. package/daemon/dist/routes/config.d.ts.map +1 -1
  562. package/daemon/dist/routes/config.js +9 -1
  563. package/daemon/dist/routes/config.js.map +1 -1
  564. package/daemon/dist/routes/events.js +7 -2
  565. package/daemon/dist/routes/events.js.map +1 -1
  566. package/daemon/dist/routes/gateway.d.ts.map +1 -1
  567. package/daemon/dist/routes/gateway.js +34 -5
  568. package/daemon/dist/routes/gateway.js.map +1 -1
  569. package/daemon/dist/routes/hosts.d.ts.map +1 -1
  570. package/daemon/dist/routes/hosts.js +146 -46
  571. package/daemon/dist/routes/hosts.js.map +1 -1
  572. package/daemon/dist/routes/provider.js +1 -1
  573. package/daemon/dist/routes/provider.js.map +1 -1
  574. package/daemon/dist/routes/queue.d.ts +19 -0
  575. package/daemon/dist/routes/queue.d.ts.map +1 -1
  576. package/daemon/dist/routes/queue.js +232 -43
  577. package/daemon/dist/routes/queue.js.map +1 -1
  578. package/daemon/dist/routes/skills.d.ts.map +1 -1
  579. package/daemon/dist/routes/skills.js +8 -2
  580. package/daemon/dist/routes/skills.js.map +1 -1
  581. package/daemon/dist/routes/slices.d.ts.map +1 -1
  582. package/daemon/dist/routes/slices.js +156 -28
  583. package/daemon/dist/routes/slices.js.map +1 -1
  584. package/daemon/dist/routes/terminal.d.ts.map +1 -1
  585. package/daemon/dist/routes/terminal.js +40 -3
  586. package/daemon/dist/routes/terminal.js.map +1 -1
  587. package/daemon/dist/routes/transport.d.ts.map +1 -1
  588. package/daemon/dist/routes/transport.js +0 -1
  589. package/daemon/dist/routes/transport.js.map +1 -1
  590. package/daemon/dist/startup.d.ts +34 -0
  591. package/daemon/dist/startup.d.ts.map +1 -1
  592. package/daemon/dist/startup.js +190 -10
  593. package/daemon/dist/startup.js.map +1 -1
  594. package/daemon/docs/reference/agent-spec.md +2 -4
  595. package/daemon/docs/reference/agent-startup-guide.md +24 -2
  596. package/daemon/docs/reference/community-harness-examples/omo/omo.yaml +14 -0
  597. package/daemon/docs/reference/community-harness-presets.md +56 -2
  598. package/daemon/docs/reference/daemon-http-clients.md +15 -1
  599. package/daemon/docs/reference/edge-types.md +6 -4
  600. package/daemon/docs/reference/gateway-participants.md +19 -0
  601. package/daemon/docs/reference/gateway-relay.md +41 -12
  602. package/daemon/docs/reference/getting-started.md +18 -3
  603. package/daemon/docs/reference/harness-runner-contract.md +61 -12
  604. package/daemon/docs/reference/health-diagnosis.md +5 -1
  605. package/daemon/docs/reference/help.md +18 -0
  606. package/daemon/docs/reference/herdr-app.md +148 -0
  607. package/daemon/docs/reference/hosted-members.md +19 -7
  608. package/daemon/docs/reference/keeping-a-watch.md +3 -1
  609. package/daemon/docs/reference/queue-erasure.md +161 -0
  610. package/daemon/docs/reference/quickstart.md +1 -1
  611. package/daemon/docs/reference/rig-spec.md +15 -9
  612. package/daemon/docs/reference/runner-conformance/README.md +3 -0
  613. package/daemon/docs/reference/runner-conformance/check-runner.mjs +27 -6
  614. package/daemon/docs/reference/runner-conformance/fake-acp-agent.mjs +1 -1
  615. package/daemon/docs/reference/sdlc-conventions.md +16 -1
  616. package/daemon/docs/reference/seat-delivery.md +10 -3
  617. package/daemon/docs/reference/slack-app-setup.md +37 -12
  618. package/daemon/docs/reference/terminal-sessions.md +28 -15
  619. package/daemon/docs/reference/tmux-servers.md +2 -2
  620. package/daemon/docs/reference/whats-new.md +141 -121
  621. package/daemon/specs/agents/shared/skills/core/openrig-herdr/SKILL.md +1 -0
  622. package/daemon/specs/agents/shared/skills/pods/review-team/SKILL.md +2 -0
  623. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +24 -0
  624. package/daemon/specs/rigs/launch/kernel/culture/CULTURE.md +7 -4
  625. package/daemon/specs/rigs/launch/kernel/rig.yaml +6 -3
  626. package/daemon/specs/rigs/launch/starter/guidance/lead-first-move.md +3 -1
  627. package/dist/build-info.js +3 -3
  628. package/dist/client.js +2 -2
  629. package/dist/client.js.map +1 -1
  630. package/dist/commands/config.d.ts.map +1 -1
  631. package/dist/commands/config.js +11 -1
  632. package/dist/commands/config.js.map +1 -1
  633. package/dist/commands/context.d.ts.map +1 -1
  634. package/dist/commands/context.js +44 -4
  635. package/dist/commands/context.js.map +1 -1
  636. package/dist/commands/daemon.d.ts.map +1 -1
  637. package/dist/commands/daemon.js +17 -3
  638. package/dist/commands/daemon.js.map +1 -1
  639. package/dist/commands/gateway.d.ts.map +1 -1
  640. package/dist/commands/gateway.js +21 -4
  641. package/dist/commands/gateway.js.map +1 -1
  642. package/dist/commands/host.d.ts.map +1 -1
  643. package/dist/commands/host.js +10 -1
  644. package/dist/commands/host.js.map +1 -1
  645. package/dist/commands/launch.d.ts +1 -0
  646. package/dist/commands/launch.d.ts.map +1 -1
  647. package/dist/commands/launch.js +1 -1
  648. package/dist/commands/launch.js.map +1 -1
  649. package/dist/commands/proof.d.ts.map +1 -1
  650. package/dist/commands/proof.js +18 -6
  651. package/dist/commands/proof.js.map +1 -1
  652. package/dist/commands/provider.js +1 -1
  653. package/dist/commands/ps.d.ts +9 -1
  654. package/dist/commands/ps.d.ts.map +1 -1
  655. package/dist/commands/ps.js +23 -2
  656. package/dist/commands/ps.js.map +1 -1
  657. package/dist/commands/queue.d.ts.map +1 -1
  658. package/dist/commands/queue.js +226 -8
  659. package/dist/commands/queue.js.map +1 -1
  660. package/dist/commands/scope.d.ts +2 -0
  661. package/dist/commands/scope.d.ts.map +1 -1
  662. package/dist/commands/scope.js +15 -0
  663. package/dist/commands/scope.js.map +1 -1
  664. package/dist/commands/seat.d.ts.map +1 -1
  665. package/dist/commands/seat.js +64 -10
  666. package/dist/commands/seat.js.map +1 -1
  667. package/dist/commands/send.d.ts +2 -0
  668. package/dist/commands/send.d.ts.map +1 -1
  669. package/dist/commands/send.js +16 -6
  670. package/dist/commands/send.js.map +1 -1
  671. package/dist/commands/setup.js +1 -1
  672. package/dist/commands/setup.js.map +1 -1
  673. package/dist/commands/skill.d.ts.map +1 -1
  674. package/dist/commands/skill.js +5 -0
  675. package/dist/commands/skill.js.map +1 -1
  676. package/dist/commands/slack.d.ts +1 -1
  677. package/dist/commands/slack.d.ts.map +1 -1
  678. package/dist/commands/slack.js +5 -1
  679. package/dist/commands/slack.js.map +1 -1
  680. package/dist/commands/status.d.ts.map +1 -1
  681. package/dist/commands/status.js +11 -1
  682. package/dist/commands/status.js.map +1 -1
  683. package/dist/commands/terminal.d.ts +22 -0
  684. package/dist/commands/terminal.d.ts.map +1 -1
  685. package/dist/commands/terminal.js +116 -7
  686. package/dist/commands/terminal.js.map +1 -1
  687. package/dist/commands/up.d.ts.map +1 -1
  688. package/dist/commands/up.js +22 -0
  689. package/dist/commands/up.js.map +1 -1
  690. package/dist/commands/whoami.d.ts.map +1 -1
  691. package/dist/commands/whoami.js +13 -2
  692. package/dist/commands/whoami.js.map +1 -1
  693. package/dist/commands/workflow-errors.js +1 -1
  694. package/dist/commands/workflow-errors.js.map +1 -1
  695. package/dist/commands/workflow.js +1 -1
  696. package/dist/commands/workflow.js.map +1 -1
  697. package/dist/config-store.d.ts +8 -1
  698. package/dist/config-store.d.ts.map +1 -1
  699. package/dist/config-store.js +60 -0
  700. package/dist/config-store.js.map +1 -1
  701. package/dist/daemon-start-lock.d.ts +24 -2
  702. package/dist/daemon-start-lock.d.ts.map +1 -1
  703. package/dist/daemon-start-lock.js +125 -4
  704. package/dist/daemon-start-lock.js.map +1 -1
  705. package/dist/lib/scope/logical-checkbox.d.ts.map +1 -1
  706. package/dist/lib/scope/logical-checkbox.js +14 -0
  707. package/dist/lib/scope/logical-checkbox.js.map +1 -1
  708. package/dist/lib/scope/scope-fs.d.ts.map +1 -1
  709. package/dist/lib/scope/scope-fs.js +36 -2
  710. package/dist/lib/scope/scope-fs.js.map +1 -1
  711. package/dist/mcp-server.d.ts.map +1 -1
  712. package/dist/mcp-server.js +49 -8
  713. package/dist/mcp-server.js.map +1 -1
  714. package/dist/recap-seat.d.ts +28 -0
  715. package/dist/recap-seat.d.ts.map +1 -0
  716. package/dist/recap-seat.js +41 -0
  717. package/dist/recap-seat.js.map +1 -0
  718. package/dist/seat-attention.d.ts +24 -0
  719. package/dist/seat-attention.d.ts.map +1 -0
  720. package/dist/seat-attention.js +119 -0
  721. package/dist/seat-attention.js.map +1 -0
  722. package/dist/terminal-window.d.ts.map +1 -1
  723. package/dist/terminal-window.js +3 -3
  724. package/dist/terminal-window.js.map +1 -1
  725. package/package.json +1 -1
  726. package/tui/dist/attention/attention-model.d.ts.map +1 -1
  727. package/tui/dist/attention/attention-model.js +3 -0
  728. package/tui/dist/attention/attention-model.js.map +1 -1
  729. package/tui/dist/config/config-model.d.ts.map +1 -1
  730. package/tui/dist/config/config-model.js +6 -1
  731. package/tui/dist/config/config-model.js.map +1 -1
  732. package/tui/dist/config/pairing.d.ts +49 -0
  733. package/tui/dist/config/pairing.d.ts.map +1 -0
  734. package/tui/dist/config/pairing.js +98 -0
  735. package/tui/dist/config/pairing.js.map +1 -0
  736. package/tui/dist/daemon-client.d.ts +11 -1
  737. package/tui/dist/daemon-client.d.ts.map +1 -1
  738. package/tui/dist/daemon-client.js +18 -5
  739. package/tui/dist/daemon-client.js.map +1 -1
  740. package/tui/dist/detail.d.ts +3 -0
  741. package/tui/dist/detail.d.ts.map +1 -1
  742. package/tui/dist/detail.js +6 -1
  743. package/tui/dist/detail.js.map +1 -1
  744. package/tui/dist/execution/execution-model.d.ts +2 -0
  745. package/tui/dist/execution/execution-model.d.ts.map +1 -1
  746. package/tui/dist/execution/execution-model.js +10 -3
  747. package/tui/dist/execution/execution-model.js.map +1 -1
  748. package/tui/dist/health/health-model.d.ts.map +1 -1
  749. package/tui/dist/health/health-model.js +27 -11
  750. package/tui/dist/health/health-model.js.map +1 -1
  751. package/tui/dist/hydrate.d.ts.map +1 -1
  752. package/tui/dist/hydrate.js +4 -2
  753. package/tui/dist/hydrate.js.map +1 -1
  754. package/tui/dist/main.js +6 -1
  755. package/tui/dist/main.js.map +1 -1
  756. package/tui/dist/scopes/scopes-model.d.ts +9 -0
  757. package/tui/dist/scopes/scopes-model.d.ts.map +1 -1
  758. package/tui/dist/scopes/scopes-model.js +27 -1
  759. package/tui/dist/scopes/scopes-model.js.map +1 -1
  760. package/tui/dist/state.d.ts.map +1 -1
  761. package/tui/dist/state.js +4 -3
  762. package/tui/dist/state.js.map +1 -1
  763. package/tui/dist/terminals/open-window.d.ts +21 -1
  764. package/tui/dist/terminals/open-window.d.ts.map +1 -1
  765. package/tui/dist/terminals/open-window.js +46 -9
  766. package/tui/dist/terminals/open-window.js.map +1 -1
  767. package/tui/dist/terminals/terminal-model.d.ts +8 -1
  768. package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
  769. package/tui/dist/terminals/terminal-model.js +25 -8
  770. package/tui/dist/terminals/terminal-model.js.map +1 -1
  771. package/tui/dist/types.d.ts +18 -2
  772. package/tui/dist/types.d.ts.map +1 -1
@@ -3,6 +3,11 @@ import { withUrgentLine } from "./urgent-line.js";
3
3
  import { quietCustodyBackstop, quietHoldCustody } from "./quiet-hold-custody.js";
4
4
  import { createHash } from "node:crypto";
5
5
  import { loadHumanRegistry, registeredPeople, resolveRegisteredHumanAddress, slackSubscriptionFor, withHumanAlertTag } from "./gateway/human-registry.js";
6
+ import { DispatchBuffer } from "./gateway/dispatch-buffer.js";
7
+ import { loadRelayProfiles } from "./gateway/relay-config.js";
8
+ import { relayStatePaths, validateRelayOutboundEnvelope } from "./gateway/relay-outbound.js";
9
+ import { SeenStore } from "./gateway/slack/state-store.js";
10
+ import { getOpenRigHome } from "../openrig-compat.js";
6
11
  import { sharedChannelAddresses } from "./gateway/participants.js";
7
12
  import { resolveExternal } from "./gateway/external-admission.js";
8
13
  import { QueueTransitionLog, RELAY_OWNER_NOTIFICATION_ACCEPTED_PREFIX, RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX, formatRelayOwnerNotificationAccepted, formatRelayOwnerNotificationTransportFailed, parseRelayOwnerNotificationAccepted, parseRelayOwnerNotificationTransportFailed, } from "./queue-transition-log.js";
@@ -15,7 +20,9 @@ import { WAKE_INTENT_PREFIX } from "./outbox-handler.js";
15
20
  import { physicalSessionName } from "./session-registry.js";
16
21
  import { derivePickup } from "./queue-pickup.js";
17
22
  import { withRecoveryIndex } from "./queue-recovery.js";
18
- import { lastMeaningfulTransition, readWaitingView } from "./queue-waiting.js";
23
+ import { lastMeaningfulTransitionMany, meaningfulFor, readWaitingView, WaitingStatements } from "./queue-waiting.js";
24
+ import { isTypedGateBlocker, typedGateBlockerPrefix } from "./queue-blocker.js";
25
+ export { TYPED_GATE_BLOCKER_PREFIXES, isTypedGateBlocker, typedGateBlockerPrefix } from "./queue-blocker.js";
19
26
  import { isOpenRigSender, OPENRIG_SENDER, wrapPaneEnvelope } from "../lib/pane-envelope.js";
20
27
  import { isBoundTerminalSeat } from "./terminal-seat.js";
21
28
  import { renderQueueHandoffNudge } from "./queue-nudge-text.js";
@@ -28,7 +35,7 @@ import { classifyDestination } from "./gateway/destination-resolver.js";
28
35
  import { join } from "node:path";
29
36
  import { SettingsStore } from "./user-settings/settings-store.js";
30
37
  import { hostedWakeFor, isHostedMemberAt } from "./rosters.js";
31
- import { ringHostedWake } from "./hosted-wake.js";
38
+ import { hostedRingMayHaveArrived, ringHostedWake } from "./hosted-wake.js";
32
39
  import { effectiveGateRoles } from "./gate-predicate.js";
33
40
  import { computeClosureRequiredAt, validateClosure, } from "./hot-potato-enforcer.js";
34
41
  import { validateHumanPark, validateHumanRoute } from "./human-route-enforcer.js";
@@ -99,22 +106,8 @@ const HOSTED_WAKE_ACCEPTED_TAG = "queue:hosted-wake-accepted";
99
106
  const AUTO_UNPARK_BLOCKER_TAG_PREFIX = "queue:auto-unpark:blocker-ref:";
100
107
  /** The actor on the transition routeToFallback writes; the row's own history is how a later reroute finds the line it wrote. */
101
108
  const FALLBACK_ACTOR = "system:queue-fallback";
102
- /** 0.5.1-53 Atom 1a — typed non-qitem gate blocker prefixes. A park may be gated on a fold / auth /
103
- * external condition that is NOT a qitem and NOT a human seat; these prefixes make such a gate a
104
- * first-class, compact-visible, downstream-classifiable blocker (the ruling detail rides a transition). */
105
- export const TYPED_GATE_BLOCKER_PREFIXES = ["fold:", "auth:", "external:"];
106
109
  /** The actor a terminal act is recorded as when it names no responder: explicitly unattributed, never a person. */
107
110
  export const UNATTRIBUTED_ACTOR = "human@host";
108
- export function typedGateBlockerPrefix(value) {
109
- return TYPED_GATE_BLOCKER_PREFIXES.find((p) => value.startsWith(p)) ?? null;
110
- }
111
- /** A well-formed typed gate blocker: a recognized prefix AND a non-empty gate body. */
112
- export function isTypedGateBlocker(value) {
113
- if (typeof value !== "string")
114
- return false;
115
- const p = typedGateBlockerPrefix(value);
116
- return p != null && value.slice(p.length).trim().length > 0;
117
- }
118
111
  /**
119
112
  * #165: a claim is the destination acting on the row, which is stronger evidence than
120
113
  * the wake send could get. While the row is claimed, an unconfirmed wire result
@@ -202,6 +195,8 @@ function defaultIsHostedMember(destination) {
202
195
  return false;
203
196
  }
204
197
  }
198
+ /** A session's check-in is written at most this often; the stuck sweep reads it in units of its unclaimed age. */
199
+ const INBOX_CHECKIN_WRITE_INTERVAL_MS = 60_000;
205
200
  export class QueueRepositoryError extends Error {
206
201
  code;
207
202
  meta;
@@ -312,11 +307,15 @@ let successorScope = null;
312
307
  * equals a text id); has() then checks qitem_id or destination_session against the target and that the successor is
313
308
  * not the source itself. A snapshot from its first has() until invalidate(): the caller invalidates it whenever other
314
309
  * 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. */
310
+ * for a covered source; any other source keeps the per-row query. builtMs() is how long the build of the index as it
311
+ * is now took (0 while it is not built), so a caller can tell when rebuilding after each invalidate() costs more than
312
+ * it saves. */
316
313
  export function createLinkedSuccessorLookup(db, sourceQitemIds) {
317
314
  const sources = new Set(sourceQitemIds);
318
315
  let bySource = null;
316
+ let buildMs = 0;
319
317
  const build = () => {
318
+ const startedAt = performance.now();
320
319
  const map = new Map();
321
320
  const ids = JSON.stringify([...sources]);
322
321
  const rows = db.prepare(`SELECT s.qitem_id, s.destination_session, s.handed_off_from AS source FROM queue_items s
@@ -333,6 +332,7 @@ export function createLinkedSuccessorLookup(db, sourceQitemIds) {
333
332
  else
334
333
  map.set(r.source, [entry]);
335
334
  }
335
+ buildMs = performance.now() - startedAt;
336
336
  return map;
337
337
  };
338
338
  const has = (sourceQitemId, target) => (bySource ??= build()).get(sourceQitemId)?.some((s) => s.qitemId !== sourceQitemId && (s.qitemId === target || s.destination === target)) ?? false;
@@ -351,7 +351,8 @@ export function createLinkedSuccessorLookup(db, sourceQitemIds) {
351
351
  successorScope = previous;
352
352
  }
353
353
  },
354
- invalidate: () => { bySource = null; },
354
+ invalidate: () => { bySource = null; buildMs = 0; },
355
+ builtMs: () => buildMs,
355
356
  };
356
357
  }
357
358
  /** PL-007 — defensive column probe. Older test fixtures bypass the
@@ -538,6 +539,7 @@ export class QueueRepository {
538
539
  promptRecoveryState = new Map();
539
540
  promptClearRetries = new Map();
540
541
  resolveOccupantGeneration;
542
+ isSenderSendable;
541
543
  resolveSessionAddresses;
542
544
  hasPendingPostCompactStage;
543
545
  wakeRepo;
@@ -557,6 +559,7 @@ export class QueueRepository {
557
559
  hasMintingGenColumn;
558
560
  hasClaimedGenColumn;
559
561
  hasQueueTransitionsTable;
562
+ hasErasedIdsTable;
560
563
  hasTransitionProvenanceColumn;
561
564
  hasOwnerNotificationColumns;
562
565
  loadHumanRegistryFn;
@@ -566,7 +569,11 @@ export class QueueRepository {
566
569
  hostedWakeFn;
567
570
  /** Whether the rosters list an address as a hosted member, trigger or not. */
568
571
  hostedMemberFn;
572
+ permissionDecider;
569
573
  hostedWakeFetch;
574
+ /** When this process last wrote each session's inbox check-in, so a seat that polls often writes at most once a minute. */
575
+ inboxCheckInWrittenAt = new Map();
576
+ inboxCheckInWriteFailed = false;
570
577
  /** OPR.0.4.6.WF3 FR-6 — injected by startup (never imported): the
571
578
  * workflow domain's is-live-frontier-packet predicate. */
572
579
  workflowFrontierPredicate;
@@ -581,12 +588,14 @@ export class QueueRepository {
581
588
  this.attachTransport(opts.transport);
582
589
  this.workflowFrontierPredicate = opts?.workflowFrontierPredicate;
583
590
  this.resolveOccupantGeneration = opts?.resolveOccupantGeneration;
591
+ this.isSenderSendable = opts?.isSenderSendable;
584
592
  this.resolveSessionAddresses = opts?.resolveSessionAddresses ?? ((name) => [name]);
585
593
  this.hasPendingPostCompactStage = opts?.hasPendingPostCompactStage;
586
594
  this.loadHumanRegistryFn = opts?.loadHumanRegistry ?? (() => loadHumanRegistry());
587
595
  this.sharedChannelsFn = opts?.sharedChannels ?? (() => sharedChannelAddresses());
588
596
  this.hostedWakeFn = opts?.hostedWake ?? defaultHostedWake;
589
597
  this.hostedMemberFn = opts?.isHostedMember ?? defaultIsHostedMember;
598
+ this.permissionDecider = opts?.permissionDecider;
590
599
  this.hostedWakeFetch = opts?.hostedWakeFetch;
591
600
  this.hasTargetRepoColumn = detectQueueColumn(db, "target_repo");
592
601
  this.hasSummaryColumn = detectQueueColumn(db, "summary");
@@ -596,6 +605,7 @@ export class QueueRepository {
596
605
  this.hasDelegatedDecisionColumn = detectQueueColumn(db, "delegated_decision");
597
606
  this.hasEvidenceRefColumn = detectQueueColumn(db, "evidence_ref");
598
607
  this.hasQueueTransitionsTable = detectTable(db, "queue_transitions");
608
+ this.hasErasedIdsTable = detectTable(db, "queue_erased_ids");
599
609
  const transitionColumns = this.hasQueueTransitionsTable
600
610
  ? new Set(db.prepare("PRAGMA table_info(queue_transitions)").all().map((column) => column.name))
601
611
  : new Set();
@@ -827,6 +837,10 @@ export class QueueRepository {
827
837
  this.recordNudgeAttempt(successorQitemId, `${WAKE_NOT_RETAINED}${err.message}`);
828
838
  }
829
839
  }
840
+ /** #2895 (a): the envelope meta for a sender `rig send` can't reach; empty (today's bytes) otherwise or when unwired. */
841
+ senderReach(sender) {
842
+ return sender && this.isSenderSendable && !this.isSenderSendable(sender) ? { senderReachable: false } : {};
843
+ }
830
844
  recordWakeIntent(input) {
831
845
  if (!this.outbox)
832
846
  return null;
@@ -834,7 +848,7 @@ export class QueueRepository {
834
848
  // recovery replay these exact bytes without re-resolving the occupant.
835
849
  const stampISO = new Date().toISOString();
836
850
  const genUuid = this.resolveOccupantGeneration?.(input.fromSession) ?? undefined;
837
- const frozenEnvelope = wrapPaneEnvelope(input.fromSession, input.toSession, input.bareBody, { stampISO, genUuid, ...(input.qitemId ? { replyToQitem: input.qitemId } : {}) });
851
+ const frozenEnvelope = wrapPaneEnvelope(input.fromSession, input.toSession, input.bareBody, { stampISO, genUuid, ...(input.qitemId ? { replyToQitem: input.qitemId } : {}), ...this.senderReach(input.fromSession) });
838
852
  const admission = this.wakeAdmission(input.auditPointer, input.tags?.includes(WAKE_TRIGGER_OPENRIG_TAG) ? "openrig" : "agent");
839
853
  // An urgent wake's frozen body carries the line naming who marked it, so a person reading it held sees it too; the
840
854
  // transport won't add it a second time when it's delivered.
@@ -919,6 +933,23 @@ export class QueueRepository {
919
933
  * hold is left alone; failed/uncertain history permits another attempt. A recovery
920
934
  * pass tracks its coalesced members only in memory so each is attempted once per pass.
921
935
  */
936
+ /** #2789: a wake committed while its seat had no pane froze a binding that can never match once the seat is bound, so
937
+ * the delivery guard refused it on every retry. Such an intent takes its first live binding, on the same node and
938
+ * canonical session, only when it is known to have written no input (pending, or failed, which a send records only
939
+ * without a write) and carries no expected identity of its own. A binding that ever named a pane is never replaced,
940
+ * so a wake can't move to another occupant; the guard's write-time check against this binding still holds.
941
+ * `entry` is the intent as read before its claim. Called inside the claim's transaction. */
942
+ bindFirstTarget(entry) {
943
+ const frozen = entry.guardBinding;
944
+ if (!frozen || frozen.pane !== null || (entry.deliveryState !== "pending" && entry.deliveryState !== "failed"))
945
+ return;
946
+ if (this.outbox.expectedIdentity(entry.outboxId))
947
+ return;
948
+ const live = this.transport?.deliveryTarget?.(entry.destinationSession);
949
+ if (!live?.pane || live.nodeId !== frozen.nodeId || live.session !== frozen.session)
950
+ return;
951
+ this.db.prepare("UPDATE outbox_entries SET guard_binding = ? WHERE outbox_id = ?").run(JSON.stringify(live), entry.outboxId);
952
+ }
922
953
  async deliverWakeIntent(outboxId, attempted = new Set(), // this pass's attempt history, inherited by any release it delivers
923
954
  eligible = () => true) {
924
955
  if (!this.outbox)
@@ -937,6 +968,7 @@ export class QueueRepository {
937
968
  const claim = (entry) => {
938
969
  if (!eligible(entry) || attempted.has(entry.outboxId) || !this.outbox.claimForDelivery(entry.outboxId))
939
970
  return false;
971
+ this.bindFirstTarget(entry);
940
972
  attempted.add(entry.outboxId);
941
973
  recovering ||= entry.deliveryState !== "pending";
942
974
  return true;
@@ -1008,8 +1040,8 @@ export class QueueRepository {
1008
1040
  // The level can change while this send waits for the seat's lease. Under the lease, each member is admitted again with
1009
1041
  // its own source and urgency; only those with the first member's outcome go with this send, and the others go back
1010
1042
  // to their state before this claim (never marked delivered, held or failed) for their own delivery.
1011
- // A hosted member's trigger already accepted the ring for exactly these intents (tagged below): recovery doesn't ring
1012
- // it again, since each ring can start a run. Any other wake rings: a new intent, or one claimed but never sent.
1043
+ // A hosted member's trigger already accepted the ring for exactly these intents, or may have before it stopped
1044
+ // answering (tagged below): recovery doesn't ring it again, since each ring can start a run. Any other wake rings: a new intent, or one claimed but never sent.
1013
1045
  if (group.every((entry) => entry.tags?.includes(HOSTED_WAKE_ACCEPTED_TAG))) {
1014
1046
  for (const entry of group)
1015
1047
  this.outbox.finalizeDelivery(entry.outboxId, "indeterminate");
@@ -1052,8 +1084,8 @@ export class QueueRepository {
1052
1084
  const wakeEvent = this.db.transaction(() => {
1053
1085
  this.recordNudgeAttempt(qitemId, nudgeResult);
1054
1086
  this.outbox.finalizeDelivery(intent.outboxId, finalState);
1055
- // The acceptance belongs to this intent, so recovery can tell this wake already rang.
1056
- if (outcome.nudgeResult.startsWith("wake-accepted:")) {
1087
+ // The acceptance (or a ring that may have arrived) belongs to this intent, so recovery can tell this wake already rang.
1088
+ if (hostedRingMayHaveArrived(outcome.nudgeResult)) {
1057
1089
  this.db.prepare(`UPDATE outbox_entries SET tags = json_insert(COALESCE(tags, '[]'), '$[#]', ?)
1058
1090
  WHERE outbox_id = ? AND NOT EXISTS (SELECT 1 FROM json_each(COALESCE(outbox_entries.tags, '[]')) WHERE value = ?)`)
1059
1091
  .run(HOSTED_WAKE_ACCEPTED_TAG, intent.outboxId, HOSTED_WAKE_ACCEPTED_TAG);
@@ -1123,9 +1155,10 @@ export class QueueRepository {
1123
1155
  /** Recover current notifications once per pass. A snapshot horizon and seek cursor
1124
1156
  * prevent new arrivals or persistent failures from making this pass unbounded. `stopRequested` is checked before
1125
1157
  * 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. */
1158
+ * A notification already tried for a seat that still has no session or transport, or that is a bound terminal seat,
1159
+ * would only fail again, so it isn't claimed, alone or in a group: it stays as it is, its row stays owed, and the
1160
+ * pass reports it as waiting. The receiver is read at each claim, so a seat that starts during the pass gets its
1161
+ * later notifications. */
1129
1162
  async drainPendingWakeIntents(opts) {
1130
1163
  const tally = { delivered: 0, indeterminate: 0, failed: 0, retained: 0 };
1131
1164
  if (!this.outbox || !this.transport)
@@ -1186,9 +1219,11 @@ export class QueueRepository {
1186
1219
  }
1187
1220
  return result();
1188
1221
  }
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. */
1222
+ /** Positive evidence only that a wake can't land now: no transport can hold the address, the address is a bound
1223
+ * terminal seat (a shell or a TUI: performWakeSend types nothing there, so a retry can only fail the same way and
1224
+ * move the row's last nudge time, which the stuck sweep reads as new evidence; #2939), or the newest session under
1225
+ * the name the transport sends to has stopped (exited, or detached because its tmux session is gone). A canonical
1226
+ * address resolves to its current physical session first. Anything unknown may have a receiver. */
1192
1227
  wakeHasNoReceiver(destinationSession) {
1193
1228
  try {
1194
1229
  const destClass = this.classifyDestinationOf(destinationSession).class;
@@ -1196,8 +1231,11 @@ export class QueueRepository {
1196
1231
  return true;
1197
1232
  if (destClass !== "pane-bound")
1198
1233
  return false;
1234
+ const physical = physicalSessionName(this.db, destinationSession);
1235
+ if (isBoundTerminalSeat(this.db, destinationSession) || isBoundTerminalSeat(this.db, physical))
1236
+ return true;
1199
1237
  const newest = this.db.prepare("SELECT status FROM sessions WHERE session_name = ? ORDER BY id DESC LIMIT 1")
1200
- .get(physicalSessionName(this.db, destinationSession));
1238
+ .get(physical);
1201
1239
  return newest?.status === "exited" || newest?.status === "detached";
1202
1240
  }
1203
1241
  catch {
@@ -1318,6 +1356,66 @@ export class QueueRepository {
1318
1356
  }
1319
1357
  }
1320
1358
  }
1359
+ /** The rule for re-sending a wake recorded unroutable once its seat may be back, shared by the stuck sweep and
1360
+ * {@link retryUnroutableWakesOnReachable}: unclaimed, not a person's notice, not a local human decision with no
1361
+ * gateway, not held or released for quiet hours, and its seat now pane-bound. A handoff's retry ladder is the
1362
+ * caller's to check: the sweep defers to a live ladder, the reachable-seat retry leaves every handed-off row to it. */
1363
+ unroutableWakeRetryable(row, now = new Date()) {
1364
+ return row.lastNudgeResult?.startsWith("unroutable:") === true
1365
+ && !row.claimedAt
1366
+ && row.deliveryOutcome !== "never-posted" && row.deliveryOutcome !== "transport-failed"
1367
+ && !this.isLocalHumanDecisionWithoutGateway(row)
1368
+ && !["held", "released"].includes(quietHoldCustody(this.db, row.qitemId, now)?.state ?? "")
1369
+ && this.classifyDestinationOf(row.destinationSession).class === "pane-bound";
1370
+ }
1371
+ /** A wake recorded unroutable because its seat wasn't bound yet, as just after a restart (#2789), is re-sent as soon
1372
+ * as the seat is seen running or idle, rather than at the stuck sweep's next tick; the sweep remains the backstop.
1373
+ * Only this seat's own pending rows, oldest first, that {@link unroutableWakeRetryable} admits. */
1374
+ async retryUnroutableWakesOnReachable(sessionName, state) {
1375
+ if (state !== "running" && state !== "idle")
1376
+ return;
1377
+ const addresses = this.resolveSessionAddresses(sessionName);
1378
+ if (!addresses.length)
1379
+ return;
1380
+ // As for a prompt clear (#2575): while a compaction's restore is owed, the wake would reach the agent before it.
1381
+ if ([sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address)))
1382
+ return;
1383
+ const rows = this.db.prepare(`SELECT qitem_id FROM queue_items
1384
+ WHERE destination_session IN (${addresses.map(() => "?").join(",")}) AND state = 'pending'
1385
+ AND handed_off_from IS NULL AND last_nudge_result LIKE 'unroutable:%' ORDER BY ts_created, qitem_id`)
1386
+ .all(...addresses);
1387
+ const now = new Date();
1388
+ // One attempt per intent for the pass: a returned result and its resume go as one send, so the second row's turn
1389
+ // mustn't send them again after a refusal.
1390
+ const attempted = new Set();
1391
+ // Correlation can add peers to a send. Each claim must qualify for this retry on its own: a failed wake of this
1392
+ // seat's pending row that the shared rule admits. A peer that may already have been written (indeterminate), or
1393
+ // failed for another reason, isn't claimed here.
1394
+ const eligible = (entry) => {
1395
+ if (entry.deliveryState !== "failed" || !entry.auditPointer)
1396
+ return false;
1397
+ const current = this.getById(entry.auditPointer);
1398
+ return current?.state === "pending" && addresses.includes(current.destinationSession) && !current.handedOffFrom
1399
+ && this.unroutableWakeRetryable(current, now);
1400
+ };
1401
+ for (const { qitem_id } of rows) {
1402
+ const row = this.getById(qitem_id);
1403
+ if (!row || row.state !== "pending" || !this.unroutableWakeRetryable(row, now))
1404
+ continue;
1405
+ // The failed wake may be the row's own intent or an un-park's blocker intent: re-send whichever failed.
1406
+ // One in flight or delivered is never sent again; only a row with no intent at all takes the plain nudge.
1407
+ const intents = this.outbox ? this.db.prepare(`SELECT outbox_id, delivery_state FROM outbox_entries
1408
+ WHERE audit_pointer = ? AND substr(outbox_id, 1, ?) = ?`)
1409
+ .all(qitem_id, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX) : [];
1410
+ if (intents.length) {
1411
+ for (const intent of intents)
1412
+ if (intent.delivery_state === "failed")
1413
+ await this.deliverWakeIntent(intent.outbox_id, attempted, eligible);
1414
+ }
1415
+ else
1416
+ await this.maybeNudge(qitem_id, row.destinationSession, undefined, row.sourceSession);
1417
+ }
1418
+ }
1321
1419
  /**
1322
1420
  * W1 (transactional closure): the shared wake-send CORE. Builds the pane
1323
1421
  * envelope, sends with verify, and CLASSIFIES the transport result into the W1
@@ -1396,7 +1494,7 @@ export class QueueRepository {
1396
1494
  const genUuid = sourceSession
1397
1495
  ? (this.resolveOccupantGeneration?.(sourceSession) ?? undefined)
1398
1496
  : undefined;
1399
- text = wrapPaneEnvelope(sourceSession, destinationSession, bareBody, { stampISO, genUuid, replyToQitem: qitemId });
1497
+ text = wrapPaneEnvelope(sourceSession, destinationSession, bareBody, { stampISO, genUuid, replyToQitem: qitemId, ...this.senderReach(sourceSession) });
1400
1498
  }
1401
1499
  const deliveryId = `guard-nudge-${qitemId}-${createHash("sha256").update(JSON.stringify([sourceSession, destinationSession, bodyOverride ?? null])).digest("hex")}`;
1402
1500
  const held = !committedOutboxIds ? this.outbox?.getById(deliveryId) : null;
@@ -1658,6 +1756,11 @@ export class QueueRepository {
1658
1756
  }
1659
1757
  this.assertHumanAlert(input.humanAlert, input.destinationSession, input.humanIntent);
1660
1758
  const id = input.qitemId ?? newQitemId();
1759
+ // A row queue erasure deleted keeps only its id: a create that reuses it would bring erased work back.
1760
+ if (input.qitemId && this.hasErasedIdsTable
1761
+ && this.db.prepare("SELECT 1 FROM queue_erased_ids WHERE qitem_id = ?").get(input.qitemId)) {
1762
+ throw new QueueRepositoryError("qitem_erased", `qitem ${input.qitemId} was erased; its id can't be used again.`);
1763
+ }
1661
1764
  const ts = new Date().toISOString();
1662
1765
  const priority = input.priority ?? "routine";
1663
1766
  const tier = input.tier ?? null;
@@ -1736,8 +1839,11 @@ export class QueueRepository {
1736
1839
  }
1737
1840
  if (humanAlert !== true)
1738
1841
  return;
1739
- if (!this.isPersonAddress(destination) || humanIntent === "update") {
1740
- throw new QueueRepositoryError("invalid_human_notification", "humanAlert marks an ask to a person as alert-worthy: it needs a human destination, and an update isn't an ask.");
1842
+ if (!this.isPersonAddress(destination)) {
1843
+ throw new QueueRepositoryError("invalid_human_notification", "humanAlert marks an ask to a person as alert-worthy: it needs a human destination.");
1844
+ }
1845
+ if (humanIntent === "update") {
1846
+ throw new QueueRepositoryError("invalid_human_notification", "humanAlert marks an ask to a person as alert-worthy, and an update isn't an ask: send it without --alert; updates are notices; delivery depends on the person's connector and settings.");
1741
1847
  }
1742
1848
  }
1743
1849
  /** A person by address or by the registry: a registered person may be addressed as their seat or an alias. */
@@ -1814,6 +1920,11 @@ export class QueueRepository {
1814
1920
  * with `handed_off_from` recording the chain. One atomic transaction.
1815
1921
  */
1816
1922
  async handoff(input) {
1923
+ return this.handoffNow(input);
1924
+ }
1925
+ /** {@link handoff}'s whole act, synchronously: its transaction commits before this returns, and the wake is delivered
1926
+ * after commit without being awaited, so a synchronous caller (an answer's close path) can hand a row on. */
1927
+ handoffNow(input) {
1817
1928
  const source = this.getById(input.qitemId);
1818
1929
  if (!source) {
1819
1930
  throw new QueueRepositoryError("qitem_not_found", `qitem ${input.qitemId} not found`);
@@ -1950,8 +2061,11 @@ export class QueueRepository {
1950
2061
  this.assertTerminalClosureHasIntent(source.qitemId, newId, input.nudge);
1951
2062
  });
1952
2063
  txn();
2064
+ // Inside a caller's notify envelope (an answer's close path), the events join it; otherwise they're notified now.
1953
2065
  for (const e of events) {
1954
- this.eventBus.notifySubscribers(e.payload);
2066
+ const event = e.payload;
2067
+ if (!this.eventBus.registerPersistedWithinActiveEnvelope(event))
2068
+ this.eventBus.notifySubscribers(event);
1955
2069
  }
1956
2070
  // Closure and successor are persisted. Delivery is separate and recoverable
1957
2071
  // from the committed intent; a slow terminal must not hold the receipt.
@@ -3185,6 +3299,9 @@ export class QueueRepository {
3185
3299
  * button set is already final; its resolve continuation must not overwrite those answers.
3186
3300
  */
3187
3301
  resolveDirectHumanReply(input) {
3302
+ const passed = this.passRunnerAnswerToDecider(input);
3303
+ if (passed !== null)
3304
+ return passed;
3188
3305
  let mine = true;
3189
3306
  const result = this.db.transaction(() => {
3190
3307
  const item = this.getById(input.qitemId);
@@ -3212,6 +3329,133 @@ export class QueueRepository {
3212
3329
  }
3213
3330
  return mine;
3214
3331
  }
3332
+ /** A runner's permission ask its person answered, where an agent can decide while the runner waits on it: their answer
3333
+ * (a choice, or their words) stays on the ask, and the ask is handed to that agent to decide, never closed with it. The
3334
+ * runner reads pending until the agent decides (`rig seat decide-permission`), or the person uses a direct control.
3335
+ * Null when this doesn't apply (no decider, or another person's answer settles it), and the ask closes as before. */
3336
+ passRunnerAnswerToDecider(input) {
3337
+ const item = this.getById(input.qitemId);
3338
+ if (!this.permissionDecider || item?.state !== "pending" || !runnerPermissionOrigin(item) || item.humanIntent === "update"
3339
+ || (!this.answersAsk(item, input.actorSession) && !input.primaryUser) || !this.isPersonAddress(item.destinationSession)
3340
+ || this.committedAnswerFromAnother(item.qitemId, input.actorSession))
3341
+ return null;
3342
+ // The requester is the runner seat that asked: the first row of the request, whoever handed it on since.
3343
+ let root = item;
3344
+ for (let hops = 0; root.handedOffFrom && hops < 10; hops++) {
3345
+ const before = this.getById(root.handedOffFrom);
3346
+ if (!before || !runnerPermissionOrigin(before))
3347
+ break;
3348
+ root = before;
3349
+ }
3350
+ let chosen;
3351
+ try {
3352
+ chosen = this.permissionDecider(item, root.sourceSession);
3353
+ }
3354
+ catch {
3355
+ chosen = null;
3356
+ }
3357
+ const decider = chosen?.session ?? null;
3358
+ if (!decider || !this.validateRig(decider))
3359
+ return this.keepRunnerAnswer(item, input.actorSession, input.decision, root.sourceSession);
3360
+ this.db.transaction(() => { this.placeTypedReply(item, input.decision); })();
3361
+ const answered = this.getById(item.qitemId) ?? item;
3362
+ const question = (this.permissionQuestionsFor(answered) ?? [])[0];
3363
+ const answer = question ? answered.humanAnswers?.[question.id] : undefined;
3364
+ const said = typeof answer === "string" ? `chose "${question?.options.find((o) => o.id === answer)?.label ?? answer}" (option ${answer})`
3365
+ : answer && typeof answer === "object" && "text" in answer ? `wrote "${String(answer.text).trim()}"`
3366
+ : "answered without a choice or words";
3367
+ const person = input.actorSession;
3368
+ // A handoff that fails after persisting its events rolls them back with its savepoint: discardOnThrow takes their
3369
+ // tokens out of the caller's notify envelope too, so the kept answer below still commits.
3370
+ try {
3371
+ this.eventBus.discardOnThrow(() => this.handoffNow({
3372
+ qitemId: item.qitemId, fromSession: person, toSession: decider,
3373
+ summary: `Decide: ${item.summary ?? "a runner's permission request"} (${person} answered)`,
3374
+ transitionNote: `runner-permission-answer-passed: ${person}'s answer goes to ${decider}, the receiving agent, to decide while the runner waits`,
3375
+ body: [
3376
+ `${person} answered ${item.sourceSession}'s permission request ${item.qitemId}: they ${said}. Its runner is waiting on your decision: nothing is permitted or refused until you decide.`,
3377
+ "",
3378
+ `- **Question:** ${question?.question ?? "Allow this tool call?"}`,
3379
+ "- **Options:**",
3380
+ ...(question?.options ?? []).map((o) => ` - ${o.label} (${o.id})`),
3381
+ "",
3382
+ `Their whole answer is recorded on the request: rig queue show ${answered.qitemId} --full.`,
3383
+ `Decide with: rig seat decide-permission ${item.qitemId} --option <id> --reason "<why>"`,
3384
+ "Act on a clear answer at once: a clear yes or an allow click is the allow option, a clear no or a reject click the reject option. Don't ask them to confirm a clear answer. If their words are unclear or conditional, ask them back, naming this request, then decide.",
3385
+ "Until it's decided (by you, or by anyone with that command), the runner keeps waiting, with no timeout that refuses it; if its turn ends first, nothing is sent.",
3386
+ ].join("\n"),
3387
+ }));
3388
+ }
3389
+ catch (error) {
3390
+ // Kept, and committed with the answer's own write (a throw here would roll it back): the request stays open, and
3391
+ // the person is told it couldn't be passed on. Never a default permit.
3392
+ console.error(`[queue] a runner permission answer couldn't be handed to ${decider}; it's kept and the request stays open`, error);
3393
+ return this.keepRunnerAnswer(item, person, input.decision, root.sourceSession, decider);
3394
+ }
3395
+ // The person learns who decides and in what recorded state, so a delay is shown: one update per request.
3396
+ const toldId = `qitem-runner-permission-passed-${item.qitemId.replace(/^qitem-runner-permission-/, "").replace(/^qitem-/, "")}`;
3397
+ setImmediate(() => {
3398
+ void this.create({ qitemId: toldId, sourceSession: root.sourceSession, destinationSession: person, humanIntent: "update",
3399
+ summary: `Your answer went to ${decider} to decide; ${root.sourceSession} is waiting`,
3400
+ body: [`Your answer to ${root.sourceSession}'s permission request ${root.qitemId} went to ${decider}, which decides it while ${root.sourceSession} waits. Nothing runs until it decides.`,
3401
+ ...(chosen?.describe ? [`Receiving agent: ${chosen.describe}`] : []),
3402
+ `To decide directly instead: rig seat decide-permission ${root.qitemId} --option <id>.`].join("\n") })
3403
+ .catch((error) => console.error(`[queue] the update for ${item.qitemId}'s decider wasn't written`, error));
3404
+ });
3405
+ return true;
3406
+ }
3407
+ /** An agent's decision on a runner's permission request, on the row that holds it now: the chosen option under its
3408
+ * question, and the row closed done, in one transaction. False when the row isn't open any more. */
3409
+ recordPermissionDecision(input) {
3410
+ const result = this.db.transaction(() => {
3411
+ const item = this.getById(input.qitemId);
3412
+ if (!item)
3413
+ return null;
3414
+ const answers = { ...item.humanAnswers, [input.questionId]: input.optionId };
3415
+ // A row closed without a decision (an agent's or a person's ordinary close): the decision is recorded on it, with
3416
+ // its own transition, over any kept answer (which the transition names); the runner's next read takes it.
3417
+ // (The caller read it first: a row already decided explicitly, withdrawn or stale never reaches here.)
3418
+ if (item.state === "done" || item.state === "failed") {
3419
+ this.db.prepare("UPDATE queue_items SET human_answers = ? WHERE qitem_id = ?").run(JSON.stringify(answers), item.qitemId);
3420
+ this.transitionLog.append({ qitemId: item.qitemId, state: item.state, actorSession: input.actorSession, transitionNote: input.transitionNote });
3421
+ // The row's state doesn't change, but its decision does: a runner waiting on this request reads it now, and
3422
+ // Steering refreshes.
3423
+ return { persistedEvents: [this.eventBus.persistWithinTransaction({ type: "queue.updated", qitemId: item.qitemId,
3424
+ fromState: item.state, toState: item.state, closureReason: null, closureTarget: null,
3425
+ actorSession: input.actorSession, summary: item.summary ?? null })] };
3426
+ }
3427
+ if (item.state !== "pending" && item.state !== "in-progress" && item.state !== "blocked")
3428
+ return null;
3429
+ this.db.prepare("UPDATE queue_items SET human_answers = ? WHERE qitem_id = ?").run(JSON.stringify(answers), item.qitemId);
3430
+ return this.updateInTransactionalContext({ qitemId: item.qitemId, actorSession: input.actorSession, state: "done",
3431
+ closureReason: "no-follow-on", transitionNote: input.transitionNote });
3432
+ })();
3433
+ if (!result)
3434
+ return false;
3435
+ for (const event of result.persistedEvents) {
3436
+ if (!this.eventBus.registerPersistedWithinActiveEnvelope(event))
3437
+ this.eventBus.notifySubscribers(event);
3438
+ }
3439
+ return true;
3440
+ }
3441
+ /** No agent here can read a runner permission answer before the tool runs (none is set, or the only one is the seat
3442
+ * asking): the person's answer, a click or words, is kept on the ask, the request stays pending, and the person is
3443
+ * told once that the tool hasn't run and how to decide directly. Never a default permit, never read as a refusal. */
3444
+ keepRunnerAnswer(item, person, decision, requester, unreachable) {
3445
+ this.db.transaction(() => { this.placeTypedReply(item, decision); })();
3446
+ const options = (this.permissionQuestionsFor(item) ?? [])[0]?.options ?? [];
3447
+ const receiptId = `qitem-runner-permission-kept-${item.qitemId.replace(/^qitem-runner-permission-/, "")}`;
3448
+ // After the answer's own write settles: one receipt per request (its id is the request's), told to who answered.
3449
+ setImmediate(() => {
3450
+ void this.create({ qitemId: receiptId, sourceSession: requester, destinationSession: person, humanIntent: "update",
3451
+ summary: `Your answer to ${requester}'s permission request is kept; the tool hasn't run`,
3452
+ body: [`Your answer to ${requester}'s permission request ${item.qitemId} is kept, and the request is still waiting: ${unreachable ? `it couldn't be passed to ${unreachable}, the receiving agent, just now (answer again to retry)` : `no receiving agent on this host can read it before the tool runs (none is set, or the only one is ${requester} itself)`}. The tool hasn't run, and nothing was permitted or refused.`,
3453
+ `To decide now: rig seat decide-permission ${item.qitemId} --option <id>${options.length ? ` (options: ${options.map((o) => `${o.id}, ${o.label}`).join("; ")})` : ""}. Or set up a receiving agent that isn't ${requester}: rig config set agents.operator_session <seat>@<rig>.`,
3454
+ "If the agent's turn ends first, the tool call doesn't happen, and nothing is sent later."].join("\n") })
3455
+ .catch((error) => console.error(`[queue] the kept-answer receipt for ${item.qitemId} wasn't written`, error));
3456
+ });
3457
+ return true;
3458
+ }
3215
3459
  /** Another person's committed return to this ask: its shared reply (for a park's question, `episodeKey`'s). It's the
3216
3460
  * answer, so a different person's later attempt settles with it rather than their own. Null when there's none, or it's
3217
3461
  * this actor's. */
@@ -3362,15 +3606,18 @@ export class QueueRepository {
3362
3606
  listRelayOwnerNotificationReceipts(qitemId) {
3363
3607
  return this.transitionLog.listRelayOwnerNotificationReceipts(qitemId);
3364
3608
  }
3365
- getRelayOwnerNotificationReceipt(qitemId, notificationKey) {
3366
- return this.transitionLog.getRelayOwnerNotificationReceipt(qitemId, notificationKey);
3609
+ getRelayOwnerNotificationReceipt(qitemId, notificationKey, deliveryId) {
3610
+ return this.transitionLog.getRelayOwnerNotificationReceipt(qitemId, notificationKey, deliveryId);
3367
3611
  }
3368
- hasRelayOwnerNotificationReceipt(qitemId, notificationKey) {
3369
- return this.transitionLog.hasRelayOwnerNotificationReceipt(qitemId, notificationKey);
3612
+ hasRelayOwnerNotificationReceipt(qitemId, notificationKey, deliveryId) {
3613
+ return this.transitionLog.hasRelayOwnerNotificationReceipt(qitemId, notificationKey, deliveryId);
3370
3614
  }
3371
3615
  findRelayOwnerNotificationReceiptByReplyRef(replyRef) {
3372
3616
  return this.transitionLog.findRelayOwnerNotificationReceiptByReplyRef(replyRef);
3373
3617
  }
3618
+ findRelayOwnerNotificationReceiptByDeliveryId(deliveryId) {
3619
+ return this.transitionLog.findRelayOwnerNotificationReceiptByDeliveryId(deliveryId);
3620
+ }
3374
3621
  recordRelayOwnerNotificationTransportFailed(input) {
3375
3622
  const current = this.getByIdOrThrow(input.qitemId);
3376
3623
  const key = typeof input.notificationKey === "string" && input.notificationKey.trim().length > 0
@@ -3534,20 +3781,20 @@ export class QueueRepository {
3534
3781
  ORDER BY json_extract(delegated_decision, '$.decidedAt'), qitem_id`).all(applicationId);
3535
3782
  return rows.map((row) => this.rowToItem(row));
3536
3783
  }
3537
- getById(qitemId) {
3784
+ /** opts.waiting: false skips the row's waiting view (the stuck sweep's own reads); the default builds it. Per call:
3785
+ * it never changes what another read returns. */
3786
+ getById(qitemId, opts) {
3538
3787
  const row = this.db
3539
3788
  .prepare("SELECT * FROM queue_items WHERE qitem_id = ?")
3540
3789
  .get(qitemId);
3541
3790
  if (!row)
3542
3791
  return null;
3543
- const item = this.rowToItem(row);
3544
3792
  // OPR.0.5.6.14 — the row FACE answers "did it reach them" in one read for
3545
3793
  // gateway-routed rows; null for pane-bound (absence-governed, no key lies).
3546
- const ledger = this.deliveryOutcomeFor(item.qitemId);
3794
+ // The same projection as a listing's, for one row: one read of its owner notifications and ledger.
3795
+ const item = this.projectRows([row], opts?.waiting !== false)[0];
3547
3796
  return {
3548
3797
  ...item,
3549
- deliveryOutcome: ledger?.outcome ?? null,
3550
- ...(ledger && ledger.outcome !== "posted" && ledger.outcome !== "accepted" ? { deliveryFailureDetail: ledger.detail } : {}),
3551
3798
  ...(item.replyTo ? { replyToFallback: this.replyToFallbackFor(item.qitemId) } : {}),
3552
3799
  };
3553
3800
  }
@@ -3677,18 +3924,24 @@ export class QueueRepository {
3677
3924
  const rows = this.db
3678
3925
  .prepare(`SELECT ${columns} FROM queue_items ${where} ORDER BY ${orderBy} LIMIT ?`)
3679
3926
  .all(...params);
3927
+ const items = this.projectRows(rows, !opts?.compact);
3928
+ return opts?.compact ? items.map(compactRow) : items;
3929
+ }
3930
+ /** The listing projection (list, and show as a listing of one row): each row's item with its delivery outcome, the
3931
+ * owner notifications, ledgers and shared reads read once for all the rows. includeWaiting: full rows (SELECT *). */
3932
+ projectRows(rows, includeWaiting) {
3680
3933
  const owners = this.transitionLog.ownerNotificationsForQitems(rows.map((row) => row.qitem_id));
3681
3934
  const ledgers = this.deliveryOutcomesFor(rows, owners, true);
3682
- const items = rows.map((r) => {
3935
+ const reads = this.listingReads(rows, includeWaiting);
3936
+ return rows.map((r) => {
3683
3937
  const ledger = ledgers.get(r.qitem_id);
3684
- const item = this.rowToItem(r, !opts?.compact, { owners: owners.get(r.qitem_id) ?? [], ledger: ledger ?? null });
3938
+ const item = this.rowToItem(r, includeWaiting, { owners: owners.get(r.qitem_id) ?? [], ledger: ledger ?? null, reads });
3685
3939
  return {
3686
3940
  ...item,
3687
3941
  deliveryOutcome: ledger?.outcome ?? null,
3688
3942
  ...(ledger && ledger.outcome !== "posted" && ledger.outcome !== "accepted" ? { deliveryFailureDetail: ledger.detail } : {}),
3689
3943
  };
3690
3944
  });
3691
- return opts?.compact ? items.map(compactRow) : items;
3692
3945
  }
3693
3946
  /**
3694
3947
  * OPR.0.3.2.20 — durable attention-class query.
@@ -3853,7 +4106,7 @@ export class QueueRepository {
3853
4106
  params.push(opts.limit);
3854
4107
  }
3855
4108
  const rows = this.db.prepare(sql).all(...params);
3856
- const items = rows.map((r) => this.rowToItem(r, !opts?.compact));
4109
+ const items = rows.map((r) => this.rowToItem(r, !opts?.compact && opts?.waiting !== false));
3857
4110
  return opts?.compact ? items.map(compactRow) : items;
3858
4111
  }
3859
4112
  /**
@@ -3947,7 +4200,7 @@ export class QueueRepository {
3947
4200
  const rows = this.db.prepare(sql).all(...params);
3948
4201
  const out = [];
3949
4202
  for (const r of rows) {
3950
- const item = this.rowToItem(r, !opts?.compact);
4203
+ const item = this.rowToItem(r, !opts?.compact && opts?.waiting !== false);
3951
4204
  const ledger = this.deliveryOutcomeFor(item.qitemId);
3952
4205
  if (ledger?.outcome === "posted" || ledger?.outcome === "accepted")
3953
4206
  continue; // the receipt wins, always
@@ -4033,6 +4286,59 @@ export class QueueRepository {
4033
4286
  return false;
4034
4287
  }
4035
4288
  }
4289
+ /** Whether the rosters list this address as a hosted member on this host, trigger or not. An unreadable roster reads
4290
+ * false. */
4291
+ isHostedMember(destination) {
4292
+ try {
4293
+ return this.hostedMemberFn(destination);
4294
+ }
4295
+ catch {
4296
+ return false;
4297
+ }
4298
+ }
4299
+ /** Whether two addresses name the same session (one of its canonical or physical names). */
4300
+ isSameSession(a, b) {
4301
+ if (a === b)
4302
+ return true;
4303
+ try {
4304
+ return this.resolveSessionAddresses(a).includes(b) || this.resolveSessionAddresses(b).includes(a);
4305
+ }
4306
+ catch {
4307
+ return false;
4308
+ }
4309
+ }
4310
+ /** A session's successful read of its own pending inbox, as the list route decides: availability, never a receipt,
4311
+ * claim or answer for any row. Written at most once a minute per session; a failed write is logged once and never
4312
+ * fails the read that made it. */
4313
+ recordInboxCheckIn(session, at = new Date()) {
4314
+ const last = this.inboxCheckInWrittenAt.get(session);
4315
+ if (last !== undefined && at.getTime() >= last && at.getTime() - last < INBOX_CHECKIN_WRITE_INTERVAL_MS)
4316
+ return;
4317
+ try {
4318
+ this.db.prepare(`INSERT INTO queue_inbox_checkins (session, checked_at) VALUES (?, ?)
4319
+ ON CONFLICT(session) DO UPDATE SET checked_at = excluded.checked_at WHERE excluded.checked_at > queue_inbox_checkins.checked_at`)
4320
+ .run(session, at.toISOString());
4321
+ this.inboxCheckInWrittenAt.set(session, at.getTime());
4322
+ }
4323
+ catch (err) {
4324
+ if (!this.inboxCheckInWriteFailed) {
4325
+ console.error(`[queue] inbox check-in not recorded for ${session}: ${err instanceof Error ? err.message : String(err)}`);
4326
+ }
4327
+ this.inboxCheckInWriteFailed = true;
4328
+ }
4329
+ }
4330
+ /** This session's latest recorded check-in under any of its names. */
4331
+ lastInboxCheckIn(session) {
4332
+ try {
4333
+ const names = [...new Set([session, ...this.resolveSessionAddresses(session)])];
4334
+ const row = this.db.prepare(`SELECT MAX(checked_at) AS at FROM queue_inbox_checkins WHERE session IN (${names.map(() => "?").join(", ")})`)
4335
+ .get(...names);
4336
+ return row?.at ? { state: "seen", at: row.at } : { state: "never" };
4337
+ }
4338
+ catch {
4339
+ return { state: "unknown" };
4340
+ }
4341
+ }
4036
4342
  classifyDestinationOf(destinationSession) {
4037
4343
  return classifyDestination(destinationSession, {
4038
4344
  entities: (() => {
@@ -4080,7 +4386,7 @@ export class QueueRepository {
4080
4386
  /** Null means legacy/no OWNER history; inactive means OWNER history exists
4081
4387
  * but the row no longer projects a current human-notification episode.
4082
4388
  * owners: the row's owner notifications, newest first. */
4083
- currentDeliveryEpisode(item, owners, loadRegistry) {
4389
+ currentDeliveryEpisode(item, owners, loadRegistry, loadProfiles, loadPullOutboxKeys) {
4084
4390
  let transition = owners[0];
4085
4391
  if (!transition)
4086
4392
  return null;
@@ -4109,14 +4415,26 @@ export class QueueRepository {
4109
4415
  : item.state === "blocked"
4110
4416
  ? resolveRegisteredHumanAddress(item.blockedOn, registry.entities)
4111
4417
  : resolveRegisteredHumanAddress(item.destinationSession, registry.entities);
4418
+ const entity = humanAddress ? registry.entities.find((entry) => entry.address === humanAddress) : undefined;
4112
4419
  // A person with no connector is reached in the Feed and Steering only: nothing is posted to them, so nothing is owed.
4113
- if (humanAddress && registry.entities.find((entity) => entity.address === humanAddress)?.connectorBindings.length === 0)
4420
+ if (entity?.connectorBindings.length === 0)
4114
4421
  return "inactive";
4422
+ const notificationKey = `${item.qitemId}:${transition.transitionId}`;
4423
+ // A ready pull-mode relay has no required polling cadence (#2742): while the outbox lists the staged envelope, waiting
4424
+ // to be pulled is not a missing post for PULL_OUTBOX_NEVER_POSTED_WINDOW_MS. ledgerOf asks only when nothing else
4425
+ // decides the outcome; a notice the outbox doesn't list gets the usual NEVER_POSTED_WINDOW_MS.
4426
+ const primary = entity?.connectorBindings.find((b) => b.role === "primary") ?? entity?.connectorBindings[0];
4427
+ const awaitingPull = primary?.kind === "relay"
4428
+ ? () => {
4429
+ const p = loadProfiles(registry.entities).get(primary.connectorRef);
4430
+ return p?.ready === true && p.mode === "pull" && loadPullOutboxKeys().has(`${primary.connectorRef}\n${notificationKey}`);
4431
+ }
4432
+ : undefined;
4115
4433
  // An ask placed on Steering without an alert (RECORD) owes no post: its ledger reports a real receipt (a posting
4116
4434
  // dial set to RECORD posts it) and never a missing one.
4117
4435
  return humanAddress
4118
- ? { notificationKey: `${item.qitemId}:${transition.transitionId}`, startedAt: transition.ts,
4119
- ...(transition.ownerNotificationLevel === "RECORD" ? { quiet: true } : {}) }
4436
+ ? { notificationKey, startedAt: transition.ts,
4437
+ ...(transition.ownerNotificationLevel === "RECORD" ? { quiet: true } : awaitingPull ? { awaitingPull } : {}) }
4120
4438
  : "inactive";
4121
4439
  }
4122
4440
  /** OPR.0.5.6.14 — derive the current episode's delivery ledger. Receipt
@@ -4212,9 +4530,13 @@ export class QueueRepository {
4212
4530
  let notes = receiptsAfterEpisodes ? undefined : this.receiptNotesFor(qitemIds);
4213
4531
  let registry;
4214
4532
  const loadRegistry = () => (registry ??= this.loadHumanRegistryFn());
4533
+ let relayProfiles;
4534
+ const loadProfiles = (entities) => (relayProfiles ??= loadRelayProfiles(undefined, { entities }));
4535
+ let pullOutboxKeys;
4536
+ const loadPullOutboxKeys = () => (pullOutboxKeys ??= listablePullOutboxKeys());
4215
4537
  const episodes = rows.map((row) => {
4216
4538
  const item = ledgerItem(row);
4217
- return { item, episode: this.currentDeliveryEpisode(item, owners.get(row.qitem_id) ?? [], loadRegistry) };
4539
+ return { item, episode: this.currentDeliveryEpisode(item, owners.get(row.qitem_id) ?? [], loadRegistry, loadProfiles, loadPullOutboxKeys) };
4218
4540
  });
4219
4541
  notes ??= this.receiptNotesFor(qitemIds);
4220
4542
  for (const { item, episode } of episodes) {
@@ -4265,7 +4587,8 @@ export class QueueRepository {
4265
4587
  const gatewayRouted = episode !== null || item.lastNudgeResult?.startsWith("gateway-owned") === true;
4266
4588
  if (gatewayRouted) {
4267
4589
  const ageMs = Date.now() - new Date(startedAt.includes("T") ? startedAt : startedAt + "Z").getTime();
4268
- if (ageMs > QueueRepository.NEVER_POSTED_WINDOW_MS) {
4590
+ if (ageMs > QueueRepository.NEVER_POSTED_WINDOW_MS
4591
+ && !(ageMs <= QueueRepository.PULL_OUTBOX_NEVER_POSTED_WINDOW_MS && episode?.awaitingPull?.())) {
4269
4592
  const key = episode ? ` for notification_key=${episode.notificationKey}` : "";
4270
4593
  return { outcome: "never-posted", detail: `gateway-routed row with no delivery receipt${key} past the post window`, episode };
4271
4594
  }
@@ -4275,6 +4598,9 @@ export class QueueRepository {
4275
4598
  /** The grace window before a receiptless gateway-routed row honestly reads
4276
4599
  * never-posted (the connector sweep cadence bounds normal posting latency). */
4277
4600
  static NEVER_POSTED_WINDOW_MS = 120_000;
4601
+ /** How long a notice staged in the relay pull outbox may wait for the connector's ack before it reads never-posted
4602
+ * (#2742). */
4603
+ static PULL_OUTBOX_NEVER_POSTED_WINDOW_MS = 24 * 60 * 60 * 1000;
4278
4604
  /** Record one wake attempt. */
4279
4605
  recordNudgeAttempt(qitemId, result) {
4280
4606
  const ts = new Date().toISOString();
@@ -4557,9 +4883,30 @@ export class QueueRepository {
4557
4883
  return null;
4558
4884
  }
4559
4885
  }
4886
+ /** What a listing reads once for all its rows instead of once per row. includeWaiting: the rows' waiting views read
4887
+ * their qitem blockers' last meaningful transitions too. */
4888
+ listingReads(rows, includeWaiting) {
4889
+ const ids = rows.map((r) => r.qitem_id);
4890
+ if (includeWaiting)
4891
+ for (const r of rows)
4892
+ if (r.blocked_on)
4893
+ ids.push(r.blocked_on);
4894
+ // Each owner's activity once per listing: a row and its waiting view (and every other row to that owner) read the
4895
+ // same seat state. ownerActivity reads a failure as null, so one session's failure stays that session's.
4896
+ const activities = new Map();
4897
+ const activity = (session) => {
4898
+ if (!activities.has(session))
4899
+ activities.set(session, this.ownerActivity(session));
4900
+ return activities.get(session) ?? null;
4901
+ };
4902
+ return { meaningful: lastMeaningfulTransitionMany(this.db, ids), statements: new WaitingStatements(this.db), activity };
4903
+ }
4560
4904
  /** listed: the row's owner notifications and ledger, when a listing read them for all its rows. */
4561
4905
  waitingView(qitemId, listed) {
4562
- const view = readWaitingView(this.db, qitemId, this.activityReader, target => this.acceptsDestination(target));
4906
+ // The row in hand, when the listing passed it: its later re-reads below are served by it too.
4907
+ const inHand = listed?.row && listed.row.qitem_id === qitemId ? listed.row : undefined;
4908
+ const reads = listed?.reads && inHand ? { ...listed.reads, row: inHand } : listed?.reads;
4909
+ const view = readWaitingView(this.db, qitemId, listed?.reads?.activity ?? this.activityReader, target => this.acceptsDestination(target), reads);
4563
4910
  if (view && ["pending", "in-progress"].includes(view.state)) {
4564
4911
  // #514 — the unclaimed sweep skips a pending ask already posted to its human in the current
4565
4912
  // episode (same predicate as runStuckSweep), so the view must not promise that sweep.
@@ -4567,7 +4914,9 @@ export class QueueRepository {
4567
4914
  const posted = episodeDelivery !== null;
4568
4915
  const onSteering = !posted && view.state === "pending" && this.humanAskWithoutAlert(qitemId, listed);
4569
4916
  const row = view.state === "pending" && !onSteering
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)
4917
+ ? inHand
4918
+ ? { state: inHand.state, human_intent: inHand.human_intent ?? null, destination_session: inHand.destination_session, last_nudge_result: inHand.last_nudge_result }
4919
+ : 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)
4571
4920
  : undefined;
4572
4921
  const humanUpdate = !!row && this.isRegisteredHumanUpdate({ state: row.state, humanIntent: row.human_intent, destinationSession: row.destination_session });
4573
4922
  const noticeOutcome = !posted && !onSteering ? (listed ? listed.ledger?.outcome : this.deliveryOutcomeFor(qitemId)?.outcome) : undefined;
@@ -4596,8 +4945,8 @@ export class QueueRepository {
4596
4945
  view.laterBackstop = { ...view.nextBackstop, note: "Conditional safety net; current delivery/recovery ownership is evaluated first." };
4597
4946
  view.nextBackstop = recovery;
4598
4947
  }
4599
- else if (!awaitingHuman && view.state === "pending" && this.db.prepare("SELECT last_nudge_result FROM queue_items WHERE qitem_id = ?")
4600
- .get(qitemId)?.last_nudge_result === "retained:typing_guard") {
4948
+ else if (!awaitingHuman && view.state === "pending" && (inHand ?? this.db.prepare("SELECT last_nudge_result FROM queue_items WHERE qitem_id = ?")
4949
+ .get(qitemId))?.last_nudge_result === "retained:typing_guard") {
4601
4950
  // Held at the seat on purpose: not stuck, and not picked up. Nothing replays it; reading or delivering it is a
4602
4951
  // deliberate step.
4603
4952
  view.nextBackstop = { owner: view.owner, mechanism: "held by the seat's typing guard", dueAt: null, intervalSeconds: null, held: true,
@@ -4645,9 +4994,11 @@ export class QueueRepository {
4645
4994
  rowToItem(row, includeWaiting = true, listed) {
4646
4995
  // S04 — derive the pickup receipt at the ONE shared projection point (list/show/overdue
4647
4996
  // all flow through here), so the park-vs-strand question is answered by the row face.
4648
- const meaningful = lastMeaningfulTransition(this.db, row.qitem_id);
4649
- const waiting = includeWaiting ? this.waitingView(row.qitem_id, listed) : null;
4650
- const activity = this.ownerActivity(row.destination_session);
4997
+ const meaningful = meaningfulFor(this.db, row.qitem_id, listed?.reads);
4998
+ // A listing's rows are its own SELECT *: the waiting view reads the row in hand instead of reading it again.
4999
+ const waiting = includeWaiting ? this.waitingView(row.qitem_id, listed?.reads ? { ...listed, row } : listed) : null;
5000
+ const listedActivity = listed?.reads?.activity;
5001
+ const activity = listedActivity ? listedActivity(row.destination_session) : this.ownerActivity(row.destination_session);
4651
5002
  const pickup = derivePickup({
4652
5003
  state: row.state,
4653
5004
  lastMeaningfulAt: meaningful?.at,
@@ -4704,6 +5055,7 @@ export class QueueRepository {
4704
5055
  // PL-007: target_repo present only when migration 038 has applied;
4705
5056
  // older test fixtures supply legacy rows where target_repo is undefined.
4706
5057
  targetRepo: row.target_repo ?? null,
5058
+ ...(row.content_erased_at ? { contentErasedAt: row.content_erased_at } : {}),
4707
5059
  };
4708
5060
  }
4709
5061
  }
@@ -4721,6 +5073,42 @@ function ledgerItem(row) {
4721
5073
  function isOutboundOwnerNotice(t) {
4722
5074
  return t.ownerNotificationLevel != null && t.ownerNotificationKind != null && t.ownerNotificationKind !== "human-decision-resolved";
4723
5075
  }
5076
+ /** The `<connectorRef>\n<notificationKey>` pairs GET /api/gateway/relay/outbox would list now: staged in the
5077
+ * DispatchBuffer and the attempted store, under a connector whose listing isn't refused for an invalid envelope. A store
5078
+ * the outbox can't read (so it answers 503) lists nothing. */
5079
+ function listablePullOutboxKeys() {
5080
+ let pending;
5081
+ let attempted;
5082
+ try {
5083
+ const home = getOpenRigHome();
5084
+ pending = new DispatchBuffer(home).pendingStrict();
5085
+ const { attemptedPath, deliveredPath } = relayStatePaths(home);
5086
+ attempted = new SeenStore(attemptedPath).statuses();
5087
+ new SeenStore(deliveredPath).statuses();
5088
+ }
5089
+ catch {
5090
+ return new Set();
5091
+ }
5092
+ const listed = [];
5093
+ const refused = new Set();
5094
+ for (const decision of pending) {
5095
+ const p = decision.payload && typeof decision.payload === "object" ? decision.payload : null;
5096
+ const ref = p?.relayConnectorRef;
5097
+ if (!p || typeof ref !== "string" || !ref || !attempted.has(decision.decisionId))
5098
+ continue;
5099
+ if (!p.relayEnvelope || !validateRelayOutboundEnvelope(p.relayEnvelope).ok) {
5100
+ refused.add(ref);
5101
+ continue;
5102
+ }
5103
+ const keys = p.deliveryDigestPost && Array.isArray(p.memberReceipts) && p.memberReceipts.length > 0
5104
+ ? p.memberReceipts.map((m) => m?.notificationKey)
5105
+ : [p.notificationKey || p.qitemId];
5106
+ for (const key of keys)
5107
+ if (typeof key === "string" && key)
5108
+ listed.push([ref, key]);
5109
+ }
5110
+ return new Set(listed.filter(([ref]) => !refused.has(ref)).map(([ref, key]) => `${ref}\n${key}`));
5111
+ }
4724
5112
  function isQueueState(value) {
4725
5113
  return typeof value === "string" && QUEUE_STATES.includes(value);
4726
5114
  }