@north-light/cli 0.3.530 → 0.3.532

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (495) hide show
  1. package/dist/clients/attach/session/connection.js +1 -1
  2. package/dist/clients/attach/session/reconnect.js +1 -1
  3. package/dist/clients/attach/viewer.js +508 -508
  4. package/dist/core/async-array.d.ts +7 -0
  5. package/dist/core/async-array.js +1 -0
  6. package/dist/core/audit.d.ts +1 -1
  7. package/dist/core/audit.js +2 -2
  8. package/dist/core/canvas/attention.d.ts +4 -4
  9. package/dist/core/canvas/attention.js +1 -1
  10. package/dist/core/canvas/boot.d.ts +4 -4
  11. package/dist/core/canvas/boot.js +1 -1
  12. package/dist/core/canvas/canvas.d.ts +59 -59
  13. package/dist/core/canvas/canvas.js +19 -19
  14. package/dist/core/canvas/context-strip.js +2 -2
  15. package/dist/core/canvas/crons.d.ts +27 -27
  16. package/dist/core/canvas/crons.js +11 -11
  17. package/dist/core/canvas/daemon-actions.d.ts +10 -10
  18. package/dist/core/canvas/daemon-actions.js +8 -8
  19. package/dist/core/canvas/daemon-owner.d.ts +3 -3
  20. package/dist/core/canvas/daemon-owner.js +2 -2
  21. package/dist/core/canvas/db.d.ts +19 -30
  22. package/dist/core/canvas/db.js +3 -2
  23. package/dist/core/canvas/deliveries.d.ts +16 -16
  24. package/dist/core/canvas/deliveries.js +24 -24
  25. package/dist/core/canvas/executions.d.ts +8 -8
  26. package/dist/core/canvas/executions.js +1 -1
  27. package/dist/core/canvas/focuses.d.ts +8 -8
  28. package/dist/core/canvas/focuses.js +1 -1
  29. package/dist/core/canvas/history.d.ts +3 -3
  30. package/dist/core/canvas/history.js +9 -9
  31. package/dist/core/canvas/install-id.d.ts +1 -1
  32. package/dist/core/canvas/install-id.js +1 -1
  33. package/dist/core/canvas/managed-worktree-sweep-candidates.d.ts +1 -1
  34. package/dist/core/canvas/managed-worktree-sweep-candidates.js +2 -2
  35. package/dist/core/canvas/memory-reads.d.ts +6 -6
  36. package/dist/core/canvas/memory-reads.js +1 -1
  37. package/dist/core/canvas/nav-model.d.ts +13 -13
  38. package/dist/core/canvas/nav-model.js +1 -1
  39. package/dist/core/canvas/node-agent-paths.d.ts +6 -6
  40. package/dist/core/canvas/node-agent-paths.js +1 -1
  41. package/dist/core/canvas/node-tokens.d.ts +7 -7
  42. package/dist/core/canvas/node-tokens.js +3 -3
  43. package/dist/core/canvas/outcome-actions.d.ts +5 -5
  44. package/dist/core/canvas/outcome-actions.js +3 -3
  45. package/dist/core/canvas/recovery.d.ts +26 -26
  46. package/dist/core/canvas/recovery.js +2 -2
  47. package/dist/core/canvas/render-source.d.ts +1 -1
  48. package/dist/core/canvas/render-source.js +1 -1
  49. package/dist/core/canvas/sessions.d.ts +10 -10
  50. package/dist/core/canvas/sessions.js +4 -4
  51. package/dist/core/canvas/source.js +1 -1
  52. package/dist/core/canvas/structured-requests.d.ts +15 -15
  53. package/dist/core/canvas/structured-requests.js +5 -5
  54. package/dist/core/canvas/tree.d.ts +9 -9
  55. package/dist/core/canvas/tree.js +5 -5
  56. package/dist/core/canvas/waits.d.ts +13 -13
  57. package/dist/core/canvas/waits.js +6 -6
  58. package/dist/core/canvas/worktrees.d.ts +15 -15
  59. package/dist/core/canvas/worktrees.js +1 -1
  60. package/dist/core/command-hooks/transport/exec-lifecycle.js +1 -1
  61. package/dist/core/conversation-store/file-store.d.ts +7 -7
  62. package/dist/core/conversation-store/file-store.js +9 -9
  63. package/dist/core/conversation-store/index.d.ts +16 -14
  64. package/dist/core/conversation-store/index.js +1 -1
  65. package/dist/core/conversation-store/listener.js +5 -5
  66. package/dist/core/conversation-store/patch.d.ts +3 -1
  67. package/dist/core/conversation-store/patch.js +1 -1
  68. package/dist/core/feed/feed.js +3 -3
  69. package/dist/core/feed/inbox.d.ts +2 -2
  70. package/dist/core/feed/inbox.js +1 -1
  71. package/dist/core/feed/messages.d.ts +11 -12
  72. package/dist/core/feed/messages.js +5 -5
  73. package/dist/core/feed/reports.d.ts +4 -4
  74. package/dist/core/feed/reports.js +2 -2
  75. package/dist/core/grants/cover.d.ts +1 -1
  76. package/dist/core/grants/cover.js +1 -1
  77. package/dist/core/grants/local.d.ts +1 -1
  78. package/dist/core/grants/local.js +1 -1
  79. package/dist/core/grants/mirror.d.ts +19 -19
  80. package/dist/core/grants/mirror.js +2 -2
  81. package/dist/core/grants/on-sync.d.ts +1 -1
  82. package/dist/core/grants/on-sync.js +1 -1
  83. package/dist/core/grants/remove.js +1 -1
  84. package/dist/core/grants/sync.js +1 -1
  85. package/dist/core/graph/access.d.ts +17 -17
  86. package/dist/core/graph/access.js +3 -3
  87. package/dist/core/graph/custom.d.ts +16 -16
  88. package/dist/core/graph/custom.js +9 -9
  89. package/dist/core/graph/deletion.d.ts +3 -7
  90. package/dist/core/graph/deletion.js +4 -4
  91. package/dist/core/graph/documents.d.ts +24 -27
  92. package/dist/core/graph/documents.js +7 -7
  93. package/dist/core/graph/edges.d.ts +13 -13
  94. package/dist/core/graph/edges.js +1 -1
  95. package/dist/core/graph/events.d.ts +7 -9
  96. package/dist/core/graph/events.js +8 -8
  97. package/dist/core/graph/exposures.d.ts +6 -6
  98. package/dist/core/graph/exposures.js +4 -4
  99. package/dist/core/graph/jobs.d.ts +6 -8
  100. package/dist/core/graph/jobs.js +2 -2
  101. package/dist/core/graph/kinds/action.js +1 -1
  102. package/dist/core/graph/kinds/custom.js +2 -2
  103. package/dist/core/graph/kinds/document.d.ts +1 -0
  104. package/dist/core/graph/kinds/document.js +4 -4
  105. package/dist/core/graph/kinds/dto.d.ts +2 -2
  106. package/dist/core/graph/kinds/dto.js +1 -1
  107. package/dist/core/graph/kinds/job.js +2 -2
  108. package/dist/core/graph/kinds/kind.d.ts +6 -8
  109. package/dist/core/graph/kinds/kind.js +1 -1
  110. package/dist/core/graph/kinds/node.js +5 -5
  111. package/dist/core/graph/kinds/owner.js +2 -2
  112. package/dist/core/graph/kinds/registry.d.ts +6 -9
  113. package/dist/core/graph/kinds/registry.js +1 -1
  114. package/dist/core/graph/names.d.ts +6 -6
  115. package/dist/core/graph/names.js +3 -3
  116. package/dist/core/graph/object-waits.d.ts +4 -7
  117. package/dist/core/graph/object-waits.js +1 -1
  118. package/dist/core/graph/objects.d.ts +14 -14
  119. package/dist/core/graph/objects.js +9 -9
  120. package/dist/core/graph/package-docs.d.ts +2 -7
  121. package/dist/core/graph/package-docs.js +5 -5
  122. package/dist/core/graph/package-kinds.d.ts +2 -5
  123. package/dist/core/graph/package-kinds.js +1 -1
  124. package/dist/core/graph/package-reconcile.d.ts +2 -5
  125. package/dist/core/graph/package-reconcile.js +1 -1
  126. package/dist/core/graph/reader.d.ts +18 -18
  127. package/dist/core/graph/reader.js +3 -3
  128. package/dist/core/graph/receivers.d.ts +4 -4
  129. package/dist/core/graph/receivers.js +5 -5
  130. package/dist/core/graph/repo-sync/exchange.d.ts +3 -7
  131. package/dist/core/graph/repo-sync/exchange.js +2 -2
  132. package/dist/core/graph/repo-sync/repos.d.ts +7 -5
  133. package/dist/core/graph/repo-sync/repos.js +3 -3
  134. package/dist/core/graph/repo-sync/sync.d.ts +3 -6
  135. package/dist/core/graph/repo-sync/sync.js +2 -2
  136. package/dist/core/graph/rules.d.ts +5 -5
  137. package/dist/core/graph/rules.js +3 -3
  138. package/dist/core/graph/spaces/app.js +1 -1
  139. package/dist/core/graph/spaces/index.d.ts +4 -5
  140. package/dist/core/graph/spaces/index.js +1 -1
  141. package/dist/core/graph/spaces/own-memory.d.ts +4 -4
  142. package/dist/core/graph/spaces/own-memory.js +1 -1
  143. package/dist/core/graph/spaces/person.js +3 -3
  144. package/dist/core/graph/spaces/repo.d.ts +1 -1
  145. package/dist/core/graph/spaces/repo.js +1 -1
  146. package/dist/core/graph/watches.d.ts +15 -15
  147. package/dist/core/graph/watches.js +10 -10
  148. package/dist/core/human/feedback-companion.d.ts +2 -2
  149. package/dist/core/human/feedback-companion.js +1 -1
  150. package/dist/core/human/feedback.d.ts +3 -3
  151. package/dist/core/human/feedback.js +1 -1
  152. package/dist/core/human/requests.d.ts +34 -33
  153. package/dist/core/human/requests.js +20 -20
  154. package/dist/core/human/scan.d.ts +2 -2
  155. package/dist/core/human/scan.js +1 -1
  156. package/dist/core/human/tickets.d.ts +9 -9
  157. package/dist/core/human/tickets.js +1 -1
  158. package/dist/core/llm/app-rungs.d.ts +1 -1
  159. package/dist/core/llm/app-rungs.js +1 -1
  160. package/dist/core/llm/run.js +2 -2
  161. package/dist/core/peer/directory.d.ts +1 -1
  162. package/dist/core/peer/directory.js +1 -1
  163. package/dist/core/peer/envelope.d.ts +3 -3
  164. package/dist/core/peer/envelope.js +1 -1
  165. package/dist/core/peer/home.d.ts +13 -7
  166. package/dist/core/peer/home.js +2 -2
  167. package/dist/core/peer/ingest.d.ts +6 -6
  168. package/dist/core/peer/ingest.js +1 -1
  169. package/dist/core/peer/outbox-store.d.ts +14 -14
  170. package/dist/core/peer/outbox-store.js +5 -5
  171. package/dist/core/peer/receiver.d.ts +2 -2
  172. package/dist/core/peer/receiver.js +1 -1
  173. package/dist/core/peer/stubs.d.ts +10 -10
  174. package/dist/core/peer/stubs.js +1 -1
  175. package/dist/core/providers/approval.d.ts +2 -2
  176. package/dist/core/providers/approval.js +2 -2
  177. package/dist/core/providers/audit.d.ts +3 -3
  178. package/dist/core/providers/audit.js +2 -2
  179. package/dist/core/providers/bundles.js +2 -2
  180. package/dist/core/providers/call.d.ts +2 -2
  181. package/dist/core/providers/call.js +1 -1
  182. package/dist/core/providers/files.d.ts +1 -1
  183. package/dist/core/providers/files.js +1 -1
  184. package/dist/core/providers/mint.js +1 -1
  185. package/dist/core/providers/receipts.d.ts +1 -1
  186. package/dist/core/providers/receipts.js +2 -2
  187. package/dist/core/review/birth.js +1 -1
  188. package/dist/core/review/comments.d.ts +19 -19
  189. package/dist/core/review/comments.js +5 -5
  190. package/dist/core/review/companion.d.ts +1 -1
  191. package/dist/core/review/companion.js +1 -1
  192. package/dist/core/review/document.d.ts +3 -3
  193. package/dist/core/review/document.js +2 -2
  194. package/dist/core/review/fork.js +2 -2
  195. package/dist/core/review/realize.js +1 -1
  196. package/dist/core/review/remap.d.ts +2 -2
  197. package/dist/core/review/remap.js +4 -4
  198. package/dist/core/review/stage.d.ts +1 -1
  199. package/dist/core/review/stage.js +1 -1
  200. package/dist/core/review/store.d.ts +21 -21
  201. package/dist/core/review/store.js +1 -1
  202. package/dist/core/runs/activity.d.ts +1 -1
  203. package/dist/core/runs/activity.js +5 -5
  204. package/dist/core/runs/confinement.d.ts +7 -7
  205. package/dist/core/runs/confinement.js +2 -2
  206. package/dist/core/runs/events.d.ts +12 -12
  207. package/dist/core/runs/events.js +4 -4
  208. package/dist/core/runs/operations.d.ts +11 -11
  209. package/dist/core/runs/operations.js +5 -5
  210. package/dist/core/runs/questions.d.ts +10 -10
  211. package/dist/core/runs/questions.js +3 -3
  212. package/dist/core/runtime/auth-reload.js +1 -1
  213. package/dist/core/runtime/bearings.d.ts +5 -5
  214. package/dist/core/runtime/bearings.js +6 -6
  215. package/dist/core/runtime/broker-inventory.js +1 -1
  216. package/dist/core/runtime/broker-request.js +1 -1
  217. package/dist/core/runtime/broker.js +1 -1
  218. package/dist/core/runtime/close.d.ts +3 -3
  219. package/dist/core/runtime/close.js +1 -1
  220. package/dist/core/runtime/deliver-live.js +1 -1
  221. package/dist/core/runtime/fleet.d.ts +2 -2
  222. package/dist/core/runtime/host.d.ts +3 -3
  223. package/dist/core/runtime/host.js +3 -3
  224. package/dist/core/runtime/kickoff.d.ts +12 -12
  225. package/dist/core/runtime/kickoff.js +17 -17
  226. package/dist/core/runtime/launch-target.d.ts +1 -1
  227. package/dist/core/runtime/launch-target.js +1 -1
  228. package/dist/core/runtime/ledger.d.ts +3 -3
  229. package/dist/core/runtime/ledger.js +3 -3
  230. package/dist/core/runtime/lifecycle.d.ts +1 -1
  231. package/dist/core/runtime/lifecycle.js +2 -2
  232. package/dist/core/runtime/memory-admission.js +1 -1
  233. package/dist/core/runtime/model-swap.d.ts +2 -2
  234. package/dist/core/runtime/model-swap.js +1 -1
  235. package/dist/core/runtime/node-read.d.ts +1 -1
  236. package/dist/core/runtime/node-read.js +2 -2
  237. package/dist/core/runtime/nodes.d.ts +6 -6
  238. package/dist/core/runtime/nodes.js +1 -1
  239. package/dist/core/runtime/outcome-document.d.ts +1 -1
  240. package/dist/core/runtime/outcome-document.js +1 -1
  241. package/dist/core/runtime/persona.d.ts +3 -3
  242. package/dist/core/runtime/persona.js +2 -2
  243. package/dist/core/runtime/placement.d.ts +11 -11
  244. package/dist/core/runtime/placement.js +1 -1
  245. package/dist/core/runtime/promote.d.ts +3 -3
  246. package/dist/core/runtime/promote.js +1 -1
  247. package/dist/core/runtime/recycle.js +1 -1
  248. package/dist/core/runtime/reopen.d.ts +5 -5
  249. package/dist/core/runtime/reopen.js +1 -1
  250. package/dist/core/runtime/reset.d.ts +4 -4
  251. package/dist/core/runtime/reset.js +1 -1
  252. package/dist/core/runtime/revive-all.d.ts +2 -2
  253. package/dist/core/runtime/revive-all.js +1 -1
  254. package/dist/core/runtime/revive.d.ts +4 -4
  255. package/dist/core/runtime/revive.js +2 -2
  256. package/dist/core/runtime/roadmap.d.ts +6 -6
  257. package/dist/core/runtime/roadmap.js +5 -5
  258. package/dist/core/runtime/session-branch.d.ts +1 -1
  259. package/dist/core/runtime/session-branch.js +1 -1
  260. package/dist/core/runtime/session-list-cache.js +1 -1
  261. package/dist/core/runtime/situational-live.js +1 -1
  262. package/dist/core/runtime/spawn.d.ts +2 -2
  263. package/dist/core/runtime/spawn.js +2 -2
  264. package/dist/core/runtime/stop-guard.d.ts +2 -2
  265. package/dist/core/runtime/stop-guard.js +3 -3
  266. package/dist/core/runtime/warm-pool.d.ts +2 -2
  267. package/dist/core/runtime/warm-pool.js +1 -1
  268. package/dist/core/spaces/mounts.d.ts +2 -2
  269. package/dist/core/spaces/mounts.js +1 -1
  270. package/dist/core/spaces/permissions.d.ts +1 -1
  271. package/dist/core/spaces/permissions.js +1 -1
  272. package/dist/core/spaces/process.d.ts +1 -1
  273. package/dist/core/spaces/process.js +1 -1
  274. package/dist/core/spaces/space.js +1 -1
  275. package/dist/core/spaces/stop.d.ts +3 -3
  276. package/dist/core/spaces/stop.js +2 -2
  277. package/dist/core/spaces/users.d.ts +6 -6
  278. package/dist/core/spaces/users.js +1 -1
  279. package/dist/core/storage/attachments.d.ts +2 -2
  280. package/dist/core/storage/attachments.js +1 -1
  281. package/dist/core/storage/shares.d.ts +2 -2
  282. package/dist/core/storage/shares.js +1 -1
  283. package/dist/core/storage/tables.d.ts +21 -21
  284. package/dist/core/storage/tables.js +3 -3
  285. package/dist/core/substrate/delivery/corpus.d.ts +5 -8
  286. package/dist/core/substrate/delivery/corpus.js +3 -3
  287. package/dist/core/substrate/delivery/deliver.d.ts +10 -15
  288. package/dist/core/substrate/delivery/deliver.js +3 -3
  289. package/dist/core/substrate/delivery/plan.d.ts +2 -12
  290. package/dist/core/substrate/delivery/plan.js +3 -3
  291. package/dist/core/substrate/delivery/render-boot.d.ts +4 -4
  292. package/dist/core/substrate/delivery/render-boot.js +18 -18
  293. package/dist/core/substrate/delivery/render-event.d.ts +7 -14
  294. package/dist/core/substrate/delivery/render-event.js +4 -4
  295. package/dist/core/substrate/subject.d.ts +2 -2
  296. package/dist/core/substrate/subject.js +1 -1
  297. package/dist/core/usage/ledger.d.ts +6 -6
  298. package/dist/core/usage/ledger.js +4 -4
  299. package/dist/core/worktree-close.js +4 -4
  300. package/dist/core/worktree-mutation-async.js +7 -7
  301. package/dist/core/worktree-quarantine.js +1 -1
  302. package/dist/core/worktree-sweep.d.ts +1 -1
  303. package/dist/core/worktree-sweep.js +6 -6
  304. package/dist/core/worktree.d.ts +5 -5
  305. package/dist/core/worktree.js +13 -13
  306. package/dist/daemon/analytics/compute.d.ts +2 -2
  307. package/dist/daemon/analytics/compute.js +1 -1
  308. package/dist/daemon/api/app-listener.d.ts +4 -4
  309. package/dist/daemon/api/app-listener.js +13 -13
  310. package/dist/daemon/api/bridge.js +5 -5
  311. package/dist/daemon/api/document-listener.js +6 -6
  312. package/dist/daemon/api/handlers/analytics.js +1 -1
  313. package/dist/daemon/api/handlers/attach.js +1 -1
  314. package/dist/daemon/api/handlers/bash-jobs.js +1 -1
  315. package/dist/daemon/api/handlers/bash.js +1 -1
  316. package/dist/daemon/api/handlers/broker-ops.d.ts +1 -1
  317. package/dist/daemon/api/handlers/broker-ops.js +1 -1
  318. package/dist/daemon/api/handlers/broker-recovery.d.ts +1 -1
  319. package/dist/daemon/api/handlers/broker-recovery.js +1 -1
  320. package/dist/daemon/api/handlers/broker-signals.d.ts +2 -2
  321. package/dist/daemon/api/handlers/broker-signals.js +2 -2
  322. package/dist/daemon/api/handlers/canvas.d.ts +1 -1
  323. package/dist/daemon/api/handlers/canvas.js +4 -4
  324. package/dist/daemon/api/handlers/chat-inventory.js +1 -1
  325. package/dist/daemon/api/handlers/crons.js +1 -1
  326. package/dist/daemon/api/handlers/custom-objects.d.ts +4 -4
  327. package/dist/daemon/api/handlers/custom-objects.js +3 -3
  328. package/dist/daemon/api/handlers/delivery-retry.js +1 -1
  329. package/dist/daemon/api/handlers/delivery.js +1 -1
  330. package/dist/daemon/api/handlers/docs.d.ts +4 -4
  331. package/dist/daemon/api/handlers/docs.js +1 -1
  332. package/dist/daemon/api/handlers/feedback-comments.js +3 -3
  333. package/dist/daemon/api/handlers/files.js +1 -1
  334. package/dist/daemon/api/handlers/focus.js +1 -1
  335. package/dist/daemon/api/handlers/health.js +3 -3
  336. package/dist/daemon/api/handlers/hook-exec.js +1 -1
  337. package/dist/daemon/api/handlers/human-requests.js +1 -1
  338. package/dist/daemon/api/handlers/inbox-page.d.ts +1 -1
  339. package/dist/daemon/api/handlers/inbox-page.js +1 -1
  340. package/dist/daemon/api/handlers/inbox.d.ts +1 -1
  341. package/dist/daemon/api/handlers/inbox.js +1 -1
  342. package/dist/daemon/api/handlers/llm.d.ts +1 -1
  343. package/dist/daemon/api/handlers/llm.js +3 -3
  344. package/dist/daemon/api/handlers/memory-reads.js +1 -1
  345. package/dist/daemon/api/handlers/memory.d.ts +5 -5
  346. package/dist/daemon/api/handlers/memory.js +5 -5
  347. package/dist/daemon/api/handlers/messages.js +2 -2
  348. package/dist/daemon/api/handlers/node-events.d.ts +2 -2
  349. package/dist/daemon/api/handlers/node-events.js +3 -3
  350. package/dist/daemon/api/handlers/node-outcomes.js +1 -1
  351. package/dist/daemon/api/handlers/node-records.js +2 -2
  352. package/dist/daemon/api/handlers/nodes.d.ts +1 -1
  353. package/dist/daemon/api/handlers/nodes.js +1 -1
  354. package/dist/daemon/api/handlers/objects.js +3 -3
  355. package/dist/daemon/api/handlers/package-docs.js +1 -1
  356. package/dist/daemon/api/handlers/plugin-app-token.d.ts +1 -1
  357. package/dist/daemon/api/handlers/plugin-app-token.js +1 -1
  358. package/dist/daemon/api/handlers/profiles.d.ts +3 -3
  359. package/dist/daemon/api/handlers/profiles.js +1 -1
  360. package/dist/daemon/api/handlers/providers.d.ts +1 -1
  361. package/dist/daemon/api/handlers/providers.js +1 -1
  362. package/dist/daemon/api/handlers/questions.js +1 -1
  363. package/dist/daemon/api/handlers/reports.d.ts +1 -1
  364. package/dist/daemon/api/handlers/reports.js +5 -5
  365. package/dist/daemon/api/handlers/review-comments.js +1 -1
  366. package/dist/daemon/api/handlers/reviews.js +1 -1
  367. package/dist/daemon/api/handlers/runs.js +1 -1
  368. package/dist/daemon/api/handlers/structured-requests.js +1 -1
  369. package/dist/daemon/api/handlers/subscriptions.js +1 -1
  370. package/dist/daemon/api/handlers/transfer.js +1 -1
  371. package/dist/daemon/api/map.d.ts +3 -3
  372. package/dist/daemon/api/map.js +1 -1
  373. package/dist/daemon/api/principal.d.ts +1 -1
  374. package/dist/daemon/api/principal.js +1 -1
  375. package/dist/daemon/api/reader.d.ts +5 -5
  376. package/dist/daemon/api/reader.js +1 -1
  377. package/dist/daemon/api/router.d.ts +5 -5
  378. package/dist/daemon/api/router.js +1 -1
  379. package/dist/daemon/api/server.js +1 -1
  380. package/dist/daemon/broker-signals/bus.d.ts +1 -1
  381. package/dist/daemon/broker-signals/bus.js +1 -1
  382. package/dist/daemon/companion-retire.js +1 -1
  383. package/dist/daemon/cron/armed-context.d.ts +2 -2
  384. package/dist/daemon/cron/armed-context.js +1 -1
  385. package/dist/daemon/cron/authority.d.ts +2 -2
  386. package/dist/daemon/cron/authority.js +1 -1
  387. package/dist/daemon/cron/disposition.js +1 -1
  388. package/dist/daemon/cron/ended.d.ts +1 -1
  389. package/dist/daemon/cron/ended.js +2 -2
  390. package/dist/daemon/cron/escalation.js +3 -3
  391. package/dist/daemon/cron/folders.d.ts +1 -1
  392. package/dist/daemon/cron/folders.js +1 -1
  393. package/dist/daemon/cron/held.d.ts +1 -1
  394. package/dist/daemon/cron/held.js +1 -1
  395. package/dist/daemon/cron/lease-recovery.d.ts +1 -1
  396. package/dist/daemon/cron/lease-recovery.js +1 -1
  397. package/dist/daemon/cron/passes.d.ts +2 -2
  398. package/dist/daemon/cron/passes.js +1 -1
  399. package/dist/daemon/cron/run-socket.d.ts +1 -1
  400. package/dist/daemon/cron/run-socket.js +1 -1
  401. package/dist/daemon/cron/settle.js +1 -1
  402. package/dist/daemon/cron/sinks.d.ts +1 -1
  403. package/dist/daemon/cron/sinks.js +2 -2
  404. package/dist/daemon/cron-run.d.ts +12 -3
  405. package/dist/daemon/cron-run.js +2 -2
  406. package/dist/daemon/crtrd.js +6 -6
  407. package/dist/daemon/delivery/run-delivery.js +1 -1
  408. package/dist/daemon/due-sources.d.ts +3 -3
  409. package/dist/daemon/due-sources.js +1 -1
  410. package/dist/daemon/due.d.ts +3 -3
  411. package/dist/daemon/due.js +7 -7
  412. package/dist/daemon/fleet.d.ts +2 -2
  413. package/dist/daemon/fleet.js +11 -11
  414. package/dist/daemon/human/finish.js +3 -3
  415. package/dist/daemon/human/settle.d.ts +1 -1
  416. package/dist/daemon/human/settle.js +1 -1
  417. package/dist/daemon/human/sweep.js +1 -1
  418. package/dist/daemon/joined-owner.d.ts +2 -2
  419. package/dist/daemon/joined-owner.js +1 -1
  420. package/dist/daemon/messaging/node-message.js +1 -1
  421. package/dist/daemon/park-activity.d.ts +2 -2
  422. package/dist/daemon/park-activity.js +1 -1
  423. package/dist/daemon/peer/authority.js +1 -1
  424. package/dist/daemon/peer/forward.d.ts +13 -6
  425. package/dist/daemon/peer/forward.js +1 -1
  426. package/dist/daemon/peer/handlers.js +1 -1
  427. package/dist/daemon/peer/ingress.d.ts +4 -4
  428. package/dist/daemon/peer/ingress.js +1 -1
  429. package/dist/daemon/peer/outbox.d.ts +2 -2
  430. package/dist/daemon/peer/outbox.js +1 -1
  431. package/dist/daemon/peer/relay-service.js +1 -1
  432. package/dist/daemon/plugin-objects/read-leaf.d.ts +2 -2
  433. package/dist/daemon/plugin-objects/read-leaf.js +2 -2
  434. package/dist/daemon/profile-delete.js +1 -1
  435. package/dist/daemon/readiness.d.ts +2 -2
  436. package/dist/daemon/readiness.js +1 -1
  437. package/dist/daemon/reconcilers/action-lane.d.ts +1 -1
  438. package/dist/daemon/reconcilers/action-lane.js +1 -1
  439. package/dist/daemon/reconcilers/bash-deadline.js +2 -2
  440. package/dist/daemon/reconcilers/broker-supervision.d.ts +1 -1
  441. package/dist/daemon/reconcilers/broker-supervision.js +4 -4
  442. package/dist/daemon/reconcilers/controller-death.d.ts +1 -1
  443. package/dist/daemon/reconcilers/controller-death.js +1 -1
  444. package/dist/daemon/reconcilers/cron-lane.d.ts +1 -1
  445. package/dist/daemon/reconcilers/cron-lane.js +1 -1
  446. package/dist/daemon/reconcilers/delivery-lane.d.ts +1 -1
  447. package/dist/daemon/reconcilers/delivery-lane.js +2 -2
  448. package/dist/daemon/reconcilers/fault-retry-backstop.d.ts +3 -3
  449. package/dist/daemon/reconcilers/fault-retry-backstop.js +1 -1
  450. package/dist/daemon/reconcilers/grove-instance-sweep.d.ts +2 -2
  451. package/dist/daemon/reconcilers/grove-instance-sweep.js +1 -1
  452. package/dist/daemon/reconcilers/live-obligation.d.ts +6 -6
  453. package/dist/daemon/reconcilers/live-obligation.js +1 -1
  454. package/dist/daemon/reconcilers/managed-worktree-sweep.js +1 -1
  455. package/dist/daemon/reconcilers/node-deadline.d.ts +1 -1
  456. package/dist/daemon/reconcilers/node-deadline.js +1 -1
  457. package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
  458. package/dist/daemon/reconcilers/node-lifecycle/respawn-policy.d.ts +3 -3
  459. package/dist/daemon/reconcilers/node-lifecycle/respawn-policy.js +1 -1
  460. package/dist/daemon/reconcilers/node-lifecycle/terminating.js +1 -1
  461. package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
  462. package/dist/daemon/reconcilers/node-lifecycle/wants-execution.d.ts +1 -1
  463. package/dist/daemon/reconcilers/node-lifecycle/wants-execution.js +1 -1
  464. package/dist/daemon/reconcilers/pending-review-submit.d.ts +1 -1
  465. package/dist/daemon/reconcilers/pending-review-submit.js +1 -1
  466. package/dist/daemon/reconcilers/storage-due-work.js +1 -1
  467. package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -1
  468. package/dist/daemon/reconcilers/storage-maintenance.js +2 -2
  469. package/dist/daemon/reconcilers/structured-request-lane.d.ts +1 -1
  470. package/dist/daemon/reconcilers/structured-request-lane.js +1 -1
  471. package/dist/daemon/review/comment-notify.js +2 -2
  472. package/dist/daemon/review/companion.d.ts +3 -3
  473. package/dist/daemon/review/companion.js +1 -1
  474. package/dist/daemon/review/finish.js +1 -1
  475. package/dist/daemon/review/sweep.js +1 -1
  476. package/dist/daemon/run-notices.d.ts +4 -4
  477. package/dist/daemon/run-notices.js +1 -1
  478. package/dist/daemon/runs/append-section.d.ts +2 -2
  479. package/dist/daemon/runs/append-section.js +2 -2
  480. package/dist/daemon/runs/observer.d.ts +2 -2
  481. package/dist/daemon/runs/observer.js +2 -2
  482. package/dist/daemon/structured-requests/boot.d.ts +1 -1
  483. package/dist/daemon/structured-requests/boot.js +1 -1
  484. package/dist/daemon/structured-requests/effects.js +1 -1
  485. package/dist/daemon/structured-requests/sidecar.d.ts +1 -1
  486. package/dist/daemon/structured-requests/sidecar.js +1 -1
  487. package/dist/migrations/004-canvas-documents/apply.d.ts +3 -3
  488. package/dist/migrations/004-canvas-documents/apply.js +1 -1
  489. package/dist/migrations/004-canvas-documents/index.d.ts +2 -2
  490. package/dist/migrations/004-canvas-documents/index.js +2 -2
  491. package/dist/migrations/activation.js +2 -2
  492. package/docs/public-api.md +11 -0
  493. package/package.json +3 -2
  494. package/packages/crouter-identity/package.json +1 -1
  495. package/runtime.lock.json +12 -12
@@ -1,3 +1,3 @@
1
- var y=Object.defineProperty;var i=(e,o)=>y(e,"name",{value:o,configurable:!0});import{withCanvasWrite as u}from"../canvas/db.js";import{changedWhileDone as $}from"../substrate/delivery/deliver.js";import{queueNodeNotice as L}from"../feed/messages.js";import{clearLedger as f,forkLedger as k,hasLedger as N}from"../graph/exposures.js";import{getById as m,getByRowid as j,nodeObject as c}from"../graph/objects.js";function q(e){u(o=>f(o,c(o,e).rowid))}i(q,"clearNodeLedger");function H(e,o){u(n=>{const r=c(n,e);if(N(n,r.rowid))return;const t=o===null?null:m(n,o);t===null||t.type!=="node"?f(n,r.rowid):k(n,t.rowid,r.rowid)})}i(H,"forkNodeLedger");function d(e){return e===null?"?":e.type==="node"?e.id:e.name}i(d,"ownerHandle");function O(e,o){return u(n=>{const r=$(n,c(n,e),o);if(r.length===0)return!1;const t=r.map(({doc:l,from:g,to:w,authors:a})=>{const h=l.owner===null?null:j(n,l.owner),s=a.length===0?"":`, by ${a.map(p=>d(m(n,p))).join(", ")}`;return`- ${d(h)}/${l.name} \u2014 revision ${g??"none"} \u2192 ${w}${s}`});return L(n,e,{body:`Documents you watch changed while you were done:
2
- ${t.join(`
3
- `)}`,label:"documents changed while you were done",tier:"normal",wake:0}),!0})}i(O,"noticeChangedWhileDone");export{q as clearNodeLedger,H as forkNodeLedger,O as noticeChangedWhileDone};
1
+ var $=Object.defineProperty;var i=(e,a)=>$(e,"name",{value:a,configurable:!0});import{withCanvasWrite as w}from"../canvas/db.js";import{changedWhileDone as L}from"../substrate/delivery/deliver.js";import{queueNodeNotice as k}from"../feed/messages.js";import{clearLedger as u,forkLedger as N,hasLedger as j}from"../graph/exposures.js";import{getById as s,getByRowid as x,nodeObject as c}from"../graph/objects.js";import{mapAsync as y}from"../async-array.js";async function H(e){await w(async a=>await u(a,(await c(a,e)).rowid))}i(H,"clearNodeLedger");async function O(e,a){await w(async n=>{const t=await c(n,e);if(await j(n,t.rowid))return;const o=a===null?null:await s(n,a);o===null||o.type!=="node"?await u(n,t.rowid):await N(n,o.rowid,t.rowid)})}i(O,"forkNodeLedger");function f(e){return e===null?"?":e.type==="node"?e.id:e.name}i(f,"ownerHandle");async function R(e,a){return await w(async n=>{const t=await L(n,await c(n,e),a);if(t.length===0)return!1;const o=await y(t,async({doc:r,from:m,to:d,authors:l})=>{const g=r.owner===null?null:await x(n,r.owner),h=l.length===0?"":`, by ${(await y(l,async p=>f(await s(n,p)))).join(", ")}`;return`- ${f(g)}/${r.name} \u2014 revision ${m??"none"} \u2192 ${d}${h}`});return await k(n,e,{body:`Documents you watch changed while you were done:
2
+ ${o.join(`
3
+ `)}`,label:"documents changed while you were done",tier:"normal",wake:0}),!0})}i(R,"noticeChangedWhileDone");export{H as clearNodeLedger,O as forkNodeLedger,R as noticeChangedWhileDone};
@@ -16,7 +16,7 @@ export interface TerminalOutcomeInput {
16
16
  export declare function transition(nodeId: string, event: LifecycleEvent, opts?: {
17
17
  reason?: TerminalReason;
18
18
  outcome?: TerminalOutcomeInput;
19
- }): NodeMeta;
19
+ }): Promise<NodeMeta>;
20
20
  /** Whether this row is a PARKED node — terminalized by the unattended clock
21
21
  * rather than by finishing its own work. The one read of the park marker:
22
22
  * `done` qualified by `intent='parked'`, both written in the same atomic
@@ -1,2 +1,2 @@
1
- var x=Object.defineProperty;var u=(t,e)=>x(t,"name",{value:e,configurable:!0});import{getNode as S,cancelCronsOnWake as J,transitionStatusIntent as b}from"../canvas/index.js";import{composeNodeOutcomeDocument as A}from"./outcome-document.js";import{withCanvasWrite as E}from"../canvas/db.js";import{nodeObject as D}from"../graph/objects.js";import{endMessageSubscriptions as L}from"../graph/watches.js";import{settleNodeObjectWaits as j}from"../canvas/waits.js";import{runStructuredRequestEffects as P,settlePendingStructuredRequestForNodeIn as $}from"../canvas/structured-requests.js";const m="*",q={finish:"finished",park:"parked",cancel:"stranded",crash:"crashed","refresh-launch":null,revive:null},l=["active","idle"],M={finish:{status:"done",intent:"done",from:l},park:{status:"done",intent:"parked",from:l},cancel:{status:"canceled",intent:null,from:m},crash:{status:"dead",from:l},yield:{intent:"refresh",from:l},release:{status:"idle",intent:"idle-release",from:[...l,"done"]},"refresh-launch":{status:"active",intent:"refresh",from:m},revive:{status:"active",intent:null,from:m}};function T(t,e){const r=t.split(`
2
- `)[0]??"";let n=0,c="";for(const d of r){const s=Buffer.byteLength(d,"utf8");if(n+s>e)break;n+=s,c+=d}return c}u(T,"firstLineAtMost");function W(t){if(t===void 0)return null;const e=t.message===void 0?void 0:T(t.message,500),r={...t,...e===void 0?{}:{message:e}},n=JSON.stringify(r);return Buffer.byteLength(n,"utf8")<=4*1024?n:JSON.stringify({schema:"crtr.node-outcome-detail/v1",truncated:!0,...e===void 0?{}:{message:e}})}u(W,"detailJson");function B(t,e){let r,n;return e==="finished"||e==="declined"?(r="done",n="done"):e==="parked"?(r="done",n="parked"):e==="closed"||e==="retired"||e==="stranded"||e==="deadline_exceeded"?(r="canceled",n=null):(r="dead",n=null),{...t,status:r,intent:n,terminal_reason:e}}u(B,"nodeAtOutcome");function H(t,e,r){const n=M[e],c=Object.prototype.hasOwnProperty.call(n,"status"),d=Object.prototype.hasOwnProperty.call(n,"intent"),s=r?.reason??q[e],f={};c&&(f.status=n.status),d&&(f.intent=n.intent??null),s!==void 0&&(f.terminal_reason=s);const a=e==="finish"||e==="park"||e==="cancel"||e==="crash",o=a?S(t):null,p=a&&o?.kind!=="human",h=s,_=a?new Date().toISOString():null,w=W(r?.outcome?.detail),N=p&&o?.run_id!=null&&s!=="parked"&&o.outcome_at!==null&&(l.includes(o.status)||o.outcome_reason==="parked");let k;p&&o!==null&&(o.outcome_at===null||N)&&(k=JSON.stringify(A({node:B(o,h),outcome:{kind:"failure",reason:h,at:_,revision:(o.outcome_revision??0)+1,detailJson:w}})));const y=a?s==="deadline_exceeded"?{intended:"expired",failureReason:"node_deadline_exceeded",failureDetail:r?.outcome?.detail??null}:{intended:"failed",failureReason:s,failureDetail:r?.outcome?.detail??null}:null,O=E(i=>{const g=b(t,f,{fromStatuses:n.from===m?void 0:n.from,requireNoFinalReport:e==="cancel",...p?{outcome:{kind:"failure",reason:h,detailJson:w,at:_,...N?{supersede:!0}:{},...k===void 0?{}:{documentJson:k}}}:{}});a&&g>0&&(L(i,D(i,t),"done"),j(i,t));const R=g===1&&y!==null?$(i,t,y):null;return{changes:g,settlement:R}});if(O.changes===0){const i=S(t);if(i===null)throw new Error(`transition: unknown node ${t}`);if(e==="cancel"&&i.final_report!==null&&i.final_report!==void 0)return i;throw new Error(`illegal lifecycle transition: '${e}' from status='${i.status}' (node ${t})`)}return O.settlement?.changed&&P(O.settlement.row),(e==="finish"||e==="park"||e==="cancel")&&J(t),S(t)}u(H,"transition");function K(t){return t.status==="done"&&t.intent==="parked"}u(K,"isParked");function Q(t){return t?.intent==="idle-release"}u(Q,"hasIdleReleaseIntent");export{Q as hasIdleReleaseIntent,K as isParked,H as transition};
1
+ var x=Object.defineProperty;var a=(t,e)=>x(t,"name",{value:e,configurable:!0});import{getNode as g,cancelCronsOnWake as J,transitionStatusIntent as b}from"../canvas/index.js";import{composeNodeOutcomeDocument as A}from"./outcome-document.js";import{withCanvasWrite as E}from"../canvas/db.js";import{nodeObject as D}from"../graph/objects.js";import{endMessageSubscriptions as L}from"../graph/watches.js";import{settleNodeObjectWaits as j}from"../canvas/waits.js";import{runStructuredRequestEffects as P,settlePendingStructuredRequestForNodeIn as $}from"../canvas/structured-requests.js";const m="*",q={finish:"finished",park:"parked",cancel:"stranded",crash:"crashed","refresh-launch":null,revive:null},u=["active","idle"],M={finish:{status:"done",intent:"done",from:u},park:{status:"done",intent:"parked",from:u},cancel:{status:"canceled",intent:null,from:m},crash:{status:"dead",from:u},yield:{intent:"refresh",from:u},release:{status:"idle",intent:"idle-release",from:[...u,"done"]},"refresh-launch":{status:"active",intent:"refresh",from:m},revive:{status:"active",intent:null,from:m}};function T(t,e){const r=t.split(`
2
+ `)[0]??"";let n=0,c="";for(const d of r){const s=Buffer.byteLength(d,"utf8");if(n+s>e)break;n+=s,c+=d}return c}a(T,"firstLineAtMost");function W(t){if(t===void 0)return null;const e=t.message===void 0?void 0:T(t.message,500),r={...t,...e===void 0?{}:{message:e}},n=JSON.stringify(r);return Buffer.byteLength(n,"utf8")<=4*1024?n:JSON.stringify({schema:"crtr.node-outcome-detail/v1",truncated:!0,...e===void 0?{}:{message:e}})}a(W,"detailJson");function B(t,e){let r,n;return e==="finished"||e==="declined"?(r="done",n="done"):e==="parked"?(r="done",n="parked"):e==="closed"||e==="retired"||e==="stranded"||e==="deadline_exceeded"?(r="canceled",n=null):(r="dead",n=null),{...t,status:r,intent:n,terminal_reason:e}}a(B,"nodeAtOutcome");async function H(t,e,r){const n=M[e],c=Object.prototype.hasOwnProperty.call(n,"status"),d=Object.prototype.hasOwnProperty.call(n,"intent"),s=r?.reason??q[e],f={};c&&(f.status=n.status),d&&(f.intent=n.intent??null),s!==void 0&&(f.terminal_reason=s);const l=e==="finish"||e==="park"||e==="cancel"||e==="crash",o=l?await g(t):null,p=l&&o?.kind!=="human",h=s,S=l?new Date().toISOString():null,y=W(r?.outcome?.detail),_=p&&o?.run_id!=null&&s!=="parked"&&o.outcome_at!==null&&(u.includes(o.status)||o.outcome_reason==="parked");let w;p&&o!==null&&(o.outcome_at===null||_)&&(w=JSON.stringify(await A({node:B(o,h),outcome:{kind:"failure",reason:h,at:S,revision:(o.outcome_revision??0)+1,detailJson:y}})));const N=l?s==="deadline_exceeded"?{intended:"expired",failureReason:"node_deadline_exceeded",failureDetail:r?.outcome?.detail??null}:{intended:"failed",failureReason:s,failureDetail:r?.outcome?.detail??null}:null,k=await E(async i=>{const O=await b(t,f,{fromStatuses:n.from===m?void 0:n.from,requireNoFinalReport:e==="cancel",...p?{outcome:{kind:"failure",reason:h,detailJson:y,at:S,..._?{supersede:!0}:{},...w===void 0?{}:{documentJson:w}}}:{}});l&&O>0&&(await L(i,await D(i,t),"done"),await j(i,t));const R=O===1&&N!==null?await $(i,t,N):null;return{changes:O,settlement:R}});if(k.changes===0){const i=await g(t);if(i===null)throw new Error(`transition: unknown node ${t}`);if(e==="cancel"&&i.final_report!==null&&i.final_report!==void 0)return i;throw new Error(`illegal lifecycle transition: '${e}' from status='${i.status}' (node ${t})`)}return k.settlement?.changed&&P(k.settlement.row),(e==="finish"||e==="park"||e==="cancel")&&await J(t),await g(t)}a(H,"transition");function K(t){return t.status==="done"&&t.intent==="parked"}a(K,"isParked");function Q(t){return t?.intent==="idle-release"}a(Q,"hasIdleReleaseIntent");export{Q as hasIdleReleaseIntent,K as isParked,H as transition};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var n=(e,r)=>f(e,"name",{value:r,configurable:!0});import{existsSync as p}from"node:fs";import{launcherRequest as u}from"../../launcher/client.js";import{LAUNCHER_SOCKET as _}from"../../launcher/spec.js";import{getNode as v}from"../canvas/index.js";import{emitEvent as y}from"../events/emit.js";import{isSafeNodeId as b}from"../canvas/paths.js";const M=1e3,x=1e4,a="*",l={available:n(()=>process.platform==="linux"&&p(_),"available"),request:n((e,r)=>u({operation:"memory.admit",app:e,nodeId:r}),"request")};let c=l;const s=new Map;function L(e){c=e??l,s.clear()}n(L,"stubMemoryAdmissionForTests");async function N(e,r={}){if(!c.available())return{verdict:"admitted"};const o=v(e)?.grantee??"app:terminal",d=r.now??Date.now();if(r.useMemo!==!1)for(const i of[o,a]){const m=s.get(i);if(m!==void 0&&d-m.at<M)return m.verdict}let t;try{t=await c.request(o,e)}catch(i){return y({level:"warn",event:"broker.memory_admission.failed",...b(e)?{node_id:e}:{},error:i}),{verdict:"admitted"}}if(!("verdict"in t))return{verdict:"admitted"};if(t.verdict==="denied"){const i={verdict:"denied",app:o,level:t.level,free_bytes:t.free_bytes,needed_bytes:t.needed_bytes};return s.set(t.level==="app"?o:a,{at:d,verdict:i}),i}return t.verdict==="too_small"?{verdict:"too_small",app:o,max_bytes:t.max_bytes,needed_bytes:t.needed_bytes}:{verdict:"admitted"}}n(N,"admitBrokerMemory");function k(e,r){return[e,a].some(o=>{const d=s.get(o);return d!==void 0&&r-d.at<x})}n(k,"memoryDeniedRecently");export{M as DENIAL_MEMO_MS,x as MEMORY_PRESSURE_MS,N as admitBrokerMemory,k as memoryDeniedRecently,L as stubMemoryAdmissionForTests};
1
+ var f=Object.defineProperty;var n=(e,r)=>f(e,"name",{value:r,configurable:!0});import{existsSync as p}from"node:fs";import{launcherRequest as u}from"../../launcher/client.js";import{LAUNCHER_SOCKET as _}from"../../launcher/spec.js";import{getNode as v}from"../canvas/index.js";import{emitEvent as y}from"../events/emit.js";import{isSafeNodeId as b}from"../canvas/paths.js";const M=1e3,x=1e4,m="*",l={available:n(()=>process.platform==="linux"&&p(_),"available"),request:n((e,r)=>u({operation:"memory.admit",app:e,nodeId:r}),"request")};let c=l;const a=new Map;function L(e){c=e??l,a.clear()}n(L,"stubMemoryAdmissionForTests");async function N(e,r={}){if(!c.available())return{verdict:"admitted"};const o=(await v(e))?.grantee??"app:terminal",d=r.now??Date.now();if(r.useMemo!==!1)for(const i of[o,m]){const s=a.get(i);if(s!==void 0&&d-s.at<M)return s.verdict}let t;try{t=await c.request(o,e)}catch(i){return y({level:"warn",event:"broker.memory_admission.failed",...b(e)?{node_id:e}:{},error:i}),{verdict:"admitted"}}if(!("verdict"in t))return{verdict:"admitted"};if(t.verdict==="denied"){const i={verdict:"denied",app:o,level:t.level,free_bytes:t.free_bytes,needed_bytes:t.needed_bytes};return a.set(t.level==="app"?o:m,{at:d,verdict:i}),i}return t.verdict==="too_small"?{verdict:"too_small",app:o,max_bytes:t.max_bytes,needed_bytes:t.needed_bytes}:{verdict:"admitted"}}n(N,"admitBrokerMemory");function k(e,r){return[e,m].some(o=>{const d=a.get(o);return d!==void 0&&r-d.at<x})}n(k,"memoryDeniedRecently");export{M as DENIAL_MEMO_MS,x as MEMORY_PRESSURE_MS,N as admitBrokerMemory,k as memoryDeniedRecently,L as stubMemoryAdmissionForTests};
@@ -20,7 +20,7 @@ export declare function setModelLive(nodeId: string, spec: string, intent: Model
20
20
  * `launch.modelExact` (the model runs verbatim). `spec` must already be a
21
21
  * concrete `provider/id` (normalizeModel maps tiers/aliases; a bare substring
22
22
  * cannot resolve offline). */
23
- export declare function updateModelRecipe(meta: NodeMeta, spec: string, intent: ModelIntent | undefined, userSelected: boolean): NodeMeta;
23
+ export declare function updateModelRecipe(meta: NodeMeta, spec: string, intent: ModelIntent | undefined, userSelected: boolean): Promise<NodeMeta>;
24
24
  /** Persist a user's model choice into a DORMANT node's durable recipe — the same
25
25
  * write the broker commits on a live switch. */
26
- export declare function persistDormantModel(nodeId: string, spec: string, intent: ModelIntent | undefined): void;
26
+ export declare function persistDormantModel(nodeId: string, spec: string, intent: ModelIntent | undefined): Promise<void>;
@@ -1 +1 @@
1
- var u=Object.defineProperty;var n=(e,o)=>u(e,"name",{value:o,configurable:!0});import{existsSync as c}from"node:fs";import{getNode as s,updateNode as f}from"../canvas/index.js";import{viewSocketPath as p}from"../canvas/paths.js";import{isPidAlive as _}from"../canvas/pid.js";import{oneShotControllerRequest as a}from"./broker-request.js";function y(e){return _(e.pi_pid)&&c(p(e.node_id))}n(y,"isBrokerLive");function L(e,o,t){let d;return a({nodeId:e,what:"the model switch",ackFor:"set_model",frame:n(()=>({type:"set_model",model:o,...t!==void 0?{intent:t}:{}}),"frame"),observe:n(r=>{r.type==="model_changed"&&r.spec!==null&&(d=r.spec)},"observe"),result:n(()=>d??o,"result")})}n(L,"setModelLive");function v(e,o,t,d){const r=e.launch===void 0?void 0:d?(()=>{const{modelIntent:h,modelExact:E,env:m,...l}=e.launch,{CRTR_MODEL_INTENT:x,...i}=m;return t!==void 0?{...l,model:o,modelIntent:t,env:{...i,CRTR_MODEL_INTENT:`${t.family}/${t.strength}`}}:{...l,model:o,modelExact:!0,env:i}})():{...e.launch,model:o};return f(e.node_id,{model_override:o,...r!==void 0?{launch:r}:{}})}n(v,"updateModelRecipe");function S(e,o,t){const d=s(e);d!==null&&v(d,o,t,!0)}n(S,"persistDormantModel");export{y as isBrokerLive,S as persistDormantModel,L as setModelLive,v as updateModelRecipe};
1
+ var u=Object.defineProperty;var n=(e,o)=>u(e,"name",{value:o,configurable:!0});import{existsSync as c}from"node:fs";import{getNode as a,updateNode as s}from"../canvas/index.js";import{viewSocketPath as f}from"../canvas/paths.js";import{isPidAlive as p}from"../canvas/pid.js";import{oneShotControllerRequest as _}from"./broker-request.js";function M(e){return p(e.pi_pid)&&c(f(e.node_id))}n(M,"isBrokerLive");function g(e,o,t){let d;return _({nodeId:e,what:"the model switch",ackFor:"set_model",frame:n(()=>({type:"set_model",model:o,...t!==void 0?{intent:t}:{}}),"frame"),observe:n(r=>{r.type==="model_changed"&&r.spec!==null&&(d=r.spec)},"observe"),result:n(()=>d??o,"result")})}n(g,"setModelLive");async function v(e,o,t,d){const r=e.launch===void 0?void 0:d?(()=>{const{modelIntent:h,modelExact:E,env:m,...i}=e.launch,{CRTR_MODEL_INTENT:x,...l}=m;return t!==void 0?{...i,model:o,modelIntent:t,env:{...l,CRTR_MODEL_INTENT:`${t.family}/${t.strength}`}}:{...i,model:o,modelExact:!0,env:l}})():{...e.launch,model:o};return await s(e.node_id,{model_override:o,...r!==void 0?{launch:r}:{}})}n(v,"updateModelRecipe");async function L(e,o,t){const d=await a(e);d!==null&&await v(d,o,t,!0)}n(L,"persistDormantModel");export{M as isBrokerLive,L as persistDormantModel,g as setModelLive,v as updateModelRecipe};
@@ -18,7 +18,7 @@ export interface NodeSessionRead {
18
18
  * per boot), so it is read from the sidecar the broker captures on every
19
19
  * rebind (`<jobDir>/system-prompt.md`), falling back to the one `launch.ts`
20
20
  * writes at spawn (`<nodeDir>/system-prompt.md`). */
21
- export declare function readNodeSession(nodeId: string): NodeSessionRead;
21
+ export declare function readNodeSession(nodeId: string): Promise<NodeSessionRead>;
22
22
  export interface NodeSnapshotRead {
23
23
  nodeId: string;
24
24
  snapshot: BrokerSnapshot;
@@ -1,3 +1,3 @@
1
- var C=Object.defineProperty;var a=(e,t)=>C(e,"name",{value:t,configurable:!0});import{existsSync as N,readFileSync as j}from"node:fs";import{isBeneathRefusal as F,readFileBeneath as $,readTextBeneathIfExists as x}from"../spaces/open-beneath.js";import{join as p}from"node:path";import{InputError as f}from"../io.js";import{conversationIdFromPath as y,conversationStore as w,ConversationNotFoundError as A}from"../conversation-store/index.js";import{fullName as T,getNode as g}from"../canvas/index.js";import{nodeRunDir as h,nodeRunJobDir as S,sessionPtrPath as k}from"../canvas/paths.js";import{hydratePersistedAdvertisedCommandMessages as v}from"./advertised-command-invocation.js";import{SessionManager as L}from"./broker-sdk.js";import{openModelRegistry as P}from"./model-registry.js";import{BUILTIN_SLASH_COMMANDS as B}from"./pi-vendored.js";import{cycleAwareMessages as J}from"./session-cycles.js";import{projectTranscript as O}from"./session-visibility.js";import{normalizeToolGroupSummaryRecord as E}from"../../shared/tool-groups.js";import{normalizeTurnReplyRecord as U}from"../../shared/turn-replies.js";async function V(e){if(e!==null)try{return(await P()).find(e.provider,e.modelId)}catch{return}}a(V,"resolveRecordedModel");function b(e,t){const o=a(i=>{const n=i?y(i):null;if(n===null)return null;try{return w().header(n).path}catch(l){if(l instanceof A)return null;throw l}},"resolvePath"),s=o(t);if(s!==null)return s;const r=k(e);return N(r)?o(j(r,"utf8").trim()):null}a(b,"resolveSessionFile");function W(e){const t=g(e);if(t===null)throw new f({error:"not_found",message:`no node: ${e}`,field:"id",next:"List nodes with `crtr node inspect list`."});return b(e,t.pi_session_file)}a(W,"readableSessionFile");function z(e,t){return{sessionFile:t,sessionId:e,userMessages:0,assistantMessages:0,toolCalls:0,toolResults:0,totalMessages:0,tokens:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},cost:0}}a(z,"emptyStats");function D(e,t,o){const s=z(t,o);s.totalMessages=e.length;for(const r of e)if(r.role==="user")s.userMessages++;else if(r.role==="assistant"){s.assistantMessages++;const i=Array.isArray(r.content)?r.content:[];s.toolCalls+=i.filter(l=>l!==null&&typeof l=="object"&&l.type==="toolCall").length;const n=r.usage;n!==void 0&&(s.tokens.input+=n.input??0,s.tokens.output+=n.output??0,s.tokens.cacheRead+=n.cacheRead??0,s.tokens.cacheWrite+=n.cacheWrite??0,s.cost+=n.cost?.total??0)}else r.role==="toolResult"&&s.toolResults++;return s.tokens.total=s.tokens.input+s.tokens.output+s.tokens.cacheRead+s.tokens.cacheWrite,s}a(D,"statsFromMessages");function ge(e){const t=g(e);if(t===null)throw new f({error:"not_found",message:`no node: ${e}`,field:"id",next:"List nodes with `crtr node inspect list`."});const o=b(e,t.pi_session_file);if(o===null)throw new f({error:"no_session",message:`node has no readable session file: ${e}`,field:"id",next:"Choose a node with captured conversation history."});return{nodeId:e,sessionFile:o,sessionJsonl:(()=>{const{header:s,entries:r}=w().read(y(o));return[s,...r].map(i=>`${JSON.stringify(i)}
2
- `).join("")})(),systemPrompt:M(e,p(S(e),"system-prompt.md"))??M(e,p(h(e),"system-prompt.md"))}}a(ge,"readNodeSession");function M(e,t){try{return $(h(e),t).toString("utf8")}catch(o){if(F(o))throw o;return null}}a(M,"readRunFileIfPresent");function G(e){try{const t=x(h(e),p(S(e),"tool-summaries.json"));return E(t===null?null:JSON.parse(t))}catch{return{}}}a(G,"readToolGroupSummaries");function q(e){try{const t=x(h(e),p(S(e),"turn-replies.json"));return U(t===null?null:JSON.parse(t))}catch{return{}}}a(q,"readTurnReplies");async function R(e){const t=g(e);if(t===null)throw new f({error:"not_found",message:`no node: ${e}`,field:"id",next:"List nodes with `crtr node inspect list`."});const o=b(e,t.pi_session_file);if(o===null)throw new f({error:"no_session",message:`node has no readable session file: ${e}`,field:"id",next:"Choose a node with captured conversation history."});const{header:s,entries:r}=w().read(y(o)),i=L.inMemory(s.cwd,void 0,[s,...r]),n=i.buildSessionContext();v(n.messages);const l=J(i);l!==void 0&&v(l.map(({message:c})=>c));const u=l===void 0?void 0:O(l,{boundaryReviewId:t.review_binding?.review_id,sessionEntries:i.getEntries()}),m=u?.map(({message:c})=>c)??n.messages;return{sessionFile:o,messages:m,identified:u,model:n.model,thinkingLevel:n.thinkingLevel,sessionId:i.getSessionId(),sessionName:i.getSessionName()}}a(R,"reconstructTranscript");function d(){throw new f({error:"invalid_cursor",message:"cursor must be a base64url-encoded messages cursor.",field:"cursor",next:"Omit cursor to start from the newest messages."})}a(d,"invalidCursor");function H(e,t){/^[A-Za-z0-9_-]+$/u.test(e)||d();let o;try{const r=Buffer.from(e,"base64url").toString("utf8");Buffer.from(r,"utf8").toString("base64url")!==e&&d(),o=JSON.parse(r)}catch{d()}(typeof o!="object"||o===null||o.v!==1||!Number.isSafeInteger(o.before))&&d();const s=o.before;return(s<0||s>t)&&d(),s}a(H,"decodeMessagesCursor");function Y(e){return Buffer.from(JSON.stringify({v:1,before:e}),"utf8").toString("base64url")}a(Y,"encodeMessagesCursor");async function Z(e){const t=await R(e),o={messages:t.messages,...t.identified===void 0?{}:{messageIds:t.identified.map(({id:s})=>s)},messageVisibility:t.identified?.map(({visibility:s})=>s)??t.messages.map(()=>"visible"),turnVisibility:"visible",stats:D(t.messages,t.sessionId,t.sessionFile),state:{model:await V(t.model),thinkingLevel:t.thinkingLevel,isStreaming:!1,isCompacting:!1,steeringMode:"one-at-a-time",followUpMode:"one-at-a-time",sessionFile:t.sessionFile,sessionId:t.sessionId,sessionName:t.sessionName,autoCompactionEnabled:!0,messageCount:t.messages.length,pendingMessageCount:0},display:{statuses:{},widgets:{},title:void 0},queued:{steering:[],followUp:[]},toolGroupSummaries:G(e),turnReplies:q(e)};return{nodeId:e,snapshot:o,commands:B.map(s=>({...s,source:"builtin"}))}}a(Z,"readNodeSnapshot");async function he(e,{cursor:t,limit:o=200}){if(!Number.isSafeInteger(o)||o<1||o>500)throw new f({error:"invalid_limit",message:"limit must be an integer from 1 through 500.",field:"limit",next:"Use a limit from 1 through 500."});if(W(e)===null)return{messages:[],messageIds:[],messageVisibility:[],nextCursor:null};const{messages:s,identified:r}=await R(e),i=t===void 0?s.length:H(t,s.length);let n=Math.max(0,i-o);for(;n>0&&typeof s[n]=="object"&&s[n]!==null&&s[n].role==="toolResult";)n--;const l=r?.slice(n,i);return{messages:l?.map(({message:u})=>u)??s.slice(n,i),...l===void 0?{}:{messageIds:l.map(({id:u})=>u)},messageVisibility:l?.map(({visibility:u})=>u)??s.slice(n,i).map(()=>"visible"),nextCursor:n===0?null:Y(n)}}a(he,"readNodeMessagesPage");function K(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null).filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(""):""}a(K,"textFromContent");function Q(e){switch(e.role){case"user":return"You";case"assistant":return"Agent";case"toolResult":return"Tool result";default:return typeof e.role=="string"?e.role:"Message"}}a(Q,"roleLabel");function X(e){return Array.isArray(e.content)?e.content.filter(t=>typeof t=="object"&&t!==null&&t.type==="toolCall").map(t=>`Tool: ${typeof t.name=="string"?t.name:"call"}`):[]}a(X,"toolSummaries");async function ye(e){const t=g(e);if(t===null)throw new f({error:"not_found",message:`no node: ${e}`,field:"node-id",next:"List nodes with `crtr node inspect list`."});const{snapshot:o}=await Z(e),r=[`# ${T(t)}`,"",`Saved transcript \xB7 ${t.status} \xB7 ${t.lifecycle}`,""];for(const i of o.messages){if(typeof i!="object"||i===null)continue;const n=i;if(n.role==="custom"&&n.display===!1)continue;const l=K(n.content),u=typeof n.text=="string"?n.text:"",m=l.trim()?l:u.trim()?u:"",c=X(n);if(!(!m&&c.length===0)){r.push(`## ${Q(n)}`,""),m&&r.push(m,"");for(const _ of c)r.push(`- ${_}`);c.length&&r.push("")}}return r.length===5&&r.push("_No saved messages._",""),r.join(`
1
+ var C=Object.defineProperty;var a=(e,t)=>C(e,"name",{value:t,configurable:!0});import{existsSync as N,readFileSync as j}from"node:fs";import{isBeneathRefusal as F,readFileBeneath as $,readTextBeneathIfExists as x}from"../spaces/open-beneath.js";import{join as p}from"node:path";import{InputError as c}from"../io.js";import{conversationIdFromPath as y,conversationStore as w,ConversationNotFoundError as A}from"../conversation-store/index.js";import{fullName as T,getNode as g}from"../canvas/index.js";import{nodeRunDir as h,nodeRunJobDir as S,sessionPtrPath as k}from"../canvas/paths.js";import{hydratePersistedAdvertisedCommandMessages as v}from"./advertised-command-invocation.js";import{SessionManager as L}from"./broker-sdk.js";import{openModelRegistry as P}from"./model-registry.js";import{BUILTIN_SLASH_COMMANDS as B}from"./pi-vendored.js";import{cycleAwareMessages as J}from"./session-cycles.js";import{projectTranscript as O}from"./session-visibility.js";import{normalizeToolGroupSummaryRecord as E}from"../../shared/tool-groups.js";import{normalizeTurnReplyRecord as U}from"../../shared/turn-replies.js";async function V(e){if(e!==null)try{return(await P()).find(e.provider,e.modelId)}catch{return}}a(V,"resolveRecordedModel");async function b(e,t){const o=a(async i=>{const n=i?y(i):null;if(n===null)return null;try{return(await w().header(n)).path}catch(l){if(l instanceof A)return null;throw l}},"resolvePath"),s=await o(t);if(s!==null)return s;const r=k(e);return N(r)?await o(j(r,"utf8").trim()):null}a(b,"resolveSessionFile");async function W(e){const t=await g(e);if(t===null)throw new c({error:"not_found",message:`no node: ${e}`,field:"id",next:"List nodes with `crtr node inspect list`."});return await b(e,t.pi_session_file)}a(W,"readableSessionFile");function z(e,t){return{sessionFile:t,sessionId:e,userMessages:0,assistantMessages:0,toolCalls:0,toolResults:0,totalMessages:0,tokens:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},cost:0}}a(z,"emptyStats");function D(e,t,o){const s=z(t,o);s.totalMessages=e.length;for(const r of e)if(r.role==="user")s.userMessages++;else if(r.role==="assistant"){s.assistantMessages++;const i=Array.isArray(r.content)?r.content:[];s.toolCalls+=i.filter(l=>l!==null&&typeof l=="object"&&l.type==="toolCall").length;const n=r.usage;n!==void 0&&(s.tokens.input+=n.input??0,s.tokens.output+=n.output??0,s.tokens.cacheRead+=n.cacheRead??0,s.tokens.cacheWrite+=n.cacheWrite??0,s.cost+=n.cost?.total??0)}else r.role==="toolResult"&&s.toolResults++;return s.tokens.total=s.tokens.input+s.tokens.output+s.tokens.cacheRead+s.tokens.cacheWrite,s}a(D,"statsFromMessages");async function ge(e){const t=await g(e);if(t===null)throw new c({error:"not_found",message:`no node: ${e}`,field:"id",next:"List nodes with `crtr node inspect list`."});const o=await b(e,t.pi_session_file);if(o===null)throw new c({error:"no_session",message:`node has no readable session file: ${e}`,field:"id",next:"Choose a node with captured conversation history."});return{nodeId:e,sessionFile:o,sessionJsonl:await(async()=>{const{header:s,entries:r}=await w().read(y(o));return[s,...r].map(i=>`${JSON.stringify(i)}
2
+ `).join("")})(),systemPrompt:M(e,p(S(e),"system-prompt.md"))??M(e,p(h(e),"system-prompt.md"))}}a(ge,"readNodeSession");function M(e,t){try{return $(h(e),t).toString("utf8")}catch(o){if(F(o))throw o;return null}}a(M,"readRunFileIfPresent");function G(e){try{const t=x(h(e),p(S(e),"tool-summaries.json"));return E(t===null?null:JSON.parse(t))}catch{return{}}}a(G,"readToolGroupSummaries");function q(e){try{const t=x(h(e),p(S(e),"turn-replies.json"));return U(t===null?null:JSON.parse(t))}catch{return{}}}a(q,"readTurnReplies");async function R(e){const t=await g(e);if(t===null)throw new c({error:"not_found",message:`no node: ${e}`,field:"id",next:"List nodes with `crtr node inspect list`."});const o=await b(e,t.pi_session_file);if(o===null)throw new c({error:"no_session",message:`node has no readable session file: ${e}`,field:"id",next:"Choose a node with captured conversation history."});const{header:s,entries:r}=await w().read(y(o)),i=L.inMemory(s.cwd,void 0,[s,...r]),n=i.buildSessionContext();v(n.messages);const l=J(i);l!==void 0&&v(l.map(({message:f})=>f));const u=l===void 0?void 0:O(l,{boundaryReviewId:t.review_binding?.review_id,sessionEntries:i.getEntries()}),m=u?.map(({message:f})=>f)??n.messages;return{sessionFile:o,messages:m,identified:u,model:n.model,thinkingLevel:n.thinkingLevel,sessionId:i.getSessionId(),sessionName:i.getSessionName()}}a(R,"reconstructTranscript");function d(){throw new c({error:"invalid_cursor",message:"cursor must be a base64url-encoded messages cursor.",field:"cursor",next:"Omit cursor to start from the newest messages."})}a(d,"invalidCursor");function H(e,t){/^[A-Za-z0-9_-]+$/u.test(e)||d();let o;try{const r=Buffer.from(e,"base64url").toString("utf8");Buffer.from(r,"utf8").toString("base64url")!==e&&d(),o=JSON.parse(r)}catch{d()}(typeof o!="object"||o===null||o.v!==1||!Number.isSafeInteger(o.before))&&d();const s=o.before;return(s<0||s>t)&&d(),s}a(H,"decodeMessagesCursor");function Y(e){return Buffer.from(JSON.stringify({v:1,before:e}),"utf8").toString("base64url")}a(Y,"encodeMessagesCursor");async function Z(e){const t=await R(e),o={messages:t.messages,...t.identified===void 0?{}:{messageIds:t.identified.map(({id:s})=>s)},messageVisibility:t.identified?.map(({visibility:s})=>s)??t.messages.map(()=>"visible"),turnVisibility:"visible",stats:D(t.messages,t.sessionId,t.sessionFile),state:{model:await V(t.model),thinkingLevel:t.thinkingLevel,isStreaming:!1,isCompacting:!1,steeringMode:"one-at-a-time",followUpMode:"one-at-a-time",sessionFile:t.sessionFile,sessionId:t.sessionId,sessionName:t.sessionName,autoCompactionEnabled:!0,messageCount:t.messages.length,pendingMessageCount:0},display:{statuses:{},widgets:{},title:void 0},queued:{steering:[],followUp:[]},toolGroupSummaries:G(e),turnReplies:q(e)};return{nodeId:e,snapshot:o,commands:B.map(s=>({...s,source:"builtin"}))}}a(Z,"readNodeSnapshot");async function he(e,{cursor:t,limit:o=200}){if(!Number.isSafeInteger(o)||o<1||o>500)throw new c({error:"invalid_limit",message:"limit must be an integer from 1 through 500.",field:"limit",next:"Use a limit from 1 through 500."});if(await W(e)===null)return{messages:[],messageIds:[],messageVisibility:[],nextCursor:null};const{messages:s,identified:r}=await R(e),i=t===void 0?s.length:H(t,s.length);let n=Math.max(0,i-o);for(;n>0&&typeof s[n]=="object"&&s[n]!==null&&s[n].role==="toolResult";)n--;const l=r?.slice(n,i);return{messages:l?.map(({message:u})=>u)??s.slice(n,i),...l===void 0?{}:{messageIds:l.map(({id:u})=>u)},messageVisibility:l?.map(({visibility:u})=>u)??s.slice(n,i).map(()=>"visible"),nextCursor:n===0?null:Y(n)}}a(he,"readNodeMessagesPage");function K(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null).filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(""):""}a(K,"textFromContent");function Q(e){switch(e.role){case"user":return"You";case"assistant":return"Agent";case"toolResult":return"Tool result";default:return typeof e.role=="string"?e.role:"Message"}}a(Q,"roleLabel");function X(e){return Array.isArray(e.content)?e.content.filter(t=>typeof t=="object"&&t!==null&&t.type==="toolCall").map(t=>`Tool: ${typeof t.name=="string"?t.name:"call"}`):[]}a(X,"toolSummaries");async function ye(e){const t=await g(e);if(t===null)throw new c({error:"not_found",message:`no node: ${e}`,field:"node-id",next:"List nodes with `crtr node inspect list`."});const{snapshot:o}=await Z(e),r=[`# ${T(t)}`,"",`Saved transcript \xB7 ${t.status} \xB7 ${t.lifecycle}`,""];for(const i of o.messages){if(typeof i!="object"||i===null)continue;const n=i;if(n.role==="custom"&&n.display===!1)continue;const l=K(n.content),u=typeof n.text=="string"?n.text:"",m=l.trim()?l:u.trim()?u:"",f=X(n);if(!(!m&&f.length===0)){r.push(`## ${Q(n)}`,""),m&&r.push(m,"");for(const _ of f)r.push(`- ${_}`);f.length&&r.push("")}}return r.length===5&&r.push("_No saved messages._",""),r.join(`
3
3
  `)}a(ye,"transcriptMarkdown");export{he as readNodeMessagesPage,ge as readNodeSession,Z as readNodeSnapshot,ye as transcriptMarkdown};
@@ -1,5 +1,5 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
1
  import { type NodeMeta, type Mode, type Lifecycle, type LaunchSpec, type ManagedWorktree, type OutcomeDeliveryBinding, type ReviewBinding } from '../canvas/index.js';
2
+ import type { CanvasDb } from '../canvas/db.js';
3
3
  /** Explicitly set the resolved install id. crtrd calls this once at boot,
4
4
  * immediately after `resolveInstallId()` — see crtrd.ts — so a provisioning
5
5
  * mismatch fails the daemon loudly at STARTUP rather than lazily on first
@@ -15,7 +15,7 @@ export declare function newJobId(): string;
15
15
  * minted node id is a globally-unique NAME that also names the canvas that
16
16
  * minted it (see the unified-chat/addressing design's "ID scheme"). crtrd is
17
17
  * the sole node minter. */
18
- export declare function newNodeId(): string;
18
+ export declare function newNodeId(): Promise<string>;
19
19
  /** Thrown when a caller-specified `--node-id` (or its API twin `node_id`)
20
20
  * already names a live node. Distinguishable from every other spawn failure
21
21
  * so a caller can treat it as "attach instead of create" per the unified
@@ -32,13 +32,13 @@ export declare class NodeIdConflictError extends Error {
32
32
  * valid); the duplicate check is advisory only — a concurrent create can
33
33
  * still win the race between this check and the synchronous check-then-
34
34
  * create below, which remains the SOLE authoritative decider. */
35
- export declare function preflightNodeId(nodeId: string): void;
35
+ export declare function preflightNodeId(nodeId: string): Promise<void>;
36
36
  /** The root of a node's spine: walk the `parent` column up to `parent == null`.
37
37
  * Cycle-guarded (parents must not cycle, but never loop forever). Lives in the
38
38
  * node layer (not placement) so the env-builder and placement both reach it
39
39
  * without an import cycle — `CRTR_SUBTREE` is emitted as `rootOfSpine(nodeId)`
40
40
  * at every launch site. */
41
- export declare function rootOfSpine(nodeId: string): string;
41
+ export declare function rootOfSpine(nodeId: string): Promise<string>;
42
42
  export interface NodeContext {
43
43
  nodeId: string | null;
44
44
  kind: string | null;
@@ -111,7 +111,7 @@ export interface SpawnNodeOpts {
111
111
  /** Run identity set on an app root; managed children inherit it. */
112
112
  run?: Pick<NodeMeta, 'grantee' | 'sub' | 'grant_id' | 'client_id' | 'metadata_json' | 'run_id' | 'event_cursor' | 'usage_json'>;
113
113
  /** Additional rows committed atomically with the newborn node. */
114
- withinCreate?: (db: DatabaseSync, row: NodeMeta) => void;
114
+ withinCreate?: (db: CanvasDb, row: NodeMeta) => Promise<void> | void;
115
115
  /** Managed worktree already created for this node, if any. */
116
116
  managedWorktree?: ManagedWorktree;
117
117
  /** Absolute wall-clock deadline persisted with the row at birth. */
@@ -129,7 +129,7 @@ export interface SpawnNodeOpts {
129
129
  nodeId?: string;
130
130
  }
131
131
  /** The node that owns the conversation a fork copies, or null when no node does. */
132
- export declare function forkSourceNode(sourceFile: string): NodeMeta | null;
132
+ export declare function forkSourceNode(sourceFile: string): Promise<NodeMeta | null>;
133
133
  /** Create a node on the canvas and wire its spawn-time edges.
134
134
  *
135
135
  * For a child (parent given): the parent auto-subscribes ACTIVE to the child
@@ -1 +1 @@
1
- var J=Object.defineProperty;var a=(e,t)=>J(e,"name",{value:t,configurable:!0});import{envHomeOverride as K,envRuntimeHomeOverride as X,INBOX_BETWEEN_TURNS_ENV as z,SCOPES_FILE_ENV as V,scopeAllowed as C}from"../../shared/env.js";import{isOwnMemoryScope as Y,validateScopes as Q}from"../scopes.js";import{activeGrant as B,terminalGrant as k}from"../grants/mirror.js";import{grantSnapshotMissing as Z}from"../../daemon/readiness.js";import{appendRunEvent as ee}from"../runs/events.js";import{readConfig as S}from"../config.js";import{InputError as T}from"../io.js";import{ApiError as w}from"../../api/errors.js";import{assertGranteeRunsHere as ne}from"./unsandboxed.js";import{randomBytes as re}from"node:crypto";import{existsSync as P}from"node:fs";import{resolve as te,relative as ie,isAbsolute as H,join as oe,sep as le}from"node:path";import{appSpace as ae}from"../layout.js";import{scopesFilePath as se}from"../canvas/paths.js";import{createNode as de,assertRunNotDeleting as ue,conversationOwner as ce,getNode as c,getRow as fe}from"../canvas/index.js";import{ensureAppSpace as pe}from"../spaces/space.js";import{LAUNCHER_SOCKET as L}from"../../launcher/spec.js";import{resolveInstallId as me}from"../canvas/install-id.js";import{isAppRun as _e}from"../canvas/app-run.js";import{canvasDbPath as ge,contextDir as we}from"../canvas/paths.js";import{conversationIdFromPath as he}from"../conversation-store/index.js";import{usage as U}from"../errors.js";import{assertProfileAvailableForBirth as ve}from"../profiles/deletion-reservation.js";import{loadExactProfileManifest as Re}from"../profiles/manifest.js";import{admitNodeCreate as Ee}from"../command-hooks/lifecycle-create.js";import{getById as ye,nodeObject as I,ownerForGrantee as Ce}from"../graph/objects.js";import{recordActedOn as Ie}from"../graph/edges.js";import{recordWatch as Ne,copyWatchesForFork as ke}from"../graph/watches.js";import{publish as Se}from"../graph/events.js";let O;const j=new Map;function pn(e){O=e}a(pn,"setInstallId");function Te(){if(O!==void 0)return O;const e=ge(),t=j.get(e);if(t!==void 0)return t;const o=me();return j.set(e,o),o}a(Te,"installId");function Oe(){return`${Date.now().toString(36)}-${re(4).toString("hex")}`}a(Oe,"newJobId");function xe(){return`${Te()}-${Oe()}`}a(xe,"newNodeId");const x=128,De=/^[a-z0-9-]+$/;class q extends Error{static{a(this,"NodeIdConflictError")}nodeId;constructor(t){super(`node already exists: ${t}`),this.nodeId=t,this.name="NodeIdConflictError"}}function D(e){if(e.length===0||e.length>x)throw U(`invalid --node-id '${e}': must be 1-${x} characters`,{next:`Pass an id-safe string (lowercase letters, digits, hyphens) of at most ${x} characters.`});if(!De.test(e))throw U(`invalid --node-id '${e}': must contain only lowercase letters, digits, and hyphens (e.g. 'remote42', 'my-node-1')`,{next:"Use only lowercase letters, digits, and hyphens."})}a(D,"validateNodeIdFormat");function mn(e){if(D(e),c(e)!==null)throw new q(e)}a(mn,"preflightNodeId");function be(e){if(D(e),c(e)!==null)throw new q(e);return e}a(be,"validatedExplicitNodeId");function _n(e){let t=e;const o=new Set;for(;;){if(o.has(t))return t;o.add(t);const s=fe(t);if(s===null||s.parent==null)return t;t=s.parent}}a(_n,"rootOfSpine");function gn(){const e=process.env;return{nodeId:e.CRTR_NODE_ID??null,kind:e.CRTR_KIND??null,mode:e.CRTR_MODE??null}}a(gn,"currentNodeContext");function Ae(e){return _e(e)}a(Ae,"inboxBetweenTurns");function wn(e){const t={CRTR_NODE_ID:e.node_id,CRTR_KIND:e.kind,CRTR_MODE:e.mode,CRTR_LIFECYCLE:e.lifecycle,CRTR_NODE_CWD:e.cwd,CRTR_CONTEXT_DIR:we(e.node_id,e.grantee),CRTR_CYCLES:(e.cycles??0).toString(),CRTR_PROFILE_ID:e.profile_id??"",PI_CLAUDE_OAUTH_REINJECT_SCOPE:"never"};e.parent&&(t.CRTR_PARENT_NODE_ID=e.parent),e.run_id&&(t.CRTR_RUN_ID=e.run_id),Ae(e)&&(t[z]="1"),e.scopes!==null&&e.scopes!==void 0&&(t[V]=se(e.node_id)),t.CRTR_GRANTEE=e.grantee??"app:terminal";const o=K();o!==void 0&&o!==""&&(t.CRTR_HOME=o);const s=X();s!==void 0&&s!==""&&(t.CRTR_RUNTIME_HOME=s);const f=process.env.CRTR_SUBTREE;return f!==void 0&&f!==""&&(t.CRTR_SUBTREE=f),{...t,...e.launch?.env??{}}}a(wn,"nodeEnv");function Me(e){const t=he(e),o=t===null?null:ce(t);return o===null?null:c(o)}a(Me,"forkSourceNode");async function hn(e){const t=e.nodeId!==void 0?(D(e.nodeId),e.nodeId):xe(),o=e.parent??null,s=o===null,f=e.spawnedBy??o,m=e.creator??null,b=e.mode??"base",N=e.lifecycle??(s?"resident":"terminal"),h=e.run===void 0?k():null,n={node_id:t,name:e.name??e.kind,description:e.description,cycles:0,created:new Date().toISOString(),cwd:e.cwd,host_kind:"broker",profile_id:e.profile_id??null,kind:e.kind,mode:b,lifecycle:N,persona_ack:{kind:e.kind,mode:b,lifecycle:N},status:"active",parent:o,spawned_by:f,creator:m,fork_from:e.forkFrom,fork_source_file:e.forkSourceFile,review_binding:e.reviewBinding,model_override:e.modelOverride??null,scopes:e.scopes??null,isolated:e.isolated===!0,grantee:e.run?.grantee??"app:terminal",sub:e.run?.sub??h?.sub??null,grant_id:e.run?.grant_id??h?.id??null,client_id:e.run?.client_id??null,metadata_json:s?e.run?.metadata_json??null:null,run_id:s?t:e.run?.run_id??null,event_cursor:s?e.run?.event_cursor??1:null,usage_json:s?e.run?.usage_json??JSON.stringify({input_tokens:0,output_tokens:0,cache_read_tokens:0,cache_write_tokens:0,cost_usd:0}):null,passive_default:e.passiveDefault??!1,...e.managedWorktree!==void 0?{managed_worktree:e.managedWorktree}:{},intent:null,deadline_at:e.deadlineAt??null,pi_session_id:null,pi_session_file:null,launch:e.launch},E=e.scopes===void 0?void 0:Q(e.scopes),v=o===null?null:c(o);if(o!==null&&v===null)throw new Error(`cannot spawn under unknown parent node: ${o}`);if(v?.run_id&&c(v.run_id)?.deleting_at)throw new Error("run is deleting");const u=m===null?null:c(m);if(m!==null&&u===null)throw new Error(`cannot spawn from unknown creator node: ${m}`);if(u?.run_id&&c(u.run_id)?.deleting_at)throw new Error("run is deleting");const A=e.forkSourceFile==null?null:Me(e.forkSourceFile),M=e.replaces==null?null:c(e.replaces),_=v??A??M??u??(f===null?null:c(f)),$=[v,u,A,M,f===null?null:c(f)].some(r=>r?.isolated===!0||r?.run_id!=null&&c(r.run_id)?.isolated===!0);if($&&e.isolated===!1)throw new w(403,"isolated_run","isolation cannot be turned off under an isolated run",{param:"isolated"});if(n.isolated=$||e.isolated===!0,_!==null){const r=u??_;if(u&&_.grantee&&u.grantee&&u.grantee!==_.grantee)throw new w(403,"other_app_run","cannot create under another app's node");const i=u&&u!==_?[_,u]:[_],d=[],g=new Set;for(const l of i){l.scopes!==null&&l.scopes!==void 0&&d.push(l.scopes);const p=l.grantee==="app:terminal"?k():l.grant_id?B(l.grant_id):null;if(p){const R=[...p.resolved];g.add(R),d.push(R)}else if(!(l.grantee==="app:terminal"&&!S("user").runtime?.issuer)){const R=[];g.add(R),d.push(R)}}const y=a(l=>Y(l,r.grantee==="user:local"?"app:terminal":r.grantee??"app:terminal"),"ownMemory"),F=a((l,p)=>y(p)&&g.has(l)||C(l,p),"allowed");if(E!==void 0&&!E.every(l=>d.every(p=>F(p,l))))throw new T({error:"unknown_scope",message:"child scopes must be covered by the creating node, its source and their current grants",received:E,field:"scopes",next:"Request only scopes the creating node currently holds."});if(n.scopes=E??(i.every(l=>l.scopes==null)&&i.every(l=>l.grant_id===r.grant_id&&l.sub===r.sub)?null:i.length===1?_.scopes??null:[...new Set(d.flat().filter(l=>d.every(p=>F(p,l))))]),n.scopes?.includes("crtr:act")&&!C(n.scopes,"crtr:llm"))throw new T({error:"invalid_scope",message:"crtr:act requires crtr:llm",received:n.scopes,field:"scopes",next:"Include crtr:llm or omit crtr:act."});n.grantee=r.grantee==="user:local"?"app:terminal":r.grantee,n.sub=r.sub??(n.grantee==="app:terminal"?h?.sub:null)??null,n.grant_id=r.grant_id??(n.grantee==="app:terminal"?h?.id:null)??null,n.client_id=r.client_id,n.run_id=s?t:r.run_id??null}if(ne(n.grantee),e.run===void 0&&n.grantee==="app:terminal"&&S("user").runtime?.issuer&&h===null)throw Z()?new w(503,"runtime_starting","the first grant snapshot from the directory has not committed"):new w(403,"scope_missing","terminal grant is not active");if(n.isolated){if(process.platform!=="linux"||!P(L))throw new w(400,"isolated_unavailable","isolated nodes require the Linux root launcher");if(e.managedWorktree!==void 0)throw new w(400,"invalid_request","isolated nodes cannot use a worktree",{param:"worktree"});const r=oe(ae(n.grantee??"app:terminal").nodes,t),i=ie(r,te(n.cwd));if(!H(n.cwd)||i===".."||i.startsWith(`..${le}`)||H(i))throw new w(400,"invalid_request","isolated node cwd must be inside its own folder",{param:"cwd"})}if(n.profile_id){const r=Re(n.profile_id).manifest.grantee??"app:terminal";if(r!==n.grantee){const i=`crtr:memory:rw:${r}:profile:${n.profile_id}`,d=n.grantee==="app:terminal"?k():n.grant_id?B(n.grant_id):null;if(!(n.grantee==="app:terminal"&&!S("user").runtime?.issuer)&&(!d||d.grantee!==n.grantee||!C(d.resolved,i))||!C(n.scopes,i))throw new T({error:"scope_missing",message:`missing scope ${i}`,received:n.profile_id,field:"profile",next:"Select a profile covered by this run and its current grant."})}}if(ve(n.profile_id??null),!n.grantee)throw new Error("node creation requires an app");const W=await Ee({kind:n.kind,mode:n.mode,cwd:n.cwd,profile:n.profile_id??null,root:s,parentId:o,requestingNodeId:m,lifecycle:N,replaces:e.replaces??null},n.grantee),G=a((r,i)=>{const d=I(r,i.node_id),g=m??o??e.actor??f??null,y=g!==null&&ye(r,g)?.type==="node"?I(r,g):Ce(r,e.run===void 0?"user:local":i.grantee);Ie(r,y,d),o!==null&&e.subscribe!==!1&&Ne(r,I(r,o),d,"spawn"),e.forkSourceNode&&ke(r,I(r,e.forkSourceNode),d),Se(r,{event:"created",object:d,actor:y,attrs:{name:i.name,kind:i.kind,creator:m??null}})},"recordBirth");try{e.nodeId!==void 0&&be(e.nodeId),await e.beforeCreate?.(),(process.platform!=="linux"||P(L))&&await pe(n.grantee??"app:terminal"),de(n,{outcomeDelivery:e.outcomeDelivery,withinCreate:a((r,i)=>{i.run_id&&i.run_id!==i.node_id&&ue(r,i.run_id),s&&e.run===void 0&&ee(r,t,t,"run.started",{scopes:i.scopes??null,payer:"user",usage:JSON.parse(i.usage_json)}),e.withinCreate?.(r,i),G(r,i)},"withinCreate")})}finally{W()}return n}a(hn,"spawnNode");export{q as NodeIdConflictError,gn as currentNodeContext,Me as forkSourceNode,Ae as inboxBetweenTurns,Oe as newJobId,xe as newNodeId,wn as nodeEnv,mn as preflightNodeId,_n as rootOfSpine,pn as setInstallId,hn as spawnNode};
1
+ var K=Object.defineProperty;var l=(e,t)=>K(e,"name",{value:t,configurable:!0});import{envHomeOverride as X,envRuntimeHomeOverride as z,INBOX_BETWEEN_TURNS_ENV as V,SCOPES_FILE_ENV as Y,scopeAllowed as C}from"../../shared/env.js";import{isOwnMemoryScope as Q,validateScopes as Z}from"../scopes.js";import{activeGrant as B,terminalGrant as k}from"../grants/mirror.js";import{grantSnapshotMissing as ee}from"../../daemon/readiness.js";import{appendRunEvent as ne}from"../runs/events.js";import{readConfig as S}from"../config.js";import{InputError as T}from"../io.js";import{ApiError as g}from"../../api/errors.js";import{assertGranteeRunsHere as re}from"./unsandboxed.js";import{randomBytes as te}from"node:crypto";import{existsSync as P}from"node:fs";import{resolve as ie,relative as ae,isAbsolute as H,join as oe,sep as le}from"node:path";import{appSpace as se}from"../layout.js";import{scopesFilePath as de}from"../canvas/paths.js";import{createNode as ce,assertRunNotDeleting as ue,conversationOwner as fe,getNode as u,getRow as pe}from"../canvas/index.js";import{ensureAppSpace as me}from"../spaces/space.js";import{LAUNCHER_SOCKET as L}from"../../launcher/spec.js";import{resolveInstallId as _e}from"../canvas/install-id.js";import{isAppRun as we}from"../canvas/app-run.js";import{canvasDbPath as ge,contextDir as he}from"../canvas/paths.js";import{conversationIdFromPath as ve}from"../conversation-store/index.js";import{usage as U}from"../errors.js";import{assertProfileAvailableForBirth as Re}from"../profiles/deletion-reservation.js";import{loadExactProfileManifest as ye}from"../profiles/manifest.js";import{admitNodeCreate as Ee}from"../command-hooks/lifecycle-create.js";import{getById as Ce,nodeObject as I,ownerForGrantee as Ie}from"../graph/objects.js";import{recordActedOn as Ne}from"../graph/edges.js";import{recordWatch as ke,copyWatchesForFork as Se}from"../graph/watches.js";import{publish as Te}from"../graph/events.js";import{someAsync as Oe}from"../async-array.js";let O;const j=new Map;function _n(e){O=e}l(_n,"setInstallId");async function xe(){if(O!==void 0)return O;const e=ge(),t=j.get(e);if(t!==void 0)return t;const a=await _e();return j.set(e,a),a}l(xe,"installId");function De(){return`${Date.now().toString(36)}-${te(4).toString("hex")}`}l(De,"newJobId");async function be(){return`${await xe()}-${De()}`}l(be,"newNodeId");const x=128,Ae=/^[a-z0-9-]+$/;class q extends Error{static{l(this,"NodeIdConflictError")}nodeId;constructor(t){super(`node already exists: ${t}`),this.nodeId=t,this.name="NodeIdConflictError"}}function D(e){if(e.length===0||e.length>x)throw U(`invalid --node-id '${e}': must be 1-${x} characters`,{next:`Pass an id-safe string (lowercase letters, digits, hyphens) of at most ${x} characters.`});if(!Ae.test(e))throw U(`invalid --node-id '${e}': must contain only lowercase letters, digits, and hyphens (e.g. 'remote42', 'my-node-1')`,{next:"Use only lowercase letters, digits, and hyphens."})}l(D,"validateNodeIdFormat");async function wn(e){if(D(e),await u(e)!==null)throw new q(e)}l(wn,"preflightNodeId");async function Me(e){if(D(e),await u(e)!==null)throw new q(e);return e}l(Me,"validatedExplicitNodeId");async function gn(e){let t=e;const a=new Set;for(;;){if(a.has(t))return t;a.add(t);const s=await pe(t);if(s===null||s.parent==null)return t;t=s.parent}}l(gn,"rootOfSpine");function hn(){const e=process.env;return{nodeId:e.CRTR_NODE_ID??null,kind:e.CRTR_KIND??null,mode:e.CRTR_MODE??null}}l(hn,"currentNodeContext");function $e(e){return we(e)}l($e,"inboxBetweenTurns");function vn(e){const t={CRTR_NODE_ID:e.node_id,CRTR_KIND:e.kind,CRTR_MODE:e.mode,CRTR_LIFECYCLE:e.lifecycle,CRTR_NODE_CWD:e.cwd,CRTR_CONTEXT_DIR:he(e.node_id,e.grantee),CRTR_CYCLES:(e.cycles??0).toString(),CRTR_PROFILE_ID:e.profile_id??"",PI_CLAUDE_OAUTH_REINJECT_SCOPE:"never"};e.parent&&(t.CRTR_PARENT_NODE_ID=e.parent),e.run_id&&(t.CRTR_RUN_ID=e.run_id),$e(e)&&(t[V]="1"),e.scopes!==null&&e.scopes!==void 0&&(t[Y]=de(e.node_id)),t.CRTR_GRANTEE=e.grantee??"app:terminal";const a=X();a!==void 0&&a!==""&&(t.CRTR_HOME=a);const s=z();s!==void 0&&s!==""&&(t.CRTR_RUNTIME_HOME=s);const f=process.env.CRTR_SUBTREE;return f!==void 0&&f!==""&&(t.CRTR_SUBTREE=f),{...t,...e.launch?.env??{}}}l(vn,"nodeEnv");async function Fe(e){const t=ve(e),a=t===null?null:await fe(t);return a===null?null:await u(a)}l(Fe,"forkSourceNode");async function Rn(e){const t=e.nodeId!==void 0?(D(e.nodeId),e.nodeId):await be(),a=e.parent??null,s=a===null,f=e.spawnedBy??a,m=e.creator??null,b=e.mode??"base",N=e.lifecycle??(s?"resident":"terminal"),h=e.run===void 0?await k():null,n={node_id:t,name:e.name??e.kind,description:e.description,cycles:0,created:new Date().toISOString(),cwd:e.cwd,host_kind:"broker",profile_id:e.profile_id??null,kind:e.kind,mode:b,lifecycle:N,persona_ack:{kind:e.kind,mode:b,lifecycle:N},status:"active",parent:a,spawned_by:f,creator:m,fork_from:e.forkFrom,fork_source_file:e.forkSourceFile,review_binding:e.reviewBinding,model_override:e.modelOverride??null,scopes:e.scopes??null,isolated:e.isolated===!0,grantee:e.run?.grantee??"app:terminal",sub:e.run?.sub??h?.sub??null,grant_id:e.run?.grant_id??h?.id??null,client_id:e.run?.client_id??null,metadata_json:s?e.run?.metadata_json??null:null,run_id:s?t:e.run?.run_id??null,event_cursor:s?e.run?.event_cursor??1:null,usage_json:s?e.run?.usage_json??JSON.stringify({input_tokens:0,output_tokens:0,cache_read_tokens:0,cache_write_tokens:0,cost_usd:0}):null,passive_default:e.passiveDefault??!1,...e.managedWorktree!==void 0?{managed_worktree:e.managedWorktree}:{},intent:null,deadline_at:e.deadlineAt??null,pi_session_id:null,pi_session_file:null,launch:e.launch},y=e.scopes===void 0?void 0:Z(e.scopes),v=a===null?null:await u(a);if(a!==null&&v===null)throw new Error(`cannot spawn under unknown parent node: ${a}`);if(v?.run_id&&(await u(v.run_id))?.deleting_at)throw new Error("run is deleting");const c=m===null?null:await u(m);if(m!==null&&c===null)throw new Error(`cannot spawn from unknown creator node: ${m}`);if(c?.run_id&&(await u(c.run_id))?.deleting_at)throw new Error("run is deleting");const A=e.forkSourceFile==null?null:await Fe(e.forkSourceFile),M=e.replaces==null?null:await u(e.replaces),_=v??A??M??c??(f===null?null:await u(f)),W=[v,c,A,M,f===null?null:await u(f)],$=await Oe(W,async r=>r?.isolated===!0||r?.run_id!=null&&(await u(r.run_id))?.isolated===!0);if($&&e.isolated===!1)throw new g(403,"isolated_run","isolation cannot be turned off under an isolated run",{param:"isolated"});if(n.isolated=$||e.isolated===!0,_!==null){const r=c??_;if(c&&_.grantee&&c.grantee&&c.grantee!==_.grantee)throw new g(403,"other_app_run","cannot create under another app's node");const i=c&&c!==_?[_,c]:[_],d=[],w=new Set;for(const o of i){o.scopes!==null&&o.scopes!==void 0&&d.push(o.scopes);const p=o.grantee==="app:terminal"?await k():o.grant_id?await B(o.grant_id):null;if(p){const R=[...p.resolved];w.add(R),d.push(R)}else if(!(o.grantee==="app:terminal"&&!S("user").runtime?.issuer)){const R=[];w.add(R),d.push(R)}}const E=l(o=>Q(o,r.grantee==="user:local"?"app:terminal":r.grantee??"app:terminal"),"ownMemory"),F=l((o,p)=>E(p)&&w.has(o)||C(o,p),"allowed");if(y!==void 0&&!y.every(o=>d.every(p=>F(p,o))))throw new T({error:"unknown_scope",message:"child scopes must be covered by the creating node, its source and their current grants",received:y,field:"scopes",next:"Request only scopes the creating node currently holds."});if(n.scopes=y??(i.every(o=>o.scopes==null)&&i.every(o=>o.grant_id===r.grant_id&&o.sub===r.sub)?null:i.length===1?_.scopes??null:[...new Set(d.flat().filter(o=>d.every(p=>F(p,o))))]),n.scopes?.includes("crtr:act")&&!C(n.scopes,"crtr:llm"))throw new T({error:"invalid_scope",message:"crtr:act requires crtr:llm",received:n.scopes,field:"scopes",next:"Include crtr:llm or omit crtr:act."});n.grantee=r.grantee==="user:local"?"app:terminal":r.grantee,n.sub=r.sub??(n.grantee==="app:terminal"?h?.sub:null)??null,n.grant_id=r.grant_id??(n.grantee==="app:terminal"?h?.id:null)??null,n.client_id=r.client_id,n.run_id=s?t:r.run_id??null}if(re(n.grantee),e.run===void 0&&n.grantee==="app:terminal"&&S("user").runtime?.issuer&&h===null)throw await ee()?new g(503,"runtime_starting","the first grant snapshot from the directory has not committed"):new g(403,"scope_missing","terminal grant is not active");if(n.isolated){if(process.platform!=="linux"||!P(L))throw new g(400,"isolated_unavailable","isolated nodes require the Linux root launcher");if(e.managedWorktree!==void 0)throw new g(400,"invalid_request","isolated nodes cannot use a worktree",{param:"worktree"});const r=oe(se(n.grantee??"app:terminal").nodes,t),i=ae(r,ie(n.cwd));if(!H(n.cwd)||i===".."||i.startsWith(`..${le}`)||H(i))throw new g(400,"invalid_request","isolated node cwd must be inside its own folder",{param:"cwd"})}if(n.profile_id){const r=ye(n.profile_id).manifest.grantee??"app:terminal";if(r!==n.grantee){const i=`crtr:memory:rw:${r}:profile:${n.profile_id}`,d=n.grantee==="app:terminal"?await k():n.grant_id?await B(n.grant_id):null;if(!(n.grantee==="app:terminal"&&!S("user").runtime?.issuer)&&(!d||d.grantee!==n.grantee||!C(d.resolved,i))||!C(n.scopes,i))throw new T({error:"scope_missing",message:`missing scope ${i}`,received:n.profile_id,field:"profile",next:"Select a profile covered by this run and its current grant."})}}if(Re(n.profile_id??null),!n.grantee)throw new Error("node creation requires an app");const G=await Ee({kind:n.kind,mode:n.mode,cwd:n.cwd,profile:n.profile_id??null,root:s,parentId:a,requestingNodeId:m,lifecycle:N,replaces:e.replaces??null},n.grantee),J=l(async(r,i)=>{const d=await I(r,i.node_id),w=m??a??e.actor??f??null,E=w!==null&&(await Ce(r,w))?.type==="node"?await I(r,w):await Ie(r,e.run===void 0?"user:local":i.grantee);await Ne(r,E,d),a!==null&&e.subscribe!==!1&&await ke(r,await I(r,a),d,"spawn"),e.forkSourceNode&&await Se(r,await I(r,e.forkSourceNode),d),await Te(r,{event:"created",object:d,actor:E,attrs:{name:i.name,kind:i.kind,creator:m??null}})},"recordBirth");try{e.nodeId!==void 0&&await Me(e.nodeId),await e.beforeCreate?.(),(process.platform!=="linux"||P(L))&&await me(n.grantee??"app:terminal"),await ce(n,{outcomeDelivery:e.outcomeDelivery,withinCreate:l(async(r,i)=>{i.run_id&&i.run_id!==i.node_id&&await ue(r,i.run_id),s&&e.run===void 0&&await ne(r,t,t,"run.started",{scopes:i.scopes??null,payer:"user",usage:JSON.parse(i.usage_json)}),await e.withinCreate?.(r,i),await J(r,i)},"withinCreate")})}finally{G()}return n}l(Rn,"spawnNode");export{q as NodeIdConflictError,hn as currentNodeContext,Fe as forkSourceNode,$e as inboxBetweenTurns,De as newJobId,be as newNodeId,vn as nodeEnv,wn as preflightNodeId,gn as rootOfSpine,_n as setInstallId,Rn as spawnNode};
@@ -56,4 +56,4 @@ export declare function composeNodeOutcomeDocument(args: {
56
56
  finalReport?: string | null;
57
57
  /** Lets the outcome transaction supply a parsed result without a second read. */
58
58
  structuredResult?: unknown;
59
- }): NodeOutcomeDocumentV1;
59
+ }): Promise<NodeOutcomeDocumentV1>;
@@ -1 +1 @@
1
- var a=Object.defineProperty;var s=(t,e)=>a(t,"name",{value:e,configurable:!0});import{contextDir as f}from"../canvas/node-agent-paths.js";import{readOutputResult as m}from"./structured-output.js";const p=256*1024;function y(t,e){try{return m(t,e)}catch{return}}s(y,"structuredResult");function _(t){if(t===null)return null;try{return JSON.parse(t)}catch{return null}}s(_,"parseDetail");function c(t){if(Buffer.byteLength(t,"utf8")<=1024)return t;const n="\u2026";let r=Buffer.byteLength(n,"utf8"),l="";for(const i of t){const d=Buffer.byteLength(i,"utf8");if(r+d>1024)break;r+=d,l+=i}return`${l}${n}`}s(c,"truncateDescription");function k(t){const{node:e,outcome:n}=t,r=_(n.detailJson),l=t.finalReport??e.final_report??"",i=c(e.name),d=e.description===void 0?void 0:c(e.description),o=n.kind==="result"?t.structuredResult===void 0?y(e.node_id,e.grantee):t.structuredResult:void 0,u={schema:"crtr.node-outcome/v1",outcomeId:`${e.node_id}:${n.revision}`,nodeId:e.node_id,revision:n.revision,kind:n.kind,reason:n.reason,settledAt:n.at,node:{name:i,...d===void 0?{}:{description:d},kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,status:e.status,terminalReason:e.terminal_reason??null,cwd:e.cwd,createdAt:e.created,parent:e.parent??null,spawnedBy:e.spawned_by??null},...n.kind==="result"?{result:{finalReport:{name:`${e.node_id}/${l}`},...o===void 0?{}:{structuredResult:o}}}:{failure:{message:r?.message??null,faultKind:r?.fault_kind??null,errorClass:r?.error_class??null,respawnFailures:r?.respawn_failures??null,deadline:r?.deadline===void 0?null:{deadlineAt:r.deadline.deadline_at,elapsedMs:r.deadline.elapsed_ms},declined:r?.declined??null}}};return Buffer.byteLength(JSON.stringify(u),"utf8")>p&&u.result?.structuredResult!==void 0&&(delete u.result.structuredResult,u.result.structuredResultOmitted=!0,u.result.structuredResultPath=`${f(e.node_id,e.grantee)}/result.json`),u}s(k,"composeNodeOutcomeDocument");export{k as composeNodeOutcomeDocument};
1
+ var c=Object.defineProperty;var s=(t,e)=>c(t,"name",{value:e,configurable:!0});import{contextDir as f}from"../canvas/node-agent-paths.js";import{readOutputResult as m}from"./structured-output.js";const p=256*1024;function y(t,e){try{return m(t,e)}catch{return}}s(y,"structuredResult");function _(t){if(t===null)return null;try{return JSON.parse(t)}catch{return null}}s(_,"parseDetail");function a(t){if(Buffer.byteLength(t,"utf8")<=1024)return t;const n="\u2026";let r=Buffer.byteLength(n,"utf8"),l="";for(const i of t){const d=Buffer.byteLength(i,"utf8");if(r+d>1024)break;r+=d,l+=i}return`${l}${n}`}s(a,"truncateDescription");async function k(t){const{node:e,outcome:n}=t,r=_(n.detailJson),l=t.finalReport??e.final_report??"",i=a(e.name),d=e.description===void 0?void 0:a(e.description),o=n.kind==="result"?t.structuredResult===void 0?y(e.node_id,e.grantee):t.structuredResult:void 0,u={schema:"crtr.node-outcome/v1",outcomeId:`${e.node_id}:${n.revision}`,nodeId:e.node_id,revision:n.revision,kind:n.kind,reason:n.reason,settledAt:n.at,node:{name:i,...d===void 0?{}:{description:d},kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,status:e.status,terminalReason:e.terminal_reason??null,cwd:e.cwd,createdAt:e.created,parent:e.parent??null,spawnedBy:e.spawned_by??null},...n.kind==="result"?{result:{finalReport:{name:`${e.node_id}/${l}`},...o===void 0?{}:{structuredResult:o}}}:{failure:{message:r?.message??null,faultKind:r?.fault_kind??null,errorClass:r?.error_class??null,respawnFailures:r?.respawn_failures??null,deadline:r?.deadline===void 0?null:{deadlineAt:r.deadline.deadline_at,elapsedMs:r.deadline.elapsed_ms},declined:r?.declined??null}}};return Buffer.byteLength(JSON.stringify(u),"utf8")>p&&u.result?.structuredResult!==void 0&&(delete u.result.structuredResult,u.result.structuredResultOmitted=!0,u.result.structuredResultPath=`${await f(e.node_id,e.grantee)}/result.json`),u}s(k,"composeNodeOutcomeDocument");export{k as composeNodeOutcomeDocument};
@@ -12,10 +12,10 @@ export interface PersonaDriftResult {
12
12
  guidance: string;
13
13
  }
14
14
  /** Build only the non-document framing for a fresh-context transition. */
15
- export declare function transitionGuidance(nodeId: string, from: Persona, to: Persona): string;
15
+ export declare function transitionGuidance(nodeId: string, from: Persona, to: Persona): Promise<string>;
16
16
  /** Compare the live persona with the last acknowledged context delivery.
17
17
  * `guidance` contains only fresh-context framing; current snapshots supply its
18
18
  * documents. An absent or pre-kind acknowledgment cannot fabricate drift. */
19
- export declare function personaDrift(nodeId: string): PersonaDriftResult | null;
19
+ export declare function personaDrift(nodeId: string): Promise<PersonaDriftResult | null>;
20
20
  /** Commit the persona state whose context delivery is complete. */
21
- export declare function commitPersonaAck(nodeId: string, to: Persona): void;
21
+ export declare function commitPersonaAck(nodeId: string, to: Persona): Promise<void>;
@@ -1,2 +1,2 @@
1
- var s=Object.defineProperty;var n=(o,e)=>s(o,"name",{value:e,configurable:!0});import{getNode as i,updateNode as d}from"../canvas/index.js";import{readRoadmap as c}from"./roadmap.js";import{orchestratorContextNote as u}from"./bearings.js";function l(o,e){const r=c(o)??"(no roadmap yet)",t=[`You are now a ${e.toUpperCase()} ORCHESTRATOR. Your scarce resource is your own context window.`,"Your job is to manage context and delegate \u2014 not to do the goal yourself."];return t.push("","Your roadmap is your document `roadmap`; it loads at every new session of yours. Author it now with `crtr doc edit roadmap`: state the goal and exit criteria, and set the preview to the goal\u2019s first line, using your orchestration protocol. Current contents:","",r,"",u(),"","What promotion changes is how long your documents matter: you now persist across refresh cycles, so the documents you own (`crtr doc write`) carry what this goal needs between your refreshes, and a lesson that should outlive this node gets another owner (`--owner user|repo|profile`).","","Then delegate each unit with `crtr node new --kind <kind>`. When your context fills, run `crtr node yield` to refresh against this roadmap."),t.join(`
2
- `)}n(l,"orchestrationGuidance");function m(){return"You are HANDS-ON again \u2014 base mode. Do the work yourself in THIS window and finish it here; stop delegating by default. You no longer drive a roadmap, so `crtr node yield` is not your exit. Spawn a child only for a cleanly separable unit, never as your first move."}n(m,"baseModeGuidance");function f(o,e,r){if(e.mode===r.mode)return"";if(r.mode==="base")return m();const t=i(o);return l(o,t?.kind??"general")}n(f,"transitionGuidance");function g(o){const e=i(o);if(e===null)return null;const r={kind:e.kind,mode:e.mode,lifecycle:e.lifecycle},t=e.persona_ack,a=t===void 0?r:{kind:t.kind??e.kind,mode:t.mode,lifecycle:t.lifecycle};return a.kind===r.kind&&a.mode===r.mode&&a.lifecycle===r.lifecycle?null:{from:a,to:r,guidance:f(o,a,r)}}n(g,"personaDrift");function k(o,e){d(o,{persona_ack:e})}n(k,"commitPersonaAck");export{k as commitPersonaAck,g as personaDrift,f as transitionGuidance};
1
+ var s=Object.defineProperty;var r=(o,e)=>s(o,"name",{value:e,configurable:!0});import{getNode as i,updateNode as c}from"../canvas/index.js";import{readRoadmap as d}from"./roadmap.js";import{orchestratorContextNote as u}from"./bearings.js";async function l(o,e){const t=await d(o)??"(no roadmap yet)",n=[`You are now a ${e.toUpperCase()} ORCHESTRATOR. Your scarce resource is your own context window.`,"Your job is to manage context and delegate \u2014 not to do the goal yourself."];return n.push("","Your roadmap is your document `roadmap`; it loads at every new session of yours. Author it now with `crtr doc edit roadmap`: state the goal and exit criteria, and set the preview to the goal\u2019s first line, using your orchestration protocol. Current contents:","",t,"",u(),"","What promotion changes is how long your documents matter: you now persist across refresh cycles, so the documents you own (`crtr doc write`) carry what this goal needs between your refreshes, and a lesson that should outlive this node gets another owner (`--owner user|repo|profile`).","","Then delegate each unit with `crtr node new --kind <kind>`. When your context fills, run `crtr node yield` to refresh against this roadmap."),n.join(`
2
+ `)}r(l,"orchestrationGuidance");function m(){return"You are HANDS-ON again \u2014 base mode. Do the work yourself in THIS window and finish it here; stop delegating by default. You no longer drive a roadmap, so `crtr node yield` is not your exit. Spawn a child only for a cleanly separable unit, never as your first move."}r(m,"baseModeGuidance");async function f(o,e,t){if(e.mode===t.mode)return"";if(t.mode==="base")return m();const n=await i(o);return await l(o,n?.kind??"general")}r(f,"transitionGuidance");async function g(o){const e=await i(o);if(e===null)return null;const t={kind:e.kind,mode:e.mode,lifecycle:e.lifecycle},n=e.persona_ack,a=n===void 0?t:{kind:n.kind??e.kind,mode:n.mode,lifecycle:n.lifecycle};return a.kind===t.kind&&a.mode===t.mode&&a.lifecycle===t.lifecycle?null:{from:a,to:t,guidance:await f(o,a,t)}}r(g,"personaDrift");async function k(o,e){await c(o,{persona_ack:e})}r(k,"commitPersonaAck");export{k as commitPersonaAck,g as personaDrift,f as transitionGuidance};
@@ -5,15 +5,15 @@ export type { RespawnPaneOpts } from './tmux-driver.js';
5
5
  export { installTmuxBindings } from './tmux-bindings.js';
6
6
  export type { TmuxInstalledPair, TmuxInstallDiagnostic, TmuxInstallResult } from './tmux-bindings.js';
7
7
  /** The viewer a node has on screen, or null. UNIQUE(node_id) ⇒ at most one. */
8
- export declare function focusOf(nodeId: string): FocusRow | null;
8
+ export declare function focusOf(nodeId: string): Promise<FocusRow | null>;
9
9
  /** Does this node have a live viewer on screen? */
10
- export declare function isFocused(nodeId: string): boolean;
10
+ export declare function isFocused(nodeId: string): Promise<boolean>;
11
11
  /** The viewer realized by a given pane (`%id`), or null. */
12
- export declare function focusByPane(pane: string): FocusRow | null;
12
+ export declare function focusByPane(pane: string): Promise<FocusRow | null>;
13
13
  /** The set of node ids that currently have a live viewer. */
14
- export declare function focusedNodes(): Set<string>;
14
+ export declare function focusedNodes(): Promise<Set<string>>;
15
15
  /** Every live viewer row (GC'ing any whose pane has gone). */
16
- export declare function listFocuses(): FocusRow[];
16
+ export declare function listFocuses(): Promise<FocusRow[]>;
17
17
  /** A reviver: ensure a node's broker ENGINE is alive (idempotent → reviveNode →
18
18
  * headlessBrokerHost.launch). Injected so placement.ts need not import revive.ts
19
19
  * (which imports placement.ts — a cycle). */
@@ -40,7 +40,7 @@ export interface FocusResult {
40
40
  * `window` is accepted for the call contract (spawn passes it) but not stored —
41
41
  * the focuses table keys on pane + session only. The attach client self-tags the
42
42
  * pane `@crtr_node` on connect, so `nodeInPane` resolves it either way. */
43
- export declare function registerViewerFocus(nodeId: string, pane: string, session: string | null, window: string | null): FocusRow | null;
43
+ export declare function registerViewerFocus(nodeId: string, pane: string, session: string | null, window: string | null): Promise<FocusRow | null>;
44
44
  /** Open a surface-attach viewer for `nodeId` and register its viewer focus row —
45
45
  * the shared opener used by `focus` (a split beside the caller) and by a --root
46
46
  * spawn (a fresh window in the caller's current session). Wraps `ensureSession`
@@ -58,7 +58,7 @@ export declare function openViewerWindow(nodeId: string, session: string, opts?:
58
58
  besidePane?: string;
59
59
  waitForBroker?: boolean;
60
60
  initialWhip?: boolean;
61
- }): FocusRow | null;
61
+ }): Promise<FocusRow | null>;
62
62
  export declare function focus(nodeId: string, opts: {
63
63
  pane?: string;
64
64
  newPane?: boolean;
@@ -70,7 +70,7 @@ export declare function focus(nodeId: string, opts: {
70
70
  * on-screen viewer: kill its pane (the window collapses once its last pane goes)
71
71
  * and drop its registry row. Best-effort tmux; the DB write always lands. No-op
72
72
  * when the node has no viewer. */
73
- export declare function tearDownNode(nodeId: string, keepPane?: string): void;
73
+ export declare function tearDownNode(nodeId: string, keepPane?: string): Promise<void>;
74
74
  /** Detach a node from the foreground (the `node lifecycle demote --detach` / Alt+C → D
75
75
  * half). Every node is a headless broker — the only thing on screen is its
76
76
  * surface-attach viewer pane — so "detach" means STOP FOREGROUNDING it: close the
@@ -78,7 +78,7 @@ export declare function tearDownNode(nodeId: string, keepPane?: string): void;
78
78
  * reconnectable by a later `focus`. `pane` is the authoritative pane the caller
79
79
  * acts on (the Alt+C menu's `#{pane_id}`); falls back to the node's registered
80
80
  * viewer pane. No-op (false) when there is no live viewer pane to close. */
81
- export declare function detachToBackground(nodeId: string, pane?: string): boolean;
81
+ export declare function detachToBackground(nodeId: string, pane?: string): Promise<boolean>;
82
82
  /** Reap `nodeId` IFF it is an empty shell (see {@link isEmptyNode}): tear down its
83
83
  * broker engine, close any viewer, and hard-delete its row (edges cascade) + dir.
84
84
  * The user closing or detaching from a node that never said anything wants it
@@ -86,7 +86,7 @@ export declare function detachToBackground(nodeId: string, pane?: string): boole
86
86
  * its node identity so the worktree remains owned and can later be closed.
87
87
  * Returns true when it reaped. No-op (false) on a node that produced output,
88
88
  * is mid-first-turn, owns an open managed worktree, or no longer exists. */
89
- export declare function reapIfEmpty(nodeId: string, keepPane?: string, teardown?: boolean): boolean;
89
+ export declare function reapIfEmpty(nodeId: string, keepPane?: string, teardown?: boolean): Promise<boolean>;
90
90
  /** Sweep the whole canvas for empty shells and reap them — the bulk cleanup
91
91
  * behind `crtr canvas prune --empty`, for the husks that accumulated before
92
92
  * close/detach learned to reap. Skips: the caller ($CRTR_NODE_ID), dead rows,
@@ -97,4 +97,4 @@ export declare function reapIfEmpty(nodeId: string, keepPane?: string, teardown?
97
97
  * without deleting. Returns the reaped (or, under dryRun, reapable) node ids. */
98
98
  export declare function reapEmptyNodes(opts?: {
99
99
  dryRun?: boolean;
100
- }): string[];
100
+ }): Promise<string[]>;
@@ -1 +1 @@
1
- var V=Object.defineProperty;var t=(e,n)=>V(e,"name",{value:n,configurable:!0});import{envNodeId as $}from"../../shared/env.js";import{getNode as m,fullName as H,deleteNode as R,listNodes as M,openFocusRow as z,closeFocusRow as a,getFocusByNode as T,getFocusByPane as x,getFocusById as D,listFocuses as J}from"../canvas/index.js";import{nodeHasAssistantMessage as Q}from"../canvas/render-source.js";import{headlessBrokerHost as k}from"./host.js";import{publishNotice as U}from"./close.js";import{paneExists as d,paneLocation as h,closePane as P,currentTmux as X,switchClient as j,selectWindow as q,selectLayout as G,selectPane as S,getPaneOption as K,setPaneOption as Y,respawnPaneSync as Z,windowOfPane as I,renameWindow as ee}from"./tmux-driver.js";import{openViewerPane as ne,viewerSplitEnv as W,waitForBrokerViewSocket as oe}from"./placement-tmux.js";import{newJobId as se}from"./nodes.js";import{isPidAlive as y}from"../canvas/pid.js";import{splitWindow as Oe,breakPane as Re,selectLayout as Te,selectPane as ke,focusWindow as Se,selectWindow as We,switchClient as be,openNodeWindow as Ae,ensureSession as Be,paneLocation as Ee,paneExists as Ce,paneRunning as Le,paneCurrentPath as Ve,currentTmux as $e,inTmux as He,paneOfNode as Me,setPaneOption as ze,getPaneOption as De,piCommand as Je,shellQuote as Qe,respawnPaneSync as Ue,closePane as Xe,displayPopup as je,windowOfPane as qe,renameWindow as Ge,paneOfWindow as Ke,windowAlive as Ye,listLivePanes as Ze,listLivePanesAsync as Ie}from"./tmux-driver.js";import{installTmuxBindings as nn}from"./tmux-bindings.js";function g(e){return e===null?null:e.pane!==null&&!d(e.pane)?(a(e.focus_id),null):e}t(g,"liveOrPrune");function p(e){return g(T(e))}t(p,"focusOf");function _e(e){return p(e)!==null}t(_e,"isFocused");function ie(e){return g(x(e))}t(ie,"focusByPane");function xe(){return new Set(te().map(e=>e.node_id))}t(xe,"focusedNodes");function te(){const e=[];for(const n of J())g(n)!==null&&e.push(n);return e}t(te,"listFocuses");function re(){return`f-${se()}`}t(re,"newFocusId");function b(e,n,o,s){const u=x(n);if(u!==null)return u;const r=T(e);if(r!==null)return r;const l=re();return z(l,n,o,e),D(l)}t(b,"registerViewerFocus");function A(e,n,o={}){const s=ne(e,n,o);return s===null?null:b(e,s.pane,s.session,s.window)}t(A,"openViewerWindow");function B(e){const n=h(e)?.window??null;n!==null&&G(n,"even-horizontal"),S(e)}t(B,"surfaceNewPane");async function he(e,n){const o=m(e);if(o===null)return{focused:!1,session:null,inPlace:!1,revived:!1};const s=n.pane??process.env.TMUX_PANE??X()?.pane;if(s===void 0||s==="")return{focused:!1,session:null,inPlace:!1,revived:!1};const u=y(o.pi_pid??null),r=n.revive(e),l=!u;if(!await oe(e,r?.launch?.exited))return{focused:!1,session:null,inPlace:!1,revived:l};const v=h(s)?.session??null,N=v??"";if(n.inPlace===!0){const i=p(e);i!==null&&(i.pane!==null&&i.pane!==s&&d(i.pane)&&P(i.pane),a(i.focus_id));const c=x(s);c!==null&&c.node_id!==e&&a(c.focus_id);try{Y(s,"@crtr_node","")}catch{}const _=I(s),F=c?.node_id,L=F===void 0?W():{...W(),CRTR_ATTACH_ROSTER:F},O=Z({pane:s,cwd:o.cwd,env:L,command:`crtr surface attach to ${e}`});return O&&(_!==null&&ee(_,H(o)),b(e,s,v,_)),{focused:O,session:v,inPlace:!0,revived:l}}if(n.newPane===!0){const i=p(e);i!==null&&(i.pane!==null&&d(i.pane)&&P(i.pane),a(i.focus_id));const c=A(e,N,{cwd:o.cwd,besidePane:s});return c===null?{focused:!1,session:null,inPlace:!1,revived:l}:(c.pane!==null&&B(c.pane),{focused:!0,session:c.session,inPlace:!1,revived:l})}const f=p(e);if(f!==null&&f.pane!==null)if(K(f.pane,"@crtr_node")===e){const i=h(f.pane);if(i!==null)return j(i.session),q(i.session,i.window),S(f.pane),{focused:!0,session:i.session,inPlace:!0,revived:l};a(f.focus_id)}else a(f.focus_id);const w=A(e,N,{cwd:o.cwd,besidePane:s});return w===null?{focused:!1,session:null,inPlace:!1,revived:l}:(w.pane!==null&&B(w.pane),{focused:!0,session:w.session,inPlace:!1,revived:l})}t(he,"focus");function E(e,n){const o=p(e);o!==null&&(o.pane!==null&&o.pane!==n&&d(o.pane)&&P(o.pane),a(o.focus_id))}t(E,"tearDownNode");function ye(e,n){const o=n??p(e)?.pane??null;if(o===null||!d(o))return!1;const s=ie(o);s!==null&&a(s.focus_id);const u=P(o);return le(e),u}t(ye,"detachToBackground");function C(e){const n=m(e);return n===null||n.streaming===!0&&y(n.pi_pid)?!1:!Q(n.pi_session_file)}t(C,"isEmptyNode");function le(e,n,o=!0){return m(e)?.managed_worktree?.state==="open"||!C(e)?!1:(o&&k.teardown(e),E(e,n),R(e).deleted)}t(le,"reapIfEmpty");function ge(e={}){const n=e.dryRun??!1,o=$()??"",s=[];for(const u of M()){const r=u.node_id,l=m(r);r===o||u.status==="dead"||y(u.pi_pid)||l?.managed_worktree?.state==="open"||!C(r)||!n&&(U(r,"notice.close",`Child closed \u2014 ${l?.name??r} (${r}) was closed from the canvas and is no longer running.`,{reason:"child-closed",child:r}),k.teardown(r),E(r),!R(r).deleted)||s.push(r)}return s}t(ge,"reapEmptyNodes");export{Re as breakPane,Xe as closePane,$e as currentTmux,ye as detachToBackground,je as displayPopup,Be as ensureSession,he as focus,ie as focusByPane,p as focusOf,Se as focusWindow,xe as focusedNodes,De as getPaneOption,He as inTmux,nn as installTmuxBindings,_e as isFocused,te as listFocuses,Ze as listLivePanes,Ie as listLivePanesAsync,Ae as openNodeWindow,A as openViewerWindow,Ve as paneCurrentPath,Ce as paneExists,Ee as paneLocation,Me as paneOfNode,Ke as paneOfWindow,Le as paneRunning,Je as piCommand,ge as reapEmptyNodes,le as reapIfEmpty,b as registerViewerFocus,Ge as renameWindow,Ue as respawnPaneSync,Te as selectLayout,ke as selectPane,We as selectWindow,ze as setPaneOption,Qe as shellQuote,Oe as splitWindow,be as switchClient,E as tearDownNode,Ye as windowAlive,qe as windowOfPane};
1
+ var V=Object.defineProperty;var s=(e,n)=>V(e,"name",{value:n,configurable:!0});import{envNodeId as $}from"../../shared/env.js";import{getNode as m,fullName as H,deleteNode as R,listNodes as M,openFocusRow as z,closeFocusRow as u,getFocusByNode as T,getFocusByPane as _,getFocusById as D,listFocuses as J}from"../canvas/index.js";import{nodeHasAssistantMessage as Q}from"../canvas/render-source.js";import{headlessBrokerHost as k}from"./host.js";import{publishNotice as U}from"./close.js";import{paneExists as p,paneLocation as x,closePane as P,currentTmux as X,switchClient as j,selectWindow as q,selectLayout as G,selectPane as S,getPaneOption as K,setPaneOption as Y,respawnPaneSync as Z,windowOfPane as I,renameWindow as ee}from"./tmux-driver.js";import{openViewerPane as ne,viewerSplitEnv as W,waitForBrokerViewSocket as ae}from"./placement-tmux.js";import{newJobId as ie}from"./nodes.js";import{isPidAlive as h}from"../canvas/pid.js";import{splitWindow as Oe,breakPane as Re,selectLayout as Te,selectPane as ke,focusWindow as Se,selectWindow as We,switchClient as be,openNodeWindow as Ae,ensureSession as Be,paneLocation as Ee,paneExists as Ce,paneRunning as Le,paneCurrentPath as Ve,currentTmux as $e,inTmux as He,paneOfNode as Me,setPaneOption as ze,getPaneOption as De,piCommand as Je,shellQuote as Qe,respawnPaneSync as Ue,closePane as Xe,displayPopup as je,windowOfPane as qe,renameWindow as Ge,paneOfWindow as Ke,windowAlive as Ye,listLivePanes as Ze,listLivePanesAsync as Ie}from"./tmux-driver.js";import{installTmuxBindings as nn}from"./tmux-bindings.js";async function g(e){return e===null?null:e.pane!==null&&!p(e.pane)?(await u(e.focus_id),null):e}s(g,"liveOrPrune");async function w(e){return await g(await T(e))}s(w,"focusOf");async function ve(e){return await w(e)!==null}s(ve,"isFocused");async function te(e){return await g(await _(e))}s(te,"focusByPane");async function _e(){return new Set((await se()).map(e=>e.node_id))}s(_e,"focusedNodes");async function se(){const e=[];for(const n of await J())await g(n)!==null&&e.push(n);return e}s(se,"listFocuses");function oe(){return`f-${ie()}`}s(oe,"newFocusId");async function b(e,n,a,i){const c=await _(n);if(c!==null)return c;const o=await T(e);if(o!==null)return o;const r=oe();return await z(r,n,a,e),await D(r)}s(b,"registerViewerFocus");async function A(e,n,a={}){const i=ne(e,n,a);return i===null?null:await b(e,i.pane,i.session,i.window)}s(A,"openViewerWindow");function B(e){const n=x(e)?.window??null;n!==null&&G(n,"even-horizontal"),S(e)}s(B,"surfaceNewPane");async function xe(e,n){const a=await m(e);if(a===null)return{focused:!1,session:null,inPlace:!1,revived:!1};const i=n.pane??process.env.TMUX_PANE??X()?.pane;if(i===void 0||i==="")return{focused:!1,session:null,inPlace:!1,revived:!1};const c=h(a.pi_pid??null),o=n.revive(e),r=!c;if(!await ae(e,o?.launch?.exited))return{focused:!1,session:null,inPlace:!1,revived:r};const y=x(i)?.session??null,N=y??"";if(n.inPlace===!0){const t=await w(e);t!==null&&(t.pane!==null&&t.pane!==i&&p(t.pane)&&P(t.pane),await u(t.focus_id));const l=await _(i);l!==null&&l.node_id!==e&&await u(l.focus_id);try{Y(i,"@crtr_node","")}catch{}const v=I(i),F=l?.node_id,L=F===void 0?W():{...W(),CRTR_ATTACH_ROSTER:F},O=Z({pane:i,cwd:a.cwd,env:L,command:`crtr surface attach to ${e}`});return O&&(v!==null&&ee(v,H(a)),await b(e,i,y,v)),{focused:O,session:y,inPlace:!0,revived:r}}if(n.newPane===!0){const t=await w(e);t!==null&&(t.pane!==null&&p(t.pane)&&P(t.pane),await u(t.focus_id));const l=await A(e,N,{cwd:a.cwd,besidePane:i});return l===null?{focused:!1,session:null,inPlace:!1,revived:r}:(l.pane!==null&&B(l.pane),{focused:!0,session:l.session,inPlace:!1,revived:r})}const f=await w(e);if(f!==null&&f.pane!==null)if(K(f.pane,"@crtr_node")===e){const t=x(f.pane);if(t!==null)return j(t.session),q(t.session,t.window),S(f.pane),{focused:!0,session:t.session,inPlace:!0,revived:r};await u(f.focus_id)}else await u(f.focus_id);const d=await A(e,N,{cwd:a.cwd,besidePane:i});return d===null?{focused:!1,session:null,inPlace:!1,revived:r}:(d.pane!==null&&B(d.pane),{focused:!0,session:d.session,inPlace:!1,revived:r})}s(xe,"focus");async function E(e,n){const a=await w(e);a!==null&&(a.pane!==null&&a.pane!==n&&p(a.pane)&&P(a.pane),await u(a.focus_id))}s(E,"tearDownNode");async function he(e,n){const a=n??(await w(e))?.pane??null;if(a===null||!p(a))return!1;const i=await te(a);i!==null&&await u(i.focus_id);const c=P(a);return await re(e),c}s(he,"detachToBackground");async function C(e){const n=await m(e);return n===null||n.streaming===!0&&h(n.pi_pid)?!1:!await Q(n.pi_session_file)}s(C,"isEmptyNode");async function re(e,n,a=!0){return(await m(e))?.managed_worktree?.state==="open"||!await C(e)?!1:(a&&k.teardown(e),await E(e,n),(await R(e)).deleted)}s(re,"reapIfEmpty");async function ge(e={}){const n=e.dryRun??!1,a=$()??"",i=[];for(const c of await M()){const o=c.node_id,r=await m(o);o===a||c.status==="dead"||h(c.pi_pid)||r?.managed_worktree?.state==="open"||!await C(o)||!n&&(await U(o,"notice.close",`Child closed \u2014 ${r?.name??o} (${o}) was closed from the canvas and is no longer running.`,{reason:"child-closed",child:o}),k.teardown(o),await E(o),!(await R(o)).deleted)||i.push(o)}return i}s(ge,"reapEmptyNodes");export{Re as breakPane,Xe as closePane,$e as currentTmux,he as detachToBackground,je as displayPopup,Be as ensureSession,xe as focus,te as focusByPane,w as focusOf,Se as focusWindow,_e as focusedNodes,De as getPaneOption,He as inTmux,nn as installTmuxBindings,ve as isFocused,se as listFocuses,Ze as listLivePanes,Ie as listLivePanesAsync,Ae as openNodeWindow,A as openViewerWindow,Ve as paneCurrentPath,Ce as paneExists,Ee as paneLocation,Me as paneOfNode,Ke as paneOfWindow,Le as paneRunning,Je as piCommand,ge as reapEmptyNodes,re as reapIfEmpty,b as registerViewerFocus,Ge as renameWindow,Ue as respawnPaneSync,Te as selectLayout,ke as selectPane,We as selectWindow,ze as setPaneOption,Qe as shellQuote,Oe as splitWindow,be as switchClient,E as tearDownNode,Ye as windowAlive,qe as windowOfPane};
@@ -22,7 +22,7 @@ type ReshapeOptions = {
22
22
  profileId?: string | null;
23
23
  };
24
24
  /** Synchronous reshape for CLI callers outside the daemon. */
25
- export declare function reshapeNode(nodeId: string, opts?: ReshapeOptions, beforePersist?: () => void): NodeMeta;
25
+ export declare function reshapeNode(nodeId: string, opts?: ReshapeOptions, beforePersist?: () => void): Promise<NodeMeta>;
26
26
  /** Daemon-safe reshape: network-backed config resolution happens off its event loop. */
27
27
  export declare function reshapeNodeAsync(nodeId: string, opts?: ReshapeOptions, beforePersist?: () => void): Promise<NodeMeta>;
28
28
  /** Promote a node to an orchestrator (mode→orchestrator), optionally
@@ -36,7 +36,7 @@ export declare function promote(nodeId: string, opts?: {
36
36
  kind?: string;
37
37
  resident?: boolean;
38
38
  model?: string;
39
- }): PromoteResult;
39
+ }): Promise<PromoteResult>;
40
40
  /** Daemon-safe promotion variant; preserves the same validation/seed ordering. */
41
41
  export declare function promoteAsync(nodeId: string, opts?: {
42
42
  kind?: string;
@@ -72,5 +72,5 @@ export declare function requestYield(nodeId: string, opts?: {
72
72
  promote?: boolean;
73
73
  }, deps?: {
74
74
  ensure?: () => void;
75
- }): YieldResult;
75
+ }): Promise<YieldResult>;
76
76
  export {};
@@ -1 +1 @@
1
- var g=Object.defineProperty;var l=(n,e)=>g(n,"name",{value:e,configurable:!0});import{getNode as m,updateNode as x}from"../canvas/index.js";import{transition as E}from"./lifecycle.js";import{ensureDaemon as R}from"../../daemon/manage.js";import{buildLaunchSpec as $,buildLaunchSpecAsync as A}from"./launch.js";import{ensureRoadmap as u,hasRoadmap as f,roadmapRef as t}from"./roadmap.js";import{readGoal as c,goalPath as k}from"./kickoff.js";function h(n,e){const d=m(n);if(d===null)throw new Error(`unknown node: ${n}`);const i=e.kind??d.kind,o=e.mode??d.mode,r=e.lifecycle??d.lifecycle,a=e.profileId===void 0?d.profile_id??null:e.profileId;return{node:d,kind:i,mode:o,lifecycle:r,profileId:a,launchOpts:{lifecycle:r,hasManager:d.parent!==null,model:e.model??d.model_override??void 0,modelOverride:e.model!==void 0,modelIntent:e.model===void 0?d.launch?.modelIntent:void 0,modelExact:e.model===void 0?d.launch?.modelExact:void 0,cwd:d.cwd,profileId:a}}}l(h,"reshapeInputs");function w(n,e,d,i,o){o?.();const r=d.node.name===d.node.kind&&d.kind!==d.node.kind;return x(n,{kind:d.kind,mode:d.mode,lifecycle:d.lifecycle,profile_id:d.profileId,launch:i,...r?{name:d.kind}:{},...e.model!==void 0?{model_override:i?.model??e.model}:{}})}l(w,"persistReshape");function s(n,e={},d){const i=h(n,e);return w(n,e,i,$(i.kind,i.mode,i.launchOpts).launch,d)}l(s,"reshapeNode");async function y(n,e={},d){const i=h(n,e),{launch:o}=await A(i.kind,i.mode,i.launchOpts);return w(n,e,i,o,d)}l(y,"reshapeNodeAsync");function N(n,e={}){const d=m(n);if(d===null)throw new Error(`unknown node: ${n}`);let i=!1;return{meta:s(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{},mode:"orchestrator",lifecycle:e.resident===!0?"resident":d.lifecycle},()=>{if(!f(n)){const r=c(n);i=u(n,r!==null&&r.trim()!==""?{goal:r.trim()}:{})}}),roadmapWritten:i,roadmapRef:t(n),goalPath:k(n)}}l(N,"promote");async function O(n,e={}){const d=m(n);if(d===null)throw new Error(`unknown node: ${n}`);let i=!1;return{meta:await y(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{},mode:"orchestrator",lifecycle:e.resident===!0?"resident":d.lifecycle},()=>{if(!f(n)){const r=c(n);i=u(n,r!==null&&r.trim()!==""?{goal:r.trim()}:{})}}),roadmapWritten:i,roadmapRef:t(n),goalPath:k(n)}}l(O,"promoteAsync");async function Y(n,e={},d={}){if(m(n)===null)throw new Error(`unknown node: ${n}`);return e.promote===!0?await O(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}):(e.kind!==void 0||e.model!==void 0)&&await y(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),{..._(n,{},d),promoted:e.promote===!0}}l(Y,"requestYieldAsync");function _(n,e={},d={}){const i=d.ensure??R;if(m(n)===null)throw new Error(`unknown node: ${n}`);const r=e.kind!==void 0||e.model!==void 0;let a=!1;return e.promote===!0?(N(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),a=!0):r&&s(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),i(),E(n,"yield"),{meta:m(n),promoted:a,willRefresh:!0}}l(_,"requestYield");export{N as promote,O as promoteAsync,_ as requestYield,Y as requestYieldAsync,s as reshapeNode,y as reshapeNodeAsync};
1
+ var g=Object.defineProperty;var r=(n,e)=>g(n,"name",{value:e,configurable:!0});import{getNode as o,updateNode as x}from"../canvas/index.js";import{transition as E}from"./lifecycle.js";import{ensureDaemon as R}from"../../daemon/manage.js";import{buildLaunchSpec as $,buildLaunchSpecAsync as A}from"./launch.js";import{ensureRoadmap as m,hasRoadmap as c,roadmapRef as u}from"./roadmap.js";import{readGoal as f,goalPath as w}from"./kickoff.js";async function k(n,e){const i=await o(n);if(i===null)throw new Error(`unknown node: ${n}`);const a=e.kind??i.kind,l=e.mode??i.mode,d=e.lifecycle??i.lifecycle,t=e.profileId===void 0?i.profile_id??null:e.profileId;return{node:i,kind:a,mode:l,lifecycle:d,profileId:t,launchOpts:{lifecycle:d,hasManager:i.parent!==null,model:e.model??i.model_override??void 0,modelOverride:e.model!==void 0,modelIntent:e.model===void 0?i.launch?.modelIntent:void 0,modelExact:e.model===void 0?i.launch?.modelExact:void 0,cwd:i.cwd,profileId:t}}}r(k,"reshapeInputs");async function s(n,e,i,a,l){l?.();const d=i.node.name===i.node.kind&&i.kind!==i.node.kind;return await x(n,{kind:i.kind,mode:i.mode,lifecycle:i.lifecycle,profile_id:i.profileId,launch:a,...d?{name:i.kind}:{},...e.model!==void 0?{model_override:a?.model??e.model}:{}})}r(s,"persistReshape");async function h(n,e={},i){const a=await k(n,e);return await s(n,e,a,$(a.kind,a.mode,a.launchOpts).launch,i)}r(h,"reshapeNode");async function y(n,e={},i){const a=await k(n,e),{launch:l}=await A(a.kind,a.mode,a.launchOpts);return await s(n,e,a,l,i)}r(y,"reshapeNodeAsync");async function N(n,e={}){const i=await o(n);if(i===null)throw new Error(`unknown node: ${n}`);let a=!1;return{meta:await h(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{},mode:"orchestrator",lifecycle:e.resident===!0?"resident":i.lifecycle},async()=>{if(!await c(n)){const d=await f(n);a=await m(n,d!==null&&d.trim()!==""?{goal:d.trim()}:{})}}),roadmapWritten:a,roadmapRef:u(n),goalPath:await w(n)}}r(N,"promote");async function O(n,e={}){const i=await o(n);if(i===null)throw new Error(`unknown node: ${n}`);let a=!1;return{meta:await y(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{},mode:"orchestrator",lifecycle:e.resident===!0?"resident":i.lifecycle},async()=>{if(!await c(n)){const d=await f(n);a=await m(n,d!==null&&d.trim()!==""?{goal:d.trim()}:{})}}),roadmapWritten:a,roadmapRef:u(n),goalPath:await w(n)}}r(O,"promoteAsync");async function Y(n,e={},i={}){if(await o(n)===null)throw new Error(`unknown node: ${n}`);return e.promote===!0?await O(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}):(e.kind!==void 0||e.model!==void 0)&&await y(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),{...await _(n,{},i),promoted:e.promote===!0}}r(Y,"requestYieldAsync");async function _(n,e={},i={}){const a=i.ensure??R;if(await o(n)===null)throw new Error(`unknown node: ${n}`);const d=e.kind!==void 0||e.model!==void 0;let t=!1;return e.promote===!0?(await N(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),t=!0):d&&await h(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),a(),await E(n,"yield"),{meta:await o(n),promoted:t,willRefresh:!0}}r(_,"requestYield");export{N as promote,O as promoteAsync,_ as requestYield,Y as requestYieldAsync,h as reshapeNode,y as reshapeNodeAsync};
@@ -1 +1 @@
1
- var w=Object.defineProperty;var r=(e,t)=>w(e,"name",{value:t,configurable:!0});import{abortExecution as y,beginExecution as _,getNode as s,setPresence as h,setFocusOccupant as v,fullName as R,recordExecutionPid as b,recordLaunch as E}from"../canvas/index.js";import{pushFinal as k}from"../feed/feed.js";import{newestReportBody as g}from"../feed/reports.js";import{spawnNode as x,rootOfSpine as S}from"./nodes.js";import{buildLaunchSpecAsync as T,buildPiArgv as B}from"./launch.js";import{focusOf as N,respawnPaneSync as O,setPaneOption as P}from"./placement.js";import{waitForBrokerViewSocket as C,viewerSplitEnv as D}from"./placement-tmux.js";import{headlessBrokerHost as u}from"./host.js";import{boundFleet as F}from"./fleet.js";import{transition as z}from"./lifecycle.js";import{ensureDaemon as A}from"../../daemon/manage.js";import{invokeBirthLifecycleHooks as L}from"./spawn.js";async function ne(e,t){const n=s(e);if(n===null)return{recycled:!1,finalized:!1,newRoot:null,delivered:[]};const o=t??process.env.TMUX_PANE;if(o===void 0||o==="")return{recycled:!1,finalized:!1,newRoot:null,delivered:[]};const f=N(e);try{A()}catch{}const{launch:m}=await T("general","base",{lifecycle:"resident",hasManager:!1,cwd:n.cwd,profileId:n.profile_id}),p=g(e)||`Closed via recycle \u2014 no final summary was authored by ${n.name}.`;let a=[],d=!1;const i=await x({kind:"general",mode:"base",lifecycle:"resident",cwd:n.cwd,name:"general",parent:null,replaces:e,profile_id:n.profile_id,launch:m,beforeCreate:r(async()=>{try{a=(await k(e,p)).deliveredTo,d=!0}catch{}},"beforeCreate")}),c=s(i.node_id);await L(c);const l=B(c);if(l.env={...l.env,CRTR_SUBTREE:S(i.node_id)},!await U(c,l))return{recycled:!1,finalized:d,newRoot:i.node_id,delivered:a};try{u.teardown(e)}catch{}try{h(e,{pane:null,window:null,tmux_session:null})}catch{}if(f!==null)try{v(f.focus_id,i.node_id)}catch{}return{recycled:M(c,o),finalized:d,newRoot:i.node_id,delivered:a}}r(ne,"recycleNode");async function U(e,t){const n=_(e.node_id,{daemonEpoch:F().epoch()});t.env={...t.env,CRTR_EXECUTION_ID:n};let o;try{if(o=await u.launch(e.node_id,t,{cwd:e.cwd,name:R(e),resuming:!1}),o.pid===null)throw new Error("broker host returned no pid");if(E(e.node_id,new Date().toISOString()),b(n,e.node_id,o.pid)==="shutdown")throw new Error("broker execution was superseded");if(await C(e.node_id,o.exited))return!0}catch{y(n,{reason:"launch_failed"})}try{H(e.node_id)}catch{}try{u.teardown(e.node_id)}catch{}return!1}r(U,"launchRecycledBroker");function H(e){const t=s(e);(t?.status==="active"||t?.status==="idle")&&z(e,"crash")}r(H,"transitionReplacementToDead");function M(e,t){try{P(t,"@crtr_node","")}catch{}return O({pane:t,cwd:e.cwd,env:D(),command:`crtr surface attach to ${e.node_id}`})}r(M,"respawnRecycledViewer");export{ne as recycleNode};
1
+ var p=Object.defineProperty;var n=(e,t)=>p(e,"name",{value:t,configurable:!0});import{abortExecution as y,beginExecution as _,getNode as s,setPresence as h,setFocusOccupant as v,fullName as R,recordExecutionPid as b,recordLaunch as E}from"../canvas/index.js";import{pushFinal as k}from"../feed/feed.js";import{newestReportBody as g}from"../feed/reports.js";import{spawnNode as x,rootOfSpine as S}from"./nodes.js";import{buildLaunchSpecAsync as T,buildPiArgv as B}from"./launch.js";import{focusOf as N,respawnPaneSync as O,setPaneOption as P}from"./placement.js";import{waitForBrokerViewSocket as C,viewerSplitEnv as D}from"./placement-tmux.js";import{headlessBrokerHost as u}from"./host.js";import{boundFleet as F}from"./fleet.js";import{transition as z}from"./lifecycle.js";import{ensureDaemon as A}from"../../daemon/manage.js";import{invokeBirthLifecycleHooks as L}from"./spawn.js";async function ae(e,t){const a=await s(e);if(a===null)return{recycled:!1,finalized:!1,newRoot:null,delivered:[]};const o=t??process.env.TMUX_PANE;if(o===void 0||o==="")return{recycled:!1,finalized:!1,newRoot:null,delivered:[]};const w=await N(e);try{A()}catch{}const{launch:f}=await T("general","base",{lifecycle:"resident",hasManager:!1,cwd:a.cwd,profileId:a.profile_id}),m=await g(e)||`Closed via recycle \u2014 no final summary was authored by ${a.name}.`;let c=[],d=!1;const r=await x({kind:"general",mode:"base",lifecycle:"resident",cwd:a.cwd,name:"general",parent:null,replaces:e,profile_id:a.profile_id,launch:f,beforeCreate:n(async()=>{try{c=(await k(e,m)).deliveredTo,d=!0}catch{}},"beforeCreate")}),i=await s(r.node_id);await L(i);const l=B(i);if(l.env={...l.env,CRTR_SUBTREE:await S(r.node_id)},!await U(i,l))return{recycled:!1,finalized:d,newRoot:r.node_id,delivered:c};try{u.teardown(e)}catch{}try{await h(e,{pane:null,window:null,tmux_session:null})}catch{}if(w!==null)try{await v(w.focus_id,r.node_id)}catch{}return{recycled:M(i,o),finalized:d,newRoot:r.node_id,delivered:c}}n(ae,"recycleNode");async function U(e,t){const a=await _(e.node_id,{daemonEpoch:F().epoch()});t.env={...t.env,CRTR_EXECUTION_ID:a};let o;try{if(o=await u.launch(e.node_id,t,{cwd:e.cwd,name:R(e),resuming:!1}),o.pid===null)throw new Error("broker host returned no pid");if(await E(e.node_id,new Date().toISOString()),await b(a,e.node_id,o.pid)==="shutdown")throw new Error("broker execution was superseded");if(await C(e.node_id,o.exited))return!0}catch{await y(a,{reason:"launch_failed"})}try{await H(e.node_id)}catch{}try{u.teardown(e.node_id)}catch{}return!1}n(U,"launchRecycledBroker");async function H(e){const t=await s(e);(t?.status==="active"||t?.status==="idle")&&await z(e,"crash")}n(H,"transitionReplacementToDead");function M(e,t){try{P(t,"@crtr_node","")}catch{}return O({pane:t,cwd:e.cwd,env:D(),command:`crtr surface attach to ${e.node_id}`})}n(M,"respawnRecycledViewer");export{ae as recycleNode};
@@ -2,14 +2,14 @@
2
2
  * `final_report` fresh — never a caller-supplied snapshot. Throws
3
3
  * `node_finalized` when latched; otherwise a no-op (the common case). No
4
4
  * side effect either way. */
5
- export declare function assertNotFinalized(nodeId: string): void;
5
+ export declare function assertNotFinalized(nodeId: string): Promise<void>;
6
6
  /** Validate a target IS latched (the `--reopen` doorway) and return the exact
7
7
  * `final_report` value observed, so the caller can CAS-clear it later via
8
8
  * `commitReopen` — once every OTHER fallible precondition the requested
9
9
  * operation needs has already passed (e.g. `--fresh`'s recoverable-state
10
10
  * check). Throws `not_finalized` when the target has nothing to clear. Pure
11
11
  * read — never mutates. */
12
- export declare function assertFinalizedForReopen(nodeId: string): string;
12
+ export declare function assertFinalizedForReopen(nodeId: string): Promise<string>;
13
13
  /** Clear `nodeId`'s finalization latch — retract-pointer-only (only
14
14
  * `final_report`/`finalized_at`; the report file and every delivered feed
15
15
  * event are untouched). CAS'd against `expectedFinalReport` (the value the
@@ -19,7 +19,7 @@ export declare function assertFinalizedForReopen(nodeId: string): string;
19
19
  * this throws `reopen_latch_changed` instead of silently clobbering a newer
20
20
  * canonical result. Callers MUST NOT proceed to revive/deliver when this
21
21
  * throws. */
22
- export declare function commitReopen(nodeId: string, expectedFinalReport: string): void;
22
+ export declare function commitReopen(nodeId: string, expectedFinalReport: string): Promise<void>;
23
23
  /** Commit the wider message-delivery reopen: settle the node's lifecycle, then
24
24
  * retract a final latch when one exists. Unlike the revive/fresh gate, an
25
25
  * unlatched node is valid here.
@@ -35,7 +35,7 @@ export declare function commitReopen(nodeId: string, expectedFinalReport: string
35
35
  *
36
36
  * Writing lifecycle first leaves a failed latch CAS with the canonical-final
37
37
  * pointer intact. Both writes finish before either delivery channel begins. */
38
- export declare function commitReopenResident(nodeId: string, expectedFinalReport?: string, callerNodeId?: string | null): string | null;
38
+ export declare function commitReopenResident(nodeId: string, expectedFinalReport?: string, callerNodeId?: string | null): Promise<string | null>;
39
39
  /** Convenience wrapper for a doorway with NO intervening fallible step between
40
40
  * the gate check and the reopen clear (`node lifecycle revive` has nothing
41
41
  * fallible between the gate and `reviveNode`). Validates and, when `reopen`,
@@ -46,4 +46,4 @@ export declare function commitReopenResident(nodeId: string, expectedFinalReport
46
46
  * CAS-clears the latch (side effect) and returns.
47
47
  * - `reopen` true + not latched → throws `not_finalized`.
48
48
  * - `reopen` false + not latched → no-op (the common case). */
49
- export declare function assertReopenGate(nodeId: string, reopen: boolean, callerNodeId?: string | null): void;
49
+ export declare function assertReopenGate(nodeId: string, reopen: boolean, callerNodeId?: string | null): Promise<void>;
@@ -1 +1 @@
1
- var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});import{clearFinalReportIfMatches as c,getFinalReport as f,getNode as u,updateNode as p}from"../canvas/index.js";import{subscribersOf as m}from"../canvas/tree.js";import{InputError as o}from"../io.js";import{transition as h}from"./lifecycle.js";import{noticeChangedWhileDone as d}from"./ledger.js";function s(e){return f(e)}n(s,"currentFinalReport");function w(e,t){throw new o({error:"node_finalized",message:`${e} already submitted its canonical final result (\`crtr canvas read ${e}/${t}\`) \u2014 reviving it now would hand it a mandate it can never finish, since a second \`push final\` always errors against an already-latched node.`,next:`Re-run this exact command with --reopen to clear ${e}'s spent latch and re-task it in place.`})}n(w,"throwNodeFinalized");function g(e){throw new o({error:"not_finalized",message:`${e} is not finalized \u2014 --reopen has nothing to clear.`,next:"Drop --reopen."})}n(g,"throwNotFinalized");function R(e){const t=s(e);t!==null&&w(e,t)}n(R,"assertNotFinalized");function x(e){const t=s(e);return t===null&&g(e),t}n(x,"assertFinalizedForReopen");function F(e,t){if(!c(e,t))throw new o({error:"reopen_latch_changed",message:`${e}'s finalization latch changed since it was last inspected \u2014 a concurrent --reopen (or a fresh push final) already moved it, so clearing it now would risk erasing a newer canonical result.`,next:"Re-run this exact command \u2014 it will re-inspect the current state before acting."})}n(F,"commitReopen");function _(e,t){return e==null?!1:m(t).some(i=>i.node_id===e)}n(_,"isManagerOf");function z(e,t,i){const a=s(e);_(i,e)||p(e,{lifecycle:"resident"});const r=u(e);return r!==null&&(r.status==="done"||r.status==="canceled"||r.status==="dead")&&(r.status==="done"&&r.last_settled_at!=null&&d(e,r.last_settled_at),h(e,"revive")),a!==null&&F(e,t??a),a}n(z,"commitReopenResident");function D(e,t,i){if(t){const a=x(e);z(e,a,i);return}R(e)}n(D,"assertReopenGate");export{x as assertFinalizedForReopen,R as assertNotFinalized,D as assertReopenGate,F as commitReopen,z as commitReopenResident};
1
+ var c=Object.defineProperty;var a=(t,e)=>c(t,"name",{value:e,configurable:!0});import{clearFinalReportIfMatches as l,getFinalReport as f,getNode as u,updateNode as p}from"../canvas/index.js";import{subscribersOf as w}from"../canvas/tree.js";import{InputError as o}from"../io.js";import{transition as m}from"./lifecycle.js";import{noticeChangedWhileDone as h}from"./ledger.js";async function s(t){return await f(t)}a(s,"currentFinalReport");function d(t,e){throw new o({error:"node_finalized",message:`${t} already submitted its canonical final result (\`crtr canvas read ${t}/${e}\`) \u2014 reviving it now would hand it a mandate it can never finish, since a second \`push final\` always errors against an already-latched node.`,next:`Re-run this exact command with --reopen to clear ${t}'s spent latch and re-task it in place.`})}a(d,"throwNodeFinalized");function g(t){throw new o({error:"not_finalized",message:`${t} is not finalized \u2014 --reopen has nothing to clear.`,next:"Drop --reopen."})}a(g,"throwNotFinalized");async function R(t){const e=await s(t);e!==null&&d(t,e)}a(R,"assertNotFinalized");async function y(t){const e=await s(t);return e===null&&g(t),e}a(y,"assertFinalizedForReopen");async function x(t,e){if(!await l(t,e))throw new o({error:"reopen_latch_changed",message:`${t}'s finalization latch changed since it was last inspected \u2014 a concurrent --reopen (or a fresh push final) already moved it, so clearing it now would risk erasing a newer canonical result.`,next:"Re-run this exact command \u2014 it will re-inspect the current state before acting."})}a(x,"commitReopen");async function F(t,e){return t==null?!1:(await w(e)).some(i=>i.node_id===t)}a(F,"isManagerOf");async function _(t,e,i){const r=await s(t);await F(i,t)||await p(t,{lifecycle:"resident"});const n=await u(t);return n!==null&&(n.status==="done"||n.status==="canceled"||n.status==="dead")&&(n.status==="done"&&n.last_settled_at!=null&&await h(t,n.last_settled_at),await m(t,"revive")),r!==null&&await x(t,e??r),r}a(_,"commitReopenResident");async function D(t,e,i){if(e){const r=await y(t);await _(t,r,i);return}await R(t)}a(D,"assertReopenGate");export{y as assertFinalizedForReopen,R as assertNotFinalized,D as assertReopenGate,x as commitReopen,_ as commitReopenResident};