@north-light/crouter 0.3.233 → 0.3.234

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 (379) hide show
  1. package/dist/api/client.js +16 -15
  2. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/__tests__/integration/provider-rotation.test.ts +1 -1
  3. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/claude-plugin-commands.ts +14 -17
  4. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/crtr-commands/index.ts +7 -11
  5. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/frontmatter-rules/index.ts +8 -8
  6. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +10 -11
  7. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/pi-shell-runner.ts +2 -2
  8. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.d.ts +3 -3
  9. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.js +7 -7
  10. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +8 -8
  11. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/statusline.ts +6 -6
  12. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/sysprompt-window.ts +3 -3
  13. package/dist/builtin-pi-packages/pi-crtr-extensions/lib/subscription-state.ts +1 -1
  14. package/dist/clients/attach/chrome/ticket-panel.js +15 -2
  15. package/dist/clients/attach/overlays/graph.js +0 -3
  16. package/dist/clients/attach/overlays/mcp.js +1 -2
  17. package/dist/clients/attach/render/chat-view.js +0 -12
  18. package/dist/clients/attach/render/crtr-output.js +0 -2
  19. package/dist/clients/attach/render/tool-calls.js +0 -6
  20. package/dist/clients/attach/slash/dispatch.js +8 -11
  21. package/dist/clients/attach/viewer.js +532 -534
  22. package/dist/clients/conversation/projection.js +0 -2
  23. package/dist/clients/inbox/controller.js +22 -3
  24. package/dist/clients/inbox/review/companion-pane.js +0 -4
  25. package/dist/clients/inbox/review-adapter.js +0 -7
  26. package/dist/clients/inbox/tui/slots.d.ts +3 -3
  27. package/dist/clients/inbox/tui/types.d.ts +2 -2
  28. package/dist/commands/api-client.js +0 -8
  29. package/dist/commands/attention.js +0 -8
  30. package/dist/commands/canvas-browse.js +2 -1
  31. package/dist/commands/canvas-config.js +0 -10
  32. package/dist/commands/canvas-history.js +2 -1
  33. package/dist/commands/cron.js +5 -18
  34. package/dist/commands/dashboard.js +0 -2
  35. package/dist/commands/human/feedback.js +2 -1
  36. package/dist/commands/human/prompts.js +2 -5
  37. package/dist/commands/human/queue.js +2 -7
  38. package/dist/commands/human/request.js +0 -14
  39. package/dist/commands/human/review.js +2 -1
  40. package/dist/commands/memory/__tests__/command-selector-and-mutation-guards.test.js +4 -4
  41. package/dist/commands/memory/find.js +2 -2
  42. package/dist/commands/memory/lint.js +2 -1
  43. package/dist/commands/memory/read.d.ts +2 -7
  44. package/dist/commands/memory/read.js +5 -16
  45. package/dist/commands/memory/shared.js +4 -7
  46. package/dist/commands/memory/write.js +4 -3
  47. package/dist/commands/node/bash.js +2 -1
  48. package/dist/commands/node/create.js +2 -1
  49. package/dist/commands/node/inspect.js +0 -6
  50. package/dist/commands/node/lifecycle.js +4 -13
  51. package/dist/commands/node/message.js +3 -2
  52. package/dist/commands/node/subscription.js +2 -1
  53. package/dist/commands/node/wait.js +4 -3
  54. package/dist/commands/node-context.js +2 -1
  55. package/dist/commands/node-lifecycle-revive.js +0 -2
  56. package/dist/commands/node-worktree.js +2 -1
  57. package/dist/commands/pkg/browse/actions.d.ts +1 -1
  58. package/dist/commands/pkg/browse/actions.js +4 -4
  59. package/dist/commands/pkg/browse/catalog.d.ts +1 -1
  60. package/dist/commands/pkg/browse/catalog.js +15 -15
  61. package/dist/commands/pkg/browse/command-view.d.ts +1 -1
  62. package/dist/commands/pkg/browse/command-view.js +3 -3
  63. package/dist/commands/pkg/browse/detail-panel.d.ts +1 -1
  64. package/dist/commands/pkg/browse/detail-panel.js +8 -8
  65. package/dist/commands/pkg/browse/doc-view.d.ts +1 -1
  66. package/dist/commands/pkg/browse/doc-view.js +3 -3
  67. package/dist/commands/pkg/browse/list-panel.d.ts +1 -1
  68. package/dist/commands/pkg/browse/list-panel.js +3 -3
  69. package/dist/commands/pkg/browse/model.d.ts +3 -3
  70. package/dist/commands/pkg/browse/shell.d.ts +2 -2
  71. package/dist/commands/pkg/browse/shell.js +13 -13
  72. package/dist/commands/pkg/plugin-manage.js +2 -1
  73. package/dist/commands/pkg/shared.js +0 -2
  74. package/dist/commands/profile/delete.js +2 -1
  75. package/dist/commands/push.js +2 -3
  76. package/dist/commands/revive.js +0 -2
  77. package/dist/commands/surface/node/placement.js +2 -1
  78. package/dist/commands/surface-edit.js +2 -1
  79. package/dist/commands/sys/config.js +0 -4
  80. package/dist/commands/sys/daemon.js +0 -10
  81. package/dist/commands/sys/doctor.js +3 -2
  82. package/dist/commands/sys/panels/broker-limits-panel.d.ts +2 -2
  83. package/dist/commands/sys/panels/broker-limits-panel.js +4 -4
  84. package/dist/commands/sys/panels/dependencies-panel.d.ts +2 -2
  85. package/dist/commands/sys/panels/dependencies-panel.js +2 -2
  86. package/dist/commands/sys/panels/keybindings-panel.d.ts +1 -1
  87. package/dist/commands/sys/panels/keybindings-panel.js +5 -5
  88. package/dist/commands/sys/panels/models-panel.d.ts +4 -4
  89. package/dist/commands/sys/panels/models-panel.js +11 -10
  90. package/dist/commands/sys/panels/plugins-panel.d.ts +2 -2
  91. package/dist/commands/sys/panels/plugins-panel.js +2 -2
  92. package/dist/commands/sys/panels/prefs-panel.d.ts +2 -2
  93. package/dist/commands/sys/panels/prefs-panel.js +4 -4
  94. package/dist/commands/sys/panels/profiles-panel.d.ts +1 -1
  95. package/dist/commands/sys/panels/profiles-panel.js +14 -13
  96. package/dist/commands/sys/panels/provider-panel.d.ts +3 -3
  97. package/dist/commands/sys/panels/provider-panel.js +8 -8
  98. package/dist/commands/sys/settings-shell.d.ts +3 -3
  99. package/dist/commands/sys/settings-shell.js +15 -15
  100. package/dist/commands/sys/setup-settings-runner.d.ts +3 -3
  101. package/dist/commands/sys/setup-settings-runner.js +5 -5
  102. package/dist/commands/sys/setup-wizard.d.ts +4 -4
  103. package/dist/commands/sys/setup-wizard.js +8 -8
  104. package/dist/commands/sys/support/prepare.js +4 -4
  105. package/dist/commands/sys/support/submit.js +2 -2
  106. package/dist/commands/sys/sync-deps.js +0 -2
  107. package/dist/commands/sys/sync-project-guidance.js +2 -1
  108. package/dist/commands/sys/sysprompt.js +2 -1
  109. package/dist/core/__tests__/boot.test.js +0 -8
  110. package/dist/core/__tests__/broker-extension-canvas-db-boundary.test.js +23 -1
  111. package/dist/core/__tests__/canvas-db-boundary.test.d.ts +1 -0
  112. package/dist/core/__tests__/canvas-db-boundary.test.js +46 -0
  113. package/dist/core/__tests__/canvas.test.js +1 -1
  114. package/dist/core/__tests__/child-death-wake.test.js +0 -2
  115. package/dist/core/__tests__/cron-armed-context-failure.test.d.ts +1 -0
  116. package/dist/core/__tests__/cron-armed-context-failure.test.js +145 -0
  117. package/dist/core/__tests__/daemon-wedge.test.js +0 -4
  118. package/dist/core/__tests__/dead-node-policy-table.test.js +0 -4
  119. package/dist/core/__tests__/fixtures/fake-engine.js +4 -14
  120. package/dist/core/__tests__/fixtures/fake-pi-host.js +5 -5
  121. package/dist/core/__tests__/focuses.test.js +0 -6
  122. package/dist/core/__tests__/fs-utils.test.d.ts +1 -0
  123. package/dist/core/__tests__/fs-utils.test.js +50 -0
  124. package/dist/core/__tests__/helpers/harness.js +1 -1
  125. package/dist/core/__tests__/inline-memory-refs.test.js +0 -2
  126. package/dist/core/__tests__/integration/broker-fork-seam.test.js +0 -2
  127. package/dist/core/__tests__/integration/broker-sdk-wiring.test.js +3 -16
  128. package/dist/core/__tests__/integration/command-plugins.test.js +0 -24
  129. package/dist/core/__tests__/integration/deferred-no-wake.test.js +0 -6
  130. package/dist/core/__tests__/integration/flagship-lifecycle.test.js +0 -26
  131. package/dist/core/__tests__/integration/live-mutation-verbs.test.js +0 -4
  132. package/dist/core/__tests__/integration/live-mutation.test.js +1 -5
  133. package/dist/core/__tests__/integration/refresh-stall-recycle.test.js +1 -5
  134. package/dist/core/__tests__/integration/revive.test.js +0 -12
  135. package/dist/core/__tests__/integration/subscription-delivery.test.js +0 -6
  136. package/dist/core/__tests__/integration/tmux-surface.test.js +24 -8
  137. package/dist/core/__tests__/integration/worktree-reap.test.js +0 -6
  138. package/dist/core/__tests__/lifecycle.test.js +0 -18
  139. package/dist/core/__tests__/memory-resolver-precedence.test.js +1 -1
  140. package/dist/core/__tests__/migration.test.js +2 -2
  141. package/dist/core/__tests__/on-read-dedup-resume.test.js +3 -3
  142. package/dist/core/__tests__/pid-identity-match.test.js +1 -1
  143. package/dist/core/__tests__/plugin-kinds.test.js +1 -1
  144. package/dist/core/__tests__/plugin-page-components.test.js +1 -1
  145. package/dist/core/__tests__/preview-registry-sync.test.js +42 -1
  146. package/dist/core/__tests__/respawn-throttle.test.js +0 -4
  147. package/dist/core/__tests__/revive-all.test.js +5 -5
  148. package/dist/core/__tests__/revive-parked-fresh.test.js +62 -11
  149. package/dist/core/__tests__/seam/broker-attach-multiclient.test.js +0 -8
  150. package/dist/core/__tests__/seam/broker-attach-stream.test.js +0 -8
  151. package/dist/core/__tests__/seam/broker-crash-teardown.test.js +0 -2
  152. package/dist/core/__tests__/tmux-driver-boundary.test.d.ts +1 -0
  153. package/dist/core/__tests__/tmux-driver-boundary.test.js +50 -0
  154. package/dist/core/activity-signal.d.ts +7 -0
  155. package/dist/core/activity-signal.js +38 -0
  156. package/dist/core/auto-update.js +2 -1
  157. package/dist/core/bootstrap.js +2 -1
  158. package/dist/core/canvas/__tests__/remote-canvas-source.test.js +1 -1
  159. package/dist/core/canvas/__tests__/remote-transport.test.js +1 -1
  160. package/dist/core/canvas/__tests__/render-remote.test.js +1 -1
  161. package/dist/core/canvas/browse/app.js +3 -2
  162. package/dist/core/canvas/browse/model.d.ts +1 -1
  163. package/dist/core/canvas/browse/model.js +0 -4
  164. package/dist/core/canvas/canvas.d.ts +22 -0
  165. package/dist/core/canvas/canvas.js +50 -18
  166. package/dist/core/canvas/crons.js +0 -6
  167. package/dist/core/canvas/db.d.ts +14 -20
  168. package/dist/core/canvas/db.js +30 -1332
  169. package/dist/core/canvas/focuses.js +0 -4
  170. package/dist/core/canvas/history.js +2 -1
  171. package/dist/core/canvas/migrations.d.ts +20 -0
  172. package/dist/core/canvas/migrations.js +1339 -0
  173. package/dist/core/canvas/nav-model.js +1 -11
  174. package/dist/core/canvas/nav-render.js +0 -8
  175. package/dist/core/canvas/remote-canvas-source.js +0 -2
  176. package/dist/core/canvas/render-source.js +31 -13
  177. package/dist/core/command-manifests/manifest.js +0 -10
  178. package/dist/core/command-manifests/schema.js +0 -4
  179. package/dist/core/command-plugins/transport/http-invoke.js +0 -14
  180. package/dist/core/command.js +0 -4
  181. package/dist/core/config.js +2 -1
  182. package/dist/core/feed/inbox.d.ts +10 -0
  183. package/dist/core/feed/inbox.js +18 -12
  184. package/dist/core/fs-utils.d.ts +9 -2
  185. package/dist/core/fs-utils.js +7 -15
  186. package/dist/core/help.js +0 -8
  187. package/dist/core/host-exports/export.d.ts +2 -2
  188. package/dist/core/host-exports/export.js +9 -12
  189. package/dist/core/human/answer.d.ts +2 -2
  190. package/dist/core/human/convention.d.ts +2 -5
  191. package/dist/core/human/convention.js +3 -13
  192. package/dist/core/human/page-schema.d.ts +2 -2
  193. package/dist/core/human/page-schema.js +2 -2
  194. package/dist/core/human/root.js +6 -23
  195. package/dist/core/human/scan.js +24 -7
  196. package/dist/core/human/tickets.d.ts +4 -1
  197. package/dist/core/human/tickets.js +20 -6
  198. package/dist/core/io.js +0 -12
  199. package/dist/core/memory/identity.js +0 -4
  200. package/dist/core/memory/inline-ref-inventory.js +3 -2
  201. package/dist/core/memory/lint.js +3 -6
  202. package/dist/core/memory-resolver.d.ts +5 -0
  203. package/dist/core/memory-resolver.js +14 -12
  204. package/dist/core/pagination.js +0 -2
  205. package/dist/core/preview-registry.d.ts +14 -0
  206. package/dist/core/preview-registry.js +2 -4
  207. package/dist/core/preview-result-path.js +2 -1
  208. package/dist/core/profiles/manifest.d.ts +37 -5
  209. package/dist/core/profiles/manifest.js +44 -24
  210. package/dist/core/profiles/select.js +0 -4
  211. package/dist/core/review/signal.js +4 -23
  212. package/dist/core/review/ticket-filter.d.ts +3 -3
  213. package/dist/core/review/ticket-filter.js +4 -9
  214. package/dist/core/runtime/__tests__/engine-route.test.js +1 -1
  215. package/dist/core/runtime/__tests__/spawn-env.test.js +0 -8
  216. package/dist/core/runtime/bearings-render.d.ts +56 -0
  217. package/dist/core/runtime/bearings-render.js +241 -0
  218. package/dist/core/runtime/bearings.d.ts +2 -17
  219. package/dist/core/runtime/bearings.js +12 -198
  220. package/dist/core/runtime/broker/auth-reload.d.ts +39 -0
  221. package/dist/core/runtime/broker/auth-reload.js +149 -0
  222. package/dist/core/runtime/broker/engine-drive.d.ts +26 -0
  223. package/dist/core/runtime/broker/engine-drive.js +257 -0
  224. package/dist/core/runtime/broker/engine-routing.d.ts +143 -0
  225. package/dist/core/runtime/broker/engine-routing.js +211 -0
  226. package/dist/core/runtime/broker/event-projection.js +3 -2
  227. package/dist/core/runtime/broker/fault-retry.js +5 -4
  228. package/dist/core/runtime/broker/frame-client.d.ts +38 -0
  229. package/dist/core/runtime/broker/frame-client.js +129 -0
  230. package/dist/core/runtime/broker/frame-dispatch.d.ts +12 -189
  231. package/dist/core/runtime/broker/frame-dispatch.js +89 -1476
  232. package/dist/core/runtime/broker/frame-engine-control.d.ts +20 -0
  233. package/dist/core/runtime/broker/frame-engine-control.js +231 -0
  234. package/dist/core/runtime/broker/frame-memory-refs.d.ts +19 -0
  235. package/dist/core/runtime/broker/frame-memory-refs.js +41 -0
  236. package/dist/core/runtime/broker/frame-model-query.d.ts +13 -0
  237. package/dist/core/runtime/broker/frame-model-query.js +69 -0
  238. package/dist/core/runtime/broker/frame-read.d.ts +19 -0
  239. package/dist/core/runtime/broker/frame-read.js +116 -0
  240. package/dist/core/runtime/broker/frame-replies.d.ts +24 -0
  241. package/dist/core/runtime/broker/frame-replies.js +64 -0
  242. package/dist/core/runtime/broker/frame-session.d.ts +34 -0
  243. package/dist/core/runtime/broker/frame-session.js +203 -0
  244. package/dist/core/runtime/broker/turn-ignition.d.ts +42 -0
  245. package/dist/core/runtime/broker/turn-ignition.js +74 -0
  246. package/dist/core/runtime/broker-extension-render.js +9 -85
  247. package/dist/core/runtime/broker-protocol.js +0 -4
  248. package/dist/core/runtime/broker-sdk.js +2 -1
  249. package/dist/core/runtime/broker.d.ts +1 -1
  250. package/dist/core/runtime/broker.js +5 -23
  251. package/dist/core/runtime/fault.js +3 -2
  252. package/dist/core/runtime/headless-pi.js +3 -2
  253. package/dist/core/runtime/host.js +2 -3
  254. package/dist/core/runtime/kickoff.js +0 -4
  255. package/dist/core/runtime/launch-target.js +2 -1
  256. package/dist/core/runtime/launch.js +3 -6
  257. package/dist/core/runtime/lifecycle.js +17 -26
  258. package/dist/core/runtime/managed-provider-cooling.d.ts +1 -1
  259. package/dist/core/runtime/naming.js +0 -2
  260. package/dist/core/runtime/nodes.js +2 -1
  261. package/dist/core/runtime/persona.js +0 -6
  262. package/dist/core/runtime/placement-tmux.js +2 -5
  263. package/dist/core/runtime/placement.js +4 -11
  264. package/dist/core/runtime/recap.js +4 -3
  265. package/dist/core/runtime/reopen.js +4 -7
  266. package/dist/core/runtime/reset.js +0 -4
  267. package/dist/core/runtime/resume-root.js +0 -2
  268. package/dist/core/runtime/revive.js +17 -13
  269. package/dist/core/runtime/session-list-cache.js +2 -2
  270. package/dist/core/runtime/shell-expansion.js +0 -2
  271. package/dist/core/runtime/spawn.js +0 -2
  272. package/dist/core/runtime/stream-watchdog.d.ts +0 -1
  273. package/dist/core/runtime/stream-watchdog.js +13 -18
  274. package/dist/core/runtime/tmux-bindings.js +0 -2
  275. package/dist/core/runtime/tmux-driver.d.ts +12 -0
  276. package/dist/core/runtime/tmux-driver.js +18 -13
  277. package/dist/core/runtime/warm-pool.js +0 -4
  278. package/dist/core/scope.js +4 -3
  279. package/dist/core/spawn.js +2 -3
  280. package/dist/core/subscription-state.js +10 -17
  281. package/dist/core/substrate/__tests__/surface-match-pre-command.test.js +3 -3
  282. package/dist/core/substrate/render.js +0 -12
  283. package/dist/core/substrate/schema.js +0 -12
  284. package/dist/core/substrate/surface-match.js +0 -2
  285. package/dist/core/termrender/display.js +2 -1
  286. package/dist/core/tui/page-host.d.ts +3 -3
  287. package/dist/core/tui/page-host.js +4 -4
  288. package/dist/core/tui/panel.js +3 -3
  289. package/dist/core/wake.js +0 -12
  290. package/dist/core/worktree.js +0 -2
  291. package/dist/daemon/__tests__/reconciler-signature.test.d.ts +1 -0
  292. package/dist/daemon/__tests__/reconciler-signature.test.js +36 -0
  293. package/dist/daemon/api/__tests__/seam/api-server.test.js +2 -16
  294. package/dist/daemon/api/__tests__/seam/b10-attach-modelauth.test.js +3 -11
  295. package/dist/daemon/api/__tests__/seam/leaf-api-parity.test.js +0 -6
  296. package/dist/daemon/api/handlers/attach.js +2 -1
  297. package/dist/daemon/api/handlers/broker-ops.js +3 -6
  298. package/dist/daemon/api/handlers/canvas.js +12 -18
  299. package/dist/daemon/api/handlers/feedback-comments.js +0 -8
  300. package/dist/daemon/api/handlers/health.js +3 -2
  301. package/dist/daemon/api/handlers/human-requests.js +0 -10
  302. package/dist/daemon/api/handlers/human.js +1 -5
  303. package/dist/daemon/api/handlers/inbox.js +0 -18
  304. package/dist/daemon/api/handlers/memory.js +1 -1
  305. package/dist/daemon/api/handlers/messages.js +4 -8
  306. package/dist/daemon/api/handlers/nodes.js +10 -21
  307. package/dist/daemon/api/handlers/reports.js +1 -1
  308. package/dist/daemon/api/handlers/reviews.js +1 -6
  309. package/dist/daemon/api/map.js +0 -6
  310. package/dist/daemon/api/router.js +0 -4
  311. package/dist/daemon/api/server.js +2 -5
  312. package/dist/daemon/boot-migrations.d.ts +14 -0
  313. package/dist/daemon/boot-migrations.js +31 -0
  314. package/dist/daemon/cron/armed-context.d.ts +21 -0
  315. package/dist/daemon/cron/armed-context.js +100 -0
  316. package/dist/daemon/cron/capture.d.ts +20 -0
  317. package/dist/daemon/cron/capture.js +45 -0
  318. package/dist/daemon/cron/disposition.d.ts +19 -0
  319. package/dist/daemon/cron/disposition.js +52 -0
  320. package/dist/daemon/cron/escalation.d.ts +12 -0
  321. package/dist/daemon/cron/escalation.js +124 -0
  322. package/dist/daemon/cron/held.d.ts +4 -0
  323. package/dist/daemon/cron/held.js +20 -0
  324. package/dist/daemon/cron/lease-recovery.d.ts +3 -0
  325. package/dist/daemon/cron/lease-recovery.js +119 -0
  326. package/dist/daemon/cron/live-runs.d.ts +11 -0
  327. package/dist/daemon/cron/live-runs.js +23 -0
  328. package/dist/daemon/cron/passes.d.ts +11 -0
  329. package/dist/daemon/cron/passes.js +78 -0
  330. package/dist/daemon/cron/settle.d.ts +28 -0
  331. package/dist/daemon/cron/settle.js +37 -0
  332. package/dist/daemon/cron/sinks.d.ts +2 -0
  333. package/dist/daemon/cron/sinks.js +100 -0
  334. package/dist/daemon/cron-run.d.ts +5 -41
  335. package/dist/daemon/cron-run.js +193 -882
  336. package/dist/daemon/crtrd-cli.js +2 -1
  337. package/dist/daemon/crtrd.js +22 -22
  338. package/dist/daemon/fleet.js +0 -4
  339. package/dist/daemon/human/deliver-action.js +2 -1
  340. package/dist/daemon/human/sweep.js +15 -4
  341. package/dist/daemon/manage.d.ts +2 -2
  342. package/dist/daemon/manage.js +4 -13
  343. package/dist/daemon/pidfile.js +2 -2
  344. package/dist/daemon/reconcilers/broker-supervision.js +26 -29
  345. package/dist/daemon/reconcilers/dormant-inbox.d.ts +1 -1
  346. package/dist/daemon/reconcilers/dormant-inbox.js +2 -1
  347. package/dist/daemon/reconcilers/live-obligation.js +2 -2
  348. package/dist/daemon/reconcilers/pending-review-submit.d.ts +1 -1
  349. package/dist/daemon/reconcilers/pending-review-submit.js +2 -1
  350. package/dist/daemon/reconcilers/storage-maintenance.d.ts +2 -1
  351. package/dist/daemon/reconcilers/storage-maintenance.js +2 -1
  352. package/dist/daemon/review/companion.js +2 -2
  353. package/dist/daemon/review/sweep.js +8 -3
  354. package/dist/migrations/001-surfaces-frontmatter.js +0 -6
  355. package/dist/migrations/corpus.js +2 -5
  356. package/dist/migrations/registry.js +15 -2
  357. package/dist/pi-extensions/__tests__/canvas-stophook-agentend.test.js +0 -4
  358. package/dist/pi-extensions/broker-local.js +2 -1
  359. package/dist/pi-extensions/canvas-bash-valve.js +3 -17
  360. package/dist/pi-extensions/canvas-context-intro.js +2 -7
  361. package/dist/pi-extensions/canvas-doc-substrate.js +2 -3
  362. package/dist/pi-extensions/canvas-goal-capture.js +2 -1
  363. package/dist/pi-extensions/canvas-inbox-watcher.js +5 -12
  364. package/dist/pi-extensions/canvas-passive-context.js +2 -5
  365. package/dist/pi-extensions/canvas-preview-result.js +2 -1
  366. package/dist/pi-extensions/canvas-prompt-scrub.js +2 -1
  367. package/dist/pi-extensions/canvas-recap.js +3 -16
  368. package/dist/pi-extensions/canvas-review-boundary.js +2 -5
  369. package/dist/pi-extensions/canvas-stophook.js +2 -26
  370. package/dist/pi-extensions/canvas-structured-output.js +2 -1
  371. package/dist/pi-extensions/canvas-tool-guide.js +2 -1
  372. package/dist/shared/__tests__/env-boundary.test.d.ts +1 -0
  373. package/dist/shared/__tests__/env-boundary.test.js +93 -0
  374. package/dist/shared/env.d.ts +68 -0
  375. package/dist/shared/env.js +171 -0
  376. package/package.json +3 -1
  377. package/runtime.lock.json +2 -2
  378. package/dist/core/canvas/render.d.ts +0 -47
  379. package/dist/core/canvas/render.js +0 -245
@@ -1,245 +0,0 @@
1
- // render.ts — the db-backed (sync, `openDb`) half of canvas rendering.
2
- //
3
- // Holds the SYNC renderers that read the local canvas.db directly
4
- // (renderTree/renderForest/dashboardRows/dashboardRowsAll/enrichRow(s)/loadPreview
5
- // /isNodeStreaming). The openDb-FREE `*FromSource` variants + every pure/disk
6
- // helper they share live in ./render-source.ts; this module imports those helpers
7
- // (one direction) and RE-EXPORTS the whole render-source module, so existing
8
- // importers of `render.js` keep resolving both the sync and the FromSource APIs
9
- // unchanged. A caller that must stay off openDb imports from ./render-source.js
10
- // directly instead.
11
- //
12
- // `subscriptionsOf(nodeId)` returns the nodes a node subscribes to (its reports /
13
- // children); walking it recursively walks DOWN the org chart.
14
- import { getNode, listNodes, subscriptionsOf, view } from './canvas.js';
15
- import { fullName } from './labels.js';
16
- import { countTickets, ticketCountsForNodes } from './attention.js';
17
- import { listFocuses } from './focuses.js';
18
- import { resolveNodeVisual, faultSummary } from './status-glyph.js';
19
- import { readNodeTelemetry, fmtCtx, hangingFor, isStreaming, dashboardRowFromNodeRow, readGoalText, readSessionParts, } from './render-source.js';
20
- // Re-export the openDb-free half so `render.js` importers keep resolving the
21
- // FromSource variants + shared types/helpers unchanged.
22
- export * from './render-source.js';
23
- // ---------------------------------------------------------------------------
24
- // Tree builder (sync, db-backed)
25
- // ---------------------------------------------------------------------------
26
- /** Build one line of the ASCII tree. */
27
- function nodeLine(nodeId, indent, connector) {
28
- const node = getNode(nodeId);
29
- if (node === null) {
30
- // Node id is in the db but meta.json is gone — paranoid guard.
31
- return `${indent}${connector}? <missing meta: ${nodeId}>`;
32
- }
33
- const hanging = hangingFor(node);
34
- const glyph = resolveNodeVisual(node.status, { hanging }).glyph;
35
- const tel = readNodeTelemetry(nodeId);
36
- const ctx = fmtCtx(tel.tokens_in);
37
- const asks = countTickets(nodeId);
38
- const askSuffix = asks > 0 ? ` ⚑${asks}` : '';
39
- const faultSuffix = hanging !== null ? ` · ${faultSummary(hanging)}` : '';
40
- return `${indent}${connector}${glyph} ${fullName(node)} [${node.kind}/${node.mode}] ctx ${ctx}${askSuffix}${faultSuffix}`;
41
- }
42
- /**
43
- * Recursively walk the subscription sub-DAG rooted at `nodeId`, appending
44
- * rendered lines to `out`. Cycle-safe via `visited`.
45
- */
46
- function walkTree(nodeId, indent, isLast, visited, out) {
47
- // Guard: if we have already rendered this node in this traversal, emit a
48
- // back-ref marker instead of recursing (prevents infinite loops in graphs
49
- // with cycles introduced by manual edge manipulation).
50
- if (visited.has(nodeId)) {
51
- // The line for this node was already emitted by the caller; just return.
52
- return;
53
- }
54
- visited.add(nodeId);
55
- const connector = isLast ? '└─ ' : '├─ ';
56
- out.push(nodeLine(nodeId, indent, connector));
57
- const children = subscriptionsOf(nodeId);
58
- const childIndent = indent + (isLast ? ' ' : '│ ');
59
- for (let i = 0; i < children.length; i++) {
60
- const child = children[i];
61
- const childIsLast = i === children.length - 1;
62
- if (visited.has(child.node_id)) {
63
- // Cycle reference — show the back-edge without recursing.
64
- const cycleConnector = childIsLast ? '└─ ' : '├─ ';
65
- out.push(`${childIndent}${cycleConnector}↺ <cycle: ${child.node_id}>`);
66
- continue;
67
- }
68
- walkTree(child.node_id, childIndent, childIsLast, visited, out);
69
- }
70
- }
71
- // ---------------------------------------------------------------------------
72
- // Public API (sync)
73
- // ---------------------------------------------------------------------------
74
- /**
75
- * Render the subscription sub-DAG rooted at `rootId` as an ASCII tree.
76
- * The root is the first line (no connector prefix); children are indented.
77
- *
78
- * Each line: `<glyph> <name> [<kind>/<mode>] ctx <Nk>[ ⚑<asks>]`
79
- *
80
- * Returns a multi-line string (no trailing newline).
81
- */
82
- export function renderTree(rootId) {
83
- const node = getNode(rootId);
84
- if (node === null)
85
- return `? <missing node: ${rootId}>`;
86
- const tel = readNodeTelemetry(rootId);
87
- const ctx = fmtCtx(tel.tokens_in);
88
- const asks = countTickets(rootId);
89
- const askSuffix = asks > 0 ? ` ⚑${asks}` : '';
90
- const hanging = hangingFor(node);
91
- const glyph = resolveNodeVisual(node.status, { hanging }).glyph;
92
- const faultSuffix = hanging !== null ? ` · ${faultSummary(hanging)}` : '';
93
- const out = [];
94
- out.push(`${glyph} ${fullName(node)} [${node.kind}/${node.mode}] ctx ${ctx}${askSuffix}${faultSuffix}`);
95
- // visited starts with root already rendered (walkTree doesn't re-emit root).
96
- const visited = new Set([rootId]);
97
- const children = subscriptionsOf(rootId);
98
- for (let i = 0; i < children.length; i++) {
99
- const child = children[i];
100
- const isLast = i === children.length - 1;
101
- walkTree(child.node_id, '', isLast, visited, out);
102
- }
103
- return out.join('\n');
104
- }
105
- /**
106
- * Render all canvas roots as a forest. A root is a node with no subscribers
107
- * (no one subscribes to it = it has no managers in the org chart).
108
- *
109
- * If there are no roots on the canvas, returns a placeholder string.
110
- */
111
- export function renderForest() {
112
- const all = listNodes();
113
- if (all.length === 0)
114
- return '(canvas is empty)';
115
- // A root has no subscribers (nobody is watching it). We discover this by
116
- // looking for nodes whose node_id never appears as a "to" side of a
117
- // subscribes_to edge — equivalently, nodes with parent === null are the
118
- // authoritative roots per the spawn contract (spawn sets parent and records
119
- // a spawned_by edge + subscribe). Fall back to parent===null because querying
120
- // the full edge table would require opening the db here.
121
- //
122
- // Fine to use parent===null: roots are created by bare `crtr` / `node new --root`
123
- // without a parent; non-roots always have a parent.
124
- //
125
- // Filter to LIVE roots: each `/new` parks a `done` root (option C relaunch)
126
- // with parent===null, so an unfiltered forest would render every parked root
127
- // as a sibling tree and clutter the dashboard. Showing only active|idle roots
128
- // drops parked (`done`) roots and, as a bonus, stray `dead`/`canceled` roots.
129
- // Parked roots stay reachable by id (inspect / revive / focus).
130
- const roots = all.filter((n) => n.parent === null && (n.status === 'active' || n.status === 'idle'));
131
- // No LIVE roots: render an empty/placeholder forest rather than resurrecting
132
- // parked (`done`) / dead / canceled roots. The live-only filter is the intent;
133
- // falling back to all-status roots would re-clutter the dashboard with the very
134
- // parked trees the filter drops (e.g. a sole root `/quit`'d with no `/new`).
135
- // Parked roots stay reachable by id (inspect / revive / focus).
136
- if (roots.length === 0)
137
- return '(no live roots)';
138
- const parts = [];
139
- for (const r of roots) {
140
- parts.push(renderTree(r.node_id));
141
- }
142
- return parts.join('\n\n');
143
- }
144
- // ---------------------------------------------------------------------------
145
- // Structured row builder (sync, db-backed)
146
- // ---------------------------------------------------------------------------
147
- /** One row per node visible in the sub-DAG of `rootId` (including root). */
148
- export function dashboardRows(rootId) {
149
- const ids = [rootId, ...view(rootId)];
150
- return ids.flatMap((id) => {
151
- const node = getNode(id);
152
- if (node === null)
153
- return [];
154
- const tel = readNodeTelemetry(id);
155
- return [{
156
- node_id: id,
157
- name: fullName(node),
158
- handle: node.name,
159
- description: node.description,
160
- status: node.status,
161
- kind: node.kind,
162
- mode: node.mode,
163
- ctx_tokens: tel.tokens_in ?? 0,
164
- asks: countTickets(id),
165
- cwd: node.cwd,
166
- created: node.created,
167
- }];
168
- });
169
- }
170
- /**
171
- * CHEAP boot builder — one row per node across the entire canvas, with only the
172
- * fields that need no per-node meta/telemetry/session read. Two db queries total:
173
- * `listNodes()` + `listFocuses()` (the focus set replaces per-node getFocusByNode
174
- * calls). See {@link dashboardRowFromNodeRow} for the per-row projection, and
175
- * {@link enrichRow}/{@link enrichRows}/{@link loadPreview} for the lazy fields.
176
- */
177
- export function dashboardRowsAll() {
178
- const focusedNodeIds = new Set(listFocuses().map((f) => f.node_id));
179
- return listNodes().map((row) => dashboardRowFromNodeRow(row, focusedNodeIds, false));
180
- }
181
- // ---------------------------------------------------------------------------
182
- // Lazy enrichment API (sync, db-backed) — fold the expensive per-node reads into
183
- // rows on demand, for the VISIBLE viewport / top tiers only (never all up front).
184
- // Each function mutates the row in place and is idempotent via a guard flag.
185
- // ---------------------------------------------------------------------------
186
- /** Fold the cheap-boot row's deferred fields in for ONE row: the full label
187
- * (meta.description → fullName), ctx tokens (telemetry.json), and ⚑ asks. One
188
- * meta read + one telemetry read + one ticket scan. Idempotent (no-op once enriched).
189
- * For a batch, prefer {@link enrichRows} — it scans each cwd's ticket inbox once. */
190
- export function enrichRow(row) {
191
- if (row.enriched === true)
192
- return row;
193
- const meta = getNode(row.node_id);
194
- if (meta !== null) {
195
- row.name = fullName(meta);
196
- row.handle = meta.name;
197
- row.description = meta.description;
198
- }
199
- row.ctx_tokens = readNodeTelemetry(row.node_id).tokens_in ?? 0;
200
- row.asks = countTickets(row.node_id);
201
- row.enriched = true;
202
- return row;
203
- }
204
- /** Batch {@link enrichRow}: enrich every not-yet-enriched row, scanning each
205
- * distinct cwd's ticket inbox exactly ONCE (via `ticketCountsForNodes`) instead
206
- * of per row. Use this for a whole viewport / the full forest; mutates each row in place. */
207
- export function enrichRows(rows) {
208
- const todo = rows.filter((r) => r.enriched !== true);
209
- if (todo.length === 0)
210
- return;
211
- const asks = ticketCountsForNodes(todo.map((r) => r.node_id));
212
- for (const row of todo) {
213
- const meta = getNode(row.node_id);
214
- if (meta !== null) {
215
- row.name = fullName(meta);
216
- row.handle = meta.name;
217
- row.description = meta.description;
218
- }
219
- row.ctx_tokens = readNodeTelemetry(row.node_id).tokens_in ?? 0;
220
- row.asks = asks[row.node_id] ?? 0;
221
- row.enriched = true;
222
- }
223
- }
224
- /** Load the SELECTED row's preview text: the spawn `goal` (initial-prompt.md) plus
225
- * the whole-conversation `prompts` and the `lastAssistant` reply — the latter two
226
- * folded into ONE session-file read (see {@link readSessionParts}). Mutates the row
227
- * in place; idempotent. Call only for the cursor row (and lazily/in-background to
228
- * warm the prompt super-search corpus), never on the boot path. */
229
- export function loadPreview(row) {
230
- if (row.previewLoaded === true)
231
- return row;
232
- row.goal = readGoalText(row.node_id);
233
- const meta = getNode(row.node_id);
234
- const { prompts, lastAssistant } = readSessionParts(meta?.pi_session_file);
235
- row.prompts = prompts;
236
- row.lastAssistant = lastAssistant;
237
- row.previewLoaded = true;
238
- return row;
239
- }
240
- /** {@link isStreaming} keyed by node id alone — hydrates the broker pid off the
241
- * db row. The exported "is this node actively generating right now?" guard so a
242
- * reap never nukes a node mid-first-turn before its output lands on disk. */
243
- export function isNodeStreaming(nodeId) {
244
- return isStreaming(nodeId, getNode(nodeId)?.pi_pid ?? null);
245
- }