@openrig/cli 0.7.1 → 0.7.3

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 (1005) hide show
  1. package/README.md +5 -5
  2. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  3. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  4. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/SKILL.md +2 -2
  5. package/daemon/assets/plugins/openrig-core/skills/delegating-work/SKILL.md +1 -1
  6. package/daemon/assets/plugins/openrig-core/skills/messaging-the-human/SKILL.md +37 -3
  7. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +90 -9
  8. package/daemon/assets/skills/rigs/SKILL.md +40 -9
  9. package/daemon/context-packs/help/help.md +6 -0
  10. package/daemon/context-packs/help/manifest.yaml +1 -1
  11. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  12. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +132 -24
  13. package/daemon/context-packs/reference/acp-agents.md +77 -0
  14. package/daemon/context-packs/reference/getting-started.md +84 -10
  15. package/daemon/context-packs/reference/manifest.yaml +6 -3
  16. package/daemon/context-packs/reference/rig-spec.md +179 -6
  17. package/daemon/context-packs/reference/whats-new.md +148 -169
  18. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  19. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  20. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  21. package/daemon/context-packs/skills/claude-compaction-restore/SKILL.md +2 -2
  22. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  23. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  24. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  25. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  26. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  27. package/daemon/context-packs/skills/core/messaging-the-human/SKILL.md +37 -3
  28. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  30. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  31. package/daemon/context-packs/skills/core/openrig-herdr/SKILL.md +20 -5
  32. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/delegating-work/SKILL.md +1 -1
  43. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/openrig-user/SKILL.md +90 -9
  49. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/process/agent-browser/LICENSE.txt +201 -0
  63. package/daemon/context-packs/skills/process/agent-browser/OPENRIG.md +13 -29
  64. package/daemon/context-packs/skills/process/agent-browser/SKILL.md +8 -8
  65. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +3 -1
  66. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/process/dogfood/LICENSE.txt +201 -0
  68. package/daemon/context-packs/skills/process/dogfood/SKILL.md +6 -2
  69. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +3 -1
  70. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/process/systematic-debugging/LICENSE.txt +21 -0
  72. package/daemon/context-packs/skills/process/systematic-debugging/SKILL.md +6 -2
  73. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +3 -1
  74. package/daemon/context-packs/skills/process/systematic-debugging/root-cause-tracing.md +1 -1
  75. package/daemon/context-packs/skills/process/test-driven-development/LICENSE.txt +21 -0
  76. package/daemon/context-packs/skills/process/test-driven-development/SKILL.md +5 -1
  77. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +3 -1
  78. package/daemon/context-packs/skills/process/verification-before-completion/LICENSE.txt +21 -0
  79. package/daemon/context-packs/skills/process/verification-before-completion/SKILL.md +5 -1
  80. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +3 -1
  81. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  83. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  84. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  85. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  86. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  87. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  88. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  89. package/daemon/dist/adapters/claude-code-adapter.d.ts +4 -0
  90. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  91. package/daemon/dist/adapters/claude-code-adapter.js +46 -17
  92. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  93. package/daemon/dist/adapters/claude-resume.d.ts +8 -1
  94. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  95. package/daemon/dist/adapters/claude-resume.js +29 -10
  96. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  97. package/daemon/dist/adapters/codex-resume.d.ts +11 -4
  98. package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
  99. package/daemon/dist/adapters/codex-resume.js +69 -18
  100. package/daemon/dist/adapters/codex-resume.js.map +1 -1
  101. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +53 -13
  102. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  103. package/daemon/dist/adapters/codex-runtime-adapter.js +801 -119
  104. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  105. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +4 -0
  106. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
  107. package/daemon/dist/adapters/community-harness-runtime-adapter.js +38 -7
  108. package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
  109. package/daemon/dist/adapters/compose-services-adapter.d.ts +16 -0
  110. package/daemon/dist/adapters/compose-services-adapter.d.ts.map +1 -1
  111. package/daemon/dist/adapters/compose-services-adapter.js +46 -2
  112. package/daemon/dist/adapters/compose-services-adapter.js.map +1 -1
  113. package/daemon/dist/adapters/kernel-authority.d.ts +1 -1
  114. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  115. package/daemon/dist/adapters/kernel-authority.js +13 -2
  116. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  117. package/daemon/dist/adapters/pi-resume.js +1 -1
  118. package/daemon/dist/adapters/pi-resume.js.map +1 -1
  119. package/daemon/dist/adapters/pi-runner-protocol.d.ts +3 -3
  120. package/daemon/dist/adapters/pi-runner-protocol.js +2 -2
  121. package/daemon/dist/adapters/pi-runner.d.ts +1 -1
  122. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  123. package/daemon/dist/adapters/pi-runner.js +24 -17
  124. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  125. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  126. package/daemon/dist/adapters/tmux-server.js +6 -2
  127. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  128. package/daemon/dist/adapters/tmux.d.ts +51 -0
  129. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  130. package/daemon/dist/adapters/tmux.js +210 -17
  131. package/daemon/dist/adapters/tmux.js.map +1 -1
  132. package/daemon/dist/adapters/yolo-mode.d.ts +7 -0
  133. package/daemon/dist/adapters/yolo-mode.d.ts.map +1 -1
  134. package/daemon/dist/adapters/yolo-mode.js +8 -0
  135. package/daemon/dist/adapters/yolo-mode.js.map +1 -1
  136. package/daemon/dist/attention-surface.d.ts +16 -1
  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/codex-auth-surface.d.ts +2 -0
  141. package/daemon/dist/codex-auth-surface.d.ts.map +1 -0
  142. package/daemon/dist/codex-auth-surface.js +2 -0
  143. package/daemon/dist/codex-auth-surface.js.map +1 -0
  144. package/daemon/dist/context-pack-taxonomy-surface.js +1 -1
  145. package/daemon/dist/context-pack-taxonomy-surface.js.map +1 -1
  146. package/daemon/dist/daemon-db-path.d.ts.map +1 -1
  147. package/daemon/dist/daemon-db-path.js +45 -12
  148. package/daemon/dist/daemon-db-path.js.map +1 -1
  149. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  150. package/daemon/dist/db/all-migrations.js +14 -0
  151. package/daemon/dist/db/all-migrations.js.map +1 -1
  152. package/daemon/dist/db/migrations/132_seat_runtime_switches.d.ts +10 -0
  153. package/daemon/dist/db/migrations/132_seat_runtime_switches.d.ts.map +1 -0
  154. package/daemon/dist/db/migrations/132_seat_runtime_switches.js +46 -0
  155. package/daemon/dist/db/migrations/132_seat_runtime_switches.js.map +1 -0
  156. package/daemon/dist/db/migrations/133_stream_reader_actions.d.ts +8 -0
  157. package/daemon/dist/db/migrations/133_stream_reader_actions.d.ts.map +1 -0
  158. package/daemon/dist/db/migrations/133_stream_reader_actions.js +25 -0
  159. package/daemon/dist/db/migrations/133_stream_reader_actions.js.map +1 -0
  160. package/daemon/dist/db/migrations/134_claude_token_readings.d.ts +3 -0
  161. package/daemon/dist/db/migrations/134_claude_token_readings.d.ts.map +1 -0
  162. package/daemon/dist/db/migrations/134_claude_token_readings.js +21 -0
  163. package/daemon/dist/db/migrations/134_claude_token_readings.js.map +1 -0
  164. package/daemon/dist/db/migrations/136_node_launch_recipe.d.ts +9 -0
  165. package/daemon/dist/db/migrations/136_node_launch_recipe.d.ts.map +1 -0
  166. package/daemon/dist/db/migrations/136_node_launch_recipe.js +11 -0
  167. package/daemon/dist/db/migrations/136_node_launch_recipe.js.map +1 -0
  168. package/daemon/dist/db/migrations/137_node_codex_permissions.d.ts +3 -0
  169. package/daemon/dist/db/migrations/137_node_codex_permissions.d.ts.map +1 -0
  170. package/daemon/dist/db/migrations/137_node_codex_permissions.js +7 -0
  171. package/daemon/dist/db/migrations/137_node_codex_permissions.js.map +1 -0
  172. package/daemon/dist/db/migrations/138_node_claude_token_ref.d.ts +3 -0
  173. package/daemon/dist/db/migrations/138_node_claude_token_ref.d.ts.map +1 -0
  174. package/daemon/dist/db/migrations/138_node_claude_token_ref.js +8 -0
  175. package/daemon/dist/db/migrations/138_node_claude_token_ref.js.map +1 -0
  176. package/daemon/dist/db/migrations/139_node_claude_permissions.d.ts +3 -0
  177. package/daemon/dist/db/migrations/139_node_claude_permissions.d.ts.map +1 -0
  178. package/daemon/dist/db/migrations/139_node_claude_permissions.js +5 -0
  179. package/daemon/dist/db/migrations/139_node_claude_permissions.js.map +1 -0
  180. package/daemon/dist/domain/active-occupant.js +1 -1
  181. package/daemon/dist/domain/active-occupant.js.map +1 -1
  182. package/daemon/dist/domain/agent-activity-store.d.ts +1 -1
  183. package/daemon/dist/domain/agent-activity-store.js +2 -2
  184. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  185. package/daemon/dist/domain/agent-resolver.js +1 -1
  186. package/daemon/dist/domain/agent-resolver.js.map +1 -1
  187. package/daemon/dist/domain/bind-plan.js +1 -1
  188. package/daemon/dist/domain/bind-plan.js.map +1 -1
  189. package/daemon/dist/domain/bootstrap-orchestrator.d.ts.map +1 -1
  190. package/daemon/dist/domain/bootstrap-orchestrator.js +16 -1
  191. package/daemon/dist/domain/bootstrap-orchestrator.js.map +1 -1
  192. package/daemon/dist/domain/bundle-skills-router.js +2 -2
  193. package/daemon/dist/domain/bundle-skills-router.js.map +1 -1
  194. package/daemon/dist/domain/claim-service.js +1 -1
  195. package/daemon/dist/domain/claim-service.js.map +1 -1
  196. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +24 -1
  197. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  198. package/daemon/dist/domain/claude-compaction-enforcer.js +70 -16
  199. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  200. package/daemon/dist/domain/claude-credential-precedence.d.ts +33 -0
  201. package/daemon/dist/domain/claude-credential-precedence.d.ts.map +1 -0
  202. package/daemon/dist/domain/claude-credential-precedence.js +62 -0
  203. package/daemon/dist/domain/claude-credential-precedence.js.map +1 -0
  204. package/daemon/dist/domain/claude-managed-launch.d.ts +43 -4
  205. package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
  206. package/daemon/dist/domain/claude-managed-launch.js +129 -27
  207. package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
  208. package/daemon/dist/domain/claude-permission-rules.d.ts +10 -0
  209. package/daemon/dist/domain/claude-permission-rules.d.ts.map +1 -0
  210. package/daemon/dist/domain/claude-permission-rules.js +41 -0
  211. package/daemon/dist/domain/claude-permission-rules.js.map +1 -0
  212. package/daemon/dist/domain/claude-seat-token.d.ts +30 -0
  213. package/daemon/dist/domain/claude-seat-token.d.ts.map +1 -0
  214. package/daemon/dist/domain/claude-seat-token.js +78 -0
  215. package/daemon/dist/domain/claude-seat-token.js.map +1 -0
  216. package/daemon/dist/domain/codex-auth.d.ts +148 -0
  217. package/daemon/dist/domain/codex-auth.d.ts.map +1 -0
  218. package/daemon/dist/domain/codex-auth.js +506 -0
  219. package/daemon/dist/domain/codex-auth.js.map +1 -0
  220. package/daemon/dist/domain/codex-daemon-support.d.ts +2 -1
  221. package/daemon/dist/domain/codex-daemon-support.d.ts.map +1 -1
  222. package/daemon/dist/domain/codex-daemon-support.js +3 -2
  223. package/daemon/dist/domain/codex-daemon-support.js.map +1 -1
  224. package/daemon/dist/domain/codex-git-add-dirs.d.ts +1 -1
  225. package/daemon/dist/domain/codex-git-add-dirs.d.ts.map +1 -1
  226. package/daemon/dist/domain/codex-member-permissions.d.ts +56 -0
  227. package/daemon/dist/domain/codex-member-permissions.d.ts.map +1 -0
  228. package/daemon/dist/domain/codex-member-permissions.js +140 -0
  229. package/daemon/dist/domain/codex-member-permissions.js.map +1 -0
  230. package/daemon/dist/domain/codex-network-default.d.ts +2 -1
  231. package/daemon/dist/domain/codex-network-default.d.ts.map +1 -1
  232. package/daemon/dist/domain/codex-network-default.js +3 -2
  233. package/daemon/dist/domain/codex-network-default.js.map +1 -1
  234. package/daemon/dist/domain/codex-owned-plugin-trust.d.ts.map +1 -1
  235. package/daemon/dist/domain/codex-owned-plugin-trust.js +2 -1
  236. package/daemon/dist/domain/codex-owned-plugin-trust.js.map +1 -1
  237. package/daemon/dist/domain/codex-team-workspace.d.ts +5 -0
  238. package/daemon/dist/domain/codex-team-workspace.d.ts.map +1 -1
  239. package/daemon/dist/domain/codex-team-workspace.js +37 -0
  240. package/daemon/dist/domain/codex-team-workspace.js.map +1 -1
  241. package/daemon/dist/domain/community-harness-first-input.d.ts +7 -0
  242. package/daemon/dist/domain/community-harness-first-input.d.ts.map +1 -0
  243. package/daemon/dist/domain/community-harness-first-input.js +16 -0
  244. package/daemon/dist/domain/community-harness-first-input.js.map +1 -0
  245. package/daemon/dist/domain/community-harness-presets.d.ts +2 -0
  246. package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
  247. package/daemon/dist/domain/community-harness-presets.js +4 -2
  248. package/daemon/dist/domain/community-harness-presets.js.map +1 -1
  249. package/daemon/dist/domain/compaction-restore-notice.d.ts +6 -0
  250. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -0
  251. package/daemon/dist/domain/compaction-restore-notice.js +27 -0
  252. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -0
  253. package/daemon/dist/domain/context-packs/context-pack-library-service.js +2 -2
  254. package/daemon/dist/domain/context-packs/context-pack-library-service.js.map +1 -1
  255. package/daemon/dist/domain/context-packs/seat-recap-store.d.ts +14 -0
  256. package/daemon/dist/domain/context-packs/seat-recap-store.d.ts.map +1 -1
  257. package/daemon/dist/domain/context-packs/seat-recap-store.js +57 -1
  258. package/daemon/dist/domain/context-packs/seat-recap-store.js.map +1 -1
  259. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  260. package/daemon/dist/domain/context-usage-store.js +6 -1
  261. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  262. package/daemon/dist/domain/current-work.d.ts +15 -4
  263. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  264. package/daemon/dist/domain/current-work.js +26 -13
  265. package/daemon/dist/domain/current-work.js.map +1 -1
  266. package/daemon/dist/domain/execution-candidate-reader.d.ts +16 -0
  267. package/daemon/dist/domain/execution-candidate-reader.d.ts.map +1 -0
  268. package/daemon/dist/domain/execution-candidate-reader.js +77 -0
  269. package/daemon/dist/domain/execution-candidate-reader.js.map +1 -0
  270. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  271. package/daemon/dist/domain/execution-view.js +21 -8
  272. package/daemon/dist/domain/execution-view.js.map +1 -1
  273. package/daemon/dist/domain/feed-perspective.d.ts +14 -0
  274. package/daemon/dist/domain/feed-perspective.d.ts.map +1 -0
  275. package/daemon/dist/domain/feed-perspective.js +36 -0
  276. package/daemon/dist/domain/feed-perspective.js.map +1 -0
  277. package/daemon/dist/domain/gateway/channel-operations.d.ts +1 -1
  278. package/daemon/dist/domain/gateway/channel-operations.d.ts.map +1 -1
  279. package/daemon/dist/domain/gateway/human-registry.d.ts +11 -4
  280. package/daemon/dist/domain/gateway/human-registry.d.ts.map +1 -1
  281. package/daemon/dist/domain/gateway/human-registry.js +36 -5
  282. package/daemon/dist/domain/gateway/human-registry.js.map +1 -1
  283. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
  284. package/daemon/dist/domain/gateway/operator-delivery-engine.js +8 -3
  285. package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
  286. package/daemon/dist/domain/gateway/participants.d.ts +180 -0
  287. package/daemon/dist/domain/gateway/participants.d.ts.map +1 -0
  288. package/daemon/dist/domain/gateway/participants.js +434 -0
  289. package/daemon/dist/domain/gateway/participants.js.map +1 -0
  290. package/daemon/dist/domain/gateway/slack/inbound-admission.d.ts +2 -2
  291. package/daemon/dist/domain/gateway/slack/inbound-admission.d.ts.map +1 -1
  292. package/daemon/dist/domain/gateway/slack/inbound-admission.js +73 -6
  293. package/daemon/dist/domain/gateway/slack/inbound-admission.js.map +1 -1
  294. package/daemon/dist/domain/gateway/slack/inbound.d.ts +19 -1
  295. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  296. package/daemon/dist/domain/gateway/slack/inbound.js +31 -14
  297. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  298. package/daemon/dist/domain/gateway/slack/message.d.ts +5 -1
  299. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  300. package/daemon/dist/domain/gateway/slack/message.js +25 -15
  301. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  302. package/daemon/dist/domain/gateway/slack/open-asks.d.ts +50 -0
  303. package/daemon/dist/domain/gateway/slack/open-asks.d.ts.map +1 -0
  304. package/daemon/dist/domain/gateway/slack/open-asks.js +215 -0
  305. package/daemon/dist/domain/gateway/slack/open-asks.js.map +1 -0
  306. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts +2 -0
  307. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts.map +1 -1
  308. package/daemon/dist/domain/gateway/slack/outbound-driver.js +1 -0
  309. package/daemon/dist/domain/gateway/slack/outbound-driver.js.map +1 -1
  310. package/daemon/dist/domain/gateway/slack/queue-access.d.ts +15 -1
  311. package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
  312. package/daemon/dist/domain/gateway/slack/queue-access.js +98 -29
  313. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  314. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
  315. package/daemon/dist/domain/gateway/slack/slack-delivery.js +1 -0
  316. package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
  317. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
  318. package/daemon/dist/domain/gateway/slack/slack-subsystem.js +60 -2
  319. package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
  320. package/daemon/dist/domain/gateway/slack/state-store.d.ts +3 -0
  321. package/daemon/dist/domain/gateway/slack/state-store.d.ts.map +1 -1
  322. package/daemon/dist/domain/gateway/slack/state-store.js +18 -0
  323. package/daemon/dist/domain/gateway/slack/state-store.js.map +1 -1
  324. package/daemon/dist/domain/hot-potato-enforcer.d.ts +1 -1
  325. package/daemon/dist/domain/managed-restore-read-access.d.ts +20 -0
  326. package/daemon/dist/domain/managed-restore-read-access.d.ts.map +1 -0
  327. package/daemon/dist/domain/managed-restore-read-access.js +77 -0
  328. package/daemon/dist/domain/managed-restore-read-access.js.map +1 -0
  329. package/daemon/dist/domain/markdown-address.d.ts.map +1 -1
  330. package/daemon/dist/domain/markdown-address.js +21 -2
  331. package/daemon/dist/domain/markdown-address.js.map +1 -1
  332. package/daemon/dist/domain/mission-control/mission-control-read-layer.d.ts.map +1 -1
  333. package/daemon/dist/domain/mission-control/mission-control-read-layer.js +3 -1
  334. package/daemon/dist/domain/mission-control/mission-control-read-layer.js.map +1 -1
  335. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +19 -3
  336. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  337. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +72 -21
  338. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  339. package/daemon/dist/domain/model-divergence/model-divergence-monitor.d.ts.map +1 -1
  340. package/daemon/dist/domain/model-divergence/model-divergence-monitor.js +18 -1
  341. package/daemon/dist/domain/model-divergence/model-divergence-monitor.js.map +1 -1
  342. package/daemon/dist/domain/native-permission-store.d.ts +8 -2
  343. package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
  344. package/daemon/dist/domain/native-permission-store.js +26 -8
  345. package/daemon/dist/domain/native-permission-store.js.map +1 -1
  346. package/daemon/dist/domain/native-resume-probe.d.ts +11 -0
  347. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  348. package/daemon/dist/domain/native-resume-probe.js +199 -37
  349. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  350. package/daemon/dist/domain/node-inventory.d.ts +5 -1
  351. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  352. package/daemon/dist/domain/node-inventory.js +18 -0
  353. package/daemon/dist/domain/node-inventory.js.map +1 -1
  354. package/daemon/dist/domain/node-launcher.d.ts +11 -0
  355. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  356. package/daemon/dist/domain/node-launcher.js +41 -6
  357. package/daemon/dist/domain/node-launcher.js.map +1 -1
  358. package/daemon/dist/domain/parent-session-env.d.ts +1 -1
  359. package/daemon/dist/domain/parent-session-env.d.ts.map +1 -1
  360. package/daemon/dist/domain/parent-session-env.js +3 -1
  361. package/daemon/dist/domain/parent-session-env.js.map +1 -1
  362. package/daemon/dist/domain/parked-query.d.ts +3 -0
  363. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  364. package/daemon/dist/domain/parked-query.js +1 -0
  365. package/daemon/dist/domain/parked-query.js.map +1 -1
  366. package/daemon/dist/domain/permission-account.d.ts +3 -0
  367. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  368. package/daemon/dist/domain/permission-account.js +60 -11
  369. package/daemon/dist/domain/permission-account.js.map +1 -1
  370. package/daemon/dist/domain/permission-drift-observer.js +1 -1
  371. package/daemon/dist/domain/permission-drift-observer.js.map +1 -1
  372. package/daemon/dist/domain/policies/delivery-digest-flush.d.ts +6 -2
  373. package/daemon/dist/domain/policies/delivery-digest-flush.d.ts.map +1 -1
  374. package/daemon/dist/domain/policies/delivery-digest-flush.js +34 -9
  375. package/daemon/dist/domain/policies/delivery-digest-flush.js.map +1 -1
  376. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +8 -0
  377. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
  378. package/daemon/dist/domain/policies/parked-owner-consumer.js +15 -1
  379. package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
  380. package/daemon/dist/domain/policies/quiet-release.d.ts +14 -0
  381. package/daemon/dist/domain/policies/quiet-release.d.ts.map +1 -1
  382. package/daemon/dist/domain/policies/quiet-release.js +13 -2
  383. package/daemon/dist/domain/policies/quiet-release.js.map +1 -1
  384. package/daemon/dist/domain/profile-resolution-worker.d.ts +1 -1
  385. package/daemon/dist/domain/profile-resolution-worker.d.ts.map +1 -1
  386. package/daemon/dist/domain/profile-resolution-worker.js +5 -5
  387. package/daemon/dist/domain/profile-resolution-worker.js.map +1 -1
  388. package/daemon/dist/domain/proof/judgments.d.ts +7 -4
  389. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  390. package/daemon/dist/domain/proof/judgments.js +12 -8
  391. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  392. package/daemon/dist/domain/proof/source-watch.d.ts +6 -1
  393. package/daemon/dist/domain/proof/source-watch.d.ts.map +1 -1
  394. package/daemon/dist/domain/proof/source-watch.js +241 -35
  395. package/daemon/dist/domain/proof/source-watch.js.map +1 -1
  396. package/daemon/dist/domain/provider/claude-auth-status-reader.d.ts +12 -0
  397. package/daemon/dist/domain/provider/claude-auth-status-reader.d.ts.map +1 -1
  398. package/daemon/dist/domain/provider/claude-auth-status-reader.js +4 -4
  399. package/daemon/dist/domain/provider/claude-auth-status-reader.js.map +1 -1
  400. package/daemon/dist/domain/provider/claude-seat-switch.d.ts +32 -0
  401. package/daemon/dist/domain/provider/claude-seat-switch.d.ts.map +1 -0
  402. package/daemon/dist/domain/provider/claude-seat-switch.js +136 -0
  403. package/daemon/dist/domain/provider/claude-seat-switch.js.map +1 -0
  404. package/daemon/dist/domain/provider/claude-token-usage.d.ts +34 -0
  405. package/daemon/dist/domain/provider/claude-token-usage.d.ts.map +1 -0
  406. package/daemon/dist/domain/provider/claude-token-usage.js +168 -0
  407. package/daemon/dist/domain/provider/claude-token-usage.js.map +1 -0
  408. package/daemon/dist/domain/provider/provider-account-readings.d.ts +7 -6
  409. package/daemon/dist/domain/provider/provider-account-readings.d.ts.map +1 -1
  410. package/daemon/dist/domain/provider/provider-account-readings.js +31 -10
  411. package/daemon/dist/domain/provider/provider-account-readings.js.map +1 -1
  412. package/daemon/dist/domain/provider/provider-collect.d.ts +3 -0
  413. package/daemon/dist/domain/provider/provider-collect.d.ts.map +1 -1
  414. package/daemon/dist/domain/provider/provider-collect.js +3 -2
  415. package/daemon/dist/domain/provider/provider-collect.js.map +1 -1
  416. package/daemon/dist/domain/provider/provider-seat-accounts.d.ts +1 -1
  417. package/daemon/dist/domain/provider/provider-seat-accounts.d.ts.map +1 -1
  418. package/daemon/dist/domain/provider/provider-seat-accounts.js +29 -2
  419. package/daemon/dist/domain/provider/provider-seat-accounts.js.map +1 -1
  420. package/daemon/dist/domain/provider/provider-service-impl.d.ts +38 -4
  421. package/daemon/dist/domain/provider/provider-service-impl.d.ts.map +1 -1
  422. package/daemon/dist/domain/provider/provider-service-impl.js +147 -5
  423. package/daemon/dist/domain/provider/provider-service-impl.js.map +1 -1
  424. package/daemon/dist/domain/provider/provider-service.d.ts +109 -4
  425. package/daemon/dist/domain/provider/provider-service.d.ts.map +1 -1
  426. package/daemon/dist/domain/provider/provider-signals.d.ts +3 -0
  427. package/daemon/dist/domain/provider/provider-signals.d.ts.map +1 -1
  428. package/daemon/dist/domain/provider/provider-signals.js +7 -2
  429. package/daemon/dist/domain/provider/provider-signals.js.map +1 -1
  430. package/daemon/dist/domain/provider/provider-types.d.ts +61 -5
  431. package/daemon/dist/domain/provider/provider-types.d.ts.map +1 -1
  432. package/daemon/dist/domain/provider/reactive-tap.d.ts +4 -0
  433. package/daemon/dist/domain/provider/reactive-tap.d.ts.map +1 -1
  434. package/daemon/dist/domain/provider/reactive-tap.js +3 -0
  435. package/daemon/dist/domain/provider/reactive-tap.js.map +1 -1
  436. package/daemon/dist/domain/provider/usage-across-hosts.d.ts.map +1 -1
  437. package/daemon/dist/domain/provider/usage-across-hosts.js +8 -2
  438. package/daemon/dist/domain/provider/usage-across-hosts.js.map +1 -1
  439. package/daemon/dist/domain/provider/usage-windows.d.ts +2 -0
  440. package/daemon/dist/domain/provider/usage-windows.d.ts.map +1 -1
  441. package/daemon/dist/domain/provider/usage-windows.js +4 -0
  442. package/daemon/dist/domain/provider/usage-windows.js.map +1 -1
  443. package/daemon/dist/domain/queue-destination-check.d.ts +5 -0
  444. package/daemon/dist/domain/queue-destination-check.d.ts.map +1 -1
  445. package/daemon/dist/domain/queue-destination-check.js +5 -1
  446. package/daemon/dist/domain/queue-destination-check.js.map +1 -1
  447. package/daemon/dist/domain/queue-owner.d.ts +9 -0
  448. package/daemon/dist/domain/queue-owner.d.ts.map +1 -1
  449. package/daemon/dist/domain/queue-owner.js +28 -0
  450. package/daemon/dist/domain/queue-owner.js.map +1 -1
  451. package/daemon/dist/domain/queue-repository.d.ts +41 -8
  452. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  453. package/daemon/dist/domain/queue-repository.js +143 -33
  454. package/daemon/dist/domain/queue-repository.js.map +1 -1
  455. package/daemon/dist/domain/queue-retention.d.ts +1 -1
  456. package/daemon/dist/domain/queue-retention.d.ts.map +1 -1
  457. package/daemon/dist/domain/queue-retention.js +6 -1
  458. package/daemon/dist/domain/queue-retention.js.map +1 -1
  459. package/daemon/dist/domain/queue-stuck-sweep.d.ts +14 -3
  460. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  461. package/daemon/dist/domain/queue-stuck-sweep.js +50 -8
  462. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  463. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  464. package/daemon/dist/domain/queue-wake-ladder.js +90 -28
  465. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  466. package/daemon/dist/domain/queue-wake-repository.d.ts +3 -0
  467. package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
  468. package/daemon/dist/domain/queue-wake-repository.js +5 -1
  469. package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
  470. package/daemon/dist/domain/restore-orchestrator.d.ts +30 -1
  471. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  472. package/daemon/dist/domain/restore-orchestrator.js +132 -14
  473. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  474. package/daemon/dist/domain/resume-metadata-refresher.d.ts +11 -2
  475. package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
  476. package/daemon/dist/domain/resume-metadata-refresher.js +32 -14
  477. package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
  478. package/daemon/dist/domain/resume-token-capture.d.ts +5 -1
  479. package/daemon/dist/domain/resume-token-capture.d.ts.map +1 -1
  480. package/daemon/dist/domain/resume-token-capture.js +3 -1
  481. package/daemon/dist/domain/resume-token-capture.js.map +1 -1
  482. package/daemon/dist/domain/review/compose.js +1 -1
  483. package/daemon/dist/domain/review/compose.js.map +1 -1
  484. package/daemon/dist/domain/review/gather.js +1 -1
  485. package/daemon/dist/domain/review/gather.js.map +1 -1
  486. package/daemon/dist/domain/rig-expansion-service.d.ts.map +1 -1
  487. package/daemon/dist/domain/rig-expansion-service.js +2 -0
  488. package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
  489. package/daemon/dist/domain/rig-repository.d.ts +20 -2
  490. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  491. package/daemon/dist/domain/rig-repository.js +262 -2
  492. package/daemon/dist/domain/rig-repository.js.map +1 -1
  493. package/daemon/dist/domain/rig-teardown.d.ts +4 -1
  494. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  495. package/daemon/dist/domain/rig-teardown.js +6 -1
  496. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  497. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  498. package/daemon/dist/domain/rigspec-codec.js +8 -0
  499. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  500. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  501. package/daemon/dist/domain/rigspec-exporter.js +19 -1
  502. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  503. package/daemon/dist/domain/rigspec-instantiator.d.ts +43 -1
  504. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  505. package/daemon/dist/domain/rigspec-instantiator.js +321 -138
  506. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  507. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  508. package/daemon/dist/domain/rigspec-schema.js +47 -1
  509. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  510. package/daemon/dist/domain/running-name-guard.d.ts.map +1 -1
  511. package/daemon/dist/domain/running-name-guard.js +2 -1
  512. package/daemon/dist/domain/running-name-guard.js.map +1 -1
  513. package/daemon/dist/domain/runtime-adapter.d.ts +19 -1
  514. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  515. package/daemon/dist/domain/runtime-adapter.js +2 -0
  516. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  517. package/daemon/dist/domain/runtime-switch-materials.d.ts +77 -0
  518. package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -0
  519. package/daemon/dist/domain/runtime-switch-materials.js +253 -0
  520. package/daemon/dist/domain/runtime-switch-materials.js.map +1 -0
  521. package/daemon/dist/domain/scope/dot-id.js +2 -2
  522. package/daemon/dist/domain/scope/dot-id.js.map +1 -1
  523. package/daemon/dist/domain/scope/scaffold-placeholder.d.ts +1 -1
  524. package/daemon/dist/domain/scope/scaffold-placeholder.js +1 -1
  525. package/daemon/dist/domain/scope/scope-approve.d.ts +1 -1
  526. package/daemon/dist/domain/scope/scope-audit.js +1 -1
  527. package/daemon/dist/domain/scope/scope-audit.js.map +1 -1
  528. package/daemon/dist/domain/scope/types.d.ts.map +1 -1
  529. package/daemon/dist/domain/scope/types.js +2 -3
  530. package/daemon/dist/domain/scope/types.js.map +1 -1
  531. package/daemon/dist/domain/seat-activity-service.d.ts +4 -0
  532. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  533. package/daemon/dist/domain/seat-activity-service.js +17 -0
  534. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  535. package/daemon/dist/domain/seat-attention-reconciler.d.ts +8 -2
  536. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  537. package/daemon/dist/domain/seat-attention-reconciler.js +31 -2
  538. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  539. package/daemon/dist/domain/seat-handover-service.d.ts +1 -1
  540. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  541. package/daemon/dist/domain/seat-handover-service.js +7 -3
  542. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  543. package/daemon/dist/domain/seat-launch-environment.d.ts +5 -0
  544. package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
  545. package/daemon/dist/domain/seat-launch-environment.js +8 -4
  546. package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
  547. package/daemon/dist/domain/seat-lifecycle-service.d.ts +42 -11
  548. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  549. package/daemon/dist/domain/seat-lifecycle-service.js +210 -23
  550. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  551. package/daemon/dist/domain/seat-restart-in-place.d.ts +11 -4
  552. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  553. package/daemon/dist/domain/seat-restart-in-place.js +29 -9
  554. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  555. package/daemon/dist/domain/seat-runtime-dir.d.ts +17 -0
  556. package/daemon/dist/domain/seat-runtime-dir.d.ts.map +1 -0
  557. package/daemon/dist/domain/seat-runtime-dir.js +27 -0
  558. package/daemon/dist/domain/seat-runtime-dir.js.map +1 -0
  559. package/daemon/dist/domain/seat-runtime-home.d.ts +42 -0
  560. package/daemon/dist/domain/seat-runtime-home.d.ts.map +1 -0
  561. package/daemon/dist/domain/seat-runtime-home.js +89 -0
  562. package/daemon/dist/domain/seat-runtime-home.js.map +1 -0
  563. package/daemon/dist/domain/seat-runtime-switch-service.d.ts +227 -0
  564. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -0
  565. package/daemon/dist/domain/seat-runtime-switch-service.js +641 -0
  566. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -0
  567. package/daemon/dist/domain/seat-skills-pointer.d.ts +5 -0
  568. package/daemon/dist/domain/seat-skills-pointer.d.ts.map +1 -0
  569. package/daemon/dist/domain/seat-skills-pointer.js +15 -0
  570. package/daemon/dist/domain/seat-skills-pointer.js.map +1 -0
  571. package/daemon/dist/domain/seat-status-service.d.ts +32 -0
  572. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  573. package/daemon/dist/domain/seat-status-service.js +55 -0
  574. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  575. package/daemon/dist/domain/seat-structural-activity-service.d.ts +3 -0
  576. package/daemon/dist/domain/seat-structural-activity-service.d.ts.map +1 -1
  577. package/daemon/dist/domain/seat-structural-activity-service.js +7 -1
  578. package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
  579. package/daemon/dist/domain/service-orchestrator.d.ts +7 -0
  580. package/daemon/dist/domain/service-orchestrator.d.ts.map +1 -1
  581. package/daemon/dist/domain/service-orchestrator.js +4 -0
  582. package/daemon/dist/domain/service-orchestrator.js.map +1 -1
  583. package/daemon/dist/domain/session-registry.d.ts +2 -0
  584. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  585. package/daemon/dist/domain/session-registry.js +3 -1
  586. package/daemon/dist/domain/session-registry.js.map +1 -1
  587. package/daemon/dist/domain/session-transport.d.ts +62 -2
  588. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  589. package/daemon/dist/domain/session-transport.js +417 -67
  590. package/daemon/dist/domain/session-transport.js.map +1 -1
  591. package/daemon/dist/domain/skill-library-discovery.js +2 -2
  592. package/daemon/dist/domain/skill-library-discovery.js.map +1 -1
  593. package/daemon/dist/domain/slices/slice-indexer.d.ts +4 -4
  594. package/daemon/dist/domain/slices/slice-indexer.js +17 -17
  595. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  596. package/daemon/dist/domain/snapshot-capture.d.ts +4 -1
  597. package/daemon/dist/domain/snapshot-capture.d.ts.map +1 -1
  598. package/daemon/dist/domain/snapshot-capture.js +4 -1
  599. package/daemon/dist/domain/snapshot-capture.js.map +1 -1
  600. package/daemon/dist/domain/snapshot-repository.d.ts +4 -3
  601. package/daemon/dist/domain/snapshot-repository.d.ts.map +1 -1
  602. package/daemon/dist/domain/snapshot-repository.js +6 -5
  603. package/daemon/dist/domain/snapshot-repository.js.map +1 -1
  604. package/daemon/dist/domain/startup-orchestrator.d.ts +3 -16
  605. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  606. package/daemon/dist/domain/startup-orchestrator.js +65 -76
  607. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  608. package/daemon/dist/domain/startup-submission-evidence.d.ts +27 -0
  609. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  610. package/daemon/dist/domain/startup-submission-evidence.js +55 -0
  611. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  612. package/daemon/dist/domain/stream-reader-actions.d.ts +49 -0
  613. package/daemon/dist/domain/stream-reader-actions.d.ts.map +1 -0
  614. package/daemon/dist/domain/stream-reader-actions.js +104 -0
  615. package/daemon/dist/domain/stream-reader-actions.js.map +1 -0
  616. package/daemon/dist/domain/successor-session-launcher.d.ts +36 -1
  617. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  618. package/daemon/dist/domain/successor-session-launcher.js +59 -3
  619. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  620. package/daemon/dist/domain/terminal/herdr-adapter.d.ts +6 -28
  621. package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -1
  622. package/daemon/dist/domain/terminal/herdr-adapter.js +16 -66
  623. package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -1
  624. package/daemon/dist/domain/terminal/rex-adapter.d.ts +42 -0
  625. package/daemon/dist/domain/terminal/rex-adapter.d.ts.map +1 -0
  626. package/daemon/dist/domain/terminal/rex-adapter.js +228 -0
  627. package/daemon/dist/domain/terminal/rex-adapter.js.map +1 -0
  628. package/daemon/dist/domain/terminal/rex-layout.d.ts +26 -0
  629. package/daemon/dist/domain/terminal/rex-layout.d.ts.map +1 -0
  630. package/daemon/dist/domain/terminal/rex-layout.js +21 -0
  631. package/daemon/dist/domain/terminal/rex-layout.js.map +1 -0
  632. package/daemon/dist/domain/terminal/rex-transport.d.ts +43 -0
  633. package/daemon/dist/domain/terminal/rex-transport.d.ts.map +1 -0
  634. package/daemon/dist/domain/terminal/rex-transport.js +176 -0
  635. package/daemon/dist/domain/terminal/rex-transport.js.map +1 -0
  636. package/daemon/dist/domain/terminal/terminal-provider.d.ts +11 -0
  637. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  638. package/daemon/dist/domain/terminal/terminal-service.d.ts +2 -2
  639. package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
  640. package/daemon/dist/domain/terminal/terminal-service.js +10 -11
  641. package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
  642. package/daemon/dist/domain/terminal/tile-attach.d.ts +2 -0
  643. package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -0
  644. package/daemon/dist/domain/terminal/tile-attach.js +42 -0
  645. package/daemon/dist/domain/terminal/tile-attach.js.map +1 -0
  646. package/daemon/dist/domain/terminal/tile-layout.d.ts +32 -0
  647. package/daemon/dist/domain/terminal/tile-layout.d.ts.map +1 -0
  648. package/daemon/dist/domain/terminal/tile-layout.js +36 -0
  649. package/daemon/dist/domain/terminal/tile-layout.js.map +1 -0
  650. package/daemon/dist/domain/terminal/view-composer.d.ts.map +1 -1
  651. package/daemon/dist/domain/terminal/view-composer.js +11 -7
  652. package/daemon/dist/domain/terminal/view-composer.js.map +1 -1
  653. package/daemon/dist/domain/toml-tables.d.ts +20 -0
  654. package/daemon/dist/domain/toml-tables.d.ts.map +1 -0
  655. package/daemon/dist/domain/toml-tables.js +101 -0
  656. package/daemon/dist/domain/toml-tables.js.map +1 -0
  657. package/daemon/dist/domain/types.d.ts +86 -0
  658. package/daemon/dist/domain/types.d.ts.map +1 -1
  659. package/daemon/dist/domain/types.js.map +1 -1
  660. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  661. package/daemon/dist/domain/user-settings/settings-store.js +5 -6
  662. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  663. package/daemon/dist/domain/view-projector.d.ts +1 -0
  664. package/daemon/dist/domain/view-projector.d.ts.map +1 -1
  665. package/daemon/dist/domain/view-projector.js +15 -2
  666. package/daemon/dist/domain/view-projector.js.map +1 -1
  667. package/daemon/dist/domain/wake-recovery.d.ts +16 -0
  668. package/daemon/dist/domain/wake-recovery.d.ts.map +1 -0
  669. package/daemon/dist/domain/wake-recovery.js +31 -0
  670. package/daemon/dist/domain/wake-recovery.js.map +1 -0
  671. package/daemon/dist/domain/workflow-human-destination.d.ts.map +1 -1
  672. package/daemon/dist/domain/workflow-human-destination.js +5 -3
  673. package/daemon/dist/domain/workflow-human-destination.js.map +1 -1
  674. package/daemon/dist/domain/workflow-projector.d.ts +1 -0
  675. package/daemon/dist/domain/workflow-projector.d.ts.map +1 -1
  676. package/daemon/dist/domain/workflow-projector.js +19 -3
  677. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  678. package/daemon/dist/domain/workflow-runtime.d.ts +2 -2
  679. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  680. package/daemon/dist/domain/workflow-runtime.js +6 -4
  681. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  682. package/daemon/dist/gateway-human-registry-surface.d.ts +1 -0
  683. package/daemon/dist/gateway-human-registry-surface.d.ts.map +1 -1
  684. package/daemon/dist/gateway-human-registry-surface.js +1 -0
  685. package/daemon/dist/gateway-human-registry-surface.js.map +1 -1
  686. package/daemon/dist/index.d.ts.map +1 -1
  687. package/daemon/dist/index.js +7 -3
  688. package/daemon/dist/index.js.map +1 -1
  689. package/daemon/dist/lib/pane-envelope.d.ts +9 -0
  690. package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
  691. package/daemon/dist/lib/pane-envelope.js +9 -2
  692. package/daemon/dist/lib/pane-envelope.js.map +1 -1
  693. package/daemon/dist/routes/activity.d.ts.map +1 -1
  694. package/daemon/dist/routes/activity.js +13 -1
  695. package/daemon/dist/routes/activity.js.map +1 -1
  696. package/daemon/dist/routes/agent-images.d.ts.map +1 -1
  697. package/daemon/dist/routes/agent-images.js +19 -0
  698. package/daemon/dist/routes/agent-images.js.map +1 -1
  699. package/daemon/dist/routes/attention.d.ts.map +1 -1
  700. package/daemon/dist/routes/attention.js +15 -3
  701. package/daemon/dist/routes/attention.js.map +1 -1
  702. package/daemon/dist/routes/bundles.js +1 -1
  703. package/daemon/dist/routes/bundles.js.map +1 -1
  704. package/daemon/dist/routes/context-packs.d.ts.map +1 -1
  705. package/daemon/dist/routes/context-packs.js +22 -0
  706. package/daemon/dist/routes/context-packs.js.map +1 -1
  707. package/daemon/dist/routes/gateway.d.ts.map +1 -1
  708. package/daemon/dist/routes/gateway.js +42 -0
  709. package/daemon/dist/routes/gateway.js.map +1 -1
  710. package/daemon/dist/routes/hosts.d.ts.map +1 -1
  711. package/daemon/dist/routes/hosts.js +5 -2
  712. package/daemon/dist/routes/hosts.js.map +1 -1
  713. package/daemon/dist/routes/mission-control.d.ts.map +1 -1
  714. package/daemon/dist/routes/mission-control.js +7 -3
  715. package/daemon/dist/routes/mission-control.js.map +1 -1
  716. package/daemon/dist/routes/plugins.js +1 -1
  717. package/daemon/dist/routes/plugins.js.map +1 -1
  718. package/daemon/dist/routes/provider.d.ts.map +1 -1
  719. package/daemon/dist/routes/provider.js +83 -3
  720. package/daemon/dist/routes/provider.js.map +1 -1
  721. package/daemon/dist/routes/queue.d.ts.map +1 -1
  722. package/daemon/dist/routes/queue.js +136 -18
  723. package/daemon/dist/routes/queue.js.map +1 -1
  724. package/daemon/dist/routes/require-sender-identity.d.ts +10 -8
  725. package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
  726. package/daemon/dist/routes/require-sender-identity.js +13 -11
  727. package/daemon/dist/routes/require-sender-identity.js.map +1 -1
  728. package/daemon/dist/routes/rigs.js +4 -0
  729. package/daemon/dist/routes/rigs.js.map +1 -1
  730. package/daemon/dist/routes/runtime-switch-custody.d.ts +21 -0
  731. package/daemon/dist/routes/runtime-switch-custody.d.ts.map +1 -0
  732. package/daemon/dist/routes/runtime-switch-custody.js +55 -0
  733. package/daemon/dist/routes/runtime-switch-custody.js.map +1 -0
  734. package/daemon/dist/routes/scope-approve.js +2 -2
  735. package/daemon/dist/routes/scope-approve.js.map +1 -1
  736. package/daemon/dist/routes/scope-audit.js +1 -1
  737. package/daemon/dist/routes/scope-audit.js.map +1 -1
  738. package/daemon/dist/routes/seat.d.ts.map +1 -1
  739. package/daemon/dist/routes/seat.js +135 -18
  740. package/daemon/dist/routes/seat.js.map +1 -1
  741. package/daemon/dist/routes/sessions.d.ts.map +1 -1
  742. package/daemon/dist/routes/sessions.js +24 -3
  743. package/daemon/dist/routes/sessions.js.map +1 -1
  744. package/daemon/dist/routes/skills.js +1 -1
  745. package/daemon/dist/routes/skills.js.map +1 -1
  746. package/daemon/dist/routes/slices.js +1 -1
  747. package/daemon/dist/routes/slices.js.map +1 -1
  748. package/daemon/dist/routes/startup.js +15 -5
  749. package/daemon/dist/routes/startup.js.map +1 -1
  750. package/daemon/dist/routes/stream.d.ts.map +1 -1
  751. package/daemon/dist/routes/stream.js +25 -2
  752. package/daemon/dist/routes/stream.js.map +1 -1
  753. package/daemon/dist/routes/transcripts.js +2 -2
  754. package/daemon/dist/routes/transcripts.js.map +1 -1
  755. package/daemon/dist/routes/transport.d.ts.map +1 -1
  756. package/daemon/dist/routes/transport.js +41 -4
  757. package/daemon/dist/routes/transport.js.map +1 -1
  758. package/daemon/dist/routes/workflow.js +1 -1
  759. package/daemon/dist/routes/workflow.js.map +1 -1
  760. package/daemon/dist/seat-recap-store-surface.d.ts +1 -1
  761. package/daemon/dist/seat-recap-store-surface.d.ts.map +1 -1
  762. package/daemon/dist/seat-recap-store-surface.js +1 -1
  763. package/daemon/dist/seat-recap-store-surface.js.map +1 -1
  764. package/daemon/dist/server.d.ts +2 -0
  765. package/daemon/dist/server.d.ts.map +1 -1
  766. package/daemon/dist/server.js +1 -0
  767. package/daemon/dist/server.js.map +1 -1
  768. package/daemon/dist/startup.d.ts +5 -0
  769. package/daemon/dist/startup.d.ts.map +1 -1
  770. package/daemon/dist/startup.js +107 -29
  771. package/daemon/dist/startup.js.map +1 -1
  772. package/daemon/dist/terminal/TerminalSessionBroker.d.ts +18 -2
  773. package/daemon/dist/terminal/TerminalSessionBroker.d.ts.map +1 -1
  774. package/daemon/dist/terminal/TerminalSessionBroker.js +60 -9
  775. package/daemon/dist/terminal/TerminalSessionBroker.js.map +1 -1
  776. package/daemon/dist/terminal/window-pin.d.ts +41 -0
  777. package/daemon/dist/terminal/window-pin.d.ts.map +1 -0
  778. package/daemon/dist/terminal/window-pin.js +103 -0
  779. package/daemon/dist/terminal/window-pin.js.map +1 -0
  780. package/daemon/docs/reference/a2a-agents.md +16 -4
  781. package/daemon/docs/reference/agent-startup-guide.md +34 -2
  782. package/daemon/docs/reference/community-harness-examples/cursor/cursor.yaml +2 -2
  783. package/daemon/docs/reference/community-harness-examples/cursor/openrig-cursor-launch +7 -0
  784. package/daemon/docs/reference/community-harness-examples/hermes/config.yaml.example +2 -1
  785. package/daemon/docs/reference/community-harness-examples/openclaw/openclaw-gateway.yaml +15 -0
  786. package/daemon/docs/reference/community-harness-examples/openclaw/openclaw.yaml +5 -2
  787. package/daemon/docs/reference/community-harness-examples/openclaw/openrig-openclaw-launch +56 -24
  788. package/daemon/docs/reference/community-harness-presets.md +104 -19
  789. package/daemon/docs/reference/gateway-participants.md +165 -0
  790. package/daemon/docs/reference/getting-started.md +84 -10
  791. package/daemon/docs/reference/health-diagnosis.md +13 -0
  792. package/daemon/docs/reference/help.md +6 -0
  793. package/daemon/docs/reference/keeping-a-watch.md +21 -0
  794. package/daemon/docs/reference/project-workspace.md +18 -0
  795. package/daemon/docs/reference/publishing-a-rig-bundle.md +11 -0
  796. package/daemon/docs/reference/quickstart.md +13 -1
  797. package/daemon/docs/reference/rig-spec.md +179 -6
  798. package/daemon/docs/reference/sdlc-conventions.md +3 -1
  799. package/daemon/docs/reference/seat-delivery.md +25 -5
  800. package/daemon/docs/reference/seat-node-targeting.md +17 -0
  801. package/daemon/docs/reference/slack-app-setup.md +21 -3
  802. package/daemon/docs/reference/terminal-sessions.md +51 -0
  803. package/daemon/docs/reference/whats-new.md +148 -169
  804. package/daemon/specs/agents/shared/skills/core/messaging-the-human/SKILL.md +37 -3
  805. package/daemon/specs/agents/shared/skills/core/openrig-herdr/SKILL.md +20 -5
  806. package/daemon/specs/agents/shared/skills/process/agent-browser/LICENSE.txt +201 -0
  807. package/daemon/specs/agents/shared/skills/process/agent-browser/OPENRIG.md +13 -29
  808. package/daemon/specs/agents/shared/skills/process/agent-browser/SKILL.md +8 -8
  809. package/daemon/specs/agents/shared/skills/process/dogfood/LICENSE.txt +201 -0
  810. package/daemon/specs/agents/shared/skills/process/dogfood/SKILL.md +6 -2
  811. package/daemon/specs/agents/shared/skills/process/systematic-debugging/LICENSE.txt +21 -0
  812. package/daemon/specs/agents/shared/skills/process/systematic-debugging/SKILL.md +6 -2
  813. package/daemon/specs/agents/shared/skills/process/systematic-debugging/root-cause-tracing.md +1 -1
  814. package/daemon/specs/agents/shared/skills/process/test-driven-development/LICENSE.txt +21 -0
  815. package/daemon/specs/agents/shared/skills/process/test-driven-development/SKILL.md +5 -1
  816. package/daemon/specs/agents/shared/skills/process/verification-before-completion/LICENSE.txt +21 -0
  817. package/daemon/specs/agents/shared/skills/process/verification-before-completion/SKILL.md +5 -1
  818. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +18 -1
  819. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/startup/context.md +3 -0
  820. package/daemon/specs/rigs/launch/kernel/agents/queue/worker/guidance/role.md +3 -2
  821. package/dist/build-info.js +3 -3
  822. package/dist/client.d.ts +12 -0
  823. package/dist/client.d.ts.map +1 -1
  824. package/dist/client.js +20 -2
  825. package/dist/client.js.map +1 -1
  826. package/dist/commands/acp.js +1 -1
  827. package/dist/commands/auth.d.ts.map +1 -1
  828. package/dist/commands/auth.js +2 -1
  829. package/dist/commands/auth.js.map +1 -1
  830. package/dist/commands/capture.d.ts +27 -0
  831. package/dist/commands/capture.d.ts.map +1 -1
  832. package/dist/commands/capture.js +68 -2
  833. package/dist/commands/capture.js.map +1 -1
  834. package/dist/commands/chatroom.d.ts.map +1 -1
  835. package/dist/commands/chatroom.js +6 -0
  836. package/dist/commands/chatroom.js.map +1 -1
  837. package/dist/commands/context.d.ts.map +1 -1
  838. package/dist/commands/context.js +29 -23
  839. package/dist/commands/context.js.map +1 -1
  840. package/dist/commands/doctor.d.ts +9 -1
  841. package/dist/commands/doctor.d.ts.map +1 -1
  842. package/dist/commands/doctor.js +18 -2
  843. package/dist/commands/doctor.js.map +1 -1
  844. package/dist/commands/down.d.ts.map +1 -1
  845. package/dist/commands/down.js +9 -2
  846. package/dist/commands/down.js.map +1 -1
  847. package/dist/commands/env.d.ts.map +1 -1
  848. package/dist/commands/env.js +3 -0
  849. package/dist/commands/env.js.map +1 -1
  850. package/dist/commands/export.d.ts.map +1 -1
  851. package/dist/commands/export.js +57 -5
  852. package/dist/commands/export.js.map +1 -1
  853. package/dist/commands/gateway.d.ts.map +1 -1
  854. package/dist/commands/gateway.js +309 -23
  855. package/dist/commands/gateway.js.map +1 -1
  856. package/dist/commands/health.js +1 -1
  857. package/dist/commands/health.js.map +1 -1
  858. package/dist/commands/launch.js +1 -1
  859. package/dist/commands/launch.js.map +1 -1
  860. package/dist/commands/project.d.ts.map +1 -1
  861. package/dist/commands/project.js +6 -1
  862. package/dist/commands/project.js.map +1 -1
  863. package/dist/commands/proof.d.ts.map +1 -1
  864. package/dist/commands/proof.js +33 -2
  865. package/dist/commands/proof.js.map +1 -1
  866. package/dist/commands/provider.d.ts.map +1 -1
  867. package/dist/commands/provider.js +172 -24
  868. package/dist/commands/provider.js.map +1 -1
  869. package/dist/commands/queue.d.ts.map +1 -1
  870. package/dist/commands/queue.js +180 -38
  871. package/dist/commands/queue.js.map +1 -1
  872. package/dist/commands/rig-mode.d.ts +1 -2
  873. package/dist/commands/rig-mode.d.ts.map +1 -1
  874. package/dist/commands/rig-mode.js +2 -2
  875. package/dist/commands/rig-mode.js.map +1 -1
  876. package/dist/commands/scope.d.ts.map +1 -1
  877. package/dist/commands/scope.js +17 -6
  878. package/dist/commands/scope.js.map +1 -1
  879. package/dist/commands/seat.d.ts.map +1 -1
  880. package/dist/commands/seat.js +243 -6
  881. package/dist/commands/seat.js.map +1 -1
  882. package/dist/commands/send.d.ts +3 -0
  883. package/dist/commands/send.d.ts.map +1 -1
  884. package/dist/commands/send.js +16 -18
  885. package/dist/commands/send.js.map +1 -1
  886. package/dist/commands/setup.d.ts.map +1 -1
  887. package/dist/commands/setup.js +10 -2
  888. package/dist/commands/setup.js.map +1 -1
  889. package/dist/commands/skill.d.ts.map +1 -1
  890. package/dist/commands/skill.js +22 -1
  891. package/dist/commands/skill.js.map +1 -1
  892. package/dist/commands/slack.d.ts +10 -0
  893. package/dist/commands/slack.d.ts.map +1 -1
  894. package/dist/commands/slack.js +70 -2
  895. package/dist/commands/slack.js.map +1 -1
  896. package/dist/commands/stream-outcome.d.ts +586 -1
  897. package/dist/commands/stream-outcome.d.ts.map +1 -1
  898. package/dist/commands/stream-outcome.js +38 -1
  899. package/dist/commands/stream-outcome.js.map +1 -1
  900. package/dist/commands/stream.d.ts.map +1 -1
  901. package/dist/commands/stream.js +22 -0
  902. package/dist/commands/stream.js.map +1 -1
  903. package/dist/commands/terminal.d.ts +4 -0
  904. package/dist/commands/terminal.d.ts.map +1 -1
  905. package/dist/commands/terminal.js +7 -5
  906. package/dist/commands/terminal.js.map +1 -1
  907. package/dist/commands/up.d.ts.map +1 -1
  908. package/dist/commands/up.js +7 -1
  909. package/dist/commands/up.js.map +1 -1
  910. package/dist/config-store.d.ts.map +1 -1
  911. package/dist/config-store.js +3 -2
  912. package/dist/config-store.js.map +1 -1
  913. package/dist/daemon-lifecycle.d.ts +1 -1
  914. package/dist/daemon-lifecycle.js +2 -2
  915. package/dist/daemon-lifecycle.js.map +1 -1
  916. package/dist/fetch-with-timeout.d.ts.map +1 -1
  917. package/dist/fetch-with-timeout.js +3 -1
  918. package/dist/fetch-with-timeout.js.map +1 -1
  919. package/dist/lib/codex-auth.d.ts +1 -147
  920. package/dist/lib/codex-auth.d.ts.map +1 -1
  921. package/dist/lib/codex-auth.js +2 -505
  922. package/dist/lib/codex-auth.js.map +1 -1
  923. package/dist/lib/scope/dot-id.js +2 -2
  924. package/dist/lib/scope/dot-id.js.map +1 -1
  925. package/dist/lib/scope/scaffold-placeholder.d.ts +1 -1
  926. package/dist/lib/scope/scaffold-placeholder.js +1 -1
  927. package/dist/lib/scope/scope-audit.js +1 -1
  928. package/dist/lib/scope/scope-audit.js.map +1 -1
  929. package/dist/lib/scope/types.d.ts.map +1 -1
  930. package/dist/lib/scope/types.js +2 -3
  931. package/dist/lib/scope/types.js.map +1 -1
  932. package/dist/long-request-fetch.d.ts +9 -0
  933. package/dist/long-request-fetch.d.ts.map +1 -0
  934. package/dist/long-request-fetch.js +48 -0
  935. package/dist/long-request-fetch.js.map +1 -0
  936. package/dist/mcp-server.d.ts.map +1 -1
  937. package/dist/mcp-server.js +53 -2
  938. package/dist/mcp-server.js.map +1 -1
  939. package/dist/release-surface/affected-skills.d.ts.map +1 -1
  940. package/dist/release-surface/affected-skills.js +1 -2
  941. package/dist/release-surface/affected-skills.js.map +1 -1
  942. package/dist/remote-host-ops.d.ts +1 -0
  943. package/dist/remote-host-ops.d.ts.map +1 -1
  944. package/dist/remote-host-ops.js +2 -2
  945. package/dist/remote-host-ops.js.map +1 -1
  946. package/dist/terminal-window-rex.d.ts +6 -0
  947. package/dist/terminal-window-rex.d.ts.map +1 -0
  948. package/dist/terminal-window-rex.js +129 -0
  949. package/dist/terminal-window-rex.js.map +1 -0
  950. package/dist/terminal-window.d.ts +2 -0
  951. package/dist/terminal-window.d.ts.map +1 -1
  952. package/dist/terminal-window.js +19 -7
  953. package/dist/terminal-window.js.map +1 -1
  954. package/dist/tmux-health.d.ts +26 -0
  955. package/dist/tmux-health.d.ts.map +1 -1
  956. package/dist/tmux-health.js +42 -0
  957. package/dist/tmux-health.js.map +1 -1
  958. package/package.json +1 -1
  959. package/tui/dist/attention/attention-model.d.ts +19 -0
  960. package/tui/dist/attention/attention-model.d.ts.map +1 -1
  961. package/tui/dist/attention/attention-model.js +38 -6
  962. package/tui/dist/attention/attention-model.js.map +1 -1
  963. package/tui/dist/commands/registry.d.ts.map +1 -1
  964. package/tui/dist/commands/registry.js +5 -2
  965. package/tui/dist/commands/registry.js.map +1 -1
  966. package/tui/dist/daemon-client.d.ts +13 -7
  967. package/tui/dist/daemon-client.d.ts.map +1 -1
  968. package/tui/dist/daemon-client.js +20 -11
  969. package/tui/dist/daemon-client.js.map +1 -1
  970. package/tui/dist/demo-data.js +17 -17
  971. package/tui/dist/demo-data.js.map +1 -1
  972. package/tui/dist/hydrate.d.ts +1 -1
  973. package/tui/dist/hydrate.d.ts.map +1 -1
  974. package/tui/dist/hydrate.js +35 -11
  975. package/tui/dist/hydrate.js.map +1 -1
  976. package/tui/dist/live-events.js +1 -1
  977. package/tui/dist/live-events.js.map +1 -1
  978. package/tui/dist/live.d.ts.map +1 -1
  979. package/tui/dist/live.js +6 -4
  980. package/tui/dist/live.js.map +1 -1
  981. package/tui/dist/main.js +27 -7
  982. package/tui/dist/main.js.map +1 -1
  983. package/tui/dist/page-read.js +1 -1
  984. package/tui/dist/page-read.js.map +1 -1
  985. package/tui/dist/render.d.ts.map +1 -1
  986. package/tui/dist/render.js +51 -7
  987. package/tui/dist/render.js.map +1 -1
  988. package/tui/dist/state.d.ts.map +1 -1
  989. package/tui/dist/state.js +5 -1
  990. package/tui/dist/state.js.map +1 -1
  991. package/tui/dist/terminals/open-window.d.ts +15 -6
  992. package/tui/dist/terminals/open-window.d.ts.map +1 -1
  993. package/tui/dist/terminals/open-window.js +47 -15
  994. package/tui/dist/terminals/open-window.js.map +1 -1
  995. package/tui/dist/terminals/terminal-model.d.ts +2 -1
  996. package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
  997. package/tui/dist/terminals/terminal-model.js +5 -4
  998. package/tui/dist/terminals/terminal-model.js.map +1 -1
  999. package/tui/dist/types.d.ts +10 -1
  1000. package/tui/dist/types.d.ts.map +1 -1
  1001. package/tui/dist/usage/usage-model.d.ts.map +1 -1
  1002. package/tui/dist/usage/usage-model.js +5 -3
  1003. package/tui/dist/usage/usage-model.js.map +1 -1
  1004. package/ui/dist/assets/{index-Blg-p32B.js → index-DV0UNxFw.js} +2 -2
  1005. package/ui/dist/index.html +1 -1
@@ -1,4 +1,5 @@
1
1
  import { codexEnvelopeArgs } from "../domain/codex-rebuild-permissions.js";
2
+ import { codexMemberEnvelope, observeCodexEnvelope, readProfileFingerprint } from "../domain/codex-member-permissions.js";
2
3
  import { operationalLaunchArg } from "./kernel-authority.js";
3
4
  import nodePath from "node:path";
4
5
  import fs from "node:fs";
@@ -33,9 +34,10 @@ const defaultCodexCli = (args, env) => new Promise((resolve) => {
33
34
  });
34
35
  // Codex's hook trust recipe (the key and hash Codex records for a trusted hook), kept in one script.
35
36
  const codexHookTrust = createRequire(import.meta.url)("../../assets/plugins/openrig-core/hooks/scripts/codex-hook-trust.cjs");
36
- import { listNativeProcesses, observeCodexPaneProcess, observeCodexForkProcess, verifyPaneIdleShell } from "../domain/native-process-lineage.js";
37
+ import { listNativeProcesses, observeCodexPaneProcess, observeCodexForkProcess, verifyCodexPaneProcess, verifyPaneIdleShell } from "../domain/native-process-lineage.js";
37
38
  import { recordSeatSkillWrite, seatPluginSkillsLossNote, seatProjectionComplete, seatSkillWriteRefusal } from "../domain/seat-skill-storage.js";
38
39
  import { codexPluginContentHash, planOwnedCodexContentApproval, recordOwnedCodexApproval } from "../domain/codex-owned-plugin-trust.js";
40
+ import { findTomlTable, opensTomlTable, parseTomlRoot, tomlArrayTableHeaderPath, tomlDefines, tomlTableHeaderPath } from "../domain/toml-tables.js";
39
41
  // The managed resume check's poll window: a quick phase, then an extended one for a slow boot.
40
42
  const RESUME_QUICK_ATTEMPTS = 6;
41
43
  const RESUME_EXTENDED_ATTEMPTS = 24;
@@ -58,6 +60,10 @@ export class CodexRuntimeAdapter {
58
60
  sleep;
59
61
  resolveHomeDirByPid;
60
62
  codexHome;
63
+ /** A seat's own CODEX_HOME from its member or rig `env:`, when it declares one. */
64
+ seatHome;
65
+ /** One thread-id resolver per Codex home its seats use, the daemon's included. */
66
+ threadResolvers = new Map();
61
67
  launchPath;
62
68
  // Housekeeping B1 fixback (guard-blocking, arch HK-AR-1 = whole-probe DI):
63
69
  // the Codex profile-LOAD probe is an injectable dep in the adapter's
@@ -66,15 +72,18 @@ export class CodexRuntimeAdapter {
66
72
  // so no real codex subprocess runs. Contract not weakened — production uses
67
73
  // the real probe by default.
68
74
  verifyProfilePreflight;
75
+ profileFingerprint;
69
76
  // #69: whether the installed Codex supports --no-daemon. Startup wires the real probe;
70
77
  // absent (unit tests, other embedders) keeps the existing invocation unchanged.
71
78
  detectDaemonSupport;
72
79
  // #275: Codex's own answer on whether the plain floor may get network access. Startup wires the
73
80
  // real reader; absent keeps every invocation unchanged.
74
81
  readNetworkDefault;
75
- // Issue #121: git metadata dirs for the fresh-launch `--add-dir`s (a linked worktree's `.git` is a file).
82
+ // Issue #121: git metadata dirs for the `--add-dir`s of fresh, resume and fork (a linked worktree's `.git` is a file).
76
83
  // Default = the real resolver; tests may inject a controlled one.
77
84
  resolveGitAddDirs;
85
+ // The seat's own topology folder for the `--add-dir`s of fresh, resume and fork. Absent: none is added.
86
+ prepareSeatFolder;
78
87
  prepareTeamWorkspace;
79
88
  resolveManagedConfigSettings;
80
89
  resolveHooksEnabled;
@@ -102,9 +111,12 @@ export class CodexRuntimeAdapter {
102
111
  this.resolveManagedConfigSettings = deps.resolveManagedConfigSettings;
103
112
  this.resolveHooksEnabled = deps.resolveHooksEnabled;
104
113
  this.prepareTeamWorkspace = deps.prepareTeamWorkspace;
114
+ this.prepareSeatFolder = deps.prepareSeatFolder;
105
115
  this.seatLaunchEnvironment = deps.seatLaunchEnvironment;
106
116
  this.fs = deps.fsOps;
107
117
  this.codexHome = deps.codexHome;
118
+ this.seatHome = deps.seatHome;
119
+ this.profileFingerprint = deps.profileFingerprint ?? readProfileFingerprint;
108
120
  this.launchPath = deps.launchPath;
109
121
  this.detectDaemonSupport = deps.detectDaemonSupport;
110
122
  this.readNetworkDefault = deps.readNetworkDefault;
@@ -112,28 +124,63 @@ export class CodexRuntimeAdapter {
112
124
  this.activityRelayPath = deps.activityRelayPath;
113
125
  this.listProcesses = deps.listProcesses ?? defaultListProcesses;
114
126
  this.resolveHomeDirByPid = deps.resolveHomeDirByPid ?? defaultResolveHomeDirByPid;
115
- const threadIdResolver = new CodexThreadIdResolver({
116
- defaultHome: this.fs.homedir ?? os.homedir(), codexHome: this.codexHome,
117
- resolveHomeDirByPid: this.resolveHomeDirByPid,
118
- });
119
- this.readThreadIdByPid = deps.readThreadIdByPid ?? ((pid, identity) => identity === undefined
120
- ? this.readThreadIdFromLogs(pid) : threadIdResolver.resolveForkChild(pid, identity));
127
+ // A seat with its own CODEX_HOME logs its threads there, so each read names the home it searches.
128
+ this.readThreadIdByPid = deps.readThreadIdByPid ?? ((pid, identity, home) => identity === undefined
129
+ ? this.readThreadIdFromLogs(pid, home) : this.threadResolverFor(home).resolveForkChild(pid, identity));
121
130
  // A just-launched resume may log only inside its start second, so this reads like a fork child's ("by-process").
122
131
  this.readResumeEvidence = deps.readResumeEvidence ?? (deps.readThreadIdByPid
123
- ? async (pid, identity) => {
124
- const threadId = (await deps.readThreadIdByPid(pid, identity))?.trim();
132
+ ? async (pid, identity, home) => {
133
+ const threadId = (await deps.readThreadIdByPid(pid, identity, home))?.trim();
125
134
  return threadId ? { threadId } : { reason: "no_log_row" };
126
135
  }
127
- : async (pid, identity) => {
136
+ : async (pid, identity, home) => {
128
137
  let reason;
129
- const threadId = (await threadIdResolver.resolveForkChild(pid, identity, (d) => { reason = d.reason; }))?.trim();
138
+ const threadId = (await this.threadResolverFor(home).resolveForkChild(pid, identity, (d) => { reason = d.reason; }))?.trim();
130
139
  return threadId ? { threadId } : { reason: reason ?? "no_log_row" };
131
140
  });
132
141
  this.resumeProofWindowMs = deps.resumeProofWindowMs ?? RESUME_QUICK_ATTEMPTS * RESUME_QUICK_SLEEP_MS + RESUME_EXTENDED_ATTEMPTS * RESUME_EXTENDED_SLEEP_MS;
133
142
  this.readinessSettings = deps.readinessSettings;
134
143
  this.sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
135
- this.verifyProfilePreflight = deps.verifyProfilePreflight
136
- ?? ((profile, cwd) => defaultProfilePreflight(profile, this.codexHome ? { cwd, codexHome: this.codexHome, launchPath: this.launchPath } : undefined));
144
+ this.verifyProfilePreflight = deps.verifyProfilePreflight ?? ((profile, cwd, home) => {
145
+ const selected = home ?? this.codexHome;
146
+ return defaultProfilePreflight(profile, selected ? { cwd, codexHome: selected, launchPath: this.launchPath } : undefined);
147
+ });
148
+ }
149
+ /** The home a seat's Codex uses: its own from its member or rig `env:`, else the daemon's explicit CODEX_HOME. Undefined
150
+ * keeps the legacy OS/PID home behavior. */
151
+ homeFor(binding) {
152
+ return this.ownHome(binding) ?? this.codexHome;
153
+ }
154
+ /** Only the seat's own CODEX_HOME, undefined when it declares none. Probes and readers get it as an extra argument
155
+ * only when it's set, so a seat without one calls them exactly as before. */
156
+ ownHome(binding) {
157
+ return binding?.nodeId ? this.seatHome?.(binding.nodeId) : undefined;
158
+ }
159
+ ownHomeCommandOpt(binding) {
160
+ const own = this.ownHome(binding);
161
+ return own ? { codexHome: own } : {};
162
+ }
163
+ ownHomeOpt(binding) {
164
+ const own = this.ownHome(binding);
165
+ return own ? { home: own } : {};
166
+ }
167
+ /** A thread id read for this seat's process, in the seat's own home when it declares one. */
168
+ readThreadIdForSeat(binding, pid, identity) {
169
+ const own = this.ownHome(binding);
170
+ if (own)
171
+ return this.readThreadIdByPid(pid, identity, own);
172
+ return identity === undefined ? this.readThreadIdByPid(pid) : this.readThreadIdByPid(pid, identity);
173
+ }
174
+ /** The thread-id resolver for one Codex home (undefined: the daemon's), kept so its process-home cache is reused. */
175
+ threadResolverFor(home) {
176
+ const selected = home ?? this.codexHome;
177
+ let resolver = this.threadResolvers.get(selected ?? "");
178
+ if (!resolver) {
179
+ resolver = new CodexThreadIdResolver({ defaultHome: this.fs.homedir ?? os.homedir(), codexHome: selected,
180
+ resolveHomeDirByPid: this.resolveHomeDirByPid });
181
+ this.threadResolvers.set(selected ?? "", resolver);
182
+ }
183
+ return resolver;
137
184
  }
138
185
  /**
139
186
  * Bring the Codex config.toml to the state OpenRig-managed seats need: feature flag,
@@ -142,8 +189,8 @@ export class CodexRuntimeAdapter {
142
189
  * them: a rig with no Codex seat leaves the user's config alone. A failure warns and does
143
190
  * not block the launch.
144
191
  */
145
- async ensureManagedConfig() {
146
- return this.withConfigLock(() => this.applyManagedConfig());
192
+ async ensureManagedConfig(home) {
193
+ return this.withConfigLock(() => this.applyManagedConfig(home));
147
194
  }
148
195
  /** Run `task` after every earlier config setup on this adapter has finished, whatever its outcome. */
149
196
  withConfigLock(task) {
@@ -151,16 +198,16 @@ export class CodexRuntimeAdapter {
151
198
  this.configLock = run.catch(() => undefined);
152
199
  return run;
153
200
  }
154
- async applyManagedConfig() {
201
+ async applyManagedConfig(home) {
155
202
  if (!this.resolveManagedConfigSettings)
156
203
  return undefined;
157
204
  try {
158
205
  const { enabled, codexVersion } = await this.resolveManagedConfigSettings();
159
- this.ensureCodexFeatureFlag(enabled, { codexVersion });
206
+ this.ensureCodexFeatureFlag(enabled, { codexVersion }, home);
160
207
  if (enabled)
161
- this.ensureCodexActivityHooks();
208
+ this.ensureCodexActivityHooks(home);
162
209
  else
163
- this.removeCodexActivityHooks();
210
+ this.removeCodexActivityHooks(home);
164
211
  return { hooksEnabled: enabled };
165
212
  }
166
213
  catch (err) {
@@ -192,7 +239,7 @@ export class CodexRuntimeAdapter {
192
239
  * doesn't disable the plugin (codexCorePluginEnablement), and only when the installed version differs from the vendored
193
240
  * one. Codex owns its plugin cache; its immutable legacy trust baseline is never rewritten.
194
241
  */
195
- async ensureCodexCorePlugin() {
242
+ async ensureCodexCorePlugin(home) {
196
243
  const report = (outcome, reason) => {
197
244
  if (outcome !== "current")
198
245
  console.error(`[openrig] codex core plugin ${outcome}: ${reason}`);
@@ -242,7 +289,7 @@ export class CodexRuntimeAdapter {
242
289
  return false;
243
290
  }
244
291
  };
245
- const codexHome = nodePath.dirname(this.resolveCodexConfigPath());
292
+ const codexHome = nodePath.dirname(this.resolveCodexConfigPath(home));
246
293
  const readLayers = () => codexReadableConfigLayers(codexHome, this.codexSystemConfigDir).map((layer) => {
247
294
  if (!this.fs.exists(layer.path))
248
295
  return { ...layer, state: "absent" };
@@ -283,7 +330,7 @@ export class CodexRuntimeAdapter {
283
330
  const firstInstall = !this.fs.exists(cacheRoot) && !layers.some(layer => layer.state === "read"
284
331
  && Object.hasOwn((parseToml(layer.content).plugins ?? {}), CODEX_CORE_PLUGIN_KEY));
285
332
  const renewContentApproval = (freshGrant = false) => {
286
- const configPath = this.resolveCodexConfigPath();
333
+ const configPath = this.resolveCodexConfigPath(home);
287
334
  const currentLayers = readLayers();
288
335
  if (codexCorePluginEnablement(currentLayers).decision !== "allow")
289
336
  return;
@@ -338,7 +385,7 @@ export class CodexRuntimeAdapter {
338
385
  let freshGrants = 0;
339
386
  const grantLayers = readLayers();
340
387
  if (firstInstall && codexCorePluginEnablement(grantLayers).decision === "allow" && matchesShippedTree(cachedDir)) {
341
- let content = this.fs.readFile(this.resolveCodexConfigPath());
388
+ let content = this.fs.readFile(this.resolveCodexConfigPath(home));
342
389
  const hookManifest = JSON.parse(fs.readFileSync(nodePath.join(shipped, "hooks/codex.json"), "utf8"));
343
390
  for (const [event, groups] of Object.entries(hookManifest.hooks)) {
344
391
  groups.forEach((group, groupIndex) => group.hooks.forEach((handler, handlerIndex) => {
@@ -359,7 +406,7 @@ export class CodexRuntimeAdapter {
359
406
  }
360
407
  }));
361
408
  }
362
- this.fs.writeFile(this.resolveCodexConfigPath(), content);
409
+ this.fs.writeFile(this.resolveCodexConfigPath(home), content);
363
410
  }
364
411
  renewContentApproval(freshGrants === 6);
365
412
  return report("installed", `${CODEX_CORE_PLUGIN_KEY} ${version} through Codex's own install (${enablement.reason})`);
@@ -394,14 +441,14 @@ export class CodexRuntimeAdapter {
394
441
  * that lived inside the auto-injected activity-hook provisioning path
395
442
  * pre-rip (plugin-primitive Phase 3a slice 3.1).
396
443
  */
397
- ensureCodexFeatureFlag(enabled, opts) {
444
+ ensureCodexFeatureFlag(enabled, opts, home) {
398
445
  if (!enabled)
399
446
  return;
400
447
  if (!opts?.codexVersion)
401
448
  return;
402
449
  if (isCodex013xOrLater(opts.codexVersion))
403
450
  return;
404
- const configPath = this.resolveCodexConfigPath();
451
+ const configPath = this.resolveCodexConfigPath(home);
405
452
  const existing = this.fs.exists(configPath) ? this.fs.readFile(configPath) : "";
406
453
  const updated = upsertCodexHooksFeature(existing);
407
454
  if (updated !== existing) {
@@ -430,7 +477,7 @@ export class CodexRuntimeAdapter {
430
477
  * codex TUI launch lacks that context and may not deliver SessionStart — not how OpenRig
431
478
  * launches seats.)
432
479
  */
433
- ensureCodexActivityHooks() {
480
+ ensureCodexActivityHooks(home) {
434
481
  const relay = this.activityRelayPath;
435
482
  if (!relay || !this.fs.exists(relay)) {
436
483
  if (relay) {
@@ -438,9 +485,20 @@ export class CodexRuntimeAdapter {
438
485
  }
439
486
  return;
440
487
  }
441
- const configPath = this.resolveCodexConfigPath();
488
+ const configPath = this.resolveCodexConfigPath(home);
442
489
  const existing = this.fs.exists(configPath) ? this.fs.readFile(configPath) : "";
490
+ // A Codex home that keeps its hooks in hooks.json gets OpenRig's there too: Codex warns when one layer mixes both
491
+ // formats. Without a hooks.json, the inline config.toml block below is unchanged.
492
+ const hooksPath = nodePath.join(nodePath.dirname(configPath), "hooks.json");
493
+ if (this.fs.exists(hooksPath)) {
494
+ this.ensureCodexJsonActivityHooks(existing, configPath, hooksPath, relay);
495
+ return;
496
+ }
443
497
  const withHooks = upsertCodexActivityHooks(existing, relay);
498
+ if (!changesOnlyOpenRigActivityHooks(existing, withHooks, `node "${relay}"`)) {
499
+ console.error(`[openrig] codex activity hooks skipped: ${configPath} can't be read as TOML, or writing OpenRig's hooks would change anything else; left untouched`);
500
+ return;
501
+ }
444
502
  if (withHooks !== existing) {
445
503
  this.fs.mkdirp(nodePath.dirname(configPath));
446
504
  this.fs.writeFile(configPath, withHooks);
@@ -458,6 +516,75 @@ export class CodexRuntimeAdapter {
458
516
  this.fs.writeFile(configPath, trusted);
459
517
  }
460
518
  }
519
+ /**
520
+ * OpenRig's activity hooks in an existing hooks.json: one marked group per event (statusMessage "OpenRig activity"),
521
+ * replaced where it already is or appended after the user's groups, so their positions (and the trust Codex keys by
522
+ * position) don't move. OpenRig's own inline block from an earlier launch moves out of config.toml; the user's hooks,
523
+ * in either file, stay where they are. Trust is written for exactly our groups, keyed by the hooks.json path. A file
524
+ * OpenRig can't read as hooks is left untouched, with a warning.
525
+ */
526
+ ensureCodexJsonActivityHooks(existing, configPath, hooksPath, relay) {
527
+ const original = this.fs.readFile(hooksPath);
528
+ let document;
529
+ try {
530
+ document = parseCodexHooksJson(original);
531
+ }
532
+ catch (err) {
533
+ console.error(`[openrig] codex activity hooks skipped: ${hooksPath} can't be read as hooks (${err.message}); left untouched`);
534
+ return;
535
+ }
536
+ const command = `node "${relay}"`;
537
+ const keySource = canonicalCodexHookSource(hooksPath);
538
+ const stripped = upsertCodexFeaturesHooksEnabled(stripCodexActivityHooks(existing, command));
539
+ let before = null;
540
+ let expected = null;
541
+ try {
542
+ before = parseToml(existing);
543
+ expected = parseToml(stripped);
544
+ }
545
+ catch (err) {
546
+ console.error(`[openrig] codex activity hooks skipped: ${configPath} can't be read as TOML (${err.message}); left untouched`);
547
+ return;
548
+ }
549
+ if (!expected)
550
+ return;
551
+ const inlineSource = canonicalCodexHookSource(configPath);
552
+ let config = stripped;
553
+ for (const event of OPENRIG_ACTIVITY_HOOK_EVENTS) {
554
+ const groups = document.hooks[event] ?? [];
555
+ const found = groups.findIndex(isOpenRigActivityGroup);
556
+ const groupIndex = found < 0 ? groups.length : found;
557
+ groups[groupIndex] = openRigActivityGroup(command);
558
+ document.hooks[event] = groups;
559
+ const { key, hash } = computeCodexHookTrust(event, { keySource, command, timeoutSec: 5, groupIndex, statusMessage: OPENRIG_ACTIVITY_STATUS });
560
+ config = upsertCodexHookTrust(config, key, hash);
561
+ // A person's disable of OpenRig's inline hook moves with it; an existing choice at the new key is kept as it is.
562
+ const inlineIndex = openRigInlineGroupIndex(before, event);
563
+ const disabled = inlineIndex >= 0
564
+ && codexHookStateOf(before)[`${inlineSource}:${CODEX_HOOK_EVENT_KEY_LABEL[event]}:${inlineIndex}:0`]?.enabled === false;
565
+ if (disabled)
566
+ config = upsertCodexHookDisabled(config, key);
567
+ const state = ((expected.hooks ??= {}).state ??= {});
568
+ state[key] = { ...state[key], trusted_hash: hash, ...(disabled ? { enabled: false } : {}) };
569
+ }
570
+ // The line writers must give exactly the planned fields in valid TOML (they don't read every TOML spelling);
571
+ // otherwise neither file changes, and OpenRig's old inline block, if any, stays working.
572
+ try {
573
+ if (!isDeepStrictEqual(parseToml(config), expected))
574
+ throw new Error("its trust records couldn't be written exactly");
575
+ }
576
+ catch (err) {
577
+ console.error(`[openrig] codex activity hooks skipped: ${configPath}: ${err.message}; left untouched`);
578
+ return;
579
+ }
580
+ const json = `${JSON.stringify(document, null, 2)}\n`;
581
+ if (json !== original)
582
+ this.fs.writeFile(hooksPath, json);
583
+ if (config !== existing) {
584
+ this.fs.mkdirp(nodePath.dirname(configPath));
585
+ this.fs.writeFile(configPath, config);
586
+ }
587
+ }
461
588
  /**
462
589
  * OPR.0.4.3.33 — compute + splice Codex's `[hooks.state."<key>"] trusted_hash` for our 4
463
590
  * authored activity hooks into `content`. `key_source` is the canonicalized config path
@@ -478,9 +605,19 @@ export class CodexRuntimeAdapter {
478
605
  // absolute path is the honest best guess; a canonicalization delta is fail-safe (gate reappears).
479
606
  }
480
607
  const command = `node "${relay}"`;
608
+ // upsertCodexActivityHooks has just written our marked block. Codex keys by the
609
+ // group's position among this event's groups, not its position inside our block.
610
+ // Count only the groups before the marker: a person's groups after it do not
611
+ // move ours, and their trust/disable records must not be written as ours.
612
+ // Without a marker (Codex's save left our groups where they sit), each group's own position.
613
+ const begin = content.indexOf(OPENRIG_ACTIVITY_HOOKS_BEGIN);
614
+ const parsed = parseToml(begin >= 0 ? content.slice(0, begin) : content);
481
615
  let next = content;
482
616
  for (const event of OPENRIG_ACTIVITY_HOOK_EVENTS) {
483
- const { key, hash } = computeCodexHookTrust(event, { keySource, command, timeoutSec: 5 });
617
+ const groupIndex = begin >= 0 ? parsed.hooks?.[event]?.length ?? 0 : openRigInlineGroupIndex(parsed, event);
618
+ if (groupIndex < 0)
619
+ continue;
620
+ const { key, hash } = computeCodexHookTrust(event, { keySource, command, timeoutSec: 5, groupIndex });
484
621
  next = upsertCodexHookTrust(next, key, hash);
485
622
  }
486
623
  return next;
@@ -492,13 +629,55 @@ export class CodexRuntimeAdapter {
492
629
  * Removes ONLY the managed block — preserves any user-owned hooks and leaves [features].hooks
493
630
  * (the Codex 0.139 default) intact. Idempotent; no-op when the config or the block is absent.
494
631
  */
495
- removeCodexActivityHooks() {
496
- const configPath = this.resolveCodexConfigPath();
497
- if (!this.fs.exists(configPath))
498
- return;
499
- const existing = this.fs.readFile(configPath);
500
- const updated = stripCodexActivityHooks(existing);
501
- if (updated !== existing) {
632
+ removeCodexActivityHooks(home) {
633
+ const configPath = this.resolveCodexConfigPath(home);
634
+ const hooksPath = nodePath.join(nodePath.dirname(configPath), "hooks.json");
635
+ const existing = this.fs.exists(configPath) ? this.fs.readFile(configPath) : null;
636
+ const current = this.activityRelayPath ? `node "${this.activityRelayPath}"` : undefined;
637
+ let updated = existing === null ? null : stripCodexActivityHooks(existing, current);
638
+ if (existing !== null && updated !== existing && !changesOnlyOpenRigActivityHooks(existing, updated, current)) {
639
+ console.error(`[openrig] codex activity hook removal skipped for ${configPath}: it can't be read as TOML, or removing OpenRig's hooks would change anything else; left untouched`);
640
+ updated = existing;
641
+ }
642
+ if (this.fs.exists(hooksPath)) {
643
+ // Only OpenRig's groups leave. Codex keys trust and disables by position, so each later group's state moves with it.
644
+ try {
645
+ const original = this.fs.readFile(hooksPath);
646
+ const document = parseCodexHooksJson(original);
647
+ const keySource = canonicalCodexHookSource(hooksPath);
648
+ let config = updated ?? "";
649
+ const expected = parseToml(config);
650
+ for (const event of OPENRIG_ACTIVITY_HOOK_EVENTS) {
651
+ const groups = document.hooks[event];
652
+ if (!groups)
653
+ continue;
654
+ const kept = groups.flatMap((group, index) => isOpenRigActivityGroup(group) ? [] : [index]);
655
+ if (kept.length === groups.length)
656
+ continue;
657
+ const prefix = `${keySource}:${CODEX_HOOK_EVENT_KEY_LABEL[event]}:`;
658
+ const newIndexOf = (index) => { const at = kept.indexOf(index); return at < 0 ? null : at; };
659
+ config = rekeyCodexHookStateText(config, prefix, newIndexOf);
660
+ if (expected.hooks?.state)
661
+ expected.hooks.state = rekeyCodexHookState(expected.hooks.state, prefix, newIndexOf);
662
+ if (kept.length > 0)
663
+ document.hooks[event] = kept.map((index) => groups[index]);
664
+ else
665
+ delete document.hooks[event];
666
+ }
667
+ if (!isDeepStrictEqual(withoutEmptyHookTables(parseToml(config)), withoutEmptyHookTables(expected))) {
668
+ throw new Error("its hooks' trust records couldn't be moved exactly");
669
+ }
670
+ const json = `${JSON.stringify(document, null, 2)}\n`;
671
+ if (json !== original)
672
+ this.fs.writeFile(hooksPath, json);
673
+ if (updated !== null)
674
+ updated = config;
675
+ }
676
+ catch (err) {
677
+ console.error(`[openrig] codex activity hook removal skipped for ${hooksPath}: ${err.message}; left untouched`);
678
+ }
679
+ }
680
+ if (existing !== null && updated !== null && updated !== existing) {
502
681
  this.fs.writeFile(configPath, updated);
503
682
  }
504
683
  }
@@ -523,7 +702,7 @@ export class CodexRuntimeAdapter {
523
702
  continue;
524
703
  }
525
704
  try {
526
- const didProject = this.projectEntry(entry, binding.cwd, warnings, binding.seatSkillsRoot, binding.seatSkillsRefused);
705
+ const didProject = this.projectEntry(entry, binding.cwd, warnings, binding.seatSkillsRoot, binding.seatSkillsRefused, this.homeFor(binding));
527
706
  if (didProject) {
528
707
  projected.push(entry.effectiveId);
529
708
  }
@@ -609,7 +788,7 @@ export class CodexRuntimeAdapter {
609
788
  const prepared = await this.prepareLaunch(binding, opts.name, undefined, { installCorePlugin: !opts.resumeToken });
610
789
  if (!prepared.ok)
611
790
  return prepared;
612
- const { modelArg, effortArg, appliedLaunch, postureArg, queueStateDirArg, daemonArg, networkArg, suppressAutoAddDirs } = prepared;
791
+ const { modelArg, effortArg, appliedLaunch, postureArg, queueStateDirArg, gitDirArg, seatFolderArg, daemonArg, networkArg } = prepared;
613
792
  // Fork branch: `codex fork <parent_thread_id>`. Captures the NEW thread id
614
793
  // post-fork. Parent thread id is NOT persisted onto the new seat record
615
794
  // (identity-honesty bedrock).
@@ -628,7 +807,9 @@ export class CodexRuntimeAdapter {
628
807
  // -s danger-full-access on every seat; otherwise the named profile, or OpenRig's explicit
629
808
  // -s workspace-write floor flag.
630
809
  // 0.5.2-07 A2-3: the FORK path threads the SPEC model too (fork-instantiate reverted it before).
631
- const cmd = `codex${daemonArg}${postureArg}${networkArg}${modelArg}${effortArg} fork${queueStateDirArg} ${shellQuote(parentId)}`;
810
+ // The git dirs and the seat folder follow the parent id: ps flattens argv, so a path with a space placed before the
811
+ // id would be read as the id when the fork is verified.
812
+ const cmd = `codex${daemonArg}${postureArg}${networkArg}${modelArg}${effortArg} fork${queueStateDirArg} ${shellQuote(parentId)}${gitDirArg}${seatFolderArg}`;
632
813
  const textResult = await this.tmux.sendShellCommand(binding.tmuxSession, await this.seatCommand(binding, cmd));
633
814
  if (!textResult.ok) {
634
815
  return { ok: false, error: `Failed to send launch command: ${textResult.message}` };
@@ -662,15 +843,11 @@ export class CodexRuntimeAdapter {
662
843
  // OPR.0.4.8.2: one posture decision (codexPostureArg) for the fresh launch too — YOLO forces
663
844
  // -s danger-full-access (overrides even a named profile); otherwise the named profile, or
664
845
  // OpenRig's explicit -s workspace-write floor flag.
665
- // Issue #121: only the fresh launch adds git metadata dirs; resume and fork never did.
666
- const gitDirArg = opts.resumeToken || binding.codexRebuildPermissions
667
- ? ""
668
- : suppressAutoAddDirs ? "" : (await this.resolveGitAddDirs(binding.cwd)).map((dir) => ` --add-dir ${shellQuote(dir)}`).join("");
669
846
  const cmd = opts.resumeToken
670
847
  // 0.5.2-07 A2-3: the pod-aware RESUME path threads the SPEC model too (reverted before — the
671
848
  // grounding map assumed codex parity with the claude adapter, but only fresh emitted -m).
672
849
  ? this.resumeCore(prepared, opts.resumeToken, binding)
673
- : `codex${daemonArg}${postureArg}${networkArg} -C ${shellQuote(binding.cwd)}${gitDirArg}${queueStateDirArg}${modelArg}${effortArg}`;
850
+ : `codex${daemonArg}${postureArg}${networkArg} -C ${shellQuote(binding.cwd)}${gitDirArg}${seatFolderArg}${queueStateDirArg}${modelArg}${effortArg}`;
674
851
  const textResult = await this.tmux.sendShellCommand(binding.tmuxSession, await this.seatCommand(binding, cmd));
675
852
  if (!textResult.ok) {
676
853
  return { ok: false, error: `Failed to send launch command: ${textResult.message}` };
@@ -679,7 +856,7 @@ export class CodexRuntimeAdapter {
679
856
  if (updatePrompt.failure)
680
857
  return updatePrompt.failure;
681
858
  if (opts.resumeToken) {
682
- const verification = await this.verifyResumeLaunch(binding.tmuxSession, updatePrompt, { resumeToken: opts.resumeToken });
859
+ const verification = await this.verifyResumeLaunch(binding.tmuxSession, updatePrompt, { resumeToken: opts.resumeToken, ...this.ownHomeOpt(binding) });
683
860
  if (!verification.ok)
684
861
  return verification;
685
862
  return { ok: true, resumeToken: opts.resumeToken, resumeType: "codex_id", appliedLaunch,
@@ -707,31 +884,65 @@ export class CodexRuntimeAdapter {
707
884
  }
708
885
  /** Type a command buildResumeCommand built into the pane's shell, then verify the resume as launchHarness
709
886
  * does. Nothing is prepared again, so the command runs exactly as it was built and checked. */
710
- async sendResumeCommand(tmuxSession, command, resumeToken) {
887
+ async sendResumeCommand(tmuxSession, command, resumeToken, nodeId, home) {
711
888
  const textResult = await this.tmux.sendShellCommand(tmuxSession, command);
712
889
  if (!textResult.ok)
713
890
  return { ok: false, error: `Failed to send launch command: ${textResult.message}` };
714
- return this.verifyResumeInPane(tmuxSession, resumeToken);
891
+ return this.verifyResumeInPane(tmuxSession, resumeToken, nodeId, home);
715
892
  }
716
893
  /** launchHarness's resume verification for a resume the caller started itself: dismiss a skippable update
717
- * prompt, then require a proven resumed conversation (never process-alive alone). */
718
- async verifyResumeInPane(tmuxSession, resumeToken) {
894
+ * prompt, then require a proven resumed conversation (never process-alive alone). The proof reads `home` when the
895
+ * caller read it from the running Codex, else the seat's own CODEX_HOME when `nodeId` names a seat that declares one,
896
+ * where its resumed Codex logs. */
897
+ async verifyResumeInPane(tmuxSession, resumeToken, nodeId, home) {
719
898
  const updatePrompt = { handled: false };
720
899
  await this.dismissSkippableCodexUpdatePrompt(tmuxSession, updatePrompt);
721
900
  if (updatePrompt.failure)
722
901
  return updatePrompt.failure;
723
- return this.verifyResumeLaunch(tmuxSession, updatePrompt, { resumeToken });
902
+ return this.verifyResumeLaunch(tmuxSession, updatePrompt, { resumeToken, ...(home ? { home } : this.ownHomeOpt({ nodeId })) });
903
+ }
904
+ /** The setter's check of a profile, in the config home this seat's launches use: its own CODEX_HOME, else the
905
+ * daemon's, resolved as launch resolves it. An absent file is reported, not refused: Codex loads a missing profile as
906
+ * an empty layer. A real load failure fails here as it does at launch. */
907
+ async observeProfile(profile, cwd, nodeId) {
908
+ const observedAt = new Date().toISOString();
909
+ const home = this.homeFor({ nodeId });
910
+ const own = this.ownHome({ nodeId });
911
+ if (!home) {
912
+ return { vantage: "unestablished", home: null, file: "unverified", load: "not_run", observedAt,
913
+ detail: "Neither this seat's env: nor the daemon sets CODEX_HOME, so this seat's pane keeps its own; OpenRig didn't check the profile there. Each launch still runs the native profile check." };
914
+ }
915
+ const path = nodePath.join(home, `${profile}.config.toml`);
916
+ // The hash is optional evidence, read without blocking; the native loader check below decides.
917
+ const print = await this.profileFingerprint(path).catch((error) => ({ state: "unreadable", reason: error.message }));
918
+ const base = { vantage: "configured_codex_home", home, file: print.state,
919
+ ...(print.state === "present" ? { sha256: print.sha256 } : {}), observedAt };
920
+ let probe;
921
+ // Only a confirmed native load failure is refused; a check that couldn't run is reported, not refused.
922
+ try {
923
+ probe = await (own ? this.verifyProfilePreflight(profile, cwd, own) : this.verifyProfilePreflight(profile, cwd));
924
+ }
925
+ catch (error) {
926
+ return { ...base, load: "not_run", detail: `The native profile check couldn't run (${error.message}); each launch runs it again.` };
927
+ }
928
+ if (!probe.ok)
929
+ return { ...base, load: "failed", detail: `${probe.error}${probe.migrationHint ? `\n Fix: ${probe.migrationHint}` : ""}` };
930
+ const unread = print.state === "unreadable" ? ` Its bytes weren't read for a hash (${print.reason}).` : "";
931
+ return { ...base, load: "ok", detail: print.state === "absent" ? `${path} is absent; Codex loads it as an empty layer, so base config applies.` : `${path} loads.${unread}` };
724
932
  }
725
933
  /** Launch flags shared by fresh, fork and resume, decided once per launch. With `running`, the probed and
726
934
  * prepared parts come from the running Codex instead, and no Codex process is started to decide them. */
727
935
  async prepareLaunch(binding, name, running, opts) {
728
936
  // The config write and, for a seat that selected openrig-core, its install run as one step under the config lock, so
729
937
  // concurrent launches never interleave them. An unselected seat's launch never installs.
938
+ // A seat with its own CODEX_HOME gets OpenRig's managed config (hooks, feature flag) and plugin in that home.
939
+ const home = this.homeFor(binding);
940
+ const own = this.ownHome(binding);
730
941
  await this.withConfigLock(async () => {
731
- const managed = await this.applyManagedConfig();
942
+ const managed = await this.applyManagedConfig(home);
732
943
  if (opts.installCorePlugin && managed?.hooksEnabled && this.resolveCorePluginSelected?.(binding.nodeId)) {
733
944
  try {
734
- await this.ensureCodexCorePlugin();
945
+ await this.ensureCodexCorePlugin(home);
735
946
  }
736
947
  catch (err) {
737
948
  console.error(`[openrig] runtime setup warning: ${err.message}`);
@@ -744,19 +955,23 @@ export class CodexRuntimeAdapter {
744
955
  const effortArg = effort ? ` -c ${shellQuote(`model_reasoning_effort="${effort}"`)}` : "";
745
956
  const profile = binding.codexConfigProfile?.trim();
746
957
  const profileArg = profile ? ` -p ${shellQuote(profile)}` : "";
747
- const posture = binding.codexRebuildPermissions
748
- ? profileArg + codexEnvelopeArgs(binding.codexRebuildPermissions)
958
+ // A handover rebuild's observed predecessor envelope, else the seat's own envelope, replaces the posture decision.
959
+ const memberEnvelope = binding.codexRebuildPermissions || !binding.codexPermissions ? undefined : codexMemberEnvelope(binding.codexPermissions);
960
+ const envelope = binding.codexRebuildPermissions ?? memberEnvelope;
961
+ const posture = envelope
962
+ ? profileArg + codexEnvelopeArgs(envelope)
749
963
  : codexPostureArg(profileArg, process.env, binding.launchPosture);
750
- const appliedLaunch = binding.codexRebuildPermissions
751
- ? { runtime: "codex", axis: "sandbox", state: "observed", value: binding.codexRebuildPermissions.sandboxPolicy.type,
752
- reason: "emitted_launch_arguments", ...(binding.codexRebuildPermissions.approvalPolicy === "never" ? { approvalPolicy: "never" } : {}) }
753
- : observeCodexSandbox(posture);
754
- const postureArg = posture + operationalLaunchArg(this.runtime, binding);
964
+ const appliedLaunch = envelope ? observeCodexEnvelope(envelope) : observeCodexSandbox(posture);
965
+ // The seat's envelope is not full access, so a policy's full_bypass extras don't follow it.
966
+ const postureArg = posture + operationalLaunchArg(this.runtime, memberEnvelope ? { ...binding, kernelAuthority: false, launchPosture: undefined } : binding);
755
967
  if (running) {
756
968
  // The running Codex already loaded its profile; drift in -p is the caller's to compare.
969
+ // Its own --add-dirs, git dirs included, carry over as they ran; none are resolved again. They follow the
970
+ // conversation id, as on every resume, so the resume proof reads the id even when a dir has a space.
757
971
  return { ok: true, model, modelArg, effort, effortArg, profile, appliedLaunch, postureArg,
758
- queueStateDirArg: running.addDirs.map((dir) => ` --add-dir ${shellQuote(dir)}`).join(""),
759
- suppressAutoAddDirs: false,
972
+ queueStateDirArg: "",
973
+ gitDirArg: running.addDirs.map((dir) => ` --add-dir ${shellQuote(dir)}`).join(""),
974
+ seatFolderArg: "",
760
975
  daemonOptOut: running.daemonOptOut, daemonArg: running.daemonOptOut ? " --no-daemon" : "",
761
976
  networkArg: running.networkOverride ? ` -c ${shellQuote(CODEX_NETWORK_DEFAULT_OVERRIDE)}` : "" };
762
977
  }
@@ -765,7 +980,7 @@ export class CodexRuntimeAdapter {
765
980
  // `codex -p <profile> resume` failure. An absent .config.toml passes
766
981
  // (Codex default-layers it; advisor Option B).
767
982
  if (profile) {
768
- const probeResult = await this.verifyProfilePreflight(profile, binding.cwd);
983
+ const probeResult = await (own ? this.verifyProfilePreflight(profile, binding.cwd, own) : this.verifyProfilePreflight(profile, binding.cwd));
769
984
  if (!probeResult.ok) {
770
985
  return {
771
986
  ok: false,
@@ -775,36 +990,47 @@ export class CodexRuntimeAdapter {
775
990
  }
776
991
  // Codex rejects writable --add-dir roots under a read-only sandbox. Only
777
992
  // suppress OpenRig's generated roots when later project layers cannot make it writable.
778
- const suppressAutoAddDirs = Boolean(!binding.codexRebuildPermissions && profile
779
- && posture === profileArg && this.profileRemainsReadOnly(profile, binding.cwd));
780
- const teamWorkspaceArg = !binding.codexRebuildPermissions && binding.teamPermissionDefault && !profile
993
+ // A seat envelope states its sandbox: read-only gets no generated roots; workspace-write keeps them.
994
+ const suppressAutoAddDirs = memberEnvelope ? memberEnvelope.sandboxPolicy.type === "read-only"
995
+ : Boolean(!binding.codexRebuildPermissions && profile && posture === profileArg && this.profileRemainsReadOnly(profile, binding.cwd, home));
996
+ // Issue #121: fresh, resume and fork get the same git metadata dirs, so a restored or forked seat can still commit.
997
+ // A rebuild keeps the writable roots its observed envelope names instead.
998
+ const gitDirArg = binding.codexRebuildPermissions || suppressAutoAddDirs
999
+ ? "" : (await this.resolveGitAddDirs(binding.cwd)).map((dir) => ` --add-dir ${shellQuote(dir)}`).join("");
1000
+ // The seat's own topology folder, so it can keep its LEARNED.md and recap: the same launches and the same suppression.
1001
+ const seatFolder = binding.codexRebuildPermissions || suppressAutoAddDirs ? undefined : this.prepareSeatFolder?.(name);
1002
+ const seatFolderArg = seatFolder ? ` --add-dir ${shellQuote(seatFolder)}` : "";
1003
+ const teamWorkspaceArg = !envelope && binding.teamPermissionDefault && !profile
781
1004
  && appliedLaunch.state === "observed" && appliedLaunch.value === "workspace-write"
782
1005
  ? codexTeamWorkspaceArg(this.prepareTeamWorkspace, name) : "";
783
1006
  const queueStateDirArg = binding.codexRebuildPermissions || suppressAutoAddDirs
784
1007
  ? "" : teamWorkspaceArg || this.buildQueueStateAddDirArg(name);
785
1008
  // #69: one daemon-support decision for this launch, for the Codex the seat pane runs
786
1009
  // (its cwd, the launch PATH), applied to fresh, fork and resume.
787
- const daemonSupport = this.detectDaemonSupport ? await this.detectDaemonSupport(binding.cwd) : undefined;
1010
+ const daemonSupport = this.detectDaemonSupport ? await (own ? this.detectDaemonSupport(binding.cwd, own) : this.detectDaemonSupport(binding.cwd)) : undefined;
788
1011
  if (daemonSupport?.kind === "unknown") {
789
1012
  return { ok: false, error: unknownDaemonSupportMessage(daemonSupport.detail) };
790
1013
  }
791
1014
  const daemonOptOut = daemonSupport?.kind === "supported";
792
1015
  const daemonArg = daemonOptOut ? " --no-daemon" : "";
793
- // #275: on the plain floor, network access unless Codex reports an opt-out or policy.
794
- const networkArg = binding.codexRebuildPermissions ? ""
795
- : await codexNetworkDefaultArg(this.readNetworkDefault, appliedLaunch, binding.cwd, name);
1016
+ // #275: on the plain floor, network access unless Codex reports an opt-out or policy. An envelope states its own.
1017
+ const networkArg = envelope ? ""
1018
+ : await codexNetworkDefaultArg(own && this.readNetworkDefault ? ((cwd) => this.readNetworkDefault(cwd, own)) : this.readNetworkDefault, appliedLaunch, binding.cwd, name);
796
1019
  // The launch facts keep the probed daemon choice, so a printed recovery command can repeat it; no probe, no fact.
797
1020
  const launchFacts = daemonSupport ? { ...appliedLaunch, daemonOptOut } : appliedLaunch;
798
- return { ok: true, model, modelArg, effort, effortArg, profile, appliedLaunch: launchFacts, postureArg, queueStateDirArg, suppressAutoAddDirs, daemonOptOut, daemonArg, networkArg };
1021
+ return { ok: true, model, modelArg, effort, effortArg, profile, appliedLaunch: launchFacts, postureArg, queueStateDirArg, gitDirArg, seatFolderArg, daemonOptOut, daemonArg, networkArg };
799
1022
  }
800
1023
  resumeCore(prepared, resumeToken, binding) {
801
- const { profile, queueStateDirArg, model, postureArg, networkArg, daemonOptOut, effort } = prepared;
802
- return buildCodexResumeCore(resumeToken, profile, false, queueStateDirArg.trim() || undefined, binding.launchPosture, model, `${postureArg}${networkArg}`, daemonOptOut, effort);
1024
+ const { profile, queueStateDirArg, gitDirArg, seatFolderArg, model, postureArg, networkArg, daemonOptOut, effort } = prepared;
1025
+ // The git dirs and the seat folder follow the conversation id, as on a fork, so the resume proof reads the id even
1026
+ // from a path with a space.
1027
+ return buildCodexResumeCore(resumeToken, profile, false, queueStateDirArg.trim() || undefined, binding.launchPosture, model, `${postureArg}${networkArg}`, daemonOptOut, effort)
1028
+ + gitDirArg + seatFolderArg;
803
1029
  }
804
1030
  async seatCommand(binding, cmd) {
805
1031
  return this.seatLaunchEnvironment
806
- ? await this.seatLaunchEnvironment.command(binding.tmuxSession, cmd, { codexCwd: binding.cwd, nodeId: binding.nodeId, generation: binding.launchGeneration, runtime: this.runtime })
807
- : this.launchCommand(cmd);
1032
+ ? await this.seatLaunchEnvironment.command(binding.tmuxSession, cmd, { codexCwd: binding.cwd, nodeId: binding.nodeId, generation: binding.launchGeneration, runtime: this.runtime, ...this.ownHomeCommandOpt(binding) })
1033
+ : this.launchCommand(cmd, this.homeFor(binding));
808
1034
  }
809
1035
  buildQueueStateAddDirArg(sessionName) {
810
1036
  const sharedDocsRoot = process.env.OPENRIG_SHARED_DOCS_ROOT?.trim()
@@ -816,8 +1042,8 @@ export class CodexRuntimeAdapter {
816
1042
  * Return true only when visible config proves a read-only profile within Codex's default project root.
817
1043
  * Unknown markers or unreadable layers retain the generated roots for native launch handling.
818
1044
  */
819
- profileRemainsReadOnly(profile, cwd) {
820
- const root = this.codexHome ?? nodePath.join(this.fs.homedir ?? os.homedir(), ".codex");
1045
+ profileRemainsReadOnly(profile, cwd, home = this.codexHome) {
1046
+ const root = home ?? nodePath.join(this.fs.homedir ?? os.homedir(), ".codex");
821
1047
  const path = nodePath.join(root, `${profile}.config.toml`);
822
1048
  const userPath = nodePath.join(root, "config.toml");
823
1049
  if (!this.fs.exists(path))
@@ -904,11 +1130,21 @@ export class CodexRuntimeAdapter {
904
1130
  }
905
1131
  const paneCommand = await this.tmux.getPaneCommand(binding.tmuxSession);
906
1132
  const paneContent = await this.captureProbeScreen(binding.tmuxSession);
907
- const probe = assessNativeResumeProbe({
1133
+ let probe = assessNativeResumeProbe({
908
1134
  runtime: "codex",
909
1135
  paneCommand,
910
1136
  paneContent,
911
1137
  });
1138
+ if (probe.code === "returned_to_shell" || probe.code === "awaiting_runtime") {
1139
+ const process = await verifyCodexPaneProcess({ target: binding.tmuxSession, tmux: this.tmux,
1140
+ listProcesses: this.listProcesses });
1141
+ if (process) {
1142
+ const currentPaneCommand = await this.tmux.getPaneCommand(binding.tmuxSession);
1143
+ const currentPaneContent = await this.captureProbeScreen(binding.tmuxSession);
1144
+ probe = assessNativeResumeProbe({ runtime: "codex", paneCommand: currentPaneCommand,
1145
+ paneContent: currentPaneContent, codexProcessVerified: true });
1146
+ }
1147
+ }
912
1148
  if (probe.code === "returned_to_shell") {
913
1149
  const isIdleShell = await verifyPaneIdleShell({
914
1150
  target: binding.tmuxSession,
@@ -937,7 +1173,7 @@ export class CodexRuntimeAdapter {
937
1173
  return null;
938
1174
  // Gate PID logs by process start time, then re-observe the whole foreground
939
1175
  // chain. Neither a reused PID nor a replacement pane proves this child.
940
- const child = (await this.readThreadIdByPid(before.process.pid, before.process.startedAt))?.trim();
1176
+ const child = (await this.readThreadIdForSeat(binding, before.process.pid, before.process.startedAt))?.trim();
941
1177
  if (!child || child === parentToken)
942
1178
  return null;
943
1179
  const after = await observeCodexForkProcess(input);
@@ -1011,10 +1247,10 @@ export class CodexRuntimeAdapter {
1011
1247
  return observation ? JSON.stringify([paneCommand, observation.fingerprint]) : null;
1012
1248
  }
1013
1249
  ensureManagedBootstrap(binding) {
1014
- this.provisionWorkspaceTrust(binding.cwd ?? null);
1250
+ this.provisionWorkspaceTrust(binding.cwd ?? null, this.homeFor(binding));
1015
1251
  }
1016
- projectEntry(entry, cwd, warnings, seatSkillsRoot, seatSkillsRefused) {
1017
- if (entry.category === "runtime_resource" && this.applyRuntimeResource(entry)) {
1252
+ projectEntry(entry, cwd, warnings, seatSkillsRoot, seatSkillsRefused, home) {
1253
+ if (entry.category === "runtime_resource" && this.applyRuntimeResource(entry, home)) {
1018
1254
  return true;
1019
1255
  }
1020
1256
  if (entry.category === "guidance" && entry.mergeStrategy === "managed_block") {
@@ -1157,11 +1393,11 @@ export class CodexRuntimeAdapter {
1157
1393
  default: return null;
1158
1394
  }
1159
1395
  }
1160
- applyRuntimeResource(entry) {
1396
+ applyRuntimeResource(entry, home) {
1161
1397
  if (entry.resourceType !== "codex_config_fragment") {
1162
1398
  return false;
1163
1399
  }
1164
- const configPath = this.resolveCodexConfigPath();
1400
+ const configPath = this.resolveCodexConfigPath(home);
1165
1401
  this.fs.mkdirp(nodePath.dirname(configPath));
1166
1402
  const existing = this.fs.exists(configPath) ? this.fs.readFile(configPath) : "";
1167
1403
  const fragment = this.fs.readFile(entry.absolutePath);
@@ -1173,6 +1409,9 @@ export class CodexRuntimeAdapter {
1173
1409
  assertFragmentOpensWithTable(fragment, entry.absolutePath, entry.effectiveId);
1174
1410
  const rendered = upsertManagedCodexConfigFragment(existing, entry.effectiveId, fragment);
1175
1411
  assertRendersAsLoadableToml(rendered, configPath, entry.effectiveId);
1412
+ if (!changesOnlyFragmentTables(existing, rendered, entry.effectiveId, fragment)) {
1413
+ throw new Error(`Codex config projection '${entry.effectiveId}' would change more than its own tables in ${configPath}; left unchanged.`);
1414
+ }
1176
1415
  this.fs.writeFile(configPath, rendered);
1177
1416
  return true;
1178
1417
  }
@@ -1204,10 +1443,10 @@ export class CodexRuntimeAdapter {
1204
1443
  detectDeliveryHint(path, content, orientation) {
1205
1444
  return resolveConcreteHint(path, content, orientation);
1206
1445
  }
1207
- provisionWorkspaceTrust(cwd) {
1446
+ provisionWorkspaceTrust(cwd, home) {
1208
1447
  if (!cwd)
1209
1448
  return;
1210
- const configPath = this.resolveCodexConfigPath();
1449
+ const configPath = this.resolveCodexConfigPath(home);
1211
1450
  this.fs.mkdirp(nodePath.dirname(configPath));
1212
1451
  let content = "";
1213
1452
  try {
@@ -1222,8 +1461,8 @@ export class CodexRuntimeAdapter {
1222
1461
  }
1223
1462
  this.fs.writeFile(configPath, content);
1224
1463
  }
1225
- resolveCodexConfigPath() {
1226
- const root = this.codexHome
1464
+ resolveCodexConfigPath(home = this.codexHome) {
1465
+ const root = home
1227
1466
  ?? nodePath.join(this.fs.homedir ?? os.homedir(), ".codex");
1228
1467
  return nodePath.join(root, "config.toml");
1229
1468
  }
@@ -1265,7 +1504,7 @@ export class CodexRuntimeAdapter {
1265
1504
  if (shellPid) {
1266
1505
  const codexPids = await this.findCodexDescendantPids(shellPid);
1267
1506
  for (const codexPid of codexPids) {
1268
- const threadId = await this.readThreadIdByPid(codexPid);
1507
+ const threadId = await this.readThreadIdForSeat(binding, codexPid);
1269
1508
  if (threadId)
1270
1509
  return threadId;
1271
1510
  }
@@ -1330,7 +1569,7 @@ export class CodexRuntimeAdapter {
1330
1569
  const value = await this.withinDeadline(Promise.resolve().then(work), deadline);
1331
1570
  return Date.now() >= deadline ? null : value;
1332
1571
  }
1333
- async proveResumedProcess(tmuxSession, resumeToken, deadline) {
1572
+ async proveResumedProcess(tmuxSession, resumeToken, deadline, home) {
1334
1573
  if (!this.tmux.getPanePid)
1335
1574
  return { kind: "unknown", reason: "the pane's process can't be read" };
1336
1575
  if (Date.now() >= deadline)
@@ -1347,7 +1586,7 @@ export class CodexRuntimeAdapter {
1347
1586
  }
1348
1587
  let evidence;
1349
1588
  try {
1350
- evidence = await this.beforeResumeDeadline(() => this.readResumeEvidence(before.process.pid, before.process.startedAt), deadline);
1589
+ evidence = await this.beforeResumeDeadline(() => home ? this.readResumeEvidence(before.process.pid, before.process.startedAt, home) : this.readResumeEvidence(before.process.pid, before.process.startedAt), deadline);
1351
1590
  }
1352
1591
  catch (err) {
1353
1592
  return { kind: "unknown", reason: `Codex's records couldn't be read (${err.message})` };
@@ -1447,6 +1686,27 @@ export class CodexRuntimeAdapter {
1447
1686
  paneCommand,
1448
1687
  paneContent,
1449
1688
  });
1689
+ if (probe.code === "returned_to_shell" || probe.code === "awaiting_runtime") {
1690
+ const process = resumeToken
1691
+ ? await this.beforeResumeDeadline(() => verifyCodexPaneProcess({ target: tmuxSession, tmux: this.tmux,
1692
+ listProcesses: this.listProcesses }), deadline)
1693
+ : await verifyCodexPaneProcess({ target: tmuxSession, tmux: this.tmux,
1694
+ listProcesses: this.listProcesses });
1695
+ if (process) {
1696
+ const current = resumeToken
1697
+ ? await this.beforeResumeDeadline(async () => ({
1698
+ command: await this.tmux.getPaneCommand(tmuxSession),
1699
+ content: await this.captureProbeScreen(tmuxSession),
1700
+ }), deadline)
1701
+ : { command: await this.tmux.getPaneCommand(tmuxSession), content: await this.captureProbeScreen(tmuxSession) };
1702
+ if (!current)
1703
+ break;
1704
+ paneCommand = current.command;
1705
+ paneContent = current.content;
1706
+ lastPaneContent = paneContent;
1707
+ probe = assessNativeResumeProbe({ runtime: "codex", paneCommand, paneContent, codexProcessVerified: true });
1708
+ }
1709
+ }
1450
1710
  if (probe.code === "no_saved_session") {
1451
1711
  return {
1452
1712
  ok: false,
@@ -1480,15 +1740,17 @@ export class CodexRuntimeAdapter {
1480
1740
  return { ok: true, resumeToken: undefined, resumeType: undefined };
1481
1741
  }
1482
1742
  if (probe.status === "resumed" && resumeToken) {
1483
- const proof = await this.proveResumedProcess(tmuxSession, resumeToken, deadline);
1743
+ const proof = await this.proveResumedProcess(tmuxSession, resumeToken, deadline, opts?.home);
1484
1744
  if (proof.kind === "match")
1485
1745
  return { ok: true, resumeToken, resumeType: "codex_id", resumedProcess: proof.process };
1486
1746
  if (proof.kind === "mismatch") {
1747
+ const detail = `Codex resume opened a different conversation: the resumed process's records name ${proof.threadId}, not the requested ${resumeToken}.`;
1487
1748
  return {
1488
1749
  ok: false,
1489
- error: `Codex resume opened a different conversation: the resumed process's records name ${proof.threadId}, not the requested ${resumeToken}. The session was preserved; nothing was restarted.`,
1750
+ error: `${detail} The session was preserved; nothing was restarted.`,
1490
1751
  recovery: "attention_required",
1491
1752
  resumeMismatch: { opened: proof.threadId },
1753
+ resumeDetail: detail,
1492
1754
  verifierInput: verifierInput(),
1493
1755
  evidence: paneContent.split("\n").slice(-12).join("\n"),
1494
1756
  };
@@ -1540,9 +1802,10 @@ export class CodexRuntimeAdapter {
1540
1802
  // Report the newest screen observed; a resumed or booting one names no gate. The loop's own decisions above used
1541
1803
  // lastUnresolved. The text follows the newest screen too, so an older gate's text never stands for a newer screen.
1542
1804
  const shown = report && report.probe.status !== "resumed" && report.probe.code !== "awaiting_runtime" ? report : null;
1543
- const unprovenText = unproven && report?.probe.status === "resumed"
1544
- ? `Codex resume could not be proven within the resume window: ${unproven}. The session was preserved; nothing was restarted.`
1805
+ const unprovenDetail = unproven && report?.probe.status === "resumed"
1806
+ ? `Codex resume could not be proven within the resume window: ${unproven}.`
1545
1807
  : null;
1808
+ const unprovenText = unprovenDetail ? `${unprovenDetail} The session was preserved; nothing was restarted.` : null;
1546
1809
  const newestText = unprovenText ? unprovenText : shown ? shown.probe.detail
1547
1810
  : report?.probe.status === "resumed" ? "Codex resume could not be confirmed: the last screen observed looked ready, but the resume check ended before proving a restored conversation."
1548
1811
  : report ? report.probe.detail
@@ -1558,6 +1821,7 @@ export class CodexRuntimeAdapter {
1558
1821
  // With a conversation to prove and no gate on the newest screen, the end is "not proven": whatever the last frame
1559
1822
  // was (a boot, a ready screen, or no capture at all before the deadline), the resumed Codex may be running.
1560
1823
  ...(resumeToken && !shown ? { resumeUnproven: true } : {}),
1824
+ ...(unprovenDetail ? { resumeDetail: unprovenDetail } : {}),
1561
1825
  verifierInput: verifierInput(),
1562
1826
  evidence: (report?.paneContent ?? lastPaneContent).split("\n").slice(-12).join("\n"),
1563
1827
  };
@@ -1566,11 +1830,11 @@ export class CodexRuntimeAdapter {
1566
1830
  const processes = await this.listProcesses();
1567
1831
  return findCodexDescendantPids(processes, parentPid);
1568
1832
  }
1569
- async readThreadIdFromLogs(pid) {
1570
- return readCodexThreadIdFromCandidateHomes(pid, this.codexHome ? [] : [await this.resolveHomeDirByPid(pid), this.fs.homedir, os.homedir()], (path) => this.fs.exists(path), this.codexHome);
1833
+ async readThreadIdFromLogs(pid, home = this.codexHome) {
1834
+ return readCodexThreadIdFromCandidateHomes(pid, home ? [] : [await this.resolveHomeDirByPid(pid), this.fs.homedir, os.homedir()], (path) => this.fs.exists(path), home);
1571
1835
  }
1572
- launchCommand(command) {
1573
- const env = [this.launchPath ? `PATH=${shellQuote(this.launchPath)}` : "", this.codexHome ? `CODEX_HOME=${shellQuote(this.codexHome)}` : ""].filter(Boolean);
1836
+ launchCommand(command, home = this.codexHome) {
1837
+ const env = [this.launchPath ? `PATH=${shellQuote(this.launchPath)}` : "", home ? `CODEX_HOME=${shellQuote(home)}` : ""].filter(Boolean);
1574
1838
  return env.length ? `env ${env.join(" ")} ${command}` : command;
1575
1839
  }
1576
1840
  }
@@ -1578,10 +1842,13 @@ function hashContent(content) {
1578
1842
  return createHash("sha256").update(content).digest("hex");
1579
1843
  }
1580
1844
  function upsertCodexProjectTrust(content, projectPath) {
1845
+ const path = ["projects", projectPath];
1581
1846
  const header = `[projects.${JSON.stringify(projectPath)}]`;
1582
1847
  const lines = content.length > 0 ? content.split("\n") : [];
1583
- const headerIndex = lines.findIndex((line) => line.trim() === header);
1848
+ const headerIndex = findTomlTable(lines, path);
1584
1849
  if (headerIndex === -1) {
1850
+ if (tomlDefines(content, path))
1851
+ return content;
1585
1852
  const trimmed = content.trimEnd();
1586
1853
  const prefix = trimmed.length > 0 ? `${trimmed}\n\n` : "";
1587
1854
  return `${prefix}${header}\ntrust_level = "trusted"\n`;
@@ -1672,16 +1939,19 @@ export function computeCodexHookTrust(event, input) {
1672
1939
  /**
1673
1940
  * OPR.0.4.3.33 — idempotent, non-clobbering, section-scoped writer for a single
1674
1941
  * `[hooks.state."<key>"] trusted_hash = "<hash>"` record. Mirrors upsertCodexProjectTrust:
1675
- * find/create the exact table header, splice ONLY its `trusted_hash` line, leave every other
1942
+ * find the table by its key in any spelling (or create it), splice ONLY its `trusted_hash` line, leave every other
1676
1943
  * `[hooks.state]` / `[projects]` entry and the managed hook block byte-identical. Same key+hash
1677
1944
  * ⇒ no-op. Only called for our authored inline or verified owned plugin keys (never blanket trust).
1678
1945
  */
1679
1946
  export function upsertCodexHookTrust(content, key, hash, field = "trusted_hash") {
1947
+ const path = ["hooks", "state", key];
1680
1948
  const header = `[hooks.state.${JSON.stringify(key)}]`;
1681
1949
  const trustLine = `${field} = ${JSON.stringify(hash)}`;
1682
1950
  const lines = content.length > 0 ? content.split("\n") : [];
1683
- const headerIndex = lines.findIndex((line) => line.trim() === header);
1951
+ const headerIndex = findTomlTable(lines, path);
1684
1952
  if (headerIndex === -1) {
1953
+ if (tomlDefines(content, path))
1954
+ return content;
1685
1955
  const trimmed = content.trimEnd();
1686
1956
  const prefix = trimmed.length > 0 ? `${trimmed}\n\n` : "";
1687
1957
  return `${prefix}${header}\n${trustLine}\n`;
@@ -1762,6 +2032,8 @@ function upsertCodexHooksFeature(content) {
1762
2032
  }
1763
2033
  // OPR.0.4.1.10 FR-A — config-layer activity-hook projection.
1764
2034
  const OPENRIG_ACTIVITY_HOOKS_BEGIN = "# BEGIN OPENRIG MANAGED ACTIVITY HOOKS";
2035
+ /** The status Codex shows while OpenRig's hooks.json activity hook runs; it also marks the group as OpenRig's. */
2036
+ const OPENRIG_ACTIVITY_STATUS = "OpenRig activity";
1765
2037
  const OPENRIG_ACTIVITY_HOOKS_END = "# END OPENRIG MANAGED ACTIVITY HOOKS";
1766
2038
  const OPENRIG_ACTIVITY_HOOK_EVENTS = ["SessionStart", "UserPromptSubmit", "Stop", "PermissionRequest"];
1767
2039
  /**
@@ -1781,24 +2053,288 @@ function upsertCodexActivityHooks(content, relayPath) {
1781
2053
  .join("\n\n");
1782
2054
  const block = `${OPENRIG_ACTIVITY_HOOKS_BEGIN}\n${stanzas}\n${OPENRIG_ACTIVITY_HOOKS_END}\n`;
1783
2055
  let next = upsertCodexFeaturesHooksEnabled(content);
1784
- const pattern = new RegExp(`${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_BEGIN)}[\\s\\S]*?${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_END)}\\n?`, "m");
2056
+ const pattern = new RegExp(`${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_BEGIN)}([\\s\\S]*?)${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_END)}\\n?`, "m");
1785
2057
  if (pattern.test(next)) {
1786
- return next.replace(pattern, () => block); // literal: a string would expand `$` patterns in the path
2058
+ // literal: a string would expand `$` patterns in the path
2059
+ return next.replace(pattern, (_span, inner) => {
2060
+ const kept = keptInActivityBlock(inner, `node "${relayPath}"`);
2061
+ return kept ? `${block}\n${kept}\n` : block;
2062
+ });
1787
2063
  }
2064
+ // Codex's own saves can leave our markers apart from our groups. Groups that already run OpenRig's relay are ours
2065
+ // where they sit: point them at this relay rather than append a second set, which Codex would run twice.
2066
+ const relayGroups = retargetOpenRigRelayGroups(next, command, `node "${relayPath}"`);
2067
+ if (relayGroups !== null)
2068
+ return relayGroups;
1788
2069
  const prefix = next.replace(/\n*$/, "");
1789
2070
  return prefix.length > 0 ? `${prefix}\n\n${block}` : block;
1790
2071
  }
2072
+ /**
2073
+ * What else sits between OpenRig's activity-hook markers. When Codex saves config.toml (its "Trust all", say), a
2074
+ * table it rewrites loses its file position and is printed after the last hook group, which can be inside our
2075
+ * block: Codex 0.164.0 rewrites all of `[hooks.state]` this way. Every section but OpenRig's own activity groups is
2076
+ * kept whole, with the comments just above it.
2077
+ */
2078
+ function keptInActivityBlock(inner, current) {
2079
+ const lines = inner.split("\n");
2080
+ return tomlSections(inner, current).filter((section) => !section.openRig)
2081
+ .map(({ start, end }) => lines.slice(start, end).join("\n")).join("\n").trim();
2082
+ }
2083
+ /** Point every inline group that runs OpenRig's relay (from any install) at `command` (TOML text), in place; null when
2084
+ * there's none, or the file can't be read as TOML. Only those groups' own `command` lines change: a person's groups,
2085
+ * their other text and every position stay as they are. */
2086
+ function retargetOpenRigRelayGroups(content, command, current) {
2087
+ let document;
2088
+ try {
2089
+ document = parseToml(content);
2090
+ }
2091
+ catch {
2092
+ return null;
2093
+ }
2094
+ if (!OPENRIG_ACTIVITY_HOOK_EVENTS.some((event) => openRigInlineGroupIndex(document, event) >= 0))
2095
+ return null;
2096
+ const lines = content.split("\n");
2097
+ const topLevel = lineStartsAtDocumentLevel(content);
2098
+ for (const { header, end, path, openRig } of tomlSections(content, current)) {
2099
+ if (!openRig || path.length !== 3)
2100
+ continue;
2101
+ for (let at = header + 1; at < end; at++)
2102
+ if (topLevel[at] && /^\s*command\s*=/.test(lines[at]))
2103
+ lines[at] = `command = ${command}`;
2104
+ }
2105
+ return lines.join("\n");
2106
+ }
2107
+ /** `text` split at its real table headers, never at text inside a string or an array. Lines before the first header
2108
+ * belong to no section. */
2109
+ function tomlSections(text, current) {
2110
+ const lines = text.split("\n");
2111
+ const topLevel = lineStartsAtDocumentLevel(text);
2112
+ const sections = [];
2113
+ for (const [at, line] of lines.entries()) {
2114
+ if (!topLevel[at] || !line.trim().startsWith("["))
2115
+ continue;
2116
+ const path = tomlArrayTableHeaderPath(line) ?? tomlTableHeaderPath(line);
2117
+ if (!path)
2118
+ continue;
2119
+ let start = at;
2120
+ while (start > 0 && topLevel[start - 1] && /^\s*(?:#.*)?$/.test(lines[start - 1]))
2121
+ start--;
2122
+ const previous = sections.at(-1);
2123
+ if (previous)
2124
+ previous.end = start;
2125
+ sections.push({ start, header: at, end: lines.length, path, openRig: false });
2126
+ }
2127
+ const events = OPENRIG_ACTIVITY_HOOK_EVENTS;
2128
+ const under = (section, event) => section.path[0] === "hooks" && section.path[1] === event;
2129
+ for (let first = 0; first < sections.length; first++) {
2130
+ const { path } = sections[first];
2131
+ const event = path[1];
2132
+ if (path[0] !== "hooks" || !events.includes(event) || path.length > 3 || (path.length === 3 && path[2] !== "hooks"))
2133
+ continue;
2134
+ let last = first;
2135
+ while (path.length === 2 && last + 1 < sections.length && sections[last + 1].path.length > 2 && under(sections[last + 1], event))
2136
+ last++;
2137
+ let group;
2138
+ try {
2139
+ const hooks = parseToml(lines.slice(sections[first].start, sections[last].end).join("\n")).hooks?.[event];
2140
+ // A group's own header gives a list holding it; a handler stanza on its own reads as the group it adds to.
2141
+ group = path.length === 2 ? (Array.isArray(hooks) && hooks.length === 1 ? hooks[0] : null) : hooks;
2142
+ }
2143
+ catch {
2144
+ group = null;
2145
+ }
2146
+ if (runsOnlyOpenRigRelay(group, current))
2147
+ for (let at = first; at <= last; at++)
2148
+ sections[at].openRig = true;
2149
+ first = last;
2150
+ }
2151
+ return sections;
2152
+ }
2153
+ function canonicalCodexHookSource(path) {
2154
+ // Codex keys hook trust by the canonical source path; a file not on the real filesystem keeps its plain path.
2155
+ try {
2156
+ return fs.realpathSync.native(path);
2157
+ }
2158
+ catch {
2159
+ return path;
2160
+ }
2161
+ }
2162
+ /** A hooks.json document as Codex reads it: `hooks` maps each event to matcher groups, each with a `hooks` list. */
2163
+ function parseCodexHooksJson(content) {
2164
+ const value = JSON.parse(content);
2165
+ if (value === null || typeof value !== "object" || Array.isArray(value))
2166
+ throw new Error("not a JSON object");
2167
+ const record = value;
2168
+ if (record.hooks === undefined)
2169
+ record.hooks = {};
2170
+ const hooks = record.hooks;
2171
+ if (hooks === null || typeof hooks !== "object" || Array.isArray(hooks)
2172
+ || Object.values(hooks).some((groups) => !Array.isArray(groups)
2173
+ || groups.some((group) => group === null || typeof group !== "object" || !Array.isArray(group.hooks)))) {
2174
+ throw new Error("expected hooks to map each event to matcher groups with a hooks list");
2175
+ }
2176
+ return record;
2177
+ }
2178
+ function openRigActivityGroup(command) {
2179
+ return { hooks: [{ type: "command", command, timeout: 5, statusMessage: OPENRIG_ACTIVITY_STATUS }] };
2180
+ }
2181
+ /** Where OpenRig's activity relay ships, in this install or an earlier one (the absolute path moves on upgrade). */
2182
+ const OPENRIG_ACTIVITY_RELAY_SUFFIX = "/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs";
2183
+ /** A hook command that runs OpenRig's own shipped activity relay, not a person's script that shares its name. */
2184
+ function isOpenRigRelayCommand(command) {
2185
+ const relay = typeof command === "string" ? /^node "(.*)"$/.exec(command)?.[1] : undefined;
2186
+ return relay !== undefined && relay.replaceAll("\\", "/").endsWith(OPENRIG_ACTIVITY_RELAY_SUFFIX);
2187
+ }
2188
+ /** OpenRig's own group, exactly as it authors it: no matcher, and one handler with only our fields, our status and
2189
+ * timeout, running OpenRig's shipped relay. Anything else is a person's group and is left alone. */
2190
+ function isOpenRigActivityGroup(group) {
2191
+ if (group === null || typeof group !== "object")
2192
+ return false;
2193
+ const { hooks, ...rest } = group;
2194
+ if (Object.keys(rest).length > 0 || !Array.isArray(hooks) || hooks.length !== 1)
2195
+ return false;
2196
+ const handler = hooks[0];
2197
+ if (handler === null || typeof handler !== "object")
2198
+ return false;
2199
+ const { type, command, timeout, statusMessage, ...extra } = handler;
2200
+ return Object.keys(extra).length === 0 && type === "command" && timeout === 5 && statusMessage === OPENRIG_ACTIVITY_STATUS
2201
+ && isOpenRigRelayCommand(command);
2202
+ }
2203
+ function codexHookStateOf(document) {
2204
+ return document?.hooks?.state ?? {};
2205
+ }
2206
+ /** A parsed config without an empty `hooks.state`, or then an empty `hooks`: the text drops a table with its last
2207
+ * entry, and an empty table means the same as none. */
2208
+ function withoutEmptyHookTables(document) {
2209
+ const { hooks, ...rest } = document;
2210
+ if (hooks === undefined)
2211
+ return document;
2212
+ const { state, ...otherHooks } = hooks;
2213
+ const kept = state !== undefined && Object.keys(state).length > 0 ? hooks : otherHooks;
2214
+ return Object.keys(kept).length > 0 ? { ...rest, hooks: kept } : rest;
2215
+ }
2216
+ /** The index of OpenRig's inline group for `event` among a parsed config.toml's inline groups, or -1. */
2217
+ function openRigInlineGroupIndex(document, event) {
2218
+ const groups = document?.hooks?.[event];
2219
+ if (!Array.isArray(groups))
2220
+ return -1;
2221
+ return groups.findIndex((group) => {
2222
+ const handlers = group?.hooks;
2223
+ const handler = Array.isArray(handlers) && handlers.length === 1 ? handlers[0] : null;
2224
+ return !!handler && handler.type === "command" && Number(handler.timeout) === 5 && isOpenRigRelayCommand(handler.command);
2225
+ });
2226
+ }
2227
+ /** An inline group that runs nothing but OpenRig's relay: every command on it or its handlers is OpenRig's shipped relay,
2228
+ * from any install, or `current`. A person's group with a command of their own is theirs. */
2229
+ function runsOnlyOpenRigRelay(group, current) {
2230
+ if (group === null || typeof group !== "object")
2231
+ return false;
2232
+ const { command, hooks } = group;
2233
+ const commands = [...(command === undefined ? [] : [command]),
2234
+ ...(Array.isArray(hooks) ? hooks.map((handler) => handler?.command) : [])];
2235
+ return commands.length > 0 && commands.every((value) => isOpenRigRelayCommand(value) || (current !== undefined && value === current));
2236
+ }
2237
+ /** Whether `next` changes nothing in `content` but OpenRig's inline activity groups and the `[features].hooks` flag
2238
+ * OpenRig sets, and still parses. A config that doesn't parse is left as it is. */
2239
+ function changesOnlyOpenRigActivityHooks(content, next, current) {
2240
+ const rest = (text) => {
2241
+ const { hooks, features, ...other } = parseToml(text);
2242
+ const { hooks: _flag, ...otherFeatures } = features ?? {};
2243
+ const otherHooks = Object.fromEntries(Object.entries(hooks ?? {}).flatMap(([event, value]) => {
2244
+ const groups = OPENRIG_ACTIVITY_HOOK_EVENTS.includes(event) && Array.isArray(value)
2245
+ ? value.filter((group) => !runsOnlyOpenRigRelay(group, current)) : value;
2246
+ return Array.isArray(groups) && groups.length === 0 ? [] : [[event, groups]];
2247
+ }));
2248
+ return { ...other, ...(Object.keys(otherFeatures).length > 0 ? { features: otherFeatures } : {}),
2249
+ ...(Object.keys(otherHooks).length > 0 ? { hooks: otherHooks } : {}) };
2250
+ };
2251
+ try {
2252
+ return isDeepStrictEqual(rest(content), rest(next));
2253
+ }
2254
+ catch {
2255
+ return false;
2256
+ }
2257
+ }
2258
+ /** Write `enabled = false` into one `[hooks.state."<key>"]` table (the trust write creates it first). */
2259
+ function upsertCodexHookDisabled(content, key) {
2260
+ const path = ["hooks", "state", key];
2261
+ const header = `[hooks.state.${JSON.stringify(key)}]`;
2262
+ const lines = content.split("\n");
2263
+ const at = findTomlTable(lines, path);
2264
+ if (at < 0)
2265
+ return tomlDefines(content, path) ? content : `${content.replace(/\n*$/, "")}\n\n${header}\nenabled = false\n`;
2266
+ let end = lines.length;
2267
+ for (let i = at + 1; i < lines.length; i++)
2268
+ if (lines[i].trim().startsWith("[")) {
2269
+ end = i;
2270
+ break;
2271
+ }
2272
+ const enabledAt = lines.findIndex((line, i) => i > at && i < end && /^\s*enabled\s*=/.test(line));
2273
+ if (enabledAt >= 0)
2274
+ lines[enabledAt] = "enabled = false";
2275
+ else
2276
+ lines.splice(at + 1, 0, "enabled = false");
2277
+ return lines.join("\n");
2278
+ }
2279
+ /** The parsed `hooks.state` after an event's groups move (`newIndexOf`; null = the group left): a group's tables move with it. */
2280
+ function rekeyCodexHookState(state, prefix, newIndexOf) {
2281
+ const next = {};
2282
+ for (const [key, value] of Object.entries(state)) {
2283
+ const tail = key.startsWith(prefix) ? /^(\d+):(\d+)$/.exec(key.slice(prefix.length)) : null;
2284
+ if (!tail) {
2285
+ next[key] = value;
2286
+ continue;
2287
+ }
2288
+ const index = newIndexOf(Number(tail[1]));
2289
+ if (index !== null)
2290
+ next[`${prefix}${index}:${tail[2]}`] = value;
2291
+ }
2292
+ return next;
2293
+ }
2294
+ /** The same move on config.toml's text: rename each moved group's `[hooks.state.<key>]` header (any key spelling), and
2295
+ * drop a removed group's table. An inline or dotted entry isn't touched; the caller compares the parsed result before writing. */
2296
+ function rekeyCodexHookStateText(content, prefix, newIndexOf) {
2297
+ const out = [];
2298
+ let dropping = false;
2299
+ const lines = content.split("\n");
2300
+ const root = parseTomlRoot(lines);
2301
+ for (const [at, line] of lines.entries()) {
2302
+ const trimmed = line.trim();
2303
+ if (trimmed.startsWith("[")) {
2304
+ dropping = false;
2305
+ const path = tomlTableHeaderPath(trimmed);
2306
+ const key = path?.length === 3 && path[0] === "hooks" && path[1] === "state" && opensTomlTable(lines, at, root) ? path[2] : undefined;
2307
+ const tail = key?.startsWith(prefix) ? /^(\d+):(\d+)$/.exec(key.slice(prefix.length)) : null;
2308
+ if (tail) {
2309
+ const index = newIndexOf(Number(tail[1]));
2310
+ if (index === null) {
2311
+ dropping = true;
2312
+ continue;
2313
+ }
2314
+ out.push(`[hooks.state.${JSON.stringify(`${prefix}${index}:${tail[2]}`)}]`);
2315
+ continue;
2316
+ }
2317
+ }
2318
+ if (!dropping)
2319
+ out.push(line);
2320
+ }
2321
+ return out.join("\n");
2322
+ }
1791
2323
  /**
1792
2324
  * OPR.0.4.1.10 B3 — remove the OpenRig-managed activity-hooks sentinel block (durable disable).
1793
2325
  * Strips ONLY the BEGIN..END block (plus the leading blank-line separator it was appended with);
1794
2326
  * leaves all other content — user-owned hooks, [features], project trust — untouched. Returns the
1795
2327
  * input unchanged when the block is absent.
1796
2328
  */
1797
- function stripCodexActivityHooks(content) {
1798
- const pattern = new RegExp(`\\n*${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_BEGIN)}[\\s\\S]*?${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_END)}[ \\t]*\\n?`, "m");
2329
+ function stripCodexActivityHooks(content, current) {
2330
+ const pattern = new RegExp(`\\n*${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_BEGIN)}([\\s\\S]*?)${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_END)}[ \\t]*\\n?`, "m");
1799
2331
  if (!pattern.test(content))
1800
2332
  return content;
1801
- return content.replace(pattern, "\n");
2333
+ // Tables Codex printed inside the block (its rewritten `[hooks.state]`) aren't ours to remove.
2334
+ return content.replace(pattern, (_span, inner) => {
2335
+ const kept = keptInActivityBlock(inner, current);
2336
+ return kept ? `\n\n${kept}\n` : "\n";
2337
+ });
1802
2338
  }
1803
2339
  /** Ensure `[features].hooks = true` (canonical key; not the deprecated codex_hooks alias). */
1804
2340
  function upsertCodexFeaturesHooksEnabled(content) {
@@ -2042,23 +2578,169 @@ function dropCollidingFragmentTables(fragment, userOwned) {
2042
2578
  dropped,
2043
2579
  };
2044
2580
  }
2045
- function upsertManagedCodexConfigFragment(content, id, fragment) {
2581
+ /** `content`'s lines and this fragment's marker pair: the first document-level BEGIN and the first END after it. */
2582
+ function fragmentMarkerPair(content, id) {
2046
2583
  const start = `# BEGIN OPENRIG MANAGED CODEX CONFIG FRAGMENT: ${id}`;
2047
2584
  const end = `# END OPENRIG MANAGED CODEX CONFIG FRAGMENT: ${id}`;
2048
- const pattern = new RegExp(`${escapeRegExp(start)}[\\s\\S]*?${escapeRegExp(end)}\\n?`, "m");
2049
- // Everything outside THIS block is what the fragment must not collide with.
2050
- // Our own previous block is excluded because re-projection replaces it
2051
- // wholesale — counting it would make the second projection drop everything
2052
- // the first one legitimately landed.
2053
- const userOwned = content.replace(pattern, "");
2054
- const { kept } = dropCollidingFragmentTables(fragment, userOwned);
2585
+ const lines = content.split("\n");
2586
+ const topLevel = lineStartsAtDocumentLevel(content);
2587
+ const isMarker = (at) => topLevel[at] === true && (lines[at].trim() === start || lines[at].trim() === end);
2588
+ const begin = lines.findIndex((line, at) => isMarker(at) && line.trim() === start);
2589
+ const close = begin < 0 ? -1 : lines.findIndex((line, at) => at > begin && isMarker(at) && line.trim() === end);
2590
+ return { start, end, lines, isMarker, begin, close };
2591
+ }
2592
+ function upsertManagedCodexConfigFragment(content, id, fragment) {
2593
+ const { start, end, lines, isMarker, begin, close } = fragmentMarkerPair(content, id);
2594
+ const inBlock = (at) => close >= 0 && at > begin && at < close;
2595
+ // Codex 0.164.0 prints every table it rewrites (all of `[mcp_servers]` on `codex mcp add`) after the others, and the
2596
+ // comment above the first goes with it, so a save can leave our markers apart from our tables. Outside the block, a
2597
+ // fragment table still holding exactly the fragment's values is ours where Codex left it, and our stray markers go.
2598
+ const ours = fragmentTableValues(fragment);
2599
+ const drop = new Set();
2600
+ for (const section of tomlSections(content)) {
2601
+ const value = ours.get(JSON.stringify(section.path));
2602
+ if (inBlock(section.header) || value === undefined)
2603
+ continue;
2604
+ let stop = section.end;
2605
+ while (stop - 1 > section.header && /^\s*(?:#.*)?$/.test(lines[stop - 1]))
2606
+ stop--;
2607
+ if (!isDeepStrictEqual(tomlTableValue(lines.slice(section.header, stop).join("\n"), section.path), value))
2608
+ continue;
2609
+ for (let at = section.start; at < stop; at++)
2610
+ if (at >= section.header || !/\S/.test(lines[at]))
2611
+ drop.add(at);
2612
+ }
2613
+ lines.forEach((_, at) => { if (isMarker(at) && !(close >= 0 && (at === begin || at === close)))
2614
+ drop.add(at); });
2615
+ const outside = (from, to) => lines.slice(from, to).filter((_, offset) => !drop.has(from + offset));
2616
+ if (close >= 0) {
2617
+ // Codex can print a table of its own between our markers (a new `[features]`, say): that's the person's, and it's
2618
+ // kept after the block. Our tables and array-of-tables entries inside are replaced whole.
2619
+ const inner = lines.slice(begin + 1, close);
2620
+ const roots = fragmentArrayRoots(fragment);
2621
+ const theirs = tomlSections(inner.join("\n"))
2622
+ .filter((section) => !ours.has(JSON.stringify(section.path)) && !underTomlRoot(section.path, roots))
2623
+ .map(({ start: from, end: to }) => inner.slice(from, to).join("\n")).join("\n").trim();
2624
+ const before = outside(0, begin);
2625
+ const after = outside(close + 1, lines.length);
2626
+ const { kept } = dropCollidingFragmentTables(fragment, [...before, theirs, ...after].join("\n"));
2627
+ const block = `${start}\n${kept}\n${end}${theirs ? `\n\n${theirs}` : ""}`;
2628
+ return [...before, block, ...(after.length > 0 ? after : [""])].join("\n");
2629
+ }
2630
+ const rest = outside(0, lines.length).join("\n");
2631
+ const { kept } = dropCollidingFragmentTables(fragment, rest);
2055
2632
  const block = `${start}\n${kept}\n${end}\n`;
2056
- if (pattern.test(content)) {
2057
- return content.replace(pattern, () => block); // literal: a string would expand `$` patterns in the fragment
2058
- }
2059
- const prefix = content.replace(/\n*$/, "");
2633
+ const prefix = rest.replace(/\n*$/, "");
2060
2634
  return prefix.length > 0 ? `${prefix}\n\n${block}` : block;
2061
2635
  }
2636
+ /** The fragment's tables by key path (JSON), each with the values it sets. A table under one of its array-of-tables
2637
+ * roots is part of that entry, not a table of its own. */
2638
+ function fragmentTableValues(fragment) {
2639
+ const roots = fragmentArrayRoots(fragment);
2640
+ const values = new Map();
2641
+ for (const block of splitAtTableHeaders(fragment)) {
2642
+ const path = block.header === null ? null : tomlTableHeaderPath(block.header);
2643
+ if (path && !underTomlRoot(path, roots))
2644
+ values.set(JSON.stringify(path), tomlTableValue(block.text, path));
2645
+ }
2646
+ return values;
2647
+ }
2648
+ /** The fragment's array-of-tables roots: each `[[path]]` that isn't under another (`[[hooks.Stop]]`, whose
2649
+ * `[[hooks.Stop.hooks]]` belong to its entry). An entry has no single path, so it's only ever recognized between our
2650
+ * markers. */
2651
+ function fragmentArrayRoots(fragment) {
2652
+ const roots = [];
2653
+ for (const { header } of splitAtTableHeaders(fragment)) {
2654
+ const path = header === null ? null : tomlArrayTableHeaderPath(header);
2655
+ if (path && !underTomlRoot(path, roots))
2656
+ roots.push(path);
2657
+ }
2658
+ return roots;
2659
+ }
2660
+ function underTomlRoot(path, roots) {
2661
+ return roots.some((root) => root.length <= path.length && root.every((key, at) => path[at] === key));
2662
+ }
2663
+ /** The array-of-tables entries between this fragment's markers in `content`, by root (JSON): OpenRig's, whatever they
2664
+ * now hold. */
2665
+ function blockArrayEntries(content, id, roots) {
2666
+ const entries = new Map();
2667
+ const { lines, begin, close } = fragmentMarkerPair(content, id);
2668
+ if (close < 0 || roots.length === 0)
2669
+ return entries;
2670
+ const inner = lines.slice(begin + 1, close);
2671
+ const text = tomlSections(inner.join("\n")).filter((section) => underTomlRoot(section.path, roots))
2672
+ .map(({ start: from, end: to }) => inner.slice(from, to).join("\n")).join("\n");
2673
+ for (const root of roots) {
2674
+ const value = tomlTableValue(text, root);
2675
+ if (Array.isArray(value))
2676
+ entries.set(JSON.stringify(root), value);
2677
+ }
2678
+ return entries;
2679
+ }
2680
+ /** The value one table's text sets at `path`, or undefined when it doesn't parse. */
2681
+ function tomlTableValue(text, path) {
2682
+ let node;
2683
+ try {
2684
+ node = parseToml(text);
2685
+ }
2686
+ catch {
2687
+ return undefined;
2688
+ }
2689
+ for (const key of path)
2690
+ node = node !== null && typeof node === "object" ? node[key] : undefined;
2691
+ return node;
2692
+ }
2693
+ /** Whether `next` changes nothing in `content` but the fragment's own tables and the array-of-tables entries between
2694
+ * its markers: the person's settings, and every table and entry Codex wrote, read the same. Both must parse. */
2695
+ function changesOnlyFragmentTables(content, next, id, fragment) {
2696
+ const paths = [...fragmentTableValues(fragment).keys()].map((key) => JSON.parse(key));
2697
+ const roots = fragmentArrayRoots(fragment);
2698
+ const rest = (text) => {
2699
+ const root = parseToml(text);
2700
+ for (const path of paths)
2701
+ withoutTomlPath(root, path);
2702
+ for (const [key, entries] of blockArrayEntries(text, id, roots))
2703
+ withoutTomlPath(root, JSON.parse(key), entries);
2704
+ return root;
2705
+ };
2706
+ try {
2707
+ return isDeepStrictEqual(rest(content), rest(next));
2708
+ }
2709
+ catch {
2710
+ return false;
2711
+ }
2712
+ }
2713
+ /** Delete `path` from a parsed document in place, or with `entries`, one equal entry for each from the array there; and
2714
+ * any table that leaves empty. */
2715
+ function withoutTomlPath(node, path, entries) {
2716
+ const [key, ...more] = path;
2717
+ if (key === undefined || !Object.hasOwn(node, key))
2718
+ return;
2719
+ const child = node[key];
2720
+ if (more.length === 0) {
2721
+ if (entries === undefined) {
2722
+ delete node[key];
2723
+ return;
2724
+ }
2725
+ if (!Array.isArray(child))
2726
+ return;
2727
+ for (const entry of entries) {
2728
+ for (let at = child.length - 1; at >= 0; at--)
2729
+ if (isDeepStrictEqual(child[at], entry)) {
2730
+ child.splice(at, 1);
2731
+ break;
2732
+ }
2733
+ }
2734
+ if (child.length === 0)
2735
+ delete node[key];
2736
+ return;
2737
+ }
2738
+ if (child === null || typeof child !== "object" || Array.isArray(child))
2739
+ return;
2740
+ withoutTomlPath(child, more, entries);
2741
+ if (Object.keys(child).length === 0)
2742
+ delete node[key];
2743
+ }
2062
2744
  /**
2063
2745
  * Refuse to hand Codex a config it cannot load. Throwing here (rather than
2064
2746
  * writing and hoping) is what keeps a malformed render off disk entirely: