@openrig/cli 0.7.2 → 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 (553) 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/messaging-the-human/SKILL.md +37 -3
  6. package/daemon/context-packs/help/manifest.yaml +1 -1
  7. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  8. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +64 -11
  9. package/daemon/context-packs/reference/getting-started.md +7 -5
  10. package/daemon/context-packs/reference/manifest.yaml +1 -1
  11. package/daemon/context-packs/reference/rig-spec.md +86 -3
  12. package/daemon/context-packs/reference/whats-new.md +147 -281
  13. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  14. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  15. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  16. package/daemon/context-packs/skills/claude-compaction-restore/SKILL.md +2 -2
  17. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  18. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  19. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  20. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  21. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  22. package/daemon/context-packs/skills/core/messaging-the-human/SKILL.md +37 -3
  23. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  24. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  25. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  26. package/daemon/context-packs/skills/core/openrig-herdr/SKILL.md +5 -2
  27. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  28. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  30. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  31. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  32. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/process/agent-browser/SKILL.md +1 -1
  56. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/process/systematic-debugging/root-cause-tracing.md +1 -1
  62. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  70. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  71. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  72. package/daemon/dist/adapters/codex-resume.d.ts +2 -1
  73. package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
  74. package/daemon/dist/adapters/codex-resume.js +12 -6
  75. package/daemon/dist/adapters/codex-resume.js.map +1 -1
  76. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +9 -1
  77. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  78. package/daemon/dist/adapters/codex-runtime-adapter.js +374 -49
  79. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  80. package/daemon/dist/adapters/pi-resume.js +1 -1
  81. package/daemon/dist/adapters/pi-resume.js.map +1 -1
  82. package/daemon/dist/adapters/pi-runner-protocol.d.ts +3 -3
  83. package/daemon/dist/adapters/pi-runner-protocol.js +2 -2
  84. package/daemon/dist/adapters/pi-runner.d.ts +1 -1
  85. package/daemon/dist/adapters/pi-runner.js +2 -2
  86. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  87. package/daemon/dist/adapters/tmux-server.d.ts +0 -3
  88. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  89. package/daemon/dist/adapters/tmux-server.js +0 -5
  90. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  91. package/daemon/dist/adapters/tmux.d.ts +13 -0
  92. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  93. package/daemon/dist/adapters/tmux.js +53 -3
  94. package/daemon/dist/adapters/tmux.js.map +1 -1
  95. package/daemon/dist/attention-surface.d.ts +16 -1
  96. package/daemon/dist/attention-surface.d.ts.map +1 -1
  97. package/daemon/dist/attention-surface.js.map +1 -1
  98. package/daemon/dist/build-info.js +3 -3
  99. package/daemon/dist/context-pack-taxonomy-surface.js +1 -1
  100. package/daemon/dist/context-pack-taxonomy-surface.js.map +1 -1
  101. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  102. package/daemon/dist/db/all-migrations.js +2 -0
  103. package/daemon/dist/db/all-migrations.js.map +1 -1
  104. package/daemon/dist/db/migrations/137_node_codex_permissions.d.ts +3 -0
  105. package/daemon/dist/db/migrations/137_node_codex_permissions.d.ts.map +1 -0
  106. package/daemon/dist/db/migrations/137_node_codex_permissions.js +7 -0
  107. package/daemon/dist/db/migrations/137_node_codex_permissions.js.map +1 -0
  108. package/daemon/dist/domain/active-occupant.js +1 -1
  109. package/daemon/dist/domain/active-occupant.js.map +1 -1
  110. package/daemon/dist/domain/agent-activity-store.d.ts +1 -1
  111. package/daemon/dist/domain/agent-activity-store.js +2 -2
  112. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  113. package/daemon/dist/domain/agent-resolver.js +1 -1
  114. package/daemon/dist/domain/agent-resolver.js.map +1 -1
  115. package/daemon/dist/domain/bind-plan.js +1 -1
  116. package/daemon/dist/domain/bind-plan.js.map +1 -1
  117. package/daemon/dist/domain/bootstrap-orchestrator.js +1 -1
  118. package/daemon/dist/domain/bootstrap-orchestrator.js.map +1 -1
  119. package/daemon/dist/domain/bundle-skills-router.js +2 -2
  120. package/daemon/dist/domain/bundle-skills-router.js.map +1 -1
  121. package/daemon/dist/domain/codex-member-permissions.d.ts +56 -0
  122. package/daemon/dist/domain/codex-member-permissions.d.ts.map +1 -0
  123. package/daemon/dist/domain/codex-member-permissions.js +140 -0
  124. package/daemon/dist/domain/codex-member-permissions.js.map +1 -0
  125. package/daemon/dist/domain/codex-owned-plugin-trust.d.ts.map +1 -1
  126. package/daemon/dist/domain/codex-owned-plugin-trust.js +2 -1
  127. package/daemon/dist/domain/codex-owned-plugin-trust.js.map +1 -1
  128. package/daemon/dist/domain/context-packs/context-pack-library-service.js +2 -2
  129. package/daemon/dist/domain/context-packs/context-pack-library-service.js.map +1 -1
  130. package/daemon/dist/domain/execution-candidate-reader.d.ts +16 -0
  131. package/daemon/dist/domain/execution-candidate-reader.d.ts.map +1 -0
  132. package/daemon/dist/domain/execution-candidate-reader.js +77 -0
  133. package/daemon/dist/domain/execution-candidate-reader.js.map +1 -0
  134. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  135. package/daemon/dist/domain/execution-view.js +16 -6
  136. package/daemon/dist/domain/execution-view.js.map +1 -1
  137. package/daemon/dist/domain/feed-perspective.d.ts +14 -0
  138. package/daemon/dist/domain/feed-perspective.d.ts.map +1 -0
  139. package/daemon/dist/domain/feed-perspective.js +36 -0
  140. package/daemon/dist/domain/feed-perspective.js.map +1 -0
  141. package/daemon/dist/domain/gateway/channel-operations.d.ts +1 -1
  142. package/daemon/dist/domain/gateway/channel-operations.d.ts.map +1 -1
  143. package/daemon/dist/domain/gateway/human-registry.d.ts +11 -4
  144. package/daemon/dist/domain/gateway/human-registry.d.ts.map +1 -1
  145. package/daemon/dist/domain/gateway/human-registry.js +36 -5
  146. package/daemon/dist/domain/gateway/human-registry.js.map +1 -1
  147. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
  148. package/daemon/dist/domain/gateway/operator-delivery-engine.js +5 -2
  149. package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
  150. package/daemon/dist/domain/gateway/participants.d.ts +180 -0
  151. package/daemon/dist/domain/gateway/participants.d.ts.map +1 -0
  152. package/daemon/dist/domain/gateway/participants.js +434 -0
  153. package/daemon/dist/domain/gateway/participants.js.map +1 -0
  154. package/daemon/dist/domain/gateway/slack/inbound-admission.d.ts +2 -2
  155. package/daemon/dist/domain/gateway/slack/inbound-admission.d.ts.map +1 -1
  156. package/daemon/dist/domain/gateway/slack/inbound-admission.js +73 -6
  157. package/daemon/dist/domain/gateway/slack/inbound-admission.js.map +1 -1
  158. package/daemon/dist/domain/gateway/slack/inbound.d.ts +18 -1
  159. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  160. package/daemon/dist/domain/gateway/slack/inbound.js +27 -11
  161. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  162. package/daemon/dist/domain/gateway/slack/message.d.ts +2 -0
  163. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  164. package/daemon/dist/domain/gateway/slack/message.js +14 -6
  165. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  166. package/daemon/dist/domain/gateway/slack/open-asks.d.ts +50 -0
  167. package/daemon/dist/domain/gateway/slack/open-asks.d.ts.map +1 -0
  168. package/daemon/dist/domain/gateway/slack/open-asks.js +215 -0
  169. package/daemon/dist/domain/gateway/slack/open-asks.js.map +1 -0
  170. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts +2 -0
  171. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts.map +1 -1
  172. package/daemon/dist/domain/gateway/slack/outbound-driver.js +1 -0
  173. package/daemon/dist/domain/gateway/slack/outbound-driver.js.map +1 -1
  174. package/daemon/dist/domain/gateway/slack/queue-access.d.ts +15 -1
  175. package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
  176. package/daemon/dist/domain/gateway/slack/queue-access.js +98 -29
  177. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  178. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
  179. package/daemon/dist/domain/gateway/slack/slack-delivery.js +1 -0
  180. package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
  181. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
  182. package/daemon/dist/domain/gateway/slack/slack-subsystem.js +56 -2
  183. package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
  184. package/daemon/dist/domain/gateway/slack/state-store.d.ts +3 -0
  185. package/daemon/dist/domain/gateway/slack/state-store.d.ts.map +1 -1
  186. package/daemon/dist/domain/gateway/slack/state-store.js +18 -0
  187. package/daemon/dist/domain/gateway/slack/state-store.js.map +1 -1
  188. package/daemon/dist/domain/hot-potato-enforcer.d.ts +1 -1
  189. package/daemon/dist/domain/mission-control/mission-control-read-layer.d.ts.map +1 -1
  190. package/daemon/dist/domain/mission-control/mission-control-read-layer.js +3 -1
  191. package/daemon/dist/domain/mission-control/mission-control-read-layer.js.map +1 -1
  192. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +16 -0
  193. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  194. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +64 -16
  195. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  196. package/daemon/dist/domain/native-permission-store.d.ts +3 -2
  197. package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
  198. package/daemon/dist/domain/native-permission-store.js +14 -1
  199. package/daemon/dist/domain/native-permission-store.js.map +1 -1
  200. package/daemon/dist/domain/native-resume-probe.d.ts +9 -0
  201. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  202. package/daemon/dist/domain/native-resume-probe.js +37 -2
  203. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  204. package/daemon/dist/domain/node-inventory.d.ts +1 -1
  205. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  206. package/daemon/dist/domain/permission-account.js +44 -9
  207. package/daemon/dist/domain/permission-account.js.map +1 -1
  208. package/daemon/dist/domain/permission-drift-observer.js +1 -1
  209. package/daemon/dist/domain/permission-drift-observer.js.map +1 -1
  210. package/daemon/dist/domain/policies/delivery-digest-flush.d.ts +6 -2
  211. package/daemon/dist/domain/policies/delivery-digest-flush.d.ts.map +1 -1
  212. package/daemon/dist/domain/policies/delivery-digest-flush.js +34 -9
  213. package/daemon/dist/domain/policies/delivery-digest-flush.js.map +1 -1
  214. package/daemon/dist/domain/policies/quiet-release.d.ts +14 -0
  215. package/daemon/dist/domain/policies/quiet-release.d.ts.map +1 -1
  216. package/daemon/dist/domain/policies/quiet-release.js +13 -2
  217. package/daemon/dist/domain/policies/quiet-release.js.map +1 -1
  218. package/daemon/dist/domain/profile-resolution-worker.d.ts +1 -1
  219. package/daemon/dist/domain/profile-resolution-worker.d.ts.map +1 -1
  220. package/daemon/dist/domain/profile-resolution-worker.js +5 -5
  221. package/daemon/dist/domain/profile-resolution-worker.js.map +1 -1
  222. package/daemon/dist/domain/queue-destination-check.d.ts +5 -0
  223. package/daemon/dist/domain/queue-destination-check.d.ts.map +1 -1
  224. package/daemon/dist/domain/queue-destination-check.js +5 -1
  225. package/daemon/dist/domain/queue-destination-check.js.map +1 -1
  226. package/daemon/dist/domain/queue-repository.d.ts +23 -5
  227. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  228. package/daemon/dist/domain/queue-repository.js +49 -23
  229. package/daemon/dist/domain/queue-repository.js.map +1 -1
  230. package/daemon/dist/domain/restore-orchestrator.d.ts +4 -0
  231. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  232. package/daemon/dist/domain/restore-orchestrator.js +17 -5
  233. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  234. package/daemon/dist/domain/review/compose.js +1 -1
  235. package/daemon/dist/domain/review/compose.js.map +1 -1
  236. package/daemon/dist/domain/review/gather.js +1 -1
  237. package/daemon/dist/domain/review/gather.js.map +1 -1
  238. package/daemon/dist/domain/rig-expansion-service.d.ts.map +1 -1
  239. package/daemon/dist/domain/rig-expansion-service.js +1 -0
  240. package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
  241. package/daemon/dist/domain/rig-repository.d.ts +1 -0
  242. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  243. package/daemon/dist/domain/rig-repository.js +15 -0
  244. package/daemon/dist/domain/rig-repository.js.map +1 -1
  245. package/daemon/dist/domain/rig-teardown.d.ts +3 -0
  246. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  247. package/daemon/dist/domain/rig-teardown.js +3 -0
  248. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  249. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  250. package/daemon/dist/domain/rigspec-codec.js +4 -0
  251. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  252. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  253. package/daemon/dist/domain/rigspec-exporter.js +12 -1
  254. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  255. package/daemon/dist/domain/rigspec-instantiator.d.ts +2 -0
  256. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  257. package/daemon/dist/domain/rigspec-instantiator.js +150 -128
  258. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  259. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  260. package/daemon/dist/domain/rigspec-schema.js +24 -1
  261. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  262. package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
  263. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  264. package/daemon/dist/domain/runtime-adapter.js +2 -0
  265. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  266. package/daemon/dist/domain/scope/dot-id.js +2 -2
  267. package/daemon/dist/domain/scope/dot-id.js.map +1 -1
  268. package/daemon/dist/domain/scope/scaffold-placeholder.d.ts +1 -1
  269. package/daemon/dist/domain/scope/scaffold-placeholder.js +1 -1
  270. package/daemon/dist/domain/scope/scope-audit.js +1 -1
  271. package/daemon/dist/domain/scope/scope-audit.js.map +1 -1
  272. package/daemon/dist/domain/scope/types.d.ts.map +1 -1
  273. package/daemon/dist/domain/scope/types.js +2 -3
  274. package/daemon/dist/domain/scope/types.js.map +1 -1
  275. package/daemon/dist/domain/seat-handover-service.d.ts +1 -1
  276. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  277. package/daemon/dist/domain/seat-handover-service.js +6 -2
  278. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  279. package/daemon/dist/domain/seat-lifecycle-service.d.ts +23 -8
  280. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  281. package/daemon/dist/domain/seat-lifecycle-service.js +153 -12
  282. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  283. package/daemon/dist/domain/seat-restart-in-place.d.ts +2 -2
  284. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  285. package/daemon/dist/domain/seat-restart-in-place.js +2 -2
  286. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  287. package/daemon/dist/domain/seat-runtime-switch-service.d.ts +9 -2
  288. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  289. package/daemon/dist/domain/seat-runtime-switch-service.js +53 -5
  290. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  291. package/daemon/dist/domain/seat-status-service.d.ts +1 -0
  292. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  293. package/daemon/dist/domain/seat-status-service.js +11 -0
  294. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  295. package/daemon/dist/domain/seat-structural-activity-service.js +1 -1
  296. package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
  297. package/daemon/dist/domain/session-registry.d.ts +2 -0
  298. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  299. package/daemon/dist/domain/session-registry.js +3 -1
  300. package/daemon/dist/domain/session-registry.js.map +1 -1
  301. package/daemon/dist/domain/session-transport.d.ts +43 -1
  302. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  303. package/daemon/dist/domain/session-transport.js +195 -25
  304. package/daemon/dist/domain/session-transport.js.map +1 -1
  305. package/daemon/dist/domain/skill-library-discovery.js +2 -2
  306. package/daemon/dist/domain/skill-library-discovery.js.map +1 -1
  307. package/daemon/dist/domain/slices/slice-indexer.d.ts +4 -4
  308. package/daemon/dist/domain/slices/slice-indexer.js +17 -17
  309. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  310. package/daemon/dist/domain/startup-orchestrator.d.ts +0 -16
  311. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  312. package/daemon/dist/domain/startup-orchestrator.js +7 -60
  313. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  314. package/daemon/dist/domain/startup-submission-evidence.d.ts +26 -0
  315. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  316. package/daemon/dist/domain/startup-submission-evidence.js +54 -0
  317. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  318. package/daemon/dist/domain/successor-session-launcher.d.ts +1 -0
  319. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  320. package/daemon/dist/domain/successor-session-launcher.js +1 -0
  321. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  322. package/daemon/dist/domain/toml-tables.d.ts +20 -0
  323. package/daemon/dist/domain/toml-tables.d.ts.map +1 -0
  324. package/daemon/dist/domain/toml-tables.js +101 -0
  325. package/daemon/dist/domain/toml-tables.js.map +1 -0
  326. package/daemon/dist/domain/types.d.ts +25 -0
  327. package/daemon/dist/domain/types.d.ts.map +1 -1
  328. package/daemon/dist/domain/types.js.map +1 -1
  329. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  330. package/daemon/dist/domain/user-settings/settings-store.js +5 -6
  331. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  332. package/daemon/dist/domain/view-projector.d.ts +1 -0
  333. package/daemon/dist/domain/view-projector.d.ts.map +1 -1
  334. package/daemon/dist/domain/view-projector.js +15 -2
  335. package/daemon/dist/domain/view-projector.js.map +1 -1
  336. package/daemon/dist/domain/workflow-human-destination.d.ts.map +1 -1
  337. package/daemon/dist/domain/workflow-human-destination.js +5 -3
  338. package/daemon/dist/domain/workflow-human-destination.js.map +1 -1
  339. package/daemon/dist/domain/workflow-projector.d.ts +1 -0
  340. package/daemon/dist/domain/workflow-projector.d.ts.map +1 -1
  341. package/daemon/dist/domain/workflow-projector.js +19 -3
  342. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  343. package/daemon/dist/domain/workflow-runtime.d.ts +2 -2
  344. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  345. package/daemon/dist/domain/workflow-runtime.js +6 -4
  346. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  347. package/daemon/dist/gateway-human-registry-surface.d.ts +1 -0
  348. package/daemon/dist/gateway-human-registry-surface.d.ts.map +1 -1
  349. package/daemon/dist/gateway-human-registry-surface.js +1 -0
  350. package/daemon/dist/gateway-human-registry-surface.js.map +1 -1
  351. package/daemon/dist/index.js +2 -2
  352. package/daemon/dist/index.js.map +1 -1
  353. package/daemon/dist/lib/pane-envelope.d.ts +4 -0
  354. package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
  355. package/daemon/dist/lib/pane-envelope.js +1 -1
  356. package/daemon/dist/lib/pane-envelope.js.map +1 -1
  357. package/daemon/dist/routes/activity.js +1 -1
  358. package/daemon/dist/routes/activity.js.map +1 -1
  359. package/daemon/dist/routes/agent-images.d.ts.map +1 -1
  360. package/daemon/dist/routes/agent-images.js +10 -0
  361. package/daemon/dist/routes/agent-images.js.map +1 -1
  362. package/daemon/dist/routes/attention.d.ts.map +1 -1
  363. package/daemon/dist/routes/attention.js +15 -3
  364. package/daemon/dist/routes/attention.js.map +1 -1
  365. package/daemon/dist/routes/bundles.js +1 -1
  366. package/daemon/dist/routes/bundles.js.map +1 -1
  367. package/daemon/dist/routes/gateway.d.ts.map +1 -1
  368. package/daemon/dist/routes/gateway.js +42 -0
  369. package/daemon/dist/routes/gateway.js.map +1 -1
  370. package/daemon/dist/routes/hosts.d.ts.map +1 -1
  371. package/daemon/dist/routes/hosts.js +5 -2
  372. package/daemon/dist/routes/hosts.js.map +1 -1
  373. package/daemon/dist/routes/mission-control.d.ts.map +1 -1
  374. package/daemon/dist/routes/mission-control.js +5 -1
  375. package/daemon/dist/routes/mission-control.js.map +1 -1
  376. package/daemon/dist/routes/plugins.js +1 -1
  377. package/daemon/dist/routes/plugins.js.map +1 -1
  378. package/daemon/dist/routes/queue.d.ts.map +1 -1
  379. package/daemon/dist/routes/queue.js +34 -8
  380. package/daemon/dist/routes/queue.js.map +1 -1
  381. package/daemon/dist/routes/rigs.js +2 -0
  382. package/daemon/dist/routes/rigs.js.map +1 -1
  383. package/daemon/dist/routes/runtime-switch-custody.js +1 -1
  384. package/daemon/dist/routes/scope-audit.js +1 -1
  385. package/daemon/dist/routes/scope-audit.js.map +1 -1
  386. package/daemon/dist/routes/seat.d.ts.map +1 -1
  387. package/daemon/dist/routes/seat.js +49 -15
  388. package/daemon/dist/routes/seat.js.map +1 -1
  389. package/daemon/dist/routes/sessions.js +15 -3
  390. package/daemon/dist/routes/sessions.js.map +1 -1
  391. package/daemon/dist/routes/skills.js +1 -1
  392. package/daemon/dist/routes/skills.js.map +1 -1
  393. package/daemon/dist/routes/slices.js +1 -1
  394. package/daemon/dist/routes/slices.js.map +1 -1
  395. package/daemon/dist/routes/transcripts.js +2 -2
  396. package/daemon/dist/routes/transcripts.js.map +1 -1
  397. package/daemon/dist/routes/transport.d.ts.map +1 -1
  398. package/daemon/dist/routes/transport.js +12 -3
  399. package/daemon/dist/routes/transport.js.map +1 -1
  400. package/daemon/dist/routes/workflow.js +1 -1
  401. package/daemon/dist/routes/workflow.js.map +1 -1
  402. package/daemon/dist/startup.js +1 -1
  403. package/daemon/dist/startup.js.map +1 -1
  404. package/daemon/dist/terminal/TerminalSessionBroker.d.ts +18 -2
  405. package/daemon/dist/terminal/TerminalSessionBroker.d.ts.map +1 -1
  406. package/daemon/dist/terminal/TerminalSessionBroker.js +55 -9
  407. package/daemon/dist/terminal/TerminalSessionBroker.js.map +1 -1
  408. package/daemon/dist/terminal/window-pin.d.ts +41 -0
  409. package/daemon/dist/terminal/window-pin.d.ts.map +1 -0
  410. package/daemon/dist/terminal/window-pin.js +103 -0
  411. package/daemon/dist/terminal/window-pin.js.map +1 -0
  412. package/daemon/docs/reference/a2a-agents.md +16 -4
  413. package/daemon/docs/reference/agent-startup-guide.md +34 -2
  414. package/daemon/docs/reference/community-harness-examples/hermes/config.yaml.example +2 -1
  415. package/daemon/docs/reference/community-harness-presets.md +72 -2
  416. package/daemon/docs/reference/gateway-participants.md +165 -0
  417. package/daemon/docs/reference/getting-started.md +7 -5
  418. package/daemon/docs/reference/quickstart.md +13 -1
  419. package/daemon/docs/reference/rig-spec.md +86 -3
  420. package/daemon/docs/reference/seat-delivery.md +10 -1
  421. package/daemon/docs/reference/seat-node-targeting.md +17 -0
  422. package/daemon/docs/reference/slack-app-setup.md +20 -2
  423. package/daemon/docs/reference/whats-new.md +147 -281
  424. package/daemon/specs/agents/shared/skills/core/messaging-the-human/SKILL.md +37 -3
  425. package/daemon/specs/agents/shared/skills/core/openrig-herdr/SKILL.md +5 -2
  426. package/daemon/specs/agents/shared/skills/process/agent-browser/SKILL.md +1 -1
  427. package/daemon/specs/agents/shared/skills/process/systematic-debugging/root-cause-tracing.md +1 -1
  428. package/dist/build-info.js +3 -3
  429. package/dist/client.d.ts +4 -0
  430. package/dist/client.d.ts.map +1 -1
  431. package/dist/client.js +4 -1
  432. package/dist/client.js.map +1 -1
  433. package/dist/commands/acp.js +1 -1
  434. package/dist/commands/capture.d.ts +27 -0
  435. package/dist/commands/capture.d.ts.map +1 -1
  436. package/dist/commands/capture.js +62 -4
  437. package/dist/commands/capture.js.map +1 -1
  438. package/dist/commands/doctor.d.ts +9 -1
  439. package/dist/commands/doctor.d.ts.map +1 -1
  440. package/dist/commands/doctor.js +18 -2
  441. package/dist/commands/doctor.js.map +1 -1
  442. package/dist/commands/down.d.ts.map +1 -1
  443. package/dist/commands/down.js +3 -0
  444. package/dist/commands/down.js.map +1 -1
  445. package/dist/commands/export.d.ts.map +1 -1
  446. package/dist/commands/export.js +10 -5
  447. package/dist/commands/export.js.map +1 -1
  448. package/dist/commands/gateway.d.ts.map +1 -1
  449. package/dist/commands/gateway.js +309 -23
  450. package/dist/commands/gateway.js.map +1 -1
  451. package/dist/commands/queue.d.ts.map +1 -1
  452. package/dist/commands/queue.js +26 -8
  453. package/dist/commands/queue.js.map +1 -1
  454. package/dist/commands/rig-mode.d.ts +1 -2
  455. package/dist/commands/rig-mode.d.ts.map +1 -1
  456. package/dist/commands/rig-mode.js +2 -2
  457. package/dist/commands/rig-mode.js.map +1 -1
  458. package/dist/commands/scope.d.ts.map +1 -1
  459. package/dist/commands/scope.js +12 -4
  460. package/dist/commands/scope.js.map +1 -1
  461. package/dist/commands/seat.d.ts.map +1 -1
  462. package/dist/commands/seat.js +35 -5
  463. package/dist/commands/seat.js.map +1 -1
  464. package/dist/commands/send.d.ts +3 -0
  465. package/dist/commands/send.d.ts.map +1 -1
  466. package/dist/commands/send.js +16 -18
  467. package/dist/commands/send.js.map +1 -1
  468. package/dist/commands/setup.d.ts.map +1 -1
  469. package/dist/commands/setup.js +10 -2
  470. package/dist/commands/setup.js.map +1 -1
  471. package/dist/commands/skill.js +1 -1
  472. package/dist/commands/skill.js.map +1 -1
  473. package/dist/commands/slack.d.ts +10 -0
  474. package/dist/commands/slack.d.ts.map +1 -1
  475. package/dist/commands/slack.js +70 -2
  476. package/dist/commands/slack.js.map +1 -1
  477. package/dist/config-store.d.ts.map +1 -1
  478. package/dist/config-store.js +3 -2
  479. package/dist/config-store.js.map +1 -1
  480. package/dist/daemon-lifecycle.d.ts +1 -1
  481. package/dist/daemon-lifecycle.js +2 -2
  482. package/dist/daemon-lifecycle.js.map +1 -1
  483. package/dist/fetch-with-timeout.d.ts.map +1 -1
  484. package/dist/fetch-with-timeout.js +3 -1
  485. package/dist/fetch-with-timeout.js.map +1 -1
  486. package/dist/lib/scope/dot-id.js +2 -2
  487. package/dist/lib/scope/dot-id.js.map +1 -1
  488. package/dist/lib/scope/scaffold-placeholder.d.ts +1 -1
  489. package/dist/lib/scope/scaffold-placeholder.js +1 -1
  490. package/dist/lib/scope/scope-audit.js +1 -1
  491. package/dist/lib/scope/scope-audit.js.map +1 -1
  492. package/dist/lib/scope/types.d.ts.map +1 -1
  493. package/dist/lib/scope/types.js +2 -3
  494. package/dist/lib/scope/types.js.map +1 -1
  495. package/dist/long-request-fetch.d.ts +9 -0
  496. package/dist/long-request-fetch.d.ts.map +1 -0
  497. package/dist/long-request-fetch.js +48 -0
  498. package/dist/long-request-fetch.js.map +1 -0
  499. package/dist/mcp-server.js +1 -1
  500. package/dist/mcp-server.js.map +1 -1
  501. package/dist/release-surface/affected-skills.d.ts.map +1 -1
  502. package/dist/release-surface/affected-skills.js +1 -2
  503. package/dist/release-surface/affected-skills.js.map +1 -1
  504. package/dist/remote-host-ops.d.ts +1 -0
  505. package/dist/remote-host-ops.d.ts.map +1 -1
  506. package/dist/remote-host-ops.js +2 -2
  507. package/dist/remote-host-ops.js.map +1 -1
  508. package/dist/tmux-health.d.ts +26 -0
  509. package/dist/tmux-health.d.ts.map +1 -1
  510. package/dist/tmux-health.js +42 -0
  511. package/dist/tmux-health.js.map +1 -1
  512. package/package.json +1 -1
  513. package/tui/dist/attention/attention-model.d.ts +19 -0
  514. package/tui/dist/attention/attention-model.d.ts.map +1 -1
  515. package/tui/dist/attention/attention-model.js +38 -6
  516. package/tui/dist/attention/attention-model.js.map +1 -1
  517. package/tui/dist/commands/registry.d.ts.map +1 -1
  518. package/tui/dist/commands/registry.js +4 -1
  519. package/tui/dist/commands/registry.js.map +1 -1
  520. package/tui/dist/daemon-client.d.ts +13 -8
  521. package/tui/dist/daemon-client.d.ts.map +1 -1
  522. package/tui/dist/daemon-client.js +18 -10
  523. package/tui/dist/daemon-client.js.map +1 -1
  524. package/tui/dist/demo-data.js +17 -17
  525. package/tui/dist/demo-data.js.map +1 -1
  526. package/tui/dist/hydrate.d.ts +1 -1
  527. package/tui/dist/hydrate.d.ts.map +1 -1
  528. package/tui/dist/hydrate.js +31 -10
  529. package/tui/dist/hydrate.js.map +1 -1
  530. package/tui/dist/live-events.js +1 -1
  531. package/tui/dist/live-events.js.map +1 -1
  532. package/tui/dist/main.js +27 -7
  533. package/tui/dist/main.js.map +1 -1
  534. package/tui/dist/page-read.js +1 -1
  535. package/tui/dist/page-read.js.map +1 -1
  536. package/tui/dist/render.d.ts.map +1 -1
  537. package/tui/dist/render.js +51 -7
  538. package/tui/dist/render.js.map +1 -1
  539. package/tui/dist/state.d.ts.map +1 -1
  540. package/tui/dist/state.js +5 -1
  541. package/tui/dist/state.js.map +1 -1
  542. package/tui/dist/terminals/open-window.d.ts +8 -3
  543. package/tui/dist/terminals/open-window.d.ts.map +1 -1
  544. package/tui/dist/terminals/open-window.js +21 -6
  545. package/tui/dist/terminals/open-window.js.map +1 -1
  546. package/tui/dist/terminals/terminal-model.d.ts +1 -1
  547. package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
  548. package/tui/dist/terminals/terminal-model.js +1 -1
  549. package/tui/dist/terminals/terminal-model.js.map +1 -1
  550. package/tui/dist/types.d.ts +10 -1
  551. package/tui/dist/types.d.ts.map +1 -1
  552. package/ui/dist/assets/{index-DLP1ipGq.js → index-DV0UNxFw.js} +1 -1
  553. package/ui/dist/index.html +1 -1
@@ -0,0 +1,180 @@
1
+ import { participantsPath, type HumanFragment } from "./human-registry.js";
2
+ export { participantsPath };
3
+ export declare const PARTICIPANTS_FILE_VERSION = 1;
4
+ export interface ParticipantOrganization {
5
+ name: string;
6
+ policy?: string;
7
+ }
8
+ export interface ParticipantGroup {
9
+ organization: string;
10
+ name: string;
11
+ policy?: string;
12
+ }
13
+ export interface SharedChannelBinding {
14
+ connector: "slack";
15
+ connectorRef: string;
16
+ secretsRef: string;
17
+ channelId: string;
18
+ }
19
+ interface Placement {
20
+ organization?: string;
21
+ groups?: string[];
22
+ policy?: string;
23
+ }
24
+ export type PersonEntry = Placement & {
25
+ kind: "person";
26
+ };
27
+ export type SharedChannelEntry = Placement & {
28
+ kind: "shared-channel";
29
+ displayName: string;
30
+ channel: SharedChannelBinding;
31
+ };
32
+ export type ParticipantEntry = PersonEntry | SharedChannelEntry;
33
+ export interface ParticipantsFile {
34
+ version: typeof PARTICIPANTS_FILE_VERSION;
35
+ /** The person for anything that needs one without naming one. Never a shared channel. */
36
+ default?: string;
37
+ organizations: Record<string, ParticipantOrganization>;
38
+ groups: Record<string, ParticipantGroup>;
39
+ participants: Record<string, ParticipantEntry>;
40
+ }
41
+ export declare const emptyParticipantsFile: () => ParticipantsFile;
42
+ export type ValidateParticipantsResult = {
43
+ ok: true;
44
+ file: ParticipantsFile;
45
+ warnings: string[];
46
+ } | {
47
+ ok: false;
48
+ error: string;
49
+ };
50
+ /** Structure is checked strictly: a typo must not silently change what agents read. References to people are checked
51
+ * against `personIds` (the registered fragments) when given: a person entry or default whose fragment is gone is
52
+ * dropped with a warning; a shared channel that takes a person's id is an error (one address space). */
53
+ export declare function validateParticipantsFile(raw: unknown, personIds?: ReadonlySet<string>): ValidateParticipantsResult;
54
+ export type ReadParticipantsResult = {
55
+ ok: true;
56
+ file: ParticipantsFile;
57
+ exists: boolean;
58
+ warnings: string[];
59
+ } | {
60
+ ok: false;
61
+ error: string;
62
+ };
63
+ /** Read and validate the side file. Absent is an empty file (a one-person install needs none). */
64
+ export declare function readParticipantsFile(home?: string, personIds?: ReadonlySet<string>): ReadParticipantsResult;
65
+ /** The canonical bytes: sections in a fixed order, ids sorted, so a write is stable and diffable. */
66
+ export declare function participantsFileBody(file: ParticipantsFile): string;
67
+ export type UpdateParticipantsResult = {
68
+ ok: true;
69
+ path: string;
70
+ file: ParticipantsFile;
71
+ warnings: string[];
72
+ } | {
73
+ ok: false;
74
+ error: string;
75
+ };
76
+ /** The one writer: read the current file against the registered people, apply `change`, validate the result the same
77
+ * way a read does, then write it atomically. `change` returns an error string to refuse. */
78
+ export declare function updateParticipantsFile(change: (file: ParticipantsFile, people: readonly HumanFragment[]) => ParticipantsFile | string, home?: string): UpdateParticipantsResult;
79
+ export type DefaultPerson<T extends Pick<HumanFragment, "entityId"> = HumanFragment> = {
80
+ person: T;
81
+ source: "chosen" | "only-person";
82
+ } | {
83
+ person: null;
84
+ source: "none";
85
+ reason: string;
86
+ };
87
+ /** The person for anything that needs one without naming one (an escalation, the notice digest, Mission Control's
88
+ * my-queue, a workflow's human step, a pairing approval): the side file's default, else the only registered person,
89
+ * else none, with the reason. Never the first of several, and never workspace.operator_seat_name. */
90
+ export declare function resolveDefaultPerson<T extends Pick<HumanFragment, "entityId">>(entities: readonly T[], home?: string): DefaultPerson<T>;
91
+ export interface PolicyPart {
92
+ source: string;
93
+ text: string;
94
+ }
95
+ /** A participant's readable policy, outermost first: its organization's, each of its groups', then its own. Each part
96
+ * says where it came from, so an agent can weigh and quote it. */
97
+ export declare function effectivePolicy(id: string, file: ParticipantsFile): PolicyPart[];
98
+ export interface ParticipantView {
99
+ id: string;
100
+ address: string;
101
+ kind: "person" | "shared-channel";
102
+ displayName: string;
103
+ organization: {
104
+ id: string;
105
+ name: string;
106
+ } | null;
107
+ groups: Array<{
108
+ id: string;
109
+ name: string;
110
+ }>;
111
+ default: boolean;
112
+ policy: PolicyPart[];
113
+ channel?: {
114
+ connector: "slack";
115
+ channelId: string;
116
+ };
117
+ }
118
+ export type ParticipantsViewResult = {
119
+ ok: true;
120
+ participants: ParticipantView[];
121
+ default: DefaultPerson;
122
+ warnings: string[];
123
+ sideFile: {
124
+ path: string;
125
+ exists: boolean;
126
+ error?: string;
127
+ };
128
+ } | {
129
+ ok: false;
130
+ error: string;
131
+ };
132
+ /** Every person and shared channel, with organization, groups, the default and effective policy. An unreadable side
133
+ * file still lists the people (from their fragments), and says why the rest is missing. */
134
+ export declare function participantsView(home?: string): ParticipantsViewResult;
135
+ export interface PlacementInput {
136
+ organization?: string | null;
137
+ groups?: string[] | null;
138
+ policy?: string | null;
139
+ }
140
+ /** A person's organization, groups and policy (null clears one). The person must already be registered. */
141
+ export declare function setPersonPlacement(entityId: string, input: PlacementInput, home?: string): UpdateParticipantsResult;
142
+ /** Choose the default person, or clear it (null). */
143
+ export declare function setDefaultPerson(entityId: string | null, home?: string): UpdateParticipantsResult;
144
+ /** Register or replace a shared-channel participant. `replace` is explicit: an existing channel is never overwritten
145
+ * silently. */
146
+ export declare function setSharedChannel(id: string, input: PlacementInput & {
147
+ displayName: string;
148
+ channel: SharedChannelBinding;
149
+ }, opts?: {
150
+ replace?: boolean;
151
+ }, home?: string): UpdateParticipantsResult;
152
+ /** Remove a participant's side-file entry (a shared channel, or a person's placement), and the default if it named
153
+ * them. With `kind`, only an entry of that kind is removed: `human remove` passes "person", so it never deletes a
154
+ * shared channel that happens to share the id. */
155
+ export declare function removeParticipantEntry(id: string, home?: string, opts?: {
156
+ kind?: ParticipantEntry["kind"];
157
+ }): UpdateParticipantsResult;
158
+ /** Create or update an organization. Its policy is text agents read. */
159
+ export declare function setOrganization(id: string, input: {
160
+ name?: string;
161
+ policy?: string | null;
162
+ }, home?: string): UpdateParticipantsResult;
163
+ /** Create or update a group inside an organization. */
164
+ export declare function setGroup(id: string, input: {
165
+ organization?: string;
166
+ name?: string;
167
+ policy?: string | null;
168
+ }, home?: string): UpdateParticipantsResult;
169
+ export interface SharedChannelAddress {
170
+ entityId: string;
171
+ address: string;
172
+ channelId: string;
173
+ connectorRef: string;
174
+ }
175
+ /** Every registered shared channel, as an address. An unreadable participant file lists none (outbound to a channel
176
+ * then waits, and the queue refuses a new row to it, as for any unknown address). */
177
+ export declare function sharedChannelAddresses(home?: string): SharedChannelAddress[];
178
+ /** The registered shared channel a session ref names (`<id>@external`), or null. */
179
+ export declare function sharedChannelFor(sessionRef: string | null | undefined, home?: string): SharedChannelAddress | null;
180
+ //# sourceMappingURL=participants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"participants.d.ts","sourceRoot":"","sources":["../../../src/domain/gateway/participants.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAkE,gBAAgB,EAAiB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG1J,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;AAC1E,MAAM,WAAW,gBAAgB;IAAG,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;AACzF,MAAM,WAAW,oBAAoB;IAAG,SAAS,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AACzH,UAAU,SAAS;IAAG,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;AACjF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,QAAQ,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,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE;AAEpH;sFACsF;AACtF,wBAAgB,sBAAsB,CAAC,IAAI,GAAE,MAAyB,GAAG,oBAAoB,EAAE,CAM9F;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,GAAE,MAAyB,GAAG,oBAAoB,GAAG,IAAI,CAKpI"}
@@ -0,0 +1,434 @@
1
+ // The gateway's participant side file (0.7.3 participant foundation).
2
+ //
3
+ // Person fragments under gateway/humans/ keep their closed key set exactly as v0.7.0 reads it, so after a rollback an
4
+ // older daemon still loads every person. Everything newer lives here, in <home>/gateway/participants.yaml, which v0.7.0
5
+ // and v0.7.1 never read: the default person, organizations and their groups, each participant's organization, groups
6
+ // and readable policy, and shared-channel participants (one vetted channel is one participant, not a person per sender).
7
+ //
8
+ // Policy is text agents read and apply. Nothing here enforces it, and nothing derives it from names.
9
+ //
10
+ // A broken side file never disables the person registry: asks, answers and inbound admission keep working from the
11
+ // fragments, this file's own features report the error, and with several people no default is chosen. A reference to a
12
+ // person whose fragment is gone is a warning and is ignored, never a reason to refuse the whole file.
13
+ import { existsSync, readFileSync } from "node:fs";
14
+ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
15
+ import { getOpenRigHome } from "../../openrig-compat.js";
16
+ import { ADDRESS_DOMAIN, ENTITY_ID_PATTERN, HANDLE_PATTERN, atomicWrite, participantsPath, projectHumans } from "./human-registry.js";
17
+ // The path lives beside the person registry, which reads it to keep a person off a shared channel's id.
18
+ export { participantsPath };
19
+ export const PARTICIPANTS_FILE_VERSION = 1;
20
+ export const emptyParticipantsFile = () => ({ version: PARTICIPANTS_FILE_VERSION, organizations: {}, groups: {}, participants: {} });
21
+ const FILE_KEYS = new Set(["version", "default", "organizations", "groups", "participants"]);
22
+ const ORGANIZATION_KEYS = new Set(["name", "policy"]);
23
+ const GROUP_KEYS = new Set(["organization", "name", "policy"]);
24
+ const PERSON_KEYS = new Set(["kind", "organization", "groups", "policy"]);
25
+ const CHANNEL_KEYS = new Set(["kind", "displayName", "channel", "organization", "groups", "policy"]);
26
+ const CHANNEL_BINDING_KEYS = new Set(["connector", "connectorRef", "secretsRef", "channelId"]);
27
+ const isObj = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
28
+ const unknownKey = (obj, allowed) => Object.keys(obj).find((key) => !allowed.has(key));
29
+ const nonEmpty = (value) => typeof value === "string" && value.trim().length > 0;
30
+ /** Structure is checked strictly: a typo must not silently change what agents read. References to people are checked
31
+ * against `personIds` (the registered fragments) when given: a person entry or default whose fragment is gone is
32
+ * dropped with a warning; a shared channel that takes a person's id is an error (one address space). */
33
+ export function validateParticipantsFile(raw, personIds) {
34
+ if (!isObj(raw))
35
+ return { ok: false, error: "the participants file must be a mapping" };
36
+ const top = unknownKey(raw, FILE_KEYS);
37
+ if (top)
38
+ return { ok: false, error: `unknown key "${top}" — allowed: ${[...FILE_KEYS].join(", ")}` };
39
+ if (raw.version !== PARTICIPANTS_FILE_VERSION)
40
+ return { ok: false, error: `version must be ${PARTICIPANTS_FILE_VERSION} (found ${String(raw.version)})` };
41
+ const warnings = [];
42
+ const mapping = (key) => {
43
+ const value = raw[key];
44
+ if (value === undefined || value === null)
45
+ return {};
46
+ return isObj(value) ? value : null;
47
+ };
48
+ const organizations = {};
49
+ const rawOrganizations = mapping("organizations");
50
+ if (!rawOrganizations)
51
+ return { ok: false, error: "organizations must be a mapping of <id>: { name, policy? }" };
52
+ for (const [id, value] of Object.entries(rawOrganizations)) {
53
+ const where = `organizations.${id}`;
54
+ if (!ENTITY_ID_PATTERN.test(id))
55
+ return { ok: false, error: `${where}: the id must be a lowercase slug (a-z0-9._-)` };
56
+ if (!isObj(value))
57
+ return { ok: false, error: `${where} must be a mapping { name, policy? }` };
58
+ const extra = unknownKey(value, ORGANIZATION_KEYS);
59
+ if (extra)
60
+ return { ok: false, error: `${where} has unknown key "${extra}" — allowed: name, policy` };
61
+ if (!nonEmpty(value.name))
62
+ return { ok: false, error: `${where}.name must be a non-empty string` };
63
+ if (value.policy !== undefined && typeof value.policy !== "string")
64
+ return { ok: false, error: `${where}.policy must be text` };
65
+ organizations[id] = { name: value.name, ...(value.policy !== undefined ? { policy: value.policy } : {}) };
66
+ }
67
+ const groups = {};
68
+ const rawGroups = mapping("groups");
69
+ if (!rawGroups)
70
+ return { ok: false, error: "groups must be a mapping of <id>: { organization, name, policy? }" };
71
+ for (const [id, value] of Object.entries(rawGroups)) {
72
+ const where = `groups.${id}`;
73
+ if (!ENTITY_ID_PATTERN.test(id))
74
+ return { ok: false, error: `${where}: the id must be a lowercase slug (a-z0-9._-)` };
75
+ if (!isObj(value))
76
+ return { ok: false, error: `${where} must be a mapping { organization, name, policy? }` };
77
+ const extra = unknownKey(value, GROUP_KEYS);
78
+ if (extra)
79
+ return { ok: false, error: `${where} has unknown key "${extra}" — allowed: organization, name, policy` };
80
+ if (typeof value.organization !== "string" || !organizations[value.organization]) {
81
+ return { ok: false, error: `${where}.organization "${String(value.organization)}" isn't a known organization` };
82
+ }
83
+ if (!nonEmpty(value.name))
84
+ return { ok: false, error: `${where}.name must be a non-empty string` };
85
+ if (value.policy !== undefined && typeof value.policy !== "string")
86
+ return { ok: false, error: `${where}.policy must be text` };
87
+ groups[id] = { organization: value.organization, name: value.name, ...(value.policy !== undefined ? { policy: value.policy } : {}) };
88
+ }
89
+ const participants = {};
90
+ const rawParticipants = mapping("participants");
91
+ if (!rawParticipants)
92
+ return { ok: false, error: "participants must be a mapping of <id>: { kind, ... }" };
93
+ const channelOwner = new Map();
94
+ for (const [id, value] of Object.entries(rawParticipants)) {
95
+ const where = `participants.${id}`;
96
+ if (!ENTITY_ID_PATTERN.test(id))
97
+ return { ok: false, error: `${where}: the id must be a lowercase slug (a-z0-9._-)` };
98
+ if (!isObj(value))
99
+ return { ok: false, error: `${where} must be a mapping { kind, ... }` };
100
+ if (value.kind !== "person" && value.kind !== "shared-channel") {
101
+ return { ok: false, error: `${where}.kind "${String(value.kind)}" must be person or shared-channel` };
102
+ }
103
+ const extra = unknownKey(value, value.kind === "person" ? PERSON_KEYS : CHANNEL_KEYS);
104
+ if (extra)
105
+ return { ok: false, error: `${where} has unknown key "${extra}" for a ${value.kind}` };
106
+ const placement = {};
107
+ if (value.organization !== undefined) {
108
+ if (typeof value.organization !== "string" || !organizations[value.organization]) {
109
+ return { ok: false, error: `${where}.organization "${String(value.organization)}" isn't a known organization` };
110
+ }
111
+ placement.organization = value.organization;
112
+ }
113
+ if (value.groups !== undefined) {
114
+ if (!Array.isArray(value.groups))
115
+ return { ok: false, error: `${where}.groups must be a list of group ids` };
116
+ const seen = new Set();
117
+ for (const group of value.groups) {
118
+ if (typeof group !== "string" || !groups[group])
119
+ return { ok: false, error: `${where}.groups: "${String(group)}" isn't a known group` };
120
+ if (seen.has(group))
121
+ return { ok: false, error: `${where}.groups lists "${group}" twice` };
122
+ seen.add(group);
123
+ }
124
+ placement.groups = [...seen];
125
+ }
126
+ if (value.policy !== undefined) {
127
+ if (typeof value.policy !== "string")
128
+ return { ok: false, error: `${where}.policy must be text` };
129
+ placement.policy = value.policy;
130
+ }
131
+ if (value.kind === "person") {
132
+ if (personIds && !personIds.has(id)) {
133
+ warnings.push(`${where}: no person "${id}" is registered, so this entry is ignored`);
134
+ continue;
135
+ }
136
+ participants[id] = { kind: "person", ...placement };
137
+ continue;
138
+ }
139
+ if (personIds?.has(id))
140
+ return { ok: false, error: `${where}: "${id}" is already a person's id; a shared channel needs its own (they share ${id}@${ADDRESS_DOMAIN})` };
141
+ if (!nonEmpty(value.displayName))
142
+ return { ok: false, error: `${where}.displayName must be a non-empty string` };
143
+ const channel = value.channel;
144
+ if (!isObj(channel))
145
+ return { ok: false, error: `${where}.channel must be { connector: slack, connectorRef, secretsRef, channelId }` };
146
+ const channelExtra = unknownKey(channel, CHANNEL_BINDING_KEYS);
147
+ if (channelExtra)
148
+ return { ok: false, error: `${where}.channel has unknown key "${channelExtra}"` };
149
+ if (channel.connector !== "slack")
150
+ return { ok: false, error: `${where}.channel.connector must be slack` };
151
+ if (!nonEmpty(channel.connectorRef))
152
+ return { ok: false, error: `${where}.channel.connectorRef must be a non-empty string` };
153
+ if (!nonEmpty(channel.secretsRef))
154
+ return { ok: false, error: `${where}.channel.secretsRef must be a vault pointer, never the secret` };
155
+ if (typeof channel.channelId !== "string" || !HANDLE_PATTERN.test(channel.channelId)) {
156
+ return { ok: false, error: `${where}.channel.channelId "${String(channel.channelId)}" must be a Slack channel id (letters and digits)` };
157
+ }
158
+ const prior = channelOwner.get(channel.channelId);
159
+ if (prior)
160
+ return { ok: false, error: `${where}: channel ${channel.channelId} is already the participant "${prior}"` };
161
+ channelOwner.set(channel.channelId, id);
162
+ participants[id] = {
163
+ kind: "shared-channel", displayName: value.displayName,
164
+ channel: { connector: "slack", connectorRef: channel.connectorRef, secretsRef: channel.secretsRef, channelId: channel.channelId },
165
+ ...placement,
166
+ };
167
+ }
168
+ const file = { version: PARTICIPANTS_FILE_VERSION, organizations, groups, participants };
169
+ if (raw.default !== undefined && raw.default !== null) {
170
+ if (typeof raw.default !== "string")
171
+ return { ok: false, error: "default must be a person's id" };
172
+ if (participants[raw.default]?.kind === "shared-channel")
173
+ return { ok: false, error: `default "${raw.default}" is a shared channel; the default is a person` };
174
+ if (personIds && !personIds.has(raw.default))
175
+ warnings.push(`default: no person "${raw.default}" is registered, so no default is chosen`);
176
+ else
177
+ file.default = raw.default;
178
+ }
179
+ return { ok: true, file, warnings };
180
+ }
181
+ /** Read and validate the side file. Absent is an empty file (a one-person install needs none). */
182
+ export function readParticipantsFile(home = getOpenRigHome(), personIds) {
183
+ const path = participantsPath(home);
184
+ if (!existsSync(path))
185
+ return { ok: true, file: emptyParticipantsFile(), exists: false, warnings: [] };
186
+ let raw;
187
+ try {
188
+ raw = parseYaml(readFileSync(path, "utf8"));
189
+ }
190
+ catch (err) {
191
+ return { ok: false, error: `the participants file at ${path} doesn't parse: ${err.message}` };
192
+ }
193
+ const validated = validateParticipantsFile(raw, personIds);
194
+ if (!validated.ok)
195
+ return { ok: false, error: `the participants file at ${path} is invalid: ${validated.error}` };
196
+ return { ok: true, file: validated.file, exists: true, warnings: validated.warnings };
197
+ }
198
+ const FILE_HEADER = "# OpenRig gateway participants: the default person, organizations, groups, readable policy and shared channels.\n" +
199
+ "# Written by `rig gateway` verbs and read by OpenRig 0.7.3 and later. Older daemons don't read this file, and\n" +
200
+ "# person records stay in gateway/humans/, so a rollback still loads every person.\n";
201
+ const sortedRecord = (record) => Object.fromEntries(Object.keys(record).sort().map((key) => [key, record[key]]));
202
+ /** The canonical bytes: sections in a fixed order, ids sorted, so a write is stable and diffable. */
203
+ export function participantsFileBody(file) {
204
+ const body = { version: file.version };
205
+ if (file.default)
206
+ body.default = file.default;
207
+ body.organizations = sortedRecord(file.organizations);
208
+ body.groups = sortedRecord(file.groups);
209
+ body.participants = sortedRecord(file.participants);
210
+ return FILE_HEADER + stringifyYaml(body);
211
+ }
212
+ /** The one writer: read the current file against the registered people, apply `change`, validate the result the same
213
+ * way a read does, then write it atomically. `change` returns an error string to refuse. */
214
+ export function updateParticipantsFile(change, home = getOpenRigHome()) {
215
+ const people = projectHumans(home);
216
+ if (!people.ok)
217
+ return { ok: false, error: `can't check participants against the person registry, which is invalid: ${people.error}` };
218
+ const personIds = new Set(people.entities.map((entity) => entity.entityId));
219
+ const current = readParticipantsFile(home, personIds);
220
+ if (!current.ok)
221
+ return current;
222
+ const next = change(structuredClone(current.file), people.entities);
223
+ if (typeof next === "string")
224
+ return { ok: false, error: next };
225
+ const validated = validateParticipantsFile(JSON.parse(JSON.stringify(next)), personIds);
226
+ if (!validated.ok)
227
+ return { ok: false, error: validated.error };
228
+ // The read already dropped entries for people removed by hand, so a reference to an unregistered person here is this
229
+ // change's own mistake: refuse it rather than write an entry nobody can use.
230
+ if (validated.warnings.length > 0)
231
+ return { ok: false, error: validated.warnings.join("; ") };
232
+ const path = participantsPath(home);
233
+ const written = atomicWrite(path, participantsFileBody(validated.file));
234
+ // The warnings name the stale entries this write left out.
235
+ return written.ok ? { ok: true, path, file: validated.file, warnings: current.warnings } : written;
236
+ }
237
+ /** The person for anything that needs one without naming one (an escalation, the notice digest, Mission Control's
238
+ * my-queue, a workflow's human step, a pairing approval): the side file's default, else the only registered person,
239
+ * else none, with the reason. Never the first of several, and never workspace.operator_seat_name. */
240
+ export function resolveDefaultPerson(entities, home = getOpenRigHome()) {
241
+ const side = readParticipantsFile(home, new Set(entities.map((entity) => entity.entityId)));
242
+ const chosen = side.ok && side.file.default ? entities.find((entity) => entity.entityId === side.file.default) : undefined;
243
+ if (chosen)
244
+ return { person: chosen, source: "chosen" };
245
+ if (entities.length === 1)
246
+ return { person: entities[0], source: "only-person" };
247
+ if (entities.length === 0)
248
+ return { person: null, source: "none", reason: "no person is registered" };
249
+ return {
250
+ person: null, source: "none",
251
+ reason: side.ok
252
+ ? "several people are registered and none is the default; choose one with `rig gateway default <id>`"
253
+ : `several people are registered and the default can't be read (${side.error})`,
254
+ };
255
+ }
256
+ /** A participant's readable policy, outermost first: its organization's, each of its groups', then its own. Each part
257
+ * says where it came from, so an agent can weigh and quote it. */
258
+ export function effectivePolicy(id, file) {
259
+ const entry = file.participants[id];
260
+ if (!entry)
261
+ return [];
262
+ const parts = [];
263
+ const organization = entry.organization ? file.organizations[entry.organization] : undefined;
264
+ if (organization?.policy)
265
+ parts.push({ source: `organization ${entry.organization} (${organization.name})`, text: organization.policy });
266
+ for (const groupId of entry.groups ?? []) {
267
+ const group = file.groups[groupId];
268
+ if (group?.policy)
269
+ parts.push({ source: `group ${groupId} (${group.name})`, text: group.policy });
270
+ }
271
+ if (entry.policy)
272
+ parts.push({ source: "participant", text: entry.policy });
273
+ return parts;
274
+ }
275
+ /** Every person and shared channel, with organization, groups, the default and effective policy. An unreadable side
276
+ * file still lists the people (from their fragments), and says why the rest is missing. */
277
+ export function participantsView(home = getOpenRigHome()) {
278
+ const people = projectHumans(home);
279
+ if (!people.ok)
280
+ return { ok: false, error: people.error };
281
+ const personIds = new Set(people.entities.map((entity) => entity.entityId));
282
+ const side = readParticipantsFile(home, personIds);
283
+ const file = side.ok ? side.file : emptyParticipantsFile();
284
+ const chosen = resolveDefaultPerson(people.entities, home);
285
+ const placementOf = (id) => {
286
+ const entry = file.participants[id];
287
+ const organization = entry?.organization ? { id: entry.organization, name: file.organizations[entry.organization].name } : null;
288
+ const groups = (entry?.groups ?? []).map((groupId) => ({ id: groupId, name: file.groups[groupId].name }));
289
+ return { organization, groups, policy: effectivePolicy(id, file) };
290
+ };
291
+ const views = people.entities.map((entity) => ({
292
+ id: entity.entityId, address: entity.address, kind: "person", displayName: entity.displayName,
293
+ ...placementOf(entity.entityId), default: chosen.person?.entityId === entity.entityId,
294
+ }));
295
+ for (const [id, entry] of Object.entries(file.participants)) {
296
+ if (entry.kind !== "shared-channel")
297
+ continue;
298
+ views.push({
299
+ id, address: `${id}@${ADDRESS_DOMAIN}`, kind: "shared-channel", displayName: entry.displayName,
300
+ ...placementOf(id), default: false, channel: { connector: entry.channel.connector, channelId: entry.channel.channelId },
301
+ });
302
+ }
303
+ views.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
304
+ return {
305
+ ok: true, participants: views, default: chosen, warnings: side.ok ? side.warnings : [],
306
+ sideFile: { path: participantsPath(home), exists: side.ok ? side.exists : true, ...(side.ok ? {} : { error: side.error }) },
307
+ };
308
+ }
309
+ const applyPlacement = (entry, input) => {
310
+ if (input.organization !== undefined) {
311
+ if (input.organization === null)
312
+ delete entry.organization;
313
+ else
314
+ entry.organization = input.organization;
315
+ }
316
+ if (input.groups !== undefined) {
317
+ if (input.groups === null || input.groups.length === 0)
318
+ delete entry.groups;
319
+ else
320
+ entry.groups = input.groups;
321
+ }
322
+ if (input.policy !== undefined) {
323
+ if (input.policy === null || input.policy === "")
324
+ delete entry.policy;
325
+ else
326
+ entry.policy = input.policy;
327
+ }
328
+ };
329
+ /** A person's organization, groups and policy (null clears one). The person must already be registered. */
330
+ export function setPersonPlacement(entityId, input, home = getOpenRigHome()) {
331
+ return updateParticipantsFile((file, people) => {
332
+ if (!people.some((person) => person.entityId === entityId))
333
+ return `no person "${entityId}" is registered`;
334
+ const entry = file.participants[entityId]?.kind === "person" ? file.participants[entityId] : { kind: "person" };
335
+ applyPlacement(entry, input);
336
+ // A person with nothing placed needs no entry: the fragment already makes them a participant.
337
+ if (entry.organization || entry.groups || entry.policy)
338
+ file.participants[entityId] = entry;
339
+ else
340
+ delete file.participants[entityId];
341
+ return file;
342
+ }, home);
343
+ }
344
+ /** Choose the default person, or clear it (null). */
345
+ export function setDefaultPerson(entityId, home = getOpenRigHome()) {
346
+ return updateParticipantsFile((file, people) => {
347
+ if (entityId === null) {
348
+ delete file.default;
349
+ return file;
350
+ }
351
+ if (!people.some((person) => person.entityId === entityId))
352
+ return `no person "${entityId}" is registered; the default is a registered person`;
353
+ file.default = entityId;
354
+ return file;
355
+ }, home);
356
+ }
357
+ /** Register or replace a shared-channel participant. `replace` is explicit: an existing channel is never overwritten
358
+ * silently. */
359
+ export function setSharedChannel(id, input, opts = {}, home = getOpenRigHome()) {
360
+ return updateParticipantsFile((file) => {
361
+ const existing = file.participants[id];
362
+ if (existing && existing.kind !== "shared-channel")
363
+ return `"${id}" is a person`;
364
+ if (existing && !opts.replace)
365
+ return `shared channel "${id}" already exists — pass an explicit replace to update it (no silent overwrite)`;
366
+ const entry = { kind: "shared-channel", displayName: input.displayName, channel: input.channel };
367
+ applyPlacement(entry, input);
368
+ file.participants[id] = entry;
369
+ return file;
370
+ }, home);
371
+ }
372
+ /** Remove a participant's side-file entry (a shared channel, or a person's placement), and the default if it named
373
+ * them. With `kind`, only an entry of that kind is removed: `human remove` passes "person", so it never deletes a
374
+ * shared channel that happens to share the id. */
375
+ export function removeParticipantEntry(id, home = getOpenRigHome(), opts = {}) {
376
+ return updateParticipantsFile((file) => {
377
+ if (!opts.kind || file.participants[id]?.kind === opts.kind)
378
+ delete file.participants[id];
379
+ if (file.default === id && opts.kind !== "shared-channel")
380
+ delete file.default;
381
+ return file;
382
+ }, home);
383
+ }
384
+ /** Create or update an organization. Its policy is text agents read. */
385
+ export function setOrganization(id, input, home = getOpenRigHome()) {
386
+ return updateParticipantsFile((file) => {
387
+ const current = file.organizations[id];
388
+ const name = input.name ?? current?.name;
389
+ if (!name)
390
+ return `organization "${id}" is new, so it needs a name`;
391
+ const next = { name };
392
+ const policy = input.policy === undefined ? current?.policy : input.policy;
393
+ if (policy)
394
+ next.policy = policy;
395
+ file.organizations[id] = next;
396
+ return file;
397
+ }, home);
398
+ }
399
+ /** Create or update a group inside an organization. */
400
+ export function setGroup(id, input, home = getOpenRigHome()) {
401
+ return updateParticipantsFile((file) => {
402
+ const current = file.groups[id];
403
+ const organization = input.organization ?? current?.organization;
404
+ const name = input.name ?? current?.name;
405
+ if (!organization || !name)
406
+ return `group "${id}" is new, so it needs an organization and a name`;
407
+ const next = { organization, name };
408
+ const policy = input.policy === undefined ? current?.policy : input.policy;
409
+ if (policy)
410
+ next.policy = policy;
411
+ file.groups[id] = next;
412
+ return file;
413
+ }, home);
414
+ }
415
+ /** Every registered shared channel, as an address. An unreadable participant file lists none (outbound to a channel
416
+ * then waits, and the queue refuses a new row to it, as for any unknown address). */
417
+ export function sharedChannelAddresses(home = getOpenRigHome()) {
418
+ const side = readParticipantsFile(home);
419
+ if (!side.ok)
420
+ return [];
421
+ return Object.entries(side.file.participants).flatMap(([id, entry]) => entry.kind === "shared-channel"
422
+ ? [{ entityId: id, address: `${id}@${ADDRESS_DOMAIN}`, channelId: entry.channel.channelId, connectorRef: entry.channel.connectorRef }]
423
+ : []);
424
+ }
425
+ /** The registered shared channel a session ref names (`<id>@external`), or null. */
426
+ export function sharedChannelFor(sessionRef, home = getOpenRigHome()) {
427
+ if (!sessionRef)
428
+ return null;
429
+ const local = sessionRef.endsWith(`@${ADDRESS_DOMAIN}`) ? sessionRef.slice(0, -(ADDRESS_DOMAIN.length + 1)) : null;
430
+ if (!local)
431
+ return null;
432
+ return sharedChannelAddresses(home).find((channel) => channel.entityId === local) ?? null;
433
+ }
434
+ //# sourceMappingURL=participants.js.map