rvlib-shipkit 2.29.0 → 2.30.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 (512) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/package.json +2 -1
  3. package/src/advisors/app-graph.ts +1 -1
  4. package/src/advisors/expose.ts +5 -1
  5. package/src/advisors/r2.ts +7 -9
  6. package/src/advisors/routes.ts +29 -2
  7. package/src/advisors/scan.ts +11 -0
  8. package/src/agent-time/accounts-usage.ts +8 -0
  9. package/src/agent-time/claude-sessions.ts +32 -0
  10. package/src/agent-time/hooks.ts +1 -1
  11. package/src/agent-time/live.ts +5 -2
  12. package/src/agent-time/registry.ts +186 -89
  13. package/src/agent-time/store.ts +6 -4
  14. package/src/asks/ask-doc.ts +2 -2
  15. package/src/asks/ask-store.ts +22 -7
  16. package/src/check.ts +9 -1
  17. package/src/checks/SK001-package-json-shape.check.ts +1 -0
  18. package/src/checks/SK003-claude-md-shape.check.ts +1 -0
  19. package/src/checks/SK004-gitignore-policy.check.ts +12 -6
  20. package/src/checks/SK008-reviewer-agent.check.ts +4 -7
  21. package/src/checks/SK013-one-way-in-policy.check.ts +1 -0
  22. package/src/checks/SK017-vscode-hub-task.check.ts +1 -0
  23. package/src/checks/SK024-identity-colors.check.ts +1 -1
  24. package/src/checks/SK027-agent-wiki-links.check.ts +2 -1
  25. package/src/checks/SK033-global-contribution.check.ts +1 -0
  26. package/src/checks/SK034-commit-gates-armed.check.ts +1 -0
  27. package/src/checks/SK039-vscode-watch-generated.check.ts +1 -0
  28. package/src/checks/SK049-thread-answers-hook.check.ts +9 -5
  29. package/src/checks/SK050-retired-commands.check.ts +1 -0
  30. package/src/checks/SK051-no-formatter.check.ts +1 -0
  31. package/src/cli/channel-run.ts +17 -0
  32. package/src/cli/cmd_Advisors.ts +28 -7
  33. package/src/cli/cmd_Asks.ts +2 -2
  34. package/src/cli/cmd_Backup.ts +5 -1
  35. package/src/cli/cmd_CacheAudit.ts +1 -1
  36. package/src/cli/cmd_Channel.ts +43 -0
  37. package/src/cli/cmd_GlobalProcesses.ts +1 -0
  38. package/src/cli/cmd_Home.ts +12 -5
  39. package/src/cli/cmd_Hooks.ts +1 -1
  40. package/src/cli/cmd_Hq.ts +43 -0
  41. package/src/cli/cmd_Lanes.ts +15 -3
  42. package/src/cli/cmd_Media.ts +8 -3
  43. package/src/cli/cmd_Orchestrator.ts +253 -84
  44. package/src/cli/cmd_OrchestratorRole.ts +163 -0
  45. package/src/cli/cmd_Review.ts +142 -165
  46. package/src/cli/cmd_Secret.ts +44 -14
  47. package/src/cli/cmd_Shot.ts +2 -4
  48. package/src/cli/cmd_Sound.ts +1 -0
  49. package/src/cli/cmd_Urls.ts +3 -3
  50. package/src/cli/inbox-hook-run.ts +109 -0
  51. package/src/cli/registry.ts +6 -2
  52. package/src/cli/review-here.ts +136 -0
  53. package/src/cli.ts +45 -14
  54. package/src/collections/actions.ts +5 -4
  55. package/src/collections/checks.ts +5 -0
  56. package/src/collections/collection-types.ts +4 -3
  57. package/src/collections/pings.ts +4 -1
  58. package/src/collections/providers.ts +6 -4
  59. package/src/collections/tests.ts +7 -4
  60. package/src/core/app-icon-frame.ts +62 -0
  61. package/src/core/app-icon.ts +179 -17
  62. package/src/core/archived.ts +10 -7
  63. package/src/core/check-ctx.ts +38 -4
  64. package/src/core/check-pass.ts +7 -0
  65. package/src/core/foreign.ts +87 -0
  66. package/src/core/gui-color.ts +75 -0
  67. package/src/core/hub-theme.ts +1 -3
  68. package/src/core/layout.ts +3 -0
  69. package/src/core/machine-commit.ts +9 -1
  70. package/src/core/one-lib.ts +2 -1
  71. package/src/core/one-way-in-policy.ts +17 -12
  72. package/src/core/owner-word-policy.ts +123 -0
  73. package/src/core/panel-shades.ts +140 -0
  74. package/src/core/repo-gui-color.ts +16 -0
  75. package/src/core/role-policy.ts +17 -0
  76. package/src/core/scope.ts +6 -3
  77. package/src/core/tmux-policy.ts +264 -0
  78. package/src/core/unit-icon.ts +43 -0
  79. package/src/fleet/push-fleet.ts +2 -0
  80. package/src/fleet/scan-fleet.ts +3 -0
  81. package/src/gate/cache-audit.ts +7 -1
  82. package/src/gate/gate-checks.ts +14 -9
  83. package/src/gate/run-fix.ts +30 -5
  84. package/src/gate/run-fixers.ts +8 -3
  85. package/src/home/activity-shape.ts +2 -0
  86. package/src/home/activity.ts +2 -1
  87. package/src/home/daemon-guard.ts +20 -2
  88. package/src/home/daemon-jobs.ts +26 -18
  89. package/src/home/gui-app/ShipkitGui.swift +2012 -144
  90. package/src/home/gui-app/icon.svg +8 -0
  91. package/src/home/gui-app.ts +94 -30
  92. package/src/home/home-routes.ts +53 -9
  93. package/src/home/home-start.ts +27 -3
  94. package/src/home/inbox-shape.ts +7 -3
  95. package/src/home/log-follow.ts +117 -0
  96. package/src/home/machine-fold.ts +1 -1
  97. package/src/home/open-app.ts +9 -3
  98. package/src/home/page-build.ts +5 -1
  99. package/src/home/page-held.ts +1 -1
  100. package/src/home/pm-config.ts +0 -8
  101. package/src/home/pm.ts +62 -5
  102. package/src/home/process-apps.ts +70 -23
  103. package/src/home/process-rows.ts +16 -1
  104. package/src/home/push-sources.ts +18 -13
  105. package/src/home/resources.ts +16 -7
  106. package/src/home/run-daemon.ts +4 -1
  107. package/src/home/run-pm.ts +1 -1
  108. package/src/home/serve-daemon.ts +13 -4
  109. package/src/home/serve-web.ts +141 -17
  110. package/src/home/space-page.ts +3 -3
  111. package/src/home/space-route.ts +2 -2
  112. package/src/home/supervise.ts +2 -1
  113. package/src/home/vault-page.ts +2 -1
  114. package/src/home/web-places.ts +239 -0
  115. package/src/home/widgets.ts +16 -2
  116. package/src/hooks/commit-message.ts +11 -9
  117. package/src/hooks/one-way-in-guard.ts +145 -68
  118. package/src/hooks/run-hooks.ts +15 -5
  119. package/src/hooks/shared-file.ts +273 -83
  120. package/src/hooks/shell-writes.ts +620 -0
  121. package/src/hooks/write-log.ts +149 -0
  122. package/src/hq/door-route.ts +63 -7
  123. package/src/hq/door.ts +45 -12
  124. package/src/hq/history-send.ts +3 -1
  125. package/src/hq/hq-db.ts +10 -3
  126. package/src/hq/hq-local.ts +24 -5
  127. package/src/hq/hq-routes.ts +3 -1
  128. package/src/hq/hq-store.ts +9 -3
  129. package/src/hq/kinds/index.ts +2 -1
  130. package/src/hq/kinds/kind.ts +9 -4
  131. package/src/hq/kinds/presence-rule.ts +56 -0
  132. package/src/hq/kinds/presence.ts +210 -0
  133. package/src/hq/kinds/report.ts +8 -5
  134. package/src/hq/lead-order.ts +68 -0
  135. package/src/hq/outbox.ts +7 -0
  136. package/src/hq/replica.ts +5 -7
  137. package/src/hq/report-facts.ts +14 -7
  138. package/src/hq/report.ts +47 -2
  139. package/src/hq/switch.ts +1 -0
  140. package/src/hq/terminal-hop.ts +64 -0
  141. package/src/hq/thread-sync.ts +13 -6
  142. package/src/http/door-forward.ts +10 -12
  143. package/src/http/door-names.ts +9 -0
  144. package/src/http/hop-caller.ts +23 -0
  145. package/src/http/hop-names.ts +14 -0
  146. package/src/http/loopback-serve.ts +28 -6
  147. package/src/http/owner-word.ts +128 -0
  148. package/src/http/same-origin.ts +12 -0
  149. package/src/{serve → http}/secret-gate.ts +3 -3
  150. package/src/ledger/run-log.ts +25 -1
  151. package/src/media-store/backup/sources.ts +53 -6
  152. package/src/media-store/backup/thread-copy.ts +9 -5
  153. package/src/media-store/copy/config.ts +10 -9
  154. package/src/media-store/daemon.ts +5 -2
  155. package/src/media-store/put.ts +3 -0
  156. package/src/media-store/space.ts +14 -16
  157. package/src/media-store/upload.ts +4 -0
  158. package/src/messages/collection.ts +2 -2
  159. package/src/messages/model.ts +6 -1
  160. package/src/messages/routes.ts +3 -0
  161. package/src/orchestrator/brief.md +8 -6
  162. package/src/orchestrator/channel-declare.ts +58 -0
  163. package/src/orchestrator/channel.ts +226 -0
  164. package/src/orchestrator/guards.ts +12 -3
  165. package/src/orchestrator/host.ts +35 -0
  166. package/src/orchestrator/lead-shape.ts +86 -0
  167. package/src/orchestrator/now.ts +88 -0
  168. package/src/orchestrator/phone.ts +4 -1
  169. package/src/orchestrator/places-file.ts +38 -0
  170. package/src/orchestrator/places-look.ts +180 -0
  171. package/src/orchestrator/places-shape.ts +151 -0
  172. package/src/orchestrator/places.ts +50 -0
  173. package/src/orchestrator/presence-shape.ts +13 -2
  174. package/src/orchestrator/presence.ts +26 -15
  175. package/src/orchestrator/push.ts +5 -10
  176. package/src/orchestrator/role-shape.ts +270 -0
  177. package/src/orchestrator/role.ts +242 -0
  178. package/src/orchestrator/routes.ts +136 -31
  179. package/src/orchestrator/sessions-shape.ts +78 -0
  180. package/src/orchestrator/sessions.ts +86 -0
  181. package/src/orchestrator/share.ts +71 -0
  182. package/src/orchestrator/start-notice.ts +61 -0
  183. package/src/orchestrator/start.ts +137 -0
  184. package/src/orchestrator/started.ts +55 -0
  185. package/src/orchestrator/stuck.ts +196 -0
  186. package/src/orchestrator/unheard.ts +18 -7
  187. package/src/pages/frame-client.ts +44 -6
  188. package/src/problems/failure-words.ts +80 -0
  189. package/src/release/run-bump.ts +26 -5
  190. package/src/release/run-release.ts +34 -14
  191. package/src/repo-config.ts +37 -9
  192. package/src/review/aside-at.ts +19 -0
  193. package/src/review/band.ts +3 -3
  194. package/src/review/doc-save.ts +1 -1
  195. package/src/review/inbox-hook.ts +12 -4
  196. package/src/review/inbox-read.ts +20 -7
  197. package/src/review/instruction-guards.ts +137 -0
  198. package/src/review/instructions.ts +14 -2
  199. package/src/review/item-db.ts +52 -2
  200. package/src/review/mentions.ts +6 -4
  201. package/src/review/model.ts +3 -2
  202. package/src/review/parties.ts +88 -19
  203. package/src/review/push.ts +32 -15
  204. package/src/review/routes.ts +12 -4
  205. package/src/review/secret-route.ts +5 -5
  206. package/src/review/snooze.ts +1 -16
  207. package/src/review/store-parties.ts +4 -2
  208. package/src/review/take-back.ts +2 -1
  209. package/src/review/threads.ts +13 -2
  210. package/src/review/unit.ts +3 -2
  211. package/src/review/view-layout.ts +8 -1
  212. package/src/review/watchers.ts +25 -4
  213. package/src/secrets/key-pair.ts +14 -0
  214. package/src/secrets/lapse.ts +3 -3
  215. package/src/secrets/manager.ts +5 -1
  216. package/src/secrets/name-template.ts +83 -0
  217. package/src/secrets/name.ts +3 -0
  218. package/src/secrets/read.ts +10 -6
  219. package/src/secrets/secrets-view.ts +299 -0
  220. package/src/secrets/who-reads.ts +2 -1
  221. package/src/serve/frame-part.ts +49 -0
  222. package/src/serve/hub-app/accounts-line.tsx +33 -45
  223. package/src/serve/hub-app/activity-st.ts +6 -5
  224. package/src/serve/hub-app/activity-view.tsx +10 -9
  225. package/src/serve/hub-app/advice-box.tsx +6 -5
  226. package/src/serve/hub-app/advisor-app.tsx +2 -0
  227. package/src/serve/hub-app/advisor-face.tsx +3 -2
  228. package/src/serve/hub-app/advisor.html +1 -0
  229. package/src/serve/hub-app/advisors-view.tsx +52 -10
  230. package/src/serve/hub-app/advisors.css +4 -0
  231. package/src/serve/hub-app/app-bridge.ts +31 -5
  232. package/src/serve/hub-app/asked-page.ts +24 -0
  233. package/src/serve/hub-app/asks-page.tsx +10 -6
  234. package/src/serve/hub-app/auto-text.tsx +7 -5
  235. package/src/serve/hub-app/card-head.tsx +3 -2
  236. package/src/serve/hub-app/check-view.tsx +10 -9
  237. package/src/serve/hub-app/checks-svc.ts +96 -32
  238. package/src/serve/hub-app/clock-svc.ts +24 -8
  239. package/src/serve/hub-app/code-copy.ts +1 -1
  240. package/src/serve/hub-app/col-card.tsx +2 -1
  241. package/src/serve/hub-app/col-list-page.tsx +12 -6
  242. package/src/serve/hub-app/col-list-st.ts +12 -2
  243. package/src/serve/hub-app/col-tables-view.tsx +8 -44
  244. package/src/serve/hub-app/col-tables.ts +0 -14
  245. package/src/serve/hub-app/cols-svc.ts +6 -12
  246. package/src/serve/hub-app/columns.ts +94 -0
  247. package/src/serve/hub-app/comfy-view.tsx +8 -7
  248. package/src/serve/hub-app/commands/commands-page.tsx +4 -3
  249. package/src/serve/hub-app/commands/commands-st.ts +2 -2
  250. package/src/serve/hub-app/controls.css +69 -23
  251. package/src/serve/hub-app/cycle-button.tsx +2 -1
  252. package/src/serve/hub-app/database-st.ts +1 -1
  253. package/src/serve/hub-app/database-view.tsx +4 -2
  254. package/src/serve/hub-app/deaf.tsx +27 -0
  255. package/src/serve/hub-app/dock-st.ts +21 -16
  256. package/src/serve/hub-app/dock-view.tsx +19 -12
  257. package/src/serve/hub-app/empty-section.tsx +30 -0
  258. package/src/serve/hub-app/entry-bar.css +1 -1
  259. package/src/serve/hub-app/entry-bar.tsx +11 -6
  260. package/src/serve/hub-app/entry-list.css +32 -0
  261. package/src/serve/hub-app/entry-list.tsx +123 -0
  262. package/src/serve/hub-app/entry-pick.ts +1 -1
  263. package/src/serve/hub-app/entry-sections.ts +140 -0
  264. package/src/serve/hub-app/event-stream-reader.ts +56 -0
  265. package/src/serve/hub-app/floating.tsx +68 -14
  266. package/src/serve/hub-app/geometry-view.tsx +3 -2
  267. package/src/serve/hub-app/git-view.tsx +3 -2
  268. package/src/serve/hub-app/hash-route.ts +14 -2
  269. package/src/serve/hub-app/header-bar.tsx +53 -36
  270. package/src/serve/hub-app/home-st.ts +131 -14
  271. package/src/serve/hub-app/home-strip.css +24 -13
  272. package/src/serve/hub-app/home-strip.tsx +131 -66
  273. package/src/serve/hub-app/home.html +5 -0
  274. package/src/serve/hub-app/hub-app.tsx +94 -102
  275. package/src/serve/hub-app/hub.css +61 -94
  276. package/src/serve/hub-app/icons.tsx +16 -0
  277. package/src/serve/hub-app/identities-st.ts +19 -54
  278. package/src/serve/hub-app/identities-view.tsx +25 -24
  279. package/src/serve/hub-app/identity-address.ts +2 -2
  280. package/src/serve/hub-app/in-sight.ts +10 -0
  281. package/src/serve/hub-app/inbox-st.ts +20 -2
  282. package/src/serve/hub-app/inbox-view.tsx +16 -9
  283. package/src/serve/hub-app/inbox.css +1 -0
  284. package/src/serve/hub-app/index.html +5 -0
  285. package/src/serve/hub-app/insights-view.tsx +6 -5
  286. package/src/serve/hub-app/instructions.css +4 -1
  287. package/src/serve/hub-app/kept-cols.tsx +83 -20
  288. package/src/serve/hub-app/kept-width.tsx +76 -0
  289. package/src/serve/hub-app/keys.ts +116 -38
  290. package/src/serve/hub-app/layout-st.ts +109 -99
  291. package/src/serve/hub-app/lightbox-zoom.css +36 -0
  292. package/src/serve/hub-app/list-filter.tsx +15 -6
  293. package/src/serve/hub-app/list-head.tsx +29 -0
  294. package/src/serve/hub-app/list-row.ts +8 -0
  295. package/src/serve/hub-app/list-walk.ts +26 -105
  296. package/src/serve/hub-app/live-socket.ts +274 -0
  297. package/src/serve/hub-app/live-sources.ts +189 -0
  298. package/src/serve/hub-app/live-svc.ts +2 -2
  299. package/src/serve/hub-app/machine-st.ts +75 -14
  300. package/src/serve/hub-app/main-panel.css +211 -0
  301. package/src/serve/hub-app/main-panel.tsx +259 -0
  302. package/src/serve/hub-app/md.ts +4 -4
  303. package/src/serve/hub-app/media-svc.ts +5 -5
  304. package/src/serve/hub-app/media-view.tsx +13 -12
  305. package/src/serve/hub-app/messages/messages-page.tsx +8 -7
  306. package/src/serve/hub-app/messages/messages-st.ts +5 -2
  307. package/src/serve/hub-app/new-thread-st.ts +170 -0
  308. package/src/serve/hub-app/new-thread.tsx +133 -107
  309. package/src/serve/hub-app/orchestrator-line.tsx +115 -45
  310. package/src/serve/hub-app/orchestrator-places.tsx +86 -0
  311. package/src/serve/hub-app/orchestrator.css +57 -5
  312. package/src/serve/hub-app/page-keys.ts +107 -68
  313. package/src/serve/hub-app/page-reload.ts +46 -6
  314. package/src/serve/hub-app/pages-frames.tsx +40 -3
  315. package/src/serve/hub-app/pages-svc.ts +3 -1
  316. package/src/serve/hub-app/palette-st.ts +198 -43
  317. package/src/serve/hub-app/palette-view.tsx +32 -8
  318. package/src/serve/hub-app/panel-head-action.tsx +39 -0
  319. package/src/serve/hub-app/panel-head.tsx +70 -0
  320. package/src/serve/hub-app/panel-repo.ts +42 -0
  321. package/src/serve/hub-app/panel-source.ts +195 -0
  322. package/src/serve/hub-app/panel-tint.css +6 -0
  323. package/src/serve/hub-app/panel-tint.ts +23 -0
  324. package/src/serve/hub-app/panel-walk.ts +107 -0
  325. package/src/serve/hub-app/pill-row.tsx +2 -1
  326. package/src/serve/hub-app/place-path.ts +4 -0
  327. package/src/serve/hub-app/places-svc.ts +75 -0
  328. package/src/serve/hub-app/plan-view.tsx +3 -2
  329. package/src/serve/hub-app/polled.ts +11 -1
  330. package/src/serve/hub-app/presence-st.ts +66 -32
  331. package/src/serve/hub-app/processes-view.tsx +2 -2
  332. package/src/serve/hub-app/project-bar.tsx +116 -0
  333. package/src/serve/hub-app/project-list.css +20 -173
  334. package/src/serve/hub-app/project-list.tsx +30 -298
  335. package/src/serve/hub-app/projects-svc.ts +59 -32
  336. package/src/serve/hub-app/push-sign.tsx +2 -1
  337. package/src/serve/hub-app/push-svc.ts +86 -69
  338. package/src/serve/hub-app/quiet-st.ts +5 -3
  339. package/src/serve/hub-app/rail-groups.ts +144 -0
  340. package/src/serve/hub-app/reader-chips.tsx +2 -1
  341. package/src/serve/hub-app/recordings-st.ts +2 -1
  342. package/src/serve/hub-app/recordings-view.tsx +19 -47
  343. package/src/serve/hub-app/recordings.css +0 -2
  344. package/src/serve/hub-app/reflections-page.tsx +10 -6
  345. package/src/serve/hub-app/releases/releases-page.tsx +6 -5
  346. package/src/serve/hub-app/repo-sections.ts +127 -38
  347. package/src/serve/hub-app/repo-st.ts +57 -36
  348. package/src/serve/hub-app/review/advisor-bar.tsx +3 -2
  349. package/src/serve/hub-app/review/ask-proof.tsx +79 -0
  350. package/src/serve/hub-app/review/attach-view.tsx +11 -10
  351. package/src/serve/hub-app/review/box-view.ts +479 -0
  352. package/src/serve/hub-app/review/box-zoom.tsx +70 -0
  353. package/src/serve/hub-app/review/diff-view.tsx +3 -2
  354. package/src/serve/hub-app/review/doc-body.tsx +2 -1
  355. package/src/serve/hub-app/review/dock.tsx +3 -2
  356. package/src/serve/hub-app/review/draft-body.tsx +4 -3
  357. package/src/serve/hub-app/review/faces.tsx +0 -8
  358. package/src/serve/hub-app/review/group-block.tsx +8 -7
  359. package/src/serve/hub-app/review/heard-line.tsx +4 -3
  360. package/src/serve/hub-app/review/instructions-view.tsx +3 -2
  361. package/src/serve/hub-app/review/item-verdict.tsx +40 -40
  362. package/src/serve/hub-app/review/kind-states.tsx +5 -4
  363. package/src/serve/hub-app/review/kit.tsx +24 -4
  364. package/src/serve/hub-app/review/lane-bar.tsx +30 -28
  365. package/src/serve/hub-app/review/lightbox.tsx +6 -4
  366. package/src/serve/hub-app/review/live-bar.tsx +7 -6
  367. package/src/serve/hub-app/review/live-view.tsx +6 -5
  368. package/src/serve/hub-app/review/object-card.tsx +2 -1
  369. package/src/serve/hub-app/review/object-panel.tsx +11 -10
  370. package/src/serve/hub-app/review/pano-view.tsx +3 -2
  371. package/src/serve/hub-app/review/question-views.tsx +6 -5
  372. package/src/serve/hub-app/review/review-cells.tsx +21 -20
  373. package/src/serve/hub-app/review/review-host.ts +3 -0
  374. package/src/serve/hub-app/review/review-kit.ts +7 -5
  375. package/src/serve/hub-app/review/review-list.tsx +98 -52
  376. package/src/serve/hub-app/review/review-page.tsx +3 -3
  377. package/src/serve/hub-app/review/review-st.ts +70 -14
  378. package/src/serve/hub-app/review/review-thread.tsx +234 -138
  379. package/src/serve/hub-app/review/review-views.tsx +166 -191
  380. package/src/serve/hub-app/review/space3d.tsx +17 -9
  381. package/src/serve/hub-app/review/thread-close.tsx +24 -32
  382. package/src/serve/hub-app/review/thread-st.ts +39 -25
  383. package/src/serve/hub-app/review/trailer-body.tsx +5 -4
  384. package/src/serve/hub-app/review/trailer-page.tsx +18 -16
  385. package/src/serve/hub-app/review/trailer-st.ts +3 -2
  386. package/src/serve/hub-app/review/trailer-timeline.tsx +10 -9
  387. package/src/serve/hub-app/review/trailer-voices.tsx +29 -28
  388. package/src/serve/hub-app/review.css +159 -42
  389. package/src/serve/hub-app/row-acts.tsx +126 -0
  390. package/src/serve/hub-app/row-face.tsx +29 -0
  391. package/src/serve/hub-app/running-rows.tsx +142 -0
  392. package/src/serve/hub-app/running-st.ts +110 -0
  393. package/src/serve/hub-app/search-view.tsx +3 -2
  394. package/src/serve/hub-app/secrets-page.tsx +290 -0
  395. package/src/serve/hub-app/secrets-st.ts +181 -0
  396. package/src/serve/hub-app/secrets.css +65 -0
  397. package/src/serve/hub-app/section-head.tsx +3 -2
  398. package/src/serve/hub-app/session-chips.tsx +55 -0
  399. package/src/serve/hub-app/shell.ts +56 -0
  400. package/src/serve/hub-app/site/site-part.tsx +6 -5
  401. package/src/serve/hub-app/site/site-st.ts +0 -6
  402. package/src/serve/hub-app/site.css +0 -1
  403. package/src/serve/hub-app/social/calendar.tsx +7 -6
  404. package/src/serve/hub-app/social/comms-page.tsx +29 -26
  405. package/src/serve/hub-app/social/group-editor.tsx +2 -1
  406. package/src/serve/hub-app/social/kit.tsx +12 -11
  407. package/src/serve/hub-app/social/next-release.tsx +3 -2
  408. package/src/serve/hub-app/social/post-card.tsx +21 -20
  409. package/src/serve/hub-app/social/post-page.tsx +2 -1
  410. package/src/serve/hub-app/social/problems.tsx +3 -2
  411. package/src/serve/hub-app/social/social-page.tsx +29 -27
  412. package/src/serve/hub-app/social/social-st.ts +4 -2
  413. package/src/serve/hub-app/social/stage-popup.tsx +11 -10
  414. package/src/serve/hub-app/social.css +7 -5
  415. package/src/serve/hub-app/source-acts.ts +79 -0
  416. package/src/serve/hub-app/source-page.tsx +17 -0
  417. package/src/serve/hub-app/space-view.tsx +5 -4
  418. package/src/serve/hub-app/stores/stores-page.tsx +21 -19
  419. package/src/serve/hub-app/stores/stores-st.ts +1 -1
  420. package/src/serve/hub-app/stores.css +1 -1
  421. package/src/serve/hub-app/terminal-history-st.ts +112 -0
  422. package/src/serve/hub-app/terminal-keys.ts +79 -0
  423. package/src/serve/hub-app/terminal-lib.ts +110 -0
  424. package/src/serve/hub-app/terminal-links.ts +55 -0
  425. package/src/serve/hub-app/terminal-list-st.ts +304 -0
  426. package/src/serve/hub-app/terminal-log-st.ts +242 -0
  427. package/src/serve/hub-app/terminal-out.ts +135 -0
  428. package/src/serve/hub-app/terminal-pages.tsx +115 -0
  429. package/src/serve/hub-app/terminal-panel.tsx +60 -9
  430. package/src/serve/hub-app/terminal-sources.tsx +335 -0
  431. package/src/serve/hub-app/terminal-st.ts +447 -167
  432. package/src/serve/hub-app/terminal-stream.ts +233 -0
  433. package/src/serve/hub-app/terminal-tab.tsx +64 -0
  434. package/src/serve/hub-app/terminal-widths.ts +30 -0
  435. package/src/serve/hub-app/terminal.css +50 -4
  436. package/src/serve/hub-app/test-view.tsx +5 -3
  437. package/src/serve/hub-app/tests-view.tsx +16 -15
  438. package/src/serve/hub-app/theme-st.ts +5 -0
  439. package/src/serve/hub-app/thread-row.tsx +39 -31
  440. package/src/serve/hub-app/time-ago.tsx +3 -2
  441. package/src/serve/hub-app/time-view.tsx +2 -1
  442. package/src/serve/hub-app/time.css +1 -1
  443. package/src/serve/hub-app/timeline-chart.tsx +5 -4
  444. package/src/serve/hub-app/timeline-view.tsx +10 -9
  445. package/src/serve/hub-app/tips.ts +247 -0
  446. package/src/serve/hub-app/tree-build.ts +40 -8
  447. package/src/serve/hub-app/tree-svc.ts +167 -134
  448. package/src/serve/hub-app/unit-icons.ts +26 -0
  449. package/src/serve/hub-app/url-address.ts +154 -0
  450. package/src/serve/hub-app/url-faces.ts +88 -0
  451. package/src/serve/hub-app/url-forms.tsx +183 -0
  452. package/src/serve/hub-app/urls-svc.ts +167 -5
  453. package/src/serve/hub-app/urls-view.tsx +56 -20
  454. package/src/serve/hub-app/urls.css +26 -0
  455. package/src/serve/hub-app/vault-view.tsx +5 -4
  456. package/src/serve/hub-app/veille/veille-page.tsx +34 -33
  457. package/src/serve/hub-app/veille/veille-st.ts +6 -3
  458. package/src/serve/hub-app/view-layout.css +3 -3
  459. package/src/serve/hub-app/when-view.tsx +5 -4
  460. package/src/serve/hub-app/wikis-view.tsx +6 -5
  461. package/src/serve/hub-app/words.tsx +9 -2
  462. package/src/serve/hub-runtime.ts +3 -2
  463. package/src/serve/orchestrator-host.ts +58 -0
  464. package/src/serve/page-live.ts +147 -0
  465. package/src/serve/project-gutter-route.ts +63 -2
  466. package/src/serve/read-worker.ts +7 -2
  467. package/src/serve/runs-stamp.ts +33 -0
  468. package/src/serve/secrets-read.ts +156 -0
  469. package/src/serve/serve-hub.ts +71 -22
  470. package/src/serve/terminal-claudes.ts +185 -0
  471. package/src/serve/terminal-guard.ts +10 -5
  472. package/src/serve/terminal-host.ts +517 -0
  473. package/src/serve/terminal-record.ts +104 -0
  474. package/src/serve/terminal-route.ts +466 -103
  475. package/src/serve/terminal-shells.ts +3 -0
  476. package/src/serve/terminal-watch.ts +102 -0
  477. package/src/shipkit-files.ts +9 -4
  478. package/src/shot/client.ts +4 -9
  479. package/src/shot/shooter.ts +2 -4
  480. package/src/shot/shot-ask.ts +2 -7
  481. package/src/shot/shot-theme.ts +6 -17
  482. package/src/social/routes.ts +2 -2
  483. package/src/social/writes.ts +3 -0
  484. package/src/suite/test-units.ts +6 -2
  485. package/src/trailer/sound/eleven.ts +1 -0
  486. package/src/urls/added.ts +111 -0
  487. package/src/urls/icons.ts +294 -0
  488. package/src/urls/places.ts +139 -0
  489. package/src/urls/routes.ts +17 -7
  490. package/src/urls/rows.ts +48 -15
  491. package/src/urls/unit.ts +57 -3
  492. package/src/urls/write-routes.ts +207 -0
  493. package/src/vault/vault-destroy.ts +2 -1
  494. package/src/vault/vault-import.ts +4 -11
  495. package/src/vault/vault-restore.ts +3 -2
  496. package/src/veille/chrome.ts +18 -3
  497. package/src/veille/identity.ts +6 -0
  498. package/src/view3d/cam.ts +30 -46
  499. package/src/view3d/lib.ts +20 -2
  500. package/src/view3d/viewer.ts +62 -88
  501. package/src/wiki/agent-paths.ts +2 -1
  502. package/src/orchestrator/deliver.ts +0 -81
  503. package/src/orchestrator/drill.ts +0 -129
  504. package/src/orchestrator/keeper.ts +0 -332
  505. package/src/orchestrator/pm.ts +0 -20
  506. package/src/orchestrator/state.ts +0 -92
  507. package/src/orchestrator/switch.ts +0 -86
  508. package/src/orchestrator/tmux.ts +0 -82
  509. package/src/serve/hub-app/rail-fly.tsx +0 -95
  510. package/src/serve/hub-app/side-lists.ts +0 -72
  511. package/src/serve/hub-app/sidebar.tsx +0 -62
  512. package/src/serve/hub-app/tree-row.tsx +0 -125
@@ -0,0 +1,56 @@
1
+ // the times of presence and the lead rule (wiki tools/shipkit/sessions.md, Places and The lead): pure, no import,
2
+ // so the hq that settles a lead, every place that reads it and the page share one rule. The words and the view are
3
+ // orchestrator/places-shape.ts and orchestrator/lead-shape.ts.
4
+ // The one constraint a reader breaks first: the lead is sticky. It stays while its place holds the role, and passes only
5
+ // after LEAD_GRACE_MS without it; a place that hears again never takes it back. Only a new order moves it at once
6
+
7
+ /** a fact of another place counts while the hq heard its node this recently: five 3 s looks, so one lost look never
8
+ * flips a light */
9
+ export const PRESENCE_FRESH_MS = 15_000
10
+ /** a daemon sends its facts when they change, and again this often: the net under a row the hq lost */
11
+ export const PRESENCE_RESEND_MS = 5 * 60_000
12
+ /** a row not sent again for this long is no fact of now, its node fresh or not (a repo that left that place) */
13
+ export const PRESENCE_OLD_MS = 2 * PRESENCE_RESEND_MS
14
+
15
+ /** a lead whose place stops holding the role keeps the lead this long: the role's own grace (role-shape.ts REARM_MS),
16
+ * so a watch between two bursts, or a place that sleeps a minute, never moves it */
17
+ export const LEAD_GRACE_MS = 2 * 60_000
18
+ /** an order names at most this many places */
19
+ export const LEAD_MAX_PLACES = 16
20
+
21
+ /** one place's role holder of a repo, as the hq reads it from that place's presence while the node is fresh */
22
+ export interface LeadCandidate {
23
+ node: string
24
+ session: string
25
+ /** when the hq first saw this session hold the role there (ms, the hq's clock): never the node's own word */
26
+ claimed: number
27
+ /** an ear of it hears now; without one it still holds the role, in the role's own grace */
28
+ hears: boolean
29
+ }
30
+
31
+ /** what the hq keeps of a repo's lead, on its clock: the node that leads, its holder's session, since when it leads,
32
+ * and since when it holds no role (null while it holds one) */
33
+ export interface LeadState {
34
+ node: string
35
+ session: string
36
+ since: number
37
+ lost: number | null
38
+ }
39
+
40
+ /** the lead now: the owner's order, then the first claim, of the candidates that hear; sticky. `was` is null after a
41
+ * new order, so the owner's pick acts at once */
42
+ export function leadOf(o: { was: LeadState | null; order: readonly string[]; candidates: readonly LeadCandidate[]; now: number }): LeadState | null {
43
+ const was = o.was
44
+ if (was !== null) {
45
+ const still = o.candidates.find((c) => c.node === was.node)
46
+ if (still !== undefined) return still.session === was.session && was.lost === null ? was : { ...was, session: still.session, lost: null }
47
+ const lost = was.lost ?? o.now
48
+ if (o.now - lost < LEAD_GRACE_MS) return { ...was, lost }
49
+ }
50
+ const rank = (n: string): number => {
51
+ const i = o.order.indexOf(n)
52
+ return i < 0 ? o.order.length : i
53
+ }
54
+ const next = o.candidates.filter((c) => c.hears).sort((a, b) => rank(a.node) - rank(b.node) || a.claimed - b.claimed || a.node.localeCompare(b.node))[0]
55
+ return next === undefined ? null : { node: next.node, session: next.session, since: o.now, lost: null }
56
+ }
@@ -0,0 +1,210 @@
1
+ // who hears a repo on one place (wiki tools/shipkit/hq.md, the kind presence): one row a node and repo, the facts its
2
+ // daemon read there (orchestrator/places-shape.ts PresenceFacts), replaced by the next one it sends. The node is the one
3
+ // the token names, never a field of the body, so no node speaks for another. Every time it holds is the hq's own: a row
4
+ // is ordered by its number in its outbox, its age is the hq's since it landed, a node is fresh by its last read of this
5
+ // kind (its look, never another job's call), and a holder's claim is when the hq first saw that session hold the role.
6
+ // No place compares two clocks, and no node's word on a time decides anything. The table `leads` holds the owner's
7
+ // order of a repo's places and the lead the reads settle (presence-rule.ts leadOf); the table `placements` the places
8
+ // he placed a repo on, read back with every look (wiki tools/shipkit/sessions.md, Placement)
9
+ import type { Database } from 'bun:sqlite'
10
+ import type { LeadSeen } from '../../orchestrator/lead-shape.ts'
11
+ import type { PlacedPlace, PresenceFacts, PresenceRow } from '../../orchestrator/places-shape.ts'
12
+ import { LEAD_MAX_PLACES, leadOf, PRESENCE_FRESH_MS, PRESENCE_OLD_MS, type LeadCandidate, type LeadState } from './presence-rule.ts'
13
+ import { isRepoId, kind } from './kind.ts'
14
+
15
+ /** one node sends one row a repo it holds: far more repos than a machine checks out */
16
+ export const NODE_MAX_PRESENCE = 500
17
+ /** a row nobody sent again for a day goes */
18
+ export const PRESENCE_KEPT_MS = 24 * 3600_000
19
+ const MAX_WATCHES = 64
20
+
21
+ const isObj = (v: unknown): v is Record<string, unknown> => v != null && typeof v === 'object' && !Array.isArray(v)
22
+ const only = (v: Record<string, unknown>, keys: readonly string[]): boolean => Object.keys(v).every((k) => keys.includes(k))
23
+ const word = (v: unknown, max = 128): v is string => typeof v === 'string' && v !== '' && v.length <= max && !/[\0-\x1f]/.test(v)
24
+ const time = (v: unknown): v is string => word(v, 40) && Number.isFinite(Date.parse(v))
25
+ const orNull = (v: unknown, ok: (x: unknown) => boolean): boolean => v === null || ok(v)
26
+
27
+ const isHolder = (v: unknown): boolean =>
28
+ isObj(v) && only(v, ['session', 'name', 'where', 'since', 'ear', 'busy']) && word(v['session']) && word(v['name'], 200) && word(v['where'], 200) && time(v['since']) && (v['ear'] === null || v['ear'] === 'watch' || v['ear'] === 'channel') && typeof v['busy'] === 'boolean'
29
+ const isWatch = (v: unknown): boolean =>
30
+ isObj(v) && only(v, ['session', 'lane', 'by', 'house', 'started']) && orNull(v['session'], word) && orNull(v['lane'], word) && orNull(v['by'], word) && typeof v['house'] === 'boolean' && time(v['started'])
31
+
32
+ const isSession = (v: unknown): boolean =>
33
+ isObj(v) && only(v, ['session', 'name', 'busy', 'ear']) && word(v['session']) && word(v['name'], 200) && typeof v['busy'] === 'boolean' && (v['ear'] === null || v['ear'] === 'watch' || v['ear'] === 'channel')
34
+
35
+ export const isPresence = (v: unknown): v is PresenceFacts =>
36
+ isObj(v) &&
37
+ only(v, ['repo', 'holder', 'watches', 'sessions']) &&
38
+ isRepoId(v['repo']) &&
39
+ orNull(v['holder'], isHolder) &&
40
+ Array.isArray(v['watches']) &&
41
+ v['watches'].length <= MAX_WATCHES &&
42
+ v['watches'].every(isWatch) &&
43
+ (v['sessions'] === undefined || (Array.isArray(v['sessions']) && v['sessions'].length <= MAX_WATCHES && v['sessions'].every(isSession)))
44
+
45
+ type LeadRow = { repo: string; places: string; at: number; node: string | null; session: string | null; since: number | null; lost: number | null }
46
+
47
+ const nodesOf = (json: string | null | undefined): string[] => {
48
+ try {
49
+ const v = JSON.parse(json ?? '[]') as unknown
50
+ return Array.isArray(v) ? v.filter((x): x is string => typeof x === 'string') : []
51
+ } catch {
52
+ return []
53
+ }
54
+ }
55
+ const orderOf = (r: LeadRow | null): string[] => nodesOf(r?.places)
56
+
57
+ /** the places the owner placed `repo` on, as node ids; none: every place that has it */
58
+ export const placedOf = (db: Database, repo: string): string[] => nodesOf((db.query('select places from placements where repo = ?').get(repo) as { places: string } | null)?.places)
59
+
60
+ /** the placement of each repo of `repos` (null: every repo placed), each place named by its machine
61
+ * (`<machine>/<os user>` on a machine of two nodes not ended); an ended node is never a place a repo runs on */
62
+ export function placementsOf(db: Database, repos: readonly string[] | null): Record<string, PlacedPlace[]> {
63
+ const rows = (repos === null ? db.query('select repo, places from placements').all() : db.query(`select repo, places from placements where repo in (${repos.map(() => '?').join(',')})`).all(...repos)) as { repo: string; places: string }[]
64
+ if (rows.length === 0) return {}
65
+ const nodes = db.query('select n.id, n.os_user, n.machine, m.name from nodes n join machines m on m.id = n.machine where n.ended is null').all() as { id: string; os_user: string; machine: string; name: string }[]
66
+ const twice = new Set(nodes.map((n) => n.machine).filter((m, i, all) => all.indexOf(m) !== i))
67
+ const name = new Map(nodes.map((n) => [n.id, twice.has(n.machine) ? `${n.name}/${n.os_user}` : n.name]))
68
+ const out: Record<string, PlacedPlace[]> = {}
69
+ for (const r of rows) {
70
+ // an ended node runs nothing: a placement left with no live place reads as none, every place that has it
71
+ const live = nodesOf(r.places).flatMap((n) => (name.has(n) ? [{ node: n, name: name.get(n)! }] : []))
72
+ if (live.length > 0) out[r.repo] = live
73
+ }
74
+ return out
75
+ }
76
+
77
+ /** the owner's placement of a repo, as node ids (none: every place that has it, today's rule). Each node must be a
78
+ * node of this hq that is not ended. A placement with no order of the owner's seeds the lead (settleLeads) */
79
+ export function setPlacement(db: Database, repo: string, nodes: readonly string[], now: number): { places: string[] } | { refused: string } {
80
+ if (!isRepoId(repo)) return { refused: `${JSON.stringify(repo).slice(0, 80)} is no repo key` }
81
+ if (nodes.length > LEAD_MAX_PLACES) return { refused: `at most ${LEAD_MAX_PLACES} places in a placement` }
82
+ if (new Set(nodes).size !== nodes.length) return { refused: 'a place is named twice in the placement' }
83
+ for (const n of nodes) {
84
+ const live = db.query('select 1 from nodes where id = ? and ended is null').get(n)
85
+ if (live == null) return { refused: `the hq knows no live place ${JSON.stringify(n).slice(0, 80)}` }
86
+ }
87
+ if (nodes.length === 0) db.query('delete from placements where repo = ?').run(repo)
88
+ else db.query('insert into placements (repo, places, at) values (?1, ?2, ?3) on conflict (repo) do update set places = ?2, at = ?3').run(repo, JSON.stringify(nodes), now)
89
+ // with no order of his, the placement picks the lead: the lead settled before it is dropped, so it acts at the next read
90
+ db.query("update leads set node = null, session = null, since = null, lost = null where repo = ? and places = '[]'").run(repo)
91
+ return { places: [...nodes] }
92
+ }
93
+
94
+ /** the lead of each repo, settled now on the hq's clock (presence-rule.ts leadOf): a candidate is a node not ended,
95
+ * whose look read this kind in the last PRESENCE_FRESH_MS, whose row is younger than PRESENCE_OLD_MS and names a
96
+ * holder, its claim the hq's own stamp. `repos`
97
+ * null: every repo with a row */
98
+ export function settleLeads(db: Database, repos: readonly string[] | null, now: number): Record<string, LeadSeen> {
99
+ const names = repos ?? (db.query('select distinct repo from presence').all() as { repo: string }[]).map((r) => r.repo)
100
+ const out: Record<string, LeadSeen> = {}
101
+ for (const repo of names) {
102
+ const row = db.query('select repo, places, at, node, session, since, lost from leads where repo = ?').get(repo) as LeadRow | null
103
+ const rows = db.query('select p.node, p.landed, p.body, p.claimed, l.at as looked from presence p join nodes n on n.id = p.node left join presence_looked l on l.node = p.node where p.repo = ? and n.ended is null').all(repo) as { node: string; landed: number; body: string; claimed: number | null; looked: number | null }[]
104
+ if (rows.length === 0 && row === null) continue
105
+ const candidates: LeadCandidate[] = rows.flatMap((r) => {
106
+ if (r.looked == null || !(now - r.looked < PRESENCE_FRESH_MS) || !(now - r.landed < PRESENCE_OLD_MS)) return []
107
+ const h = (JSON.parse(r.body) as PresenceFacts).holder
108
+ return h === null ? [] : [{ node: r.node, session: h.session, claimed: r.claimed ?? r.landed, hears: h.ear !== null }]
109
+ })
110
+ const was: LeadState | null = row?.node != null && row.session != null && row.since != null ? { node: row.node, session: row.session, since: row.since, lost: row.lost } : null
111
+ const order = orderOf(row)
112
+ // with no order of the owner, the placement picks the lead first: a project placed on tower is led from there
113
+ const placed = placedOf(db, repo)
114
+ const next = leadOf({ was, order: order.length > 0 ? order : placed, candidates, now })
115
+ if (JSON.stringify(next) !== JSON.stringify(was)) {
116
+ db.query('insert into leads (repo, places, at, node, session, since, lost) values (?1, ?2, ?3, ?4, ?5, ?6, ?7) on conflict (repo) do update set node = ?4, session = ?5, since = ?6, lost = ?7').run(repo, row?.places ?? '[]', row?.at ?? now, next?.node ?? null, next?.session ?? null, next?.since ?? null, next?.lost ?? null)
117
+ }
118
+ out[repo] = { order, lead: next?.node ?? null, waits: next?.lost != null, ...(placed.length > 0 ? { placed } : {}) }
119
+ }
120
+ return out
121
+ }
122
+
123
+ /** the owner's order of a repo's places, as node ids (none: the first claim picks the lead). It drops the lead it
124
+ * settled, so the owner's pick acts at the next read. Each node must be a node of this hq that is not ended */
125
+ export function setLeadOrder(db: Database, repo: string, nodes: readonly string[], now: number): { order: string[] } | { refused: string } {
126
+ if (!isRepoId(repo)) return { refused: `${JSON.stringify(repo).slice(0, 80)} is no repo key` }
127
+ if (nodes.length > LEAD_MAX_PLACES) return { refused: `at most ${LEAD_MAX_PLACES} places in an order` }
128
+ if (new Set(nodes).size !== nodes.length) return { refused: 'a place is named twice in the order' }
129
+ for (const n of nodes) {
130
+ const live = db.query('select 1 from nodes where id = ? and ended is null').get(n)
131
+ if (live == null) return { refused: `the hq knows no live place ${JSON.stringify(n).slice(0, 80)}` }
132
+ }
133
+ db.query('insert into leads (repo, places, at, node, session, since, lost) values (?1, ?2, ?3, null, null, null, null) on conflict (repo) do update set places = ?2, at = ?3, node = null, session = null, since = null, lost = null').run(repo, JSON.stringify(nodes), now)
134
+ return { order: [...nodes] }
135
+ }
136
+
137
+ type Sql = { node: string; repo: string; landed: number; body: string; looked: number | null; claimed: number | null; os_user: string; kind: string | null; host: string | null; machine: string; name: string }
138
+ type Was = { epoch: string; seq: number; bytes: number; body: string; claimed_session: string | null; claimed: number | null }
139
+
140
+ export const presenceKind = kind<PresenceFacts>({
141
+ kind: 'presence',
142
+ // presence the last row of a node and repo; `claimed_session` and `claimed` the holder the hq saw last and
143
+ // when it first saw that session hold the role
144
+ // presence_looked a node's last read of this kind: the end of each of its looks, what says its place is live
145
+ // leads one row a repo: the owner's order of its places (node ids, `at` when set) and the lead the reads
146
+ // settled last, on this clock (16)
147
+ // placements one row a repo the owner placed: the places it runs on (node ids, `at` when set); no row, every
148
+ // place that has it (17)
149
+ schema: `
150
+ create table if not exists presence (node text not null, repo text not null, epoch text not null, seq integer not null, landed integer not null, body text not null, claimed_session text, claimed integer, primary key (node, repo)) without rowid;
151
+ create table if not exists presence_looked (node text primary key, at integer not null) without rowid;
152
+ create table if not exists leads (repo text primary key, places text not null default '[]', at integer not null, node text, session text, since integer, lost integer) without rowid;
153
+ create table if not exists placements (repo text primary key, places text not null, at integer not null) without rowid;
154
+ `,
155
+ tables: ['presence', 'presence_looked', 'leads', 'placements'],
156
+ check: isPresence,
157
+ // a session's name is Claude Code's, made from its first prompt: masked like any text
158
+ texts: ['holder.name', 'holder.where', 'sessions.*.name'],
159
+ repoOf: (b) => b.repo,
160
+ maxRowBytes: 16 * 1024,
161
+ insert: (db, r) => {
162
+ const was = db.query('select epoch, seq, length(cast(body as blob)) as bytes, body, claimed_session, claimed from presence where node = ? and repo = ?').get(r.node, r.body.repo) as Was | null
163
+ // a row sent late never replaces a newer one of its outbox: its number says which, never a clock
164
+ if (was != null && was.epoch === r.epoch && was.seq >= r.seq) return null
165
+ const session = r.body.holder?.session ?? null
166
+ // a holder keeps the time the hq first saw it hold, across rows that name no holder between
167
+ const claimedSession = session ?? was?.claimed_session ?? null
168
+ const claimed = session === null ? (was?.claimed ?? null) : session === was?.claimed_session ? was.claimed : r.landed
169
+ db.query('insert into presence (node, repo, epoch, seq, landed, body, claimed_session, claimed) values (?, ?, ?, ?, ?, ?, ?, ?) on conflict (node, repo) do update set epoch = excluded.epoch, seq = excluded.seq, landed = excluded.landed, body = excluded.body, claimed_session = excluded.claimed_session, claimed = excluded.claimed').run(r.node, r.body.repo, r.epoch, r.seq, r.landed, r.text, claimedSession, claimed)
170
+ return { rows: was == null ? 1 : 0, bytes: Buffer.byteLength(r.text) - (was?.bytes ?? 0) }
171
+ },
172
+ usage: (db) => db.query('select node, count(*) as rows, sum(length(cast(body as blob))) as bytes from presence group by node').all() as { node: string; rows: number; bytes: number }[],
173
+ maxPerNode: NODE_MAX_PRESENCE,
174
+ // a row is about a kB: a node of 500 repos at 16 kB a row is refused before it fills a share of the file
175
+ maxBytesPerNode: 1024 * 1024,
176
+ sweep: (db, now) => db.query('delete from presence where landed < ?').run(now - PRESENCE_KEPT_MS).changes + db.query('delete from presence_looked where at < ?').run(now - PRESENCE_KEPT_MS).changes,
177
+ outbox: 'presence',
178
+ read: {
179
+ // every row of the repos the viewer reads, with its node's place and ages by the hq's clock: a few dozen rows.
180
+ // A read is the end of the viewer's look: it stamps the viewer live
181
+ page: (db, q) => {
182
+ const now = q.now ?? Date.now()
183
+ if (q.viewer != null) db.query('insert into presence_looked (node, at) values (?, ?) on conflict (node) do update set at = excluded.at').run(q.viewer, now)
184
+ const inRepos = q.repos == null ? '' : `and p.repo in (${q.repos.map(() => '?').join(',')})`
185
+ const rows = db
186
+ .query(`select p.node, p.repo, p.landed, p.body, l.at as looked, p.claimed, n.os_user, n.kind, n.host, n.machine, m.name from presence p join nodes n on n.id = p.node join machines m on m.id = n.machine left join presence_looked l on l.node = p.node where n.ended is null and (p.node || char(0) || p.repo) > ? ${inRepos} order by p.node, p.repo limit ?`)
187
+ .all(q.after, ...(q.repos ?? []), q.limit + 1) as Sql[]
188
+ const page = rows.slice(0, q.limit).map((r): PresenceRow => {
189
+ const facts = JSON.parse(r.body) as PresenceFacts
190
+ return {
191
+ place: { node: r.node, name: r.name, osUser: r.os_user, kind: r.kind === 'vm' || r.kind === 'container' ? r.kind : 'machine', host: r.host },
192
+ // a node that never read this kind is no live place
193
+ age: r.looked == null ? Number.MAX_SAFE_INTEGER : Math.max(0, now - r.looked),
194
+ old: Math.max(0, now - r.landed),
195
+ claimed: facts.holder === null ? null : r.claimed,
196
+ hq: q.hqMachine != null && r.machine === q.hqMachine,
197
+ facts,
198
+ }
199
+ })
200
+ const last = rows[q.limit - 1]
201
+ // the lead of each repo the viewer reads, settled once a look (its first page) on this clock
202
+ const leads = q.after === '' ? settleLeads(db, q.repos, now) : undefined
203
+ // and where the owner placed them, once a look too: what each place's pm reads at its next start
204
+ const placed = q.after === '' ? placementsOf(db, q.repos) : undefined
205
+ return { rows: page, next: rows.length > q.limit && last != null ? `${last.node}\0${last.repo}` : null, now, ...(q.viewer != null ? { you: q.viewer } : {}), ...(leads !== undefined ? { leads } : {}), ...(placed !== undefined ? { placed } : {}) }
206
+ },
207
+ lacks: () => [],
208
+ count: (db, q) => (db.query(`select count(*) as n from presence${q.repos == null ? '' : ` where repo in (${q.repos.map(() => '?').join(',')})`}`).get(...(q.repos ?? [])) as { n: number }).n,
209
+ },
210
+ })
@@ -1,6 +1,6 @@
1
1
  // what a node says of its machine at one moment (hq/report.ts builds it): appends only, raw for 30 days, then the
2
2
  // last one of each day a node. Only the newest report's activity is read, so an older one loses it after a day
3
- import { isReport, REPORT_TEXTS, type Report } from '../report.ts'
3
+ import { isReport, REPORT_TEXTS, storedReport, type Report } from '../report.ts'
4
4
  import { kind } from './kind.ts'
5
5
 
6
6
  /** raw reports are kept this long, then one a day a node */
@@ -12,9 +12,10 @@ export const NODE_MAX_REPORT_BYTES = 40 * 1024 * 1024
12
12
  /** a report keeps its activity this long: past it only its figures are read (the disk line) */
13
13
  export const REPORT_ACTIVITY_MS = 24 * 3600_000
14
14
 
15
- /** a report past a day: what only the newest one is read for (its activity, each repo's gate, each process's url) goes */
15
+ /** a report past a day: what only the newest one is read for (its activity, each repo's gate, each process's url, its
16
+ * url facts) goes */
16
17
  export function slimReport(r: Report): Report {
17
- const { activity: _activity, ...rest } = r
18
+ const { activity: _activity, urls: _urls, ...rest } = r
18
19
  return { ...rest, repos: r.repos.map(({ gate: _gate, ...x }) => x), ...(r.processes == null ? {} : { processes: r.processes.map(({ url: _url, ...p }) => p) }) }
19
20
  }
20
21
 
@@ -30,11 +31,13 @@ create index if not exists reports_at on reports (node, at);
30
31
  // a report is the machine's, and names every repo it holds: it is filed under none
31
32
  repoOf: () => '',
32
33
  insert: (db, r) => {
33
- if (db.query('insert into reports (node, epoch, seq, at, body) values (?, ?, ?, ?, ?) on conflict (node, epoch, seq) do nothing').run(r.node, r.epoch, r.seq, r.at, r.text).changes === 0) return null
34
+ // its url facts rebuilt field by field: a login or a secret's name a sender put beside one is never stored
35
+ const text = r.body.urls === undefined ? r.text : JSON.stringify(storedReport(r.body))
36
+ if (db.query('insert into reports (node, epoch, seq, at, body) values (?, ?, ?, ?, ?) on conflict (node, epoch, seq) do nothing').run(r.node, r.epoch, r.seq, r.at, text).changes === 0) return null
34
37
  // a wanted switch value is done once a report of its node shows it
35
38
  const sw = r.body.switches
36
39
  if (sw != null) for (const w of db.query('select name, value from wanted where node = ? and done is null').all(r.node) as { name: string; value: number }[]) if (sw[w.name] === (w.value === 1)) db.query('update wanted set done = ? where node = ? and name = ?').run(r.at, r.node, w.name)
37
- return { rows: 1, bytes: Buffer.byteLength(r.text) }
40
+ return { rows: 1, bytes: Buffer.byteLength(text) }
38
41
  },
39
42
  usage: (db) => db.query('select node, count(*) as rows, sum(length(cast(body as blob))) as bytes from reports group by node').all() as { node: string; rows: number; bytes: number }[],
40
43
  maxPerNode: NODE_MAX_REPORTS,
@@ -0,0 +1,68 @@
1
+ // the owner's picks of a project's places (wiki tools/shipkit/sessions.md, The lead and Placement): the order,
2
+ // which picks the lead, and the placement, the places it runs on. Written into the hq this machine's daemon carries, read
3
+ // back by every place through its view (orchestrator/places.ts). The lead rule is kinds/presence-rule.ts.
4
+ // The one constraint a reader breaks first: both are the owner's act alone. They are written here only, in the daemon
5
+ // that carries the hq, asked by the owner's hub page or by `sk orchestrator lead` and `sk place` over loopback; a lane
6
+ // and the orchestrator are refused before they ask (cli/cmd_Orchestrator.ts ownerPickRefusal)
7
+
8
+ /** the hq key of a repo of this machine, by its folder name, as the threads job last held it; null when it holds none */
9
+ export async function repoKeyOf(name: string): Promise<string | null> {
10
+ const { machineGet } = await import('../core/machine-db.ts')
11
+ const { HELD_REPOS } = await import('./thread-sync.ts')
12
+ const { repoNameOf } = await import('../agent-time/registry.ts')
13
+ const held = machineGet<import('./thread-sync.ts').HeldRepo[]>(HELD_REPOS) ?? []
14
+ return held.find((r) => repoNameOf(r.path) === name)?.id ?? null
15
+ }
16
+
17
+ /** the node a word names: its id, its machine's name when one node of that machine is live, or `<machine>/<os user>` */
18
+ export function nodeOfPlace(db: import('bun:sqlite').Database, word: string): string | { refused: string } {
19
+ const live = db.query('select n.id, n.os_user, m.name from nodes n join machines m on m.id = n.machine where n.ended is null').all() as { id: string; os_user: string; name: string }[]
20
+ const hit = live.filter((n) => n.id === word || n.name === word || `${n.name}/${n.os_user}` === word)
21
+ if (hit.length === 1) return hit[0]!.id
22
+ const w = JSON.stringify(word).slice(0, 80)
23
+ return { refused: hit.length === 0 ? `the hq knows no live place ${w} (sk machines lists them)` : `${hit.length} places are ${w}: name one as <machine>/<os user>` }
24
+ }
25
+
26
+ /** the owner's order of `repo`'s places (this machine's name of the repo; places as nodes or names, none: the first claim), into
27
+ * the hq this machine carries. The answer names the places as the hq does */
28
+ export async function setLeadHere(repo: string, places: readonly string[], now: number = Date.now()): Promise<{ order: string[] } | { refused: string }> {
29
+ const { carriesHq, carriedHq } = await import('./hq-local.ts')
30
+ const store = carriesHq() ? carriedHq() : null
31
+ if (store === null) return { refused: 'the lead is your order in the hq: set it on the machine that carries the hq, in its hub or with sk orchestrator lead there' }
32
+ const key = await repoKeyOf(repo)
33
+ if (key === null) return { refused: `${JSON.stringify(repo).slice(0, 80)} is no repo this machine sends to the hq (its threads job holds none of that name)` }
34
+ const nodes: string[] = []
35
+ for (const p of places) {
36
+ const n = nodeOfPlace(store.db, p)
37
+ if (typeof n !== 'string') return n
38
+ nodes.push(n)
39
+ }
40
+ const { setLeadOrder } = await import('./kinds/presence.ts')
41
+ const r = setLeadOrder(store.db, key, nodes, now)
42
+ if ('refused' in r) return r
43
+ const names = new Map((store.db.query('select n.id, m.name from nodes n join machines m on m.id = n.machine').all() as { id: string; name: string }[]).map((n) => [n.id, n.name]))
44
+ return { order: r.order.map((n) => names.get(n) ?? n) }
45
+ }
46
+
47
+ /** the owner's placement of `repo` (this machine's name of the repo; places as nodes or names, none: every place that has
48
+ * it), into the hq this machine carries. The answer names the places as the hq does, and those that hold no checkout
49
+ * of the repo yet (no presence row of it): their processes start there once it is cloned */
50
+ export async function setPlacementHere(repo: string, places: readonly string[], now: number = Date.now()): Promise<{ places: string[]; without: string[] } | { refused: string }> {
51
+ const { carriesHq, carriedHq } = await import('./hq-local.ts')
52
+ const store = carriesHq() ? carriedHq() : null
53
+ if (store === null) return { refused: 'a placement is your pick in the hq: set it on the machine that carries the hq, in its hub or with sk place there' }
54
+ const key = await repoKeyOf(repo)
55
+ if (key === null) return { refused: `${JSON.stringify(repo).slice(0, 80)} is no repo this machine sends to the hq (its threads job holds none of that name)` }
56
+ const nodes: string[] = []
57
+ for (const p of places) {
58
+ const n = nodeOfPlace(store.db, p)
59
+ if (typeof n !== 'string') return n
60
+ nodes.push(n)
61
+ }
62
+ const { setPlacement, placementsOf } = await import('./kinds/presence.ts')
63
+ const r = setPlacement(store.db, key, nodes, now)
64
+ if ('refused' in r) return r
65
+ const named = placementsOf(store.db, [key])[key] ?? []
66
+ const holds = new Set((store.db.query('select node from presence where repo = ?').all(key) as { node: string }[]).map((x) => x.node))
67
+ return { places: named.map((p) => p.name), without: named.filter((p) => !holds.has(p.node)).map((p) => p.name) }
68
+ }
package/src/hq/outbox.ts CHANGED
@@ -313,6 +313,13 @@ export class Outbox {
313
313
  return (this.db.query('select count(*) as n from outbox where box = ?').get(this.name) as { n: number }).n
314
314
  }
315
315
 
316
+ /** the rows of `kind` the hq has not taken yet whose body's `field` is `value`: a row a newer one replaces, for a
317
+ * kind the hq keeps the last row of (presence). How many went */
318
+ dropWaiting(kind: string, field: string, value: string): number {
319
+ if (!/^\w+$/.test(field)) throw new Error(`no field ${JSON.stringify(field)} of a row`)
320
+ return this.db.query(`delete from outbox where box = ? and kind = ? and confirmed is null and json_extract(body, '$.${field}') = ?`).run(this.name, kind, value).changes
321
+ }
322
+
316
323
  /** the rows the hq has not taken yet */
317
324
  waiting(): number {
318
325
  return (this.db.query('select count(*) as n from outbox where box = ? and confirmed is null').get(this.name) as { n: number }).n
package/src/hq/replica.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // the hq's second copy (wiki tools/shipkit/hq.md): Litestream sends the hq's file to a bucket as it is written, and
2
2
  // the drill proves the copy by a restore beside the live file. The key pair is read through the house's secret
3
3
  // command and handed to Litestream in its environment: never in the config file, never in an argument
4
+ import { readKeyPair, type KeyPairNames } from '../secrets/key-pair.ts'
4
5
  import { Database } from 'bun:sqlite'
5
6
  import { mkdtempSync, rmSync, statSync, writeFileSync } from 'fs'
6
7
  import { tmpdir } from 'os'
@@ -18,8 +19,8 @@ export interface HqReplica {
18
19
  region: string
19
20
  /** the replica's folder in the bucket, `hq` when absent */
20
21
  path?: string
21
- /** the secret whose value is `KEY:SECRET`, read through the house store */
22
- secret: string
22
+ /** the two secrets of its key, read through the house store */
23
+ key: KeyPairNames
23
24
  }
24
25
 
25
26
  /** how often Litestream sends: what a hard stop of the hq can lose, and what the outboxes hold for longer */
@@ -43,15 +44,12 @@ export async function houseReplica(cwd: string = process.cwd()): Promise<Replica
43
44
  const c = await loadRepoConfig(house)
44
45
  const replica = c.serve?.hqReplica
45
46
  if (!replica) return { why: `the house config (${house}) names no serve.hqReplica: the hq has no second copy`, configured: false }
46
- let pair = ''
47
47
  try {
48
- pair = await readThrough(c.credsReadCommand, replica.secret)
48
+ const pair = await readKeyPair(replica.key, (name) => readThrough(c.credsReadCommand, name))
49
+ return { replica, env: { LITESTREAM_ACCESS_KEY_ID: pair.accessKeyId, LITESTREAM_SECRET_ACCESS_KEY: pair.secretAccessKey } }
49
50
  } catch (e) {
50
51
  return { why: (e as Error).message, configured: true }
51
52
  }
52
- const at = pair.indexOf(':')
53
- if (at <= 0) return { why: `the secret ${replica.secret} is no KEY:SECRET pair`, configured: true }
54
- return { replica, env: { LITESTREAM_ACCESS_KEY_ID: pair.slice(0, at), LITESTREAM_SECRET_ACCESS_KEY: pair.slice(at + 1) } }
55
53
  }
56
54
 
57
55
  const litestream = (): string | null => Bun.which('litestream')
@@ -1,11 +1,11 @@
1
1
  // the facts of a report that are not git's (hq/report.ts): the global processes as pm holds them, the live agents as
2
- // counts a house repo, the declared switches. The one constraint a reader breaks first: a lane's row carries what it
2
+ // counts a house repo, the declared switches, the declared urls. The one constraint a reader breaks first: a lane's row carries what it
3
3
  // does, made of the owner's prompts, and the name of any folder it works in: only counts leave, and only a house
4
4
  // repo's name
5
5
  import { dirname, resolve } from 'path'
6
6
  import { gitRoot } from '../core/git-root.ts'
7
- import type { LaneCount, ProcFact, Report } from './report.ts'
8
- import { MAX_LANE_REPOS, MAX_PROCESSES, MAX_URL } from './report.ts'
7
+ import type { LaneCount, ProcFact, Report, UrlFact } from './report.ts'
8
+ import { MAX_LANE_REPOS, MAX_PROCESSES, MAX_URL, urlFacts } from './report.ts'
9
9
 
10
10
  /** a process as pm answers it, the fields a report keeps */
11
11
  type PmResource = { id: string; repo: string; status: string; since: number; url?: string | null }
@@ -95,23 +95,30 @@ export async function liveAgents(now: number): Promise<LiveAgent[]> {
95
95
 
96
96
  /** what the facts read: pm's answer, the live agents, a machine db value. Handed in, so a test or a scratch run never
97
97
  * reaches the real ones */
98
- export type FactReaders = { pm: () => Promise<{ resources: readonly PmResource[] } | null>; agents: (now: number) => Promise<LiveAgent[]>; get: (name: string) => unknown }
98
+ export type FactReaders = { pm: () => Promise<{ resources: readonly PmResource[] } | null>; agents: (now: number) => Promise<LiveAgent[]>; get: (name: string) => unknown; /** each repo's urls as its hub lists them (urls/rows.ts houseUrls); absent: the report carries none */ urls?: (repos: readonly { name: string; path: string }[]) => Promise<readonly { repo: string; urls: readonly { id: string; label: string; env: string; url: string }[] }[]> }
99
99
 
100
- /** the readers of this machine, for the report job alone */
100
+ /** the readers of this machine, for the report job alone; its urls reader comes from the job (home/daemon-jobs.ts),
101
+ * a layer above this one */
101
102
  export async function realReaders(): Promise<FactReaders> {
102
103
  const { askPm } = await import('../home/pm-switch.ts')
103
104
  const { machineGet } = await import('../core/machine-db.ts')
104
105
  return { pm: askPm, agents: liveAgents, get: machineGet }
105
106
  }
106
107
 
108
+ /** each url of the repos as a fact: its id, label, env and address, never its logins (report.ts urlFacts) */
109
+ export function urlFactsOf(lists: readonly { repo: string; urls: readonly { id: string; label: string; env: string; url: string }[] }[]): UrlFact[] {
110
+ return urlFacts(lists.flatMap((l) => l.urls.map((u) => ({ repo: l.repo, id: u.id, label: u.label, env: u.env, url: u.url }))))
111
+ }
112
+
107
113
  /** everything of the report that is not git's, each part absent when it does not read */
108
- export async function machineFacts(o: { repos: readonly { name: string; path: string }[]; now: number } & FactReaders): Promise<Pick<Report, 'processes' | 'lanes' | 'switches'>> {
114
+ export async function machineFacts(o: { repos: readonly { name: string; path: string }[]; now: number } & FactReaders): Promise<Pick<Report, 'processes' | 'lanes' | 'switches' | 'urls'>> {
109
115
  const { switchValues } = await import('./switch.ts')
110
- const [pm, agents] = await Promise.all([o.pm().catch(() => null), o.agents(o.now).catch(() => null)])
116
+ const [pm, agents, urls] = await Promise.all([o.pm().catch(() => null), o.agents(o.now).catch(() => null), o.urls == null ? null : o.urls(o.repos).catch(() => null)])
111
117
  const processes = procFacts(pm?.resources ?? null)
112
118
  return {
113
119
  ...(processes == null ? {} : { processes }),
114
120
  ...(agents == null ? {} : { lanes: laneCounts(agents, o.repos) }),
115
121
  switches: switchValues(o.get),
122
+ ...(urls == null ? {} : { urls: urlFactsOf(urls) }),
116
123
  }
117
124
  }
package/src/hq/report.ts CHANGED
@@ -63,8 +63,14 @@ export type Report = {
63
63
  switches?: Record<string, boolean | number | null>
64
64
  /** the newest commits of its house repos over ACTIVITY_MS, every local branch, newest first; absent before */
65
65
  activity?: ActivityFact[]
66
+ /** each url its house repos declare (wiki tools/shipkit/urls.md), never a login: absent before */
67
+ urls?: UrlFact[]
66
68
  }
67
69
 
70
+ /** a url a house repo declares, as a place says it: its repo by folder name, its id, label and env, its address as
71
+ * origin and path alone (no user, no query, no fragment). Never a login, an account or a secret's name */
72
+ export type UrlFact = { repo: string; id: string; label: string; env: string; url: string }
73
+
68
74
  export type MediaReport = { at: number; noSpace: string | null; since: number | null; waiting: number; bytes: number; failing: number }
69
75
 
70
76
  /** a global process: its id, the house repo that declares it, its state, since when (ms), the url it declares */
@@ -81,11 +87,12 @@ export const MAX_ACTIVITY = 40
81
87
  export const MAX_TITLE = 120
82
88
  export const MAX_REDS = 8
83
89
  export const MAX_URL = 300
90
+ export const MAX_URLS = 400
84
91
  /** the window of the activity a report carries */
85
92
  export const ACTIVITY_MS = 24 * 3600_000
86
93
  /** the free text fields of a report, masked by the sender and again by the hq as it takes them in (kinds/kind.ts, maskFields): a
87
94
  * branch is named by whoever made it, so a token's shape in it is masked like a title */
88
- export const REPORT_TEXTS = ['activity.*.title', 'activity.*.branch', 'repos.*.branch'] as const
95
+ export const REPORT_TEXTS = ['activity.*.title', 'activity.*.branch', 'repos.*.branch', 'urls.*.label', 'urls.*.url'] as const
89
96
  const MAX_NAME = 128
90
97
  const name = (v: unknown): v is string => typeof v === 'string' && v.length > 0 && v.length <= MAX_NAME
91
98
  const whole = (v: unknown): v is number => typeof v === 'number' && Number.isSafeInteger(v) && v >= 0
@@ -116,9 +123,46 @@ export function isReport(v: unknown): v is Report {
116
123
  if (switches !== undefined && !isSwitches(switches)) return false
117
124
  const activity = v['activity']
118
125
  if (activity !== undefined && !(Array.isArray(activity) && activity.length <= MAX_ACTIVITY && activity.every(isActivity))) return false
126
+ // each url fact is read field by field as the hq takes it (urlFacts): one of a wrong shape is dropped, never stored
127
+ const urls = v['urls']
128
+ if (urls !== undefined && !(Array.isArray(urls) && urls.length <= MAX_URLS)) return false
119
129
  return Array.isArray(repos) && repos.length <= MAX_REPOS && repos.every((r) => isObj(r) && typeof r['name'] === 'string' && (r['key'] === undefined || typeof r['key'] === 'string') && typeof r['branch'] === 'string' && typeof r['head'] === 'string' && isNum(r['ahead']) && isNum(r['behind']) && isNum(r['dirty']) && (r['gate'] === undefined || isGate(r['gate'])))
120
130
  }
121
131
 
132
+ const URL_ID = /^[a-z0-9][a-z0-9-]{0,62}$/
133
+ /** a repo as a url fact names it: one folder's name, never a path or a dot name */
134
+ const FOLDER = /^[A-Za-z0-9_][A-Za-z0-9._-]{0,127}$/
135
+ const ENV = /^[a-z]{2,8}$/
136
+
137
+ /** a url as a fact keeps it: http or https, no user or password, its origin and path alone; null for anything else */
138
+ export function factUrl(v: unknown): string | null {
139
+ if (typeof v !== 'string' || v.length > MAX_URL) return null
140
+ try {
141
+ const u = new URL(v)
142
+ return (u.protocol === 'http:' || u.protocol === 'https:') && u.username === '' && u.password === '' ? `${u.origin}${u.pathname}` : null
143
+ } catch {
144
+ return null
145
+ }
146
+ }
147
+
148
+ /** the url facts a body may carry, rebuilt field by field: a fact of a wrong shape is dropped, and a field no fact
149
+ * knows (a login, an account, a secret's name) never rides. The sender and the hq read them through here alike */
150
+ export function urlFacts(v: unknown): UrlFact[] {
151
+ if (!Array.isArray(v)) return []
152
+ const out: UrlFact[] = []
153
+ for (const f of v.slice(0, MAX_URLS)) {
154
+ if (!isObj(f) || typeof f['repo'] !== 'string' || !FOLDER.test(f['repo']) || typeof f['id'] !== 'string' || !URL_ID.test(f['id']) || typeof f['env'] !== 'string' || !ENV.test(f['env'])) continue
155
+ const url = factUrl(f['url'])
156
+ if (url == null) continue
157
+ const label = typeof f['label'] === 'string' && f['label'] !== '' ? f['label'].slice(0, MAX_NAME) : f['id']
158
+ out.push({ repo: f['repo'], id: f['id'], label, env: f['env'], url })
159
+ }
160
+ return out
161
+ }
162
+
163
+ /** a report as the hq stores it: its url facts rebuilt by urlFacts, nothing else of the body changed */
164
+ export const storedReport = (r: Report): Report => (r.urls === undefined ? r : { ...r, urls: urlFacts(r.urls) })
165
+
122
166
  /** a repo's facts from `git status --porcelain=v2 --branch`: one spawn tells the branch, the head, the distance to
123
167
  * the upstream and each dirty path */
124
168
  export function repoFacts(name: string, status: string): RepoFacts {
@@ -242,7 +286,7 @@ async function gateOf(path: string): Promise<GateFact | undefined> {
242
286
  }
243
287
 
244
288
  /** this machine's report. `house` is the checkout shipkit runs from, null on a machine with none */
245
- export async function buildReport(o: { repos: { name: string; path: string }[]; house: string | null; tailnet: { name: string | null; up: boolean }; diskOf: string; cards?: { waiting: number; since: number | null }; media?: MediaReport | null; now?: number } & Pick<Report, 'processes' | 'lanes' | 'switches'>): Promise<Report> {
289
+ export async function buildReport(o: { repos: { name: string; path: string }[]; house: string | null; tailnet: { name: string | null; up: boolean }; diskOf: string; cards?: { waiting: number; since: number | null }; media?: MediaReport | null; now?: number } & Pick<Report, 'processes' | 'lanes' | 'switches' | 'urls'>): Promise<Report> {
246
290
  const since = (o.now ?? Date.now()) - ACTIVITY_MS
247
291
  const read = await Promise.all(
248
292
  o.repos.slice(0, MAX_REPOS).map(async (r) => {
@@ -267,6 +311,7 @@ export async function buildReport(o: { repos: { name: string; path: string }[];
267
311
  ...(o.lanes == null ? {} : { lanes: o.lanes }),
268
312
  ...(o.switches == null ? {} : { switches: o.switches }),
269
313
  activity,
314
+ ...(o.urls == null ? {} : { urls: urlFacts(o.urls) }),
270
315
  }
271
316
  return maskFields(report, REPORT_TEXTS)
272
317
  }
package/src/hq/switch.ts CHANGED
@@ -94,6 +94,7 @@ export const SWITCHES: readonly SwitchDecl[] = [
94
94
  { name: 'hq-open', type: 'bool', default: false, owner: 'hq/hq-local.ts', what: "the hq's port to the other machines" },
95
95
  { name: 'hq-proxy', type: 'bool', default: false, owner: 'hq/door.ts', what: "the hq's home opens a process of any machine at <process>.<machine>.localhost, on the hq's machine only" },
96
96
  { name: 'machine-door', type: 'bool', default: false, owner: 'hq/door.ts', what: "this machine's web opens its own global processes to the hq's home, for the key the hq gave it" },
97
+ { name: 'machine-terminals', type: 'bool', default: false, owner: 'hq/terminal-hop.ts', what: "the hq Mac's page types into this machine's terminals, for the key the hq gave it; never the phone" },
97
98
  { name: 'media-purge-auto', type: 'bool', default: false, owner: 'media-store/daemon.ts', what: 'an uploaded media file leaves the disk after a day', deletes: true, afar: async (on) => (await import('../media-store/daemon.ts')).setAutoPurge(on) },
98
99
  { name: 'annex-auto', type: 'bool', default: false, owner: 'annex/tidy.ts', what: 'the daemon tidies the annex on its own', deletes: true, afar: async (on) => (await import('../annex/tidy.ts')).setAnnexAuto(on) },
99
100
  { name: 'temp-auto', type: 'bool', default: false, owner: 'home/machine-temp.ts', what: 'the hourly sweep deletes what the temp folders hold idle', deletes: true, afar: async (on) => (await import('../home/machine-temp.ts')).setTempAuto(on) },