@north-light/cli 0.3.530 → 0.3.531

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 +3 -3
  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 +1 -1
  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 +7 -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 +6 -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,10 +1,7 @@
1
- /** The repo-sync engine in crtrd: per repo at most one sync running and one queued. No timer and
2
- * no retry loop — the next trigger is the retry. A failed sync keeps the local mirror commit and
3
- * every canvas.db revision; the next run sends them. Every outcome is written as an event. */
4
- import type { DatabaseSync } from 'node:sqlite';
5
1
  import type { DetachedWorkLifecycle } from '../../../daemon/reconcilers/broker-supervision.js';
6
2
  import type { ObjectRow } from '../types.js';
7
3
  import { type ImportResult } from './exchange.js';
4
+ import { type CanvasDb } from '../../canvas/db.js';
8
5
  export declare const FIRST_FETCH_WAIT_MS = 20000;
9
6
  export type SyncStep = 'export' | 'fetch' | 'merge' | 'import' | 'push';
10
7
  export type SyncOutcome = {
@@ -17,7 +14,7 @@ export type SyncOutcome = {
17
14
  reason: string;
18
15
  };
19
16
  /** Called once by crtrd. Until then triggers are refused loudly. */
20
- export declare function startRepoSync(lifecycle: DetachedWorkLifecycle, db: () => DatabaseSync): void;
17
+ export declare function startRepoSync(lifecycle: DetachedWorkLifecycle, db: () => Promise<CanvasDb>): Promise<void>;
21
18
  /**
22
19
  * A node starts working in `cwd`, enclosed by `repos`. For each syncing repo: when no fetch has
23
20
  * ever succeeded on this machine and none was attempted in this daemon's lifetime, wait for its
@@ -34,7 +31,7 @@ export declare function noteNodeBooting(nodeId: string): Promise<void>;
34
31
  /** A repo-owned document changed (write, edit, move at either end, delete). `dirs`, the caller's
35
32
  * cwd and the checkouts it reaches, record the fetch URL of any that is a checkout of the repo; the
36
33
  * sync itself never depends on where the writer runs. */
37
- export declare function noteRepoDocumentsChanged(repo: ObjectRow, dirs?: readonly string[]): void;
34
+ export declare function noteRepoDocumentsChanged(repo: ObjectRow, dirs?: readonly string[]): Promise<void>;
38
35
  /**
39
36
  * One sync: export canvas.db to a local commit, fetch the remote ref, fast-forward or merge,
40
37
  * import the merged tree into canvas.db, push (never forced). A rejected push fetches again,
@@ -1,2 +1,2 @@
1
- var B=Object.defineProperty;var c=(t,r)=>B(t,"name",{value:r,configurable:!0});import{prepared as v}from"../../sqlite-statements.js";import{existsSync as D}from"node:fs";import{readFile as K,writeFile as q}from"node:fs/promises";import{join as S}from"node:path";import{emitEvent as G}from"../../events/emit.js";import{exportRepo as J,importTree as Q,pendingPaths as V}from"./exchange.js";import{checkoutChain as X}from"./identity.js";import{checkoutsForCwd as Y,reposForCwd as Z}from"./repos.js";import{commitTree as k,fetchDocs as ee,FIRST_FETCH_MARKER as te,isAncestor as L,mergeBase as re,openMirror as _,pushDocs as ne,readTree as p,remoteDocsTip as oe,resolveRef as h,setRef as y}from"./mirror.js";import{mergeTrees as se}from"./ref-format.js";const ie=2e4,A=3,H="remote-url",m="refs/crtr/docs",ae="refs/crtr/remote-docs",g="refs/crtr/imported";function T(t){try{G(t)}catch{}}c(T,"emitEvent");let M=null;const b=new Map,O=new Set;function Se(t,r){M={lifecycle:t,db:r}}c(Se,"startRepoSync");function P(t,r){return r.type!=="repo"?!1:v(t,"SELECT 1 FROM identities WHERE object = ? AND scheme = 'git'").get(r.rowid)!==void 0}c(P,"gitScheme");async function U(t,r){const e=new Map;for(const f of r)for(const o of X(f))o.ok&&o.scheme==="git"&&e.set(o.externalId,o.remoteUrl);if(e.size===0)return;const a=M.db(),n=v(a,"SELECT external_id FROM identities WHERE object = ? AND scheme = 'git'");for(const f of t){const o=n.get(f.rowid),i=o&&e.get(o.external_id);if(!i)continue;const s=await _(f.id);await q(S(s.dir,H),`${i}
2
- `)}}c(U,"recordRemoteUrls");async function ce(t,r){const a=E().db(),n=t.filter(s=>P(a,s));if(n.length===0)return;await U(n,[r]);const f=[];for(const s of n){const l=!O.has(s.id)&&!D(S((await _(s.id)).dir,te)),u=R(s);l&&u&&f.push(u)}if(f.length===0)return;let o;const i=new Promise(s=>{o=setTimeout(s,ie)});await Promise.race([Promise.all(f),i]),clearTimeout(o)}c(ce,"noteNodeWorking");async function ke(t){try{const r=E().db(),e=v(r,"SELECT cwd FROM nodes WHERE node_id = ?").get(t);if(!e)return;const a=fe(r,()=>Z(r,e.cwd));a.length>0&&await ce(a,e.cwd)}catch(r){T({level:"warn",event:"repo_sync.failed",outcome:"failed",error:r,node_id:t,fields:{step:"fetch",reason:`the boot trigger failed: ${r instanceof Error?r.message:String(r)}`}})}}c(ke,"noteNodeBooting");function fe(t,r){if(t.isTransaction)return r();t.exec("BEGIN IMMEDIATE");try{const e=r();return t.exec("COMMIT"),e}catch(e){throw t.exec("ROLLBACK"),e}}c(fe,"inWrite");function _e(t,r=[]){const e=E();if(!P(e.db(),t))return;if(r.length===0){R(t);return}const a=U([t],r).then(()=>{R(t)},n=>{T({level:"error",event:"repo_sync.failed",error:n,fields:{repo:t.name,step:"fetch",reason:"recording the remote URL failed"}})});e.lifecycle.registerDetached(a)}c(_e,"noteRepoDocumentsChanged");function E(){if(!M)throw new Error("repo sync is not started: crtrd must call startRepoSync first");return M}c(E,"requireEngine");function R(t){const r=E(),e=b.get(t.id)??{running:null,again:!1};if(b.set(t.id,e),e.running)return e.again=!0,e.running.then(()=>b.get(t.id)?.running??null).then(n=>n??{ok:!0,pushed:!1,imported:$()});if(!r.lifecycle.acceptsDetachedWork())return null;O.add(t.id);const a=de(t).then(n=>(W(t,n),n),n=>{const f={ok:!1,step:"export",reason:n instanceof Error?n.message:String(n)};return W(t,f),f}).finally(()=>{e.running=null,e.again&&(e.again=!1,R(t))});return e.running=a,r.lifecycle.registerDetached(a.then(()=>{})),a}c(R,"schedule");function W(t,r){if(r.ok){const e=r.imported;T({level:"info",event:"repo_sync.completed",outcome:"succeeded",fields:{repo:t.name,pushed:r.pushed,created:e.created,revisions:e.revisions,deleted:e.deleted,needs_merge:e.needsMerge,refused:e.refused}})}else T({level:"warn",event:"repo_sync.failed",outcome:"failed",fields:{repo:t.name,step:r.step,reason:r.reason}})}c(W,"report");function $(){return{created:0,revisions:0,deleted:0,needsMerge:[],refused:[]}}c($,"emptyImport");class x extends Error{static{c(this,"StepError")}step;constructor(r,e){super(e),this.step=r}}async function C(t,r){try{return await r()}catch(e){throw e instanceof x?e:new x(t,e instanceof Error?e.message:String(e))}}c(C,"step");async function de(t){const r=E();try{const e=await _(t.id),a=await ue(e);if(a===null)return{ok:!1,step:"fetch",reason:`no checkout of ${t.name} with an origin remote has been seen by this runtime`};let n=$();const f=c(()=>C("import",async()=>{const o=await h(e,m),i=await h(e,g);if(o===null||i===o)return;const s=i?await p(e,g):new Map,l=r.db(),u=await p(e,m),d=Q(l,t,s,u,w=>Y(l,w));n={created:n.created+d.created,revisions:n.revisions+d.revisions,deleted:n.deleted+d.deleted,needsMerge:[...new Set([...n.needsMerge,...d.needsMerge])],refused:[...n.refused,...d.refused]},await j(e,o,u,s,new Set(d.refused.map(w=>w.path)),i)}),"importLocal");await f(),await C("export",async()=>{const o=await h(e,m),i=o?await p(e,m):null,s=await h(e,g),l=s?await p(e,g):null,u=J(r.db(),t,i,l);if(o?z(i,u):u.size===0)return;const d=await k(e,u,o?[o]:[],`crtr: export ${t.name}`);await y(e,m,d,o),await j(e,d,u,l??new Map,new Set(V(i,l)),s)});for(let o=1;;o++){const i=await oe(e,a);if(!i.ok)return{ok:!1,step:"fetch",reason:i.reason};let s=await h(e,m);if(i.value!==null&&!(s&&await le(e,i.value)&&await L(e,i.value,s))){const u=await ee(e,a);if(!u.ok)return{ok:!1,step:"fetch",reason:u.reason};const d=u.value;s=await C("merge",async()=>{if(!s||await L(e,s,d))return await y(e,m,d,s),d;const w=await re(e,s,d),F=se(w?await p(e,w):new Map,await p(e,m),await p(e,ae));for(const N of F.refused)n.refused.push(N);const I=await k(e,F.tree,[s,d],`crtr: merge ${t.name}`);return await y(e,m,I,s),I})}if(await f(),s===null||s===i.value)return{ok:!0,pushed:!1,imported:n};const l=await ne(e,a,s);if(l.ok)return{ok:!0,pushed:!0,imported:n};if(l.reason!=="rejected")return{ok:!1,step:"push",reason:l.reason};if(o>=A)return{ok:!1,step:"push",reason:`push rejected ${A} times`}}}catch(e){if(e instanceof x)return{ok:!1,step:e.step,reason:e.message};throw e}}c(de,"syncRepo");async function j(t,r,e,a,n,f){if(n.size===0){await y(t,g,r,f);return}const o=new Map(e);for(const i of n)a.has(i)?o.set(i,a.get(i)):o.delete(i);f!==null&&z(a,o)||await y(t,g,await k(t,o,[],"crtr: imported baseline (some files pending)"),f)}c(j,"advanceImported");async function ue(t){const r=S(t.dir,H);return D(r)&&(await K(r,"utf8")).trim()||null}c(ue,"readUrl");async function le(t,r){return await h(t,r)!==null}c(le,"hasCommit");function z(t,r){if(t.size!==r.size)return!1;for(const[e,a]of t)if(r.get(e)!==a)return!1;return!0}c(z,"sameTree");export{ie as FIRST_FETCH_WAIT_MS,ke as noteNodeBooting,ce as noteNodeWorking,_e as noteRepoDocumentsChanged,Se as startRepoSync,de as syncRepo};
1
+ var N=Object.defineProperty;var c=(t,n)=>N(t,"name",{value:n,configurable:!0});import{existsSync as D}from"node:fs";import{readFile as B,writeFile as q}from"node:fs/promises";import{join as R}from"node:path";import{emitEvent as K}from"../../events/emit.js";import{exportRepo as G,importTree as J,pendingPaths as Q}from"./exchange.js";import{checkoutChain as V}from"./identity.js";import{checkoutsForCwd as X,reposForCwd as Y,warmCheckoutIdentities as Z}from"./repos.js";import{commitTree as S,fetchDocs as ee,FIRST_FETCH_MARKER as te,isAncestor as I,mergeBase as ne,openMirror as b,pushDocs as re,readTree as m,remoteDocsTip as ae,resolveRef as h,setRef as y}from"./mirror.js";import{mergeTrees as ie}from"./ref-format.js";import{withCanvasWrite as se}from"../../canvas/db.js";import{filterAsync as oe}from"../../async-array.js";const ce=2e4,L=3,A="remote-url",w="refs/crtr/docs",fe="refs/crtr/remote-docs",g="refs/crtr/imported";function v(t){try{K(t)}catch{}}c(v,"emitEvent");let T=null;const M=new Map,H=new Set;async function Me(t,n){T={lifecycle:t,db:n}}c(Me,"startRepoSync");async function P(t,n){return n.type!=="repo"?!1:await t.prepare("SELECT 1 FROM identities WHERE object = ? AND scheme = 'git'").get(n.rowid)!==void 0}c(P,"gitScheme");async function U(t,n){const e=new Map;for(const f of n)for(const a of V(f))a.ok&&a.scheme==="git"&&e.set(a.externalId,a.remoteUrl);if(e.size===0)return;const r=(await T.db()).prepare("SELECT external_id FROM identities WHERE object = ? AND scheme = 'git'");for(const f of t){const a=await r.get(f.rowid),s=a&&e.get(a.external_id);if(!s)continue;const i=await b(f.id);await q(R(i.dir,A),`${s}
2
+ `)}}c(U,"recordRemoteUrls");async function de(t,n){const o=await E().db(),r=await oe(t,async i=>await P(o,i));if(r.length===0)return;await U(r,[n]);const f=[];for(const i of r){const l=!H.has(i.id)&&!D(R((await b(i.id)).dir,te)),u=k(i);l&&u&&f.push(u)}if(f.length===0)return;let a;const s=new Promise(i=>{a=setTimeout(i,ce)});await Promise.race([Promise.all(f),s]),clearTimeout(a)}c(de,"noteNodeWorking");async function _e(t){try{const n=await E().db(),e=await n.prepare("SELECT cwd FROM nodes WHERE node_id = ?").get(t);if(!e)return;Z(e.cwd);const o=await se(async()=>await Y(n,e.cwd));o.length>0&&await de(o,e.cwd)}catch(n){v({level:"warn",event:"repo_sync.failed",outcome:"failed",error:n,node_id:t,fields:{step:"fetch",reason:`the boot trigger failed: ${n instanceof Error?n.message:String(n)}`}})}}c(_e,"noteNodeBooting");async function xe(t,n=[]){const e=E();if(!await P(await e.db(),t))return;if(n.length===0){k(t);return}const o=U([t],n).then(()=>{k(t)},r=>{v({level:"error",event:"repo_sync.failed",error:r,fields:{repo:t.name,step:"fetch",reason:"recording the remote URL failed"}})});e.lifecycle.registerDetached(o)}c(xe,"noteRepoDocumentsChanged");function E(){if(!T)throw new Error("repo sync is not started: crtrd must call startRepoSync first");return T}c(E,"requireEngine");function k(t){const n=E(),e=M.get(t.id)??{running:null,again:!1};if(M.set(t.id,e),e.running)return e.again=!0,e.running.then(()=>M.get(t.id)?.running??null).then(r=>r??{ok:!0,pushed:!1,imported:$()});if(!n.lifecycle.acceptsDetachedWork())return null;H.add(t.id);const o=ue(t).then(r=>(W(t,r),r),r=>{const f={ok:!1,step:"export",reason:r instanceof Error?r.message:String(r)};return W(t,f),f}).finally(()=>{e.running=null,e.again&&(e.again=!1,k(t))});return e.running=o,n.lifecycle.registerDetached(o.then(()=>{})),o}c(k,"schedule");function W(t,n){if(n.ok){const e=n.imported;v({level:"info",event:"repo_sync.completed",outcome:"succeeded",fields:{repo:t.name,pushed:n.pushed,created:e.created,revisions:e.revisions,deleted:e.deleted,needs_merge:e.needsMerge,refused:e.refused}})}else v({level:"warn",event:"repo_sync.failed",outcome:"failed",fields:{repo:t.name,step:n.step,reason:n.reason}})}c(W,"report");function $(){return{created:0,revisions:0,deleted:0,needsMerge:[],refused:[]}}c($,"emptyImport");class _ extends Error{static{c(this,"StepError")}step;constructor(n,e){super(e),this.step=n}}async function x(t,n){try{return await n()}catch(e){throw e instanceof _?e:new _(t,e instanceof Error?e.message:String(e))}}c(x,"step");async function ue(t){const n=E();try{const e=await b(t.id),o=await le(e);if(o===null)return{ok:!1,step:"fetch",reason:`no checkout of ${t.name} with an origin remote has been seen by this runtime`};let r=$();const f=c(()=>x("import",async()=>{const a=await h(e,w),s=await h(e,g);if(a===null||s===a)return;const i=s?await m(e,g):new Map,l=await n.db(),u=await m(e,w),d=await J(l,t,i,u,async p=>await X(l,p));r={created:r.created+d.created,revisions:r.revisions+d.revisions,deleted:r.deleted+d.deleted,needsMerge:[...new Set([...r.needsMerge,...d.needsMerge])],refused:[...r.refused,...d.refused]},await j(e,a,u,i,new Set(d.refused.map(p=>p.path)),s)}),"importLocal");await f(),await x("export",async()=>{const a=await h(e,w),s=a?await m(e,w):null,i=await h(e,g),l=i?await m(e,g):null,u=await G(await n.db(),t,s,l);if(a?z(s,u):u.size===0)return;const d=await S(e,u,a?[a]:[],`crtr: export ${t.name}`);await y(e,w,d,a),await j(e,d,u,l??new Map,new Set(Q(s,l)),i)});for(let a=1;;a++){const s=await ae(e,o);if(!s.ok)return{ok:!1,step:"fetch",reason:s.reason};let i=await h(e,w);if(s.value!==null&&!(i&&await we(e,s.value)&&await I(e,s.value,i))){const u=await ee(e,o);if(!u.ok)return{ok:!1,step:"fetch",reason:u.reason};const d=u.value;i=await x("merge",async()=>{if(!i||await I(e,i,d))return await y(e,w,d,i),d;const p=await ne(e,i,d),C=ie(p?await m(e,p):new Map,await m(e,w),await m(e,fe));for(const O of C.refused)r.refused.push(O);const F=await S(e,C.tree,[i,d],`crtr: merge ${t.name}`);return await y(e,w,F,i),F})}if(await f(),i===null||i===s.value)return{ok:!0,pushed:!1,imported:r};const l=await re(e,o,i);if(l.ok)return{ok:!0,pushed:!0,imported:r};if(l.reason!=="rejected")return{ok:!1,step:"push",reason:l.reason};if(a>=L)return{ok:!1,step:"push",reason:`push rejected ${L} times`}}}catch(e){if(e instanceof _)return{ok:!1,step:e.step,reason:e.message};throw e}}c(ue,"syncRepo");async function j(t,n,e,o,r,f){if(r.size===0){await y(t,g,n,f);return}const a=new Map(e);for(const s of r)o.has(s)?a.set(s,o.get(s)):a.delete(s);f!==null&&z(o,a)||await y(t,g,await S(t,a,[],"crtr: imported baseline (some files pending)"),f)}c(j,"advanceImported");async function le(t){const n=R(t.dir,A);return D(n)&&(await B(n,"utf8")).trim()||null}c(le,"readUrl");async function we(t,n){return await h(t,n)!==null}c(we,"hasCommit");function z(t,n){if(t.size!==n.size)return!1;for(const[e,o]of t)if(n.get(e)!==o)return!1;return!0}c(z,"sameTree");export{ce as FIRST_FETCH_WAIT_MS,_e as noteNodeBooting,de as noteNodeWorking,xe as noteRepoDocumentsChanged,Me as startRepoSync,ue as syncRepo};
@@ -1,8 +1,8 @@
1
1
  /** A document's delivery rules as `rules` rows. `rules.owner` mirrors the
2
2
  * document's `objects.owner` so delivery can select rules by owner through
3
3
  * `rules_on_owner`; `replaceRules` and `setRulesOwner` are the only writers. */
4
- import type { DatabaseSync } from 'node:sqlite';
5
4
  import type { ObjectRow, RuleOn, RuleSpec } from './types.js';
5
+ import type { CanvasDb } from '../canvas/db.js';
6
6
  export declare const RULE_ONS: readonly RuleOn[];
7
7
  export interface RuleRow extends RuleSpec {
8
8
  rowid: number;
@@ -11,12 +11,12 @@ export interface RuleRow extends RuleSpec {
11
11
  position: number;
12
12
  }
13
13
  /** Replace the document's rules; `position` is the array index, `owner` the document's owner. */
14
- export declare function replaceRules(db: DatabaseSync, object: ObjectRow, specs: readonly RuleSpec[]): void;
14
+ export declare function replaceRules(db: CanvasDb, object: ObjectRow, specs: readonly RuleSpec[]): Promise<void>;
15
15
  /** Re-point the document's rule rows at its current owner (after a move). */
16
- export declare function setRulesOwner(db: DatabaseSync, object: ObjectRow): void;
17
- export declare function rulesOf(db: DatabaseSync, object: ObjectRow): RuleRow[];
16
+ export declare function setRulesOwner(db: CanvasDb, object: ObjectRow): Promise<void>;
17
+ export declare function rulesOf(db: CanvasDb, object: ObjectRow): Promise<RuleRow[]>;
18
18
  /** Every rule on one of `on` whose document belongs to one of `owners`. */
19
- export declare function rulesForOwners(db: DatabaseSync, on: readonly RuleOn[], owners: readonly number[]): RuleRow[];
19
+ export declare function rulesForOwners(db: CanvasDb, on: readonly RuleOn[], owners: readonly number[]): Promise<RuleRow[]>;
20
20
  /** The only converter from package/legacy frontmatter (`surfaces`, `gate`,
21
21
  * `slash`) to rules. Tolerant like the runtime parser it replaces: invalid
22
22
  * entries are dropped; `lintRules` is the strict check. A document-level
@@ -1,3 +1,3 @@
1
- var R=Object.defineProperty;var a=(e,n)=>R(e,"name",{value:n,configurable:!0});import{prepared as u}from"../sqlite-statements.js";const E=["boot","workspace-open","file-read","document-read","command","pre-command","slash-command"],p=["name","preview","content"],y=["file-read","document-read","command","pre-command"],O=["on","match","matchFrontmatter","if","deliver"];function g(e){return{rowid:e.rowid,object:e.object,owner:e.owner,position:e.position,on:e.on_event,deliver:e.deliver,...e.match_json!==null?{match:JSON.parse(e.match_json)}:{},...e.match_frontmatter_json!==null?{matchFrontmatter:JSON.parse(e.match_frontmatter_json)}:{},...e.if_json!==null?{if:JSON.parse(e.if_json)}:{}}}a(g,"fromRaw");function _(e,n,t){const i=w(t);if(i!==null)throw new Error(`replaceRules(${n.id}): ${i}`);u(e,"DELETE FROM rules WHERE object = ?").run(n.rowid);const c=u(e,`INSERT INTO rules (object, owner, position, on_event, match_json, match_frontmatter_json, if_json, deliver)
2
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)`);t.forEach((r,o)=>{c.run(n.rowid,n.owner,o,r.on,r.match!==void 0?JSON.stringify(r.match):null,r.matchFrontmatter!==void 0?JSON.stringify(r.matchFrontmatter):null,r.if!==void 0?JSON.stringify(r.if):null,r.deliver)})}a(_,"replaceRules");function v(e,n){const t=u(e,"SELECT owner FROM objects WHERE rowid = ?").get(n.rowid);if(t===void 0)throw new Error(`setRulesOwner: object ${n.id} does not exist`);u(e,"UPDATE rules SET owner = ? WHERE object = ?").run(t.owner,n.rowid)}a(v,"setRulesOwner");function $(e,n){return u(e,"SELECT * FROM rules WHERE object = ? ORDER BY position").all(n.rowid).map(g)}a($,"rulesOf");function b(e,n,t){if(n.length===0||t.length===0)return[];const i=`SELECT * FROM rules WHERE on_event IN (${n.map(()=>"?").join(",")})
3
- AND owner IN (${t.map(()=>"?").join(",")}) ORDER BY object, position`;return e.prepare(i).all(...n,...t).map(g)}a(b,"rulesForOwners");const S={boot:"boot","workspace-open":"workspace-open",read:"file-read","memory-read":"document-read",command:"command","pre-command":"pre-command"};function s(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}a(s,"predicate");function j(e){if(typeof e=="string")return e.trim()===""?void 0:[e.trim()];if(!Array.isArray(e))return;const n=e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim());return n.length>0?n:void 0}a(j,"globs");function x(e){const n=s(e.gate),t=a(r=>n!==void 0&&r!==void 0?{all:[n,r]}:n??r,"withGate"),i=[],c=Array.isArray(e.surfaces)?e.surfaces:[];for(const r of c){const o=s(r);if(o===void 0)continue;const d=typeof o.on=="string"?S[o.on]:void 0,f=o.at;if(d===void 0||typeof f!="string"||!p.includes(f))continue;const l=j(o.match),m=d==="file-read"?s(o["match-frontmatter"]):void 0;if(y.includes(d)&&l===void 0&&m===void 0)continue;const h=t(s(o.gate));i.push({on:d,deliver:f,...l!==void 0&&d!=="boot"&&d!=="workspace-open"?{match:l}:{},...m!==void 0?{matchFrontmatter:m}:{},...h!==void 0?{if:h}:{}})}return e.slash===!0&&i.push({on:"slash-command",deliver:"content",...n!==void 0?{if:n}:{}}),i}a(x,"rulesFromFrontmatter");function w(e){if(!Array.isArray(e))return`invalid rules: ${JSON.stringify(e)} (expected a list of {on, deliver, match?, matchFrontmatter?, if?} entries)`;for(const n of e){const t=s(n);if(t===void 0)return`invalid rule: ${JSON.stringify(n)} (expected an {on, deliver, match?, matchFrontmatter?, if?} object)`;for(const d of Object.keys(t))if(!O.includes(d))return`invalid rule: unknown key \`${d}\` (a rule carries only ${O.join(", ")})`;const i=t.on;if(typeof i!="string"||!E.includes(i))return`invalid rule \`on\`: ${JSON.stringify(i)} (expected ${E.join("|")})`;const c=t.deliver;if(typeof c!="string"||!p.includes(c))return`invalid rule \`deliver\`: ${JSON.stringify(c)} (expected ${p.join("|")})`;const r=t.match;if(r!==void 0){if(i==="boot"||i==="workspace-open"||i==="slash-command")return`invalid rule: \`match\` is meaningless on \`${i}\`; drop it`;if(!Array.isArray(r)||r.length===0||r.some(d=>typeof d!="string"||d.trim()===""))return`invalid rule \`match\`: ${JSON.stringify(r)} (expected a non-empty list of non-empty globs)`}const o=t.matchFrontmatter;if(o!==void 0){if(i!=="file-read")return"invalid rule: `matchFrontmatter` applies to `file-read` rules only";if(s(o)===void 0)return`invalid rule \`matchFrontmatter\`: ${JSON.stringify(o)} (expected a field\u2192matcher object)`}if(y.includes(i)&&r===void 0&&o===void 0)return`invalid rule: a \`${i}\` rule requires \`match\`${i==="file-read"?" or `matchFrontmatter`":""}`;if(t.if!==void 0&&s(t.if)===void 0)return`invalid rule \`if\`: ${JSON.stringify(t.if)} (expected a predicate object)`}return null}a(w,"lintRules");export{E as RULE_ONS,w as lintRules,_ as replaceRules,b as rulesForOwners,x as rulesFromFrontmatter,$ as rulesOf,v as setRulesOwner};
1
+ var O=Object.defineProperty;var d=(e,n)=>O(e,"name",{value:n,configurable:!0});import{forEachAsync as g}from"../async-array.js";const h=["boot","workspace-open","file-read","document-read","command","pre-command","slash-command"],m=["name","preview","content"],y=["file-read","document-read","command","pre-command"],E=["on","match","matchFrontmatter","if","deliver"];function w(e){return{rowid:e.rowid,object:e.object,owner:e.owner,position:e.position,on:e.on_event,deliver:e.deliver,...e.match_json!==null?{match:JSON.parse(e.match_json)}:{},...e.match_frontmatter_json!==null?{matchFrontmatter:JSON.parse(e.match_frontmatter_json)}:{},...e.if_json!==null?{if:JSON.parse(e.if_json)}:{}}}d(w,"fromRaw");async function _(e,n,t){const i=S(t);if(i!==null)throw new Error(`replaceRules(${n.id}): ${i}`);await e.prepare("DELETE FROM rules WHERE object = ?").run(n.rowid);const c=e.prepare(`INSERT INTO rules (object, owner, position, on_event, match_json, match_frontmatter_json, if_json, deliver)
2
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`);await g(t,async(r,o)=>{await c.run(n.rowid,n.owner,o,r.on,r.match!==void 0?JSON.stringify(r.match):null,r.matchFrontmatter!==void 0?JSON.stringify(r.matchFrontmatter):null,r.if!==void 0?JSON.stringify(r.if):null,r.deliver)})}d(_,"replaceRules");async function v(e,n){const t=await e.prepare("SELECT owner FROM objects WHERE rowid = ?").get(n.rowid);if(t===void 0)throw new Error(`setRulesOwner: object ${n.id} does not exist`);await e.prepare("UPDATE rules SET owner = ? WHERE object = ?").run(t.owner,n.rowid)}d(v,"setRulesOwner");async function $(e,n){return(await e.prepare("SELECT * FROM rules WHERE object = ? ORDER BY position").all(n.rowid)).map(w)}d($,"rulesOf");async function A(e,n,t){if(n.length===0||t.length===0)return[];const i=`SELECT * FROM rules WHERE on_event IN (${n.map(()=>"?").join(",")})
3
+ AND owner IN (${t.map(()=>"?").join(",")}) ORDER BY object, position`;return(await e.prepareUncached(i).all(...n,...t)).map(w)}d(A,"rulesForOwners");const R={boot:"boot","workspace-open":"workspace-open",read:"file-read","memory-read":"document-read",command:"command","pre-command":"pre-command"};function s(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}d(s,"predicate");function j(e){if(typeof e=="string")return e.trim()===""?void 0:[e.trim()];if(!Array.isArray(e))return;const n=e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim());return n.length>0?n:void 0}d(j,"globs");function b(e){const n=s(e.gate),t=d(r=>n!==void 0&&r!==void 0?{all:[n,r]}:n??r,"withGate"),i=[],c=Array.isArray(e.surfaces)?e.surfaces:[];for(const r of c){const o=s(r);if(o===void 0)continue;const a=typeof o.on=="string"?R[o.on]:void 0,u=o.at;if(a===void 0||typeof u!="string"||!m.includes(u))continue;const f=j(o.match),l=a==="file-read"?s(o["match-frontmatter"]):void 0;if(y.includes(a)&&f===void 0&&l===void 0)continue;const p=t(s(o.gate));i.push({on:a,deliver:u,...f!==void 0&&a!=="boot"&&a!=="workspace-open"?{match:f}:{},...l!==void 0?{matchFrontmatter:l}:{},...p!==void 0?{if:p}:{}})}return e.slash===!0&&i.push({on:"slash-command",deliver:"content",...n!==void 0?{if:n}:{}}),i}d(b,"rulesFromFrontmatter");function S(e){if(!Array.isArray(e))return`invalid rules: ${JSON.stringify(e)} (expected a list of {on, deliver, match?, matchFrontmatter?, if?} entries)`;for(const n of e){const t=s(n);if(t===void 0)return`invalid rule: ${JSON.stringify(n)} (expected an {on, deliver, match?, matchFrontmatter?, if?} object)`;for(const a of Object.keys(t))if(!E.includes(a))return`invalid rule: unknown key \`${a}\` (a rule carries only ${E.join(", ")})`;const i=t.on;if(typeof i!="string"||!h.includes(i))return`invalid rule \`on\`: ${JSON.stringify(i)} (expected ${h.join("|")})`;const c=t.deliver;if(typeof c!="string"||!m.includes(c))return`invalid rule \`deliver\`: ${JSON.stringify(c)} (expected ${m.join("|")})`;const r=t.match;if(r!==void 0){if(i==="boot"||i==="workspace-open"||i==="slash-command")return`invalid rule: \`match\` is meaningless on \`${i}\`; drop it`;if(!Array.isArray(r)||r.length===0||r.some(a=>typeof a!="string"||a.trim()===""))return`invalid rule \`match\`: ${JSON.stringify(r)} (expected a non-empty list of non-empty globs)`}const o=t.matchFrontmatter;if(o!==void 0){if(i!=="file-read")return"invalid rule: `matchFrontmatter` applies to `file-read` rules only";if(s(o)===void 0)return`invalid rule \`matchFrontmatter\`: ${JSON.stringify(o)} (expected a field\u2192matcher object)`}if(y.includes(i)&&r===void 0&&o===void 0)return`invalid rule: a \`${i}\` rule requires \`match\`${i==="file-read"?" or `matchFrontmatter`":""}`;if(t.if!==void 0&&s(t.if)===void 0)return`invalid rule \`if\`: ${JSON.stringify(t.if)} (expected a predicate object)`}return null}d(S,"lintRules");export{h as RULE_ONS,S as lintRules,_ as replaceRules,A as rulesForOwners,b as rulesFromFrontmatter,$ as rulesOf,v as setRulesOwner};
@@ -1 +1 @@
1
- var d=Object.defineProperty;var c=(t,n)=>d(t,"name",{value:n,configurable:!0});import{covers as u}from"@north-light/identity";import{identityOf as r}from"./index.js";import{memoryScope as p,missingOwnMemoryScope as f}from"./own-memory.js";import{objectPlace as x,runPlace as m,runsSeeEachOther as O}from"../../runs/confinement.js";const M={identity:r,sync:"runtime",canRead(t,n,e,o,s){if(n.class==="person"||o.length===0)return!0;if(n.app.rowid===e.rowid)return y(t,n,o)&&f(t,n,e,o,s,"read")===null;const i=r(t,e).external_id,l=c(g=>n.scopes!==null&&n.scopes.some(S=>u(S,g)),"held");return o[0].type==="node"?l(`crtr:objects:read:${i}`)||s.type==="document"&&s.kind==="report"&&l(`crtr:conversations:read:${i}`):l(p(t,i,"read",o))},canChange(t,n,e,o,s){if(n.class==="person")return!0;if(n.app.rowid===e.rowid)return o.length===0||y(t,n,o)&&f(t,n,e,o,s,"rw")===null;if(o.length===0||o[0].type==="node")return!1;const i=p(t,r(t,e).external_id,"rw",o);return n.scopes!==null&&n.scopes.some(l=>u(l,i))}},w=new WeakMap;function y(t,n,e){if(n.class==="person"||e.length===0||e[0].type!=="node"||n.class==="app"&&n.place===void 0)return!0;let o=w.get(n);if(o===void 0&&(o=n.class==="app"?n.place:n.class==="node"?m(n.node.id,t):n.place??x(n.object.rowid,t),w.set(n,o)),o===null)return!0;const s=m(e[0].id,t);return s===null?!o.isolated:O(o,s)}c(y,"runConfined");export{M as appSpace};
1
+ var S=Object.defineProperty;var l=(o,n)=>S(o,"name",{value:n,configurable:!0});import{covers as r}from"@north-light/identity";import{identityOf as u}from"./index.js";import{memoryScope as a,missingOwnMemoryScope as p}from"./own-memory.js";import{objectPlace as x,runPlace as w,runsSeeEachOther as O}from"../../runs/confinement.js";const M={sync:"runtime",async canRead(o,n,i,t,e){if(n.class==="person"||t.length===0)return!0;if(n.app.rowid===i.rowid)return await m(o,n,t)&&await p(o,n,i,t,e,"read")===null;const s=(await u(o,i)).external_id,c=l(y=>n.scopes!==null&&n.scopes.some(g=>r(g,y)),"held");return t[0].type==="node"?c(`crtr:objects:read:${s}`)||e.type==="document"&&e.kind==="report"&&c(`crtr:conversations:read:${s}`):c(await a(o,s,"read",t))},async canChange(o,n,i,t,e){if(n.class==="person")return!0;if(n.app.rowid===i.rowid)return t.length===0||await m(o,n,t)&&await p(o,n,i,t,e,"rw")===null;if(t.length===0||t[0].type==="node")return!1;const s=await a(o,(await u(o,i)).external_id,"rw",t);return n.scopes!==null&&n.scopes.some(c=>r(c,s))}},f=new WeakMap;async function m(o,n,i){if(n.class==="person"||i.length===0||i[0].type!=="node"||n.class==="app"&&n.place===void 0)return!0;let t=f.get(n);if(t===void 0&&(t=n.class==="app"?n.place:n.class==="node"?await w(n.node.id,o):n.place??await x(n.object.rowid,o),f.set(n,t)),t===null)return!0;const e=await w(i[0].id,o);return e===null?!t.isolated:O(t,e)}l(m,"runConfined");export{M as appSpace};
@@ -1,5 +1,5 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
1
  import type { ObjectRow, Reader } from '../types.js';
2
+ import type { CanvasDb } from '../../canvas/db.js';
3
3
  export interface IdentityRow {
4
4
  object: number;
5
5
  scheme: string;
@@ -10,10 +10,9 @@ export type SpaceType = 'person' | 'app' | 'repo';
10
10
  * `path` is the owner chain below the space, top first, ending at the object
11
11
  * (e.g. `[node, document]`); it is empty when the object is the space itself. */
12
12
  export interface Space {
13
- identity(db: DatabaseSync, space: ObjectRow): IdentityRow;
14
13
  sync: 'runtime' | 'repo-ref';
15
- canRead(db: DatabaseSync, reader: Reader, space: ObjectRow, path: ObjectRow[], object: ObjectRow): boolean;
16
- canChange(db: DatabaseSync, reader: Reader, space: ObjectRow, path: ObjectRow[], object: ObjectRow): boolean;
14
+ canRead(db: CanvasDb, reader: Reader, space: ObjectRow, path: ObjectRow[], object: ObjectRow): Promise<boolean>;
15
+ canChange(db: CanvasDb, reader: Reader, space: ObjectRow, path: ObjectRow[], object: ObjectRow): Promise<boolean>;
17
16
  }
18
17
  export declare const SPACES: Record<SpaceType, Space>;
19
- export declare function identityOf(db: DatabaseSync, object: ObjectRow): IdentityRow;
18
+ export declare function identityOf(db: CanvasDb, object: ObjectRow): Promise<IdentityRow>;
@@ -1 +1 @@
1
- var p=Object.defineProperty;var o=(r,e)=>p(r,"name",{value:e,configurable:!0});import{prepared as i}from"../../sqlite-statements.js";import{appSpace as n}from"./app.js";import{personSpace as a}from"./person.js";import{repoSpace as m}from"./repo.js";const E={person:a,app:n,repo:m};function h(r,e){const t=i(r,"SELECT object, scheme, external_id FROM identities WHERE object = ?").get(e.rowid);if(!t)throw new Error(`${e.type} ${e.id} has no identity`);return t}o(h,"identityOf");export{E as SPACES,h as identityOf};
1
+ var p=Object.defineProperty;var t=(r,e)=>p(r,"name",{value:e,configurable:!0});import{appSpace as i}from"./app.js";import{personSpace as n}from"./person.js";import{repoSpace as a}from"./repo.js";const f={person:n,app:i,repo:a};async function E(r,e){const o=await r.prepare("SELECT object, scheme, external_id FROM identities WHERE object = ?").get(e.rowid);if(!o)throw new Error(`${e.type} ${e.id} has no identity`);return o}t(E,"identityOf");export{f as SPACES,E as identityOf};
@@ -1,18 +1,18 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
1
  import type { ObjectRow, Reader } from '../types.js';
2
+ import type { CanvasDb } from '../../canvas/db.js';
3
3
  type Path = ObjectRow[];
4
4
  /** The scope a run launched with a `scopes` list lacks to read (`read`) or change (`rw`) one of its own app's documents, or null.
5
5
  * Own-app memory needs no grant scope, but a launched list narrows it (identity MEM-2): reading needs `crtr:memory:read:app:<A>`,
6
6
  * writing `crtr:memory:rw:app:<A>` (profile forms for a profile's documents). Only documents are gated — never a node, job or
7
7
  * lifecycle object — and a run with no list, an app's server and the person keep full access. A report is readable inside its
8
8
  * own run (a run hears its children through them); writing one is the runtime's own act (see `asRuntimeWriter`). */
9
- export declare function missingOwnMemoryScope(db: DatabaseSync, reader: Reader, space: ObjectRow, path: Path, object: {
9
+ export declare function missingOwnMemoryScope(db: CanvasDb, reader: Reader, space: ObjectRow, path: Path, object: {
10
10
  type: string;
11
11
  kind: string | null;
12
- } | null, access: 'read' | 'rw'): string | null;
12
+ } | null, access: 'read' | 'rw'): Promise<string | null>;
13
13
  /** The same reader with its launched list lifted, for the runtime's own writes inside a narrowed run: a `crtr push` report and the
14
14
  * scaffolded roadmap of a promoted node. Wrap only the one call that creates the document the runtime names. */
15
15
  export declare function asRuntimeWriter<R extends Reader>(reader: R): R;
16
16
  /** `crtr:memory:<access>:app:<B>` for an app document, or its profile form for a profile and what it owns. */
17
- export declare function memoryScope(db: DatabaseSync, app: string, access: 'read' | 'rw', path: Path): string;
17
+ export declare function memoryScope(db: CanvasDb, app: string, access: 'read' | 'rw', path: Path): Promise<string>;
18
18
  export {};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var l=(n,e)=>f(n,"name",{value:e,configurable:!0});import{prepared as d}from"../../sqlite-statements.js";import{covers as a}from"@north-light/identity";import{runPlace as s}from"../../runs/confinement.js";const m=l((n,e)=>d(n,"SELECT external_id FROM identities WHERE object = ?").get(e.rowid).external_id,"externalId");function S(n,e,o,t,r,i){if(e.class==="person"||t.length===0||r!==null&&r.type!=="document")return null;const u=e.launched;if(u==null||i==="read"&&r?.kind==="report"&&t[0].type==="node"&&y(n,e,t[0].id))return null;const c=x(n,m(n,o),i,t);return u.some(p=>a(p,c))?null:c}l(S,"missingOwnMemoryScope");function y(n,e,o){const t=e.class==="node"?s(e.node.id,n):e.class==="person"?null:e.place??null,r=s(o,n);return t!==null&&r!==null&&t.run===r.run}l(y,"inReadersRun");function w(n){return n.class==="person"?n:{...n,launched:null}}l(w,"asRuntimeWriter");function x(n,e,o,t){const r=t[0];return r.type!=="profile"?`crtr:memory:${o}:${e}`:`crtr:memory:${o}:${e}:profile:${m(n,r)}`}l(x,"memoryScope");export{w as asRuntimeWriter,x as memoryScope,S as missingOwnMemoryScope};
1
+ var m=Object.defineProperty;var l=(n,t)=>m(n,"name",{value:t,configurable:!0});import{covers as f}from"@north-light/identity";import{runPlace as s}from"../../runs/confinement.js";const a=l(async(n,t)=>(await n.prepare("SELECT external_id FROM identities WHERE object = ?").get(t.rowid)).external_id,"externalId");async function $(n,t,o,e,r,u){if(t.class==="person"||e.length===0||r!==null&&r.type!=="document")return null;const i=t.launched;if(i==null||u==="read"&&r?.kind==="report"&&e[0].type==="node"&&await y(n,t,e[0].id))return null;const c=await w(n,await a(n,o),u,e);return i.some(p=>f(p,c))?null:c}l($,"missingOwnMemoryScope");async function y(n,t,o){const e=t.class==="node"?await s(t.node.id,n):t.class==="person"?null:t.place??null,r=await s(o,n);return e!==null&&r!==null&&e.run===r.run}l(y,"inReadersRun");function g(n){return n.class==="person"?n:{...n,launched:null}}l(g,"asRuntimeWriter");async function w(n,t,o,e){const r=e[0];return r.type!=="profile"?`crtr:memory:${o}:${t}`:`crtr:memory:${o}:${t}:profile:${await a(n,r)}`}l(w,"memoryScope");export{g as asRuntimeWriter,w as memoryScope,$ as missingOwnMemoryScope};
@@ -1,3 +1,3 @@
1
- import{prepared as p}from"../../sqlite-statements.js";import{covers as o}from"@north-light/identity";import{identityOf as f}from"./index.js";const d={identity:f,sync:"runtime",canRead(c,r,s,t,i){return r.class==="person"||r.class==="object"&&r.owner.rowid===s.rowid?!0:r.scopes===null?!1:r.app.rowid===s.rowid||t.length===0?!0:t[0].type!=="document"?!1:r.scopes.some(n=>o(n,"crtr:memory:manage:user"))||i.privacy==="public"?!0:i.privacy==="private"&&r.scopes.some(n=>o(n,"crtr:memory:read_private:user"))},canChange(c,r,s,t,i){if(r.class==="person"||r.class==="object"&&r.owner.rowid===s.rowid||r.app.rowid===s.rowid||r.scopes?.some(e=>o(e,"crtr:memory:manage:user")))return!0;if(t.length===0)return r.scopes?.some(e=>o(e,"crtr:memory:rw:user"))??!1;if(t[0].type!=="document")return!1;const n=`crtr:memory:rw:user:${i.name}`;if(r.scopes===null||!r.scopes.some(e=>o(e,n)))return!1;const u=p(c,`SELECT author.type, author.owner AS app FROM revisions r JOIN objects author ON author.rowid = r.author
2
- WHERE r.document = ? ORDER BY r.number, r.created_at LIMIT 1`).get(t[0].rowid);return u?u.type==="person"||u.app===r.app.rowid?!0:p(c,`SELECT g.resolved_scopes_json FROM grants g JOIN identities i ON i.external_id = g.grantee
3
- WHERE i.object = ? AND i.scheme = 'app'`).all(u.app).some(({resolved_scopes_json:e})=>JSON.parse(e).some(({scope:a,mode:m})=>m==="always"&&o(a,"crtr:memory:manage:user"))):!1}};export{d as personSpace};
1
+ import{covers as t}from"@north-light/identity";const f={sync:"runtime",async canRead(a,r,o,s,i){return r.class==="person"||r.class==="object"&&r.owner.rowid===o.rowid?!0:r.scopes===null?!1:r.app.rowid===o.rowid||s.length===0?!0:s[0].type!=="document"?!1:r.scopes.some(n=>t(n,"crtr:memory:manage:user"))||i.privacy==="public"?!0:i.privacy==="private"&&r.scopes.some(n=>t(n,"crtr:memory:read_private:user"))},async canChange(a,r,o,s,i){if(r.class==="person"||r.class==="object"&&r.owner.rowid===o.rowid||r.app.rowid===o.rowid||r.scopes?.some(e=>t(e,"crtr:memory:manage:user")))return!0;if(s.length===0)return r.scopes?.some(e=>t(e,"crtr:memory:rw:user"))??!1;if(s[0].type!=="document")return!1;const n=`crtr:memory:rw:user:${i.name}`;if(r.scopes===null||!r.scopes.some(e=>t(e,n)))return!1;const u=await a.prepare(`SELECT author.type, author.owner AS app FROM revisions r JOIN objects author ON author.rowid = r.author
2
+ WHERE r.document = ? ORDER BY r.number, r.created_at LIMIT 1`).get(s[0].rowid);return u?u.type==="person"||u.app===r.app.rowid?!0:(await a.prepare(`SELECT g.resolved_scopes_json FROM grants g JOIN identities i ON i.external_id = g.grantee
3
+ WHERE i.object = ? AND i.scheme = 'app'`).all(u.app)).some(({resolved_scopes_json:e})=>JSON.parse(e).some(({scope:c,mode:p})=>p==="always"&&t(c,"crtr:memory:manage:user"))):!1}};export{f as personSpace};
@@ -7,7 +7,7 @@ import type { Space } from './index.js';
7
7
  * own repo. A Mac terminal node reaches every path. */
8
8
  export declare function insideRepo(db: Parameters<Space['canRead']>[0], reader: Reader, repo: {
9
9
  rowid: number;
10
- }, access: 'read' | 'rw'): boolean;
10
+ }, access: 'read' | 'rw'): Promise<boolean>;
11
11
  /** A repo: read and changed by a run with a checkout of it (enclosing its cwd or one of its
12
12
  * profile's project paths) that its file permissions reach (see `insideRepo`). It owns only public documents, so a
13
13
  * non-public one is never changed. */
@@ -1 +1 @@
1
- var u=Object.defineProperty;var i=(t,o)=>u(t,"name",{value:o,configurable:!0});import{fileRoot as f}from"../../spaces/file-root.js";import{identityOf as c}from"./index.js";function p(t,o,e,r){if(o.class==="object")return o.repos.some(n=>n.rowid===e.rowid);if(o.class!=="node")return!1;const s=[...o.checkouts,...o.projectCheckouts].filter(n=>n.repo.rowid===e.rowid);if(s.length===0)return!1;const l={app:c(t,o.app).external_id,resolved:o.scopes??[],launched:null};return s.some(n=>"root"in f(l,n.root,r))}i(p,"insideRepo");const d={identity:c,sync:"repo-ref",canRead(t,o,e,r){return o.class==="person"||r.length===0?!0:p(t,o,e,"read")},canChange(t,o,e,r,s){return s.privacy!=="public"?!1:o.class==="person"?!0:p(t,o,e,"rw")}};export{p as insideRepo,d as repoSpace};
1
+ var p=Object.defineProperty;var c=(o,t)=>p(o,"name",{value:t,configurable:!0});import{fileRoot as l}from"../../spaces/file-root.js";import{identityOf as u}from"./index.js";async function i(o,t,e,r){if(t.class==="object")return t.repos.some(n=>n.rowid===e.rowid);if(t.class!=="node")return!1;const s=[...t.checkouts,...t.projectCheckouts].filter(n=>n.repo.rowid===e.rowid);if(s.length===0)return!1;const a={app:(await u(o,t.app)).external_id,resolved:t.scopes??[],launched:null};return s.some(n=>"root"in l(a,n.root,r))}c(i,"insideRepo");const m={sync:"repo-ref",async canRead(o,t,e,r){return t.class==="person"||r.length===0?!0:await i(o,t,e,"read")},async canChange(o,t,e,r,s){return s.privacy!=="public"?!1:t.class==="person"?!0:await i(o,t,e,"rw")}};export{i as insideRepo,m as repoSpace};
@@ -1,8 +1,8 @@
1
1
  /** Watches and their subscriptions, message-subscription ending, tree walks and fork copies.
2
2
  * `watches.in_tree` is written only here: it is 1 while any subscription of the watch
3
3
  * started from spawn, job-start or ask. */
4
- import type { DatabaseSync } from 'node:sqlite';
5
4
  import type { ListenConfig, ObjectRow, Reader, WatchStart } from './types.js';
5
+ import type { CanvasDb } from '../canvas/db.js';
6
6
  export interface Subscription {
7
7
  rowid: number;
8
8
  pattern: string;
@@ -36,33 +36,33 @@ export declare function configFromJson(json: string): ListenConfig;
36
36
  /** Record (or extend) watcher's watch on object. Adds only the subscriptions the watch lacks:
37
37
  * a pattern already held without an end covers any new one, except that a tree start
38
38
  * still adds its own subscription when only non-tree ones hold the pattern. */
39
- export declare function recordWatch(db: DatabaseSync, watcher: ObjectRow, object: ObjectRow, start: WatchStart, opts?: RecordWatchOpts): void;
39
+ export declare function recordWatch(db: CanvasDb, watcher: ObjectRow, object: ObjectRow, start: WatchStart, opts?: RecordWatchOpts): Promise<void>;
40
40
  /** Mark the existing watch of `object` by `watcher` as made through `link` by `app`, changing nothing else about it. */
41
- export declare function markLinkWatch(db: DatabaseSync, watcher: ObjectRow, object: ObjectRow, app: ObjectRow): void;
41
+ export declare function markLinkWatch(db: CanvasDb, watcher: ObjectRow, object: ObjectRow, app: ObjectRow): Promise<void>;
42
42
  /** Remove the whole watch, the subscriptions with one pattern, or (tree-only form) the
43
43
  * subscriptions one start made. A watch left with no subscription is deleted. */
44
- export declare function unwatch(db: DatabaseSync, watcher: ObjectRow, object: ObjectRow, which?: string | {
44
+ export declare function unwatch(db: CanvasDb, watcher: ObjectRow, object: ObjectRow, which?: string | {
45
45
  startedBy: WatchStart;
46
- }): void;
46
+ }): Promise<void>;
47
47
  /** Change the listening configuration of the watcher's subscriptions with `pattern`; null = the watcher's default. */
48
- export declare function setSubscriptionConfig(db: DatabaseSync, watcher: ObjectRow, object: ObjectRow, pattern: string, config: ListenConfig | null): void;
48
+ export declare function setSubscriptionConfig(db: CanvasDb, watcher: ObjectRow, object: ObjectRow, pattern: string, config: ListenConfig | null): Promise<void>;
49
49
  /** End the message subscriptions on `object` (a node): 'final' and 'done' end all of them;
50
50
  * `{result}` ends those waiting for that request's answer. */
51
- export declare function endMessageSubscriptions(db: DatabaseSync, object: ObjectRow, cause: 'final' | 'done' | {
51
+ export declare function endMessageSubscriptions(db: CanvasDb, object: ObjectRow, cause: 'final' | 'done' | {
52
52
  result: string;
53
- }): void;
53
+ }): Promise<void>;
54
54
  /** The watches `watcher` holds that the reader may see (both ends readable). */
55
- export declare function watchesOf(db: DatabaseSync, reader: Reader, watcher: ObjectRow): Watch[];
55
+ export declare function watchesOf(db: CanvasDb, reader: Reader, watcher: ObjectRow): Promise<Watch[]>;
56
56
  /** The watches held on `object` that the reader may see (both ends readable). */
57
- export declare function watchersOf(db: DatabaseSync, reader: Reader, object: ObjectRow): Watch[];
57
+ export declare function watchersOf(db: CanvasDb, reader: Reader, object: ObjectRow): Promise<Watch[]>;
58
58
  /** The ids of every object that watches `object`, whatever started the watch. */
59
- export declare function watcherIdsOf(db: DatabaseSync, object: ObjectRow): string[];
59
+ export declare function watcherIdsOf(db: CanvasDb, object: ObjectRow): Promise<string[]>;
60
60
  /** Every node below `root` in the tree (in-tree watches, watcher → object), each once. */
61
- export declare function descendants(db: DatabaseSync, root: ObjectRow): ObjectRow[];
61
+ export declare function descendants(db: CanvasDb, root: ObjectRow): Promise<ObjectRow[]>;
62
62
  /** Every node above `leaf` in the tree (in-tree watches, object → watcher), each once. */
63
- export declare function ancestors(db: DatabaseSync, leaf: ObjectRow): ObjectRow[];
63
+ export declare function ancestors(db: CanvasDb, leaf: ObjectRow): Promise<ObjectRow[]>;
64
64
  /** The objects whose in-tree watch covers `object` (its spawner, job starter, explicit watchers). */
65
- export declare function treeWatchersOf(db: DatabaseSync, object: ObjectRow): ObjectRow[];
65
+ export declare function treeWatchersOf(db: CanvasDb, object: ObjectRow): Promise<ObjectRow[]>;
66
66
  /** Give `fork` a copy of every watch `source` holds, with the same subscriptions, configurations
67
67
  * and read base; each copied subscription records `fork`, so no copy is in the tree. */
68
- export declare function copyWatchesForFork(db: DatabaseSync, source: ObjectRow, fork: ObjectRow): void;
68
+ export declare function copyWatchesForFork(db: CanvasDb, source: ObjectRow, fork: ObjectRow): Promise<void>;
@@ -1,19 +1,19 @@
1
- var D=Object.defineProperty;var c=(e,t)=>D(e,"name",{value:t,configurable:!0});import{prepared as i}from"../sqlite-statements.js";import{canRead as p}from"./access.js";import{receiverForObject as j}from"./receivers.js";import{getByRowid as S}from"./objects.js";const O=["spawn","job-start","ask"],y=["report.final","report.result","notice.>"];function N(e){return JSON.stringify(Object.fromEntries(e.map(t=>[String(t.threshold),t.delivery])))}c(N,"configToJson");function I(e){const t=JSON.parse(e);return Object.entries(t).map(([r,o])=>({threshold:Number(r),delivery:o})).sort((r,o)=>o.threshold-r.threshold)}c(I,"configFromJson");function h(e,t,r){return i(e,"SELECT * FROM watches WHERE watcher = ? AND object = ?").get(t.rowid,r.rowid)}c(h,"watchRow");function d(e,t){return i(e,"SELECT * FROM watch_subscriptions WHERE watch = ? ORDER BY rowid").all(t)}c(d,"subsOf");function _(e,t){const r=d(e,t);if(r.length===0){i(e,"DELETE FROM watches WHERE rowid = ?").run(t);return}const o=r.some(n=>O.includes(n.started_by))?1:0;i(e,"UPDATE watches SET in_tree = ? WHERE rowid = ? AND in_tree != ?").run(o,t,o)}c(_,"settle");function C(e,t){return e==="message"?y:t.patterns?.length?t.patterns:[">"]}c(C,"defaultPatterns");function F(e,t,r,o,n={}){if(o==="fork")throw new Error("recordWatch: fork watches are made by copyWatchesForFork");if(t.type.includes(".")&&!j(e,t))throw new Error(`custom object ${t.id} has no receiver`);const a=new Date().toISOString();i(e,`INSERT INTO watches (watcher, object, in_tree, read_heads_key, created_at, link_app) VALUES (?, ?, 0, ?, ?, ?)
1
+ var y=Object.defineProperty;var o=(e,t)=>y(e,"name",{value:t,configurable:!0});import{canRead as O}from"./access.js";import{receiverForObject as T}from"./receivers.js";import{getByRowid as R}from"./objects.js";import{filterAsync as D,mapAsync as j}from"../async-array.js";const _=["spawn","job-start","ask"],I=["report.final","report.result","notice.>"];function S(e){return JSON.stringify(Object.fromEntries(e.map(t=>[String(t.threshold),t.delivery])))}o(S,"configToJson");function A(e){const t=JSON.parse(e);return Object.entries(t).map(([a,n])=>({threshold:Number(a),delivery:n})).sort((a,n)=>n.threshold-a.threshold)}o(A,"configFromJson");async function u(e,t,a){return await e.prepare("SELECT * FROM watches WHERE watcher = ? AND object = ?").get(t.rowid,a.rowid)}o(u,"watchRow");async function E(e,t){return await e.prepare("SELECT * FROM watch_subscriptions WHERE watch = ? ORDER BY rowid").all(t)}o(E,"subsOf");async function l(e,t){const a=await E(e,t);if(a.length===0){await e.prepare("DELETE FROM watches WHERE rowid = ?").run(t);return}const n=a.some(r=>_.includes(r.started_by))?1:0;await e.prepare("UPDATE watches SET in_tree = ? WHERE rowid = ? AND in_tree != ?").run(n,t,n)}o(l,"settle");function C(e,t){return e==="message"?I:t.patterns?.length?t.patterns:[">"]}o(C,"defaultPatterns");async function H(e,t,a,n,r={}){if(n==="fork")throw new Error("recordWatch: fork watches are made by copyWatchesForFork");if(t.type.includes(".")&&!await T(e,t))throw new Error(`custom object ${t.id} has no receiver`);const c=new Date().toISOString();await e.prepare(`INSERT INTO watches (watcher, object, in_tree, read_heads_key, created_at, link_app) VALUES (?, ?, 0, ?, ?, ?)
2
2
  ON CONFLICT (watcher, object) DO UPDATE SET read_heads_key = COALESCE(excluded.read_heads_key, read_heads_key),
3
- link_app = COALESCE(excluded.link_app, link_app)`).run(t.rowid,r.rowid,n.readHeadsKey??null,a,n.linkApp?.rowid??null);const s=h(e,t,r),E=o==="message"?n.endsOn??"final":null,f=O.includes(o),w=d(e,s.rowid),u=i(e,`INSERT INTO watch_subscriptions (watch, pattern, filter_json, config_json, started_by, ends_on, created_at)
4
- VALUES (?, ?, ?, ?, ?, ?, ?)`);for(const R of C(o,n))w.some(l=>l.pattern===R&&(l.ends_on===null||l.ends_on===E)&&(!f||O.includes(l.started_by)))||u.run(s.rowid,R,n.filter===void 0?null:JSON.stringify(n.filter),n.config?N(n.config):null,o,E,a);_(e,s.rowid)}c(F,"recordWatch");function H(e,t,r,o){i(e,"UPDATE watches SET link_app = ? WHERE watcher = ? AND object = ?").run(o.rowid,t.rowid,r.rowid)}c(H,"markLinkWatch");function M(e,t,r,o){const n=h(e,t,r);n&&(o===void 0?i(e,"DELETE FROM watch_subscriptions WHERE watch = ?").run(n.rowid):typeof o=="string"?i(e,"DELETE FROM watch_subscriptions WHERE watch = ? AND pattern = ?").run(n.rowid,o):i(e,"DELETE FROM watch_subscriptions WHERE watch = ? AND started_by = ?").run(n.rowid,o.startedBy),_(e,n.rowid))}c(M,"unwatch");function x(e,t,r,o,n){const a=h(e,t,r),s=a?i(e,"UPDATE watch_subscriptions SET config_json = ? WHERE watch = ? AND pattern = ?").run(n?N(n):null,a.rowid,o).changes:0;if(Number(s)===0)throw new Error(`${t.id} has no subscription ${o} on ${r.id}`)}c(x,"setSubscriptionConfig");function U(e,t,r){const o=typeof r=="string"?i(e,`DELETE FROM watch_subscriptions WHERE started_by = 'message'
5
- AND watch IN (SELECT rowid FROM watches WHERE object = ?) RETURNING watch`).all(t.rowid):i(e,`DELETE FROM watch_subscriptions WHERE started_by = 'message' AND ends_on = ?
6
- AND watch IN (SELECT rowid FROM watches WHERE object = ?) RETURNING watch`).all(`result:${r.result}`,t.rowid);for(const n of new Set(o.map(a=>a.watch)))_(e,n)}c(U,"endMessageSubscriptions");function g(e,t){const r=S(e,t.watcher),o=S(e,t.object);return!r||!o?null:{rowid:t.rowid,watcher:r,object:o,in_tree:t.in_tree===1,read_heads_key:t.read_heads_key,created_at:t.created_at,subscriptions:d(e,t.rowid).map(n=>({rowid:n.rowid,pattern:n.pattern,started_by:n.started_by,ends_on:n.ends_on,created_at:n.created_at,filter:n.filter_json===null?null:JSON.parse(n.filter_json),config:n.config_json===null?null:I(n.config_json)}))}}c(g,"hydrate");function T(e,t,r){return r.map(o=>g(e,o)).filter(o=>o!==null&&p(e,t,o.watcher)&&p(e,t,o.object))}c(T,"visible");function J(e,t,r){return T(e,t,i(e,"SELECT * FROM watches WHERE watcher = ? ORDER BY rowid").all(r.rowid))}c(J,"watchesOf");function B(e,t,r){return T(e,t,i(e,"SELECT * FROM watches WHERE object = ? ORDER BY rowid").all(r.rowid))}c(B,"watchersOf");function Y(e,t){return i(e,"SELECT o.id FROM watches w JOIN objects o ON o.rowid = w.watcher WHERE w.object = ? ORDER BY w.rowid").all(t.rowid).map(r=>r.id)}c(Y,"watcherIdsOf");function v(e,t){return i(e,`WITH RECURSIVE walk(rowid) AS (
3
+ link_app = COALESCE(excluded.link_app, link_app)`).run(t.rowid,a.rowid,r.readHeadsKey??null,c,r.linkApp?.rowid??null);const i=await u(e,t,a),s=n==="message"?r.endsOn??"final":null,h=_.includes(n),w=await E(e,i.rowid),d=e.prepare(`INSERT INTO watch_subscriptions (watch, pattern, filter_json, config_json, started_by, ends_on, created_at)
4
+ VALUES (?, ?, ?, ?, ?, ?, ?)`);for(const f of C(n,r))w.some(p=>p.pattern===f&&(p.ends_on===null||p.ends_on===s)&&(!h||_.includes(p.started_by)))||await d.run(i.rowid,f,r.filter===void 0?null:JSON.stringify(r.filter),r.config?S(r.config):null,n,s,c);await l(e,i.rowid)}o(H,"recordWatch");async function M(e,t,a,n){await e.prepare("UPDATE watches SET link_app = ? WHERE watcher = ? AND object = ?").run(n.rowid,t.rowid,a.rowid)}o(M,"markLinkWatch");async function x(e,t,a,n){const r=await u(e,t,a);r&&(n===void 0?await e.prepare("DELETE FROM watch_subscriptions WHERE watch = ?").run(r.rowid):typeof n=="string"?await e.prepare("DELETE FROM watch_subscriptions WHERE watch = ? AND pattern = ?").run(r.rowid,n):await e.prepare("DELETE FROM watch_subscriptions WHERE watch = ? AND started_by = ?").run(r.rowid,n.startedBy),await l(e,r.rowid))}o(x,"unwatch");async function U(e,t,a,n,r){const c=await u(e,t,a),i=c?(await e.prepare("UPDATE watch_subscriptions SET config_json = ? WHERE watch = ? AND pattern = ?").run(r?S(r):null,c.rowid,n)).changes:0;if(Number(i)===0)throw new Error(`${t.id} has no subscription ${n} on ${a.id}`)}o(U,"setSubscriptionConfig");async function J(e,t,a){const n=typeof a=="string"?await e.prepare(`DELETE FROM watch_subscriptions WHERE started_by = 'message'
5
+ AND watch IN (SELECT rowid FROM watches WHERE object = ?) RETURNING watch`).all(t.rowid):await e.prepare(`DELETE FROM watch_subscriptions WHERE started_by = 'message' AND ends_on = ?
6
+ AND watch IN (SELECT rowid FROM watches WHERE object = ?) RETURNING watch`).all(`result:${a.result}`,t.rowid);for(const r of new Set(n.map(c=>c.watch)))await l(e,r)}o(J,"endMessageSubscriptions");async function g(e,t){const a=await R(e,t.watcher),n=await R(e,t.object);return!a||!n?null:{rowid:t.rowid,watcher:a,object:n,in_tree:t.in_tree===1,read_heads_key:t.read_heads_key,created_at:t.created_at,subscriptions:(await E(e,t.rowid)).map(r=>({rowid:r.rowid,pattern:r.pattern,started_by:r.started_by,ends_on:r.ends_on,created_at:r.created_at,filter:r.filter_json===null?null:JSON.parse(r.filter_json),config:r.config_json===null?null:A(r.config_json)}))}}o(g,"hydrate");async function N(e,t,a){const n=(await j(a,async r=>await g(e,r))).filter(r=>r!==null);return await D(n,async r=>await O(e,t,r.watcher)&&await O(e,t,r.object))}o(N,"visible");async function B(e,t,a){return await N(e,t,await e.prepare("SELECT * FROM watches WHERE watcher = ? ORDER BY rowid").all(a.rowid))}o(B,"watchesOf");async function Y(e,t,a){return await N(e,t,await e.prepare("SELECT * FROM watches WHERE object = ? ORDER BY rowid").all(a.rowid))}o(Y,"watchersOf");async function v(e,t){return(await e.prepare("SELECT o.id FROM watches w JOIN objects o ON o.rowid = w.watcher WHERE w.object = ? ORDER BY w.rowid").all(t.rowid)).map(a=>a.id)}o(v,"watcherIdsOf");async function P(e,t){return await e.prepare(`WITH RECURSIVE walk(rowid) AS (
7
7
  SELECT ?
8
8
  UNION
9
9
  SELECT w.object FROM walk CROSS JOIN watches w INDEXED BY watches_tree_down ON w.watcher = walk.rowid AND w.in_tree = 1
10
10
  ) SELECT o.* FROM walk CROSS JOIN objects o ON o.rowid = walk.rowid
11
- WHERE o.type = 'node' AND o.rowid != ?`).all(t.rowid,t.rowid)}c(v,"descendants");function P(e,t){return i(e,`WITH RECURSIVE walk(rowid) AS (
11
+ WHERE o.type = 'node' AND o.rowid != ?`).all(t.rowid,t.rowid)}o(P,"descendants");async function V(e,t){return await e.prepare(`WITH RECURSIVE walk(rowid) AS (
12
12
  SELECT ?
13
13
  UNION
14
14
  SELECT w.watcher FROM walk CROSS JOIN watches w INDEXED BY watches_tree_up ON w.object = walk.rowid AND w.in_tree = 1
15
15
  ) SELECT o.* FROM walk CROSS JOIN objects o ON o.rowid = walk.rowid
16
- WHERE o.type = 'node' AND o.rowid != ?`).all(t.rowid,t.rowid)}c(P,"ancestors");function V(e,t){return i(e,`SELECT o.* FROM watches w INDEXED BY watches_tree_up CROSS JOIN objects o ON o.rowid = w.watcher
17
- WHERE w.object = ? AND w.in_tree = 1 ORDER BY w.rowid`).all(t.rowid)}c(V,"treeWatchersOf");function $(e,t,r){const o=new Date().toISOString(),n=i(e,"SELECT * FROM watches WHERE watcher = ?").all(t.rowid),a=i(e,`INSERT INTO watch_subscriptions (watch, pattern, filter_json, config_json, started_by, ends_on, created_at)
18
- VALUES (?, ?, ?, ?, 'fork', ?, ?)`);for(const s of n){if(s.object===r.rowid)continue;i(e,`INSERT INTO watches (watcher, object, in_tree, read_heads_key, created_at) VALUES (?, ?, 0, ?, ?)
19
- ON CONFLICT (watcher, object) DO NOTHING`).run(r.rowid,s.object,s.read_heads_key,o);const E=h(e,r,{rowid:s.object}),f=d(e,E.rowid);for(const w of d(e,s.rowid))f.some(u=>u.pattern===w.pattern&&u.ends_on===w.ends_on)||a.run(E.rowid,w.pattern,w.filter_json,w.config_json,w.ends_on,o);_(e,E.rowid)}}c($,"copyWatchesForFork");export{P as ancestors,I as configFromJson,N as configToJson,$ as copyWatchesForFork,v as descendants,U as endMessageSubscriptions,H as markLinkWatch,F as recordWatch,x as setSubscriptionConfig,V as treeWatchersOf,M as unwatch,Y as watcherIdsOf,B as watchersOf,J as watchesOf};
16
+ WHERE o.type = 'node' AND o.rowid != ?`).all(t.rowid,t.rowid)}o(V,"ancestors");async function $(e,t){return await e.prepare(`SELECT o.* FROM watches w INDEXED BY watches_tree_up CROSS JOIN objects o ON o.rowid = w.watcher
17
+ WHERE w.object = ? AND w.in_tree = 1 ORDER BY w.rowid`).all(t.rowid)}o($,"treeWatchersOf");async function G(e,t,a){const n=new Date().toISOString(),r=await e.prepare("SELECT * FROM watches WHERE watcher = ?").all(t.rowid),c=e.prepare(`INSERT INTO watch_subscriptions (watch, pattern, filter_json, config_json, started_by, ends_on, created_at)
18
+ VALUES (?, ?, ?, ?, 'fork', ?, ?)`);for(const i of r){if(i.object===a.rowid)continue;await e.prepare(`INSERT INTO watches (watcher, object, in_tree, read_heads_key, created_at) VALUES (?, ?, 0, ?, ?)
19
+ ON CONFLICT (watcher, object) DO NOTHING`).run(a.rowid,i.object,i.read_heads_key,n);const s=await u(e,a,{rowid:i.object}),h=await E(e,s.rowid);for(const w of await E(e,i.rowid))h.some(d=>d.pattern===w.pattern&&d.ends_on===w.ends_on)||await c.run(s.rowid,w.pattern,w.filter_json,w.config_json,w.ends_on,n);await l(e,s.rowid)}}o(G,"copyWatchesForFork");export{V as ancestors,A as configFromJson,S as configToJson,G as copyWatchesForFork,P as descendants,J as endMessageSubscriptions,M as markLinkWatch,H as recordWatch,U as setSubscriptionConfig,$ as treeWatchersOf,x as unwatch,v as watcherIdsOf,Y as watchersOf,B as watchesOf};
@@ -1,10 +1,10 @@
1
1
  /** Hex sha256 of the ticket's page document, recorded at first comment so the
2
2
  * settle-time completion can say whether the page changed during feedback. */
3
- export declare function pageDocumentSha256(dir: string): string;
3
+ export declare function pageDocumentSha256(dir: string): Promise<string>;
4
4
  /** A companion node nothing on the ticket points at must not stay resident:
5
5
  * the comment that would have bound it was refused, failed to commit, or lost
6
6
  * the first-comment race to a concurrently recorded companion. */
7
- export declare function discardFeedbackCompanion(nodeId: string): void;
7
+ export declare function discardFeedbackCompanion(nodeId: string): Promise<void>;
8
8
  /**
9
9
  * Fork the sending node's current state into the ticket-bound companion and
10
10
  * wait for its durable boundary bind. Throws on any failure — the caller
@@ -1 +1 @@
1
- var f=Object.defineProperty;var i=(e,o)=>f(e,"name",{value:o,configurable:!0});import{createHash as l}from"node:crypto";import{readFileSync as s}from"node:fs";import{getNode as u}from"../canvas/index.js";import{awaitCompanionBind as w,captureOrigin as h}from"../review/companion.js";import{COMPANION_BIND_DEADLINE_MS as t}from"../review/types.js";import{buildLaunchSpec as _}from"../runtime/launch.js";import{transition as N}from"../runtime/lifecycle.js";import{headlessBrokerHost as k}from"../runtime/host.js";import{spawnNode as b}from"../runtime/nodes.js";import{reviveNode as I}from"../runtime/revive.js";import{materializeSessionBranch as S}from"../runtime/session-branch.js";import{forkNodeLedger as x}from"../runtime/ledger.js";import{pagePath as a}from"./convention.js";import{selectedPageDir as c}from"./tickets.js";function H(e){return l("sha256").update(s(a(c(e),"jsx"))).digest("hex")}i(H,"pageDocumentSha256");function y(e){try{N(e,"cancel",{reason:"retired"}),k.teardown(e)}catch{}}i(y,"discardFeedbackCompanion");async function q(e){const o=u(e.senderNodeId);if(o===null)throw new Error(`page sender was not found: ${e.senderNodeId}`);const d=await h(e.senderNodeId),n=S(d),{launch:m}=_(o.kind,o.mode,{lifecycle:"resident",hasManager:!1,model:d.modelSpec,modelExact:!0,cwd:o.cwd,profileId:o.profile_id??null}),r=await b({kind:o.kind,mode:o.mode,lifecycle:"resident",cwd:o.cwd,profile_id:o.profile_id??null,parent:e.senderNodeId,creator:e.senderNodeId,subscribe:!1,forkFrom:n,forkSourceFile:n,modelOverride:d.modelSpec,reviewBinding:{kind:"page_feedback",review_id:e.ticketId,origin_node_id:e.senderNodeId,branch_file:n,target_file:a(c(e.dir),"jsx")},name:`Feedback \xB7 ${e.title}`,launch:m});try{if(x(r.node_id,e.senderNodeId),await I(r.node_id,{resume:!1,capacity:"refuse"}),!await w(r.node_id,t))throw new Error(`feedback companion did not bind within ${t}ms`)}catch(p){throw y(r.node_id),p}return r.node_id}i(q,"realizeFeedbackCompanion");export{y as discardFeedbackCompanion,H as pageDocumentSha256,q as realizeFeedbackCompanion};
1
+ var f=Object.defineProperty;var r=(e,o)=>f(e,"name",{value:o,configurable:!0});import{createHash as l}from"node:crypto";import{readFileSync as s}from"node:fs";import{getNode as w}from"../canvas/index.js";import{awaitCompanionBind as u,captureOrigin as h}from"../review/companion.js";import{COMPANION_BIND_DEADLINE_MS as t}from"../review/types.js";import{buildLaunchSpec as _}from"../runtime/launch.js";import{transition as N}from"../runtime/lifecycle.js";import{headlessBrokerHost as k}from"../runtime/host.js";import{spawnNode as b}from"../runtime/nodes.js";import{reviveNode as I}from"../runtime/revive.js";import{materializeSessionBranch as y}from"../runtime/session-branch.js";import{forkNodeLedger as S}from"../runtime/ledger.js";import{pagePath as a}from"./convention.js";import{selectedPageDir as c}from"./tickets.js";async function H(e){return l("sha256").update(s(a(await c(e),"jsx"))).digest("hex")}r(H,"pageDocumentSha256");async function x(e){try{await N(e,"cancel",{reason:"retired"}),k.teardown(e)}catch{}}r(x,"discardFeedbackCompanion");async function q(e){const o=await w(e.senderNodeId);if(o===null)throw new Error(`page sender was not found: ${e.senderNodeId}`);const d=await h(e.senderNodeId),n=await y(d),{launch:m}=_(o.kind,o.mode,{lifecycle:"resident",hasManager:!1,model:d.modelSpec,modelExact:!0,cwd:o.cwd,profileId:o.profile_id??null}),i=await b({kind:o.kind,mode:o.mode,lifecycle:"resident",cwd:o.cwd,profile_id:o.profile_id??null,parent:e.senderNodeId,creator:e.senderNodeId,subscribe:!1,forkFrom:n,forkSourceFile:n,modelOverride:d.modelSpec,reviewBinding:{kind:"page_feedback",review_id:e.ticketId,origin_node_id:e.senderNodeId,branch_file:n,target_file:a(await c(e.dir),"jsx")},name:`Feedback \xB7 ${e.title}`,launch:m});try{if(await S(i.node_id,e.senderNodeId),await I(i.node_id,{resume:!1,capacity:"refuse"}),!await u(i.node_id,t))throw new Error(`feedback companion did not bind within ${t}ms`)}catch(p){throw await x(i.node_id),p}return i.node_id}r(q,"realizeFeedbackCompanion");export{x as discardFeedbackCompanion,H as pageDocumentSha256,q as realizeFeedbackCompanion};
@@ -34,7 +34,7 @@ declare const pageFeedbackSchema: z.ZodObject<{
34
34
  export type PageFeedbackComment = z.infer<typeof pageFeedbackCommentSchema>;
35
35
  export type PageFeedback = z.infer<typeof pageFeedbackSchema>;
36
36
  /** Read page feedback from the request row. */
37
- export declare function readPageFeedback(dir: string): PageFeedback;
37
+ export declare function readPageFeedback(dir: string): Promise<PageFeedback>;
38
38
  export interface CreatePageFeedbackCommentInput {
39
39
  quote: string;
40
40
  context?: string;
@@ -56,7 +56,7 @@ export declare class PageFeedbackCommentAlreadyResolvedError extends Error {
56
56
  constructor(commentId: string);
57
57
  }
58
58
  /** Append feedback in the request transaction; terminal rows reject it. */
59
- export declare function createPageFeedbackComment(dir: string, input: CreatePageFeedbackCommentInput): PageFeedbackMutation;
59
+ export declare function createPageFeedbackComment(dir: string, input: CreatePageFeedbackCommentInput): Promise<PageFeedbackMutation>;
60
60
  /** Resolve one feedback comment in the request transaction. */
61
- export declare function resolvePageFeedbackComment(dir: string, commentId: string): PageFeedbackMutation;
61
+ export declare function resolvePageFeedbackComment(dir: string, commentId: string): Promise<PageFeedbackMutation>;
62
62
  export {};
@@ -1 +1 @@
1
- var h=Object.defineProperty;var r=(t,e)=>h(t,"name",{value:e,configurable:!0});import{prepared as c}from"../sqlite-statements.js";import{randomUUID as b}from"node:crypto";import{z as n}from"zod";import{withCanvasWrite as p}from"../canvas/db.js";import{getRequestByDirectory as w}from"./requests.js";const _="crtr.page-feedback/v1";function D(t){return`${t}/feedback-comments.json`}r(D,"pageFeedbackPath");const S=n.object({id:n.string().min(1),quote:n.string().min(1),context:n.string().optional(),note:n.string().min(1),status:n.enum(["open","resolved"]),createdAt:n.string().datetime({offset:!0}),resolvedAt:n.string().datetime({offset:!0}).optional()}).strict(),E=n.object({schema:n.literal(_),companionNodeId:n.string().min(1).optional(),firstCommentedSha256:n.string().min(1).optional(),comments:n.array(S)}).strict();function k(){return{schema:_,comments:[]}}r(k,"emptyFeedback");function u(t){const e=w(t);if(e===null||e.kind!=="page")throw new Error(`unknown page request directory: ${t}`);return e}r(u,"requestForDirectory");function f(t){if(t.feedback_json===null)return t.companion_node_id===null?k():{...k(),companionNodeId:t.companion_node_id};try{return E.parse(JSON.parse(t.feedback_json))}catch(e){throw new Error(`page feedback is malformed for ${t.request_id}`,{cause:e})}}r(f,"feedback");function I(t){return f(u(t))}r(I,"readPageFeedback");class l extends Error{static{r(this,"PageTicketTerminalError")}constructor(){super("ticket already has a terminal outcome")}}class q extends Error{static{r(this,"UnknownPageFeedbackCommentError")}constructor(e){super(`no feedback comment ${e} on this ticket`)}}class x extends Error{static{r(this,"PageFeedbackCommentAlreadyResolvedError")}constructor(e){super(`feedback comment ${e} is already resolved`)}}function N(t,e){const a=u(t);return p(i=>{const s=c(i,"SELECT * FROM human_requests WHERE request_id = ?").get(a.request_id);if(s===void 0)throw new Error(`human request disappeared: ${a.request_id}`);if(s.state!=="open")throw new l;const m={...a,feedback_json:s.feedback_json,companion_node_id:s.companion_node_id},o=f(m);o.companionNodeId===void 0&&e.companionNodeId!==void 0&&(o.companionNodeId=e.companionNodeId,e.firstCommentedSha256!==void 0&&(o.firstCommentedSha256=e.firstCommentedSha256));const d={id:b(),quote:e.quote,...e.context===void 0?{}:{context:e.context},note:e.note,status:"open",createdAt:new Date().toISOString()};return o.comments.push(d),E.parse(o),c(i,"UPDATE human_requests SET feedback_json = ?, companion_node_id = COALESCE(companion_node_id, ?), updated_at = ? WHERE request_id = ?").run(JSON.stringify(o),o.companionNodeId??null,new Date().toISOString(),a.request_id),{comment:d,feedback:o}})}r(N,"createPageFeedbackComment");function O(t,e){const a=u(t);return p(i=>{const s=c(i,"SELECT * FROM human_requests WHERE request_id = ?").get(a.request_id);if(s===void 0)throw new Error(`human request disappeared: ${a.request_id}`);if(s.state!=="open")throw new l;const m={...a,feedback_json:s.feedback_json,companion_node_id:s.companion_node_id},o=f(m),d=o.comments.find(g=>g.id===e);if(d===void 0)throw new q(e);if(d.status==="resolved")throw new x(e);return d.status="resolved",d.resolvedAt=new Date().toISOString(),c(i,"UPDATE human_requests SET feedback_json = ?, updated_at = ? WHERE request_id = ?").run(JSON.stringify(o),new Date().toISOString(),a.request_id),{comment:d,feedback:o}})}r(O,"resolvePageFeedbackComment");export{_ as PAGE_FEEDBACK_SCHEMA,x as PageFeedbackCommentAlreadyResolvedError,l as PageTicketTerminalError,q as UnknownPageFeedbackCommentError,N as createPageFeedbackComment,D as pageFeedbackPath,I as readPageFeedback,O as resolvePageFeedbackComment};
1
+ var l=Object.defineProperty;var r=(t,e)=>l(t,"name",{value:e,configurable:!0});import{randomUUID as g}from"node:crypto";import{z as n}from"zod";import{withCanvasWrite as f}from"../canvas/db.js";import{getRequestByDirectory as h}from"./requests.js";const p="crtr.page-feedback/v1";function A(t){return`${t}/feedback-comments.json`}r(A,"pageFeedbackPath");const b=n.object({id:n.string().min(1),quote:n.string().min(1),context:n.string().optional(),note:n.string().min(1),status:n.enum(["open","resolved"]),createdAt:n.string().datetime({offset:!0}),resolvedAt:n.string().datetime({offset:!0}).optional()}).strict(),_=n.object({schema:n.literal(p),companionNodeId:n.string().min(1).optional(),firstCommentedSha256:n.string().min(1).optional(),comments:n.array(b)}).strict();function w(){return{schema:p,comments:[]}}r(w,"emptyFeedback");async function m(t){const e=await h(t);if(e===null||e.kind!=="page")throw new Error(`unknown page request directory: ${t}`);return e}r(m,"requestForDirectory");function u(t){if(t.feedback_json===null)return t.companion_node_id===null?w():{...w(),companionNodeId:t.companion_node_id};try{return _.parse(JSON.parse(t.feedback_json))}catch(e){throw new Error(`page feedback is malformed for ${t.request_id}`,{cause:e})}}r(u,"feedback");async function v(t){return u(await m(t))}r(v,"readPageFeedback");class E extends Error{static{r(this,"PageTicketTerminalError")}constructor(){super("ticket already has a terminal outcome")}}class S extends Error{static{r(this,"UnknownPageFeedbackCommentError")}constructor(e){super(`no feedback comment ${e} on this ticket`)}}class q extends Error{static{r(this,"PageFeedbackCommentAlreadyResolvedError")}constructor(e){super(`feedback comment ${e} is already resolved`)}}async function D(t,e){const a=await m(t);return await f(async d=>{const s=await d.prepare("SELECT * FROM human_requests WHERE request_id = ?").get(a.request_id);if(s===void 0)throw new Error(`human request disappeared: ${a.request_id}`);if(s.state!=="open")throw new E;const c={...a,feedback_json:s.feedback_json,companion_node_id:s.companion_node_id},o=u(c);o.companionNodeId===void 0&&e.companionNodeId!==void 0&&(o.companionNodeId=e.companionNodeId,e.firstCommentedSha256!==void 0&&(o.firstCommentedSha256=e.firstCommentedSha256));const i={id:g(),quote:e.quote,...e.context===void 0?{}:{context:e.context},note:e.note,status:"open",createdAt:new Date().toISOString()};return o.comments.push(i),_.parse(o),await d.prepare("UPDATE human_requests SET feedback_json = ?, companion_node_id = COALESCE(companion_node_id, ?), updated_at = ? WHERE request_id = ?").run(JSON.stringify(o),o.companionNodeId??null,new Date().toISOString(),a.request_id),{comment:i,feedback:o}})}r(D,"createPageFeedbackComment");async function I(t,e){const a=await m(t);return await f(async d=>{const s=await d.prepare("SELECT * FROM human_requests WHERE request_id = ?").get(a.request_id);if(s===void 0)throw new Error(`human request disappeared: ${a.request_id}`);if(s.state!=="open")throw new E;const c={...a,feedback_json:s.feedback_json,companion_node_id:s.companion_node_id},o=u(c),i=o.comments.find(k=>k.id===e);if(i===void 0)throw new S(e);if(i.status==="resolved")throw new q(e);return i.status="resolved",i.resolvedAt=new Date().toISOString(),await d.prepare("UPDATE human_requests SET feedback_json = ?, updated_at = ? WHERE request_id = ?").run(JSON.stringify(o),new Date().toISOString(),a.request_id),{comment:i,feedback:o}})}r(I,"resolvePageFeedbackComment");export{p as PAGE_FEEDBACK_SCHEMA,q as PageFeedbackCommentAlreadyResolvedError,E as PageTicketTerminalError,S as UnknownPageFeedbackCommentError,D as createPageFeedbackComment,A as pageFeedbackPath,v as readPageFeedback,I as resolvePageFeedbackComment};
@@ -1,4 +1,5 @@
1
1
  import type { DatabaseSync } from 'node:sqlite';
2
+ import { type CanvasDb } from '../canvas/db.js';
2
3
  import { type PreparedPage } from './page-authoring.js';
3
4
  import { type PageResponses } from './page-schema.js';
4
5
  export type HumanRequestKind = 'page' | 'review';
@@ -86,52 +87,52 @@ export declare function publishPageRevision(dir: string, prepared: PreparedPage,
86
87
  /** The SQL-selected page revision. There is no path-based fallback for page reads. */
87
88
  export declare function presentationDir(request: HumanRequestRecord): string;
88
89
  /** Creates one SQL-authoritative page request. `request_id` is optional for ordinary callers and frozen by cron creation. */
89
- export declare function createPageRequest(input: CreatePageRequestInput): HumanRequestRecord;
90
+ export declare function createPageRequest(input: CreatePageRequestInput): Promise<HumanRequestRecord>;
90
91
  /** Claims a review idempotency key before companion realization. */
91
- export declare function commitBindingRequest(input: NewReviewRequest): {
92
+ export declare function commitBindingRequest(input: NewReviewRequest): Promise<{
92
93
  request_id: string;
93
94
  won: boolean;
94
- };
95
- export declare function getRequest(requestId: string): HumanRequestRecord | null;
96
- export declare function getRequestByInboxTicket(ticketId: string): HumanRequestRecord | null;
97
- export declare function getRequestByDirectory(dir: string): HumanRequestRecord | null;
98
- export declare function getRequestByCompanion(nodeId: string): HumanRequestRecord | null;
99
- export declare function getRequestByIdempotencyKey(key: string): HumanRequestRecord | null;
95
+ }>;
96
+ export declare function getRequest(requestId: string): Promise<HumanRequestRecord | null>;
97
+ export declare function getRequestByInboxTicket(ticketId: string): Promise<HumanRequestRecord | null>;
98
+ export declare function getRequestByDirectory(dir: string): Promise<HumanRequestRecord | null>;
99
+ export declare function getRequestByCompanion(nodeId: string): Promise<HumanRequestRecord | null>;
100
+ export declare function getRequestByIdempotencyKey(key: string): Promise<HumanRequestRecord | null>;
100
101
  /** SQL for the node a page request belongs to: its requester, else, for a notice only (a page that takes no response
101
102
  * and so has no requester), the node that sent it. `alias` is the human_requests table or alias. */
102
103
  export declare const askingNodeSql: (alias: string) => string;
103
104
  /** A page asked from a run of an app other than the terminal is that app's to show
104
105
  * (daemon-operations §question.*: the terminal shows `app:terminal` runs' questions). */
105
106
  export declare const NOT_OTHER_APP_QUESTION: string;
106
- export declare function listOpenInboxRequests(): HumanRequestRecord[];
107
+ export declare function listOpenInboxRequests(): Promise<HumanRequestRecord[]>;
107
108
  /** Every open request a person is being asked to act on: the inbox's set (`listOpenInboxRequests`), plus
108
109
  * answerable pages kept out of the inbox. This is the set the attach viewer's inbox strip shows. */
109
- export declare function listPendingAsks(): HumanRequestRecord[];
110
- export declare function openRequestsByRequester(nodeId: string): HumanRequestRecord[];
111
- export declare function hasOpenReplyBearingRequestByRequester(nodeId: string): boolean;
110
+ export declare function listPendingAsks(): Promise<HumanRequestRecord[]>;
111
+ export declare function openRequestsByRequester(nodeId: string): Promise<HumanRequestRecord[]>;
112
+ export declare function hasOpenReplyBearingRequestByRequester(nodeId: string): Promise<boolean>;
112
113
  /** Indexed attention projection: only open inbox-listed requests with a reply target keep a node wakeable. */
113
- export declare function listOpenReplyBearingRequests(): HumanRequestRecord[];
114
- export declare function listBindingRequests(): HumanRequestRecord[];
115
- export declare function listSubmitRequestedRequests(): HumanRequestRecord[];
116
- export declare function listUnprojectedReviews(): HumanRequestRecord[];
114
+ export declare function listOpenReplyBearingRequests(): Promise<HumanRequestRecord[]>;
115
+ export declare function listBindingRequests(): Promise<HumanRequestRecord[]>;
116
+ export declare function listSubmitRequestedRequests(): Promise<HumanRequestRecord[]>;
117
+ export declare function listUnprojectedReviews(): Promise<HumanRequestRecord[]>;
117
118
  export declare function listRequests(filter?: {
118
119
  kind?: HumanRequestKind;
119
120
  state?: HumanRequestState;
120
121
  requester_node_id?: string;
121
122
  file?: string;
122
123
  page_source_node_id?: string;
123
- }): HumanRequestRecord[];
124
+ }): Promise<HumanRequestRecord[]>;
124
125
  /** An indexed preflight preserves the old map-before-filter error for corrupt page JSON. */
125
- export declare function hasPageResultException(): boolean;
126
- export declare function firstInvalidPageSpecification(): Pick<HumanRequestRecord, 'request_id' | 'specification_json'> | null;
127
- export declare function openRequest(requestId: string, openedAt: string): boolean;
126
+ export declare function hasPageResultException(): Promise<boolean>;
127
+ export declare function firstInvalidPageSpecification(): Promise<Pick<HumanRequestRecord, 'request_id' | 'specification_json'> | null>;
128
+ export declare function openRequest(requestId: string, openedAt: string): Promise<boolean>;
128
129
  /** A binding whose immutable branch disappeared never recaptures a new origin. */
129
- export declare function cancelBindingRequest(requestId: string, at: string, reason: string): boolean;
130
- export declare function requestSubmit(requestId: string, at: string): boolean;
130
+ export declare function cancelBindingRequest(requestId: string, at: string, reason: string): Promise<boolean>;
131
+ export declare function requestSubmit(requestId: string, at: string): Promise<boolean>;
131
132
  /** The first-writer-wins terminal transition. Callers add obligations in this same `withCanvasWrite` boundary. */
132
- export declare function settleRequestLocked(db: DatabaseSync, args: SettleRequestArgs): HumanRequestRecord | null;
133
- export declare function setSettlementDeliveryMarksLocked(db: DatabaseSync, requestId: string, marks: RequestSettlementMarks): void;
134
- export declare function setSubmitNoteDeliveryLocked(db: DatabaseSync, requestId: string, deliveryId: string): boolean;
133
+ export declare function settleRequestLocked(db: CanvasDb, args: SettleRequestArgs): Promise<HumanRequestRecord | null>;
134
+ export declare function setSettlementDeliveryMarksLocked(db: CanvasDb, requestId: string, marks: RequestSettlementMarks): Promise<void>;
135
+ export declare function setSubmitNoteDeliveryLocked(db: CanvasDb, requestId: string, deliveryId: string): Promise<boolean>;
135
136
  export declare function revisePageRequest(requestId: string, values: {
136
137
  presentation_dir: string;
137
138
  specification_json: string;
@@ -139,14 +140,14 @@ export declare function revisePageRequest(requestId: string, values: {
139
140
  subtitle: string | null;
140
141
  inbox_listed: boolean;
141
142
  settleable: boolean;
142
- }): boolean;
143
- export declare function writeProgress(ticketId: string, responses: PageResponses): boolean;
144
- export declare function markProjected(requestId: string, at: string): void;
145
- export declare function markProjectionError(requestId: string, error: string): void;
146
- export declare function markCompanionRetired(requestId: string, at: string): void;
147
- export declare function readAnchorBase(requestId: string): {
143
+ }): Promise<boolean>;
144
+ export declare function writeProgress(ticketId: string, responses: PageResponses): Promise<boolean>;
145
+ export declare function markProjected(requestId: string, at: string): Promise<void>;
146
+ export declare function markProjectionError(requestId: string, error: string): Promise<void>;
147
+ export declare function markCompanionRetired(requestId: string, at: string): Promise<void>;
148
+ export declare function readAnchorBase(requestId: string): Promise<{
148
149
  bytes: Buffer;
149
150
  sha256: string;
150
- } | null;
151
- export declare function replaceAnchorBaseLocked(db: DatabaseSync, requestId: string, bytes: Buffer, sha256: string): void;
151
+ } | null>;
152
+ export declare function replaceAnchorBaseLocked(db: CanvasDb, requestId: string, bytes: Buffer, sha256: string): Promise<void>;
152
153
  export declare function migrateHumanRequestsState(db: DatabaseSync): void;