@idleware/ringi 0.4.0 → 0.6.0

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 (375) hide show
  1. package/README.md +1 -1
  2. package/package.json +5 -1
  3. package/target/dts/adapters/fs/index.d.ts +2 -0
  4. package/target/dts/adapters/fs/lock.d.ts +1 -0
  5. package/target/dts/adapters/fs/write.d.ts +5 -0
  6. package/target/dts/adapters/host-posix/group-state.d.ts +7 -0
  7. package/target/dts/adapters/host-posix/groups.d.ts +1 -0
  8. package/target/dts/adapters/host-posix/index.d.ts +2 -0
  9. package/target/dts/adapters/host-posix/launch.d.ts +7 -0
  10. package/target/dts/adapters/host-posix/probes.d.ts +5 -0
  11. package/target/dts/adapters/host-posix/stats.d.ts +9 -0
  12. package/target/dts/adapters/keys-file/index.d.ts +2 -0
  13. package/target/dts/adapters/state-fs/index.d.ts +5 -0
  14. package/target/dts/adapters/tool-claude/index.d.ts +2 -0
  15. package/target/dts/adapters/tool-codex/index.d.ts +2 -0
  16. package/target/dts/adapters/tool-cursor/index.d.ts +2 -0
  17. package/target/dts/adapters/tool-traces/index.d.ts +3 -0
  18. package/target/dts/adapters/transport-git/branches.d.ts +43 -0
  19. package/target/dts/adapters/transport-git/files.d.ts +2 -0
  20. package/target/dts/adapters/transport-git/index.d.ts +32 -0
  21. package/target/dts/adapters/transport-git/marks.d.ts +20 -0
  22. package/target/dts/adapters/transport-git/remote/admit.d.ts +7 -0
  23. package/target/dts/adapters/transport-git/remote/alarms.d.ts +3 -0
  24. package/target/dts/adapters/transport-git/remote/bootstrap.d.ts +7 -0
  25. package/target/dts/adapters/transport-git/remote/branch-commit.d.ts +3 -0
  26. package/target/dts/adapters/transport-git/remote/branch-control.d.ts +15 -0
  27. package/target/dts/adapters/transport-git/remote/branch-scan.d.ts +2 -0
  28. package/target/dts/adapters/transport-git/remote/branch.d.ts +5 -0
  29. package/target/dts/adapters/transport-git/remote/cache.d.ts +3 -0
  30. package/target/dts/adapters/transport-git/remote/commits.d.ts +2 -0
  31. package/target/dts/adapters/transport-git/remote/forget.d.ts +2 -0
  32. package/target/dts/adapters/transport-git/remote/git.d.ts +26 -0
  33. package/target/dts/adapters/transport-git/remote/heartbeat-facts.d.ts +1 -0
  34. package/target/dts/adapters/transport-git/remote/heartbeat-name.d.ts +6 -0
  35. package/target/dts/adapters/transport-git/remote/heartbeat-object.d.ts +10 -0
  36. package/target/dts/adapters/transport-git/remote/heartbeat-push.d.ts +2 -0
  37. package/target/dts/adapters/transport-git/remote/heartbeat.d.ts +7 -0
  38. package/target/dts/adapters/transport-git/remote/keys.d.ts +13 -0
  39. package/target/dts/adapters/transport-git/remote/main.d.ts +11 -0
  40. package/target/dts/adapters/transport-git/remote/process.d.ts +20 -0
  41. package/target/dts/adapters/transport-git/remote/push-retry.d.ts +2 -0
  42. package/target/dts/adapters/transport-git/remote/push-validate.d.ts +2 -0
  43. package/target/dts/adapters/transport-git/remote/push.d.ts +16 -0
  44. package/target/dts/adapters/transport-git/remote/roster.d.ts +7 -0
  45. package/target/dts/adapters/transport-git/remote/signals.d.ts +15 -0
  46. package/target/dts/adapters/transport-git/remote/signature.d.ts +5 -0
  47. package/target/dts/adapters/transport-git/remote/sync-heartbeat.d.ts +2 -0
  48. package/target/dts/adapters/transport-git/remote/sync-rooms.d.ts +6 -0
  49. package/target/dts/adapters/transport-git/remote/sync-tags.d.ts +8 -0
  50. package/target/dts/adapters/transport-git/remote/sync.d.ts +2 -0
  51. package/target/dts/adapters/transport-git/remote/types.d.ts +64 -0
  52. package/target/dts/adapters/transport-git/remote.d.ts +17 -0
  53. package/target/dts/adapters/transport-git/repo.d.ts +31 -0
  54. package/target/dts/adapters/transport-git/run.d.ts +21 -0
  55. package/target/dts/adapters/transport-git/signing.d.ts +4 -0
  56. package/target/dts/adapters/transport-git/tags.d.ts +15 -0
  57. package/target/dts/adapters/transport-git/transport.d.ts +7 -0
  58. package/target/dts/adapters/transport-kafka/index.d.ts +2 -0
  59. package/target/dts/adapters/transport-temporal/index.d.ts +2 -0
  60. package/target/dts/cli.d.ts +2 -1
  61. package/target/dts/{cli/agent.d.ts → clients/cli/agent/index.d.ts} +3 -3
  62. package/target/dts/{cli → clients/cli/agent}/session.d.ts +2 -2
  63. package/target/dts/clients/cli/arg-parse.d.ts +2 -0
  64. package/target/dts/{cli → clients/cli}/args.d.ts +2 -2
  65. package/target/dts/clients/cli/commands.d.ts +2 -0
  66. package/target/dts/clients/cli/context.d.ts +4 -0
  67. package/target/dts/{cli/index.d.ts → clients/cli/help.d.ts} +1 -3
  68. package/target/dts/clients/cli/index.d.ts +4 -0
  69. package/target/dts/clients/cli/operator/heartbeat-format.d.ts +5 -0
  70. package/target/dts/clients/cli/operator/heartbeat.d.ts +3 -0
  71. package/target/dts/clients/cli/operator/hub-commands.d.ts +6 -0
  72. package/target/dts/clients/cli/operator/hub.d.ts +2 -0
  73. package/target/dts/clients/cli/operator/index.d.ts +5 -0
  74. package/target/dts/clients/cli/operator/room-lifecycle.d.ts +5 -0
  75. package/target/dts/clients/cli/operator/room-list.d.ts +5 -0
  76. package/target/dts/clients/cli/operator/room-members.d.ts +4 -0
  77. package/target/dts/clients/cli/operator/room.d.ts +2 -0
  78. package/target/dts/clients/cli/operator/sessions.d.ts +5 -0
  79. package/target/dts/clients/cli/operator/watch.d.ts +2 -0
  80. package/target/dts/clients/cli/operator/where-format.d.ts +7 -0
  81. package/target/dts/clients/cli/operator/where.d.ts +2 -0
  82. package/target/dts/clients/cli/shared/budget.d.ts +7 -0
  83. package/target/dts/clients/cli/shared/files.d.ts +4 -0
  84. package/target/dts/clients/cli/shared/index.d.ts +7 -0
  85. package/target/dts/clients/cli/shared/messages.d.ts +7 -0
  86. package/target/dts/clients/cli/shared/profile.d.ts +4 -0
  87. package/target/dts/clients/cli/shared/session.d.ts +6 -0
  88. package/target/dts/clients/cli/shared/signals.d.ts +3 -0
  89. package/target/dts/clients/cli/shared/work.d.ts +6 -0
  90. package/target/dts/clients/cli/skill/index.d.ts +3 -0
  91. package/target/dts/{cli/skill.d.ts → clients/cli/skill/targets.d.ts} +1 -2
  92. package/target/dts/composition/index.d.ts +2 -0
  93. package/target/dts/core/agents/heartbeat/index.d.ts +33 -0
  94. package/target/dts/core/agents/heartbeat/pulse.d.ts +32 -0
  95. package/target/dts/core/agents/heartbeat/singleton.d.ts +3 -0
  96. package/target/dts/core/agents/heartbeat/tools.d.ts +6 -0
  97. package/target/dts/{app → core/agents}/overview.d.ts +12 -6
  98. package/target/dts/core/agents/ports/host.d.ts +47 -0
  99. package/target/dts/core/agents/ports/index.d.ts +9 -0
  100. package/target/dts/core/agents/ports/tools.d.ts +18 -0
  101. package/target/dts/core/agents/sessions/agent.d.ts +70 -0
  102. package/target/dts/core/agents/sessions/binding.d.ts +9 -0
  103. package/target/dts/core/agents/sessions/context.d.ts +8 -0
  104. package/target/dts/{runtime/session.d.ts → core/agents/sessions/index.d.ts} +2 -9
  105. package/target/dts/core/agents/sessions/join.d.ts +20 -0
  106. package/target/dts/core/agents/sessions/resume.d.ts +2 -0
  107. package/target/dts/core/agents/sessions/session.d.ts +46 -0
  108. package/target/dts/core/agents/sessions/wait.d.ts +38 -0
  109. package/target/dts/core/agents/turns/budgets.d.ts +5 -0
  110. package/target/dts/core/agents/turns/dispatch.d.ts +9 -0
  111. package/target/dts/core/agents/turns/exhaustion.d.ts +11 -0
  112. package/target/dts/core/agents/turns/grants.d.ts +4 -0
  113. package/target/dts/core/agents/turns/index.d.ts +4 -0
  114. package/target/dts/core/agents/turns/limits.d.ts +2 -0
  115. package/target/dts/core/agents/turns/messages.d.ts +10 -0
  116. package/target/dts/core/agents/turns/pings.d.ts +5 -0
  117. package/target/dts/core/agents/turns/plan.d.ts +3 -0
  118. package/target/dts/core/agents/turns/poll.d.ts +8 -0
  119. package/target/dts/core/agents/turns/results.d.ts +3 -0
  120. package/target/dts/core/agents/turns/seat.d.ts +2 -0
  121. package/target/dts/core/agents/turns/types.d.ts +59 -0
  122. package/target/dts/core/hub/decisions/budget.d.ts +15 -0
  123. package/target/dts/core/hub/decisions/check.d.ts +6 -0
  124. package/target/dts/core/hub/decisions/index.d.ts +5 -0
  125. package/target/dts/core/hub/decisions/proposal.d.ts +38 -0
  126. package/target/dts/core/hub/decisions/usage.d.ts +12 -0
  127. package/target/dts/{runtime/reader.d.ts → core/hub/history/index.d.ts} +12 -6
  128. package/target/dts/core/hub/ports/index.d.ts +16 -0
  129. package/target/dts/core/hub/ports/state.d.ts +12 -0
  130. package/target/dts/{store/index.d.ts → core/hub/ports/store.d.ts} +58 -17
  131. package/target/dts/core/hub/protocol/index.d.ts +5 -0
  132. package/target/dts/{protocol/index.d.ts → core/hub/protocol/model.d.ts} +0 -25
  133. package/target/dts/core/hub/protocol/order.d.ts +2 -0
  134. package/target/dts/core/hub/protocol/reading.d.ts +8 -0
  135. package/target/dts/core/hub/protocol/text.d.ts +11 -0
  136. package/target/dts/core/hub/protocol/threads.d.ts +5 -0
  137. package/target/dts/core/hub/rooms/compat.d.ts +5 -0
  138. package/target/dts/core/hub/rooms/hubs.d.ts +14 -0
  139. package/target/dts/core/hub/rooms/index.d.ts +53 -0
  140. package/target/dts/core/hub/rooms/messages.d.ts +8 -0
  141. package/target/dts/core/hub/rooms/rooms.d.ts +10 -0
  142. package/target/dts/core/hub/signals/check.d.ts +3 -0
  143. package/target/dts/core/hub/signals/effective.d.ts +3 -0
  144. package/target/dts/core/hub/signals/index.d.ts +5 -0
  145. package/target/dts/core/hub/signals/marks.d.ts +4 -0
  146. package/target/dts/core/hub/signals/model.d.ts +28 -0
  147. package/target/dts/core/hub/signals/pins.d.ts +5 -0
  148. package/target/dts/{hub/signals.d.ts → core/hub/signals/write.d.ts} +1 -1
  149. package/target/dts/core/hub/usecases/actor.d.ts +6 -0
  150. package/target/dts/{app → core/hub/usecases}/budget.d.ts +5 -18
  151. package/target/dts/core/hub/usecases/config.d.ts +6 -0
  152. package/target/dts/{app → core/hub/usecases}/context.d.ts +3 -8
  153. package/target/dts/{app → core/hub/usecases}/hubs.d.ts +1 -1
  154. package/target/dts/core/hub/usecases/propose.d.ts +17 -0
  155. package/target/dts/{app → core/hub/usecases}/room.d.ts +8 -33
  156. package/target/dts/{app → core/hub/usecases}/rooms.d.ts +2 -6
  157. package/target/dts/core/hub/usecases/roster.d.ts +5 -0
  158. package/target/dts/core/hub/usecases/send.d.ts +21 -0
  159. package/target/dts/core/hub/usecases/staging.d.ts +8 -0
  160. package/target/dts/{app → core/hub/usecases}/view.d.ts +4 -4
  161. package/target/dts/{domain/profiles.d.ts → core/hub/work/index.d.ts} +3 -7
  162. package/target/dts/core/hub/work/parse.d.ts +2 -0
  163. package/target/dts/core/hub/work/task.d.ts +6 -0
  164. package/target/dts/core/signing/index.d.ts +35 -0
  165. package/target/dts/index.d.ts +8 -8
  166. package/target/dts/lib/fail.d.ts +8 -0
  167. package/target/dts/lib/index.d.ts +3 -11
  168. package/target/dts/lib/json.d.ts +1 -0
  169. package/target/esm/adapters/fs/index.js +5 -0
  170. package/target/esm/adapters/fs/lock.js +83 -0
  171. package/target/esm/adapters/fs/write.js +25 -0
  172. package/target/esm/adapters/host-posix/group-state.js +24 -0
  173. package/target/esm/adapters/host-posix/groups.js +43 -0
  174. package/target/esm/adapters/host-posix/index.js +35 -0
  175. package/target/esm/adapters/host-posix/launch.js +80 -0
  176. package/target/esm/adapters/host-posix/probes.js +66 -0
  177. package/target/esm/adapters/host-posix/stats.js +27 -0
  178. package/target/esm/adapters/keys-file/index.js +68 -0
  179. package/target/esm/adapters/state-fs/index.js +79 -0
  180. package/target/esm/adapters/tool-claude/index.js +32 -0
  181. package/target/esm/adapters/tool-codex/index.js +38 -0
  182. package/target/esm/adapters/tool-cursor/index.js +8 -0
  183. package/target/esm/adapters/tool-traces/index.js +18 -0
  184. package/target/esm/adapters/transport-git/branches.js +155 -0
  185. package/target/esm/adapters/transport-git/files.js +48 -0
  186. package/target/esm/adapters/transport-git/index.js +128 -0
  187. package/target/esm/adapters/transport-git/marks.js +88 -0
  188. package/target/esm/adapters/transport-git/remote/admit.js +71 -0
  189. package/target/esm/adapters/transport-git/remote/alarms.js +30 -0
  190. package/target/esm/adapters/transport-git/remote/bootstrap.js +47 -0
  191. package/target/esm/adapters/transport-git/remote/branch-commit.js +36 -0
  192. package/target/esm/adapters/transport-git/remote/branch-control.js +37 -0
  193. package/target/esm/adapters/transport-git/remote/branch-scan.js +28 -0
  194. package/target/esm/adapters/transport-git/remote/branch.js +37 -0
  195. package/target/esm/adapters/transport-git/remote/cache.js +23 -0
  196. package/target/esm/adapters/transport-git/remote/commits.js +25 -0
  197. package/target/esm/adapters/transport-git/remote/forget.js +35 -0
  198. package/target/esm/adapters/transport-git/remote/git.js +58 -0
  199. package/target/esm/adapters/transport-git/remote/heartbeat-facts.js +35 -0
  200. package/target/esm/adapters/transport-git/remote/heartbeat-name.js +19 -0
  201. package/target/esm/adapters/transport-git/remote/heartbeat-object.js +40 -0
  202. package/target/esm/adapters/transport-git/remote/heartbeat-push.js +44 -0
  203. package/target/esm/adapters/transport-git/remote/heartbeat.js +44 -0
  204. package/target/esm/adapters/transport-git/remote/keys.js +75 -0
  205. package/target/esm/adapters/transport-git/remote/main.js +41 -0
  206. package/target/esm/adapters/transport-git/remote/process.js +37 -0
  207. package/target/esm/adapters/transport-git/remote/push-retry.js +46 -0
  208. package/target/esm/adapters/transport-git/remote/push-validate.js +39 -0
  209. package/target/esm/adapters/transport-git/remote/push.js +62 -0
  210. package/target/esm/adapters/transport-git/remote/roster.js +48 -0
  211. package/target/esm/adapters/transport-git/remote/signals.js +63 -0
  212. package/target/esm/adapters/transport-git/remote/signature.js +56 -0
  213. package/target/esm/adapters/transport-git/remote/sync-heartbeat.js +26 -0
  214. package/target/esm/adapters/transport-git/remote/sync-rooms.js +38 -0
  215. package/target/esm/adapters/transport-git/remote/sync-tags.js +48 -0
  216. package/target/esm/adapters/transport-git/remote/sync.js +38 -0
  217. package/target/esm/adapters/transport-git/remote/types.js +10 -0
  218. package/target/esm/adapters/transport-git/remote.js +17 -0
  219. package/target/esm/adapters/transport-git/repo.js +115 -0
  220. package/target/esm/adapters/transport-git/run.js +57 -0
  221. package/target/esm/adapters/transport-git/signing.js +44 -0
  222. package/target/esm/adapters/transport-git/tags.js +21 -0
  223. package/target/esm/adapters/transport-git/transport.js +29 -0
  224. package/target/esm/adapters/transport-kafka/index.js +4 -0
  225. package/target/esm/adapters/transport-temporal/index.js +4 -0
  226. package/target/esm/cli.js +5 -4
  227. package/target/esm/{cli/agent.js → clients/cli/agent/index.js} +8 -7
  228. package/target/esm/{cli → clients/cli/agent}/session.js +13 -7
  229. package/target/esm/clients/cli/arg-parse.js +41 -0
  230. package/target/esm/{cli → clients/cli}/args.js +3 -36
  231. package/target/esm/clients/cli/commands.js +45 -0
  232. package/target/esm/clients/cli/context.js +6 -0
  233. package/target/esm/{cli/index.js → clients/cli/help.js} +6 -73
  234. package/target/esm/clients/cli/index.js +27 -0
  235. package/target/esm/clients/cli/operator/heartbeat-format.js +8 -0
  236. package/target/esm/clients/cli/operator/heartbeat.js +35 -0
  237. package/target/esm/clients/cli/operator/hub-commands.js +37 -0
  238. package/target/esm/clients/cli/operator/hub.js +10 -0
  239. package/target/esm/clients/cli/operator/index.js +8 -0
  240. package/target/esm/clients/cli/operator/room-lifecycle.js +23 -0
  241. package/target/esm/clients/cli/operator/room-list.js +27 -0
  242. package/target/esm/clients/cli/operator/room-members.js +15 -0
  243. package/target/esm/clients/cli/operator/room.js +15 -0
  244. package/target/esm/clients/cli/operator/sessions.js +32 -0
  245. package/target/esm/clients/cli/operator/watch.js +15 -0
  246. package/target/esm/clients/cli/operator/where-format.js +24 -0
  247. package/target/esm/clients/cli/operator/where.js +32 -0
  248. package/target/esm/clients/cli/shared/budget.js +50 -0
  249. package/target/esm/clients/cli/shared/files.js +26 -0
  250. package/target/esm/clients/cli/shared/index.js +10 -0
  251. package/target/esm/clients/cli/shared/messages.js +41 -0
  252. package/target/esm/clients/cli/shared/profile.js +17 -0
  253. package/target/esm/clients/cli/shared/session.js +8 -0
  254. package/target/esm/clients/cli/shared/signals.js +21 -0
  255. package/target/esm/clients/cli/shared/work.js +26 -0
  256. package/target/esm/clients/cli/skill/index.js +40 -0
  257. package/target/esm/clients/cli/skill/targets.js +20 -0
  258. package/target/esm/composition/index.js +34 -0
  259. package/target/esm/core/agents/heartbeat/index.js +43 -0
  260. package/target/esm/core/agents/heartbeat/pulse.js +86 -0
  261. package/target/esm/core/agents/heartbeat/singleton.js +38 -0
  262. package/target/esm/core/agents/heartbeat/tools.js +24 -0
  263. package/target/esm/{app → core/agents}/overview.js +15 -9
  264. package/target/esm/core/agents/ports/host.js +4 -0
  265. package/target/esm/core/agents/ports/index.js +7 -0
  266. package/target/esm/core/agents/ports/tools.js +5 -0
  267. package/target/esm/{app → core/agents/sessions}/agent.js +11 -43
  268. package/target/esm/core/agents/sessions/binding.js +43 -0
  269. package/target/esm/core/agents/sessions/context.js +11 -0
  270. package/target/esm/core/agents/sessions/index.js +59 -0
  271. package/target/esm/core/agents/sessions/join.js +55 -0
  272. package/target/esm/core/agents/sessions/resume.js +54 -0
  273. package/target/esm/core/agents/sessions/session.js +28 -0
  274. package/target/esm/core/agents/sessions/wait.js +47 -0
  275. package/target/esm/core/agents/turns/budgets.js +48 -0
  276. package/target/esm/core/agents/turns/dispatch.js +40 -0
  277. package/target/esm/core/agents/turns/exhaustion.js +16 -0
  278. package/target/esm/core/agents/turns/grants.js +36 -0
  279. package/target/esm/core/agents/turns/index.js +33 -0
  280. package/target/esm/core/agents/turns/limits.js +11 -0
  281. package/target/esm/core/agents/turns/messages.js +32 -0
  282. package/target/esm/core/agents/turns/pings.js +30 -0
  283. package/target/esm/core/agents/turns/plan.js +29 -0
  284. package/target/esm/core/agents/turns/poll.js +48 -0
  285. package/target/esm/core/agents/turns/results.js +40 -0
  286. package/target/esm/core/agents/turns/seat.js +44 -0
  287. package/target/esm/core/agents/turns/types.js +3 -0
  288. package/target/esm/{domain/index.js → core/hub/capabilities.js} +3 -3
  289. package/target/esm/core/hub/decisions/budget.js +40 -0
  290. package/target/esm/core/hub/decisions/check.js +43 -0
  291. package/target/esm/core/hub/decisions/index.js +10 -0
  292. package/target/esm/core/hub/decisions/proposal.js +73 -0
  293. package/target/esm/core/hub/decisions/usage.js +39 -0
  294. package/target/esm/core/hub/history/index.js +90 -0
  295. package/target/esm/core/hub/ports/index.js +10 -0
  296. package/target/esm/core/hub/ports/state.js +5 -0
  297. package/target/esm/core/hub/ports/store.js +10 -0
  298. package/target/esm/{protocol → core/hub/protocol}/files.js +4 -2
  299. package/target/esm/core/hub/protocol/index.js +9 -0
  300. package/target/esm/core/hub/protocol/model.js +15 -0
  301. package/target/esm/core/hub/protocol/order.js +39 -0
  302. package/target/esm/core/hub/protocol/reading.js +29 -0
  303. package/target/esm/core/hub/protocol/text.js +95 -0
  304. package/target/esm/core/hub/protocol/threads.js +52 -0
  305. package/target/esm/core/hub/rooms/compat.js +42 -0
  306. package/target/esm/core/hub/rooms/hubs.js +92 -0
  307. package/target/esm/core/hub/rooms/index.js +23 -0
  308. package/target/esm/core/hub/rooms/messages.js +47 -0
  309. package/target/esm/core/hub/rooms/rooms.js +84 -0
  310. package/target/esm/core/hub/signals/check.js +33 -0
  311. package/target/esm/core/hub/signals/effective.js +31 -0
  312. package/target/esm/core/hub/signals/index.js +23 -0
  313. package/target/esm/core/hub/signals/marks.js +30 -0
  314. package/target/esm/core/hub/signals/model.js +5 -0
  315. package/target/esm/core/hub/signals/pins.js +21 -0
  316. package/target/esm/{hub/signals.js → core/hub/signals/write.js} +4 -4
  317. package/target/esm/core/hub/usecases/actor.js +3 -0
  318. package/target/esm/core/hub/usecases/budget.js +78 -0
  319. package/target/esm/core/hub/usecases/config.js +5 -0
  320. package/target/esm/core/hub/usecases/context.js +13 -0
  321. package/target/esm/core/hub/usecases/hubs.js +95 -0
  322. package/target/esm/core/hub/usecases/propose.js +39 -0
  323. package/target/esm/core/hub/usecases/room.js +82 -0
  324. package/target/esm/{app → core/hub/usecases}/rooms.js +11 -63
  325. package/target/esm/core/hub/usecases/roster.js +47 -0
  326. package/target/esm/core/hub/usecases/send.js +78 -0
  327. package/target/esm/core/hub/usecases/staging.js +60 -0
  328. package/target/esm/{app → core/hub/usecases}/view.js +33 -33
  329. package/target/esm/core/hub/work/index.js +13 -0
  330. package/target/esm/core/hub/work/parse.js +37 -0
  331. package/target/esm/core/hub/work/task.js +68 -0
  332. package/target/esm/core/signing/index.js +4 -0
  333. package/target/esm/index.js +7 -6
  334. package/target/esm/lib/fail.js +18 -0
  335. package/target/esm/lib/index.js +20 -195
  336. package/target/esm/lib/json.js +81 -0
  337. package/target/dts/app/agent.d.ts +0 -109
  338. package/target/dts/app/session.d.ts +0 -65
  339. package/target/dts/cli/context.d.ts +0 -6
  340. package/target/dts/cli/operator.d.ts +0 -8
  341. package/target/dts/cli/shared.d.ts +0 -27
  342. package/target/dts/domain/decisions.d.ts +0 -65
  343. package/target/dts/domain/signals.d.ts +0 -37
  344. package/target/dts/home/index.d.ts +0 -21
  345. package/target/dts/hub/index.d.ts +0 -72
  346. package/target/dts/runtime/watch.d.ts +0 -17
  347. package/target/dts/store/git/index.d.ts +0 -79
  348. package/target/dts/store/git/remote.d.ts +0 -86
  349. package/target/dts/store/kafka/index.d.ts +0 -2
  350. package/target/dts/store/temporal/index.d.ts +0 -2
  351. package/target/esm/app/budget.js +0 -95
  352. package/target/esm/app/context.js +0 -16
  353. package/target/esm/app/hubs.js +0 -76
  354. package/target/esm/app/room.js +0 -163
  355. package/target/esm/app/session.js +0 -99
  356. package/target/esm/cli/context.js +0 -8
  357. package/target/esm/cli/operator.js +0 -157
  358. package/target/esm/cli/shared.js +0 -159
  359. package/target/esm/cli/skill.js +0 -54
  360. package/target/esm/domain/decisions.js +0 -178
  361. package/target/esm/domain/profiles.js +0 -96
  362. package/target/esm/domain/signals.js +0 -134
  363. package/target/esm/home/index.js +0 -88
  364. package/target/esm/hub/index.js +0 -224
  365. package/target/esm/protocol/index.js +0 -219
  366. package/target/esm/runtime/reader.js +0 -65
  367. package/target/esm/runtime/session.js +0 -116
  368. package/target/esm/runtime/watch.js +0 -321
  369. package/target/esm/store/git/index.js +0 -644
  370. package/target/esm/store/git/remote.js +0 -758
  371. package/target/esm/store/index.js +0 -15
  372. package/target/esm/store/kafka/index.js +0 -3
  373. package/target/esm/store/temporal/index.js +0 -3
  374. /package/target/dts/{domain/index.d.ts → core/hub/capabilities.d.ts} +0 -0
  375. /package/target/dts/{protocol → core/hub/protocol}/files.d.ts +0 -0
@@ -1,9 +1,10 @@
1
- // Session interface: the operator's words become typed app requests.
2
- import * as Session from '../app/session.js';
3
- import { fail } from '../lib/index.js';
4
- import { opt, out } from './args.js';
5
- import { showInbox } from './agent.js';
6
- import { scopeLine, taskLine, waiting } from './shared.js';
1
+ // session: what the operator says in an agent's chat (join, continue, stop, leave) becomes the session's requests.
2
+ import * as Heartbeat from '../../../core/agents/heartbeat/pulse.js';
3
+ import * as Session from '../../../core/agents/sessions/session.js';
4
+ import { fail } from '../../../lib/index.js';
5
+ import { opt, out } from '../args.js';
6
+ import { showInbox } from './index.js';
7
+ import { scopeLine, taskLine, waiting } from '../shared/index.js';
7
8
  export const briefing = (s) => {
8
9
  const r = Session.briefing(s);
9
10
  const auto = r.start.quorum !== null;
@@ -30,9 +31,14 @@ export const join = (o) => {
30
31
  return;
31
32
  }
32
33
  out(`joined ${r.hub}/${r.room} as ${r.agent}`);
34
+ Heartbeat.ensurePulse(process.argv[1]);
33
35
  briefing(r.session);
34
36
  };
35
- export const resume = (o) => briefing(Session.resume(o._[0]));
37
+ export const resume = (o) => {
38
+ const s = Session.resume(o._[0]);
39
+ Heartbeat.ensurePulse(process.argv[1]);
40
+ briefing(s);
41
+ };
36
42
  export const stop = () => {
37
43
  const s = Session.stop();
38
44
  out(`stopped: ${s.agent} keeps its seat in ${s.hub}/${s.room} and reacts to nothing until the operator says "continue"`);
@@ -0,0 +1,41 @@
1
+ // Parse one option at a time, keeping positional arguments and repeated values in order.
2
+ import { fail } from '../../lib/index.js';
3
+ const BOOLS = new Set(['task', 'peek', 'all', 'json', 'help', 'once', 'project', 'follow', 'short', 'yes', 'require-grant', 'md', 'archived', 'signed', 'repair', 'handoff', 'clear', 'published']);
4
+ const MULTI = new Set(['m', 'attach', 'set', 'drop']);
5
+ const SHORT = { m: 'm', F: 'file', n: 'n', o: 'out', h: 'help' };
6
+ const option = (a) => {
7
+ if (a.startsWith('--')) {
8
+ const [key, val] = a.slice(2).split(/=(.*)/s);
9
+ return { key, val };
10
+ }
11
+ if (/^-[a-zA-Z]$/.test(a))
12
+ return { key: SHORT[a[1]] ?? fail(`unknown option ${a}`) };
13
+ return null;
14
+ };
15
+ const consume = (argv, o, i) => {
16
+ const parsed = option(argv[i]);
17
+ if (!parsed) {
18
+ o._.push(argv[i]);
19
+ return 1;
20
+ }
21
+ const { key, val } = parsed;
22
+ if (BOOLS.has(key)) {
23
+ o[key] = true;
24
+ return 1;
25
+ }
26
+ const value = val ?? argv[i + 1] ?? fail(`--${key} needs a value`);
27
+ o[key] = MULTI.has(key) ? [...(o[key] ?? []), value] : value;
28
+ return val === undefined ? 2 : 1;
29
+ };
30
+ export const parseArgs = (argv) => {
31
+ const o = { _: [] };
32
+ for (let i = 0; i < argv.length;) {
33
+ if (argv[i] === '--') {
34
+ o._.push(...argv.slice(i + 1));
35
+ break;
36
+ }
37
+ i += consume(argv, o, i);
38
+ }
39
+ return o;
40
+ };
41
+ //# sourceMappingURL=arg-parse.js.map
@@ -1,44 +1,11 @@
1
1
  // args: the command line: options, message text, files to attach, and printing to stdout.
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
- import { fail } from '../lib/index.js';
5
- import { checkPath } from '../app/room.js';
4
+ import { checkPath } from '../../core/hub/usecases/room.js';
5
+ import { fail } from '../../lib/index.js';
6
6
  export const out = (s = '') => { process.stdout.write(s.endsWith('\n') ? s : `${s}\n`); };
7
7
  export const dump = (v) => out(JSON.stringify(v, null, 2));
8
- const BOOLS = new Set(['task', 'peek', 'all', 'json', 'help', 'once', 'project', 'follow', 'short', 'yes', 'require-grant', 'md', 'archived', 'signed', 'repair', 'handoff', 'clear']);
9
- const MULTI = new Set(['m', 'attach', 'set', 'drop']);
10
- const SHORT = { m: 'm', F: 'file', n: 'n', o: 'out', h: 'help' };
11
- export const parseArgs = (argv) => {
12
- const o = { _: [] };
13
- for (let i = 0; i < argv.length; i++) {
14
- const a = argv[i];
15
- let key;
16
- let val;
17
- if (a === '--') {
18
- o._.push(...argv.slice(i + 1));
19
- break;
20
- }
21
- if (a.startsWith('--'))
22
- [key, val] = a.slice(2).split(/=(.*)/s);
23
- else if (/^-[a-zA-Z]$/.test(a))
24
- key = SHORT[a[1]] ?? fail(`unknown option ${a}`);
25
- else {
26
- o._.push(a);
27
- continue;
28
- }
29
- if (BOOLS.has(key)) {
30
- o[key] = true;
31
- continue;
32
- }
33
- if (val === undefined)
34
- val = argv[++i] ?? fail(`--${key} needs a value`);
35
- if (MULTI.has(key))
36
- o[key] = [...(o[key] ?? []), val];
37
- else
38
- o[key] = val;
39
- }
40
- return o;
41
- };
8
+ export { parseArgs } from './arg-parse.js';
42
9
  export const opt = (o, key) => typeof o[key] === 'string' ? o[key] : undefined;
43
10
  export const list = (o, key) => Array.isArray(o[key]) ? o[key] : [];
44
11
  export const flag = (o, key) => o[key] === true;
@@ -0,0 +1,45 @@
1
+ // commands: one table for the one command line: the operator's commands (operator/), `ringi agent …` for an agent
2
+ // (agent/), and the shared ones (shared/) under both; aliases kept together.
3
+ import { about } from '../../core/hub/usecases/context.js';
4
+ import { agent } from '../../core/agents/sessions/context.js';
5
+ import { fail } from '../../lib/index.js';
6
+ import { card, inbox, ping, take, wait, whoami } from './agent/index.js';
7
+ import { flag, out, parseArgs } from './args.js';
8
+ import { operatorCtx } from './context.js';
9
+ import { helpMarkdown, helpText } from './help.js';
10
+ import { forget, heartbeats, hub, pulse, roomCmd, sessions, where } from './operator/index.js';
11
+ import { join, leave, resume, stop } from './agent/session.js';
12
+ import { add, cat, decide, get, grants, log, profileCmd, proposals, propose, read, reply, send, signals, stamp_, tasks, thread, who } from './shared/index.js';
13
+ import { skill } from './skill/index.js';
14
+ import { watchCommand } from './operator/watch.js';
15
+ const SHARED = { add, send, reply, read, thread, tasks, log, cat, get, who, signals, profile: profileCmd, propose, stamp: stamp_, decide, proposals, grants };
16
+ const AGENT = { ...SHARED, inbox, whoami, status: whoami, card, ping, wait, take };
17
+ const agentCommand = (_, rest) => {
18
+ const [sub = 'whoami', ...more] = rest;
19
+ const fn = AGENT[sub] ?? fail(`unknown: ringi agent ${sub}; see ringi help`);
20
+ return fn(agent(), parseArgs(more));
21
+ };
22
+ const version = () => {
23
+ const b = about();
24
+ out(`ringi ${b.version}; hub contract ${b.contract}; capabilities ${b.capabilities.join(' ')}`);
25
+ };
26
+ const help = (o) => flag(o, 'md') ? void process.stdout.write(helpMarkdown()) : out(helpText());
27
+ const DIRECT = new Map([
28
+ ['--version', version], ['-v', version], ['version', version],
29
+ ['help', help], ['--help', help], ['-h', help], ['skill', skill], ['agent', agentCommand],
30
+ ['hub', hub], ['room', roomCmd], ['where', where], ['sessions', sessions], ['heartbeats', heartbeats],
31
+ ['pulse', pulse], ['forget', forget], ['watch', watchCommand], ['join', join], ['continue', resume], ['stop', stop], ['leave', leave]
32
+ ]);
33
+ const unknown = (cmd) => {
34
+ if (['inbox', 'whoami', 'ping', 'wait', 'card'].includes(cmd))
35
+ fail(`${cmd} is an agent command: ringi agent ${cmd}`);
36
+ return fail(`unknown command ${cmd}; see ringi help`);
37
+ };
38
+ export const dispatch = (cmd, o, rest) => {
39
+ const direct = DIRECT.get(cmd);
40
+ if (direct)
41
+ return direct(o, rest);
42
+ const shared = SHARED[cmd] ?? unknown(cmd);
43
+ return shared(operatorCtx(o), o);
44
+ };
45
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,6 @@
1
+ // context: who runs a command and in which room, from the command line.
2
+ import * as Context from '../../core/hub/usecases/context.js';
3
+ import { opt } from './args.js';
4
+ export { isRef } from '../../core/hub/usecases/room.js';
5
+ export const operatorCtx = (o) => Context.operator({ hub: opt(o, 'hub'), room: opt(o, 'room') });
6
+ //# sourceMappingURL=context.js.map
@@ -1,15 +1,5 @@
1
- // ringi: a distributed agent coordinator (docs/spec/hub-1.md). This file is the command surface: what the operator, a session
2
- // and an agent may run, and how each command maps onto hubs, rooms, sessions and the watcher.
3
- import { about, agent } from '../app/context.js';
4
- import { fail, words } from '../lib/index.js';
5
- import { flag, opt, out, parseArgs } from './args.js';
6
- import { watch } from '../app/agent.js';
7
- import { card, inbox, ping, take, wait, whoami } from './agent.js';
8
- import { operatorCtx } from './context.js';
9
- import { forget, hub, roomCmd, sessions, where } from './operator.js';
10
- import { join, leave, resume, stop } from './session.js';
11
- import { add, cat, decide, get, grants, log, profileCmd, proposals, propose, read, reply, send, signals, stamp_, tasks, thread, who } from './shared.js';
12
- import { skill } from './skill.js';
1
+ // help: the command table — every command, who runs it and what it does — as text, and as COMMANDS.md.
2
+ import { about } from '../../core/hub/usecases/context.js';
13
3
  // --- commands ---
14
4
  // [command, who runs it, what it does]: the one table behind `ringi help` and COMMANDS.md.
15
5
  export const TABLE = [
@@ -20,7 +10,6 @@ export const TABLE = [
20
10
  ['hub amend -m <subject> [--set <key>=<value>]... [--authority <file>] [--attach <file>:profiles/<name>.json]...', 'operator', 'refine the shared contract: version, capabilities, default profile, authority table, profiles'],
21
11
  ['room list [--archived]', 'operator', 'rooms of the current hub'],
22
12
  ['room create <id> [--profile <name>] [--quorum <agents>]', 'operator', 'a room for one piece of work, following a profile; becomes the current room; --quorum: its work starts by itself once that many agents joined (1: at once)'],
23
- ['room migrate <id>', 'operator', 'local hubs: join the old room branches without changing message ids or sessions'],
24
13
  ['room switch <id>', 'operator', 'change the terminal\'s current room; agents stay where they are'],
25
14
  ['room admit <agent> <public key|file>', 'operator', 'signed hubs: admit the key an agent made on its own machine'],
26
15
  ['room remove <agent>', 'operator', 'local hubs: take an agent out of the current room'],
@@ -38,6 +27,8 @@ export const TABLE = [
38
27
  ['signals [--all] [--repair]', 'both', 'what happened (signals) and where attention is (read and taken marks), each checked; --repair restores your missing signals'],
39
28
  ['profile', 'both', 'the room\'s profile: what a piece of work is, its states, who may move it'],
40
29
  ['sessions | sessions forget <handle>', 'operator', 'the chats the CLI remembers; drop a stale one'],
30
+ ['heartbeats [--json] | heartbeats --published [--room <id>]', 'operator', 'each session\'s pulse on this machine, from its process and its tool\'s trace, without the model: working, waiting (for what) or gone; --published: the room\'s heartbeat tags as an orchestrator reads them'],
31
+ ['pulse [--beat <s>] [--once]', 'operator', 'beat for every session here: sync its hub, put its heartbeat tag on the last pulled commit of its room; join and continue start it (RINGI_PULSE=off: not)'],
41
32
  ['forget <room>/<log>', 'operator', 'after a changed-history alarm: accept a new baseline for that log'],
42
33
  ['watch [<hub>:]<room>/<agent> --exec <cmd> [--handoff] [--scope <text>] [--once] [--require-grant] [--from <ids>] [--max-hop n] [--max-runs n] [--window s] [--interval s]', 'operator', 'headless turns for one agent: answers pings, spends grants, writes usage receipts; --handoff, run from the agent\'s own chat, moves its seat and scope to the watcher; exits with the failed turn\'s status'],
43
34
  ['skill install [--project] | uninstall | status | show', 'operator', 'the skill for Claude Code, Codex and Cursor'],
@@ -53,7 +44,7 @@ export const TABLE = [
53
44
  ['agent tasks | log | read | thread | cat | get | who | signals | profile', 'agent', 'reading, as the joined agent'],
54
45
  ['agent ping <id> [-m <note>] [--next <s>] | agent wait [--max <s>] | agent card -m <text>', 'agent', 'heartbeats; hold the line only when the operator asks; who you are'],
55
46
  ];
56
- const helpText = () => {
47
+ export const helpText = () => {
57
48
  const groups = [['operator', 'operator: in a terminal, in the current hub and room'], ['session', 'session: in a chat, on the operator\'s words'], ['agent', 'agent: during a turn, in the session\'s own room'], ['both', 'operator in a terminal, or an agent as ringi agent …']];
58
49
  const width = 56;
59
50
  const line = ([cmd, , what]) => cmd.length > width ? ` ringi ${cmd}\n ${' '.repeat(width + 6)} ${what}` : ` ringi ${cmd.padEnd(width)} ${what}`;
@@ -66,62 +57,4 @@ export const helpMarkdown = () => ['# ringi commands', '',
66
57
  '| command | who | what |', '|---|---|---|',
67
58
  ...TABLE.map(([cmd, w, what]) => `| \`ringi ${cmd.replace(/\|/g, '\\|')}\` | ${w} | ${what} |`), '',
68
59
  'Message ids are store revisions (git: commit shas), any unique prefix of 4+ characters. States and roles come from the room\'s profile (`ringi profile`).', ''].join('\n');
69
- const SHARED = { add, send, reply, read, thread, tasks, log, cat, get, who, signals, profile: profileCmd, propose, stamp: stamp_, decide, proposals, grants };
70
- const AGENT = { ...SHARED, inbox, whoami, status: whoami, card, ping, wait, take };
71
- // A reader that stops early (`ringi log | head`) closes the pipe: that ends the output, not the command's work.
72
- const quietPipe = (e) => { if (e.code === 'EPIPE')
73
- process.exit(process.exitCode ?? 0);
74
- else
75
- throw e; };
76
- export const main = async (argv = process.argv.slice(2)) => {
77
- if (!process.stdout.listeners('error').includes(quietPipe))
78
- process.stdout.on('error', quietPipe);
79
- const [cmd = 'help', ...rest] = argv;
80
- const o = cmd === 'agent' ? { _: [] } : parseArgs(rest);
81
- if (['--version', '-v', 'version'].includes(cmd)) {
82
- const b = about();
83
- return out(`ringi ${b.version}; hub contract ${b.contract}; capabilities ${b.capabilities.join(' ')}`);
84
- }
85
- if (['help', '--help', '-h'].includes(cmd))
86
- return flag(o, 'md') ? void process.stdout.write(helpMarkdown()) : out(helpText());
87
- if (cmd === 'skill')
88
- return skill(o);
89
- if (cmd === 'agent') {
90
- const [sub = 'whoami', ...more] = rest;
91
- const fn = AGENT[sub] ?? fail(`unknown: ringi agent ${sub}; see ringi help`);
92
- return fn(agent(), parseArgs(more));
93
- }
94
- if (cmd === 'hub')
95
- return hub(o);
96
- if (cmd === 'room')
97
- return roomCmd(o);
98
- if (cmd === 'where')
99
- return where(o);
100
- if (cmd === 'sessions')
101
- return sessions(o);
102
- if (cmd === 'forget')
103
- return forget(o);
104
- if (cmd === 'watch') {
105
- const num = (k) => opt(o, k) === undefined ? undefined : Number(opt(o, k));
106
- process.exitCode = await watch({ seat: o._[0] ?? fail('usage: ringi watch <room>/<agent> --exec <cmd> [--scope <text>] [--once] [--require-grant] …'),
107
- exec: opt(o, 'exec') ?? fail('--exec <cmd> is required: the command that starts a headless turn'),
108
- hub: opt(o, 'hub'), scope: opt(o, 'scope'), once: flag(o, 'once'), requireGrant: flag(o, 'require-grant'), handoff: flag(o, 'handoff'),
109
- interval: num('interval'), from: opt(o, 'from') ? words(opt(o, 'from')) : undefined, maxHop: num('max-hop'),
110
- maxRuns: num('max-runs'), window: num('window') }, out);
111
- return;
112
- }
113
- if (cmd === 'join')
114
- return join(o);
115
- if (cmd === 'continue')
116
- return resume(o);
117
- if (cmd === 'stop')
118
- return stop();
119
- if (cmd === 'leave')
120
- return leave();
121
- if (SHARED[cmd])
122
- return SHARED[cmd](operatorCtx(o), o);
123
- if (['inbox', 'whoami', 'ping', 'wait', 'card'].includes(cmd))
124
- fail(`${cmd} is an agent command: ringi agent ${cmd}`);
125
- fail(`unknown command ${cmd}; see ringi help`);
126
- };
127
- //# sourceMappingURL=index.js.map
60
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1,27 @@
1
+ import { parseArgs } from './args.js';
2
+ import { dispatch } from './commands.js';
3
+ import { sandboxHints } from '../../core/agents/sessions/context.js';
4
+ import { Fail, WriteDenied } from '../../lib/index.js';
5
+ export { helpMarkdown, TABLE } from './help.js';
6
+ // A reader that stops early (`ringi log | head`) closes the pipe: that ends the output, not the command's work.
7
+ const quietPipe = (e) => {
8
+ if (e.code === 'EPIPE')
9
+ process.exit(process.exitCode ?? 0);
10
+ else
11
+ throw e;
12
+ };
13
+ // What a failed command says: a refusal as it is (a write the host denied, with what each tool's sandbox needs to
14
+ // allow it), anything else with its stack.
15
+ export const failure = (e) => {
16
+ if (e instanceof WriteDenied)
17
+ return [e.message, ...sandboxHints(e.where).map(h => ` ${h}`)].join('\n');
18
+ return e instanceof Fail ? e.message : e.stack ?? String(e);
19
+ };
20
+ export const main = async (argv = process.argv.slice(2)) => {
21
+ if (!process.stdout.listeners('error').includes(quietPipe))
22
+ process.stdout.on('error', quietPipe);
23
+ const [cmd = 'help', ...rest] = argv;
24
+ const o = cmd === 'agent' ? { _: [] } : parseArgs(rest);
25
+ await dispatch(cmd, o, rest);
26
+ };
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ // heartbeat-format: one line per heartbeat, as this machine judges it or as the room publishes it.
2
+ import { short } from '../../../lib/index.js';
3
+ export const publishedLine = (h) => `${h.agent.padEnd(12)} ${(h.waits ? `${h.state} (${h.waits})` : h.state).padEnd(22)} ${h.age}s ago${h.overdue ? ', overdue' : ''} on ${short(h.target)}`;
4
+ export const pulseLine = ({ session: s, tool, beat: b }) => {
5
+ const state = b.waits ? `${b.state} (${b.waits})` : b.state;
6
+ return `${s.agent.padEnd(12)} ${`${s.hub}/${s.room}`.padEnd(24)} ${state.padEnd(22)} alive ${b.alive === null ? '?' : b.alive ? 'yes' : 'no'} quiet ${b.quiet}s${b.cpu === null ? '' : ` cpu ${b.cpu.toFixed(1)}s`} ${tool} ${s.handle}`;
7
+ };
8
+ //# sourceMappingURL=heartbeat-format.js.map
@@ -0,0 +1,35 @@
1
+ // heartbeat: `ringi heartbeats` (this machine's sessions, or what a room publishes) and `ringi pulse`.
2
+ import * as Heartbeat from '../../../core/agents/heartbeat/pulse.js';
3
+ import * as Hubs from '../../../core/hub/usecases/hubs.js';
4
+ import * as Rooms from '../../../core/hub/usecases/rooms.js';
5
+ import { dump, flag, opt, out } from '../args.js';
6
+ import { publishedLine, pulseLine } from './heartbeat-format.js';
7
+ const published = (o) => {
8
+ const R = Rooms.roomIn(Hubs.hubOf(opt(o, 'hub')), opt(o, 'room'));
9
+ const hs = Heartbeat.published(R);
10
+ if (flag(o, 'json'))
11
+ return dump(hs);
12
+ if (!hs.length)
13
+ return out(`no heartbeats in ${R.name}`);
14
+ for (const h of hs)
15
+ out(publishedLine(h));
16
+ };
17
+ const local = async (o) => {
18
+ const ps = await Heartbeat.heartbeats();
19
+ if (flag(o, 'json'))
20
+ return dump(ps);
21
+ if (!ps.length)
22
+ return out('no sessions');
23
+ for (const p of ps)
24
+ out(pulseLine(p));
25
+ };
26
+ export const heartbeats = async (o) => {
27
+ if (flag(o, 'published'))
28
+ published(o);
29
+ else
30
+ await local(o);
31
+ };
32
+ export const pulse = async (o) => {
33
+ process.exitCode = await Heartbeat.pulse({ every: Number(opt(o, 'beat') ?? 30), once: flag(o, 'once'), log: s => process.stderr.write(`ringi: ${s}\n`) });
34
+ };
35
+ //# sourceMappingURL=heartbeat.js.map
@@ -0,0 +1,37 @@
1
+ // hub-commands: `ringi hub list | create | switch | add | amend`.
2
+ import fs from 'node:fs';
3
+ import * as Hubs from '../../../core/hub/usecases/hubs.js';
4
+ import * as Rooms from '../../../core/hub/usecases/rooms.js';
5
+ import { fail } from '../../../lib/index.js';
6
+ import { attachments, flag, list, opt, out, textOf } from '../args.js';
7
+ export const listHub = (_) => {
8
+ for (const h of Hubs.hubs())
9
+ out(`${h.current ? '*' : ' '} ${h.name.padEnd(12)} ${h.store}, ${h.trust}, contract ${h.contract}, ${h.rooms} room(s)${h.remote ? ` remote ${h.remote}` : ''} ${h.dir}`);
10
+ return;
11
+ };
12
+ export const createHub = (o) => {
13
+ const [, arg] = o._;
14
+ const r = Hubs.create(arg ?? '', { signed: flag(o, 'signed'), url: opt(o, 'url') });
15
+ if (!r.add)
16
+ return out(`created hub ${arg} (${r.H.dir})`);
17
+ return out(`created signed hub ${arg}${r.H.d.store.remote ? `, published to ${r.H.d.store.remote}` : ''}. Its root key stays on this machine (${r.rootKey}).
18
+ Give every machine that joins it, out of band:
19
+ ${r.add}`);
20
+ };
21
+ export const switchHub = (o) => {
22
+ const [, arg] = o._;
23
+ Hubs.use(arg ?? fail('usage: ringi hub switch <name>'));
24
+ return out(`current hub: ${arg}; agents keep their own rooms`);
25
+ };
26
+ export const addHub = (o) => {
27
+ const [, arg] = o._;
28
+ const H = Hubs.add(arg ?? '', o._[2] ?? '', { root: opt(o, 'root'), genesis: opt(o, 'genesis') });
29
+ return out(`added signed hub ${arg} from ${o._[2]}: contract ${H.contract.version}, ${Rooms.rooms(H).length} room(s), root pinned`);
30
+ };
31
+ export const amendHub = (o) => {
32
+ const H = Hubs.hubOf(opt(o, 'hub'));
33
+ const files = list(o, 'attach').flatMap(attachments).map(e => ({ path: e.path, content: fs.readFileSync(e.file) }));
34
+ const r = Hubs.amend(H, { text: textOf(o), set: list(o, 'set'), authority: opt(o, 'authority'), files });
35
+ return out(`amended hub ${H.name}: contract ${r.version}; rooms keep their base until ringi room rebase-contract <room>`);
36
+ };
37
+ //# sourceMappingURL=hub-commands.js.map
@@ -0,0 +1,10 @@
1
+ // hub: `ringi hub <subcommand>`, by its table (hub-commands.ts).
2
+ import { fail } from '../../../lib/index.js';
3
+ import { addHub, amendHub, createHub, listHub, switchHub } from './hub-commands.js';
4
+ const COMMANDS = new Map([['list', listHub], ['create', createHub], ['switch', switchHub], ['add', addHub], ['amend', amendHub]]);
5
+ export const hub = (o) => {
6
+ const [sub] = o._;
7
+ const run = COMMANDS.get(sub || 'list') ?? fail(`unknown: hub ${sub}`);
8
+ run(o);
9
+ };
10
+ //# sourceMappingURL=hub.js.map
@@ -0,0 +1,8 @@
1
+ // operator: the commands only the operator runs, as the operator of this machine in its terminal context: hubs, rooms,
2
+ // where things stand, sessions, heartbeats, the pulse and the watcher.
3
+ export { heartbeats, pulse } from './heartbeat.js';
4
+ export { hub } from './hub.js';
5
+ export { roomCmd } from './room.js';
6
+ export { forget, sessionLine, sessions } from './sessions.js';
7
+ export { where } from './where.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,23 @@
1
+ // room-lifecycle: `ringi room archive | delete | rebase-contract`.
2
+ import * as Rooms from '../../../core/hub/usecases/rooms.js';
3
+ import { fail, short } from '../../../lib/index.js';
4
+ import { flag, opt, out } from '../args.js';
5
+ export const archiveRoom = (H, arg, o) => {
6
+ // Without an id, the room of the current context.
7
+ const R = Rooms.roomIn(H, arg ?? opt(o, 'room'));
8
+ const name = Rooms.archive(H, R);
9
+ return out(`archived ${R.name} as ${name}: read-only, wakes nobody; its sessions end. Read it with --room ${name}`);
10
+ };
11
+ export const deleteRoom = (H, arg, o) => {
12
+ const R = Rooms.roomIn(H, arg ?? opt(o, 'room'));
13
+ if (!flag(o, 'yes'))
14
+ fail(`deleting ${R.name} in hub ${H.name} erases it and everything kept for it, for good. Run again with --yes, or archive it instead`);
15
+ Rooms.erase(H, R);
16
+ return out(`deleted room ${R.name}: its branch, signals, pins, evidence and readers' state. Sessions bound to it leave it on their next turn`);
17
+ };
18
+ export const rebaseRoomContract = (H, arg, o) => {
19
+ const R = Rooms.roomIn(H, arg ?? fail('usage: ringi room rebase-contract <id>'));
20
+ Rooms.rebase(H, R);
21
+ return out(`room ${R.name} now follows the hub contract at ${short(H.main)} (${H.contract.version})`);
22
+ };
23
+ //# sourceMappingURL=room-lifecycle.js.map
@@ -0,0 +1,27 @@
1
+ // room-list: `ringi room list | create | switch`.
2
+ import { roomsActive } from '../../../core/agents/overview.js';
3
+ import * as Rooms from '../../../core/hub/usecases/rooms.js';
4
+ import { fail, short } from '../../../lib/index.js';
5
+ import { flag, opt, out } from '../args.js';
6
+ export const listRoom = (H, arg, o) => {
7
+ const rs = roomsActive(H, { archived: flag(o, 'archived') });
8
+ for (const r of rs.filter(r => !r.archived))
9
+ out(`${r.current ? '*' : ' '} ${r.name.padEnd(16)} ${r.members} member(s), ${r.active} active session(s), profile ${r.profile} genesis ${short(r.genesis)}`);
10
+ for (const r of rs.filter(r => r.archived))
11
+ out(` ${r.name.padEnd(16)} archived, read-only`);
12
+ if (!rs.length && !flag(o, 'archived'))
13
+ out(`no rooms in hub ${H.name}: ringi room create <id>`);
14
+ return;
15
+ };
16
+ export const createRoom = (H, arg, o) => {
17
+ const quorum = opt(o, 'quorum');
18
+ const r = Rooms.create(H, arg ?? '', { profile: opt(o, 'profile'), quorum: quorum === undefined ? undefined : Number(quorum) });
19
+ if (quorum !== undefined)
20
+ return out(`created room ${arg} in hub ${H.name} with profile ${r.profile}; it is the current room. Its work starts by itself at a quorum of ${quorum} agent(s): in each chat that should take part, say "join ${arg} as <id>"`);
21
+ return out(`created room ${arg} in hub ${H.name} with profile ${r.profile}; it is the current room. In each chat that should take part, say: "join ${arg} as <id>; <what to accept>"`);
22
+ };
23
+ export const switchRoom = (H, arg, o) => {
24
+ const R = Rooms.use(H, arg ?? fail('usage: ringi room switch <id>'));
25
+ return out(`current room: ${H.name}/${R.name}; agents keep their own rooms`);
26
+ };
27
+ //# sourceMappingURL=room-list.js.map
@@ -0,0 +1,15 @@
1
+ // room-members: `ringi room admit | remove`.
2
+ import * as Rooms from '../../../core/hub/usecases/rooms.js';
3
+ import { fail } from '../../../lib/index.js';
4
+ import { opt, out } from '../args.js';
5
+ export const admitRoom = (H, arg, o) => {
6
+ const R = Rooms.roomIn(H, opt(o, 'room'));
7
+ Rooms.admit(H, R, arg ?? fail('usage: ringi room admit <agent> <public key|file>'), o._[2] ?? fail('usage: ringi room admit <agent> <public key|file>'));
8
+ return out(`admitted ${arg} to ${H.name}/${R.name}: its signed messages are accepted from now on; it can join`);
9
+ };
10
+ export const removeRoom = (H, arg, o) => {
11
+ const R = Rooms.roomIn(H, opt(o, 'room'));
12
+ Rooms.remove(H, R, arg ?? fail('usage: ringi room remove <agent>'));
13
+ return out(`removed ${arg} from ${R.name}: it can no longer write or be woken there; returning needs a fresh join`);
14
+ };
15
+ //# sourceMappingURL=room-members.js.map
@@ -0,0 +1,15 @@
1
+ // room: `ringi room <subcommand>`, by its table (room-list, room-members, room-lifecycle).
2
+ import * as Hubs from '../../../core/hub/usecases/hubs.js';
3
+ import { fail } from '../../../lib/index.js';
4
+ import { opt } from '../args.js';
5
+ import { archiveRoom, deleteRoom, rebaseRoomContract } from './room-lifecycle.js';
6
+ import { createRoom, listRoom, switchRoom } from './room-list.js';
7
+ import { admitRoom, removeRoom } from './room-members.js';
8
+ const COMMANDS = new Map([['list', listRoom], ['create', createRoom], ['switch', switchRoom], ['admit', admitRoom], ['remove', removeRoom], ['archive', archiveRoom], ['delete', deleteRoom], ['rebase-contract', rebaseRoomContract]]);
9
+ export const roomCmd = (o) => {
10
+ const [sub, arg] = o._;
11
+ const H = Hubs.hubOf(opt(o, 'hub'));
12
+ const run = COMMANDS.get(sub || 'list') ?? fail(`unknown: room ${sub}`);
13
+ run(H, arg, o);
14
+ };
15
+ //# sourceMappingURL=room.js.map
@@ -0,0 +1,32 @@
1
+ // sessions: `ringi sessions` (the seats this machine holds; `forget <handle>` frees one) and `ringi forget <room>/<log>`
2
+ // (a new baseline for a log after an alarm).
3
+ import * as Hubs from '../../../core/hub/usecases/hubs.js';
4
+ import * as Overview from '../../../core/agents/overview.js';
5
+ import * as Rooms from '../../../core/hub/usecases/rooms.js';
6
+ import { fail } from '../../../lib/index.js';
7
+ import { dump, flag, opt, out } from '../args.js';
8
+ // --- where things stand, sessions, forget ---
9
+ export const sessionLine = (s) => `${s.agent.padEnd(12)} ${s.liveness.padEnd(8)} ${(s.product ?? '?').padEnd(7)} ${s.handle}${s.scope ? ` scope: ${s.scope}` : ''}`;
10
+ export const sessions = (o) => {
11
+ if (o._[0] === 'forget') {
12
+ const handle = o._[1] ?? fail('usage: ringi sessions forget <handle>');
13
+ Overview.forgetSession(handle);
14
+ return out(`forgot session ${handle}; its seat is free`);
15
+ }
16
+ const ss = Overview.sessions();
17
+ if (flag(o, 'json'))
18
+ return dump(ss);
19
+ if (!ss.length)
20
+ return out('no sessions');
21
+ for (const s of ss)
22
+ out(`${s.hub}/${s.room} ${sessionLine(s)}`);
23
+ };
24
+ export const forget = (o) => {
25
+ const [name, id] = (o._[0] ?? '').split('/');
26
+ if (!name || !id)
27
+ fail('usage: ringi forget <room>/<log>');
28
+ const H = Hubs.hubOf(opt(o, 'hub'));
29
+ const n = Rooms.forgetLog(H, Rooms.roomIn(H, name), id);
30
+ out(`forgot the accepted history of ${name}/${id} for ${n} reader(s); the next read accepts what is there now`);
31
+ };
32
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1,15 @@
1
+ // watch: the headless watcher the operator starts for an agent's seat (`ringi watch <room>/<agent> --exec …`).
2
+ import { watch } from '../../../core/agents/sessions/agent.js';
3
+ import { fail, words } from '../../../lib/index.js';
4
+ import { flag, opt, out } from '../args.js';
5
+ const numberOption = (o, k) => opt(o, k) === undefined ? undefined : Number(opt(o, k));
6
+ export const watchCommand = async (o) => {
7
+ process.exitCode = await watch({
8
+ seat: o._[0] ?? fail('usage: ringi watch <room>/<agent> --exec <cmd> [--scope <text>] [--once] [--require-grant] …'),
9
+ exec: opt(o, 'exec') ?? fail('--exec <cmd> is required: the command that starts a headless turn'),
10
+ hub: opt(o, 'hub'), scope: opt(o, 'scope'), once: flag(o, 'once'), requireGrant: flag(o, 'require-grant'), handoff: flag(o, 'handoff'),
11
+ interval: numberOption(o, 'interval'), from: opt(o, 'from') ? words(opt(o, 'from')) : undefined, maxHop: numberOption(o, 'max-hop'),
12
+ maxRuns: numberOption(o, 'max-runs'), window: numberOption(o, 'window')
13
+ }, out);
14
+ };
15
+ //# sourceMappingURL=watch.js.map
@@ -0,0 +1,24 @@
1
+ // where-format: how `ringi where` shows the hub, the room, who is in, open work and the latest messages.
2
+ import { withSizes } from '../../../core/hub/usecases/room.js';
3
+ import { oneLine, render } from '../../../core/hub/usecases/view.js';
4
+ import { short } from '../../../lib/index.js';
5
+ import { flag, out } from '../args.js';
6
+ import { taskLine } from '../shared/index.js';
7
+ import { sessionLine } from './sessions.js';
8
+ export const hubLine = (H) => `hub ${H.name}: ${H.d.store.type} store, ${H.contract.trust} senders, contract ${H.contract.version}, protocol ${H.contract.protocol}${H.contract.capabilities?.length ? `, ${H.contract.capabilities.join(' ')}` : ''}`;
9
+ const quorumLine = (R) => {
10
+ if (R.quorum === null)
11
+ return '';
12
+ const agents = Object.values(R.members).filter(m => m.role !== 'root').length;
13
+ return agents >= R.quorum ? `; started at its quorum of ${R.quorum} agents` : `; waiting for a quorum of ${R.quorum} agents, has ${agents}`;
14
+ };
15
+ const roomLine = (R) => `room ${R.name}${R.archived ? ' (archived, read-only)' : ''}, genesis ${short(R.genesis)}, profile ${R.profile.name}; members: ${Object.entries(R.members).map(([id, i]) => i.role === 'root' ? `${id} (root)` : id).join(', ')}` + quorumLine(R);
16
+ export const printOverview = (w, R) => {
17
+ out(roomLine(R));
18
+ out(w.sessions.length ? `sessions:\n${w.sessions.map(s => ` ${sessionLine(s)}`).join('\n')}` : 'sessions: none joined');
19
+ out(w.work.length ? `open work:\n${w.work.map(t => ` ${taskLine(t)}`).join('\n')}` : 'open work: none');
20
+ if (w.proposals.length)
21
+ out(`open proposals:\n${w.proposals.map(x => ` ${short(x.proposal.id)} ${x.state} → ${x.decider} ${x.proposal.subject}`).join('\n')}`);
22
+ };
23
+ export const showMessage = (R, o, all, m) => out(flag(o, 'short') ? ` ${oneLine(m)}` : `\n${render(all, m, { max: 2000, files: () => withSizes(R, m) })}`);
24
+ //# sourceMappingURL=where-format.js.map
@@ -0,0 +1,32 @@
1
+ // where: `ringi where`, where things stand for the operator, and `--follow` for what lands next.
2
+ import { config } from '../../../core/hub/usecases/context.js';
3
+ import * as Hubs from '../../../core/hub/usecases/hubs.js';
4
+ import * as Overview from '../../../core/agents/overview.js';
5
+ import { sleep } from '../../../lib/index.js';
6
+ import { flag, opt, out } from '../args.js';
7
+ import { hubLine, printOverview, showMessage } from './where-format.js';
8
+ const follow = async (H, R, o, seen) => {
9
+ out('following; new messages appear as they land (Ctrl-C to stop)');
10
+ for (;;) {
11
+ await sleep(Number(opt(o, 'interval') ?? 2) * 1000);
12
+ const now = Overview.arrived(H, R, seen);
13
+ for (const m of now.messages)
14
+ showMessage(R, o, now.all, m);
15
+ }
16
+ };
17
+ export const where = async (o) => {
18
+ const H = Hubs.hubOf(opt(o, 'hub'));
19
+ const w = Overview.where(H, opt(o, 'room') ?? config().room);
20
+ out(hubLine(H));
21
+ const R = w.room;
22
+ if (!R)
23
+ return out('no current room: ringi room create <id> | ringi room switch <id>');
24
+ printOverview(w, R);
25
+ const n = Number(opt(o, 'n') ?? (flag(o, 'short') ? 10 : 5));
26
+ out(`last ${Math.min(n, w.messages.length)} of ${w.messages.length} messages:`);
27
+ for (const m of w.messages.slice(-n))
28
+ showMessage(R, o, w.all, m);
29
+ if (flag(o, 'follow'))
30
+ await follow(H, R, o, new Set(w.all.keys()));
31
+ };
32
+ //# sourceMappingURL=where.js.map