@north-light/cli 0.3.530 → 0.3.532

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 (495) hide show
  1. package/dist/clients/attach/session/connection.js +1 -1
  2. package/dist/clients/attach/session/reconnect.js +1 -1
  3. package/dist/clients/attach/viewer.js +508 -508
  4. package/dist/core/async-array.d.ts +7 -0
  5. package/dist/core/async-array.js +1 -0
  6. package/dist/core/audit.d.ts +1 -1
  7. package/dist/core/audit.js +2 -2
  8. package/dist/core/canvas/attention.d.ts +4 -4
  9. package/dist/core/canvas/attention.js +1 -1
  10. package/dist/core/canvas/boot.d.ts +4 -4
  11. package/dist/core/canvas/boot.js +1 -1
  12. package/dist/core/canvas/canvas.d.ts +59 -59
  13. package/dist/core/canvas/canvas.js +19 -19
  14. package/dist/core/canvas/context-strip.js +2 -2
  15. package/dist/core/canvas/crons.d.ts +27 -27
  16. package/dist/core/canvas/crons.js +11 -11
  17. package/dist/core/canvas/daemon-actions.d.ts +10 -10
  18. package/dist/core/canvas/daemon-actions.js +8 -8
  19. package/dist/core/canvas/daemon-owner.d.ts +3 -3
  20. package/dist/core/canvas/daemon-owner.js +2 -2
  21. package/dist/core/canvas/db.d.ts +19 -30
  22. package/dist/core/canvas/db.js +3 -2
  23. package/dist/core/canvas/deliveries.d.ts +16 -16
  24. package/dist/core/canvas/deliveries.js +24 -24
  25. package/dist/core/canvas/executions.d.ts +8 -8
  26. package/dist/core/canvas/executions.js +1 -1
  27. package/dist/core/canvas/focuses.d.ts +8 -8
  28. package/dist/core/canvas/focuses.js +1 -1
  29. package/dist/core/canvas/history.d.ts +3 -3
  30. package/dist/core/canvas/history.js +9 -9
  31. package/dist/core/canvas/install-id.d.ts +1 -1
  32. package/dist/core/canvas/install-id.js +1 -1
  33. package/dist/core/canvas/managed-worktree-sweep-candidates.d.ts +1 -1
  34. package/dist/core/canvas/managed-worktree-sweep-candidates.js +2 -2
  35. package/dist/core/canvas/memory-reads.d.ts +6 -6
  36. package/dist/core/canvas/memory-reads.js +1 -1
  37. package/dist/core/canvas/nav-model.d.ts +13 -13
  38. package/dist/core/canvas/nav-model.js +1 -1
  39. package/dist/core/canvas/node-agent-paths.d.ts +6 -6
  40. package/dist/core/canvas/node-agent-paths.js +1 -1
  41. package/dist/core/canvas/node-tokens.d.ts +7 -7
  42. package/dist/core/canvas/node-tokens.js +3 -3
  43. package/dist/core/canvas/outcome-actions.d.ts +5 -5
  44. package/dist/core/canvas/outcome-actions.js +3 -3
  45. package/dist/core/canvas/recovery.d.ts +26 -26
  46. package/dist/core/canvas/recovery.js +2 -2
  47. package/dist/core/canvas/render-source.d.ts +1 -1
  48. package/dist/core/canvas/render-source.js +1 -1
  49. package/dist/core/canvas/sessions.d.ts +10 -10
  50. package/dist/core/canvas/sessions.js +4 -4
  51. package/dist/core/canvas/source.js +1 -1
  52. package/dist/core/canvas/structured-requests.d.ts +15 -15
  53. package/dist/core/canvas/structured-requests.js +5 -5
  54. package/dist/core/canvas/tree.d.ts +9 -9
  55. package/dist/core/canvas/tree.js +5 -5
  56. package/dist/core/canvas/waits.d.ts +13 -13
  57. package/dist/core/canvas/waits.js +6 -6
  58. package/dist/core/canvas/worktrees.d.ts +15 -15
  59. package/dist/core/canvas/worktrees.js +1 -1
  60. package/dist/core/command-hooks/transport/exec-lifecycle.js +1 -1
  61. package/dist/core/conversation-store/file-store.d.ts +7 -7
  62. package/dist/core/conversation-store/file-store.js +9 -9
  63. package/dist/core/conversation-store/index.d.ts +16 -14
  64. package/dist/core/conversation-store/index.js +1 -1
  65. package/dist/core/conversation-store/listener.js +5 -5
  66. package/dist/core/conversation-store/patch.d.ts +3 -1
  67. package/dist/core/conversation-store/patch.js +1 -1
  68. package/dist/core/feed/feed.js +3 -3
  69. package/dist/core/feed/inbox.d.ts +2 -2
  70. package/dist/core/feed/inbox.js +1 -1
  71. package/dist/core/feed/messages.d.ts +11 -12
  72. package/dist/core/feed/messages.js +5 -5
  73. package/dist/core/feed/reports.d.ts +4 -4
  74. package/dist/core/feed/reports.js +2 -2
  75. package/dist/core/grants/cover.d.ts +1 -1
  76. package/dist/core/grants/cover.js +1 -1
  77. package/dist/core/grants/local.d.ts +1 -1
  78. package/dist/core/grants/local.js +1 -1
  79. package/dist/core/grants/mirror.d.ts +19 -19
  80. package/dist/core/grants/mirror.js +2 -2
  81. package/dist/core/grants/on-sync.d.ts +1 -1
  82. package/dist/core/grants/on-sync.js +1 -1
  83. package/dist/core/grants/remove.js +1 -1
  84. package/dist/core/grants/sync.js +1 -1
  85. package/dist/core/graph/access.d.ts +17 -17
  86. package/dist/core/graph/access.js +3 -3
  87. package/dist/core/graph/custom.d.ts +16 -16
  88. package/dist/core/graph/custom.js +9 -9
  89. package/dist/core/graph/deletion.d.ts +3 -7
  90. package/dist/core/graph/deletion.js +4 -4
  91. package/dist/core/graph/documents.d.ts +24 -27
  92. package/dist/core/graph/documents.js +7 -7
  93. package/dist/core/graph/edges.d.ts +13 -13
  94. package/dist/core/graph/edges.js +1 -1
  95. package/dist/core/graph/events.d.ts +7 -9
  96. package/dist/core/graph/events.js +8 -8
  97. package/dist/core/graph/exposures.d.ts +6 -6
  98. package/dist/core/graph/exposures.js +4 -4
  99. package/dist/core/graph/jobs.d.ts +6 -8
  100. package/dist/core/graph/jobs.js +2 -2
  101. package/dist/core/graph/kinds/action.js +1 -1
  102. package/dist/core/graph/kinds/custom.js +2 -2
  103. package/dist/core/graph/kinds/document.d.ts +1 -0
  104. package/dist/core/graph/kinds/document.js +4 -4
  105. package/dist/core/graph/kinds/dto.d.ts +2 -2
  106. package/dist/core/graph/kinds/dto.js +1 -1
  107. package/dist/core/graph/kinds/job.js +2 -2
  108. package/dist/core/graph/kinds/kind.d.ts +6 -8
  109. package/dist/core/graph/kinds/kind.js +1 -1
  110. package/dist/core/graph/kinds/node.js +5 -5
  111. package/dist/core/graph/kinds/owner.js +2 -2
  112. package/dist/core/graph/kinds/registry.d.ts +6 -9
  113. package/dist/core/graph/kinds/registry.js +1 -1
  114. package/dist/core/graph/names.d.ts +6 -6
  115. package/dist/core/graph/names.js +3 -3
  116. package/dist/core/graph/object-waits.d.ts +4 -7
  117. package/dist/core/graph/object-waits.js +1 -1
  118. package/dist/core/graph/objects.d.ts +14 -14
  119. package/dist/core/graph/objects.js +9 -9
  120. package/dist/core/graph/package-docs.d.ts +2 -7
  121. package/dist/core/graph/package-docs.js +5 -5
  122. package/dist/core/graph/package-kinds.d.ts +2 -5
  123. package/dist/core/graph/package-kinds.js +1 -1
  124. package/dist/core/graph/package-reconcile.d.ts +2 -5
  125. package/dist/core/graph/package-reconcile.js +1 -1
  126. package/dist/core/graph/reader.d.ts +18 -18
  127. package/dist/core/graph/reader.js +3 -3
  128. package/dist/core/graph/receivers.d.ts +4 -4
  129. package/dist/core/graph/receivers.js +5 -5
  130. package/dist/core/graph/repo-sync/exchange.d.ts +3 -7
  131. package/dist/core/graph/repo-sync/exchange.js +2 -2
  132. package/dist/core/graph/repo-sync/repos.d.ts +7 -5
  133. package/dist/core/graph/repo-sync/repos.js +3 -3
  134. package/dist/core/graph/repo-sync/sync.d.ts +3 -6
  135. package/dist/core/graph/repo-sync/sync.js +2 -2
  136. package/dist/core/graph/rules.d.ts +5 -5
  137. package/dist/core/graph/rules.js +3 -3
  138. package/dist/core/graph/spaces/app.js +1 -1
  139. package/dist/core/graph/spaces/index.d.ts +4 -5
  140. package/dist/core/graph/spaces/index.js +1 -1
  141. package/dist/core/graph/spaces/own-memory.d.ts +4 -4
  142. package/dist/core/graph/spaces/own-memory.js +1 -1
  143. package/dist/core/graph/spaces/person.js +3 -3
  144. package/dist/core/graph/spaces/repo.d.ts +1 -1
  145. package/dist/core/graph/spaces/repo.js +1 -1
  146. package/dist/core/graph/watches.d.ts +15 -15
  147. package/dist/core/graph/watches.js +10 -10
  148. package/dist/core/human/feedback-companion.d.ts +2 -2
  149. package/dist/core/human/feedback-companion.js +1 -1
  150. package/dist/core/human/feedback.d.ts +3 -3
  151. package/dist/core/human/feedback.js +1 -1
  152. package/dist/core/human/requests.d.ts +34 -33
  153. package/dist/core/human/requests.js +20 -20
  154. package/dist/core/human/scan.d.ts +2 -2
  155. package/dist/core/human/scan.js +1 -1
  156. package/dist/core/human/tickets.d.ts +9 -9
  157. package/dist/core/human/tickets.js +1 -1
  158. package/dist/core/llm/app-rungs.d.ts +1 -1
  159. package/dist/core/llm/app-rungs.js +1 -1
  160. package/dist/core/llm/run.js +2 -2
  161. package/dist/core/peer/directory.d.ts +1 -1
  162. package/dist/core/peer/directory.js +1 -1
  163. package/dist/core/peer/envelope.d.ts +3 -3
  164. package/dist/core/peer/envelope.js +1 -1
  165. package/dist/core/peer/home.d.ts +13 -7
  166. package/dist/core/peer/home.js +2 -2
  167. package/dist/core/peer/ingest.d.ts +6 -6
  168. package/dist/core/peer/ingest.js +1 -1
  169. package/dist/core/peer/outbox-store.d.ts +14 -14
  170. package/dist/core/peer/outbox-store.js +5 -5
  171. package/dist/core/peer/receiver.d.ts +2 -2
  172. package/dist/core/peer/receiver.js +1 -1
  173. package/dist/core/peer/stubs.d.ts +10 -10
  174. package/dist/core/peer/stubs.js +1 -1
  175. package/dist/core/providers/approval.d.ts +2 -2
  176. package/dist/core/providers/approval.js +2 -2
  177. package/dist/core/providers/audit.d.ts +3 -3
  178. package/dist/core/providers/audit.js +2 -2
  179. package/dist/core/providers/bundles.js +2 -2
  180. package/dist/core/providers/call.d.ts +2 -2
  181. package/dist/core/providers/call.js +1 -1
  182. package/dist/core/providers/files.d.ts +1 -1
  183. package/dist/core/providers/files.js +1 -1
  184. package/dist/core/providers/mint.js +1 -1
  185. package/dist/core/providers/receipts.d.ts +1 -1
  186. package/dist/core/providers/receipts.js +2 -2
  187. package/dist/core/review/birth.js +1 -1
  188. package/dist/core/review/comments.d.ts +19 -19
  189. package/dist/core/review/comments.js +5 -5
  190. package/dist/core/review/companion.d.ts +1 -1
  191. package/dist/core/review/companion.js +1 -1
  192. package/dist/core/review/document.d.ts +3 -3
  193. package/dist/core/review/document.js +2 -2
  194. package/dist/core/review/fork.js +2 -2
  195. package/dist/core/review/realize.js +1 -1
  196. package/dist/core/review/remap.d.ts +2 -2
  197. package/dist/core/review/remap.js +4 -4
  198. package/dist/core/review/stage.d.ts +1 -1
  199. package/dist/core/review/stage.js +1 -1
  200. package/dist/core/review/store.d.ts +21 -21
  201. package/dist/core/review/store.js +1 -1
  202. package/dist/core/runs/activity.d.ts +1 -1
  203. package/dist/core/runs/activity.js +5 -5
  204. package/dist/core/runs/confinement.d.ts +7 -7
  205. package/dist/core/runs/confinement.js +2 -2
  206. package/dist/core/runs/events.d.ts +12 -12
  207. package/dist/core/runs/events.js +4 -4
  208. package/dist/core/runs/operations.d.ts +11 -11
  209. package/dist/core/runs/operations.js +5 -5
  210. package/dist/core/runs/questions.d.ts +10 -10
  211. package/dist/core/runs/questions.js +3 -3
  212. package/dist/core/runtime/auth-reload.js +1 -1
  213. package/dist/core/runtime/bearings.d.ts +5 -5
  214. package/dist/core/runtime/bearings.js +6 -6
  215. package/dist/core/runtime/broker-inventory.js +1 -1
  216. package/dist/core/runtime/broker-request.js +1 -1
  217. package/dist/core/runtime/broker.js +1 -1
  218. package/dist/core/runtime/close.d.ts +3 -3
  219. package/dist/core/runtime/close.js +1 -1
  220. package/dist/core/runtime/deliver-live.js +1 -1
  221. package/dist/core/runtime/fleet.d.ts +2 -2
  222. package/dist/core/runtime/host.d.ts +3 -3
  223. package/dist/core/runtime/host.js +3 -3
  224. package/dist/core/runtime/kickoff.d.ts +12 -12
  225. package/dist/core/runtime/kickoff.js +17 -17
  226. package/dist/core/runtime/launch-target.d.ts +1 -1
  227. package/dist/core/runtime/launch-target.js +1 -1
  228. package/dist/core/runtime/ledger.d.ts +3 -3
  229. package/dist/core/runtime/ledger.js +3 -3
  230. package/dist/core/runtime/lifecycle.d.ts +1 -1
  231. package/dist/core/runtime/lifecycle.js +2 -2
  232. package/dist/core/runtime/memory-admission.js +1 -1
  233. package/dist/core/runtime/model-swap.d.ts +2 -2
  234. package/dist/core/runtime/model-swap.js +1 -1
  235. package/dist/core/runtime/node-read.d.ts +1 -1
  236. package/dist/core/runtime/node-read.js +2 -2
  237. package/dist/core/runtime/nodes.d.ts +6 -6
  238. package/dist/core/runtime/nodes.js +1 -1
  239. package/dist/core/runtime/outcome-document.d.ts +1 -1
  240. package/dist/core/runtime/outcome-document.js +1 -1
  241. package/dist/core/runtime/persona.d.ts +3 -3
  242. package/dist/core/runtime/persona.js +2 -2
  243. package/dist/core/runtime/placement.d.ts +11 -11
  244. package/dist/core/runtime/placement.js +1 -1
  245. package/dist/core/runtime/promote.d.ts +3 -3
  246. package/dist/core/runtime/promote.js +1 -1
  247. package/dist/core/runtime/recycle.js +1 -1
  248. package/dist/core/runtime/reopen.d.ts +5 -5
  249. package/dist/core/runtime/reopen.js +1 -1
  250. package/dist/core/runtime/reset.d.ts +4 -4
  251. package/dist/core/runtime/reset.js +1 -1
  252. package/dist/core/runtime/revive-all.d.ts +2 -2
  253. package/dist/core/runtime/revive-all.js +1 -1
  254. package/dist/core/runtime/revive.d.ts +4 -4
  255. package/dist/core/runtime/revive.js +2 -2
  256. package/dist/core/runtime/roadmap.d.ts +6 -6
  257. package/dist/core/runtime/roadmap.js +5 -5
  258. package/dist/core/runtime/session-branch.d.ts +1 -1
  259. package/dist/core/runtime/session-branch.js +1 -1
  260. package/dist/core/runtime/session-list-cache.js +1 -1
  261. package/dist/core/runtime/situational-live.js +1 -1
  262. package/dist/core/runtime/spawn.d.ts +2 -2
  263. package/dist/core/runtime/spawn.js +2 -2
  264. package/dist/core/runtime/stop-guard.d.ts +2 -2
  265. package/dist/core/runtime/stop-guard.js +3 -3
  266. package/dist/core/runtime/warm-pool.d.ts +2 -2
  267. package/dist/core/runtime/warm-pool.js +1 -1
  268. package/dist/core/spaces/mounts.d.ts +2 -2
  269. package/dist/core/spaces/mounts.js +1 -1
  270. package/dist/core/spaces/permissions.d.ts +1 -1
  271. package/dist/core/spaces/permissions.js +1 -1
  272. package/dist/core/spaces/process.d.ts +1 -1
  273. package/dist/core/spaces/process.js +1 -1
  274. package/dist/core/spaces/space.js +1 -1
  275. package/dist/core/spaces/stop.d.ts +3 -3
  276. package/dist/core/spaces/stop.js +2 -2
  277. package/dist/core/spaces/users.d.ts +6 -6
  278. package/dist/core/spaces/users.js +1 -1
  279. package/dist/core/storage/attachments.d.ts +2 -2
  280. package/dist/core/storage/attachments.js +1 -1
  281. package/dist/core/storage/shares.d.ts +2 -2
  282. package/dist/core/storage/shares.js +1 -1
  283. package/dist/core/storage/tables.d.ts +21 -21
  284. package/dist/core/storage/tables.js +3 -3
  285. package/dist/core/substrate/delivery/corpus.d.ts +5 -8
  286. package/dist/core/substrate/delivery/corpus.js +3 -3
  287. package/dist/core/substrate/delivery/deliver.d.ts +10 -15
  288. package/dist/core/substrate/delivery/deliver.js +3 -3
  289. package/dist/core/substrate/delivery/plan.d.ts +2 -12
  290. package/dist/core/substrate/delivery/plan.js +3 -3
  291. package/dist/core/substrate/delivery/render-boot.d.ts +4 -4
  292. package/dist/core/substrate/delivery/render-boot.js +18 -18
  293. package/dist/core/substrate/delivery/render-event.d.ts +7 -14
  294. package/dist/core/substrate/delivery/render-event.js +4 -4
  295. package/dist/core/substrate/subject.d.ts +2 -2
  296. package/dist/core/substrate/subject.js +1 -1
  297. package/dist/core/usage/ledger.d.ts +6 -6
  298. package/dist/core/usage/ledger.js +4 -4
  299. package/dist/core/worktree-close.js +4 -4
  300. package/dist/core/worktree-mutation-async.js +7 -7
  301. package/dist/core/worktree-quarantine.js +1 -1
  302. package/dist/core/worktree-sweep.d.ts +1 -1
  303. package/dist/core/worktree-sweep.js +6 -6
  304. package/dist/core/worktree.d.ts +5 -5
  305. package/dist/core/worktree.js +13 -13
  306. package/dist/daemon/analytics/compute.d.ts +2 -2
  307. package/dist/daemon/analytics/compute.js +1 -1
  308. package/dist/daemon/api/app-listener.d.ts +4 -4
  309. package/dist/daemon/api/app-listener.js +13 -13
  310. package/dist/daemon/api/bridge.js +5 -5
  311. package/dist/daemon/api/document-listener.js +6 -6
  312. package/dist/daemon/api/handlers/analytics.js +1 -1
  313. package/dist/daemon/api/handlers/attach.js +1 -1
  314. package/dist/daemon/api/handlers/bash-jobs.js +1 -1
  315. package/dist/daemon/api/handlers/bash.js +1 -1
  316. package/dist/daemon/api/handlers/broker-ops.d.ts +1 -1
  317. package/dist/daemon/api/handlers/broker-ops.js +1 -1
  318. package/dist/daemon/api/handlers/broker-recovery.d.ts +1 -1
  319. package/dist/daemon/api/handlers/broker-recovery.js +1 -1
  320. package/dist/daemon/api/handlers/broker-signals.d.ts +2 -2
  321. package/dist/daemon/api/handlers/broker-signals.js +2 -2
  322. package/dist/daemon/api/handlers/canvas.d.ts +1 -1
  323. package/dist/daemon/api/handlers/canvas.js +4 -4
  324. package/dist/daemon/api/handlers/chat-inventory.js +1 -1
  325. package/dist/daemon/api/handlers/crons.js +1 -1
  326. package/dist/daemon/api/handlers/custom-objects.d.ts +4 -4
  327. package/dist/daemon/api/handlers/custom-objects.js +3 -3
  328. package/dist/daemon/api/handlers/delivery-retry.js +1 -1
  329. package/dist/daemon/api/handlers/delivery.js +1 -1
  330. package/dist/daemon/api/handlers/docs.d.ts +4 -4
  331. package/dist/daemon/api/handlers/docs.js +1 -1
  332. package/dist/daemon/api/handlers/feedback-comments.js +3 -3
  333. package/dist/daemon/api/handlers/files.js +1 -1
  334. package/dist/daemon/api/handlers/focus.js +1 -1
  335. package/dist/daemon/api/handlers/health.js +3 -3
  336. package/dist/daemon/api/handlers/hook-exec.js +1 -1
  337. package/dist/daemon/api/handlers/human-requests.js +1 -1
  338. package/dist/daemon/api/handlers/inbox-page.d.ts +1 -1
  339. package/dist/daemon/api/handlers/inbox-page.js +1 -1
  340. package/dist/daemon/api/handlers/inbox.d.ts +1 -1
  341. package/dist/daemon/api/handlers/inbox.js +1 -1
  342. package/dist/daemon/api/handlers/llm.d.ts +1 -1
  343. package/dist/daemon/api/handlers/llm.js +3 -3
  344. package/dist/daemon/api/handlers/memory-reads.js +1 -1
  345. package/dist/daemon/api/handlers/memory.d.ts +5 -5
  346. package/dist/daemon/api/handlers/memory.js +5 -5
  347. package/dist/daemon/api/handlers/messages.js +2 -2
  348. package/dist/daemon/api/handlers/node-events.d.ts +2 -2
  349. package/dist/daemon/api/handlers/node-events.js +3 -3
  350. package/dist/daemon/api/handlers/node-outcomes.js +1 -1
  351. package/dist/daemon/api/handlers/node-records.js +2 -2
  352. package/dist/daemon/api/handlers/nodes.d.ts +1 -1
  353. package/dist/daemon/api/handlers/nodes.js +1 -1
  354. package/dist/daemon/api/handlers/objects.js +3 -3
  355. package/dist/daemon/api/handlers/package-docs.js +1 -1
  356. package/dist/daemon/api/handlers/plugin-app-token.d.ts +1 -1
  357. package/dist/daemon/api/handlers/plugin-app-token.js +1 -1
  358. package/dist/daemon/api/handlers/profiles.d.ts +3 -3
  359. package/dist/daemon/api/handlers/profiles.js +1 -1
  360. package/dist/daemon/api/handlers/providers.d.ts +1 -1
  361. package/dist/daemon/api/handlers/providers.js +1 -1
  362. package/dist/daemon/api/handlers/questions.js +1 -1
  363. package/dist/daemon/api/handlers/reports.d.ts +1 -1
  364. package/dist/daemon/api/handlers/reports.js +5 -5
  365. package/dist/daemon/api/handlers/review-comments.js +1 -1
  366. package/dist/daemon/api/handlers/reviews.js +1 -1
  367. package/dist/daemon/api/handlers/runs.js +1 -1
  368. package/dist/daemon/api/handlers/structured-requests.js +1 -1
  369. package/dist/daemon/api/handlers/subscriptions.js +1 -1
  370. package/dist/daemon/api/handlers/transfer.js +1 -1
  371. package/dist/daemon/api/map.d.ts +3 -3
  372. package/dist/daemon/api/map.js +1 -1
  373. package/dist/daemon/api/principal.d.ts +1 -1
  374. package/dist/daemon/api/principal.js +1 -1
  375. package/dist/daemon/api/reader.d.ts +5 -5
  376. package/dist/daemon/api/reader.js +1 -1
  377. package/dist/daemon/api/router.d.ts +5 -5
  378. package/dist/daemon/api/router.js +1 -1
  379. package/dist/daemon/api/server.js +1 -1
  380. package/dist/daemon/broker-signals/bus.d.ts +1 -1
  381. package/dist/daemon/broker-signals/bus.js +1 -1
  382. package/dist/daemon/companion-retire.js +1 -1
  383. package/dist/daemon/cron/armed-context.d.ts +2 -2
  384. package/dist/daemon/cron/armed-context.js +1 -1
  385. package/dist/daemon/cron/authority.d.ts +2 -2
  386. package/dist/daemon/cron/authority.js +1 -1
  387. package/dist/daemon/cron/disposition.js +1 -1
  388. package/dist/daemon/cron/ended.d.ts +1 -1
  389. package/dist/daemon/cron/ended.js +2 -2
  390. package/dist/daemon/cron/escalation.js +3 -3
  391. package/dist/daemon/cron/folders.d.ts +1 -1
  392. package/dist/daemon/cron/folders.js +1 -1
  393. package/dist/daemon/cron/held.d.ts +1 -1
  394. package/dist/daemon/cron/held.js +1 -1
  395. package/dist/daemon/cron/lease-recovery.d.ts +1 -1
  396. package/dist/daemon/cron/lease-recovery.js +1 -1
  397. package/dist/daemon/cron/passes.d.ts +2 -2
  398. package/dist/daemon/cron/passes.js +1 -1
  399. package/dist/daemon/cron/run-socket.d.ts +1 -1
  400. package/dist/daemon/cron/run-socket.js +1 -1
  401. package/dist/daemon/cron/settle.js +1 -1
  402. package/dist/daemon/cron/sinks.d.ts +1 -1
  403. package/dist/daemon/cron/sinks.js +2 -2
  404. package/dist/daemon/cron-run.d.ts +12 -3
  405. package/dist/daemon/cron-run.js +2 -2
  406. package/dist/daemon/crtrd.js +6 -6
  407. package/dist/daemon/delivery/run-delivery.js +1 -1
  408. package/dist/daemon/due-sources.d.ts +3 -3
  409. package/dist/daemon/due-sources.js +1 -1
  410. package/dist/daemon/due.d.ts +3 -3
  411. package/dist/daemon/due.js +7 -7
  412. package/dist/daemon/fleet.d.ts +2 -2
  413. package/dist/daemon/fleet.js +11 -11
  414. package/dist/daemon/human/finish.js +3 -3
  415. package/dist/daemon/human/settle.d.ts +1 -1
  416. package/dist/daemon/human/settle.js +1 -1
  417. package/dist/daemon/human/sweep.js +1 -1
  418. package/dist/daemon/joined-owner.d.ts +2 -2
  419. package/dist/daemon/joined-owner.js +1 -1
  420. package/dist/daemon/messaging/node-message.js +1 -1
  421. package/dist/daemon/park-activity.d.ts +2 -2
  422. package/dist/daemon/park-activity.js +1 -1
  423. package/dist/daemon/peer/authority.js +1 -1
  424. package/dist/daemon/peer/forward.d.ts +13 -6
  425. package/dist/daemon/peer/forward.js +1 -1
  426. package/dist/daemon/peer/handlers.js +1 -1
  427. package/dist/daemon/peer/ingress.d.ts +4 -4
  428. package/dist/daemon/peer/ingress.js +1 -1
  429. package/dist/daemon/peer/outbox.d.ts +2 -2
  430. package/dist/daemon/peer/outbox.js +1 -1
  431. package/dist/daemon/peer/relay-service.js +1 -1
  432. package/dist/daemon/plugin-objects/read-leaf.d.ts +2 -2
  433. package/dist/daemon/plugin-objects/read-leaf.js +2 -2
  434. package/dist/daemon/profile-delete.js +1 -1
  435. package/dist/daemon/readiness.d.ts +2 -2
  436. package/dist/daemon/readiness.js +1 -1
  437. package/dist/daemon/reconcilers/action-lane.d.ts +1 -1
  438. package/dist/daemon/reconcilers/action-lane.js +1 -1
  439. package/dist/daemon/reconcilers/bash-deadline.js +2 -2
  440. package/dist/daemon/reconcilers/broker-supervision.d.ts +1 -1
  441. package/dist/daemon/reconcilers/broker-supervision.js +4 -4
  442. package/dist/daemon/reconcilers/controller-death.d.ts +1 -1
  443. package/dist/daemon/reconcilers/controller-death.js +1 -1
  444. package/dist/daemon/reconcilers/cron-lane.d.ts +1 -1
  445. package/dist/daemon/reconcilers/cron-lane.js +1 -1
  446. package/dist/daemon/reconcilers/delivery-lane.d.ts +1 -1
  447. package/dist/daemon/reconcilers/delivery-lane.js +2 -2
  448. package/dist/daemon/reconcilers/fault-retry-backstop.d.ts +3 -3
  449. package/dist/daemon/reconcilers/fault-retry-backstop.js +1 -1
  450. package/dist/daemon/reconcilers/grove-instance-sweep.d.ts +2 -2
  451. package/dist/daemon/reconcilers/grove-instance-sweep.js +1 -1
  452. package/dist/daemon/reconcilers/live-obligation.d.ts +6 -6
  453. package/dist/daemon/reconcilers/live-obligation.js +1 -1
  454. package/dist/daemon/reconcilers/managed-worktree-sweep.js +1 -1
  455. package/dist/daemon/reconcilers/node-deadline.d.ts +1 -1
  456. package/dist/daemon/reconcilers/node-deadline.js +1 -1
  457. package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
  458. package/dist/daemon/reconcilers/node-lifecycle/respawn-policy.d.ts +3 -3
  459. package/dist/daemon/reconcilers/node-lifecycle/respawn-policy.js +1 -1
  460. package/dist/daemon/reconcilers/node-lifecycle/terminating.js +1 -1
  461. package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
  462. package/dist/daemon/reconcilers/node-lifecycle/wants-execution.d.ts +1 -1
  463. package/dist/daemon/reconcilers/node-lifecycle/wants-execution.js +1 -1
  464. package/dist/daemon/reconcilers/pending-review-submit.d.ts +1 -1
  465. package/dist/daemon/reconcilers/pending-review-submit.js +1 -1
  466. package/dist/daemon/reconcilers/storage-due-work.js +1 -1
  467. package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -1
  468. package/dist/daemon/reconcilers/storage-maintenance.js +2 -2
  469. package/dist/daemon/reconcilers/structured-request-lane.d.ts +1 -1
  470. package/dist/daemon/reconcilers/structured-request-lane.js +1 -1
  471. package/dist/daemon/review/comment-notify.js +2 -2
  472. package/dist/daemon/review/companion.d.ts +3 -3
  473. package/dist/daemon/review/companion.js +1 -1
  474. package/dist/daemon/review/finish.js +1 -1
  475. package/dist/daemon/review/sweep.js +1 -1
  476. package/dist/daemon/run-notices.d.ts +4 -4
  477. package/dist/daemon/run-notices.js +1 -1
  478. package/dist/daemon/runs/append-section.d.ts +2 -2
  479. package/dist/daemon/runs/append-section.js +2 -2
  480. package/dist/daemon/runs/observer.d.ts +2 -2
  481. package/dist/daemon/runs/observer.js +2 -2
  482. package/dist/daemon/structured-requests/boot.d.ts +1 -1
  483. package/dist/daemon/structured-requests/boot.js +1 -1
  484. package/dist/daemon/structured-requests/effects.js +1 -1
  485. package/dist/daemon/structured-requests/sidecar.d.ts +1 -1
  486. package/dist/daemon/structured-requests/sidecar.js +1 -1
  487. package/dist/migrations/004-canvas-documents/apply.d.ts +3 -3
  488. package/dist/migrations/004-canvas-documents/apply.js +1 -1
  489. package/dist/migrations/004-canvas-documents/index.d.ts +2 -2
  490. package/dist/migrations/004-canvas-documents/index.js +2 -2
  491. package/dist/migrations/activation.js +2 -2
  492. package/docs/public-api.md +11 -0
  493. package/package.json +3 -2
  494. package/packages/crouter-identity/package.json +1 -1
  495. package/runtime.lock.json +12 -12
@@ -1,14 +1,14 @@
1
- var w=Object.defineProperty;var d=(e,s)=>w(e,"name",{value:s,configurable:!0});import{prepared as M}from"../sqlite-statements.js";import{envNodeId as v}from"../../shared/env.js";import{getNode as p,listNodes as j,view as E}from"./canvas.js";import{openDb as O}from"./db.js";import{readTextIfExists as I}from"../fs-utils.js";import{conversationIdFromPath as y,conversationStore as g,ConversationNotFoundError as C}from"../conversation-store/index.js";import{reportBodyByName as B}from"../feed/reports.js";import{readStamps as R}from"../runtime/stamp/protocol.js";const ee=["human","inbox","wake","revive","restart-continuation","stop-guard","park","recovery","context-nudge","kickoff","unknown"],ne=["user","assistant","toolResult"];function A(){const e=v();if(e!==void 0&&e!==""){const s=p(e);if(s!==null)return s.cwd}return process.cwd()}d(A,"callerCwd");function k(e){const s=Date.parse(e);return Number.isNaN(s)?0:s}d(k,"toMs");function _(e){return M(O(),`SELECT m.created_at, m.sender_node_id, d.urgency, m.kind, m.label, m.body_ref, m.body_json
1
+ var S=Object.defineProperty;var a=(n,s)=>S(n,"name",{value:s,configurable:!0});import{envNodeId as M}from"../../shared/env.js";import{getNode as p,listNodes as v,view as j}from"./canvas.js";import{openDb as E}from"./db.js";import{readTextIfExists as O}from"../fs-utils.js";import{conversationIdFromPath as y,conversationStore as g,ConversationNotFoundError as I}from"../conversation-store/index.js";import{reportBodyByName as C}from"../feed/reports.js";import{readStamps as A}from"../runtime/stamp/protocol.js";import{forEachAsync as B}from"../async-array.js";const nn=["human","inbox","wake","revive","restart-continuation","stop-guard","park","recovery","context-nudge","kickoff","unknown"],en=["user","assistant","toolResult"];async function R(){const n=M();if(n!==void 0&&n!==""){const s=await p(n);if(s!==null)return s.cwd}return process.cwd()}a(R,"callerCwd");function x(n){const s=Date.parse(n);return Number.isNaN(s)?0:s}a(x,"toMs");async function k(n){return(await(await E()).prepare(`SELECT m.created_at, m.sender_node_id, d.urgency, m.kind, m.label, m.body_ref, m.body_json
2
2
  FROM deliveries d JOIN messages m ON m.message_id = d.message_id
3
3
  WHERE d.destination_id = ? AND d.wake = 1
4
- ORDER BY m.seq, d.created_at, d.delivery_id`).all(e).map(n=>({ts:n.created_at,from:n.sender_node_id,tier:n.urgency,kind:n.kind,label:n.label,ref:n.body_ref,data:n.body_json===null?null:JSON.parse(n.body_json)}))}d(_,"allInboxEntries");function N(e){const s=[`from: ${e.from??"system"}`,`tier: ${e.tier}`].join(`
5
- `),n=`[${e.kind}] ${e.label}`,t=typeof e.data=="object"&&e.data!==null&&!Array.isArray(e.data)?e.data.body:void 0,o=typeof t=="string"?t.trim():"",i=typeof t=="string",r=e.ref!==null?i?I(e.ref)??"":B(e.ref)??"":o,l=r!==""&&r!==e.label,u=[s,n];return e.ref!==null&&u.push(`ref: ${e.ref}`),l&&u.push(r),u.join(`
4
+ ORDER BY m.seq, d.created_at, d.delivery_id`).all(n)).map(e=>({ts:e.created_at,from:e.sender_node_id,tier:e.urgency,kind:e.kind,label:e.label,ref:e.body_ref,data:e.body_json===null?null:JSON.parse(e.body_json)}))}a(k,"allInboxEntries");async function _(n){const s=[`from: ${n.from??"system"}`,`tier: ${n.tier}`].join(`
5
+ `),e=`[${n.kind}] ${n.label}`,t=typeof n.data=="object"&&n.data!==null&&!Array.isArray(n.data)?n.data.body:void 0,i=typeof t=="string"?t.trim():"",o=typeof t=="string",r=n.ref!==null?o?O(n.ref)??"":await C(n.ref)??"":i,c=r!==""&&r!==n.label,f=[s,e];return n.ref!==null&&f.push(`ref: ${n.ref}`),c&&f.push(r),f.join(`
6
6
 
7
- `)}d(N,"inboxEntryBody");function D(e,s,n,t){const o=`inbox/${String(t).padStart(6,"0")}`,i=N(n),r={ref:`${e.node_id}:${o}`,nodeId:e.node_id,relpath:o,source:"inbox",ts:n.ts,tsMs:k(n.ts),title:`[${n.kind}] from ${n.from??"system"}: ${n.label}`,nodeName:e.name,nodeKind:e.kind,nodeStatus:e.status,nodeCwd:e.cwd,nodeDesc:s,loadBody:d(()=>i,"loadBody"),origin:"inbox"};return typeof n.from=="string"&&n.from!==""&&(r.from=n.from),r}d(D,"inboxArtifact");function $(e){const s=p(e)?.pi_session_file,n=typeof s=="string"?y(s):null;if(n===null)return null;try{return g().header(n).path}catch(t){if(t instanceof C)return null;throw t}}d($,"resolveSessionFile");function T(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const s=[];for(const n of e){if(n===null||typeof n!="object")continue;const t=n;t.type==="text"&&typeof t.text=="string"?s.push(t.text):t.type==="toolCall"&&s.push(`Tool: ${typeof t.name=="string"?t.name:"call"}`)}return s.join(`
8
- `)}d(T,"textFromBlocks");function F(e){return e==null?"unknown":e.type==="human"?"human":e.kind}d(F,"originToken");function L(e){if(e==null||e.type!=="runtime")return;const s=e.entries;if(s===void 0||s.length===0)return;const n=new Set;for(const t of s){const o=t.fromName??t.from;typeof o=="string"&&o!==""&&n.add(o)}return n.size===0?void 0:[...n].join(", ")}d(L,"sendersOf");function S(e){const s=$(e);if(s===null)return[];const n=g().read(y(s)).entries,t=new Map;for(const i of R(n)){if(i.kind!=="message")continue;const r=i.payload;typeof r.msgTs=="number"&&t.set(r.msgTs,r.origin)}const o=[];for(const i of n){if(i===null||typeof i!="object")continue;const r=i;if(r.type!=="message")continue;const l=r.message;if(l===null||typeof l!="object")continue;const u=l,f=typeof u.role=="string"?u.role:"";if(f==="")continue;const a=typeof u.timestamp=="number"?u.timestamp:void 0,c=typeof r.timestamp=="string"?r.timestamp:a!==void 0?new Date(a).toISOString():"",m=T(u.content),b={index:o.length,role:f,text:m,ts:c,tsMs:a??k(c)};if(f==="user"){const h=a!==void 0&&t.has(a)?t.get(a):null;b.origin=F(h);const x=L(h);x!==void 0&&(b.from=x)}o.push(b)}return o}d(S,"sessionMessages");function J(e,s){const n=g().read(y(e)).entries;let t=0;for(const o of n){if(o.type!=="message")continue;const i=o.message;if(!(i===null||typeof i!="object"||typeof i.role!="string")){if(t===s)return JSON.stringify(o);t++}}return null}d(J,"rawSessionLine");function K(e,s,n){const t=`session/${String(n.index).padStart(6,"0")}`,o=n.text.split(`
9
- `).map(r=>r.trim()).find(r=>r!=="")??"",i={ref:`${e.node_id}:${t}`,nodeId:e.node_id,relpath:t,source:"transcript",ts:n.ts,tsMs:n.tsMs,title:`[${n.role}] ${o.length>80?`${o.slice(0,80)}\u2026`:o}`,nodeName:e.name,nodeKind:e.kind,nodeStatus:e.status,nodeCwd:e.cwd,nodeDesc:s,loadBody:d(()=>n.text,"loadBody"),role:n.role};return n.origin!==void 0&&(i.origin=n.origin),n.from!==void 0&&(i.from=n.from),i}d(K,"transcriptArtifact");function W(e){return p(e)?.description??""}d(W,"nodeDescOf");function te(e,s){const n=P(e),t=s.kinds,o=s.statuses,i=n.filter(f=>!(t!==void 0&&t.length>0&&!t.includes(f.kind)||o!==void 0&&o.length>0&&!o.includes(f.status))),r=s.types!==void 0&&s.types.length>0?s.types:["inbox"],l=new Set(r),u=[];for(const f of i){const a=W(f.node_id);if(l.has("inbox")&&_(f.node_id).forEach((c,m)=>u.push(D(f,a,c,m))),l.has("transcript"))for(const c of S(f.node_id))u.push(K(f,a,c))}return u.filter(f=>s.sinceMs!==void 0&&f.tsMs<s.sinceMs||s.untilMs!==void 0&&f.tsMs>s.untilMs?!1:G(f,s))}d(te,"buildCorpus");function G(e,s){const{origins:n,roles:t,from:o}=s;return!(n!==void 0&&n.length>0&&(e.origin===void 0||!n.includes(e.origin))||t!==void 0&&t.length>0&&(e.role===void 0||!t.includes(e.role))||o!==void 0&&o!==""&&(e.from===void 0||!e.from.toLowerCase().includes(o.toLowerCase())))}d(G,"matchesMessageFilters");function oe(e,s){const n=new Map;for(const t of e){let o;switch(s){case"origin":o=t.origin;break;case"role":o=t.role;break;case"node":o=`${t.nodeName} (${t.nodeId})`;break;case"kind":o=t.nodeKind;break;case"type":o=t.source;break;case"day":o=t.ts.slice(0,10)||void 0;break}o===void 0||o===""||n.set(o,(n.get(o)??0)+1)}return[...n.entries()].map(([t,o])=>({key:t,count:o})).sort((t,o)=>o.count-t.count||t.key.localeCompare(o.key))}d(oe,"groupCorpus");function P(e){const s=j(),n=new Map(s.map(o=>[o.node_id,o]));if(e.nodes!==void 0&&e.nodes.length>0)return e.nodes.map(o=>n.get(o)).filter(o=>o!==void 0);if(e.under!==void 0&&e.under!=="")return[e.under,...E(e.under)].map(i=>n.get(i)).filter(i=>i!==void 0);if(e.allCwds===!0)return s;const t=e.cwd!==void 0&&e.cwd!==""?e.cwd:A();return s.filter(o=>o.cwd===t)}d(P,"scopedRows");function se(e){const s=e.indexOf(":");if(s===-1)return null;const n=e.slice(0,s),t=e.slice(s+1),o=p(n);if(o===null)return null;if(t.startsWith("inbox/")){const i=Number(t.slice(6)),r=_(n)[i];return r===void 0?null:{nodeId:n,relpath:t,source:"inbox",ts:r.ts,nodeName:o.name,body:N(r),raw:null,path:null}}if(t==="session"||t.startsWith("session/")){const i=$(n);if(i===null)return null;const r=S(n);if(t==="session"){const f=r.map(a=>`## ${a.role}${a.origin!==void 0?` (origin: ${a.origin})`:""}
7
+ `)}a(_,"inboxEntryBody");async function D(n,s,e,t){const i=`inbox/${String(t).padStart(6,"0")}`,o=await _(e),r={ref:`${n.node_id}:${i}`,nodeId:n.node_id,relpath:i,source:"inbox",ts:e.ts,tsMs:x(e.ts),title:`[${e.kind}] from ${e.from??"system"}: ${e.label}`,nodeName:n.name,nodeKind:n.kind,nodeStatus:n.status,nodeCwd:n.cwd,nodeDesc:s,loadBody:a(()=>o,"loadBody"),origin:"inbox"};return typeof e.from=="string"&&e.from!==""&&(r.from=e.from),r}a(D,"inboxArtifact");async function N(n){const s=(await p(n))?.pi_session_file,e=typeof s=="string"?y(s):null;if(e===null)return null;try{return(await g().header(e)).path}catch(t){if(t instanceof I)return null;throw t}}a(N,"resolveSessionFile");function T(n){if(typeof n=="string")return n;if(!Array.isArray(n))return"";const s=[];for(const e of n){if(e===null||typeof e!="object")continue;const t=e;t.type==="text"&&typeof t.text=="string"?s.push(t.text):t.type==="toolCall"&&s.push(`Tool: ${typeof t.name=="string"?t.name:"call"}`)}return s.join(`
8
+ `)}a(T,"textFromBlocks");function F(n){return n==null?"unknown":n.type==="human"?"human":n.kind}a(F,"originToken");function L(n){if(n==null||n.type!=="runtime")return;const s=n.entries;if(s===void 0||s.length===0)return;const e=new Set;for(const t of s){const i=t.fromName??t.from;typeof i=="string"&&i!==""&&e.add(i)}return e.size===0?void 0:[...e].join(", ")}a(L,"sendersOf");async function $(n){const s=await N(n);if(s===null)return[];const e=(await g().read(y(s))).entries,t=new Map;for(const o of A(e)){if(o.kind!=="message")continue;const r=o.payload;typeof r.msgTs=="number"&&t.set(r.msgTs,r.origin)}const i=[];for(const o of e){if(o===null||typeof o!="object")continue;const r=o;if(r.type!=="message")continue;const c=r.message;if(c===null||typeof c!="object")continue;const f=c,d=typeof f.role=="string"?f.role:"";if(d==="")continue;const u=typeof f.timestamp=="number"?f.timestamp:void 0,l=typeof r.timestamp=="string"?r.timestamp:u!==void 0?new Date(u).toISOString():"",m=T(f.content),w={index:i.length,role:d,text:m,ts:l,tsMs:u??x(l)};if(d==="user"){const b=u!==void 0&&t.has(u)?t.get(u):null;w.origin=F(b);const h=L(b);h!==void 0&&(w.from=h)}i.push(w)}return i}a($,"sessionMessages");async function J(n,s){const e=(await g().read(y(n))).entries;let t=0;for(const i of e){if(i.type!=="message")continue;const o=i.message;if(!(o===null||typeof o!="object"||typeof o.role!="string")){if(t===s)return JSON.stringify(i);t++}}return null}a(J,"rawSessionLine");function K(n,s,e){const t=`session/${String(e.index).padStart(6,"0")}`,i=e.text.split(`
9
+ `).map(r=>r.trim()).find(r=>r!=="")??"",o={ref:`${n.node_id}:${t}`,nodeId:n.node_id,relpath:t,source:"transcript",ts:e.ts,tsMs:e.tsMs,title:`[${e.role}] ${i.length>80?`${i.slice(0,80)}\u2026`:i}`,nodeName:n.name,nodeKind:n.kind,nodeStatus:n.status,nodeCwd:n.cwd,nodeDesc:s,loadBody:a(()=>e.text,"loadBody"),role:e.role};return e.origin!==void 0&&(o.origin=e.origin),e.from!==void 0&&(o.from=e.from),o}a(K,"transcriptArtifact");async function W(n){return(await p(n))?.description??""}a(W,"nodeDescOf");async function tn(n,s){const e=await P(n),t=s.kinds,i=s.statuses,o=e.filter(d=>!(t!==void 0&&t.length>0&&!t.includes(d.kind)||i!==void 0&&i.length>0&&!i.includes(d.status))),r=s.types!==void 0&&s.types.length>0?s.types:["inbox"],c=new Set(r),f=[];for(const d of o){const u=await W(d.node_id);if(c.has("inbox")&&await B(await k(d.node_id),async(l,m)=>f.push(await D(d,u,l,m))),c.has("transcript"))for(const l of await $(d.node_id))f.push(K(d,u,l))}return f.filter(d=>s.sinceMs!==void 0&&d.tsMs<s.sinceMs||s.untilMs!==void 0&&d.tsMs>s.untilMs?!1:G(d,s))}a(tn,"buildCorpus");function G(n,s){const{origins:e,roles:t,from:i}=s;return!(e!==void 0&&e.length>0&&(n.origin===void 0||!e.includes(n.origin))||t!==void 0&&t.length>0&&(n.role===void 0||!t.includes(n.role))||i!==void 0&&i!==""&&(n.from===void 0||!n.from.toLowerCase().includes(i.toLowerCase())))}a(G,"matchesMessageFilters");function sn(n,s){const e=new Map;for(const t of n){let i;switch(s){case"origin":i=t.origin;break;case"role":i=t.role;break;case"node":i=`${t.nodeName} (${t.nodeId})`;break;case"kind":i=t.nodeKind;break;case"type":i=t.source;break;case"day":i=t.ts.slice(0,10)||void 0;break}i===void 0||i===""||e.set(i,(e.get(i)??0)+1)}return[...e.entries()].map(([t,i])=>({key:t,count:i})).sort((t,i)=>i.count-t.count||t.key.localeCompare(i.key))}a(sn,"groupCorpus");async function P(n){const s=await v(),e=new Map(s.map(i=>[i.node_id,i]));if(n.nodes!==void 0&&n.nodes.length>0)return n.nodes.map(i=>e.get(i)).filter(i=>i!==void 0);if(n.under!==void 0&&n.under!=="")return[n.under,...await j(n.under)].map(o=>e.get(o)).filter(o=>o!==void 0);if(n.allCwds===!0)return s;const t=n.cwd!==void 0&&n.cwd!==""?n.cwd:await R();return s.filter(i=>i.cwd===t)}a(P,"scopedRows");async function on(n){const s=n.indexOf(":");if(s===-1)return null;const e=n.slice(0,s),t=n.slice(s+1),i=await p(e);if(i===null)return null;if(t.startsWith("inbox/")){const o=Number(t.slice(6)),r=(await k(e))[o];return r===void 0?null:{nodeId:e,relpath:t,source:"inbox",ts:r.ts,nodeName:i.name,body:await _(r),raw:null,path:null}}if(t==="session"||t.startsWith("session/")){const o=await N(e);if(o===null)return null;const r=await $(e);if(t==="session"){const d=r.map(u=>`## ${u.role}${u.origin!==void 0?` (origin: ${u.origin})`:""}
10
10
 
11
- ${a.text}`).join(`
11
+ ${u.text}`).join(`
12
12
 
13
- `);return{nodeId:n,relpath:t,source:"transcript",ts:r[r.length-1]?.ts??o.created,nodeName:o.name,body:f,raw:(()=>{const{header:a,entries:c}=g().read(y(i));return[a,...c].map(m=>`${JSON.stringify(m)}
14
- `).join("")})(),path:i}}const l=Number(t.slice(8)),u=r[l];return u===void 0?null:{nodeId:n,relpath:t,source:"transcript",ts:u.ts,nodeName:o.name,body:u.text,raw:J(i,l),path:i}}return null}d(se,"resolveRef");export{ne as MESSAGE_ROLES,ee as ORIGIN_TOKENS,te as buildCorpus,A as callerCwd,oe as groupCorpus,se as resolveRef};
13
+ `);return{nodeId:e,relpath:t,source:"transcript",ts:r[r.length-1]?.ts??i.created,nodeName:i.name,body:d,raw:await(async()=>{const{header:u,entries:l}=await g().read(y(o));return[u,...l].map(m=>`${JSON.stringify(m)}
14
+ `).join("")})(),path:o}}const c=Number(t.slice(8)),f=r[c];return f===void 0?null:{nodeId:e,relpath:t,source:"transcript",ts:f.ts,nodeName:i.name,body:f.text,raw:await J(o,c),path:o}}return null}a(on,"resolveRef");export{en as MESSAGE_ROLES,nn as ORIGIN_TOKENS,tn as buildCorpus,R as callerCwd,sn as groupCorpus,on as resolveRef};
@@ -6,4 +6,4 @@ export declare function isValidInstallId(id: string): boolean;
6
6
  * which is the intended behavior for both an invalid env value and a
7
7
  * stored/env mismatch. Runs in the caller's canvas write transaction when
8
8
  * one is open, else its own. `env` is injectable for tests. */
9
- export declare function resolveInstallId(env?: NodeJS.ProcessEnv): string;
9
+ export declare function resolveInstallId(env?: NodeJS.ProcessEnv): Promise<string>;
@@ -1 +1 @@
1
- var u=Object.defineProperty;var a=(t,e)=>u(t,"name",{value:e,configurable:!0});import{prepared as l}from"../sqlite-statements.js";import{randomBytes as d}from"node:crypto";import{withCanvasWrite as I}from"./db.js";const i="install_id",h=/^[a-z0-9]{4,16}$/,c="abcdefghijklmnopqrstuvwxyz0123456789";function f(t){return h.test(t)}a(f,"isValidInstallId");function m(){const t=d(8);let e="";for(let n=0;n<8;n++)e+=c[t[n]%c.length];return e}a(m,"mintInstallId");function v(t){return l(t,"SELECT value FROM canvas_meta WHERE key = ?").get(i)?.value??null}a(v,"readInstallId");function T(t,e){l(t,"INSERT INTO canvas_meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(i,e)}a(T,"writeInstallId");function _(t=process.env){return I(e=>{const n=v(e),s=t.CRTR_INSTALL_ID,r=s!==void 0&&s!==""?s:null;if(n!==null){if(r!==null&&r!==n)throw new Error(`CRTR_INSTALL_ID='${r}' conflicts with the install id already persisted in this canvas home ('${n}'). This canvas home was minted under a different install id \u2014 refusing to boot rather than silently mask what is usually a provisioning bug (this process pointed at the wrong volume/home).`);return n}if(r!==null&&!f(r))throw new Error(`CRTR_INSTALL_ID='${r}' is not a valid install id \u2014 expected 4-16 lowercase [a-z0-9] characters.`);const o=r??m();return T(e,o),o})}a(_,"resolveInstallId");export{f as isValidInstallId,_ as resolveInstallId};
1
+ var c=Object.defineProperty;var r=(t,e)=>c(t,"name",{value:e,configurable:!0});import{randomBytes as u}from"node:crypto";import{withCanvasWrite as d}from"./db.js";const l="install_id",I=/^[a-z0-9]{4,16}$/,o="abcdefghijklmnopqrstuvwxyz0123456789";function w(t){return I.test(t)}r(w,"isValidInstallId");function h(){const t=u(8);let e="";for(let n=0;n<8;n++)e+=o[t[n]%o.length];return e}r(h,"mintInstallId");async function f(t){return(await t.prepare("SELECT value FROM canvas_meta WHERE key = ?").get(l))?.value??null}r(f,"readInstallId");async function v(t,e){await t.prepare("INSERT INTO canvas_meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(l,e)}r(v,"writeInstallId");async function L(t=process.env){return await d(async e=>{const n=await f(e),s=t.CRTR_INSTALL_ID,a=s!==void 0&&s!==""?s:null;if(n!==null){if(a!==null&&a!==n)throw new Error(`CRTR_INSTALL_ID='${a}' conflicts with the install id already persisted in this canvas home ('${n}'). This canvas home was minted under a different install id \u2014 refusing to boot rather than silently mask what is usually a provisioning bug (this process pointed at the wrong volume/home).`);return n}if(a!==null&&!w(a))throw new Error(`CRTR_INSTALL_ID='${a}' is not a valid install id \u2014 expected 4-16 lowercase [a-z0-9] characters.`);const i=a??h();return await v(e,i),i})}r(L,"resolveInstallId");export{w as isValidInstallId,L as resolveInstallId};
@@ -1,4 +1,4 @@
1
1
  /** Find only terminal nodes with an unreconciled, explicitly disposable worktree.
2
2
  * Keep due-time parsing in JS: Date.parse accepts more than SQLite's date
3
3
  * functions, and malformed dates are due rather than permanently skipped. */
4
- export declare function managedWorktreeSweepCandidates(now: number): string[];
4
+ export declare function managedWorktreeSweepCandidates(now: number): Promise<string[]>;
@@ -1,4 +1,4 @@
1
- var d=Object.defineProperty;var a=(t,o)=>d(t,"name",{value:o,configurable:!0});import{openDb as _,prepared as r}from"./db.js";function w(t){const o=r(_(),`
1
+ var d=Object.defineProperty;var s=(t,o)=>d(t,"name",{value:o,configurable:!0});import{openDb as _}from"./db.js";async function w(t){const o=await(await _()).prepare(`
2
2
  SELECT w.node_id, w.sweep_observed_json, w.next_attempt_at,
3
3
  w.abandoned_json, w.land_intent_json, w.disposal_json
4
4
  FROM worktrees w
@@ -9,4 +9,4 @@ var d=Object.defineProperty;var a=(t,o)=>d(t,"name",{value:o,configurable:!0});i
9
9
  AND (w.state = 'open' OR w.cleanup_state IS NULL OR w.cleanup_state != 'complete')
10
10
  AND (w.state = 'closed' OR (n.status = 'done' AND n.final_report IS NOT NULL))
11
11
  ORDER BY n.created
12
- `).all(),s=[];for(const e of o){try{for(const n of[e.sweep_observed_json,e.abandoned_json,e.land_intent_json,e.disposal_json])n!==null&&JSON.parse(n)}catch{continue}if(e.sweep_observed_json!==null&&e.next_attempt_at!==null){const n=Date.parse(e.next_attempt_at);if(!Number.isNaN(n)&&n>t)continue}s.push(e.node_id)}return s}a(w,"managedWorktreeSweepCandidates");export{w as managedWorktreeSweepCandidates};
12
+ `).all(),a=[];for(const e of o){try{for(const n of[e.sweep_observed_json,e.abandoned_json,e.land_intent_json,e.disposal_json])n!==null&&JSON.parse(n)}catch{continue}if(e.sweep_observed_json!==null&&e.next_attempt_at!==null){const n=Date.parse(e.next_attempt_at);if(!Number.isNaN(n)&&n>t)continue}a.push(e.node_id)}return a}s(w,"managedWorktreeSweepCandidates");export{w as managedWorktreeSweepCandidates};
@@ -1,5 +1,5 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
1
  import type { MemoryReadEventDTO } from '../../api/dto/analytics.js';
2
+ import { type CanvasDb } from './db.js';
3
3
  /** Entries older than this are deleted by the hourly storage-maintenance pass. */
4
4
  export declare const MEMORY_READS_RETENTION_MS: number;
5
5
  export interface MemoryReadRow {
@@ -11,14 +11,14 @@ export interface MemoryReadRow {
11
11
  }
12
12
  /** Insert every event for one node in one transaction. `at` must already be a
13
13
  * canonical ISO UTC string (`Date#toISOString`) so range reads compare as text. */
14
- export declare function insertMemoryReads(nodeId: string, events: MemoryReadEventDTO[]): void;
14
+ export declare function insertMemoryReads(nodeId: string, events: MemoryReadEventDTO[]): Promise<void>;
15
15
  /** Record events inside the caller's write transaction: the canvas-model
16
16
  * delivery (`loaded`) and explicit document read (`read`) sites call this so
17
17
  * the log lands with the exposures and watches it describes. */
18
- export declare function recordMemoryReadsIn(db: DatabaseSync, nodeId: string, events: readonly MemoryReadEventDTO[]): void;
18
+ export declare function recordMemoryReadsIn(db: CanvasDb, nodeId: string, events: readonly MemoryReadEventDTO[]): Promise<void>;
19
19
  /** Entries with `fromIso <= at < toIso`, oldest first. */
20
- export declare function listMemoryReads(fromIso: string, toIso: string): MemoryReadRow[];
20
+ export declare function listMemoryReads(fromIso: string, toIso: string): Promise<MemoryReadRow[]>;
21
21
  /** Delete entries older than the retention window; returns the count deleted. */
22
- export declare function pruneMemoryReads(nowMs: number): number;
22
+ export declare function pruneMemoryReads(nowMs: number): Promise<number>;
23
23
  /** When recording began: the time the memory_reads migration ran. */
24
- export declare function memoryReadsStartedAt(): string | null;
24
+ export declare function memoryReadsStartedAt(): Promise<string | null>;
@@ -1 +1 @@
1
- var E=Object.defineProperty;var o=(e,t)=>E(e,"name",{value:t,configurable:!0});import{prepared as n}from"../sqlite-statements.js";import{openDb as m,withCanvasWrite as p}from"./db.js";const c=720*60*60*1e3;function u(e,t){p(a=>{const s=n(a,"INSERT INTO memory_reads (node_id, name, scope, at, type) VALUES (?, ?, ?, ?, ?)");for(const r of t)s.run(e,r.name,r.scope,r.at,r.type)})}o(u,"insertMemoryReads");function y(e,t,a){if(a.length===0)return;const s=n(e,"INSERT INTO memory_reads (node_id, name, scope, at, type) VALUES (?, ?, ?, ?, ?)");for(const r of a)s.run(t,r.name,r.scope,r.at,r.type)}o(y,"recordMemoryReadsIn");function _(e,t){return n(m(),"SELECT node_id, name, scope, at, type FROM memory_reads WHERE at >= ? AND at < ? ORDER BY at").all(e,t)}o(_,"listMemoryReads");function f(e){return p(t=>Number(n(t,"DELETE FROM memory_reads WHERE at < ?").run(new Date(e-c).toISOString()).changes))}o(f,"pruneMemoryReads");function S(){return n(m(),"SELECT value FROM canvas_meta WHERE key = 'memory_reads.started_at'").get()?.value??null}o(S,"memoryReadsStartedAt");export{c as MEMORY_READS_RETENTION_MS,u as insertMemoryReads,_ as listMemoryReads,S as memoryReadsStartedAt,f as pruneMemoryReads,y as recordMemoryReadsIn};
1
+ var p=Object.defineProperty;var r=(e,t)=>p(e,"name",{value:t,configurable:!0});import{withCanvasWrite as i,openDb as s}from"./db.js";const c=720*60*60*1e3;async function E(e,t){await i(async n=>{const o=n.prepare("INSERT INTO memory_reads (node_id, name, scope, at, type) VALUES (?, ?, ?, ?, ?)");for(const a of t)await o.run(e,a.name,a.scope,a.at,a.type)})}r(E,"insertMemoryReads");async function d(e,t,n){if(n.length===0)return;const o=e.prepare("INSERT INTO memory_reads (node_id, name, scope, at, type) VALUES (?, ?, ?, ?, ?)");for(const a of n)await o.run(t,a.name,a.scope,a.at,a.type)}r(d,"recordMemoryReadsIn");async function R(e,t){return await(await s()).prepare("SELECT node_id, name, scope, at, type FROM memory_reads WHERE at >= ? AND at < ? ORDER BY at").all(e,t)}r(R,"listMemoryReads");async function u(e){return Number((await(await s()).prepare("DELETE FROM memory_reads WHERE at < ?").run(new Date(e-c).toISOString())).changes)}r(u,"pruneMemoryReads");async function w(){return(await(await s()).prepare("SELECT value FROM canvas_meta WHERE key = 'memory_reads.started_at'").get())?.value??null}r(w,"memoryReadsStartedAt");export{c as MEMORY_READS_RETENTION_MS,E as insertMemoryReads,R as listMemoryReads,w as memoryReadsStartedAt,u as pruneMemoryReads,d as recordMemoryReadsIn};
@@ -2,7 +2,7 @@ import { type FlatRow, type FoldState, type SubtreeActivity } from './nav-render
2
2
  import type { NodeMeta } from './index.js';
3
3
  export { PI_MAX_WIDGET_LINES, VIEWPORT_FALLBACK_ROWS, ESC, RESET, BOLD, DIM, REVERSE, BG_ATTACHED, GREEN, RED, YELLOW, CYAN, GRAY, nodeGlyph, visibleWidth, truncate, fillWidth, fillBar, fmtTokens, tokensCell, activityCell, cycleBadge, navLabel, shortId, askBadge, liveBelowBadge, isAttached, hasBrokerViewers, fetchAsksMap, graphWidgetBudget, GRAPH_HINT, type FlatRow, type FoldState, type SubtreeActivity, } from './nav-render.js';
4
4
  /** First manager (by created) — the UP step for the ancestry spine. */
5
- export declare function managerOf(id: string): string | undefined;
5
+ export declare function managerOf(id: string): Promise<string | undefined>;
6
6
  /** A kind:'human' node is a control-plane ASK (a page on the human's
7
7
  * screen), NOT a pi conversation — it has no session, so focusing/reviving it
8
8
  * boots a confused blank "you have been revived" pi. Its pending-ask signal
@@ -10,35 +10,35 @@ export declare function managerOf(id: string): string | undefined;
10
10
  * bridge node's parent relation), so the row carries no signal of its
11
11
  * own. Drop it from every navigable list (the tree, BASE reports, child counts,
12
12
  * subtree expansion) so it can never be selected. */
13
- export declare function isHumanAsk(id: string): boolean;
13
+ export declare function isHumanAsk(id: string): Promise<boolean>;
14
14
  /** A node's direct children that are navigable conversations — human-ask nodes
15
15
  * dropped. The one place the nav chrome enumerates children. */
16
- export declare function convoChildIds(id: string): string[];
16
+ export declare function convoChildIds(id: string): Promise<string[]>;
17
17
  /** Live reports (active|idle) of a node — the DOWN set in BASE. */
18
- export declare function liveReports(id: string): string[];
18
+ export declare function liveReports(id: string): Promise<string[]>;
19
19
  /** Direct navigable children — used for the ⤳ badge (human-ask nodes excluded,
20
20
  * so the count matches what the tree actually shows). */
21
- export declare function childCount(id: string): number;
21
+ export declare function childCount(id: string): Promise<number>;
22
22
  /** Climb first-manager edges from `self` to the ancestry root (cycle-guarded). */
23
- export declare function climbRoot(self: string): string;
23
+ export declare function climbRoot(self: string): Promise<string>;
24
24
  /** Space-joined ids of a node's subtree (cursor-relative {subtree} var). */
25
- export declare function subtreeIds(root: string): string[];
25
+ export declare function subtreeIds(root: string): Promise<string[]>;
26
26
  /** ⤳M direct-children badge — the single child-count signal, shown on any row
27
27
  * with navigable children (folded or not). In GRAPH the ▸ caret separately marks
28
28
  * a collapsed row, so this stays a pure count and never doubles as a fold badge. */
29
- export declare function childBadge(node: NodeMeta | null): string;
29
+ export declare function childBadge(node: NodeMeta | null): Promise<string>;
30
30
  /** Direct children, live-first — the sibling order used both when flattening
31
31
  * the tree and when stepping into a subtree (`l`). Array.sort is stable, so
32
32
  * equal-status siblings keep their creation order. */
33
- export declare function sortedChildIds(id: string): string[];
34
- export declare function computeSubtreeActivity(root: string, self: string): SubtreeActivity;
33
+ export declare function sortedChildIds(id: string): Promise<string[]>;
34
+ export declare function computeSubtreeActivity(root: string, self: string): Promise<SubtreeActivity>;
35
35
  /** Fold policy alone — thin wrapper over computeSubtreeActivity for the keypress
36
36
  * path (buildGraphModel without a precomputed set). The render path computes the
37
37
  * activity once and threads `expand` in, so it never recomputes here. */
38
- export declare function computeDefaultExpanded(root: string, self: string): Set<string>;
39
- export declare function buildGraphModel(self: string, folds: FoldState, expand?: ReadonlySet<string>): FlatRow[];
38
+ export declare function computeDefaultExpanded(root: string, self: string): Promise<Set<string>>;
39
+ export declare function buildGraphModel(self: string, folds: FoldState, expand?: ReadonlySet<string>): Promise<FlatRow[]>;
40
40
  /** Render one GRAPH row. CURSOR (selected) → reverse-video bar; an ATTACHED
41
41
  * (human-watched) node → a coloured background bar; SELF → bold name. The
42
42
  * cursor outranks the attached tint when both land on the same row. The
43
43
  * overlay-aware glyph alone carries the live signal (status / ⟳ / ⚠). */
44
- export declare function renderGraphRow(r: FlatRow, isCursor: boolean, focused: ReadonlySet<string>, activeBelow: ReadonlyMap<string, number>, asks: Record<string, number>): string;
44
+ export declare function renderGraphRow(r: FlatRow, isCursor: boolean, focused: ReadonlySet<string>, activeBelow: ReadonlyMap<string, number>, asks: Record<string, number>): Promise<string>;
@@ -1 +1 @@
1
- var A=Object.defineProperty;var o=(t,e)=>A(t,"name",{value:e,configurable:!0});import{getNode as x,subscribersOf as R,subscriptionsOf as y}from"./index.js";import{faultSummary as I}from"./status-glyph.js";import{statusRank as C}from"./node-order.js";import{nodeGlyph as _,navLabel as G,shortId as O,tokensCell as T,activityCell as D,cycleBadge as W,askBadge as L,liveBelowBadge as M,truncate as N,fillBar as b,fillWidth as S,isAttached as H,BOLD as K,DIM as g,RESET as $,REVERSE as P,BG_ATTACHED as V}from"./nav-render.js";import{PI_MAX_WIDGET_LINES as dt,VIEWPORT_FALLBACK_ROWS as ft,ESC as ht,RESET as pt,BOLD as $t,DIM as mt,REVERSE as vt,BG_ATTACHED as Et,GREEN as xt,RED as gt,YELLOW as kt,CYAN as Bt,GRAY as bt,nodeGlyph as St,visibleWidth as wt,truncate as At,fillWidth as Rt,fillBar as yt,fmtTokens as It,tokensCell as Ct,activityCell as _t,cycleBadge as Gt,navLabel as Ot,shortId as Tt,askBadge as Dt,liveBelowBadge as Wt,isAttached as Lt,hasBrokerViewers as Mt,fetchAsksMap as Nt,graphWidgetBudget as Ht,GRAPH_HINT as Kt}from"./nav-render.js";function Y(t){try{return y(t)}catch{return[]}}o(Y,"subsOf");function F(t){try{return R(t)}catch{return[]}}o(F,"mgrsOf");function q(t){return F(t)[0]?.node_id}o(q,"managerOf");function X(t){return x(t)?.kind==="human"}o(X,"isHumanAsk");function m(t){return Y(t).map(e=>e.node_id).filter(e=>!X(e))}o(m,"convoChildIds");function st(t){return m(t).filter(e=>{const r=x(e)?.status;return r==="active"||r==="idle"})}o(st,"liveReports");function j(t){return m(t).length}o(j,"childCount");function z(t){let e=t;const r=new Set([e]);for(;;){const c=q(e);if(c===void 0||r.has(c))break;r.add(c),e=c}return e}o(z,"climbRoot");function ct(t){const e=[],r=new Set([t]),c=m(t);for(;c.length>0;){const l=c.shift();if(!r.has(l)){r.add(l),e.push(l);for(const u of m(l))r.has(u)||c.push(u)}}return e}o(ct,"subtreeIds");function J(t){if(t===null)return"";const e=j(t.node_id);return e>0?` ${g}\u2933${e}${$}`:""}o(J,"childBadge");function Q(t){return m(t).map(e=>({cid:e,rank:C(x(e)?.status)})).sort((e,r)=>e.rank-r.rank).map(({cid:e})=>e)}o(Q,"sortedChildIds");function U(t,e){const r=new Set,c=new Map,l=new Set,u=o(n=>{const i=x(n)?.status==="active";if(l.has(n))return{active:i?1:0,reveal:i||n===e};l.add(n);let d=0,s=!1;for(const h of m(n)){const f=u(h);d+=f.active,f.reveal&&(s=!0)}return c.set(n,d),s&&r.add(n),{active:d+(i?1:0),reveal:s||i||n===e}},"visit");return u(t),{expand:r,activeBelow:c}}o(U,"computeSubtreeActivity");function Z(t,e){return U(t,e).expand}o(Z,"computeDefaultExpanded");function at(t,e,r){const c=z(t),l=r??Z(c,t),u=o(s=>e.userExpanded.has(s)?!1:e.userCollapsed.has(s)?!0:!l.has(s),"isFolded"),n=[],i=new Set,d=o((s,h,f,v)=>{if(i.has(s)){const a=f?"":v?"\u2514\u2500 ":"\u251C\u2500 ";n.push({id:s,hasKids:!1,isSelf:s===t,branch:h+a,cycle:!0,collapsed:!1});return}i.add(s);const p=Q(s),E=u(s),k=f?"":v?"\u2514\u2500 ":"\u251C\u2500 ";if(n.push({id:s,hasKids:p.length>0,isSelf:s===t,branch:h+k,cycle:!1,collapsed:E}),E)return;const B=f?"":h+(v?" ":"\u2502 ");for(let a=0;a<p.length;a++)d(p[a],B,!1,a===p.length-1)},"walk");return d(c,"",!0,!0),n}o(at,"buildGraphModel");function lt(t,e,r,c,l){const u=o((a,w)=>e?b(a,S(),P):w?b(a,S(),V):N(a),"wrap");if(t.cycle){const a=`${t.branch} ${g}\u21BA ${O(t.id)}${$}`;return u(a,!1)}const n=x(t.id),i=_(n),d=G(n,t.id),s=t.isSelf?`${K}${d}${$}`:d,h=`${g}${n?.kind??""}${$}`,f=`${g}${T(n)}${$}`,v=t.hasKids&&t.collapsed,p=!e&&v?`${g}\u25B8${$} `:" ",E=n?.fault??null,k=E!==null?` \xB7 ${I(E)}`:"",B=`${t.branch}${p}${i} ${s} ${h} ${f}${W(n)}${J(n)}${M(n,c)}${L(t.id,l)}${D(n)}${k}`;return u(B,H(t.id,n,r))}o(lt,"renderGraphRow");export{Et as BG_ATTACHED,$t as BOLD,Bt as CYAN,mt as DIM,ht as ESC,Kt as GRAPH_HINT,bt as GRAY,xt as GREEN,dt as PI_MAX_WIDGET_LINES,gt as RED,pt as RESET,vt as REVERSE,ft as VIEWPORT_FALLBACK_ROWS,kt as YELLOW,_t as activityCell,Dt as askBadge,at as buildGraphModel,J as childBadge,j as childCount,z as climbRoot,Z as computeDefaultExpanded,U as computeSubtreeActivity,m as convoChildIds,Gt as cycleBadge,Nt as fetchAsksMap,yt as fillBar,Rt as fillWidth,It as fmtTokens,Ht as graphWidgetBudget,Mt as hasBrokerViewers,Lt as isAttached,X as isHumanAsk,Wt as liveBelowBadge,st as liveReports,q as managerOf,Ot as navLabel,St as nodeGlyph,lt as renderGraphRow,Tt as shortId,Q as sortedChildIds,ct as subtreeIds,Ct as tokensCell,At as truncate,wt as visibleWidth};
1
+ var S=Object.defineProperty;var n=(t,a)=>S(t,"name",{value:a,configurable:!0});import{getNode as v,subscribersOf as R,subscriptionsOf as I}from"./index.js";import{faultSummary as C}from"./status-glyph.js";import{statusRank as _}from"./node-order.js";import{nodeGlyph as G,navLabel as O,shortId as T,tokensCell as D,activityCell as W,cycleBadge as L,askBadge as M,liveBelowBadge as N,truncate as H,fillBar as k,fillWidth as B,isAttached as K,BOLD as P,DIM as E,RESET as p,REVERSE as V,BG_ATTACHED as Y}from"./nav-render.js";import{filterAsync as b,mapAsync as F}from"../async-array.js";import{PI_MAX_WIDGET_LINES as wt,VIEWPORT_FALLBACK_ROWS as pt,ESC as yt,RESET as $t,BOLD as mt,DIM as vt,REVERSE as Et,BG_ATTACHED as xt,GREEN as gt,RED as kt,YELLOW as Bt,CYAN as bt,GRAY as At,nodeGlyph as St,visibleWidth as Rt,truncate as It,fillWidth as Ct,fillBar as _t,fmtTokens as Gt,tokensCell as Ot,activityCell as Tt,cycleBadge as Dt,navLabel as Wt,shortId as Lt,askBadge as Mt,liveBelowBadge as Nt,isAttached as Ht,hasBrokerViewers as Kt,fetchAsksMap as Pt,graphWidgetBudget as Vt,GRAPH_HINT as Yt}from"./nav-render.js";async function q(t){try{return await I(t)}catch{return[]}}n(q,"subsOf");async function X(t){try{return await R(t)}catch{return[]}}n(X,"mgrsOf");async function j(t){return(await X(t))[0]?.node_id}n(j,"managerOf");async function z(t){return(await v(t))?.kind==="human"}n(z,"isHumanAsk");async function y(t){return await b((await q(t)).map(a=>a.node_id),async a=>!await z(a))}n(y,"convoChildIds");async function it(t){return await b(await y(t),async a=>{const s=(await v(a))?.status;return s==="active"||s==="idle"})}n(it,"liveReports");async function J(t){return(await y(t)).length}n(J,"childCount");async function Q(t){let a=t;const s=new Set([a]);for(;;){const o=await j(a);if(o===void 0||s.has(o))break;s.add(o),a=o}return a}n(Q,"climbRoot");async function lt(t){const a=[],s=new Set([t]),o=await y(t);for(;o.length>0;){const i=o.shift();if(!s.has(i)){s.add(i),a.push(i);for(const l of await y(i))s.has(l)||o.push(l)}}return a}n(lt,"subtreeIds");async function U(t){if(t===null)return"";const a=await J(t.node_id);return a>0?` ${E}\u2933${a}${p}`:""}n(U,"childBadge");async function Z(t){return(await F(await y(t),async a=>({cid:a,rank:_((await v(a))?.status)}))).sort((a,s)=>a.rank-s.rank).map(({cid:a})=>a)}n(Z,"sortedChildIds");async function tt(t,a){const s=new Set,o=new Map,i=new Set,l=n(async e=>{const u=(await v(e))?.status==="active";if(i.has(e))return{active:u?1:0,reveal:u||e===a};i.add(e);let d=0,c=!1;for(const h of await y(e)){const f=await l(h);d+=f.active,f.reveal&&(c=!0)}return o.set(e,d),c&&s.add(e),{active:d+(u?1:0),reveal:c||u||e===a}},"visit");return await l(t),{expand:s,activeBelow:o}}n(tt,"computeSubtreeActivity");async function at(t,a){return(await tt(t,a)).expand}n(at,"computeDefaultExpanded");async function ut(t,a,s){const o=await Q(t),i=s??await at(o,t),l=n(c=>a.userExpanded.has(c)?!1:a.userCollapsed.has(c)?!0:!i.has(c),"isFolded"),e=[],u=new Set,d=n(async(c,h,f,$)=>{if(u.has(c)){const r=f?"":$?"\u2514\u2500 ":"\u251C\u2500 ";e.push({id:c,hasKids:!1,isSelf:c===t,branch:h+r,cycle:!0,collapsed:!1});return}u.add(c);const w=await Z(c),m=l(c),x=f?"":$?"\u2514\u2500 ":"\u251C\u2500 ";if(e.push({id:c,hasKids:w.length>0,isSelf:c===t,branch:h+x,cycle:!1,collapsed:m}),m)return;const g=f?"":h+($?" ":"\u2502 ");for(let r=0;r<w.length;r++)await d(w[r],g,!1,r===w.length-1)},"walk");return await d(o,"",!0,!0),e}n(ut,"buildGraphModel");async function dt(t,a,s,o,i){const l=n((r,A)=>a?k(r,B(),V):A?k(r,B(),Y):H(r),"wrap");if(t.cycle){const r=`${t.branch} ${E}\u21BA ${T(t.id)}${p}`;return l(r,!1)}const e=await v(t.id),u=G(e),d=O(e,t.id),c=t.isSelf?`${P}${d}${p}`:d,h=`${E}${e?.kind??""}${p}`,f=`${E}${D(e)}${p}`,$=t.hasKids&&t.collapsed,w=!a&&$?`${E}\u25B8${p} `:" ",m=e?.fault??null,x=m!==null?` \xB7 ${C(m)}`:"",g=`${t.branch}${w}${u} ${c} ${h} ${f}${L(e)}${await U(e)}${N(e,o)}${M(t.id,i)}${W(e)}${x}`;return l(g,K(t.id,e,s))}n(dt,"renderGraphRow");export{xt as BG_ATTACHED,mt as BOLD,bt as CYAN,vt as DIM,yt as ESC,Yt as GRAPH_HINT,At as GRAY,gt as GREEN,wt as PI_MAX_WIDGET_LINES,kt as RED,$t as RESET,Et as REVERSE,pt as VIEWPORT_FALLBACK_ROWS,Bt as YELLOW,Tt as activityCell,Mt as askBadge,ut as buildGraphModel,U as childBadge,J as childCount,Q as climbRoot,at as computeDefaultExpanded,tt as computeSubtreeActivity,y as convoChildIds,Dt as cycleBadge,Pt as fetchAsksMap,_t as fillBar,Ct as fillWidth,Gt as fmtTokens,Vt as graphWidgetBudget,Kt as hasBrokerViewers,Ht as isAttached,z as isHumanAsk,Nt as liveBelowBadge,it as liveReports,j as managerOf,Wt as navLabel,St as nodeGlyph,dt as renderGraphRow,Lt as shortId,Z as sortedChildIds,lt as subtreeIds,Ot as tokensCell,It as truncate,Rt as visibleWidth};
@@ -1,8 +1,8 @@
1
1
  /** Resolve an existing node's app from the sole durable assignment, its row.
2
2
  * Brokers have only their own app in their launch environment, not the DB. */
3
- export declare function appForNode(nodeId: string): string;
4
- export declare function nodeAgentDir(nodeId: string, grantee?: string): string;
5
- export declare function contextDir(nodeId: string, grantee?: string): string;
6
- export declare function reportsDir(nodeId: string, grantee?: string): string;
7
- export declare function interpolateNodePaths(text: string, nodeId: string): string;
8
- export declare function ensureNodeDirs(nodeId: string, grantee?: string): void;
3
+ export declare function appForNode(nodeId: string): Promise<string>;
4
+ export declare function nodeAgentDir(nodeId: string, grantee?: string): Promise<string>;
5
+ export declare function contextDir(nodeId: string, grantee?: string): Promise<string>;
6
+ export declare function reportsDir(nodeId: string, grantee?: string): Promise<string>;
7
+ export declare function interpolateNodePaths(text: string, nodeId: string): Promise<string>;
8
+ export declare function ensureNodeDirs(nodeId: string, grantee?: string): Promise<void>;
@@ -1 +1 @@
1
- var a=Object.defineProperty;var t=(r,e)=>a(r,"name",{value:e,configurable:!0});import{prepared as s}from"../sqlite-statements.js";import{join as p}from"node:path";import{envGrantee as u,envNodeId as f}from"../../shared/env.js";import{openDb as c}from"./db.js";import{nodeAgentDir as m,ensureNodeDirs as D,interpolateNodePaths as g}from"./paths.js";function o(r){const e=u();if(f()===r&&e)return e;const n=s(c(),"SELECT grantee FROM node_rows WHERE node_id = ?").get(r);if(!n?.grantee)throw new Error(`node ${r} has no app assignment`);return n.grantee}t(o,"appForNode");function i(r,e){return m(r,e??o(r))}t(i,"nodeAgentDir");function E(r,e){return p(i(r,e),"context")}t(E,"contextDir");function F(r,e){return p(i(r,e),"reports")}t(F,"reportsDir");function l(r,e){return g(r,e,o(e))}t(l,"interpolateNodePaths");function P(r,e){D(r,e??o(r))}t(P,"ensureNodeDirs");export{o as appForNode,E as contextDir,P as ensureNodeDirs,l as interpolateNodePaths,i as nodeAgentDir,F as reportsDir};
1
+ var p=Object.defineProperty;var e=(r,t)=>p(r,"name",{value:t,configurable:!0});import{join as a}from"node:path";import{envGrantee as s,envNodeId as c}from"../../shared/env.js";import{openDb as u}from"./db.js";import{nodeAgentDir as f,ensureNodeDirs as w,interpolateNodePaths as m}from"./paths.js";async function n(r){const t=s();if(c()===r&&t)return t;const o=await(await u()).prepare("SELECT grantee FROM node_rows WHERE node_id = ?").get(r);if(!o?.grantee)throw new Error(`node ${r} has no app assignment`);return o.grantee}e(n,"appForNode");async function i(r,t){return f(r,t??await n(r))}e(i,"nodeAgentDir");async function N(r,t){return a(await i(r,t),"context")}e(N,"contextDir");async function h(r,t){return a(await i(r,t),"reports")}e(h,"reportsDir");async function E(r,t){return m(r,t,await n(t))}e(E,"interpolateNodePaths");async function F(r,t){w(r,t??await n(r))}e(F,"ensureNodeDirs");export{n as appForNode,N as contextDir,F as ensureNodeDirs,E as interpolateNodePaths,i as nodeAgentDir,h as reportsDir};
@@ -1,4 +1,4 @@
1
- import { openDb } from './db.js';
1
+ import { type CanvasDb } from './db.js';
2
2
  export interface NodePrincipal {
3
3
  app: string;
4
4
  node: string;
@@ -9,16 +9,16 @@ export interface NodePrincipal {
9
9
  client_id: string | null;
10
10
  scopes: string[] | null;
11
11
  }
12
- export declare function mintNodeToken(db: ReturnType<typeof openDb>, executionId: string, nodeId: string, issuedAt: string): void;
12
+ export declare function mintNodeToken(db: CanvasDb, executionId: string, nodeId: string, issuedAt: string): Promise<void>;
13
13
  /** Called exactly once by the host at spawn, never serialized into a launch recipe. */
14
14
  export declare function takeNodeToken(executionId: string): string;
15
15
  export declare function forgetNodeToken(executionId: string): void;
16
16
  /** A stopped or superseded execution can never authenticate, even after restart. */
17
- export declare function resolveNodeToken(token: string): NodePrincipal | null;
18
- export declare function revokeExitedNodeToken(executionId: string): void;
19
- export declare function revokePriorEpochNodeTokens(epoch: string): void;
17
+ export declare function resolveNodeToken(token: string): Promise<NodePrincipal | null>;
18
+ export declare function revokeExitedNodeToken(executionId: string): Promise<void>;
19
+ export declare function revokePriorEpochNodeTokens(epoch: string): Promise<void>;
20
20
  /** OWN-11 for a joined runtime: a `user:local` subject becomes the owner, a
21
21
  * `user:local` grantee becomes `app:terminal` (no token has the owner as grantee),
22
22
  * and a reference to the dropped local grant is cleared. */
23
- export declare function rewriteLocalNodeTokenIdentity(db: ReturnType<typeof openDb>, owner: string, localGrantId: string): number;
24
- export declare function revokeNodeTokens(db: ReturnType<typeof openDb>, where: 'broker_process_id' | 'node_id', id: string, at: string): void;
23
+ export declare function rewriteLocalNodeTokenIdentity(db: CanvasDb, owner: string, localGrantId: string): Promise<number>;
24
+ export declare function revokeNodeTokens(db: CanvasDb, where: 'broker_process_id' | 'node_id', id: string, at: string): Promise<void>;
@@ -1,5 +1,5 @@
1
- var k=Object.defineProperty;var o=(e,n)=>k(e,"name",{value:n,configurable:!0});import{prepared as i}from"../sqlite-statements.js";import{createHash as m,randomBytes as N}from"node:crypto";import{openDb as _,prepared as T}from"./db.js";import{terminalGrant as f}from"../grants/mirror.js";import{readConfig as l}from"../config.js";import{uidForApp as S}from"../spaces/users.js";const s=new Map,E=o(e=>m("sha256").update(e).digest("hex"),"hash");function v(e,n,r,a){const t=i(e,"SELECT grantee, sub, grant_id, client_id, scopes_json, run_id FROM node_rows WHERE node_id = ?").get(r);if(!t)throw new Error(`cannot mint node token: missing node ${r}`);const d=t.run_id&&t.run_id!==r?i(e,"SELECT sub, grant_id, client_id FROM nodes WHERE node_id = ?").get(t.run_id):void 0,u=t.grantee==="app:terminal"?f():null,c=u?.sub??d?.sub??t.sub,g=u?.id??d?.grant_id??t.grant_id??null;if(t.grantee==="app:terminal"&&l("user").runtime?.issuer&&!u)throw new Error("cannot mint node token: terminal grant is not active");if(!c&&t.grantee!=="user:local"&&!(t.grantee==="app:terminal"&&!l("user").runtime?.issuer))throw new Error(`cannot mint node token: no subject for ${t.grantee}`);const p=N(32).toString("base64url");i(e,"INSERT INTO node_tokens (broker_process_id, node_id, token_hash, grantee, uid, sub, grant, client_id, scopes_json, issued_at, revoked_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)").run(n,r,E(p),t.grantee==="user:local"?"app:terminal":t.grantee,S(t.grantee==="user:local"?"app:terminal":t.grantee),c??"user:local",g,d?.client_id??t.client_id,t.scopes_json,a),s.set(n,p)}o(v,"mintNodeToken");function U(e){const n=s.get(e);if(s.delete(e),!n)throw new Error(`missing node token for execution ${e}`);return n}o(U,"takeNodeToken");function h(e){s.delete(e)}o(h,"forgetNodeToken");function H(e){if(!/^[A-Za-z0-9_-]{43}$/.test(e))return null;const n=T(_(),`SELECT t.node_id, t.grantee, t.uid, t.sub, t.grant, t.client_id, t.scopes_json, n.run_id
1
+ var g=Object.defineProperty;var r=(e,n)=>g(e,"name",{value:n,configurable:!0});import{createHash as k,randomBytes as m}from"node:crypto";import{openDb as u}from"./db.js";import{terminalGrant as w}from"../grants/mirror.js";import{readConfig as _}from"../config.js";import{uidForApp as N}from"../spaces/users.js";const a=new Map,l=r(e=>k("sha256").update(e).digest("hex"),"hash");async function x(e,n,o,i){const t=await e.prepare("SELECT grantee, sub, grant_id, client_id, scopes_json, run_id FROM node_rows WHERE node_id = ?").get(o);if(!t)throw new Error(`cannot mint node token: missing node ${o}`);const s=t.run_id&&t.run_id!==o?await e.prepare("SELECT sub, grant_id, client_id FROM nodes WHERE node_id = ?").get(t.run_id):void 0,d=t.grantee==="app:terminal"?await w():null,p=d?.sub??s?.sub??t.sub,E=d?.id??s?.grant_id??t.grant_id??null;if(t.grantee==="app:terminal"&&_("user").runtime?.issuer&&!d)throw new Error("cannot mint node token: terminal grant is not active");if(!p&&t.grantee!=="user:local"&&!(t.grantee==="app:terminal"&&!_("user").runtime?.issuer))throw new Error(`cannot mint node token: no subject for ${t.grantee}`);const c=m(32).toString("base64url");await e.prepare("INSERT INTO node_tokens (broker_process_id, node_id, token_hash, grantee, uid, sub, grant, client_id, scopes_json, issued_at, revoked_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)").run(n,o,l(c),t.grantee==="user:local"?"app:terminal":t.grantee,await N(t.grantee==="user:local"?"app:terminal":t.grantee),p??"user:local",E,s?.client_id??t.client_id,t.scopes_json,i),a.set(n,c)}r(x,"mintNodeToken");function A(e){const n=a.get(e);if(a.delete(e),!n)throw new Error(`missing node token for execution ${e}`);return n}r(A,"takeNodeToken");function T(e){a.delete(e)}r(T,"forgetNodeToken");async function D(e){if(!/^[A-Za-z0-9_-]{43}$/.test(e))return null;const n=await(await u()).prepare(`SELECT t.node_id, t.grantee, t.uid, t.sub, t.grant, t.client_id, t.scopes_json, n.run_id
2
2
  FROM node_tokens t JOIN executions e ON e.execution_id = t.broker_process_id
3
3
  JOIN nodes n ON n.node_id = t.node_id
4
- WHERE t.token_hash = ? AND t.revoked_at IS NULL AND e.state != 'exited'`).get(E(e));return n?{app:n.grantee,node:n.node_id,run:n.run_id,uid:n.uid,sub:n.sub,grant:n.grant,client_id:n.client_id,scopes:n.scopes_json===null?null:JSON.parse(n.scopes_json)}:null}o(H,"resolveNodeToken");function W(e){h(e),b(_(),"broker_process_id",e,new Date().toISOString())}o(W,"revokeExitedNodeToken");function j(e){i(_(),`UPDATE node_tokens SET revoked_at = ? WHERE revoked_at IS NULL
5
- AND broker_process_id IN (SELECT execution_id FROM executions WHERE daemon_epoch IS NOT ?)`).run(new Date().toISOString(),e)}o(j,"revokePriorEpochNodeTokens");function P(e,n,r){return Number(i(e,"UPDATE node_tokens SET sub = ? WHERE sub = 'user:local'").run(n).changes)+Number(i(e,"UPDATE node_tokens SET grantee = 'app:terminal' WHERE grantee = 'user:local'").run().changes)+Number(i(e,'UPDATE node_tokens SET "grant" = NULL WHERE "grant" = ?').run(r).changes)}o(P,"rewriteLocalNodeTokenIdentity");function b(e,n,r,a){e.prepare(`UPDATE node_tokens SET revoked_at = ? WHERE ${n} = ? AND revoked_at IS NULL`).run(a,r)}o(b,"revokeNodeTokens");export{h as forgetNodeToken,v as mintNodeToken,H as resolveNodeToken,W as revokeExitedNodeToken,b as revokeNodeTokens,j as revokePriorEpochNodeTokens,P as rewriteLocalNodeTokenIdentity,U as takeNodeToken};
4
+ WHERE t.token_hash = ? AND t.revoked_at IS NULL AND e.state != 'exited'`).get(l(e));return n?{app:n.grantee,node:n.node_id,run:n.run_id,uid:n.uid,sub:n.sub,grant:n.grant,client_id:n.client_id,scopes:n.scopes_json===null?null:JSON.parse(n.scopes_json)}:null}r(D,"resolveNodeToken");async function U(e){T(e),await f(await u(),"broker_process_id",e,new Date().toISOString())}r(U,"revokeExitedNodeToken");async function v(e){await(await u()).prepare(`UPDATE node_tokens SET revoked_at = ? WHERE revoked_at IS NULL
5
+ AND broker_process_id IN (SELECT execution_id FROM executions WHERE daemon_epoch IS NOT ?)`).run(new Date().toISOString(),e)}r(v,"revokePriorEpochNodeTokens");async function H(e,n,o){return Number((await e.prepare("UPDATE node_tokens SET sub = ? WHERE sub = 'user:local'").run(n)).changes)+Number((await e.prepare("UPDATE node_tokens SET grantee = 'app:terminal' WHERE grantee = 'user:local'").run()).changes)+Number((await e.prepare('UPDATE node_tokens SET "grant" = NULL WHERE "grant" = ?').run(o)).changes)}r(H,"rewriteLocalNodeTokenIdentity");async function f(e,n,o,i){await e.prepareUncached(`UPDATE node_tokens SET revoked_at = ? WHERE ${n} = ? AND revoked_at IS NULL`).run(i,o)}r(f,"revokeNodeTokens");export{T as forgetNodeToken,x as mintNodeToken,D as resolveNodeToken,U as revokeExitedNodeToken,f as revokeNodeTokens,v as revokePriorEpochNodeTokens,H as rewriteLocalNodeTokenIdentity,A as takeNodeToken};
@@ -1,8 +1,8 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
1
  import type { ObjectRow } from '../graph/types.js';
3
2
  import type { NodeOutcomeDocumentV1 } from '../runtime/outcome-document.js';
4
3
  import type { OutcomeDeliveryBinding } from './canvas.js';
5
4
  import { type DeliveryRecord } from './deliveries.js';
5
+ import type { CanvasDb } from './db.js';
6
6
  export interface OutcomeActionRecord {
7
7
  object: ObjectRow;
8
8
  actionName: string;
@@ -14,10 +14,10 @@ export interface OutcomeActionRecord {
14
14
  updatedAt: number;
15
15
  }
16
16
  /** Resolve only the live action belonging to this node, never an unrelated action of the same name. */
17
- export declare function readOutcomeAction(db: DatabaseSync, nodeId: string): OutcomeActionRecord | null;
17
+ export declare function readOutcomeAction(db: CanvasDb, nodeId: string): Promise<OutcomeActionRecord | null>;
18
18
  /** Register or replace an undelivered action in the caller's transaction. */
19
- export declare function registerOutcomeAction(db: DatabaseSync, nodeId: string, binding: OutcomeDeliveryBinding): void;
19
+ export declare function registerOutcomeAction(db: CanvasDb, nodeId: string, binding: OutcomeDeliveryBinding): Promise<void>;
20
20
  /** Refuse removal after any delivery, including an acknowledged historical one. */
21
- export declare function unregisterOutcomeAction(db: DatabaseSync, nodeId: string): boolean;
21
+ export declare function unregisterOutcomeAction(db: CanvasDb, nodeId: string): Promise<boolean>;
22
22
  /** Late registration dispatches directly to its action, not to every outcome watcher. */
23
- export declare function enqueueLateOutcomeAction(db: DatabaseSync, nodeId: string, document: NodeOutcomeDocumentV1): void;
23
+ export declare function enqueueLateOutcomeAction(db: CanvasDb, nodeId: string, document: NodeOutcomeDocumentV1): Promise<void>;
@@ -1,6 +1,6 @@
1
- var u=Object.defineProperty;var i=(o,t)=>u(o,"name",{value:t,configurable:!0});import{prepared as c}from"../sqlite-statements.js";import{createObject as m,nodeObject as d}from"../graph/objects.js";import{recordWatch as p}from"../graph/watches.js";import{argvReceiver as v}from"../graph/receivers.js";import{finalizeNodeMail as E,insertMessage as j}from"../feed/messages.js";import{deliveryFrom as f}from"./deliveries.js";function l(o,t){const e=c(o,`SELECT a.*, c.receiver_json, c.payload_json FROM objects a
1
+ var p=Object.defineProperty;var i=(t,a)=>p(t,"name",{value:a,configurable:!0});import{createObject as u,nodeObject as l}from"../graph/objects.js";import{recordWatch as d}from"../graph/watches.js";import{argvReceiver as m}from"../graph/receivers.js";import{finalizeNodeMail as w,insertMessage as v}from"../feed/messages.js";import{deliveryFrom as E}from"./deliveries.js";async function s(t,a){const e=await t.prepare(`SELECT a.*, c.receiver_json, c.payload_json FROM objects a
2
2
  JOIN objects n ON n.id = ? AND n.type = 'node'
3
3
  JOIN custom_objects c ON c.object = a.rowid
4
4
  WHERE a.type = 'action' AND a.name = ? AND a.owner = n.owner AND a.deleted_at IS NULL
5
- ORDER BY a.rowid DESC LIMIT 1`).get(t,`outcome/${t}`);if(!e)return null;const a=JSON.parse(e.receiver_json),r=c(o,"SELECT * FROM deliveries WHERE destination_id = ? ORDER BY created_at DESC, rowid DESC LIMIT 1").get(e.id);return{object:e,actionName:a.name,argv:a.argv,cwd:a.cwd,configOrigin:a.config_origin,payload:e.payload_json===null?null:JSON.parse(e.payload_json),delivery:r?f(r):null,updatedAt:a.updated_at??Date.parse(e.created_at)}}i(l,"readOutcomeAction");function S(o,t,e){const a=d(o,t),r=l(o,t);if(r?.delivery)throw new Error(`outcome action ${t} already has a delivery`);const n=r?.object??m(o,{type:"action",kind:null,owner:a.owner,privacy:"public",name:`outcome/${t}`,preview:e.actionName}),s=JSON.stringify({argv:e.argv,cwd:e.cwd,config_origin:e.configOrigin,name:e.actionName,updated_at:r?Math.max(Date.now(),r.updatedAt+1):Date.parse(n.created_at)});c(o,`INSERT INTO custom_objects (object, receiver_json, payload_json) VALUES (?, ?, ?)
6
- ON CONFLICT(object) DO UPDATE SET receiver_json = excluded.receiver_json, payload_json = excluded.payload_json`).run(n.rowid,s,JSON.stringify(e.payload??null)),r?c(o,"UPDATE objects SET preview = ? WHERE rowid = ?").run(e.actionName,n.rowid):(c(o,"UPDATE objects SET reception = 2 WHERE rowid = ?").run(n.rowid),p(o,n,a,"spawn",{patterns:["outcome"],config:[{threshold:1,delivery:"after-turn"}]}))}i(S,"registerOutcomeAction");function T(o,t){const e=l(o,t);return e?e.delivery?!1:(c(o,"DELETE FROM objects WHERE rowid = ?").run(e.object.rowid),!0):!0}i(T,"unregisterOutcomeAction");function A(o,t,e){const a=l(o,t);if(!a||a.delivery)throw new Error(`outcome action ${t} cannot be delivered again`);const r=d(o,t),n=E({senderNodeId:t,senderName:r.name,kind:"completed",label:`outcome node ${r.name}`,bodyJson:e,urgency:"normal"},null),s=j(o,{...n,senderNodeId:t,senderName:r.name,kind:"completed",label:`outcome node ${r.name}`,disposition:null,event:{event:"outcome",objectId:t,level:1,actorId:t}});v.enqueue(o,{messageId:s,event:"outcome",level:1,senderNodeId:t,elevatesTier:!1},[{id:a.object.id,reception:2,delivery:"after-turn"}])}i(A,"enqueueLateOutcomeAction");export{A as enqueueLateOutcomeAction,l as readOutcomeAction,S as registerOutcomeAction,T as unregisterOutcomeAction};
5
+ ORDER BY a.rowid DESC LIMIT 1`).get(a,`outcome/${a}`);if(!e)return null;const r=JSON.parse(e.receiver_json),o=await t.prepare("SELECT * FROM deliveries WHERE destination_id = ? ORDER BY created_at DESC, rowid DESC LIMIT 1").get(e.id);return{object:e,actionName:r.name,argv:r.argv,cwd:r.cwd,configOrigin:r.config_origin,payload:e.payload_json===null?null:JSON.parse(e.payload_json),delivery:o?E(o):null,updatedAt:r.updated_at??Date.parse(e.created_at)}}i(s,"readOutcomeAction");async function g(t,a,e){const r=await l(t,a),o=await s(t,a);if(o?.delivery)throw new Error(`outcome action ${a} already has a delivery`);const n=o?.object??await u(t,{type:"action",kind:null,owner:r.owner,privacy:"public",name:`outcome/${a}`,preview:e.actionName}),c=JSON.stringify({argv:e.argv,cwd:e.cwd,config_origin:e.configOrigin,name:e.actionName,updated_at:o?Math.max(Date.now(),o.updatedAt+1):Date.parse(n.created_at)});await t.prepare(`INSERT INTO custom_objects (object, receiver_json, payload_json) VALUES (?, ?, ?)
6
+ ON CONFLICT(object) DO UPDATE SET receiver_json = excluded.receiver_json, payload_json = excluded.payload_json`).run(n.rowid,c,JSON.stringify(e.payload??null)),o?await t.prepare("UPDATE objects SET preview = ? WHERE rowid = ?").run(e.actionName,n.rowid):(await t.prepare("UPDATE objects SET reception = 2 WHERE rowid = ?").run(n.rowid),await d(t,n,r,"spawn",{patterns:["outcome"],config:[{threshold:1,delivery:"after-turn"}]}))}i(g,"registerOutcomeAction");async function D(t,a){const e=await s(t,a);return e?e.delivery?!1:(await t.prepare("DELETE FROM objects WHERE rowid = ?").run(e.object.rowid),!0):!0}i(D,"unregisterOutcomeAction");async function S(t,a,e){const r=await s(t,a);if(!r||r.delivery)throw new Error(`outcome action ${a} cannot be delivered again`);const o=await l(t,a),n=w({senderNodeId:a,senderName:o.name,kind:"completed",label:`outcome node ${o.name}`,bodyJson:e,urgency:"normal"},null),c=await v(t,{...n,senderNodeId:a,senderName:o.name,kind:"completed",label:`outcome node ${o.name}`,disposition:null,event:{event:"outcome",objectId:a,level:1,actorId:a}});await m.enqueue(t,{messageId:c,event:"outcome",level:1,senderNodeId:a,elevatesTier:!1},[{id:r.object.id,reception:2,delivery:"after-turn"}])}i(S,"enqueueLateOutcomeAction");export{S as enqueueLateOutcomeAction,s as readOutcomeAction,g as registerOutcomeAction,D as unregisterOutcomeAction};
@@ -28,68 +28,68 @@ export interface TransportPoisonVerdict {
28
28
  routes: string[];
29
29
  }
30
30
  export interface BootFaultAttempt {
31
- explanation(): string | null;
31
+ explanation(): Promise<string | null>;
32
32
  }
33
33
  export declare function parseProviderError(value: unknown): FaultProviderError | undefined;
34
34
  export declare function hydrateFault(row: Record<string, unknown>): StoredFault;
35
35
  export declare function openTurn(executionId: string, _opts: {
36
36
  reason: 'agent-start' | 'prompt-unsettled';
37
- }): boolean;
38
- export declare function recordTurnProgress(executionId: string): boolean;
37
+ }): Promise<boolean>;
38
+ export declare function recordTurnProgress(executionId: string): Promise<boolean>;
39
39
  /** Closes the open turn. A `settled` close also stamps the node's `reply_at` (the dashboard's unread marker) in the same
40
40
  * write, and `read_at` too when a viewer was shown the conversation while the turn ended. A close that changes no row writes neither. */
41
41
  export declare function closeTurn(executionId: string, opts: {
42
42
  endReason: 'settled' | 'teardown-aborted';
43
43
  viewerPresent?: boolean;
44
- }): boolean;
44
+ }): Promise<boolean>;
45
45
  /** Stamps `read_at`: a viewer has just been shown this conversation. */
46
- export declare function markNodeRead(nodeId: string): boolean;
47
- export declare function recordTransportPoisonVerdict(executionId: string, verdict: TransportPoisonVerdict): boolean;
48
- export declare function readTransportPoisonVerdict(nodeId: string): TransportPoisonVerdict | null;
49
- export declare function readLiveTurn(nodeId: string): {
46
+ export declare function markNodeRead(nodeId: string): Promise<boolean>;
47
+ export declare function recordTransportPoisonVerdict(executionId: string, verdict: TransportPoisonVerdict): Promise<boolean>;
48
+ export declare function readTransportPoisonVerdict(nodeId: string): Promise<TransportPoisonVerdict | null>;
49
+ export declare function readLiveTurn(nodeId: string): Promise<{
50
50
  busy: boolean;
51
51
  progressAt: string | null;
52
- } | null;
53
- export declare function readInterruptedTurn(nodeId: string): {
52
+ } | null>;
53
+ export declare function readInterruptedTurn(nodeId: string): Promise<{
54
54
  interrupted: boolean;
55
55
  progressAt: string | null;
56
- } | null;
56
+ } | null>;
57
57
  /** Whether any execution of this node ever admitted a turn (agent_start recorded
58
58
  * by the daemon). This, not the transcript, is the durable fact that a node's
59
59
  * birth task was delivered: a session file holding only the bearings message
60
60
  * exists before the kickoff is admitted. */
61
- export declare function hasAdmittedTurn(nodeId: string): boolean;
62
- export declare function recordFault(nodeId: string, input: FaultRecordInput): StoredFault | null;
61
+ export declare function hasAdmittedTurn(nodeId: string): Promise<boolean>;
62
+ export declare function recordFault(nodeId: string, input: FaultRecordInput): Promise<StoredFault | null>;
63
63
  /** Record that the fatal-fault notice for this fault row's current episode has been published. Callers run it in the write that publishes. */
64
- export declare function markFaultNotified(faultId: string): boolean;
64
+ export declare function markFaultNotified(faultId: string): Promise<boolean>;
65
65
  /** Nodes whose active fatal provider fault has not been announced yet, read from the fault table so a node with no live broker is still found. */
66
- export declare function listUnnotifiedFatalFaultNodes(): string[];
66
+ export declare function listUnnotifiedFatalFaultNodes(): Promise<string[]>;
67
67
  /** The daemon registers the one function that publishes a fatal provider fault's notice. Every clear of an unannounced fatal fault runs it first, so no clear can drop a notice. */
68
- export declare function setFatalFaultAnnouncer(announce: ((nodeId: string) => void) | null): void;
68
+ export declare function setFatalFaultAnnouncer(announce: ((nodeId: string) => Promise<void>) | null): void;
69
69
  export declare function clearFault(nodeId: string, opts?: {
70
70
  link?: FaultLink;
71
71
  preserveEpisode?: boolean;
72
- }): boolean;
73
- export declare function readFault(nodeId: string): StoredFault | null;
72
+ }): Promise<boolean>;
73
+ export declare function readFault(nodeId: string): Promise<StoredFault | null>;
74
74
  export declare function recordPendingEpisode(nodeId: string, input: {
75
75
  sessionId: string;
76
76
  input: FaultRecordInput;
77
- }): StoredFault | null;
77
+ }): Promise<StoredFault | null>;
78
78
  export declare function admitEpisode(nodeId: string, input: {
79
79
  sessionId: string;
80
80
  faultId: string;
81
81
  retry: FaultRetry;
82
- }): boolean;
82
+ }): Promise<boolean>;
83
83
  export declare function reopenEpisode(nodeId: string, input: {
84
84
  sessionId: string;
85
- }): boolean;
85
+ }): Promise<boolean>;
86
86
  export declare function invalidateEpisode(nodeId: string, input: {
87
87
  sessionId: string;
88
- }): boolean;
88
+ }): Promise<boolean>;
89
89
  export declare function clearEpisode(nodeId: string, input: {
90
90
  sessionId: string;
91
- }): boolean;
92
- export declare function readEpisode(nodeId: string): ProviderRetryEpisode | null;
91
+ }): Promise<boolean>;
92
+ export declare function readEpisode(nodeId: string): Promise<ProviderRetryEpisode | null>;
93
93
  /** One active automatic provider-retry fault whose `pending` episode is bound to
94
94
  * its node's live session — the shape a broker's in-process retry timer owns. */
95
95
  export interface PendingProviderRetry {
@@ -102,8 +102,8 @@ export interface PendingProviderRetry {
102
102
  /** Every node with an active daemon-retried provider fault (connection,
103
103
  * rate-limit, overloaded) and a pending episode on its live session binding.
104
104
  * The daemon backstop reads this to find retries whose broker timer died. */
105
- export declare function listPendingProviderRetries(): PendingProviderRetry[];
106
- export declare function beginBootFaultAttempt(nodeId: string): BootFaultAttempt;
105
+ export declare function listPendingProviderRetries(): Promise<PendingProviderRetry[]>;
106
+ export declare function beginBootFaultAttempt(nodeId: string): Promise<BootFaultAttempt>;
107
107
  /** Import legacy witness and recovery files inside the parent's one shared consolidation transaction. */
108
108
  /** v98 — `notified_since` on a fault row: the episode start its fatal notice was published for.
109
109
  * No backfill: a fatal fault already active at upgrade reads as unannounced and is announced once more,