@idleware/ringi 0.5.0 → 0.6.1

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 (378) hide show
  1. package/package.json +1 -1
  2. package/target/dts/adapters/fs/index.d.ts +2 -0
  3. package/target/dts/adapters/fs/lock.d.ts +1 -0
  4. package/target/dts/adapters/fs/write.d.ts +5 -0
  5. package/target/dts/adapters/host-posix/group-state.d.ts +7 -0
  6. package/target/dts/adapters/host-posix/groups.d.ts +1 -0
  7. package/target/dts/adapters/host-posix/index.d.ts +2 -0
  8. package/target/dts/adapters/host-posix/launch.d.ts +7 -0
  9. package/target/dts/adapters/host-posix/probes.d.ts +5 -0
  10. package/target/dts/adapters/host-posix/stats.d.ts +9 -0
  11. package/target/dts/adapters/keys-file/index.d.ts +2 -0
  12. package/target/dts/adapters/state-fs/index.d.ts +5 -0
  13. package/target/dts/adapters/tool-claude/index.d.ts +2 -0
  14. package/target/dts/adapters/tool-codex/index.d.ts +2 -0
  15. package/target/dts/adapters/tool-cursor/index.d.ts +2 -0
  16. package/target/dts/adapters/tool-traces/index.d.ts +3 -0
  17. package/target/dts/adapters/transport-git/branches.d.ts +43 -0
  18. package/target/dts/adapters/transport-git/files.d.ts +2 -0
  19. package/target/dts/adapters/transport-git/index.d.ts +32 -0
  20. package/target/dts/adapters/transport-git/marks.d.ts +20 -0
  21. package/target/dts/adapters/transport-git/remote/admit.d.ts +7 -0
  22. package/target/dts/adapters/transport-git/remote/alarms.d.ts +3 -0
  23. package/target/dts/adapters/transport-git/remote/bootstrap.d.ts +7 -0
  24. package/target/dts/adapters/transport-git/remote/branch-commit.d.ts +3 -0
  25. package/target/dts/adapters/transport-git/remote/branch-control.d.ts +15 -0
  26. package/target/dts/adapters/transport-git/remote/branch-scan.d.ts +2 -0
  27. package/target/dts/adapters/transport-git/remote/branch.d.ts +5 -0
  28. package/target/dts/adapters/transport-git/remote/cache.d.ts +3 -0
  29. package/target/dts/adapters/transport-git/remote/commits.d.ts +2 -0
  30. package/target/dts/adapters/transport-git/remote/forget.d.ts +2 -0
  31. package/target/dts/adapters/transport-git/remote/git.d.ts +26 -0
  32. package/target/dts/adapters/transport-git/remote/heartbeat-facts.d.ts +1 -0
  33. package/target/dts/adapters/transport-git/remote/heartbeat-name.d.ts +6 -0
  34. package/target/dts/adapters/transport-git/remote/heartbeat-object.d.ts +10 -0
  35. package/target/dts/adapters/transport-git/remote/heartbeat-push.d.ts +2 -0
  36. package/target/dts/adapters/transport-git/remote/heartbeat.d.ts +7 -0
  37. package/target/dts/adapters/transport-git/remote/keys.d.ts +13 -0
  38. package/target/dts/adapters/transport-git/remote/main.d.ts +11 -0
  39. package/target/dts/adapters/transport-git/remote/process.d.ts +20 -0
  40. package/target/dts/adapters/transport-git/remote/push-retry.d.ts +2 -0
  41. package/target/dts/adapters/transport-git/remote/push-validate.d.ts +2 -0
  42. package/target/dts/adapters/transport-git/remote/push.d.ts +16 -0
  43. package/target/dts/adapters/transport-git/remote/roster.d.ts +7 -0
  44. package/target/dts/adapters/transport-git/remote/signals.d.ts +15 -0
  45. package/target/dts/adapters/transport-git/remote/signature.d.ts +5 -0
  46. package/target/dts/adapters/transport-git/remote/sync-heartbeat.d.ts +2 -0
  47. package/target/dts/adapters/transport-git/remote/sync-rooms.d.ts +6 -0
  48. package/target/dts/adapters/transport-git/remote/sync-tags.d.ts +8 -0
  49. package/target/dts/adapters/transport-git/remote/sync.d.ts +2 -0
  50. package/target/dts/adapters/transport-git/remote/types.d.ts +64 -0
  51. package/target/dts/adapters/transport-git/remote.d.ts +17 -0
  52. package/target/dts/adapters/transport-git/repo.d.ts +31 -0
  53. package/target/dts/adapters/transport-git/run.d.ts +21 -0
  54. package/target/dts/adapters/transport-git/signing.d.ts +4 -0
  55. package/target/dts/adapters/transport-git/tags.d.ts +15 -0
  56. package/target/dts/adapters/transport-git/transport.d.ts +7 -0
  57. package/target/dts/adapters/transport-kafka/index.d.ts +2 -0
  58. package/target/dts/adapters/transport-temporal/index.d.ts +2 -0
  59. package/target/dts/cli.d.ts +2 -1
  60. package/target/dts/{cli/agent.d.ts → clients/cli/agent/index.d.ts} +3 -3
  61. package/target/dts/{cli → clients/cli/agent}/session.d.ts +2 -2
  62. package/target/dts/clients/cli/arg-parse.d.ts +2 -0
  63. package/target/dts/{cli → clients/cli}/args.d.ts +2 -2
  64. package/target/dts/clients/cli/commands.d.ts +2 -0
  65. package/target/dts/clients/cli/context.d.ts +4 -0
  66. package/target/dts/{cli/index.d.ts → clients/cli/help.d.ts} +1 -3
  67. package/target/dts/clients/cli/index.d.ts +4 -0
  68. package/target/dts/clients/cli/operator/heartbeat-format.d.ts +5 -0
  69. package/target/dts/clients/cli/operator/heartbeat.d.ts +3 -0
  70. package/target/dts/clients/cli/operator/hub-commands.d.ts +6 -0
  71. package/target/dts/clients/cli/operator/hub.d.ts +2 -0
  72. package/target/dts/clients/cli/operator/index.d.ts +5 -0
  73. package/target/dts/clients/cli/operator/room-lifecycle.d.ts +5 -0
  74. package/target/dts/clients/cli/operator/room-list.d.ts +5 -0
  75. package/target/dts/clients/cli/operator/room-members.d.ts +4 -0
  76. package/target/dts/clients/cli/operator/room.d.ts +2 -0
  77. package/target/dts/clients/cli/operator/sessions.d.ts +5 -0
  78. package/target/dts/clients/cli/operator/watch.d.ts +2 -0
  79. package/target/dts/clients/cli/operator/where-format.d.ts +7 -0
  80. package/target/dts/clients/cli/operator/where.d.ts +2 -0
  81. package/target/dts/clients/cli/shared/budget.d.ts +7 -0
  82. package/target/dts/clients/cli/shared/files.d.ts +4 -0
  83. package/target/dts/clients/cli/shared/index.d.ts +7 -0
  84. package/target/dts/clients/cli/shared/messages.d.ts +7 -0
  85. package/target/dts/clients/cli/shared/profile.d.ts +4 -0
  86. package/target/dts/clients/cli/shared/session.d.ts +6 -0
  87. package/target/dts/clients/cli/shared/signals.d.ts +3 -0
  88. package/target/dts/clients/cli/shared/work.d.ts +6 -0
  89. package/target/dts/clients/cli/skill/index.d.ts +3 -0
  90. package/target/dts/{cli/skill.d.ts → clients/cli/skill/targets.d.ts} +1 -2
  91. package/target/dts/composition/index.d.ts +2 -0
  92. package/target/dts/{heartbeat → core/agents/heartbeat}/index.d.ts +2 -4
  93. package/target/dts/{app/heartbeat.d.ts → core/agents/heartbeat/pulse.d.ts} +5 -6
  94. package/target/dts/core/agents/heartbeat/singleton.d.ts +3 -0
  95. package/target/dts/core/agents/heartbeat/tools.d.ts +6 -0
  96. package/target/dts/{app → core/agents}/overview.d.ts +12 -6
  97. package/target/dts/core/agents/ports/host.d.ts +47 -0
  98. package/target/dts/core/agents/ports/index.d.ts +9 -0
  99. package/target/dts/core/agents/ports/tools.d.ts +18 -0
  100. package/target/dts/core/agents/sessions/agent.d.ts +70 -0
  101. package/target/dts/core/agents/sessions/binding.d.ts +9 -0
  102. package/target/dts/core/agents/sessions/context.d.ts +8 -0
  103. package/target/dts/{runtime/session.d.ts → core/agents/sessions/index.d.ts} +2 -9
  104. package/target/dts/core/agents/sessions/join.d.ts +20 -0
  105. package/target/dts/core/agents/sessions/resume.d.ts +2 -0
  106. package/target/dts/core/agents/sessions/session.d.ts +46 -0
  107. package/target/dts/core/agents/sessions/wait.d.ts +38 -0
  108. package/target/dts/core/agents/turns/budgets.d.ts +5 -0
  109. package/target/dts/core/agents/turns/dispatch.d.ts +9 -0
  110. package/target/dts/core/agents/turns/exhaustion.d.ts +11 -0
  111. package/target/dts/core/agents/turns/grants.d.ts +4 -0
  112. package/target/dts/core/agents/turns/index.d.ts +4 -0
  113. package/target/dts/core/agents/turns/limits.d.ts +2 -0
  114. package/target/dts/core/agents/turns/messages.d.ts +10 -0
  115. package/target/dts/core/agents/turns/pings.d.ts +5 -0
  116. package/target/dts/core/agents/turns/plan.d.ts +3 -0
  117. package/target/dts/core/agents/turns/poll.d.ts +8 -0
  118. package/target/dts/core/agents/turns/results.d.ts +3 -0
  119. package/target/dts/core/agents/turns/seat.d.ts +2 -0
  120. package/target/dts/core/agents/turns/types.d.ts +59 -0
  121. package/target/dts/core/hub/decisions/budget.d.ts +15 -0
  122. package/target/dts/core/hub/decisions/check.d.ts +6 -0
  123. package/target/dts/core/hub/decisions/index.d.ts +5 -0
  124. package/target/dts/core/hub/decisions/proposal.d.ts +38 -0
  125. package/target/dts/core/hub/decisions/usage.d.ts +12 -0
  126. package/target/dts/{runtime/reader.d.ts → core/hub/history/index.d.ts} +12 -6
  127. package/target/dts/core/hub/ports/index.d.ts +16 -0
  128. package/target/dts/core/hub/ports/state.d.ts +12 -0
  129. package/target/dts/{store/index.d.ts → core/hub/ports/store.d.ts} +48 -18
  130. package/target/dts/core/hub/protocol/index.d.ts +5 -0
  131. package/target/dts/{protocol/index.d.ts → core/hub/protocol/model.d.ts} +0 -25
  132. package/target/dts/core/hub/protocol/order.d.ts +2 -0
  133. package/target/dts/core/hub/protocol/reading.d.ts +8 -0
  134. package/target/dts/core/hub/protocol/text.d.ts +11 -0
  135. package/target/dts/core/hub/protocol/threads.d.ts +5 -0
  136. package/target/dts/core/hub/rooms/compat.d.ts +5 -0
  137. package/target/dts/core/hub/rooms/hubs.d.ts +14 -0
  138. package/target/dts/core/hub/rooms/index.d.ts +53 -0
  139. package/target/dts/core/hub/rooms/messages.d.ts +8 -0
  140. package/target/dts/core/hub/rooms/rooms.d.ts +10 -0
  141. package/target/dts/core/hub/signals/check.d.ts +3 -0
  142. package/target/dts/core/hub/signals/effective.d.ts +3 -0
  143. package/target/dts/core/hub/signals/index.d.ts +5 -0
  144. package/target/dts/core/hub/signals/marks.d.ts +4 -0
  145. package/target/dts/core/hub/signals/model.d.ts +28 -0
  146. package/target/dts/core/hub/signals/pins.d.ts +5 -0
  147. package/target/dts/{hub/signals.d.ts → core/hub/signals/write.d.ts} +1 -1
  148. package/target/dts/core/hub/usecases/actor.d.ts +6 -0
  149. package/target/dts/{app → core/hub/usecases}/budget.d.ts +5 -18
  150. package/target/dts/core/hub/usecases/config.d.ts +6 -0
  151. package/target/dts/{app → core/hub/usecases}/context.d.ts +3 -8
  152. package/target/dts/{app → core/hub/usecases}/hubs.d.ts +1 -1
  153. package/target/dts/core/hub/usecases/propose.d.ts +17 -0
  154. package/target/dts/{app → core/hub/usecases}/room.d.ts +8 -34
  155. package/target/dts/{app → core/hub/usecases}/rooms.d.ts +2 -6
  156. package/target/dts/core/hub/usecases/roster.d.ts +5 -0
  157. package/target/dts/core/hub/usecases/send.d.ts +21 -0
  158. package/target/dts/core/hub/usecases/staging.d.ts +8 -0
  159. package/target/dts/{app → core/hub/usecases}/view.d.ts +4 -4
  160. package/target/dts/{domain/profiles.d.ts → core/hub/work/index.d.ts} +3 -7
  161. package/target/dts/core/hub/work/parse.d.ts +2 -0
  162. package/target/dts/core/hub/work/task.d.ts +6 -0
  163. package/target/dts/core/signing/index.d.ts +35 -0
  164. package/target/dts/index.d.ts +8 -8
  165. package/target/dts/lib/fail.d.ts +8 -0
  166. package/target/dts/lib/index.d.ts +3 -11
  167. package/target/dts/lib/json.d.ts +1 -0
  168. package/target/esm/adapters/fs/index.js +5 -0
  169. package/target/esm/adapters/fs/lock.js +83 -0
  170. package/target/esm/adapters/fs/write.js +25 -0
  171. package/target/esm/adapters/host-posix/group-state.js +24 -0
  172. package/target/esm/adapters/host-posix/groups.js +43 -0
  173. package/target/esm/adapters/host-posix/index.js +35 -0
  174. package/target/esm/adapters/host-posix/launch.js +80 -0
  175. package/target/esm/adapters/host-posix/probes.js +66 -0
  176. package/target/esm/adapters/host-posix/stats.js +27 -0
  177. package/target/esm/adapters/keys-file/index.js +68 -0
  178. package/target/esm/adapters/state-fs/index.js +79 -0
  179. package/target/esm/adapters/tool-claude/index.js +32 -0
  180. package/target/esm/adapters/tool-codex/index.js +38 -0
  181. package/target/esm/adapters/tool-cursor/index.js +8 -0
  182. package/target/esm/adapters/tool-traces/index.js +18 -0
  183. package/target/esm/adapters/transport-git/branches.js +155 -0
  184. package/target/esm/adapters/transport-git/files.js +48 -0
  185. package/target/esm/adapters/transport-git/index.js +128 -0
  186. package/target/esm/adapters/transport-git/marks.js +88 -0
  187. package/target/esm/adapters/transport-git/remote/admit.js +71 -0
  188. package/target/esm/adapters/transport-git/remote/alarms.js +30 -0
  189. package/target/esm/adapters/transport-git/remote/bootstrap.js +47 -0
  190. package/target/esm/adapters/transport-git/remote/branch-commit.js +36 -0
  191. package/target/esm/adapters/transport-git/remote/branch-control.js +37 -0
  192. package/target/esm/adapters/transport-git/remote/branch-scan.js +28 -0
  193. package/target/esm/adapters/transport-git/remote/branch.js +37 -0
  194. package/target/esm/adapters/transport-git/remote/cache.js +23 -0
  195. package/target/esm/adapters/transport-git/remote/commits.js +25 -0
  196. package/target/esm/adapters/transport-git/remote/forget.js +35 -0
  197. package/target/esm/adapters/transport-git/remote/git.js +58 -0
  198. package/target/esm/adapters/transport-git/remote/heartbeat-facts.js +35 -0
  199. package/target/esm/adapters/transport-git/remote/heartbeat-name.js +19 -0
  200. package/target/esm/adapters/transport-git/remote/heartbeat-object.js +40 -0
  201. package/target/esm/adapters/transport-git/remote/heartbeat-push.js +44 -0
  202. package/target/esm/adapters/transport-git/remote/heartbeat.js +44 -0
  203. package/target/esm/adapters/transport-git/remote/keys.js +75 -0
  204. package/target/esm/adapters/transport-git/remote/main.js +41 -0
  205. package/target/esm/adapters/transport-git/remote/process.js +37 -0
  206. package/target/esm/adapters/transport-git/remote/push-retry.js +46 -0
  207. package/target/esm/adapters/transport-git/remote/push-validate.js +39 -0
  208. package/target/esm/adapters/transport-git/remote/push.js +62 -0
  209. package/target/esm/adapters/transport-git/remote/roster.js +48 -0
  210. package/target/esm/adapters/transport-git/remote/signals.js +63 -0
  211. package/target/esm/adapters/transport-git/remote/signature.js +56 -0
  212. package/target/esm/adapters/transport-git/remote/sync-heartbeat.js +26 -0
  213. package/target/esm/adapters/transport-git/remote/sync-rooms.js +38 -0
  214. package/target/esm/adapters/transport-git/remote/sync-tags.js +48 -0
  215. package/target/esm/adapters/transport-git/remote/sync.js +38 -0
  216. package/target/esm/adapters/transport-git/remote/types.js +10 -0
  217. package/target/esm/adapters/transport-git/remote.js +17 -0
  218. package/target/esm/adapters/transport-git/repo.js +115 -0
  219. package/target/esm/adapters/transport-git/run.js +57 -0
  220. package/target/esm/adapters/transport-git/signing.js +44 -0
  221. package/target/esm/adapters/transport-git/tags.js +21 -0
  222. package/target/esm/adapters/transport-git/transport.js +29 -0
  223. package/target/esm/adapters/transport-kafka/index.js +4 -0
  224. package/target/esm/adapters/transport-temporal/index.js +4 -0
  225. package/target/esm/cli.js +5 -4
  226. package/target/esm/{cli/agent.js → clients/cli/agent/index.js} +8 -7
  227. package/target/esm/{cli → clients/cli/agent}/session.js +7 -7
  228. package/target/esm/clients/cli/arg-parse.js +41 -0
  229. package/target/esm/{cli → clients/cli}/args.js +3 -36
  230. package/target/esm/clients/cli/commands.js +45 -0
  231. package/target/esm/clients/cli/context.js +6 -0
  232. package/target/esm/{cli/index.js → clients/cli/help.js} +4 -77
  233. package/target/esm/clients/cli/index.js +27 -0
  234. package/target/esm/clients/cli/operator/heartbeat-format.js +8 -0
  235. package/target/esm/clients/cli/operator/heartbeat.js +35 -0
  236. package/target/esm/clients/cli/operator/hub-commands.js +37 -0
  237. package/target/esm/clients/cli/operator/hub.js +10 -0
  238. package/target/esm/clients/cli/operator/index.js +8 -0
  239. package/target/esm/clients/cli/operator/room-lifecycle.js +23 -0
  240. package/target/esm/clients/cli/operator/room-list.js +27 -0
  241. package/target/esm/clients/cli/operator/room-members.js +15 -0
  242. package/target/esm/clients/cli/operator/room.js +15 -0
  243. package/target/esm/clients/cli/operator/sessions.js +32 -0
  244. package/target/esm/clients/cli/operator/watch.js +15 -0
  245. package/target/esm/clients/cli/operator/where-format.js +24 -0
  246. package/target/esm/clients/cli/operator/where.js +32 -0
  247. package/target/esm/clients/cli/shared/budget.js +50 -0
  248. package/target/esm/clients/cli/shared/files.js +26 -0
  249. package/target/esm/clients/cli/shared/index.js +10 -0
  250. package/target/esm/clients/cli/shared/messages.js +41 -0
  251. package/target/esm/clients/cli/shared/profile.js +17 -0
  252. package/target/esm/clients/cli/shared/session.js +8 -0
  253. package/target/esm/clients/cli/shared/signals.js +21 -0
  254. package/target/esm/clients/cli/shared/work.js +26 -0
  255. package/target/esm/clients/cli/skill/index.js +40 -0
  256. package/target/esm/clients/cli/skill/targets.js +20 -0
  257. package/target/esm/composition/index.js +34 -0
  258. package/target/esm/{heartbeat → core/agents/heartbeat}/index.js +14 -12
  259. package/target/esm/{app/heartbeat.js → core/agents/heartbeat/pulse.js} +31 -55
  260. package/target/esm/core/agents/heartbeat/singleton.js +38 -0
  261. package/target/esm/core/agents/heartbeat/tools.js +24 -0
  262. package/target/esm/{app → core/agents}/overview.js +15 -9
  263. package/target/esm/core/agents/ports/host.js +4 -0
  264. package/target/esm/core/agents/ports/index.js +7 -0
  265. package/target/esm/core/agents/ports/tools.js +5 -0
  266. package/target/esm/{app → core/agents/sessions}/agent.js +11 -43
  267. package/target/esm/core/agents/sessions/binding.js +43 -0
  268. package/target/esm/core/agents/sessions/context.js +11 -0
  269. package/target/esm/core/agents/sessions/index.js +59 -0
  270. package/target/esm/core/agents/sessions/join.js +55 -0
  271. package/target/esm/core/agents/sessions/resume.js +54 -0
  272. package/target/esm/core/agents/sessions/session.js +28 -0
  273. package/target/esm/core/agents/sessions/wait.js +47 -0
  274. package/target/esm/core/agents/turns/budgets.js +48 -0
  275. package/target/esm/core/agents/turns/dispatch.js +40 -0
  276. package/target/esm/core/agents/turns/exhaustion.js +16 -0
  277. package/target/esm/core/agents/turns/grants.js +36 -0
  278. package/target/esm/core/agents/turns/index.js +33 -0
  279. package/target/esm/core/agents/turns/limits.js +11 -0
  280. package/target/esm/core/agents/turns/messages.js +32 -0
  281. package/target/esm/core/agents/turns/pings.js +30 -0
  282. package/target/esm/core/agents/turns/plan.js +29 -0
  283. package/target/esm/core/agents/turns/poll.js +48 -0
  284. package/target/esm/core/agents/turns/results.js +40 -0
  285. package/target/esm/core/agents/turns/seat.js +44 -0
  286. package/target/esm/core/agents/turns/types.js +3 -0
  287. package/target/esm/{domain/index.js → core/hub/capabilities.js} +3 -3
  288. package/target/esm/core/hub/decisions/budget.js +40 -0
  289. package/target/esm/core/hub/decisions/check.js +43 -0
  290. package/target/esm/core/hub/decisions/index.js +10 -0
  291. package/target/esm/core/hub/decisions/proposal.js +73 -0
  292. package/target/esm/core/hub/decisions/usage.js +39 -0
  293. package/target/esm/core/hub/history/index.js +90 -0
  294. package/target/esm/core/hub/ports/index.js +10 -0
  295. package/target/esm/core/hub/ports/state.js +5 -0
  296. package/target/esm/core/hub/ports/store.js +10 -0
  297. package/target/esm/{protocol → core/hub/protocol}/files.js +4 -2
  298. package/target/esm/core/hub/protocol/index.js +9 -0
  299. package/target/esm/core/hub/protocol/model.js +15 -0
  300. package/target/esm/core/hub/protocol/order.js +39 -0
  301. package/target/esm/core/hub/protocol/reading.js +29 -0
  302. package/target/esm/core/hub/protocol/text.js +95 -0
  303. package/target/esm/core/hub/protocol/threads.js +52 -0
  304. package/target/esm/core/hub/rooms/compat.js +51 -0
  305. package/target/esm/core/hub/rooms/hubs.js +92 -0
  306. package/target/esm/core/hub/rooms/index.js +23 -0
  307. package/target/esm/core/hub/rooms/messages.js +47 -0
  308. package/target/esm/core/hub/rooms/rooms.js +84 -0
  309. package/target/esm/core/hub/signals/check.js +33 -0
  310. package/target/esm/core/hub/signals/effective.js +31 -0
  311. package/target/esm/core/hub/signals/index.js +23 -0
  312. package/target/esm/core/hub/signals/marks.js +30 -0
  313. package/target/esm/core/hub/signals/model.js +5 -0
  314. package/target/esm/core/hub/signals/pins.js +21 -0
  315. package/target/esm/{hub/signals.js → core/hub/signals/write.js} +4 -4
  316. package/target/esm/core/hub/usecases/actor.js +3 -0
  317. package/target/esm/core/hub/usecases/budget.js +78 -0
  318. package/target/esm/core/hub/usecases/config.js +5 -0
  319. package/target/esm/core/hub/usecases/context.js +13 -0
  320. package/target/esm/core/hub/usecases/hubs.js +95 -0
  321. package/target/esm/core/hub/usecases/propose.js +39 -0
  322. package/target/esm/core/hub/usecases/room.js +82 -0
  323. package/target/esm/{app → core/hub/usecases}/rooms.js +11 -63
  324. package/target/esm/core/hub/usecases/roster.js +47 -0
  325. package/target/esm/core/hub/usecases/send.js +78 -0
  326. package/target/esm/core/hub/usecases/staging.js +60 -0
  327. package/target/esm/{app → core/hub/usecases}/view.js +33 -33
  328. package/target/esm/core/hub/work/index.js +13 -0
  329. package/target/esm/core/hub/work/parse.js +37 -0
  330. package/target/esm/core/hub/work/task.js +68 -0
  331. package/target/esm/core/signing/index.js +4 -0
  332. package/target/esm/index.js +7 -6
  333. package/target/esm/lib/fail.js +18 -0
  334. package/target/esm/lib/index.js +20 -195
  335. package/target/esm/lib/json.js +81 -0
  336. package/target/dts/app/agent.d.ts +0 -109
  337. package/target/dts/app/session.d.ts +0 -65
  338. package/target/dts/cli/context.d.ts +0 -6
  339. package/target/dts/cli/operator.d.ts +0 -10
  340. package/target/dts/cli/shared.d.ts +0 -27
  341. package/target/dts/domain/decisions.d.ts +0 -65
  342. package/target/dts/domain/signals.d.ts +0 -37
  343. package/target/dts/heartbeat/platform.d.ts +0 -15
  344. package/target/dts/heartbeat/tools.d.ts +0 -11
  345. package/target/dts/home/index.d.ts +0 -21
  346. package/target/dts/hub/index.d.ts +0 -72
  347. package/target/dts/runtime/watch.d.ts +0 -17
  348. package/target/dts/store/git/index.d.ts +0 -92
  349. package/target/dts/store/git/remote.d.ts +0 -95
  350. package/target/dts/store/kafka/index.d.ts +0 -2
  351. package/target/dts/store/temporal/index.d.ts +0 -2
  352. package/target/esm/app/budget.js +0 -95
  353. package/target/esm/app/context.js +0 -16
  354. package/target/esm/app/hubs.js +0 -76
  355. package/target/esm/app/room.js +0 -181
  356. package/target/esm/app/session.js +0 -99
  357. package/target/esm/cli/context.js +0 -8
  358. package/target/esm/cli/operator.js +0 -185
  359. package/target/esm/cli/shared.js +0 -159
  360. package/target/esm/cli/skill.js +0 -54
  361. package/target/esm/domain/decisions.js +0 -178
  362. package/target/esm/domain/profiles.js +0 -96
  363. package/target/esm/domain/signals.js +0 -134
  364. package/target/esm/heartbeat/platform.js +0 -83
  365. package/target/esm/heartbeat/tools.js +0 -68
  366. package/target/esm/home/index.js +0 -88
  367. package/target/esm/hub/index.js +0 -224
  368. package/target/esm/protocol/index.js +0 -219
  369. package/target/esm/runtime/reader.js +0 -65
  370. package/target/esm/runtime/session.js +0 -116
  371. package/target/esm/runtime/watch.js +0 -321
  372. package/target/esm/store/git/index.js +0 -719
  373. package/target/esm/store/git/remote.js +0 -928
  374. package/target/esm/store/index.js +0 -15
  375. package/target/esm/store/kafka/index.js +0 -3
  376. package/target/esm/store/temporal/index.js +0 -3
  377. /package/target/dts/{domain/index.d.ts → core/hub/capabilities.d.ts} +0 -0
  378. /package/target/dts/{protocol → core/hub/protocol}/files.d.ts +0 -0
@@ -1,83 +0,0 @@
1
- // platform: what the operating system says about a process, on macOS and Linux (Ubuntu). Elsewhere every probe says
2
- // nothing (null) rather than guess.
3
- import { spawnSync } from 'node:child_process';
4
- import fs from 'node:fs';
5
- export const SUPPORTED = process.platform === 'darwin' || process.platform === 'linux';
6
- // Whether the process exists; a process of another user that we may not signal still exists.
7
- export const alive = (pid) => {
8
- try {
9
- process.kill(pid, 0);
10
- return true;
11
- }
12
- catch (e) {
13
- return e.code === 'EPERM';
14
- }
15
- };
16
- // `ps` cumulative CPU time: `[DD-][HH:]MM:SS[.ss]` on both systems.
17
- export const seconds = (time) => {
18
- const [days, rest] = time.includes('-') ? [Number(time.split('-')[0]), time.split('-')[1]] : [0, time];
19
- return days * 86400 + rest.split(':').reduce((acc, part) => acc * 60 + Number(part), 0);
20
- };
21
- // One line of /proc/<pid>/stat: the parent and the CPU seconds (user + system, in clock ticks of 1/100 s). The command
22
- // name is in parentheses and may hold spaces, so the fields are counted after the last `)`.
23
- export const procStat = (line) => {
24
- const f = line.slice(line.lastIndexOf(')') + 2).split(' ');
25
- const ppid = Number(f[1]), cpu = (Number(f[11]) + Number(f[12])) / 100;
26
- return Number.isFinite(ppid) && Number.isFinite(cpu) ? { ppid, cpu } : null;
27
- };
28
- // Linux: /proc gives CPU to the hundredth of a second, where `ps` rounds to whole seconds.
29
- const proc = () => {
30
- let pids;
31
- try {
32
- pids = fs.readdirSync('/proc').filter(d => /^\d+$/.test(d));
33
- }
34
- catch {
35
- return null;
36
- }
37
- const rows = new Map();
38
- for (const pid of pids) {
39
- try {
40
- const row = procStat(fs.readFileSync(`/proc/${pid}/stat`, 'utf8'));
41
- if (row)
42
- rows.set(Number(pid), row);
43
- }
44
- catch { /* the process ended meanwhile */ }
45
- }
46
- return rows.size ? rows : null;
47
- };
48
- // Every process with its parent and CPU seconds: /proc on Linux, else one `ps` call.
49
- export const table = () => {
50
- if (!SUPPORTED)
51
- return null;
52
- if (process.platform === 'linux') {
53
- const rows = proc();
54
- if (rows)
55
- return rows;
56
- }
57
- const r = spawnSync('ps', ['-A', '-o', 'pid=,ppid=,time='], { encoding: 'utf8', timeout: 10000 });
58
- if (r.status !== 0)
59
- return null;
60
- const rows = new Map();
61
- for (const line of r.stdout.split('\n')) {
62
- const [pid, ppid, time] = line.trim().split(/\s+/);
63
- if (pid && time)
64
- rows.set(Number(pid), { ppid: Number(ppid), cpu: seconds(time) });
65
- }
66
- return rows;
67
- };
68
- // CPU seconds the process and all its descendants used so far: a turn's model client, its tools and their children.
69
- export const treeCpu = (pid, rows = table()) => {
70
- if (!rows?.has(pid))
71
- return null;
72
- const children = new Map();
73
- for (const [p, { ppid }] of rows)
74
- children.set(ppid, [...children.get(ppid) ?? [], p]);
75
- let sum = 0;
76
- for (const stack = [pid]; stack.length;) {
77
- const p = stack.pop();
78
- sum += rows.get(p)?.cpu ?? 0;
79
- stack.push(...children.get(p) ?? []);
80
- }
81
- return sum;
82
- };
83
- //# sourceMappingURL=platform.js.map
@@ -1,68 +0,0 @@
1
- // tools: the trace each agent tool writes of a session while it works, found by the session's id. Its modification
2
- // time is the session's own activity, unlike the CPU of an app process that hosts many sessions.
3
- // Claude Code $CLAUDE_CONFIG_DIR (or ~/.claude)/projects/<dir>/<session id>.jsonl, the session's transcript
4
- // Codex $CODEX_HOME (or ~/.codex)/sessions/<yyyy>/<mm>/<dd>/rollout-<time>-<thread id>.jsonl
5
- // A ringi watcher writes no trace of its own: the CPU of its process tree speaks for its turn (platform.ts).
6
- import fs from 'node:fs';
7
- import os from 'node:os';
8
- import path from 'node:path';
9
- const UUID = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/;
10
- const dirs = (d) => { try {
11
- return fs.readdirSync(d).sort().reverse();
12
- }
13
- catch {
14
- return [];
15
- } };
16
- const mtime = (f) => { try {
17
- return fs.statSync(f).mtimeMs / 1000;
18
- }
19
- catch {
20
- return null;
21
- } };
22
- const claude = (id) => {
23
- const root = path.join(process.env.CLAUDE_CONFIG_DIR ?? path.join(os.homedir(), '.claude'), 'projects');
24
- for (const d of dirs(root))
25
- if (fs.existsSync(path.join(root, d, `${id}.jsonl`)))
26
- return path.join(root, d, `${id}.jsonl`);
27
- return null;
28
- };
29
- const codex = (id) => {
30
- const root = path.join(process.env.CODEX_HOME ?? path.join(os.homedir(), '.codex'), 'sessions');
31
- for (const y of dirs(root))
32
- for (const m of dirs(path.join(root, y)))
33
- for (const d of dirs(path.join(root, y, m))) {
34
- const f = dirs(path.join(root, y, m, d)).find(n => n.startsWith('rollout-') && n.endsWith(`-${id}.jsonl`));
35
- if (f)
36
- return path.join(root, y, m, d, f);
37
- }
38
- return null;
39
- };
40
- // A trace once found keeps its path; only its time is read again.
41
- const found = new Map();
42
- // Which tool a session runs and the id its trace is named by: Claude Code sessions are `claude:<id>`; a Codex chat
43
- // names itself with RINGI_SESSION=codex-<thread id>.
44
- export const toolOf = (s) => {
45
- const id = UUID.exec(s.handle)?.[1];
46
- if (!id)
47
- return null;
48
- if (s.handle.startsWith('claude:') || s.product === 'claude')
49
- return { tool: 'claude', id };
50
- if (s.product === 'codex' || s.handle.startsWith('env:codex-'))
51
- return { tool: 'codex', id };
52
- return null;
53
- };
54
- // When the session's tool last wrote its trace (unix seconds), or null: no tool known, or no trace found.
55
- export const traceTime = (s) => {
56
- const t = toolOf(s);
57
- if (!t)
58
- return null;
59
- const key = `${t.tool}:${t.id}`;
60
- if (!found.has(key)) {
61
- const f = t.tool === 'claude' ? claude(t.id) : codex(t.id);
62
- if (!f)
63
- return null;
64
- found.set(key, f);
65
- }
66
- return mtime(found.get(key));
67
- };
68
- //# sourceMappingURL=tools.js.map
@@ -1,88 +0,0 @@
1
- // home: where ringi keeps its state on this machine. $RINGI_HOME holds hubs (each a descriptor and a store),
2
- // reader state, session records and locks. Reading state fails closed; a write the sandbox denies fails with one
3
- // fixed instruction.
4
- import fs from 'node:fs';
5
- import os from 'node:os';
6
- import path from 'node:path';
7
- import { spawnSync } from 'node:child_process';
8
- import { fileURLToPath } from 'node:url';
9
- import { errno, fail, guardWrite, locked as lockFile, mkdirIn, note, writeJsonAtomic } from '../lib/index.js';
10
- const HERE = path.dirname(fileURLToPath(import.meta.url));
11
- // This file sits in src/main/ts/home (source) or target/esm/home (build): three levels below the package root.
12
- export const ROOT = path.resolve(HERE, '..', '..', '..');
13
- export const RESOURCES = path.join(ROOT, 'src', 'main', 'resources');
14
- export const VERSION = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version;
15
- export const HOME = path.resolve(process.env.RINGI_HOME || path.join(os.homedir(), '.ringi'));
16
- export const HOME_VERSION = 3;
17
- export const OPERATOR = 'operator';
18
- // --- writing safely ---
19
- export const guard = (fn) => guardWrite(HOME, fn);
20
- export const mkdir = (d) => mkdirIn(HOME, d);
21
- export const writeJson = (f, v) => guard(() => {
22
- mkdir(path.dirname(f));
23
- writeJsonAtomic(f, v);
24
- });
25
- // State fails closed: unreadable JSON is an error, never a silent fresh start.
26
- export const readJson = (f, dflt) => {
27
- let raw;
28
- try {
29
- raw = fs.readFileSync(f, 'utf8');
30
- }
31
- catch (e) {
32
- if (errno(e) === 'ENOENT')
33
- return dflt;
34
- throw e;
35
- }
36
- try {
37
- return JSON.parse(raw);
38
- }
39
- catch (e) {
40
- return fail(`${f} is not valid JSON (${e.message}); refusing to continue with lost state`);
41
- }
42
- };
43
- // --- the home ---
44
- export const hubsDir = () => path.join(HOME, 'hub');
45
- export const hubHome = (name) => path.join(hubsDir(), name);
46
- // The home is created on first use; anything else at that path is refused. A home of the previous layout (each hub a
47
- // bare repository `hub/<name>.git` with its settings in git config) is moved into descriptor and store.
48
- export const ensureHome = () => {
49
- const marker = path.join(HOME, 'home.json');
50
- if (fs.existsSync(marker)) {
51
- const h = readJson(marker, {});
52
- if (h.version === 2)
53
- return migrate2(marker);
54
- if (h.version !== HOME_VERSION)
55
- fail(`${HOME} is a ringi home of version ${h.version}; this ringi ${VERSION} needs version ${HOME_VERSION}`);
56
- return;
57
- }
58
- if (fs.existsSync(HOME) && fs.readdirSync(HOME).length)
59
- fail(`${HOME} exists and is not a ringi home (no home.json); move it away or set RINGI_HOME`);
60
- mkdir(HOME);
61
- writeJson(marker, { version: HOME_VERSION });
62
- };
63
- const migrate2 = (marker) => {
64
- for (const f of fs.existsSync(hubsDir()) ? fs.readdirSync(hubsDir()).filter(f => f.endsWith('.git')) : []) {
65
- const name = f.slice(0, -4);
66
- const old = path.join(hubsDir(), f);
67
- const cfg = (k) => String(spawnSync('git', ['--git-dir', old, 'config', '--get', k], { encoding: 'utf8' }).stdout ?? '').trim();
68
- const signed = cfg('ringi.type') === 'remote';
69
- const descriptor = { schema: 'ringi-hub/2', name, trust: signed ? 'signed' : 'asserted',
70
- ...(signed ? { root: cfg('ringi.rootKey') || undefined, genesis: cfg('ringi.genesis') || undefined } : {}),
71
- store: { type: 'git', path: 'store', ...(cfg('remote.origin.url') ? { remote: cfg('remote.origin.url') } : {}) } };
72
- mkdir(path.join(hubHome(name), 'store'));
73
- guard(() => fs.renameSync(old, path.join(hubHome(name), 'store', '.git')));
74
- writeJson(path.join(hubHome(name), 'hub.json'), descriptor);
75
- note(`moved hub ${name} to ${hubHome(name)} (descriptor hub.json, store/.git)`);
76
- }
77
- writeJson(marker, { version: HOME_VERSION });
78
- };
79
- export const locked = (name, fn) => {
80
- ensureHome();
81
- const dir = path.join(HOME, 'locks');
82
- mkdir(dir);
83
- return guard(() => lockFile(path.join(dir, `${name}.lock`), fn));
84
- };
85
- export const configFile = () => path.join(HOME, 'config.json');
86
- export const config = () => ({ hub: 'local', room: null, ...readJson(configFile(), {}) });
87
- export const setConfig = (patch) => writeJson(configFile(), { ...config(), ...patch });
88
- //# sourceMappingURL=index.js.map
@@ -1,224 +0,0 @@
1
- // hub: hubs and rooms on top of any store. A hub is a directory with a descriptor (hub.json: which store, where,
2
- // what this machine pins) beside its store. Its shared contract lives in the store (contract.json, authority.json,
3
- // profiles/*.json). This file reads contracts, opens rooms with their profile and authority, and decides what a reader
4
- // accepts: only history that extends what it accepted before, from members the store verifies (docs/spec/hub-1.md, Trust).
5
- import fs from 'node:fs';
6
- import path from 'node:path';
7
- import * as D from '../domain/decisions.js';
8
- import { CAPABILITIES, unenforceable } from '../domain/index.js';
9
- import { GitStore } from '../store/git/index.js';
10
- import { HOME, OPERATOR, RESOURCES, VERSION, ensureHome, hubHome, hubsDir, locked, mkdir, writeJson } from '../home/index.js';
11
- import { DEFAULT_PROFILE, PROFILES_CAPABILITY, parseProfile } from '../domain/profiles.js';
12
- import { HIDDEN, compose, decodeText, link, parse } from '../protocol/index.js';
13
- import { emit } from './signals.js';
14
- import { STORES } from '../store/index.js';
15
- import { fail, short, strictJson } from '../lib/index.js';
16
- export const HUB_MAJOR = 1;
17
- export const CAPS = new Set(Object.keys(CAPABILITIES));
18
- export const RESERVED_ROOMS = new Set(['main', 'archive']);
19
- // Whether the room's work has started: it has the quorum of agents its genesis asked for (`Quorum`), or asked for none.
20
- export const start = (R) => {
21
- const agents = Object.values(R.members).filter(m => m.role !== 'root').length;
22
- return { quorum: R.quorum, agents, started: R.quorum === null || agents >= R.quorum };
23
- };
24
- // --- hubs ---
25
- export const hubNames = () => {
26
- try {
27
- return fs.readdirSync(hubsDir()).filter(n => fs.existsSync(path.join(hubsDir(), n, 'hub.json'))).sort();
28
- }
29
- catch {
30
- return [];
31
- }
32
- };
33
- const HUB_MD = `# ringi hub
34
-
35
- The shared contract of a ringi hub (docs/spec/hub-1.md): contract.json (schema, version, protocol, trust, capabilities, the
36
- default profile), authority.json (who may decide what, up to which budget; the root, \`operator\`, always may) and
37
- profiles/ (what a piece of work is in a room: its states, and who may move it). Use \`ringi\`; never edit by hand.
38
- `;
39
- const readProfileResource = (name) => fs.readFileSync(path.join(RESOURCES, 'profiles', `${name}.json`), 'utf8');
40
- // A new hub: local (asserted senders), or signed, with the operator's root key generated on this machine and pinned.
41
- export const createHub = (name, { signed = false, url } = {}) => {
42
- ensureHome();
43
- const dir = hubHome(name);
44
- if (fs.existsSync(dir))
45
- fail(`hub ${name} exists`);
46
- if (url && !signed)
47
- fail('--url publishes a hub; only a --signed hub may be published');
48
- const d = { schema: 'ringi-hub/2', name, trust: signed ? 'signed' : 'asserted', store: { type: 'git', path: 'store', ...(url ? { remote: url } : {}) } };
49
- try {
50
- mkdir(dir);
51
- if (signed)
52
- d.root = GitStore.rootFor(dir, d, HOME);
53
- const contract = { schema: 'ringi-hub', version: '1.1', protocol: 1, trust: d.trust, capabilities: [D.CAPABILITY, PROFILES_CAPABILITY], profile: DEFAULT_PROFILE, ...(d.root ? { root: d.root } : {}) };
54
- const store = GitStore.create(dir, d, HOME, {
55
- 'contract.json': JSON.stringify(contract, null, 2) + '\n',
56
- 'authority.json': JSON.stringify({ decide: {} }, null, 2) + '\n',
57
- 'HUB.md': HUB_MD,
58
- [`profiles/${DEFAULT_PROFILE}.json`]: readProfileResource(DEFAULT_PROFILE),
59
- }, compose(`hub ${name}`, [['To', '*'], ['Kind', 'hub']]));
60
- if (signed)
61
- d.genesis = store.contractHead();
62
- writeJson(path.join(dir, 'hub.json'), d);
63
- }
64
- catch (e) {
65
- if (!fs.existsSync(path.join(dir, 'hub.json')))
66
- fs.rmSync(dir, { recursive: true, force: true });
67
- throw e;
68
- }
69
- };
70
- export const readDescriptor = (name) => {
71
- const f = path.join(hubHome(name), 'hub.json');
72
- if (!fs.existsSync(f))
73
- fail(`no hub ${name}; hubs: ${hubNames().join(', ') || 'none'}`);
74
- const d = strictJson(fs.readFileSync(f, 'utf8'), f);
75
- if (d.schema !== 'ringi-hub/2' || d.name !== name || !['signed', 'asserted'].includes(d.trust) || !d.store?.type || !d.store.path)
76
- fail(`${f} is not a ringi hub descriptor this ringi ${VERSION} reads`);
77
- return d;
78
- };
79
- // The contract a tool must understand before it touches a hub or a room: known schema, major and capabilities.
80
- export const contractAt = (store, name, rev) => {
81
- const text = store.contractFile(rev, 'contract.json') ?? store.contractFile(rev, 'hub.json') ?? fail(`hub ${name} has no contract at ${short(rev)}`);
82
- const c = strictJson(text, `hub ${name}: contract`);
83
- if (c.schema !== 'ringi-hub')
84
- fail(`hub ${name} declares schema ${String(c.schema)}, not ringi-hub`);
85
- const major = Number(String(c.version).split('.')[0]);
86
- if (major !== HUB_MAJOR)
87
- fail(`hub ${name} follows contract version ${c.version}; this ringi ${VERSION} supports ${HUB_MAJOR}.x. Upgrade ringi`);
88
- const why = unenforceable(c.capabilities ?? []);
89
- if (why)
90
- fail(`hub ${name} ${why}, which this ringi ${VERSION} cannot enforce. Upgrade ringi`);
91
- const a = store.contractFile(rev, 'authority.json');
92
- return { ...c, authority: a === null ? {} : strictJson(a, `hub ${name}: authority.json at ${short(rev)}`) };
93
- };
94
- // A hub is opened once per process; its store syncs then (a signed store fetches and verifies), and again on refresh.
95
- const opened = new Map();
96
- export const openHub = (name, { refresh = false } = {}) => {
97
- ensureHome();
98
- if (!/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(name))
99
- fail(`bad hub name ${name}`);
100
- if (opened.has(name) && !refresh)
101
- return opened.get(name);
102
- if (name === 'local' && !fs.existsSync(path.join(hubHome(name), 'hub.json')))
103
- createHub('local');
104
- const d = readDescriptor(name);
105
- const factory = STORES[d.store.type] ?? fail(`hub ${name} uses a ${d.store.type} store; this ringi ${VERSION} knows ${Object.keys(STORES).join(', ')}`);
106
- const store = factory(hubHome(name), d, HOME);
107
- store.sync();
108
- const main = store.contractHead();
109
- const H = { name, dir: hubHome(name), d, store, main, contract: contractAt(store, name, main), signed: d.trust === 'signed' };
110
- opened.set(name, H);
111
- return H;
112
- };
113
- // --- rooms ---
114
- export const roomNames = (H, archived = false) => H.store.roomNames(archived);
115
- export const openRoom = (H, name, { quiet = false } = {}) => {
116
- if (!name)
117
- return fail('no room: the operator creates one with ringi room create <id>, or picks one with ringi room switch <id>');
118
- const s = H.store.room(name);
119
- if (!s) {
120
- if (quiet)
121
- return null;
122
- const gone = roomNames(H, true).find(a => a.startsWith(`${name}@`));
123
- return fail(gone ? `room ${name} is archived as ${gone}; read it with --room ${gone}` : `no room ${name} in hub ${H.name}; rooms: ${roomNames(H).join(', ') || 'none'}`);
124
- }
125
- // The genesis names its room, in the root's hand: a history offered under another name is not that room.
126
- const named = s.archived ? name.slice(0, name.lastIndexOf('@')) : name;
127
- const subject = s.control[0]?.rev === s.genesis ? s.control[0].text.split('\n')[0] : '(none)';
128
- if (subject !== `room ${named}` || (s.archived && name !== `${named}@${s.genesis.slice(0, 8)}`))
129
- fail(`room ${name}: its genesis is "${subject}"; refusing a room's history under another name`);
130
- // The contract in effect at each control entry: the hub contract the room was created on, then each `Contract:`
131
- // the operator moved it to. A decision names the control entry it was made under (decide.ts).
132
- const atControl = new Map();
133
- let current = s.base;
134
- for (const rec of s.control) {
135
- const m = /^Contract: ([0-9a-f]{40,64})$/m.exec(rec.text);
136
- if (m)
137
- current = m[1];
138
- atControl.set(rec.rev, current);
139
- }
140
- const contract = current === H.main ? H.contract : contractAt(H.store, H.name, current);
141
- const tables = new Map();
142
- const authorityAt = (control) => {
143
- const rev = control ? atControl.get(control) : undefined;
144
- if (!rev)
145
- return null;
146
- if (!tables.has(rev))
147
- tables.set(rev, contractAt(H.store, H.name, rev).authority);
148
- return tables.get(rev);
149
- };
150
- // The room's profile is fixed when the room is made: its content is copied into the genesis control entry, so no
151
- // later change of the hub's profiles or contract reinterprets the room's history. Rooms made before this carry
152
- // none and use the default profile of the contract they were created on.
153
- const baseProfile = contractAt(H.store, H.name, s.base).profile ?? DEFAULT_PROFILE;
154
- const profileText = H.store.controlFile(s, 'profile.json', s.genesis)
155
- ?? H.store.contractFile(s.base, `profiles/${baseProfile}.json`)
156
- ?? (baseProfile === DEFAULT_PROFILE ? readProfileResource(DEFAULT_PROFILE) : fail(`room ${name}: unknown profile ${baseProfile}`));
157
- const roster = H.store.roster(s);
158
- const members = roster?.members ?? strictJson(H.store.controlFile(s, 'members.json') ?? '{}', `room ${name}: members.json`);
159
- // The root's control records set the quorum; the latest one counts.
160
- let quorum = null;
161
- for (const rec of s.control) {
162
- const m = /^Quorum: ([1-9][0-9]?)$/m.exec(rec.text);
163
- if (m)
164
- quorum = Number(m[1]);
165
- }
166
- return { hub: H, s, name, archived: s.archived, head: s.head, genesis: s.genesis, contractRev: current, contract, authorityAt,
167
- profile: parseProfile(profileText, `room ${name}: profile`), members, quorum };
168
- };
169
- export const room = (H, name) => openRoom(H, name);
170
- export const ROOM_MD = (name) => `# room ${name}\n\nA ringi room: members.json lists who takes part; profile.json is what a piece of work is here, fixed when the room was made.\n`;
171
- export const profileText = (H, name) => H.store.contractFile(H.main, `profiles/${name}.json`) ?? (name === DEFAULT_PROFILE ? readProfileResource(DEFAULT_PROFILE) : null);
172
- // A control change under the hub lock. In a signed room membership changes only through `room admit`.
173
- export const controlChange = (R, who, subject, mutate, extra = []) => locked(`hub-${R.hub.name}`, () => {
174
- const s = R.hub.store.room(R.name) ?? fail(`room ${R.name} is gone`);
175
- const members = strictJson(R.hub.store.controlFile(s, 'members.json') ?? '{}', `room ${R.name}: members.json`);
176
- const before = JSON.stringify(members);
177
- mutate(members);
178
- if (R.hub.signed && JSON.stringify(members) !== before)
179
- fail('in a signed room, membership changes only by ringi room admit');
180
- R.head = R.hub.store.updateControl(s, who, compose(subject, [['To', '*'], ['Kind', 'room'], ...extra]), { 'members.json': JSON.stringify(members, null, 2) + '\n' });
181
- R.members = members;
182
- });
183
- // --- messages and what a reader accepts ---
184
- export const toMessage = (R, from, x, seq) => {
185
- const trust = R.hub.signed ? 'verified' : 'asserted';
186
- const files = x.files.map(f => ({ path: f.path, size: null }));
187
- const base = { id: x.id, from, trust, time: x.time, seq, files, refused: x.refused, reId: null, hopEff: 0 };
188
- const d = decodeText(x.text);
189
- if (d.invalid !== undefined) {
190
- return { ...base, invalid: d.invalid, subject: '', body: '', to: [], re: null, kind: null, state: null, assign: null, roles: null, hop: 0, bad: d.invalid, trailers: {} };
191
- }
192
- const p = parse(d.text, s => R.hub.store.isRef(s));
193
- // An extension's trailers and the room profile's states are part of a message's validity.
194
- const ext = D.check(p, s => R.hub.store.isRef(s));
195
- const state = !p.bad && p.state && !R.profile.states.includes(p.state) ? `State ${p.state} is not in profile ${R.profile.name}` : null;
196
- return { ...base, invalid: null, ...p, bad: p.bad ?? ext ?? state };
197
- };
198
- // The room as stored, read without a reader's lock or state: for an author working out the signals of its own message
199
- // (append runs inside reader locks too). Readers check signals themselves.
200
- export const asStored = (R) => {
201
- const s = R.hub.store.room(R.name) ?? R.s;
202
- return link(new Map(R.hub.store.logIds(s).map(id => [id, R.hub.store.messages(s, id, R.hub.store.logHead(s, id)).map((x, seq) => toMessage(R, id, x, seq))])));
203
- };
204
- const CARRIES = (p, R) => !p.bad && (p.kind === R.profile.opens || !!p.assign || !!p.state || ['proposal', 'stamp', 'decision', 'usage'].includes(p.kind ?? ''));
205
- // A message on the author's log, and the signals it made (signals.ts).
206
- export const append = (R, who, text, entries = []) => {
207
- const id = R.hub.store.append(R.s, who, text, entries);
208
- if (CARRIES(parse(text, s => R.hub.store.isRef(s)), R)) {
209
- const all = asStored(R);
210
- const m = all.get(id);
211
- if (m)
212
- emit(R, who, all, m);
213
- }
214
- return id;
215
- };
216
- export const withSizes = (R, m) => {
217
- if (!m.files.length)
218
- return [];
219
- const sizes = R.hub.store.sizes(m.id, m.files.map(f => f.path));
220
- return m.files.map(f => ({ ...f, size: sizes.get(f.path) ?? null }));
221
- };
222
- export const pongText = (me, m, what) => compose(`pong: ${me} ${what}`, [['To', m.from], ['Re', m.id], ['Kind', 'pong'], ['Hop', String(m.hopEff + 1)]]);
223
- export { OPERATOR, HIDDEN };
224
- //# sourceMappingURL=index.js.map