@north-light/crouter 0.3.349 → 0.3.350

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 (629) hide show
  1. package/bin/crtr-launcher +4 -0
  2. package/bin/runtime-generation-manifest.mjs +12 -2
  3. package/dist/api/client.d.ts +50 -7
  4. package/dist/api/client.js +2 -2
  5. package/dist/api/dto/analytics.d.ts +184 -0
  6. package/dist/api/dto/analytics.js +0 -0
  7. package/dist/api/dto/broker-ops.d.ts +43 -1
  8. package/dist/api/dto/config.d.ts +11 -0
  9. package/dist/api/dto/grants.d.ts +14 -0
  10. package/dist/api/dto/grants.js +0 -0
  11. package/dist/api/dto/human-requests.d.ts +14 -0
  12. package/dist/api/dto/memory.d.ts +6 -0
  13. package/dist/api/dto/modelauth.d.ts +35 -0
  14. package/dist/api/dto/node-records.d.ts +35 -0
  15. package/dist/api/dto/node-records.js +0 -0
  16. package/dist/api/dto/nodes.d.ts +5 -0
  17. package/dist/api/dto/profiles.d.ts +38 -3
  18. package/dist/api/dto/worktree.d.ts +11 -0
  19. package/dist/api/errors.d.ts +23 -1
  20. package/dist/api/errors.js +1 -1
  21. package/dist/api/index.d.ts +2 -0
  22. package/dist/api/index.js +1 -1
  23. package/dist/api/node-transport.js +1 -1
  24. package/dist/api/routes.d.ts +22 -0
  25. package/dist/api/routes.js +1 -1
  26. package/dist/build-root.d.ts +6 -1
  27. package/dist/build-root.js +1 -1
  28. package/dist/builtin-memory/crouter-sdk/client.md +34 -0
  29. package/dist/builtin-memory/crouter-sdk/errors.md +2 -0
  30. package/dist/builtin-memory/crouter-sdk/memory.md +2 -2
  31. package/dist/builtin-memory/crouter-sdk/streaming.md +21 -0
  32. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/claude-plugin-commands.ts +8 -4
  33. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +39 -118
  34. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.d.ts +6 -1
  35. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.js +41 -27
  36. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +52 -29
  37. package/dist/cli.js +9 -8
  38. package/dist/clients/attach/chrome/inbox-strip.js +1 -1
  39. package/dist/clients/attach/chrome/roster.js +1 -1
  40. package/dist/clients/attach/config.js +1 -1
  41. package/dist/clients/attach/overlays/auth.js +2 -2
  42. package/dist/clients/attach/overlays/graph.js +1 -1
  43. package/dist/clients/attach/render/tool-calls.js +3 -3
  44. package/dist/clients/attach/session/connection.js +1 -1
  45. package/dist/clients/attach/session/profile-files.js +1 -1
  46. package/dist/clients/attach/viewer.js +1569 -816
  47. package/dist/commands/api-client.js +3 -3
  48. package/dist/commands/broker-permissions.d.ts +2 -0
  49. package/dist/commands/broker-permissions.js +1 -0
  50. package/dist/commands/canvas-analytics/chart.d.ts +52 -0
  51. package/dist/commands/canvas-analytics/chart.js +1 -0
  52. package/dist/commands/canvas-analytics/drilldown.d.ts +34 -0
  53. package/dist/commands/canvas-analytics/drilldown.js +1 -0
  54. package/dist/commands/canvas-analytics/format.d.ts +29 -0
  55. package/dist/commands/canvas-analytics/format.js +1 -0
  56. package/dist/commands/canvas-analytics/graph-detail.d.ts +2 -0
  57. package/dist/commands/canvas-analytics/graph-detail.js +2 -0
  58. package/dist/commands/canvas-analytics/graphs.d.ts +9 -0
  59. package/dist/commands/canvas-analytics/graphs.js +1 -0
  60. package/dist/commands/canvas-analytics/memory.d.ts +2 -0
  61. package/dist/commands/canvas-analytics/memory.js +1 -0
  62. package/dist/commands/canvas-analytics/overview.d.ts +2 -0
  63. package/dist/commands/canvas-analytics/overview.js +1 -0
  64. package/dist/commands/canvas-analytics/shell.d.ts +60 -0
  65. package/dist/commands/canvas-analytics/shell.js +2 -0
  66. package/dist/commands/canvas-analytics/time.d.ts +2 -0
  67. package/dist/commands/canvas-analytics/time.js +1 -0
  68. package/dist/commands/canvas-analytics/usage.d.ts +2 -0
  69. package/dist/commands/canvas-analytics/usage.js +1 -0
  70. package/dist/commands/canvas-analytics/view.d.ts +85 -0
  71. package/dist/commands/canvas-analytics/view.js +1 -0
  72. package/dist/commands/canvas-analytics.d.ts +2 -0
  73. package/dist/commands/canvas-analytics.js +1 -0
  74. package/dist/commands/canvas-prune.js +1 -1
  75. package/dist/commands/canvas.js +1 -1
  76. package/dist/commands/cron.js +5 -5
  77. package/dist/commands/human/components.d.ts +2 -0
  78. package/dist/commands/human/components.js +2 -2
  79. package/dist/commands/human/prompts.js +1 -1
  80. package/dist/commands/human/queue.js +1 -1
  81. package/dist/commands/memory/client.d.ts +11 -0
  82. package/dist/commands/memory/client.js +1 -0
  83. package/dist/commands/memory/delete.js +1 -1
  84. package/dist/commands/memory/edit.js +3 -3
  85. package/dist/commands/memory/find.js +1 -1
  86. package/dist/commands/memory/history.js +4 -4
  87. package/dist/commands/memory/lint.js +1 -1
  88. package/dist/commands/memory/list.d.ts +0 -2
  89. package/dist/commands/memory/list.js +1 -1
  90. package/dist/commands/memory/move.js +1 -1
  91. package/dist/commands/memory/origin.js +1 -1
  92. package/dist/commands/memory/read.d.ts +0 -5
  93. package/dist/commands/memory/read.js +3 -3
  94. package/dist/commands/memory/shared.d.ts +0 -178
  95. package/dist/commands/memory/shared.js +1 -12
  96. package/dist/commands/memory/write.js +5 -5
  97. package/dist/commands/node/bash.js +5 -5
  98. package/dist/commands/node/create.d.ts +0 -17
  99. package/dist/commands/node/create.js +2 -3
  100. package/dist/commands/node/inspect.js +6 -6
  101. package/dist/commands/node/lifecycle.js +2 -2
  102. package/dist/commands/node-context.js +2 -2
  103. package/dist/commands/node-inspect-artifacts.js +6 -6
  104. package/dist/commands/pkg/browse/catalog.js +1 -1
  105. package/dist/commands/pkg/browse/model.d.ts +1 -1
  106. package/dist/commands/pkg/market-manage.js +1 -1
  107. package/dist/commands/pkg/plugin-manage.js +10 -10
  108. package/dist/commands/profile/daemon-profiles.d.ts +13 -0
  109. package/dist/commands/profile/daemon-profiles.js +4 -0
  110. package/dist/commands/profile/delete.js +1 -1
  111. package/dist/commands/profile/env.d.ts +6 -0
  112. package/dist/commands/profile/env.js +2 -2
  113. package/dist/commands/profile/kind.js +1 -2
  114. package/dist/commands/profile/list.js +1 -1
  115. package/dist/commands/profile/meta.js +1 -1
  116. package/dist/commands/profile/new.js +1 -1
  117. package/dist/commands/profile/pause.js +1 -1
  118. package/dist/commands/profile/project.js +1 -1
  119. package/dist/commands/profile/rename.js +1 -1
  120. package/dist/commands/profile/show.js +1 -1
  121. package/dist/commands/profile.js +1 -1
  122. package/dist/commands/push.js +3 -3
  123. package/dist/commands/surface-inspect.js +1 -1
  124. package/dist/commands/sys/branch.js +1 -1
  125. package/dist/commands/sys/config.js +1 -1
  126. package/dist/commands/sys/connect.js +3 -3
  127. package/dist/commands/sys/context/admin/actions.js +1 -1
  128. package/dist/commands/sys/context/admin/model.d.ts +1 -0
  129. package/dist/commands/sys/context/admin/model.js +1 -1
  130. package/dist/commands/sys/context/admin.js +1 -1
  131. package/dist/commands/sys/context/expose.js +2 -1
  132. package/dist/commands/sys/context/prompt-review.js +2 -2
  133. package/dist/commands/sys/context/resolve.js +7 -7
  134. package/dist/commands/sys/context/sysprompt.js +1 -1
  135. package/dist/commands/sys/join.d.ts +1 -0
  136. package/dist/commands/sys/join.js +1 -0
  137. package/dist/commands/sys/migrate.js +1 -1
  138. package/dist/commands/sys/panels/models-panel.js +1 -1
  139. package/dist/commands/sys/panels/profiles-panel.d.ts +0 -1
  140. package/dist/commands/sys/panels/profiles-panel.js +1 -1
  141. package/dist/commands/sys/provider-login.js +6 -6
  142. package/dist/commands/sys/setup-core.d.ts +1 -1
  143. package/dist/commands/sys/setup-core.js +6 -6
  144. package/dist/commands/sys/setup-settings-runner.js +1 -1
  145. package/dist/commands/sys/setup.js +1 -1
  146. package/dist/commands/sys/spaces.d.ts +1 -0
  147. package/dist/commands/sys/spaces.js +2 -0
  148. package/dist/commands/sys/sync-deps.js +2 -2
  149. package/dist/commands/sys/sync-project-guidance.js +4 -4
  150. package/dist/commands/sys/sync-skills.js +2 -2
  151. package/dist/commands/sys/worktrees.d.ts +1 -0
  152. package/dist/commands/sys/worktrees.js +1 -1
  153. package/dist/commands/sys.js +1 -1
  154. package/dist/core/auth-file.js +2 -2
  155. package/dist/core/bash-job-supervisor.d.ts +6 -0
  156. package/dist/core/bash-job-supervisor.js +4 -0
  157. package/dist/core/bash-jobs.d.ts +13 -6
  158. package/dist/core/bash-jobs.js +8 -7
  159. package/dist/core/broker-client/transport-relay.d.ts +6 -3
  160. package/dist/core/broker-client/transport-relay.js +1 -1
  161. package/dist/core/broker-client/transport-socket.d.ts +6 -1
  162. package/dist/core/broker-client/transport-socket.js +1 -1
  163. package/dist/core/canvas/canvas.d.ts +39 -18
  164. package/dist/core/canvas/canvas.js +21 -20
  165. package/dist/core/canvas/context-strip.d.ts +20 -0
  166. package/dist/core/canvas/context-strip.js +5 -0
  167. package/dist/core/canvas/crons.d.ts +12 -20
  168. package/dist/core/canvas/crons.js +15 -13
  169. package/dist/core/canvas/db.js +2 -2
  170. package/dist/core/canvas/deliveries.d.ts +4 -1
  171. package/dist/core/canvas/deliveries.js +1 -1
  172. package/dist/core/canvas/executions.js +1 -1
  173. package/dist/core/canvas/history.d.ts +2 -1
  174. package/dist/core/canvas/history.js +17 -18
  175. package/dist/core/canvas/memory-reads.d.ts +19 -0
  176. package/dist/core/canvas/memory-reads.js +1 -0
  177. package/dist/core/canvas/migrations.d.ts +0 -4
  178. package/dist/core/canvas/migrations.js +99 -32
  179. package/dist/core/canvas/nav-render.js +1 -1
  180. package/dist/core/canvas/node-agent-paths.d.ts +8 -0
  181. package/dist/core/canvas/node-agent-paths.js +1 -0
  182. package/dist/core/canvas/node-recap.d.ts +2 -2
  183. package/dist/core/canvas/node-recap.js +2 -2
  184. package/dist/core/canvas/node-tokens.d.ts +24 -0
  185. package/dist/core/canvas/node-tokens.js +5 -0
  186. package/dist/core/canvas/paths.d.ts +16 -19
  187. package/dist/core/canvas/paths.js +1 -1
  188. package/dist/core/canvas/render-source.d.ts +2 -2
  189. package/dist/core/canvas/render-source.js +6 -9
  190. package/dist/core/canvas/sessions.d.ts +18 -0
  191. package/dist/core/canvas/sessions.js +4 -1
  192. package/dist/core/canvas/types.d.ts +22 -6
  193. package/dist/core/command-hooks/compose.js +1 -1
  194. package/dist/core/command-hooks/discovery.d.ts +15 -1
  195. package/dist/core/command-hooks/discovery.js +1 -1
  196. package/dist/core/command-hooks/help.d.ts +2 -2
  197. package/dist/core/command-hooks/lifecycle-create.d.ts +1 -1
  198. package/dist/core/command-hooks/lifecycle-create.js +1 -1
  199. package/dist/core/command-hooks/transport/exec-invoke.d.ts +2 -0
  200. package/dist/core/command-hooks/transport/exec-invoke.js +1 -1
  201. package/dist/core/command-hooks/transport/exec-lifecycle.d.ts +1 -0
  202. package/dist/core/command-hooks/transport/exec-lifecycle.js +1 -1
  203. package/dist/core/command-hooks/transport/plan.d.ts +3 -0
  204. package/dist/core/command-hooks/transport/plan.js +1 -0
  205. package/dist/core/command-plugins/discovery.js +1 -1
  206. package/dist/core/command.d.ts +6 -2
  207. package/dist/core/command.js +6 -6
  208. package/dist/core/config.d.ts +8 -5
  209. package/dist/core/config.js +1 -1
  210. package/dist/core/conversation-store/client-worker.d.ts +1 -0
  211. package/dist/core/conversation-store/client-worker.js +1 -0
  212. package/dist/core/conversation-store/client.d.ts +2 -0
  213. package/dist/core/conversation-store/client.js +2 -0
  214. package/dist/core/conversation-store/file-store.d.ts +37 -0
  215. package/dist/core/conversation-store/file-store.js +9 -0
  216. package/dist/core/conversation-store/index.d.ts +50 -0
  217. package/dist/core/conversation-store/index.js +1 -0
  218. package/dist/core/conversation-store/listener.d.ts +4 -0
  219. package/dist/core/conversation-store/listener.js +3 -0
  220. package/dist/core/conversation-store/patch.d.ts +1 -0
  221. package/dist/core/conversation-store/patch.js +1 -0
  222. package/dist/core/directory/join.d.ts +27 -0
  223. package/dist/core/directory/join.js +1 -0
  224. package/dist/core/disk-usage.d.ts +4 -0
  225. package/dist/core/disk-usage.js +1 -0
  226. package/dist/core/events/emit.d.ts +2 -0
  227. package/dist/core/events/emit.js +3 -1
  228. package/dist/core/feed/feed.js +4 -4
  229. package/dist/core/feed/messages.d.ts +3 -0
  230. package/dist/core/feed/messages.js +6 -6
  231. package/dist/core/fs-utils.d.ts +2 -0
  232. package/dist/core/fs-utils.js +3 -3
  233. package/dist/core/grants/local.d.ts +4 -0
  234. package/dist/core/grants/local.js +1 -0
  235. package/dist/core/grants/mirror.d.ts +44 -0
  236. package/dist/core/grants/mirror.js +4 -0
  237. package/dist/core/grants/on-sync.d.ts +22 -0
  238. package/dist/core/grants/on-sync.js +1 -0
  239. package/dist/core/grants/remove.d.ts +7 -0
  240. package/dist/core/grants/remove.js +1 -0
  241. package/dist/core/grants/sandboxes.d.ts +7 -0
  242. package/dist/core/grants/sandboxes.js +1 -0
  243. package/dist/core/grants/sync.d.ts +12 -0
  244. package/dist/core/grants/sync.js +1 -0
  245. package/dist/core/help/memory-extensions.d.ts +3 -0
  246. package/dist/core/help/memory-extensions.js +2 -0
  247. package/dist/core/help.d.ts +14 -0
  248. package/dist/core/help.js +7 -7
  249. package/dist/core/host-exports/builtins.js +3 -3
  250. package/dist/core/host-exports/export.js +3 -3
  251. package/dist/core/human/action-binding.d.ts +2 -0
  252. package/dist/core/human/action-binding.js +1 -1
  253. package/dist/core/human/feedback-companion.d.ts +0 -1
  254. package/dist/core/human/feedback-companion.js +1 -1
  255. package/dist/core/human/page-schema.d.ts +1 -1
  256. package/dist/core/inspector/core.d.ts +2 -0
  257. package/dist/core/inspector/core.js +1 -1
  258. package/dist/core/inspector/tui.js +2 -2
  259. package/dist/core/installed-plugins.js +1 -1
  260. package/dist/core/io.js +6 -6
  261. package/dist/core/keybindings/catalog.d.ts +1 -1
  262. package/dist/core/keybindings/catalog.js +1 -1
  263. package/dist/core/layout-migrate/index.d.ts +15 -0
  264. package/dist/core/layout-migrate/index.js +4 -0
  265. package/dist/core/layout-migrate/paths.d.ts +26 -0
  266. package/dist/core/layout-migrate/paths.js +1 -0
  267. package/dist/core/layout-migrate/stored-paths.d.ts +2 -0
  268. package/dist/core/layout-migrate/stored-paths.js +11 -0
  269. package/dist/core/layout-migrate/stores.d.ts +17 -0
  270. package/dist/core/layout-migrate/stores.js +4 -0
  271. package/dist/core/layout.d.ts +26 -0
  272. package/dist/core/layout.js +2 -0
  273. package/dist/core/llm/run.d.ts +60 -0
  274. package/dist/core/llm/run.js +4 -0
  275. package/dist/core/memory/cli-selector.d.ts +13 -0
  276. package/dist/core/memory/cli-selector.js +1 -0
  277. package/dist/core/memory/history.d.ts +5 -4
  278. package/dist/core/memory/history.js +6 -6
  279. package/dist/core/memory/inline-ref-inventory.d.ts +2 -1
  280. package/dist/core/memory/inline-ref-inventory.js +1 -1
  281. package/dist/core/memory/lint.js +2 -2
  282. package/dist/core/memory/mutation-domain.d.ts +2 -2
  283. package/dist/core/memory/mutation-domain.js +8 -7
  284. package/dist/core/memory/mutations.js +1 -1
  285. package/dist/core/memory/service.d.ts +5 -0
  286. package/dist/core/memory/service.js +2 -2
  287. package/dist/core/memory-resolver.d.ts +11 -7
  288. package/dist/core/memory-resolver.js +2 -2
  289. package/dist/core/model-auth/daemon-login.d.ts +13 -0
  290. package/dist/core/model-auth/daemon-login.js +1 -0
  291. package/dist/core/model-auth/flows.d.ts +45 -0
  292. package/dist/core/model-auth/flows.js +1 -0
  293. package/dist/core/model-auth/handoff-jti.d.ts +4 -0
  294. package/dist/core/model-auth/handoff-jti.js +1 -0
  295. package/dist/core/model-routes.js +1 -1
  296. package/dist/core/nested-stores.d.ts +2 -1
  297. package/dist/core/nested-stores.js +1 -2
  298. package/dist/core/preview-registry.js +2 -2
  299. package/dist/core/profiles/env-store.js +2 -2
  300. package/dist/core/profiles/manifest.d.ts +16 -5
  301. package/dist/core/profiles/manifest.js +1 -1
  302. package/dist/core/provider-management.js +1 -1
  303. package/dist/core/review/birth.js +1 -1
  304. package/dist/core/review/companion.d.ts +0 -2
  305. package/dist/core/review/companion.js +1 -1
  306. package/dist/core/review/fork.js +2 -2
  307. package/dist/core/review/realize.js +1 -1
  308. package/dist/core/review/stage.d.ts +1 -1
  309. package/dist/core/review/stage.js +1 -1
  310. package/dist/core/review/types.d.ts +1 -1
  311. package/dist/core/runs/events.d.ts +34 -0
  312. package/dist/core/runs/events.js +1 -0
  313. package/dist/core/runs/operations.d.ts +43 -0
  314. package/dist/core/runs/operations.js +12 -0
  315. package/dist/core/runtime/bearings-render.d.ts +2 -2
  316. package/dist/core/runtime/bearings-render.js +11 -11
  317. package/dist/core/runtime/bearings.js +2 -2
  318. package/dist/core/runtime/broker/cli-relay.d.ts +5 -0
  319. package/dist/core/runtime/broker/cli-relay.js +1 -0
  320. package/dist/core/runtime/broker/client-registry.d.ts +0 -5
  321. package/dist/core/runtime/broker/client-registry.js +1 -1
  322. package/dist/core/runtime/broker/daemon-ops.d.ts +28 -1
  323. package/dist/core/runtime/broker/daemon-ops.js +1 -1
  324. package/dist/core/runtime/broker/engine-drive.d.ts +0 -2
  325. package/dist/core/runtime/broker/engine-drive.js +1 -1
  326. package/dist/core/runtime/broker/fault-retry.d.ts +9 -0
  327. package/dist/core/runtime/broker/fault-retry.js +1 -1
  328. package/dist/core/runtime/broker/frame-dispatch.d.ts +5 -9
  329. package/dist/core/runtime/broker/frame-dispatch.js +1 -1
  330. package/dist/core/runtime/broker/frame-engine-control.d.ts +3 -2
  331. package/dist/core/runtime/broker/frame-engine-control.js +1 -1
  332. package/dist/core/runtime/broker/frame-memory-refs.d.ts +4 -3
  333. package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
  334. package/dist/core/runtime/broker/frame-read.js +1 -1
  335. package/dist/core/runtime/broker/frame-session.js +1 -1
  336. package/dist/core/runtime/broker/held-deferred-inbox.d.ts +3 -1
  337. package/dist/core/runtime/broker/held-deferred-inbox.js +1 -1
  338. package/dist/core/runtime/broker/inbox.d.ts +1 -2
  339. package/dist/core/runtime/broker/inbox.js +7 -10
  340. package/dist/core/runtime/broker/model-adapter.d.ts +9 -0
  341. package/dist/core/runtime/broker/model-adapter.js +2 -0
  342. package/dist/core/runtime/broker/node-token.d.ts +3 -0
  343. package/dist/core/runtime/broker/node-token.js +1 -0
  344. package/dist/core/runtime/broker/read-ops.js +1 -1
  345. package/dist/core/runtime/broker/rebind.d.ts +2 -0
  346. package/dist/core/runtime/broker/rebind.js +1 -1
  347. package/dist/core/runtime/broker/tool-groups.js +1 -1
  348. package/dist/core/runtime/broker/turn-ignition.d.ts +3 -3
  349. package/dist/core/runtime/broker/turn-ignition.js +1 -1
  350. package/dist/core/runtime/broker-cli.js +3 -3
  351. package/dist/core/runtime/broker-extension-render.d.ts +2 -5
  352. package/dist/core/runtime/broker-extension-render.js +4 -4
  353. package/dist/core/runtime/broker-persona-guidance.js +3 -3
  354. package/dist/core/runtime/broker-protocol.d.ts +7 -8
  355. package/dist/core/runtime/broker.js +1 -1
  356. package/dist/core/runtime/canvas-extensions.d.ts +1 -0
  357. package/dist/core/runtime/canvas-extensions.js +1 -1
  358. package/dist/core/runtime/close.d.ts +9 -0
  359. package/dist/core/runtime/close.js +1 -1
  360. package/dist/core/runtime/deliver-live.js +1 -1
  361. package/dist/core/runtime/fleet.d.ts +1 -1
  362. package/dist/core/runtime/front-door-login.js +1 -1
  363. package/dist/core/runtime/front-door.js +2 -2
  364. package/dist/core/runtime/headless-pi.d.ts +1 -1
  365. package/dist/core/runtime/headless-pi.js +1 -1
  366. package/dist/core/runtime/host.d.ts +1 -1
  367. package/dist/core/runtime/host.js +3 -1
  368. package/dist/core/runtime/invocation.d.ts +3 -0
  369. package/dist/core/runtime/kickoff.d.ts +1 -0
  370. package/dist/core/runtime/kickoff.js +16 -16
  371. package/dist/core/runtime/launch-target.d.ts +1 -1
  372. package/dist/core/runtime/launch-target.js +1 -1
  373. package/dist/core/runtime/launch.d.ts +10 -35
  374. package/dist/core/runtime/launch.js +1 -1
  375. package/dist/core/runtime/lifecycle.js +2 -2
  376. package/dist/core/runtime/memory.d.ts +1 -1
  377. package/dist/core/runtime/memory.js +1 -1
  378. package/dist/core/runtime/model-registry.js +1 -1
  379. package/dist/core/runtime/model-swap.d.ts +17 -19
  380. package/dist/core/runtime/model-swap.js +1 -1
  381. package/dist/core/runtime/node-read.js +3 -2
  382. package/dist/core/runtime/nodes.d.ts +7 -0
  383. package/dist/core/runtime/nodes.js +1 -1
  384. package/dist/core/runtime/outcome-document.js +1 -1
  385. package/dist/core/runtime/package-health.js +2 -2
  386. package/dist/core/runtime/persona.js +2 -2
  387. package/dist/core/runtime/pi-vendored.js +1 -1
  388. package/dist/core/runtime/placement-tmux.d.ts +1 -1
  389. package/dist/core/runtime/placement-tmux.js +1 -1
  390. package/dist/core/runtime/placement.js +1 -1
  391. package/dist/core/runtime/promote.js +1 -1
  392. package/dist/core/runtime/provider-credential-gate.js +2 -2
  393. package/dist/core/runtime/recovery-hold.d.ts +2 -0
  394. package/dist/core/runtime/recovery-hold.js +1 -0
  395. package/dist/core/runtime/recycle.js +1 -1
  396. package/dist/core/runtime/reopen.js +1 -1
  397. package/dist/core/runtime/reset.js +1 -1
  398. package/dist/core/runtime/revive.d.ts +1 -1
  399. package/dist/core/runtime/revive.js +2 -3
  400. package/dist/core/runtime/roadmap.js +4 -4
  401. package/dist/core/runtime/run-command.d.ts +6 -0
  402. package/dist/core/runtime/run-command.js +1 -1
  403. package/dist/core/runtime/session-branch.d.ts +2 -8
  404. package/dist/core/runtime/session-branch.js +1 -1
  405. package/dist/core/runtime/session-list-cache.d.ts +6 -22
  406. package/dist/core/runtime/session-list-cache.js +1 -1
  407. package/dist/core/runtime/situational-context.js +2 -2
  408. package/dist/core/runtime/spawn-env.d.ts +6 -6
  409. package/dist/core/runtime/spawn-env.js +1 -1
  410. package/dist/core/runtime/spawn.d.ts +5 -0
  411. package/dist/core/runtime/spawn.js +2 -2
  412. package/dist/core/runtime/stop-guard.js +2 -2
  413. package/dist/core/runtime/stop-signals.d.ts +2 -2
  414. package/dist/core/runtime/stop-signals.js +1 -1
  415. package/dist/core/runtime/structured-output.d.ts +10 -4
  416. package/dist/core/runtime/structured-output.js +4 -4
  417. package/dist/core/runtime/tmux-bindings.js +3 -3
  418. package/dist/core/runtime/tmux-driver.d.ts +4 -0
  419. package/dist/core/runtime/tmux-driver.js +7 -7
  420. package/dist/core/runtime/view-socket.d.ts +9 -2
  421. package/dist/core/runtime/view-socket.js +1 -1
  422. package/dist/core/runtime/warm-pool.js +1 -1
  423. package/dist/core/scope.d.ts +3 -2
  424. package/dist/core/scope.js +1 -1
  425. package/dist/core/scoped-state/db.js +1 -1
  426. package/dist/core/scoped-state/migrate.js +3 -3
  427. package/dist/core/scoped-state/profiles.d.ts +2 -1
  428. package/dist/core/scoped-state/profiles.js +1 -1
  429. package/dist/core/scoped-state/schema.d.ts +2 -1
  430. package/dist/core/scoped-state/schema.js +4 -4
  431. package/dist/core/scopes.d.ts +2 -2
  432. package/dist/core/scopes.js +1 -1
  433. package/dist/core/secrets.d.ts +1 -0
  434. package/dist/core/secrets.js +2 -2
  435. package/dist/core/spaces/mounts.d.ts +32 -0
  436. package/dist/core/spaces/mounts.js +1 -0
  437. package/dist/core/spaces/open-beneath.d.ts +71 -0
  438. package/dist/core/spaces/open-beneath.js +1 -0
  439. package/dist/core/spaces/permissions.d.ts +46 -0
  440. package/dist/core/spaces/permissions.js +1 -0
  441. package/dist/core/spaces/process.d.ts +27 -0
  442. package/dist/core/spaces/process.js +1 -0
  443. package/dist/core/spaces/space.d.ts +8 -0
  444. package/dist/core/spaces/space.js +2 -0
  445. package/dist/core/spaces/stop.d.ts +8 -0
  446. package/dist/core/spaces/stop.js +2 -0
  447. package/dist/core/spaces/users.d.ts +19 -0
  448. package/dist/core/spaces/users.js +1 -0
  449. package/dist/core/subscription-state.d.ts +2 -0
  450. package/dist/core/subscription-state.js +3 -3
  451. package/dist/core/substrate/frontmatter-validation.js +1 -1
  452. package/dist/core/substrate/injected-store.d.ts +28 -3
  453. package/dist/core/substrate/injected-store.js +2 -1
  454. package/dist/core/substrate/listings.js +1 -1
  455. package/dist/core/substrate/memory-events.d.ts +6 -0
  456. package/dist/core/substrate/memory-events.js +1 -0
  457. package/dist/core/substrate/on-read-node.js +1 -1
  458. package/dist/core/substrate/on-read.d.ts +6 -6
  459. package/dist/core/substrate/on-read.js +5 -5
  460. package/dist/core/substrate/plan.js +1 -1
  461. package/dist/core/substrate/render-node.js +1 -1
  462. package/dist/core/substrate/render.d.ts +4 -3
  463. package/dist/core/substrate/render.js +38 -38
  464. package/dist/core/substrate/schema.d.ts +6 -0
  465. package/dist/core/substrate/schema.js +1 -1
  466. package/dist/core/tui/panel.js +1 -1
  467. package/dist/core/user-settings.d.ts +12 -0
  468. package/dist/core/user-settings.js +1 -1
  469. package/dist/core/worktree-mutation-async.js +5 -5
  470. package/dist/core/worktree-quarantine.js +1 -1
  471. package/dist/core/worktree-remove.d.ts +15 -0
  472. package/dist/core/worktree-remove.js +1 -0
  473. package/dist/core/worktree-sweep.js +6 -6
  474. package/dist/daemon/analytics/compute.d.ts +37 -0
  475. package/dist/daemon/analytics/compute.js +1 -0
  476. package/dist/daemon/analytics/scan-worker.d.ts +1 -0
  477. package/dist/daemon/analytics/scan-worker.js +2 -0
  478. package/dist/daemon/analytics/scan.d.ts +37 -0
  479. package/dist/daemon/analytics/scan.js +1 -0
  480. package/dist/daemon/api/app-listener.d.ts +11 -0
  481. package/dist/daemon/api/app-listener.js +21 -0
  482. package/dist/daemon/api/bridge.js +5 -5
  483. package/dist/daemon/api/handlers/analytics.d.ts +2 -0
  484. package/dist/daemon/api/handlers/analytics.js +1 -0
  485. package/dist/daemon/api/handlers/attach.js +1 -1
  486. package/dist/daemon/api/handlers/bash-jobs.js +2 -2
  487. package/dist/daemon/api/handlers/bash.js +1 -1
  488. package/dist/daemon/api/handlers/broker-ops.js +1 -1
  489. package/dist/daemon/api/handlers/canvas.d.ts +1 -1
  490. package/dist/daemon/api/handlers/canvas.js +6 -6
  491. package/dist/daemon/api/handlers/crons.js +1 -1
  492. package/dist/daemon/api/handlers/files.d.ts +1 -1
  493. package/dist/daemon/api/handlers/files.js +1 -1
  494. package/dist/daemon/api/handlers/health.js +2 -2
  495. package/dist/daemon/api/handlers/hook-exec.d.ts +2 -0
  496. package/dist/daemon/api/handlers/hook-exec.js +1 -0
  497. package/dist/daemon/api/handlers/human-requests.js +1 -1
  498. package/dist/daemon/api/handlers/inbox.js +1 -1
  499. package/dist/daemon/api/handlers/llm.d.ts +2 -0
  500. package/dist/daemon/api/handlers/llm.js +3 -0
  501. package/dist/daemon/api/handlers/memory-reads.d.ts +4 -0
  502. package/dist/daemon/api/handlers/memory-reads.js +1 -0
  503. package/dist/daemon/api/handlers/memory.js +5 -1
  504. package/dist/daemon/api/handlers/messages.js +2 -2
  505. package/dist/daemon/api/handlers/modelauth.js +1 -1
  506. package/dist/daemon/api/handlers/node-outcomes.js +1 -1
  507. package/dist/daemon/api/handlers/node-records.d.ts +2 -0
  508. package/dist/daemon/api/handlers/node-records.js +3 -0
  509. package/dist/daemon/api/handlers/nodes.d.ts +1 -1
  510. package/dist/daemon/api/handlers/nodes.js +1 -1
  511. package/dist/daemon/api/handlers/profiles.d.ts +4 -1
  512. package/dist/daemon/api/handlers/profiles.js +1 -1
  513. package/dist/daemon/api/handlers/reports.js +5 -3
  514. package/dist/daemon/api/handlers/reviews.d.ts +1 -1
  515. package/dist/daemon/api/handlers/reviews.js +1 -1
  516. package/dist/daemon/api/handlers/run-routes.d.ts +2 -0
  517. package/dist/daemon/api/handlers/run-routes.js +1 -0
  518. package/dist/daemon/api/handlers/runs.d.ts +9 -0
  519. package/dist/daemon/api/handlers/runs.js +1 -0
  520. package/dist/daemon/api/handlers/subscriptions.js +1 -1
  521. package/dist/daemon/api/handlers/worktree.js +1 -1
  522. package/dist/daemon/api/map.d.ts +10 -4
  523. package/dist/daemon/api/map.js +2 -2
  524. package/dist/daemon/api/operations.d.ts +18 -0
  525. package/dist/daemon/api/operations.js +1 -0
  526. package/dist/daemon/api/principal.d.ts +42 -0
  527. package/dist/daemon/api/principal.js +1 -0
  528. package/dist/daemon/api/router.d.ts +27 -3
  529. package/dist/daemon/api/router.js +1 -1
  530. package/dist/daemon/api/server.d.ts +4 -0
  531. package/dist/daemon/api/server.js +1 -1
  532. package/dist/daemon/api/vendor-signin.d.ts +7 -0
  533. package/dist/daemon/api/vendor-signin.js +77 -0
  534. package/dist/daemon/api/viewer-presence.d.ts +3 -0
  535. package/dist/daemon/api/viewer-presence.js +1 -0
  536. package/dist/daemon/cron/armed-context.d.ts +4 -0
  537. package/dist/daemon/cron/armed-context.js +1 -1
  538. package/dist/daemon/cron/escalation.js +3 -3
  539. package/dist/daemon/cron/lease-recovery.js +1 -1
  540. package/dist/daemon/cron/sinks.js +2 -2
  541. package/dist/daemon/cron-run.d.ts +5 -5
  542. package/dist/daemon/cron-run.js +1 -1
  543. package/dist/daemon/crtrd.js +8 -7
  544. package/dist/daemon/delivery/run-delivery.d.ts +4 -0
  545. package/dist/daemon/delivery/run-delivery.js +1 -1
  546. package/dist/daemon/fleet.d.ts +1 -1
  547. package/dist/daemon/fleet.js +6 -6
  548. package/dist/daemon/human/finish.js +7 -7
  549. package/dist/daemon/joined-owner.d.ts +5 -0
  550. package/dist/daemon/joined-owner.js +1 -0
  551. package/dist/daemon/manage.js +2 -2
  552. package/dist/daemon/messaging/node-message.js +1 -1
  553. package/dist/daemon/park-activity.js +1 -1
  554. package/dist/daemon/reconcilers/bash-deadline.js +1 -1
  555. package/dist/daemon/reconcilers/broker-supervision.d.ts +1 -1
  556. package/dist/daemon/reconcilers/broker-supervision.js +4 -4
  557. package/dist/daemon/reconcilers/delivery-lane.js +1 -1
  558. package/dist/daemon/reconcilers/live-obligation.d.ts +7 -0
  559. package/dist/daemon/reconcilers/live-obligation.js +1 -1
  560. package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
  561. package/dist/daemon/reconcilers/storage-maintenance.d.ts +20 -1
  562. package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
  563. package/dist/daemon/runs/append-section.d.ts +6 -0
  564. package/dist/daemon/runs/append-section.js +2 -0
  565. package/dist/daemon/runs/observer.d.ts +5 -0
  566. package/dist/daemon/runs/observer.js +4 -0
  567. package/dist/launcher/bwrap.d.ts +4 -0
  568. package/dist/launcher/bwrap.js +2 -0
  569. package/dist/launcher/client.d.ts +2 -0
  570. package/dist/launcher/client.js +3 -0
  571. package/dist/launcher/main.d.ts +1 -0
  572. package/dist/launcher/main.js +3 -0
  573. package/dist/launcher/netrule.d.ts +1 -0
  574. package/dist/launcher/netrule.js +1 -0
  575. package/dist/launcher/seccomp.d.ts +1 -0
  576. package/dist/launcher/seccomp.js +1 -0
  577. package/dist/launcher/spec.d.ts +88 -0
  578. package/dist/launcher/spec.js +1 -0
  579. package/dist/launcher/users.d.ts +18 -0
  580. package/dist/launcher/users.js +7 -0
  581. package/dist/launcher/validate.d.ts +22 -0
  582. package/dist/launcher/validate.js +1 -0
  583. package/dist/migrations/corpus.js +3 -3
  584. package/dist/migrations/runner.js +1 -1
  585. package/dist/native/linux/addon.node +0 -0
  586. package/dist/native/linux.d.ts +29 -0
  587. package/dist/native/linux.js +1 -0
  588. package/dist/pi-extensions/broker-local.js +2 -2
  589. package/dist/pi-extensions/canvas-bash-valve.d.ts +1 -3
  590. package/dist/pi-extensions/canvas-bash-valve.js +4 -7
  591. package/dist/pi-extensions/canvas-context-intro.d.ts +1 -2
  592. package/dist/pi-extensions/canvas-context-intro.js +2 -2
  593. package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
  594. package/dist/pi-extensions/canvas-inbox-watcher.d.ts +2 -1
  595. package/dist/pi-extensions/canvas-inbox-watcher.js +2 -1
  596. package/dist/pi-extensions/canvas-passive-context.d.ts +1 -1
  597. package/dist/pi-extensions/canvas-passive-context.js +11 -11
  598. package/dist/pi-extensions/canvas-recap.js +6 -6
  599. package/dist/pi-extensions/canvas-stophook.js +1 -1
  600. package/dist/pi-extensions/canvas-structured-output.js +4 -4
  601. package/dist/pi-extensions/canvas-tool-guide.js +1 -1
  602. package/dist/pi-extensions/system-prompt-entry.d.ts +15 -0
  603. package/dist/pi-extensions/system-prompt-entry.js +1 -0
  604. package/dist/shared/env.d.ts +5 -1
  605. package/dist/shared/env.js +1 -1
  606. package/dist/shared/strip-cd-prefix.d.ts +1 -0
  607. package/dist/shared/strip-cd-prefix.js +1 -0
  608. package/dist/types.d.ts +31 -15
  609. package/docs/cli/memory-and-preferences.md +3 -1
  610. package/docs/sdk/client.md +34 -0
  611. package/docs/sdk/errors.md +2 -0
  612. package/docs/sdk/memory.md +2 -2
  613. package/docs/sdk/streaming.md +21 -0
  614. package/package.json +18 -4
  615. package/packages/crouter-identity/dist/index.d.ts +54 -0
  616. package/packages/crouter-identity/dist/index.js +166 -0
  617. package/packages/crouter-identity/package.json +33 -0
  618. package/runtime.lock.json +34 -8
  619. package/scripts/build-native-linux.mjs +16 -0
  620. package/scripts/install-runtime.mjs +9 -7
  621. package/scripts/lib/isolation-env.mjs +42 -0
  622. package/scripts/runtime-smoke.mjs +49 -0
  623. package/src/native/linux/addon.c +249 -0
  624. package/dist/core/profiles/state-block.d.ts +0 -4
  625. package/dist/core/profiles/state-block.js +0 -3
  626. package/dist/core/runtime/broker/auth-reload.d.ts +0 -41
  627. package/dist/core/runtime/broker/auth-reload.js +0 -1
  628. package/dist/core/substrate/cli-context-delivery.d.ts +0 -22
  629. package/dist/core/substrate/cli-context-delivery.js +0 -1
@@ -1,2 +1,2 @@
1
- var C=Object.defineProperty;var s=(e,n)=>C(e,"name",{value:n,configurable:!0});import{record as I,scheduledItems as i}from"./model.js";function c(e,n,r,o){return{kind:e,display:{headline:n,explanation:r,nextStep:"Press g to retry.",level:"error",blocking:o}}}s(c,"error");function u(e,n,r){if(!e.ok)return{ok:!1,error:c("unavailable","Inspector unavailable",`Could not run crtr: ${e.stderr||"command not found"}`,r)};if(e.exitCode!==0)return{ok:!1,error:c("failed",r?"Node is gone":"Schedule unavailable",e.stderr||e.stdout||`crtr ${n} failed`,r)};try{const o=JSON.parse(e.stdout);if(o===null||typeof o!="object"||Array.isArray(o))throw new Error("not an object");return{ok:!0,data:o}}catch{return{ok:!1,error:c("parse","Inspector unavailable",`Could not parse crtr ${n} JSON.`,r)}}}s(u,"parseJson");const k={id:"dossier",request:s(e=>({kind:"exec",bin:"crtr",args:["--json","node","inspect","show",e]}),"request"),parse:s(e=>u(e,"node inspect show",!0),"parse")},w={id:"schedule",request:s(()=>({kind:"exec",bin:"crtr",args:["--json","cron","list"]}),"request"),parse:s(e=>{const n=u(e,"cron list",!1);if(!n.ok)return n;const r=n.data.crons;return Array.isArray(r)?{ok:!0,data:r}:{ok:!1,error:c("parse","Schedule unavailable","The cron list did not contain cron rows.",!1)}},"parse")},S=14,y={id:"jobs",request:s(e=>({kind:"exec",bin:"crtr",args:["--json","node","bash","list","--node",e,"--tail",String(S)]}),"request"),parse:s(e=>{const n=u(e,"node bash list",!1);if(!n.ok)return n;const r=n.data.jobs;return Array.isArray(r)?{ok:!0,data:r}:{ok:!1,error:c("parse","Jobs unavailable","The job list did not contain job rows.",!1)}},"parse")},_={id:"cancel",request:s(e=>({kind:"exec",bin:"crtr",args:["--json","cron","cancel",e]}),"request"),parse:s(e=>{const n=u(e,"cron cancel",!1);return n.ok?{ok:!0,data:{canceled:String(n.data.canceled??"")}}:n},"parse")},v={id:"kill-job",request:s(({target:e,job:n})=>({kind:"exec",bin:"crtr",args:["--json","node","bash","kill",n,"--node",e]}),"request"),parse:s(e=>{const n=u(e,"node bash kill",!1);return n.ok?{ok:!0,data:{job:String(n.data.job_id??"")}}:n},"parse")},$={id:"open-log",request:s(({path:e,title:n})=>({kind:"exec",bin:"tmux",args:["new-window","-n",n,`less +F -- ${h(e)} 2>/dev/null || tail -f -- ${h(e)}`]}),"request"),parse:s(e=>!e.ok||(e.exitCode??0)!==0?{ok:!1,error:c("no_tmux","Could not open the log",e.stderr||"tmux new-window failed \u2014 the Inspector must be running inside tmux.",!1)}:{ok:!0,data:{}},"parse")};function h(e){return`'${e.split("'").join("'\\''")}'`}s(h,"quote");const b=["overview","schedule","jobs","raw"];function J(e){return e==="schedule"||e==="jobs"||e==="raw"?e:"overview"}s(J,"section");function g(e){const n=`${i(e.schedule.data??[]).length} cron(s) armed`,r=`${(e.jobs.data??[]).length} background job(s) running`;return e.section==="schedule"?n:e.section==="jobs"?r:`${n} \xB7 ${r}`}s(g,"countsFor");function A(e,n){const r=i(n),o=e.selectedCronId;if(o!==null&&r.some(t=>t.cron.cron_id===o))return{...e,schedule:{data:n,error:null,fetchedAt:Date.now()}};const l=i(e.schedule.data??[]).findIndex(t=>t.cron.cron_id===o),a=r[Math.min(Math.max(0,l),Math.max(0,r.length-1))];return{...e,schedule:{data:n,error:null,fetchedAt:Date.now()},selectedCronId:a?.cron.cron_id??null,expanded:!1,pendingCancel:null}}s(A,"reconcile");const D={manifest:{title:"Inspector",refreshMs:5e3},init(e){return{target:e.target??"",section:J(e.section),dossier:{data:null,error:null,fetchedAt:0},schedule:{data:null,error:null,fetchedAt:0},jobs:{data:null,error:null,fetchedAt:0},selectedCronId:null,selectedJobId:null,expanded:!1,pendingCancel:null,scroll:{overview:0,schedule:0,jobs:0,raw:0}}},intents:{async refresh(e){e.signal.setStatus("Refreshing\u2026");let n;const[r,o,l]=await Promise.all([e.resolve(k,e.state.target),e.resolve(w,e.state.target),e.resolve(y,e.state.target)]);if(!r.ok){e.set(t=>({...t,dossier:{...t.dossier,error:r.error}})),e.signal.setBanner(`${r.error.display.headline}: ${r.error.display.explanation}`,"error"),e.signal.setStatus(null);return}if(e.set(t=>({...t,dossier:{data:r.data,error:null,fetchedAt:Date.now()}})),!o.ok)e.set(t=>({...t,schedule:{...t.schedule,error:o.error}})),e.signal.setBanner(o.error.display.explanation,"error");else{const t=e.state.selectedCronId;e.set(d=>A(d,o.data)),t!==null&&!o.data.some(d=>d.cron_id===t)&&(n="Selected cron disappeared; moved to the next item."),e.state.schedule.error!==null&&e.signal.clearBanner()}if(!l.ok)e.set(t=>({...t,jobs:{...t.jobs,error:l.error}}));else{const t=e.state.selectedJobId!==null&&!l.data.some(d=>d.job_id===e.state.selectedJobId);e.set(d=>B(d,l.data)),t&&(n="The selected job finished; moved to the next one.")}e.signal.setStatus(n??g(e.state));const a=I(e.state.dossier.data?.node);e.signal.setSubtitle(`${a.name??e.state.target} \xB7 ${e.state.section}`)},sectionNext(e){const n=b,r=n[(n.indexOf(e.state.section)+1)%n.length];e.set(o=>({...o,section:r,pendingCancel:null})),e.signal.clearBanner(),e.signal.setStatus(g(e.state)),e.signal.setSubtitle(`${e.state.target} \xB7 ${r}`)},sectionPrev(e){const n=b,r=n[(n.indexOf(e.state.section)+n.length-1)%n.length];e.set(o=>({...o,section:r,pendingCancel:null})),e.signal.clearBanner(),e.signal.setStatus(g(e.state)),e.signal.setSubtitle(`${e.state.target} \xB7 ${r}`)},down(e){e.set(n=>m(n,1))},up(e){e.set(n=>m(n,-1))},pageDown(e){e.set(n=>({...n,scroll:{...n.scroll,[n.section]:n.scroll[n.section]+8}}))},pageUp(e){e.set(n=>({...n,scroll:{...n.scroll,[n.section]:Math.max(0,n.scroll[n.section]-8)}}))},toggleDetail(e){(e.state.section==="jobs"?e.state.selectedJobId!==null:e.state.selectedCronId!==null)&&e.set(n=>({...n,expanded:!n.expanded}))},cancelItem(e){const n=e.state.section==="jobs"?f(e.state)&&{kind:"job",id:f(e.state).job_id,label:p(f(e.state).command)}:e.state.selectedCronId!==null&&{kind:"cron",id:e.state.selectedCronId,label:e.state.selectedCronId};if(n){if(n.kind==="job"&&f(e.state)?.pgid===null){e.signal.setBanner("This job predates recorded process groups \u2014 crtr cannot stop it. Open its log and stop it by hand.","error");return}e.set(r=>({...r,pendingCancel:n})),e.signal.setBanner(n.kind==="job"?`Stop job \u201C${n.label}\u201D? It dies now and the node is told. Press y to confirm.`:`Cancel cron ${n.label}? Press y to confirm.`,"action")}},async openLog(e){const n=f(e.state);if(n===void 0)return;e.signal.setStatus("Opening the job log\u2026");const r=await e.execute($,{path:n.log_path,title:`job \xB7 ${p(n.command,18)}`});if(!r.ok){e.signal.setBanner(r.error.display.explanation,"error");return}e.signal.setBanner("Log opened in a new tmux window, following live. Quit the Inspector to read it.","info")},async confirm(e){const n=e.state.pendingCancel;if(n===null)return;if(n.kind==="job"){e.signal.setStatus("Stopping the job\u2026");const l=await e.execute(v,{target:e.state.target,job:n.id});if(e.set(t=>({...t,pendingCancel:null})),!l.ok){e.signal.setBanner(l.error.display.explanation,"error");return}await e.dispatch("refresh");const a=(e.state.jobs.data??[]).some(t=>t.job_id===n.id);e.signal.setBanner(a?"The job is still running; refresh and retry.":"Job stopped \u2014 the node was told it was canceled.",a?"error":"info");return}e.signal.setStatus("Canceling cron\u2026");const r=await e.execute(_,n.id);if(e.set(l=>({...l,pendingCancel:null})),!r.ok){e.signal.setBanner(r.error.display.explanation,"error");return}await e.dispatch("refresh");const o=(e.state.schedule.data??[]).some(l=>l.cron_id===n.id);e.signal.setBanner(o?"Cron remains armed; refresh and retry.":"Cron canceled.",o?"error":"info")},dismiss(e){e.set(n=>({...n,pendingCancel:null})),e.signal.clearBanner()},retarget(e){const n=M(e.state)?.cron,r=n?.anchor_node??n?.created_by;r&&(e.set(o=>({...o,target:r,selectedCronId:null,expanded:!1,pendingCancel:null,dossier:{data:null,error:null,fetchedAt:0},schedule:{data:null,error:null,fetchedAt:0},jobs:{data:null,error:null,fetchedAt:0}})),e.dispatch("refresh"))},quit(e){e.signal.quit()}}};function M(e){return i(e.schedule.data??[]).find(n=>n.cron.cron_id===e.selectedCronId)}s(M,"selectedItem");function f(e){return(e.jobs.data??[]).find(n=>n.job_id===e.selectedJobId)}s(f,"selectedJob");function p(e,n=40){const r=(e.split(`
1
+ var C=Object.defineProperty;var s=(e,n)=>C(e,"name",{value:n,configurable:!0});import{record as I,scheduledItems as i}from"./model.js";function c(e,n,r,o){return{kind:e,display:{headline:n,explanation:r,nextStep:"Press g to retry.",level:"error",blocking:o}}}s(c,"error");function u(e,n,r){if(!e.ok)return{ok:!1,error:c("unavailable","Inspector unavailable",`Could not run crtr: ${e.stderr||"command not found"}`,r)};if(e.exitCode!==0)return{ok:!1,error:c("failed",r?"Node is gone":"Schedule unavailable",e.stderr||e.stdout||`crtr ${n} failed`,r)};try{const o=JSON.parse(e.stdout);if(o===null||typeof o!="object"||Array.isArray(o))throw new Error("not an object");return{ok:!0,data:o}}catch{return{ok:!1,error:c("parse","Inspector unavailable",`Could not parse crtr ${n} JSON.`,r)}}}s(u,"parseJson");const k={id:"dossier",request:s(e=>({kind:"exec",bin:"crtr",args:["--json","node","inspect","show",e]}),"request"),parse:s(e=>u(e,"node inspect show",!0),"parse")},w={id:"schedule",request:s(()=>({kind:"exec",bin:"crtr",args:["--json","cron","list"]}),"request"),parse:s(e=>{const n=u(e,"cron list",!1);if(!n.ok)return n;const r=n.data.crons;return Array.isArray(r)?{ok:!0,data:r}:{ok:!1,error:c("parse","Schedule unavailable","The cron list did not contain cron rows.",!1)}},"parse")},y=14,S={id:"jobs",request:s(e=>({kind:"exec",bin:"crtr",args:["--json","node","bash","list","--node",e,"--tail",String(y)]}),"request"),parse:s(e=>{const n=u(e,"node bash list",!1);if(!n.ok)return n;const r=n.data.jobs;return Array.isArray(r)?{ok:!0,data:r}:{ok:!1,error:c("parse","Jobs unavailable","The job list did not contain job rows.",!1)}},"parse")},_={id:"cancel",request:s(e=>({kind:"exec",bin:"crtr",args:["--json","cron","cancel",e]}),"request"),parse:s(e=>{const n=u(e,"cron cancel",!1);return n.ok?{ok:!0,data:{canceled:String(n.data.canceled??"")}}:n},"parse")},v={id:"kill-job",request:s(({target:e,job:n})=>({kind:"exec",bin:"crtr",args:["--json","node","bash","kill",n,"--node",e]}),"request"),parse:s(e=>{const n=u(e,"node bash kill",!1);return n.ok?{ok:!0,data:{job:String(n.data.job_id??"")}}:n},"parse")},$={id:"open-log",request:s(({path:e,title:n})=>({kind:"exec",bin:"tmux",args:["new-window","-n",n,`less +F -- ${h(e)} 2>/dev/null || tail -f -- ${h(e)}`]}),"request"),parse:s(e=>!e.ok||(e.exitCode??0)!==0?{ok:!1,error:c("no_tmux","Could not open the log",e.stderr||"tmux new-window failed \u2014 the Inspector must be running inside tmux.",!1)}:{ok:!0,data:{}},"parse")};function h(e){return`'${e.split("'").join("'\\''")}'`}s(h,"quote");const b=["overview","schedule","jobs","raw"];function J(e){return e==="schedule"||e==="jobs"||e==="raw"?e:"overview"}s(J,"section");function g(e){const n=`${i(e.schedule.data??[]).length} cron(s) armed`,r=`${(e.jobs.data??[]).length} background job(s) running`;return e.section==="schedule"?n:e.section==="jobs"?r:`${n} \xB7 ${r}`}s(g,"countsFor");function A(e,n){const r=i(n),o=e.selectedCronId;if(o!==null&&r.some(t=>t.cron.cron_id===o))return{...e,schedule:{data:n,error:null,fetchedAt:Date.now()}};const l=i(e.schedule.data??[]).findIndex(t=>t.cron.cron_id===o),a=r[Math.min(Math.max(0,l),Math.max(0,r.length-1))];return{...e,schedule:{data:n,error:null,fetchedAt:Date.now()},selectedCronId:a?.cron.cron_id??null,expanded:!1,pendingCancel:null}}s(A,"reconcile");const D={manifest:{title:"Inspector",refreshMs:5e3},init(e){return{target:e.target??"",section:J(e.section),dossier:{data:null,error:null,fetchedAt:0},schedule:{data:null,error:null,fetchedAt:0},jobs:{data:null,error:null,fetchedAt:0},selectedCronId:null,selectedJobId:null,expanded:!1,pendingCancel:null,scroll:{overview:0,schedule:0,jobs:0,raw:0},readOnly:e.readOnly==="true"}},intents:{async refresh(e){e.signal.setStatus("Refreshing\u2026");let n;const[r,o,l]=await Promise.all([e.resolve(k,e.state.target),e.resolve(w,e.state.target),e.resolve(S,e.state.target)]);if(!r.ok){e.set(t=>({...t,dossier:{...t.dossier,error:r.error}})),e.signal.setBanner(`${r.error.display.headline}: ${r.error.display.explanation}`,"error"),e.signal.setStatus(null);return}if(e.set(t=>({...t,dossier:{data:r.data,error:null,fetchedAt:Date.now()}})),!o.ok)e.set(t=>({...t,schedule:{...t.schedule,error:o.error}})),e.signal.setBanner(o.error.display.explanation,"error");else{const t=e.state.selectedCronId;e.set(d=>A(d,o.data)),t!==null&&!o.data.some(d=>d.cron_id===t)&&(n="Selected cron disappeared; moved to the next item."),e.state.schedule.error!==null&&e.signal.clearBanner()}if(!l.ok)e.set(t=>({...t,jobs:{...t.jobs,error:l.error}}));else{const t=e.state.selectedJobId!==null&&!l.data.some(d=>d.job_id===e.state.selectedJobId);e.set(d=>B(d,l.data)),t&&(n="The selected job finished; moved to the next one.")}e.signal.setStatus(n??g(e.state));const a=I(e.state.dossier.data?.node);e.signal.setSubtitle(`${a.name??e.state.target} \xB7 ${e.state.section}`)},sectionNext(e){const n=b,r=n[(n.indexOf(e.state.section)+1)%n.length];e.set(o=>({...o,section:r,pendingCancel:null})),e.signal.clearBanner(),e.signal.setStatus(g(e.state)),e.signal.setSubtitle(`${e.state.target} \xB7 ${r}`)},sectionPrev(e){const n=b,r=n[(n.indexOf(e.state.section)+n.length-1)%n.length];e.set(o=>({...o,section:r,pendingCancel:null})),e.signal.clearBanner(),e.signal.setStatus(g(e.state)),e.signal.setSubtitle(`${e.state.target} \xB7 ${r}`)},down(e){e.set(n=>m(n,1))},up(e){e.set(n=>m(n,-1))},pageDown(e){e.set(n=>({...n,scroll:{...n.scroll,[n.section]:n.scroll[n.section]+8}}))},pageUp(e){e.set(n=>({...n,scroll:{...n.scroll,[n.section]:Math.max(0,n.scroll[n.section]-8)}}))},toggleDetail(e){(e.state.section==="jobs"?e.state.selectedJobId!==null:e.state.selectedCronId!==null)&&e.set(n=>({...n,expanded:!n.expanded}))},cancelItem(e){const n=e.state.section==="jobs"?f(e.state)&&{kind:"job",id:f(e.state).job_id,label:p(f(e.state).command)}:e.state.selectedCronId!==null&&{kind:"cron",id:e.state.selectedCronId,label:e.state.selectedCronId};if(n){if(n.kind==="job"&&f(e.state)?.pgid===null){e.signal.setBanner("This job predates recorded process groups \u2014 crtr cannot stop it. Open its log and stop it by hand.","error");return}e.set(r=>({...r,pendingCancel:n})),e.signal.setBanner(n.kind==="job"?`Stop job \u201C${n.label}\u201D? It dies now and the node is told. Press y to confirm.`:`Cancel cron ${n.label}? Press y to confirm.`,"action")}},async openLog(e){const n=f(e.state);if(n===void 0)return;e.signal.setStatus("Opening the job log\u2026");const r=await e.execute($,{path:n.log_path,title:`job \xB7 ${p(n.command,18)}`});if(!r.ok){e.signal.setBanner(r.error.display.explanation,"error");return}e.signal.setBanner("Log opened in a new tmux window, following live. Quit the Inspector to read it.","info")},async confirm(e){const n=e.state.pendingCancel;if(n===null)return;if(n.kind==="job"){e.signal.setStatus("Stopping the job\u2026");const l=await e.execute(v,{target:e.state.target,job:n.id});if(e.set(t=>({...t,pendingCancel:null})),!l.ok){e.signal.setBanner(l.error.display.explanation,"error");return}await e.dispatch("refresh");const a=(e.state.jobs.data??[]).some(t=>t.job_id===n.id);e.signal.setBanner(a?"The job is still running; refresh and retry.":"Job stopped \u2014 the node was told it was canceled.",a?"error":"info");return}e.signal.setStatus("Canceling cron\u2026");const r=await e.execute(_,n.id);if(e.set(l=>({...l,pendingCancel:null})),!r.ok){e.signal.setBanner(r.error.display.explanation,"error");return}await e.dispatch("refresh");const o=(e.state.schedule.data??[]).some(l=>l.cron_id===n.id);e.signal.setBanner(o?"Cron remains armed; refresh and retry.":"Cron canceled.",o?"error":"info")},dismiss(e){e.set(n=>({...n,pendingCancel:null})),e.signal.clearBanner()},retarget(e){const n=M(e.state)?.cron,r=n?.anchor_node??n?.created_by;r&&(e.set(o=>({...o,target:r,selectedCronId:null,expanded:!1,pendingCancel:null,dossier:{data:null,error:null,fetchedAt:0},schedule:{data:null,error:null,fetchedAt:0},jobs:{data:null,error:null,fetchedAt:0}})),e.dispatch("refresh"))},quit(e){e.signal.quit()}}};function M(e){return i(e.schedule.data??[]).find(n=>n.cron.cron_id===e.selectedCronId)}s(M,"selectedItem");function f(e){return(e.jobs.data??[]).find(n=>n.job_id===e.selectedJobId)}s(f,"selectedJob");function p(e,n=40){const r=(e.split(`
2
2
  `)[0]??"").replace(/\s+/g," ").trim();return r.length>n?`${r.slice(0,n-1)}\u2026`:r}s(p,"commandHead");function B(e,n){const r={data:n,error:null,fetchedAt:Date.now()};if(e.selectedJobId!==null&&n.some(t=>t.job_id===e.selectedJobId))return{...e,jobs:r};const o=(e.jobs.data??[]).findIndex(t=>t.job_id===e.selectedJobId),l=n[Math.min(Math.max(0,o),Math.max(0,n.length-1))],a=e.pendingCancel?.kind==="job"?null:e.pendingCancel;return{...e,jobs:r,selectedJobId:l?.job_id??null,expanded:!1,pendingCancel:a}}s(B,"reconcileJobs");function m(e,n){if(e.section==="jobs"){const a=e.jobs.data??[];if(a.length===0)return e;const t=Math.max(0,a.findIndex(j=>j.job_id===e.selectedJobId)),d=Math.max(0,Math.min(a.length-1,t+n));return{...e,selectedJobId:a[d].job_id,expanded:!1,pendingCancel:null}}if(e.section!=="schedule")return{...e,scroll:{...e.scroll,[e.section]:Math.max(0,e.scroll[e.section]+n)}};const r=i(e.schedule.data??[]);if(r.length===0)return e;const o=Math.max(0,r.findIndex(a=>a.cron.cron_id===e.selectedCronId)),l=Math.max(0,Math.min(r.length-1,o+n));return{...e,selectedCronId:r[l].cron.cron_id,expanded:!1,pendingCancel:null}}s(m,"move");export{D as inspectorCore,i as scheduledItems,f as selectedJob};
@@ -1,2 +1,2 @@
1
- var S=Object.defineProperty;var o=(e,n)=>S(e,"name",{value:n,configurable:!0});import{ICON as p,commandCell as T,jobElapsed as j,jobElapsedMs as L,jobLabel as C,jobTone as R,overviewGroups as A,relativeTime as f,scheduledItems as I,shortPath as x,value as b}from"./model.js";const m=12,d=" ",v={plain:void 0,dim:{dim:!0},good:{fg:"32"},warn:{fg:"33"},bad:{fg:"31",bold:!0},accent:{fg:"36"}},$={dim:!0},g={dim:!0},N={fg:"36",bold:!0},k=[{id:"overview",label:"overview"},{id:"schedule",label:"schedule"},{id:"jobs",label:"jobs"},{id:"raw",label:"raw"}];function J(e,n){return[{text:`${d}${e.padEnd(m)}`,style:$},...n]}o(J,"fieldRow");function O(e,n,t){const i=v[n??"plain"];return[{text:t===void 0?e:`${t} ${e}`,style:i}]}o(O,"valueSpans");function E(e,n,t){const i=`${e} ${n}`,l=Math.max(0,t-i.length-3);return[{text:" "},{text:i,style:N},{text:` ${"\u2500".repeat(l)}`,style:g}]}o(E,"groupHeader");function y(e,n){const t=[{text:" "}];k.forEach((l,s)=>{s>0&&t.push({text:" \xB7 ",style:{dim:!0}});const r=l.id===e.section,c=l.id==="schedule"?` ${I(e.schedule.data??[]).length}`:l.id==="jobs"?` ${(e.jobs.data??[]).length}`:"";t.push({text:r?`${p.section} ${l.label}${c}`:`${l.label}${c}`,style:r?{fg:"36",bold:!0}:{dim:!0}})});const i=t.reduce((l,s)=>l+s.text.length,0);return t.push({text:` ${"\u2500".repeat(Math.max(0,n-i-1))}`,style:g}),t}o(y,"tabStrip");function D(e,n){const t=[];for(const i of e){t.push(E(i.icon,i.title,n));for(const l of i.fields)t.push(J(l.label,O(l.value,l.tone,l.glyph)));t.push([])}return t[t.length-1]?.length===0&&t.pop(),t}o(D,"groupRows");function q(e,n){return e.dossier.data===null?[[{text:`${d}loading node overview\u2026`,style:{dim:!0}}]]:D(A(e.dossier.data),n)}o(q,"overviewRows");function W(e){return e.dossier.data===null?[[{text:`${d}loading raw record\u2026`,style:{dim:!0}}]]:JSON.stringify(e.dossier.data,null,2).split(`
2
- `).map(n=>{const t=/^(\s*)"([^"]+)":\s?(.*)$/.exec(n);if(t===null)return[{text:n,style:g}];const[,i="",l="",s=""]=t,r=s.startsWith('"')?void 0:s.startsWith("{")||s.startsWith("[")?g:{fg:"33"};return[{text:i},{text:l,style:{fg:"36"}},{text:": ",style:g},{text:s,style:r}]})}o(W,"rawRows");function w(e,n,t){return[[{text:` \u2717 ${e}`,style:{fg:"31",bold:!0}}],[],[{text:`${d}${n}`}],[],[{text:`${d}${t}`,style:{dim:!0}}]]}o(w,"errorRows");function Y(e,n){const t=e.cron,i=t.state==="paused",l=f(e.nextAt)==="due now",s=i?{dim:!0}:l?{fg:"33",bold:!0}:{fg:"32"},r=[[{text:`${d}${d}${e.cadence}`,style:{dim:!0}},{text:" \xB7 ",style:{dim:!0}},{text:`${t.on_output}${t.sink?` \u2192 ${t.sink}`:""}`,style:{dim:!0}},...i?[{text:" paused",style:{fg:"33"}}]:[]]];if(n){const c=[["id",t.cron_id],["next fire",`${f(e.nextAt)} ${b(t.fire_at)}`],["recurrence",e.cadence],["state",b(t.state)],["target",x(e.target)],["expires",b(t.expires_at)]];r.push([]);for(const[a,u]of c)r.push([{text:`${d}${d}${a.padEnd(m)}`,style:$},{text:u}])}return r.push([]),{spans:[{text:` ${p.cron} `,style:s},{text:t.name,style:{bold:!0}}],right:[{text:`${f(e.nextAt)} `,style:s}],lines:r}}o(Y,"cronItem");function B(e,n,t){const i=v[R(L(e))],l=e.log_tail[e.log_tail.length-1],s=[];if(!n)s.push([{text:`${d}${d}${l===void 0?"no output yet":_(l,t-6)}`,style:{dim:!0}}]);else{const r=[["job",e.job_id],...e.purpose===null?[]:[["command",T(e.command,Math.max(20,t-26))]],["started",e.started_at],["log",x(e.log_path)],["watch",`tail -f ${x(e.log_path)}`]];for(const[c,a]of r)s.push([{text:`${d}${d}${c.padEnd(m)}`,style:$},{text:a,style:c==="watch"?{fg:"36"}:void 0}]);s.push([]),s.push(E(p.log,`last ${e.log_tail.length} lines`,t-2)),e.log_tail.length===0&&s.push([{text:`${d}${d}no output yet`,style:{dim:!0}}]);for(const c of e.log_tail)s.push([{text:`${d}${d}${_(c,t-6)}`,style:{dim:!0}}])}return s.push([]),{spans:[{text:` ${p.job} `,style:i},{text:C(e,Math.max(20,t-26)),style:{bold:!0}}],right:[{text:`${j(e)} `,style:i}],lines:s}}o(B,"jobItem");function _(e,n){const t=e.replace(/\t/g," ").replace(/[\u0000-\u0008\u000b-\u001f]/g,""),i=Math.max(10,n);return t.length>i?`${t.slice(0,i-1)}\u2026`:t}o(_,"logCell");function H(){return[[{text:` ${p.empty} nothing running`,style:{dim:!0}}],[],[{text:`${d}This node has no bash commands running in the background.`,style:{dim:!0}}]]}o(H,"jobsEmptyRows");function P(){return[[{text:` ${p.empty} nothing armed`,style:{dim:!0}}],[],[{text:`${d}This node has no crons waiting to fire.`,style:{dim:!0}}],[{text:`${d}Arm one with `,style:{dim:!0}},{text:"crtr cron add",style:{fg:"36"}},{text:".",style:{dim:!0}}]]}o(P,"scheduleEmptyRows");function h(e,n,t,i){const l=y(e,i.width),s=i.height-2;if(t.spans(i.row,i.col,l,i.width),s<=0)return;const r=Math.max(0,n.length-s),c=Math.min(Math.max(0,e.scroll[e.section]),r);if(n.slice(c,c+s).forEach((a,u)=>t.spans(i.row+2+u,i.col,a,i.width)),n.length>s){const a=r===0?100:Math.round((c+s)/n.length*100);t.spansRight(i.row,i.col+i.width,[{text:` ${a}% `,style:{dim:!0}}])}}o(h,"paint");const V={render(e,n,t){if(e.dossier.error?.display.blocking){const r=e.dossier.error.display;h(e,w(r.headline,r.explanation,r.nextStep),n,t);return}if(e.section==="overview"){h(e,q(e,t.width),n,t);return}if(e.section==="raw"){h(e,W(e),n,t);return}if(e.section==="jobs"){if(e.jobs.error){const u=e.jobs.error.display;h(e,w(u.headline,u.explanation,u.nextStep),n,t);return}const r=e.jobs.data??[];if(r.length===0){h(e,H(),n,t);return}n.spans(t.row,t.col,y(e,t.width),t.width);const c=Math.max(0,r.findIndex(u=>u.job_id===e.selectedJobId)),a=r.map((u,M)=>B(u,M===c&&e.expanded,t.width));n.list({...t,row:t.row+2,height:Math.max(0,t.height-2)},a,c,e.scroll.jobs);return}if(e.schedule.error){const r=e.schedule.error.display;h(e,w(r.headline,r.explanation,r.nextStep),n,t);return}const i=I(e.schedule.data??[]);if(i.length===0){h(e,P(),n,t);return}n.spans(t.row,t.col,y(e,t.width),t.width);const l=Math.max(0,i.findIndex(r=>r.cron.cron_id===e.selectedCronId)),s=i.map((r,c)=>Y(r,c===l&&e.expanded));n.list({...t,row:t.row+2,height:Math.max(0,t.height-2)},s,l,e.scroll.schedule)},keymap:[{bindingId:"crtr.inspector.down",intent:"down",hint:{label:"move"}},{bindingId:"crtr.inspector.up",intent:"up"},{bindingId:"crtr.inspector.section-next",intent:"sectionNext",hint:{label:"section"}},{bindingId:"crtr.inspector.section-prev",intent:"sectionPrev"},{bindingId:"crtr.inspector.page-down",intent:"pageDown"},{bindingId:"crtr.inspector.page-up",intent:"pageUp"},{bindingId:"crtr.inspector.toggle-detail",intent:"toggleDetail",when:o(e=>e.section==="schedule"&&e.selectedCronId!==null||e.section==="jobs"&&e.selectedJobId!==null,"when"),hint:{label:"details"}},{bindingId:"crtr.inspector.cancel-item",intent:"cancelItem",when:o(e=>e.section==="schedule"&&e.selectedCronId!==null,"when"),hint:{label:"cancel"}},{bindingId:"crtr.inspector.cancel-item",intent:"cancelItem",when:o(e=>e.section==="jobs"&&e.selectedJobId!==null,"when"),hint:{label:"stop job"}},{bindingId:"crtr.inspector.open-log",intent:"openLog",when:o(e=>e.section==="jobs"&&e.selectedJobId!==null,"when"),hint:{label:"open log"}},{bindingId:"crtr.inspector.confirm",intent:"confirm",when:o(e=>e.pendingCancel!==null,"when"),hint:{label:"confirm"}},{bindingId:"crtr.inspector.dismiss",intent:"dismiss",hint:{label:"dismiss"}},{bindingId:"crtr.inspector.retarget",intent:"retarget",when:o(e=>e.section==="schedule"&&e.selectedCronId!==null,"when"),hint:{label:"retarget"}},{bindingId:"crtr.inspector.refresh",intent:"refresh",hint:{label:"refresh"}},{bindingId:"crtr.inspector.quit",intent:"quit",hint:{label:"quit"}}]};export{V as inspectorTui};
1
+ var S=Object.defineProperty;var o=(e,n)=>S(e,"name",{value:n,configurable:!0});import{ICON as p,commandCell as T,jobElapsed as j,jobElapsedMs as L,jobLabel as C,jobTone as R,overviewGroups as A,relativeTime as f,scheduledItems as I,shortPath as x,value as b}from"./model.js";const m=12,d=" ",v={plain:void 0,dim:{dim:!0},good:{fg:"32"},warn:{fg:"33"},bad:{fg:"31",bold:!0},accent:{fg:"36"}},$={dim:!0},g={dim:!0},N={fg:"36",bold:!0},O=[{id:"overview",label:"overview"},{id:"schedule",label:"schedule"},{id:"jobs",label:"jobs"},{id:"raw",label:"raw"}];function k(e,n){return[{text:`${d}${e.padEnd(m)}`,style:$},...n]}o(k,"fieldRow");function J(e,n,t){const i=v[n??"plain"];return[{text:t===void 0?e:`${t} ${e}`,style:i}]}o(J,"valueSpans");function E(e,n,t){const i=`${e} ${n}`,s=Math.max(0,t-i.length-3);return[{text:" "},{text:i,style:N},{text:` ${"\u2500".repeat(s)}`,style:g}]}o(E,"groupHeader");function y(e,n){const t=[{text:" "}];O.forEach((s,l)=>{l>0&&t.push({text:" \xB7 ",style:{dim:!0}});const r=s.id===e.section,c=s.id==="schedule"?` ${I(e.schedule.data??[]).length}`:s.id==="jobs"?` ${(e.jobs.data??[]).length}`:"";t.push({text:r?`${p.section} ${s.label}${c}`:`${s.label}${c}`,style:r?{fg:"36",bold:!0}:{dim:!0}})});const i=t.reduce((s,l)=>s+l.text.length,0);return t.push({text:` ${"\u2500".repeat(Math.max(0,n-i-1))}`,style:g}),t}o(y,"tabStrip");function D(e,n){const t=[];for(const i of e){t.push(E(i.icon,i.title,n));for(const s of i.fields)t.push(k(s.label,J(s.value,s.tone,s.glyph)));t.push([])}return t[t.length-1]?.length===0&&t.pop(),t}o(D,"groupRows");function q(e,n){return e.dossier.data===null?[[{text:`${d}loading node overview\u2026`,style:{dim:!0}}]]:D(A(e.dossier.data),n)}o(q,"overviewRows");function W(e){return e.dossier.data===null?[[{text:`${d}loading raw record\u2026`,style:{dim:!0}}]]:JSON.stringify(e.dossier.data,null,2).split(`
2
+ `).map(n=>{const t=/^(\s*)"([^"]+)":\s?(.*)$/.exec(n);if(t===null)return[{text:n,style:g}];const[,i="",s="",l=""]=t,r=l.startsWith('"')?void 0:l.startsWith("{")||l.startsWith("[")?g:{fg:"33"};return[{text:i},{text:s,style:{fg:"36"}},{text:": ",style:g},{text:l,style:r}]})}o(W,"rawRows");function w(e,n,t){return[[{text:` \u2717 ${e}`,style:{fg:"31",bold:!0}}],[],[{text:`${d}${n}`}],[],[{text:`${d}${t}`,style:{dim:!0}}]]}o(w,"errorRows");function Y(e,n){const t=e.cron,i=t.state==="paused",s=f(e.nextAt)==="due now",l=i?{dim:!0}:s?{fg:"33",bold:!0}:{fg:"32"},r=[[{text:`${d}${d}${e.cadence}`,style:{dim:!0}},{text:" \xB7 ",style:{dim:!0}},{text:`${t.on_output}${t.sink?` \u2192 ${t.sink}`:""}`,style:{dim:!0}},...i?[{text:" paused",style:{fg:"33"}}]:[]]];if(n){const c=[["id",t.cron_id],["next fire",`${f(e.nextAt)} ${b(t.fire_at)}`],["recurrence",e.cadence],["state",b(t.state)],["target",x(e.target)],["expires",b(t.expires_at)]];r.push([]);for(const[a,u]of c)r.push([{text:`${d}${d}${a.padEnd(m)}`,style:$},{text:u}])}return r.push([]),{spans:[{text:` ${p.cron} `,style:l},{text:t.name,style:{bold:!0}}],right:[{text:`${f(e.nextAt)} `,style:l}],lines:r}}o(Y,"cronItem");function B(e,n,t){const i=v[R(L(e))],s=e.log_tail[e.log_tail.length-1],l=[];if(!n)l.push([{text:`${d}${d}${s===void 0?"no output yet":_(s,t-6)}`,style:{dim:!0}}]);else{const r=[["job",e.job_id],...e.purpose===null?[]:[["command",T(e.command,Math.max(20,t-26))]],["started",e.started_at],["log",x(e.log_path)],["watch",`tail -f ${x(e.log_path)}`]];for(const[c,a]of r)l.push([{text:`${d}${d}${c.padEnd(m)}`,style:$},{text:a,style:c==="watch"?{fg:"36"}:void 0}]);l.push([]),l.push(E(p.log,`last ${e.log_tail.length} lines`,t-2)),e.log_tail.length===0&&l.push([{text:`${d}${d}no output yet`,style:{dim:!0}}]);for(const c of e.log_tail)l.push([{text:`${d}${d}${_(c,t-6)}`,style:{dim:!0}}])}return l.push([]),{spans:[{text:` ${p.job} `,style:i},{text:C(e,Math.max(20,t-26)),style:{bold:!0}}],right:[{text:`${j(e)} `,style:i}],lines:l}}o(B,"jobItem");function _(e,n){const t=e.replace(/\t/g," ").replace(/[\u0000-\u0008\u000b-\u001f]/g,""),i=Math.max(10,n);return t.length>i?`${t.slice(0,i-1)}\u2026`:t}o(_,"logCell");function H(){return[[{text:` ${p.empty} nothing running`,style:{dim:!0}}],[],[{text:`${d}This node has no bash commands running in the background.`,style:{dim:!0}}]]}o(H,"jobsEmptyRows");function P(){return[[{text:` ${p.empty} nothing armed`,style:{dim:!0}}],[],[{text:`${d}This node has no crons waiting to fire.`,style:{dim:!0}}],[{text:`${d}Arm one with `,style:{dim:!0}},{text:"crtr cron add",style:{fg:"36"}},{text:".",style:{dim:!0}}]]}o(P,"scheduleEmptyRows");function h(e,n,t,i){const s=y(e,i.width),l=i.height-2;if(t.spans(i.row,i.col,s,i.width),l<=0)return;const r=Math.max(0,n.length-l),c=Math.min(Math.max(0,e.scroll[e.section]),r);if(n.slice(c,c+l).forEach((a,u)=>t.spans(i.row+2+u,i.col,a,i.width)),n.length>l){const a=r===0?100:Math.round((c+l)/n.length*100);t.spansRight(i.row,i.col+i.width,[{text:` ${a}% `,style:{dim:!0}}])}}o(h,"paint");const V={render(e,n,t){if(e.dossier.error?.display.blocking){const r=e.dossier.error.display;h(e,w(r.headline,r.explanation,r.nextStep),n,t);return}if(e.section==="overview"){h(e,q(e,t.width),n,t);return}if(e.section==="raw"){h(e,W(e),n,t);return}if(e.section==="jobs"){if(e.jobs.error){const u=e.jobs.error.display;h(e,w(u.headline,u.explanation,u.nextStep),n,t);return}const r=e.jobs.data??[];if(r.length===0){h(e,H(),n,t);return}n.spans(t.row,t.col,y(e,t.width),t.width);const c=Math.max(0,r.findIndex(u=>u.job_id===e.selectedJobId)),a=r.map((u,M)=>B(u,M===c&&e.expanded,t.width));n.list({...t,row:t.row+2,height:Math.max(0,t.height-2)},a,c,e.scroll.jobs);return}if(e.schedule.error){const r=e.schedule.error.display;h(e,w(r.headline,r.explanation,r.nextStep),n,t);return}const i=I(e.schedule.data??[]);if(i.length===0){h(e,P(),n,t);return}n.spans(t.row,t.col,y(e,t.width),t.width);const s=Math.max(0,i.findIndex(r=>r.cron.cron_id===e.selectedCronId)),l=i.map((r,c)=>Y(r,c===s&&e.expanded));n.list({...t,row:t.row+2,height:Math.max(0,t.height-2)},l,s,e.scroll.schedule)},keymap:[{bindingId:"crtr.inspector.down",intent:"down",hint:{label:"move"}},{bindingId:"crtr.inspector.up",intent:"up"},{bindingId:"crtr.inspector.section-next",intent:"sectionNext",hint:{label:"section"}},{bindingId:"crtr.inspector.section-prev",intent:"sectionPrev"},{bindingId:"crtr.inspector.page-down",intent:"pageDown"},{bindingId:"crtr.inspector.page-up",intent:"pageUp"},{bindingId:"crtr.inspector.toggle-detail",intent:"toggleDetail",when:o(e=>e.section==="schedule"&&e.selectedCronId!==null||e.section==="jobs"&&e.selectedJobId!==null,"when"),hint:{label:"details"}},{bindingId:"crtr.inspector.cancel-item",intent:"cancelItem",when:o(e=>!e.readOnly&&e.section==="schedule"&&e.selectedCronId!==null,"when"),hint:{label:"cancel"}},{bindingId:"crtr.inspector.cancel-item",intent:"cancelItem",when:o(e=>!e.readOnly&&e.section==="jobs"&&e.selectedJobId!==null,"when"),hint:{label:"stop job"}},{bindingId:"crtr.inspector.open-log",intent:"openLog",when:o(e=>e.section==="jobs"&&e.selectedJobId!==null,"when"),hint:{label:"open log"}},{bindingId:"crtr.inspector.confirm",intent:"confirm",when:o(e=>e.pendingCancel!==null,"when"),hint:{label:"confirm"}},{bindingId:"crtr.inspector.dismiss",intent:"dismiss",hint:{label:"dismiss"}},{bindingId:"crtr.inspector.retarget",intent:"retarget",when:o(e=>e.section==="schedule"&&e.selectedCronId!==null,"when"),hint:{label:"retarget"}},{bindingId:"crtr.inspector.refresh",intent:"refresh",hint:{label:"refresh"}},{bindingId:"crtr.inspector.quit",intent:"quit",hint:{label:"quit"}}]};export{V as inspectorTui};
@@ -1 +1 @@
1
- var m=Object.defineProperty;var f=(r,n)=>m(r,"name",{value:n,configurable:!0});import{join as a}from"node:path";import{CONFIG_FILE as p}from"../types.js";import{listDirs as g,pathExists as d,readJsonIfExists as w}from"./fs-utils.js";import{readPluginManifest as y}from"./manifest.js";import{awaitBundleSwap as b,bundleSwapInFlightElsewhere as I}from"./plugin-swap-lock.js";import{userStore as k}from"./scoped-state/paths.js";import{readRawSettings as v}from"./scoped-state/settings.js";function S(r,n){const e=r==="user"?k(n):void 0,t=e?v({store:e,key:"user",kind:"user",root:e.root}):w(a(n,p));return t&&t.plugins&&typeof t.plugins=="object"?t.plugins:{}}f(S,"pluginConfigForRoot");function h(r,n,e){const t=Object.keys(n);return t.every(o=>e.has(o))?[]:t.filter(o=>!e.has(o)&&I(r,o))}f(h,"swapsToWaitOut");function B(r,n){const e=a(n,"plugins");if(!d(e))return[];const t=S(r,n),o=l(r,e,t),u=h(n,t,new Set(o.map(i=>i.name)));if(u.length===0)return o;for(const i of u)b(n,i);return l(r,e,t)}f(B,"listInstalledPluginsInRoot");function l(r,n,e){const t=[];for(const o of g(n)){const u=a(n,o),i=y(u);if(!i)continue;const s=e[o],c=typeof s?.version=="string"?s.version:i.version;t.push({name:o,scope:r,root:u,manifest:i,enabled:typeof s?.enabled=="boolean"?s.enabled:!0,sourceMarketplace:typeof s?.source_marketplace=="string"?s.source_marketplace:void 0,version:c})}return t}f(l,"collectInstalledPlugins");export{B as listInstalledPluginsInRoot};
1
+ var m=Object.defineProperty;var f=(e,n)=>m(e,"name",{value:n,configurable:!0});import{join as l}from"node:path";import{CONFIG_FILE as p}from"../types.js";import{listDirs as g,pathExists as d,readJsonIfExists as w}from"./fs-utils.js";import{readPluginManifest as y}from"./manifest.js";import{awaitBundleSwap as b,bundleSwapInFlightElsewhere as I}from"./plugin-swap-lock.js";import{userStore as k}from"./scoped-state/paths.js";import{readRawSettings as v}from"./scoped-state/settings.js";import{pluginsDir as S}from"./scope.js";function h(e,n){const r=e==="user"?k(n):void 0,t=r?v({store:r,key:"user",kind:"user",root:r.root}):w(l(n,p));return t&&t.plugins&&typeof t.plugins=="object"?t.plugins:{}}f(h,"pluginConfigForRoot");function E(e,n,r){const t=Object.keys(n);return t.every(o=>r.has(o))?[]:t.filter(o=>!r.has(o)&&I(e,o))}f(E,"swapsToWaitOut");function G(e,n){const r=e==="user"?S("user"):l(n,"plugins");if(!d(r))return[];const t=h(e,n),o=a(e,r,t),u=E(n,t,new Set(o.map(i=>i.name)));if(u.length===0)return o;for(const i of u)b(n,i);return a(e,r,t)}f(G,"listInstalledPluginsInRoot");function a(e,n,r){const t=[];for(const o of g(n)){const u=l(n,o),i=y(u);if(!i)continue;const s=r[o],c=typeof s?.version=="string"?s.version:i.version;t.push({name:o,scope:e,root:u,manifest:i,enabled:typeof s?.enabled=="boolean"?s.enabled:!0,sourceMarketplace:typeof s?.source_marketplace=="string"?s.source_marketplace:void 0,version:c})}return t}f(a,"collectInstalledPlugins");export{G as listInstalledPluginsInRoot};
package/dist/core/io.js CHANGED
@@ -1,7 +1,7 @@
1
- var x=Object.defineProperty;var n=(e,t)=>x(e,"name",{value:t,configurable:!0});import{appendFileSync as E,statSync as w}from"node:fs";import{CrtrError as f}from"./errors.js";import{ExitCode as c}from"../types.js";import{PREVIEW_RESULT_PATH_ENV as m}from"./preview-result-path.js";import{renderError as b}from"./render.js";import{ApiError as T}from"../api/index.js";let a=!1,i;const _=256*1024;function $(e){const t=process.env[m];i=t===void 0||t===""?void 0:{path:e,jsonl:[]}}n($,"beginPreview");function d(e){const t=process.env[m];if(t===void 0||t==="")return;const s=`${JSON.stringify({path:i?.path??"",...e})}
2
- `;try{if((w(t,{throwIfNoEntry:!1})?.size??0)+Buffer.byteLength(s,"utf8")>_)return;E(t,s,"utf8")}catch{}}n(d,"publishPreview");function B(e){i!==void 0&&(e!=null?d({result:e}):(i.jsonl.length>0||i.error!==void 0)&&d({...i.jsonl.length>0?{jsonl:i.jsonl}:{},...i.error===void 0?{}:{error:i.error}}))}n(B,"publishPreviewResult");function y(e){i?.jsonl.push(e)}n(y,"recordPreviewLine");function W(e){try{const t=JSON.parse(e);t!==null&&typeof t=="object"&&!Array.isArray(t)&&y(t)}catch{}}n(W,"recordPreviewJsonLine");function F(e){i!==void 0&&(i.error=e)}n(F,"recordPreviewError");function G(e){a=e}n(G,"setJsonOutput");function D(){return a}n(D,"isJsonOutput");class h extends f{static{n(this,"InputError")}payload;constructor(t,s=c.USAGE){super(t.error,t.message,s,{...t}),this.name="InputError",this.payload=t}}async function V(){if(process.stdin.isTTY)return"";const e=[];for await(const t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8")}n(V,"readStdinRaw");async function Y(e=200){return process.stdin.isTTY?"":await new Promise(t=>{const s=[];let o=!1;const r=n(()=>{o||(o=!0,clearTimeout(g),process.stdin.removeListener("data",u),process.stdin.removeListener("end",p),process.stdin.removeListener("error",l),process.stdin.pause(),t(Buffer.concat(s).toString("utf8")))},"finish"),u=n(S=>s.push(S),"onData"),p=n(()=>r(),"onEnd"),l=n(()=>r(),"onError"),g=setTimeout(r,e);process.stdin.on("data",u),process.stdin.on("end",p),process.stdin.on("error",l),process.stdin.resume()})}n(Y,"peekStdinRaw");function K(e){process.stdout.write(JSON.stringify(e,null,2)+`
3
- `)}n(K,"emit");function M(e){y(e),process.stdout.write(JSON.stringify(e)+`
4
- `)}n(M,"emitLine");function q(e){return new Promise(t=>{let s=!1;const o=n(u=>{u.code==="EPIPE"&&r(!1)},"onErr"),r=n(u=>{s||(s=!0,process.stdout.off("error",o),t(u))},"finish");process.stdout.on("error",o);try{process.stdout.write(e,u=>r(u==null))}catch{r(!1)}})}n(q,"writeStdout");function z(e){process.stderr.write(e+`
5
- `)}n(z,"diag");function O(e){if(e instanceof h)return e.payload;const t=e.details!==void 0?e.details:{},s=t.primaryCompleted===!0&&t.result!==null&&typeof t.result=="object"&&!Array.isArray(t.result)?N(t.result):void 0,o=t.next!==void 0?t.next:"Inspect the error and adjust the call. See -h for the schema.",r={error:e.code,message:e.message,received:t.received,field:t.field,...typeof t.http_status=="number"?{http_status:t.http_status}:{}};return s===void 0?{...r,next:o}:{...r,primaryCompleted:!0,result:s,next:o}}n(O,"payloadOf");function N(e){const t=new WeakSet;try{const s=JSON.stringify(e,(o,r)=>{if(typeof r=="bigint")return{$crtrType:"bigint",value:r.toString()};if(typeof r=="number"&&!Number.isFinite(r))return{$crtrType:"number",value:String(r)};if(typeof r>"u"||typeof r=="function"||typeof r=="symbol")return{$crtrType:typeof r};if(r!==null&&typeof r=="object"){if(t.has(r))return{$crtrType:"circular"};t.add(r)}return r});if(s!==void 0){const o=JSON.parse(s);if(o!==null&&typeof o=="object"&&!Array.isArray(o))return o}}catch{}return{$crtrType:"unavailable",message:"The completed primary result could not be represented as JSON."}}n(N,"jsonSafeResult");const P={400:"invalid_request",404:"not_found",409:"conflict",422:"unprocessable",503:"daemon_unavailable"};function A(e,t){if(e.code==="daemon_restarting")return new f("daemon_restarting",e.message,c.NETWORK,{next:"crtrd is now on the new generation \u2014 retry the command."});if(e.status===503||e.code==="daemon_unavailable")return new f("daemon_unavailable",e.message,c.NETWORK,{next:"Start it with `crtr sys daemon start`, then retry."});const s=e.details,o=s&&typeof s.error=="string"&&typeof s.message=="string"&&typeof s.next=="string"?s:{error:P[e.status]??e.code,message:e.message,next:t??(e.status>=500?"This is a crtr bug, not a bad call. Retry; if it persists, report it (the daemon log holds the full cause).":e.status===404?"List nodes with `crtr node inspect list`.":"Inspect the error and adjust the call. See -h for the schema.")};return new h(o,j(o.error,e.status))}n(A,"apiErrorToCliError");function j(e,t){return e==="not_found"||t===404?c.NOT_FOUND:e==="ambiguous"?c.AMBIGUOUS:c.USAGE}n(j,"exitForCliCode");function R(e){if(e instanceof T){R(A(e));return}if(e instanceof f){const o=O(e);i!==void 0&&d({error:o});const r=a?JSON.stringify(o,null,2):b(o);process.stdout.write(r+`
1
+ var S=Object.defineProperty;var n=(e,t)=>S(e,"name",{value:t,configurable:!0});import{appendFileSync as w,statSync as E}from"node:fs";import{CrtrError as a}from"./errors.js";import{ExitCode as c}from"../types.js";import{PREVIEW_RESULT_PATH_ENV as m}from"./preview-result-path.js";import{renderError as b}from"./render.js";import{ApiError as T}from"../api/index.js";let f=!1,i;const _=256*1024;function W(e){const t=process.env[m];i=t===void 0||t===""?void 0:{path:e,jsonl:[]}}n(W,"beginPreview");function d(e){const t=process.env[m];if(t===void 0||t==="")return;const s=`${JSON.stringify({path:i?.path??"",...e})}
2
+ `;try{if((E(t,{throwIfNoEntry:!1})?.size??0)+Buffer.byteLength(s,"utf8")>_)return;w(t,s,"utf8")}catch{}}n(d,"publishPreview");function $(e){i!==void 0&&(e!=null?d({result:e}):(i.jsonl.length>0||i.error!==void 0)&&d({...i.jsonl.length>0?{jsonl:i.jsonl}:{},...i.error===void 0?{}:{error:i.error}}))}n($,"publishPreviewResult");function y(e){i?.jsonl.push(e)}n(y,"recordPreviewLine");function B(e){try{const t=JSON.parse(e);t!==null&&typeof t=="object"&&!Array.isArray(t)&&y(t)}catch{}}n(B,"recordPreviewJsonLine");function F(e){i!==void 0&&(i.error=e)}n(F,"recordPreviewError");function G(e){f=e}n(G,"setJsonOutput");function q(){return f}n(q,"isJsonOutput");class h extends a{static{n(this,"InputError")}payload;constructor(t,s=c.USAGE){super(t.error,t.message,s,{...t}),this.name="InputError",this.payload=t}}async function D(){if(process.stdin.isTTY)return"";const e=[];for await(const t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8")}n(D,"readStdinRaw");async function K(e=200){return process.stdin.isTTY?"":await new Promise(t=>{const s=[];let o=!1;const r=n(()=>{o||(o=!0,clearTimeout(g),process.stdin.removeListener("data",u),process.stdin.removeListener("end",p),process.stdin.removeListener("error",l),process.stdin.pause(),t(Buffer.concat(s).toString("utf8")))},"finish"),u=n(x=>s.push(x),"onData"),p=n(()=>r(),"onEnd"),l=n(()=>r(),"onError"),g=setTimeout(r,e);process.stdin.on("data",u),process.stdin.on("end",p),process.stdin.on("error",l),process.stdin.resume()})}n(K,"peekStdinRaw");function V(e){process.stdout.write(JSON.stringify(e,null,2)+`
3
+ `)}n(V,"emit");function Y(e){y(e),process.stdout.write(JSON.stringify(e)+`
4
+ `)}n(Y,"emitLine");function M(e){return new Promise(t=>{let s=!1;const o=n(u=>{u.code==="EPIPE"&&r(!1)},"onErr"),r=n(u=>{s||(s=!0,process.stdout.off("error",o),t(u))},"finish");process.stdout.on("error",o);try{process.stdout.write(e,u=>r(u==null))}catch{r(!1)}})}n(M,"writeStdout");function z(e){process.stderr.write(e+`
5
+ `)}n(z,"diag");function O(e){if(e instanceof h)return e.payload;const t=e.details!==void 0?e.details:{},s=t.primaryCompleted===!0&&t.result!==null&&typeof t.result=="object"&&!Array.isArray(t.result)?N(t.result):void 0,o=t.next!==void 0?t.next:"Inspect the error and adjust the call. See -h for the schema.",r={error:e.code,message:e.message,received:t.received,field:t.field,...typeof t.http_status=="number"?{http_status:t.http_status}:{}};return s===void 0?{...r,next:o}:{...r,primaryCompleted:!0,result:s,next:o}}n(O,"payloadOf");function N(e){const t=new WeakSet;try{const s=JSON.stringify(e,(o,r)=>{if(typeof r=="bigint")return{$crtrType:"bigint",value:r.toString()};if(typeof r=="number"&&!Number.isFinite(r))return{$crtrType:"number",value:String(r)};if(typeof r>"u"||typeof r=="function"||typeof r=="symbol")return{$crtrType:typeof r};if(r!==null&&typeof r=="object"){if(t.has(r))return{$crtrType:"circular"};t.add(r)}return r});if(s!==void 0){const o=JSON.parse(s);if(o!==null&&typeof o=="object"&&!Array.isArray(o))return o}}catch{}return{$crtrType:"unavailable",message:"The completed primary result could not be represented as JSON."}}n(N,"jsonSafeResult");const P={400:"invalid_request",404:"not_found",409:"conflict",422:"unprocessable",503:"daemon_unavailable"};function R(e,t){if(e.code==="daemon_restarting")return new a("daemon_restarting",e.message,c.NETWORK,{next:"crtrd is now on the new generation \u2014 retry the command."});if(e.code==="layout_migration_required")return new a("layout_migration_required",e.message,c.NETWORK,{next:"Run `crtr sys migrate` while the runtime is offline, then restart it."});if(e.status===503||e.code==="daemon_unavailable")return new a("daemon_unavailable",e.message,c.NETWORK,{next:"Start it with `crtr sys daemon start`, then retry."});const s=e.details,o=s&&typeof s.error=="string"&&typeof s.message=="string"&&typeof s.next=="string"?s:{error:P[e.status]??e.code,message:e.message,next:t??(e.status>=500?"This is a crtr bug, not a bad call. Retry; if it persists, report it (the daemon log holds the full cause).":e.status===404?"List nodes with `crtr node inspect list`.":"Inspect the error and adjust the call. See -h for the schema.")};return new h(o,A(o.error,e.status))}n(R,"apiErrorToCliError");function A(e,t){return e==="not_found"||t===404?c.NOT_FOUND:e==="ambiguous"?c.AMBIGUOUS:c.USAGE}n(A,"exitForCliCode");function j(e){if(e instanceof T){j(R(e));return}if(e instanceof a){const o=O(e);i!==void 0&&d({error:o});const r=f?JSON.stringify(o,null,2):b(o);process.stdout.write(r+`
6
6
  `),process.exitCode=e.exitCode;return}const t=e,s=t!=null&&typeof t.message=="string"?t.message:String(e);process.stderr.write(JSON.stringify({error:"internal",message:s,next:"This is a crtr bug, not a bad call. Retry; if it persists, report it."},null,2)+`
7
- `),process.exitCode=c.GENERAL}n(R,"handle");export{h as InputError,_ as PREVIEW_RESULT_MAX_BYTES,A as apiErrorToCliError,$ as beginPreview,z as diag,K as emit,M as emitLine,R as handle,D as isJsonOutput,Y as peekStdinRaw,B as publishPreviewResult,V as readStdinRaw,F as recordPreviewError,W as recordPreviewJsonLine,y as recordPreviewLine,G as setJsonOutput,q as writeStdout};
7
+ `),process.exitCode=c.GENERAL}n(j,"handle");export{h as InputError,_ as PREVIEW_RESULT_MAX_BYTES,R as apiErrorToCliError,W as beginPreview,z as diag,V as emit,Y as emitLine,j as handle,q as isJsonOutput,K as peekStdinRaw,$ as publishPreviewResult,D as readStdinRaw,F as recordPreviewError,B as recordPreviewJsonLine,y as recordPreviewLine,G as setJsonOutput,M as writeStdout};
@@ -1,6 +1,6 @@
1
1
  import type { BindingDefinition, SafetyRequirement } from './types.js';
2
2
  import type { AttachBindingId, AttachMenuBindingId } from './attach-control.js';
3
- type TmuxMenuAction = 'open' | 'attach' | 'show' | 'view-settings' | 'provider-options' | 'fold-tools' | 'metadata' | 'promote' | 'demote-mode' | 'resume' | 'fork' | 'demote' | 'make-resident' | 'detach' | 'close-subtree' | 'background-bash' | 'file-review' | 'pin' | 'reload-viewer' | 'recap' | 'context' | 'context-admin' | 'providers' | 'plugins' | 'graph' | 'focus-manager' | 'copy-id' | 'issues';
3
+ type TmuxMenuAction = 'open' | 'attach' | 'show' | 'view-settings' | 'provider-options' | 'fold-tools' | 'metadata' | 'promote' | 'demote-mode' | 'resume' | 'fork' | 'demote' | 'make-resident' | 'detach' | 'close-subtree' | 'background-bash' | 'file-review' | 'pin' | 'reload-viewer' | 'recap' | 'context' | 'context-admin' | 'providers' | 'plugins' | 'analytics' | 'graph' | 'focus-manager' | 'copy-id' | 'issues';
4
4
  type TmuxMenuEntryAction = Exclude<TmuxMenuAction, 'open' | 'attach'> | `issue.${'idea' | 'bug'}`;
5
5
  type GraphAction = 'down' | 'up' | 'first' | 'last' | 'collapse-or-manager' | 'expand-or-child' | 'focus' | 'revive' | 'focus-manager' | 'close-subtree' | 'dismiss';
6
6
  type BrowseAction = 'quit' | 'down' | 'up' | 'first' | 'last' | 'expand-or-child' | 'collapse-or-parent' | 'toggle-fold' | 'tab-next' | 'tab-previous' | `tab.${1 | 2 | 3 | 4 | 5}` | 'close-subtree' | 'confirm-close' | 'sort' | 'scope' | 'profile' | 'residents' | 'preview' | 'report' | 'pin' | 'search' | 'revive-now' | 'focus' | 'focus-background' | 'yank-id';
@@ -1 +1 @@
1
- var g=Object.defineProperty;var i=(t,o)=>g(t,"name",{value:o,configurable:!0});function b(t,o,s,c,p,l,d,u,m){return Object.freeze({id:t,group:o,name:s,description:c,defaults:Object.freeze([...p]),inputKind:l,contexts:Object.freeze([...d]),...u===void 0?{}:{safety:u},...m===void 0?{}:{pair:Object.freeze({...m})}})}i(b,"binding");const e=b;function r(t,o,s,c,p){const l=`crtr.tmux.menu.${t}`,d=`crtr.tmux.menu-global.${t}`;return[e(l,"Global tmux",o,s,c,"tmux-menu-selector",p,void 0,{field:"menu",pairedId:d}),e(d,"Global tmux",o,s,[],"tmux-global-action",["tmux.root"],void 0,{field:"global",pairedId:l})]}i(r,"menuEntry");function n(t,o,s,c,p,l){return[e(t,"Attach",s,c,p,"tmux-menu-selector",["tmux.menu.attach"],void 0,{field:"menu",pairedId:o}),e(o,"Attach",s,c,l,"host-global",a,void 0,{field:"direct",pairedId:t})]}i(n,"attachEntry");const a=["attach","graph","graph.confirm"],f=["setup.login","setup.list","setup.input","setup.keybindings","setup.keybindings.edit","setup.keybindings.filter","setup.models"],h=["setup.login","setup.list","setup.keybindings","setup.models"],w=Object.freeze([e("crtr.tmux.menu.open","Global tmux","Open crouter menu","Open the crouter action menu.",["alt+c"],"host-global",["tmux.root"]),e("crtr.tmux.menu.attach","Global tmux","Attach actions","Open the attach-viewer action submenu.",["a"],"tmux-menu-selector",["tmux.menu"]),...r("promote","Promote to orchestrator","Promote the focused node to orchestrator \u2014 it holds a roadmap and delegates.",["o"],["tmux.menu"]),...r("demote-mode","Demote to base node","Demote the focused orchestrator back to a base node \u2014 hands-on again in its own window, no roadmap to drive.",["shift+o"],["tmux.menu"]),...r("resume","Find node","Open the canvas navigator and go to the chosen node.",["/"],["tmux.menu"]),...r("fork","Fork node","Fork the focused node into an independent idle root.",["f"],["tmux.menu"]),...r("demote","Demote to terminal","Demote the focused node to terminal \u2014 it keeps running, owes a final up the spine, and reaps when done.",["d"],["tmux.menu"]),...r("make-resident","Make resident","Flip the focused node to resident \u2014 interactable, never forced to submit a final, and wakeable while attached or awaiting something live.",["shift+r"],["tmux.menu"]),...r("detach","Demote and close viewer","Demote the focused node and close its viewer; its broker keeps running off-screen.",["shift+d"],["tmux.menu"]),...r("close-subtree","Close subtree","Close the focused node and its subtree.",["x"],["tmux.menu"]),...r("background-bash","Background running bash","Hand the focused node\u2019s running bash command to its background job system.",["b"],["tmux.menu"]),...r("file-review","Review a file","Open a line-anchored review of a file named in the transcript.",["v"],["tmux.menu"]),...r("pin","Pin conversation","Pin or unpin this conversation in the canvas navigator.",["p"],["tmux.menu"]),...r("show","Inspect node","Open the focused node\u2019s inspection menu.",["i"],["tmux.menu"]),...r("view-settings","Display settings","Open the viewer display-settings menu.",["z"],["tmux.menu"]),...r("fold-tools","Fold finished tool calls","Fold every finished tool call in the transcript to its single call line.",["f"],["tmux.menu.view-settings"]),...r("metadata","Show metadata","Show the focused node\u2019s metadata dossier.",["m"],["tmux.menu.show"]),...r("context","Browse context","Browse the focused node context.",["c"],["tmux.menu.show"]),...r("providers","Open settings","Open the crouter settings panel.",[","],["tmux.menu"]),...r("provider-options","Provider options","Open provider options \u2014 how an authenticated provider serves your turns, including Codex fast mode.",["."],["tmux.menu"]),...r("plugins","Browse plugins","Open the crouter plugin browser.",["l"],["tmux.menu"]),...r("context-admin","Context surface","Open the context surface: what memory each event delivers, and the surfaces, gates, and caps that decide it.",["shift+c"],["tmux.menu"]),...r("graph","Canvas graph","Open the canvas graph.",["g"],["tmux.menu"]),...r("focus-manager","Go to manager","Focus this node\u2019s manager.",["h"],["tmux.menu"]),...r("copy-id","Copy node id","Copy the focused node id to the system clipboard.",["y"],["tmux.menu"]),...r("reload-viewer","Reload viewer","Respawn this pane\u2019s viewer onto the current runtime generation.",["r"],["tmux.menu"]),...r("recap","Generate recap","Generate the focused node\u2019s Goal and State recap and refresh its generated title.",["s"],["tmux.menu"]),...r("issues","Open create menu","Open the create submenu.",["c"],["tmux.menu"]),...r("issue.idea","Create idea","Create an idea issue.",["i"],["tmux.menu.issue"]),...r("issue.bug","Create bug","Create a bug issue.",["b"],["tmux.menu.issue"]),e("crtr.tmux.node.next","Global tmux","Next node","Focus the next canvas node.",["alt+]"],"host-global",["tmux.root"]),e("crtr.tmux.node.previous","Global tmux","Previous node","Focus the previous canvas node.",["alt+["],"host-global",["tmux.root"]),e("crtr.tmux.inbox.toggle","Global tmux","Toggle inbox","Open or close the human inbox in the focused viewer.",["alt+i"],"host-global",["tmux.root"]),...n("crtr.tmux.menu.attach.detach","crtr.attach.detach","Detach","Detach from the node.",["d"],["ctrl+d"]),...n("crtr.tmux.menu.attach.clear-or-detach","crtr.attach.clear-or-detach","Clear input (cancel agent on repeat)","Clear the input; press again within a second to cancel the running agent turn. Detach lives on its own binding.",["c"],["ctrl+c"]),...n("crtr.tmux.menu.attach.graph.toggle","crtr.attach.graph.toggle","Toggle graph","Open or close the graph overlay.",["g"],["alt+g"]),...n("crtr.tmux.menu.attach.help.toggle","crtr.attach.help.toggle","Help","Open the attach help overlay.",["?"],["alt+shift+k"]),...n("crtr.tmux.menu.attach.inbox.toggle","crtr.attach.inbox.toggle","Toggle inbox","Open or close the human inbox surface in this viewer.",["i"],[]),...n("crtr.tmux.menu.attach.inbox-strip","crtr.attach.inbox-strip","Pending requests","Jump to the pending human-request strip at the top of the pane.",["u"],["alt+u"]),...n("crtr.tmux.menu.attach.model-ladder.next","crtr.attach.model-ladder.next","Next model","Move to the next model ladder rung.",["]"],["alt+m"]),...n("crtr.tmux.menu.attach.model-ladder.previous","crtr.attach.model-ladder.previous","Previous model","Move to the previous model ladder rung.",["["],["alt+shift+m"]),...n("crtr.tmux.menu.attach.command.inspect","crtr.attach.command.inspect","Inspect loaded command","Open the loaded slash command\u2019s expanded prompt.",["h"],["alt+shift+h"]),...n("crtr.tmux.menu.attach.file-review","crtr.attach.file-review","Review a file","Open a line-anchored review of a file named in the transcript.",[],["alt+shift+r"]),...n("crtr.tmux.menu.attach.profile-files","crtr.attach.profile-files","Search profile files","Fuzzy-match path segments across the node family\u2019s working directories, their context and reports directories, profile projects and memory, and ancestor crouter memory stores; Ctrl+Y copies a selected path.",["f"],["ctrl+f"]),...n("crtr.tmux.menu.attach.search","crtr.attach.search","Search transcript","Search the transcript as it is currently displayed \u2014 folded tool output is not searched until it is unfolded.",["/"],["alt+/"]),...n("crtr.tmux.menu.attach.whip","crtr.attach.whip","Whip agent","Interrupt the agent and send a playful command.",["w"],[]),e("crtr.attach.scroll.up","Attach","Scroll up","Scroll the transcript one line up.",["shift+up"],"terminal",a),e("crtr.attach.scroll.down","Attach","Scroll down","Scroll the transcript one line down.",["shift+down"],"terminal",a),e("crtr.attach.scroll.page-up","Attach","Scroll page up","Scroll the transcript one page up.",["pageup"],"terminal",a),e("crtr.attach.scroll.page-down","Attach","Scroll page down","Scroll the transcript one page down.",["pagedown"],"terminal",a),e("crtr.attach.scroll.live","Attach","Return to live","Return the transcript to the live bottom.",["shift+end"],"terminal",a),e("crtr.attach.mouse.toggle","Attach","Toggle mouse wheel scrolling","Toggle mouse wheel scrolling on or off.",["alt+shift+o"],"terminal",a),e("crtr.attach.copy.message","Attach","Copy visible message","Copy the newest message visible in the transcript viewport.",["alt+shift+y"],"terminal",a),e("crtr.attach.search.next","Attach","Next match","Move to the next transcript search match.",["n"],"terminal",["attach.search"]),e("crtr.attach.search.previous","Attach","Previous match","Move to the previous transcript search match.",["shift+n"],"terminal",["attach.search"]),e("crtr.attach.search.edit","Attach","Edit query","Return to editing the transcript search query.",["/"],"terminal",["attach.search"]),e("crtr.attach.search.close","Attach","Close search","Leave transcript search and clear its highlights.",["escape"],"terminal",["attach.search"],"dismiss-modal"),e("crtr.graph.down","GRAPH","Move down","Move to the next graph row.",["j"],"terminal",["graph"]),e("crtr.graph.up","GRAPH","Move up","Move to the previous graph row.",["k"],"terminal",["graph"]),e("crtr.graph.first","GRAPH","First row","Move to the first graph row.",["g"],"terminal",["graph"]),e("crtr.graph.last","GRAPH","Last row","Move to the last graph row.",["shift+g"],"terminal",["graph"]),e("crtr.graph.collapse-or-manager","GRAPH","Collapse or manager","Collapse a node or move to its manager.",["h"],"terminal",["graph"]),e("crtr.graph.expand-or-child","GRAPH","Expand or child","Expand a node or move to its child.",["l"],"terminal",["graph"]),e("crtr.graph.focus","GRAPH","Focus node","Focus the selected node.",["enter"],"terminal",["graph"]),e("crtr.graph.revive","GRAPH","Revive node","Revive and open the selected dormant node.",["r"],"terminal",["graph"]),e("crtr.graph.focus-manager","GRAPH","Focus manager","Focus the selected node manager.",["m"],"terminal",["graph"]),e("crtr.graph.close-subtree","GRAPH","Close subtree","Ask to close the selected subtree.",["x"],"terminal",["graph"]),e("crtr.graph.dismiss","GRAPH","Dismiss graph","Close the graph overlay.",["escape"],"terminal",["graph"],"dismiss-modal"),e("crtr.graph.confirm.accept","GRAPH","Confirm close","Confirm closing the selected subtree.",["y"],"terminal",["graph.confirm"]),e("crtr.graph.confirm.cancel","GRAPH","Cancel close","Cancel closing the selected subtree.",["n","escape"],"terminal",["graph.confirm"],"dismiss-modal"),e("crtr.inspector.force-quit","Inspector","Force quit Inspector","Immediately leave the Inspector.",["ctrl+c"],"host-global",["inspector"],"leave-screen"),e("crtr.inspector.down","Inspector","Move down","Move the Inspector selection or scroll cursor down.",["j","down"],"terminal",["inspector"]),e("crtr.inspector.up","Inspector","Move up","Move the Inspector selection or scroll cursor up.",["k","up"],"terminal",["inspector"]),e("crtr.inspector.section-next","Inspector","Next section","Move to the next Inspector section.",["tab"],"terminal",["inspector"]),e("crtr.inspector.section-prev","Inspector","Previous section","Move to the previous Inspector section.",["shift+tab"],"terminal",["inspector"]),e("crtr.inspector.page-down","Inspector","Page down","Scroll the Inspector detail body down.",["ctrl+d","pagedown"],"terminal",["inspector"]),e("crtr.inspector.page-up","Inspector","Page up","Scroll the Inspector detail body up.",["ctrl+u","pageup"],"terminal",["inspector"]),e("crtr.inspector.toggle-detail","Inspector","Toggle item detail","Expand or collapse the selected cron or background job.",["enter"],"terminal",["inspector"]),e("crtr.inspector.cancel-item","Inspector","Cancel selected item","Arm cancellation for the selected cron, or stopping for the selected background job.",["x"],"terminal",["inspector"]),e("crtr.inspector.open-log","Inspector","Open job log","Follow the selected background job\u2019s log in a new tmux window.",["o"],"terminal",["inspector"]),e("crtr.inspector.confirm","Inspector","Confirm action","Confirm the armed Inspector action.",["y"],"terminal",["inspector"]),e("crtr.inspector.dismiss","Inspector","Dismiss action","Dismiss an Inspector confirmation or banner.",["escape"],"terminal",["inspector"],"dismiss-modal"),e("crtr.inspector.retarget","Inspector","Retarget","Inspect the selected cron anchor or creator node.",["t"],"terminal",["inspector"]),e("crtr.inspector.refresh","Inspector","Refresh","Refresh the Inspector now.",["g","r"],"terminal",["inspector"]),e("crtr.inspector.quit","Inspector","Quit","Leave the Inspector.",["q"],"terminal",["inspector"],"leave-screen"),...v(),...x(),...k()]);function v(){const t="browse";return[e("crtr.browse.quit","Browse and pickers","Quit browse","Leave canvas browse.",["q","escape","ctrl+c"],"terminal",[t],"leave-screen"),e("crtr.browse.down","Browse and pickers","Move down","Move to the next row.",["j","down"],"terminal",[t]),e("crtr.browse.up","Browse and pickers","Move up","Move to the previous row.",["k","up"],"terminal",[t]),e("crtr.browse.first","Browse and pickers","First row","Move to the first row.",["g"],"terminal",[t]),e("crtr.browse.last","Browse and pickers","Last row","Move to the last row.",["shift+g"],"terminal",[t]),e("crtr.browse.expand-or-child","Browse and pickers","Expand or child","Expand a row or move to its child.",["l","right"],"terminal",[t]),e("crtr.browse.collapse-or-parent","Browse and pickers","Collapse or parent","Collapse a row or move to its parent.",["h","left"],"terminal",[t]),e("crtr.browse.toggle-fold","Browse and pickers","Toggle fold","Toggle the selected fold.",["space"],"terminal",[t]),e("crtr.browse.tab-next","Browse and pickers","Next tab","Select the next browse tab.",["tab","]"],"terminal",[t]),e("crtr.browse.tab-previous","Browse and pickers","Previous tab","Select the previous browse tab.",["shift+tab","["],"terminal",[t]),...[1,2,3,4,5].map(o=>e(`crtr.browse.tab.${o}`,"Browse and pickers",`Tab ${o}`,`Select browse tab ${o}.`,[`${o}`],"terminal",[t])),e("crtr.browse.close-subtree","Browse and pickers","Close subtree","Ask to close the selected subtree.",["x"],"terminal",[t]),e("crtr.browse.confirm-close","Browse and pickers","Confirm close","Confirm closing the selected subtree.",["y"],"terminal",["browse.confirm"]),e("crtr.browse.sort","Browse and pickers","Change sort","Change the browse sort.",["s"],"terminal",[t]),e("crtr.browse.scope","Browse and pickers","Change scope","Toggle the browse cwd scope.",["c"],"terminal",[t]),e("crtr.browse.profile","Browse and pickers","Toggle profile","Toggle the browse profile scope.",["shift+p"],"terminal",[t]),e("crtr.browse.residents","Browse and pickers","Toggle residents","Toggle resident display.",["r"],"terminal",[t]),e("crtr.browse.preview","Browse and pickers","Toggle preview","Toggle the preview panel.",["v"],"terminal",[t]),e("crtr.browse.report","Browse and pickers","Toggle report","Swap the preview panel between the conversation and the node's newest report.",["shift+v"],"terminal",[t]),e("crtr.browse.pin","Browse and pickers","Pin node","Star or unstar the selected node.",["p"],"terminal",[t]),e("crtr.browse.search","Browse and pickers","Search","Open browse search.",["/"],"terminal",[t]),e("crtr.browse.revive-now","Browse and pickers","Revive now","Revive the selected node now.",["shift+k"],"terminal",[t]),e("crtr.browse.focus","Browse and pickers","Focus node","Focus the selected node.",["enter","o"],"terminal",[t]),e("crtr.browse.focus-background","Browse and pickers","Focus node (keep browsing)","Focus the selected node without leaving the navigator.",["shift+o"],"terminal",[t]),e("crtr.browse.yank-id","Browse and pickers","Yank node id","Copy the selected node id to the system clipboard.",["y"],"terminal",[t]),e("crtr.browse.search.cancel","Browse and pickers","Cancel search","Cancel browse search.",["escape"],"terminal",["browse.search"],"dismiss-modal"),e("crtr.browse.search.commit","Browse and pickers","Commit search","Apply browse search.",["enter"],"terminal",["browse.search"]),e("crtr.browse.search.delete","Browse and pickers","Delete search text","Delete the previous search character.",["backspace"],"terminal",["browse.search"]),e("crtr.browse.search.quit","Browse and pickers","Quit browse","Leave canvas browse from search.",["ctrl+c"],"terminal",["browse.search"],"leave-screen")]}i(v,"browseBindings");function x(){const t="profile.menu",o="profile.search";return[e("crtr.profile.menu.up","Profiles","Move up","Move to the previous profile.",["k","up"],"terminal",[t]),e("crtr.profile.menu.down","Profiles","Move down","Move to the next profile.",["j","down"],"terminal",[t]),e("crtr.profile.menu.select","Profiles","Select profile","Select the highlighted profile.",["enter"],"terminal",[t]),e("crtr.profile.menu.accept-default","Profiles","Accept default","Accept the default profile.",["escape"],"terminal",[t],"leave-screen"),e("crtr.profile.menu.abort","Profiles","Abort","Leave profile selection.",["ctrl+c"],"terminal",[t],"leave-screen"),...[1,2,3,4,5,6,7,8,9].map(s=>e(`crtr.profile.menu.slot.${s}`,"Profiles",`Profile slot ${s}`,`Select profile slot ${s}.`,[`${s}`],"terminal",[t])),e("crtr.profile.menu.create","Profiles","Create profile","Create a profile.",["c"],"terminal",[t]),e("crtr.profile.menu.search-existing","Profiles","Search profiles","Search existing profiles.",["s"],"terminal",[t]),e("crtr.profile.menu.use-root","Profiles","Use root profile","Use the root profile.",["r"],"terminal",[t]),e("crtr.profile.menu.set-default","Profiles","Set default","Set the selected profile as default.",["d"],"terminal",[t]),e("crtr.profile.menu.add-directory","Profiles","Add directory","Add a directory to the profile.",["a"],"terminal",[t]),e("crtr.profile.menu.unpin","Profiles","Unpin directory","Unpin the selected directory.",["u"],"terminal",[t]),e("crtr.profile.menu.manage","Profiles","Manage profiles","Open the profiles settings page in a popup.",["v"],"terminal",[t]),e("crtr.profile.search.up","Profiles","Move up","Move to the previous search result.",["up","ctrl+p"],"terminal",[o]),e("crtr.profile.search.down","Profiles","Move down","Move to the next search result.",["down","ctrl+n"],"terminal",[o]),e("crtr.profile.search.pick","Profiles","Pick profile","Pick the highlighted profile.",["enter"],"terminal",[o]),e("crtr.profile.search.back","Profiles","Back","Return to profile selection.",["escape"],"terminal",[o],"leave-screen"),e("crtr.profile.search.delete","Profiles","Delete filter text","Delete the previous filter character.",["backspace"],"terminal",[o]),e("crtr.profile.search.abort","Profiles","Abort","Leave profile search.",["ctrl+c"],"terminal",[o],"leave-screen")]}i(x,"profileBindings");function k(){return[e("crtr.setup.cancel","Setup","Cancel setup","Leave the setup wizard.",["q","ctrl+c","ctrl+d"],"terminal",f,"leave-screen"),e("crtr.setup.tab-next","Setup","Next tab","Select the next setup tab.",["tab","right"],"terminal",h),e("crtr.setup.tab-previous","Setup","Previous tab","Select the previous setup tab.",["shift+tab","left"],"terminal",h),e("crtr.setup.open","Setup","Open","Open the selected setup item.",["enter"],"terminal",["setup.login"]),e("crtr.setup.list-down","Setup","Move down","Move to the next setup item.",["j","down"],"terminal",["setup.list","setup.models","setup.models.dimension-picker","setup.models.route-form"]),e("crtr.setup.list-up","Setup","Move up","Move to the previous setup item.",["k","up"],"terminal",["setup.list","setup.models","setup.models.dimension-picker","setup.models.route-form"]),e("crtr.setup.toggle","Setup","Toggle","Toggle the selected setup item.",["space"],"terminal",["setup.list","setup.keybindings"]),e("crtr.setup.details","Setup","Show details","Show details for the selected item.",["?"],"terminal",["setup.list"]),e("crtr.setup.advance","Setup","Advance","Advance the setup flow.",["enter"],"terminal",["setup.list"]),e("crtr.setup.confirm.accept","Setup","Confirm","Accept the setup confirmation.",["y","enter"],"terminal",["setup.confirm","setup.models.confirm"]),e("crtr.setup.confirm.back","Setup","Go back","Cancel the setup confirmation.",["n","escape","q"],"terminal",["setup.confirm","setup.models.confirm"],"dismiss-modal"),e("crtr.setup.keybindings.edit","Setup","Edit binding","Edit the selected binding.",["enter"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.commit-edit","Setup","Commit edit","Commit the active binding edit.",["enter"],"terminal",["setup.keybindings.edit"]),e("crtr.setup.keybindings.cancel-edit","Setup","Cancel edit","Cancel the active binding edit.",["escape"],"terminal",["setup.keybindings.edit"],"dismiss-modal"),e("crtr.setup.keybindings.unbind","Setup","Unbind","Disable the selected binding.",["delete"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.reset-row","Setup","Reset binding","Reset the selected binding.",["r"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.reset-all","Setup","Reset all bindings","Reset all bindings to defaults.",["shift+r"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.save","Setup","Save bindings","Save keybinding changes.",["s"],"terminal",["setup.keybindings"],"save-keybindings"),e("crtr.setup.keybindings.discard","Setup","Discard changes","Discard keybinding changes.",["escape"],"terminal",["setup.keybindings"],"leave-screen"),e("crtr.setup.keybindings.page-up","Setup","Page up","Move up one keybinding page.",["pageup"],"terminal",["setup.keybindings","setup.keybindings.edit"]),e("crtr.setup.keybindings.page-down","Setup","Page down","Move down one keybinding page.",["pagedown"],"terminal",["setup.keybindings","setup.keybindings.edit"]),e("crtr.setup.keybindings.filter","Setup","Filter bindings","Open the keybinding filter.",["/"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.filter-delete","Setup","Delete filter text","Delete the previous filter character.",["backspace"],"terminal",["setup.keybindings.filter"]),e("crtr.setup.keybindings.filter-clear","Setup","Clear filter","Clear the keybinding filter.",["escape"],"terminal",["setup.keybindings.filter"],"dismiss-modal"),e("crtr.setup.cell-previous","Setup","Previous field","Select the previous field or setup table cell.",["h"],"terminal",["setup.models","setup.keybindings"]),e("crtr.setup.cell-next","Setup","Next field","Select the next field or setup table cell.",["l"],"terminal",["setup.models","setup.keybindings"]),e("crtr.setup.models.open","Setup","Edit model","Edit the selected model cell or route field.",["enter"],"terminal",["setup.models","setup.models.route-form"]),e("crtr.setup.models.scope-next","Setup","Next model config scope","Edit the next applicable user, profile, or project config.",["s"],"terminal",["setup.models"]),e("crtr.setup.models.commit","Setup","Commit pick","Commit the provider, strength, model, or thinking-level pick.",["enter"],"terminal",["setup.models.picker","setup.models.dimension-picker"]),e("crtr.setup.models.cancel","Setup","Cancel pick","Cancel the model picker or route form.",["escape"],"terminal",["setup.models.picker","setup.models.dimension-picker","setup.models.route-form"],"dismiss-modal")]}i(k,"setupBindings");const S=new Set(w.map(t=>t.id));function C(t){return t.contexts.includes("attach")&&(t.inputKind==="terminal"||t.inputKind==="host-global")}i(C,"isAttachPaneBinding");const P=Object.freeze([{context:"graph",capability:"dismiss-modal"},{context:"graph.confirm",capability:"dismiss-modal"},{context:"inspector",capability:"leave-screen"},{context:"inspector",capability:"dismiss-modal"},{context:"attach.search",capability:"dismiss-modal"},{context:"browse",capability:"leave-screen"},{context:"browse.search",capability:"dismiss-modal"},{context:"profile.menu",capability:"leave-screen"},{context:"profile.search",capability:"leave-screen"},{context:"setup.login",capability:"leave-screen"},{context:"setup.list",capability:"leave-screen"},{context:"setup.input",capability:"leave-screen"},{context:"setup.confirm",capability:"dismiss-modal"},{context:"setup.keybindings",capability:"leave-screen"},{context:"setup.keybindings",capability:"save-keybindings"},{context:"setup.keybindings.edit",capability:"dismiss-modal"},{context:"setup.keybindings.filter",capability:"dismiss-modal"},{context:"setup.models",capability:"leave-screen"},{context:"setup.models.picker",capability:"dismiss-modal"},{context:"setup.models.dimension-picker",capability:"dismiss-modal"},{context:"setup.models.route-form",capability:"dismiss-modal"},{context:"setup.models.confirm",capability:"dismiss-modal"}]);export{w as BINDING_CATALOG,S as BINDING_IDS,P as SAFETY_REQUIREMENTS,C as isAttachPaneBinding};
1
+ var g=Object.defineProperty;var i=(t,o)=>g(t,"name",{value:o,configurable:!0});function f(t,o,s,c,p,l,d,u,m){return Object.freeze({id:t,group:o,name:s,description:c,defaults:Object.freeze([...p]),inputKind:l,contexts:Object.freeze([...d]),...u===void 0?{}:{safety:u},...m===void 0?{}:{pair:Object.freeze({...m})}})}i(f,"binding");const e=f;function r(t,o,s,c,p){const l=`crtr.tmux.menu.${t}`,d=`crtr.tmux.menu-global.${t}`;return[e(l,"Global tmux",o,s,c,"tmux-menu-selector",p,void 0,{field:"menu",pairedId:d}),e(d,"Global tmux",o,s,[],"tmux-global-action",["tmux.root"],void 0,{field:"global",pairedId:l})]}i(r,"menuEntry");function n(t,o,s,c,p,l){return[e(t,"Attach",s,c,p,"tmux-menu-selector",["tmux.menu.attach"],void 0,{field:"menu",pairedId:o}),e(o,"Attach",s,c,l,"host-global",a,void 0,{field:"direct",pairedId:t})]}i(n,"attachEntry");const a=["attach","graph","graph.confirm"],b=["setup.login","setup.list","setup.input","setup.keybindings","setup.keybindings.edit","setup.keybindings.filter","setup.models"],h=["setup.login","setup.list","setup.keybindings","setup.models"],w=Object.freeze([e("crtr.tmux.menu.open","Global tmux","Open crouter menu","Open the crouter action menu.",["alt+c"],"host-global",["tmux.root"]),e("crtr.tmux.menu.attach","Global tmux","Attach actions","Open the attach-viewer action submenu.",["a"],"tmux-menu-selector",["tmux.menu"]),...r("promote","Promote to orchestrator","Promote the focused node to orchestrator \u2014 it holds a roadmap and delegates.",["o"],["tmux.menu"]),...r("demote-mode","Demote to base node","Demote the focused orchestrator back to a base node \u2014 hands-on again in its own window, no roadmap to drive.",["shift+o"],["tmux.menu"]),...r("resume","Find node","Open the canvas navigator and go to the chosen node.",["/"],["tmux.menu"]),...r("fork","Fork node","Fork the focused node into an independent idle root.",["f"],["tmux.menu"]),...r("demote","Demote to terminal","Demote the focused node to terminal \u2014 it keeps running, owes a final up the spine, and reaps when done.",["d"],["tmux.menu"]),...r("make-resident","Make resident","Flip the focused node to resident \u2014 interactable, never forced to submit a final, and wakeable while attached or awaiting something live.",["shift+r"],["tmux.menu"]),...r("detach","Demote and close viewer","Demote the focused node and close its viewer; its broker keeps running off-screen.",["shift+d"],["tmux.menu"]),...r("close-subtree","Close subtree","Close the focused node and its subtree.",["x"],["tmux.menu"]),...r("background-bash","Background running bash","Hand the focused node\u2019s running bash command to its background job system.",["b"],["tmux.menu"]),...r("file-review","Review a file","Open a line-anchored review of a file named in the transcript.",["v"],["tmux.menu"]),...r("pin","Pin conversation","Pin or unpin this conversation in the canvas navigator.",["p"],["tmux.menu"]),...r("show","Inspect node","Open the focused node\u2019s inspection menu.",["i"],["tmux.menu"]),...r("view-settings","Display settings","Open the viewer display-settings menu.",["z"],["tmux.menu"]),...r("fold-tools","Fold finished tool calls","Fold every finished tool call in the transcript to its single call line.",["f"],["tmux.menu.view-settings"]),...r("metadata","Show metadata","Show the focused node\u2019s metadata dossier.",["m"],["tmux.menu.show"]),...r("context","Browse context","Browse the focused node context.",["c"],["tmux.menu.show"]),...r("providers","Open settings","Open the crouter settings panel.",[","],["tmux.menu"]),...r("provider-options","Provider options","Open provider options \u2014 how an authenticated provider serves your turns, including Codex fast mode.",["."],["tmux.menu"]),...r("plugins","Browse plugins","Open the crouter plugin browser.",["l"],["tmux.menu"]),...r("analytics","Analytics","Open the Analytics page: how agents worked in the last 24 hours or 7 days.",["shift+a"],["tmux.menu"]),...r("context-admin","Context surface","Open the context surface: what memory each event delivers, and the surfaces, gates, and caps that decide it.",["shift+c"],["tmux.menu"]),...r("graph","Canvas graph","Open the canvas graph.",["g"],["tmux.menu"]),...r("focus-manager","Go to manager","Focus this node\u2019s manager.",["h"],["tmux.menu"]),...r("copy-id","Copy node id","Copy the focused node id to the system clipboard.",["y"],["tmux.menu"]),...r("reload-viewer","Reload viewer","Respawn this pane\u2019s viewer onto the current runtime generation.",["r"],["tmux.menu"]),...r("recap","Generate recap","Generate the focused node\u2019s Goal and State recap and refresh its generated title.",["s"],["tmux.menu"]),...r("issues","Open create menu","Open the create submenu.",["c"],["tmux.menu"]),...r("issue.idea","Create idea","Create an idea issue.",["i"],["tmux.menu.issue"]),...r("issue.bug","Create bug","Create a bug issue.",["b"],["tmux.menu.issue"]),e("crtr.tmux.node.next","Global tmux","Next node","Focus the next canvas node.",["alt+]"],"host-global",["tmux.root"]),e("crtr.tmux.node.previous","Global tmux","Previous node","Focus the previous canvas node.",["alt+["],"host-global",["tmux.root"]),e("crtr.tmux.inbox.toggle","Global tmux","Toggle inbox","Open or close the human inbox in the focused viewer.",["alt+i"],"host-global",["tmux.root"]),...n("crtr.tmux.menu.attach.detach","crtr.attach.detach","Detach","Detach from the node.",["d"],["ctrl+d"]),...n("crtr.tmux.menu.attach.clear-or-detach","crtr.attach.clear-or-detach","Clear input (cancel agent on repeat)","Clear the input; press again within a second to cancel the running agent turn. Detach lives on its own binding.",["c"],["ctrl+c"]),...n("crtr.tmux.menu.attach.graph.toggle","crtr.attach.graph.toggle","Toggle graph","Open or close the graph overlay.",["g"],["alt+g"]),...n("crtr.tmux.menu.attach.help.toggle","crtr.attach.help.toggle","Help","Open the attach help overlay.",["?"],["alt+shift+k"]),...n("crtr.tmux.menu.attach.inbox.toggle","crtr.attach.inbox.toggle","Toggle inbox","Open or close the human inbox surface in this viewer.",["i"],[]),...n("crtr.tmux.menu.attach.inbox-strip","crtr.attach.inbox-strip","Pending requests","Jump to the pending human-request strip at the top of the pane.",["u"],["alt+u"]),...n("crtr.tmux.menu.attach.model-ladder.next","crtr.attach.model-ladder.next","Next model","Move to the next model ladder rung.",["]"],["alt+m"]),...n("crtr.tmux.menu.attach.model-ladder.previous","crtr.attach.model-ladder.previous","Previous model","Move to the previous model ladder rung.",["["],["alt+shift+m"]),...n("crtr.tmux.menu.attach.command.inspect","crtr.attach.command.inspect","Inspect loaded command","Open the loaded slash command\u2019s expanded prompt.",["h"],["alt+shift+h"]),...n("crtr.tmux.menu.attach.file-review","crtr.attach.file-review","Review a file","Open a line-anchored review of a file named in the transcript.",[],["alt+shift+r"]),...n("crtr.tmux.menu.attach.profile-files","crtr.attach.profile-files","Search profile files","Fuzzy-match path segments across the node family\u2019s working directories, their context and reports directories, profile projects and memory, and ancestor crouter memory stores; Ctrl+Y copies a selected path.",["f"],["ctrl+f"]),...n("crtr.tmux.menu.attach.search","crtr.attach.search","Search transcript","Search the transcript as it is currently displayed \u2014 folded tool output is not searched until it is unfolded.",["/"],["alt+/"]),...n("crtr.tmux.menu.attach.whip","crtr.attach.whip","Whip agent","Interrupt the agent and send a playful command.",["w"],[]),e("crtr.attach.scroll.up","Attach","Scroll up","Scroll the transcript one line up.",["shift+up"],"terminal",a),e("crtr.attach.scroll.down","Attach","Scroll down","Scroll the transcript one line down.",["shift+down"],"terminal",a),e("crtr.attach.scroll.page-up","Attach","Scroll page up","Scroll the transcript one page up.",["pageup"],"terminal",a),e("crtr.attach.scroll.page-down","Attach","Scroll page down","Scroll the transcript one page down.",["pagedown"],"terminal",a),e("crtr.attach.scroll.live","Attach","Return to live","Return the transcript to the live bottom.",["shift+end"],"terminal",a),e("crtr.attach.mouse.toggle","Attach","Toggle mouse wheel scrolling","Toggle mouse wheel scrolling on or off.",["alt+shift+o"],"terminal",a),e("crtr.attach.copy.message","Attach","Copy visible message","Copy the newest message visible in the transcript viewport.",["alt+shift+y"],"terminal",a),e("crtr.attach.search.next","Attach","Next match","Move to the next transcript search match.",["n"],"terminal",["attach.search"]),e("crtr.attach.search.previous","Attach","Previous match","Move to the previous transcript search match.",["shift+n"],"terminal",["attach.search"]),e("crtr.attach.search.edit","Attach","Edit query","Return to editing the transcript search query.",["/"],"terminal",["attach.search"]),e("crtr.attach.search.close","Attach","Close search","Leave transcript search and clear its highlights.",["escape"],"terminal",["attach.search"],"dismiss-modal"),e("crtr.graph.down","GRAPH","Move down","Move to the next graph row.",["j"],"terminal",["graph"]),e("crtr.graph.up","GRAPH","Move up","Move to the previous graph row.",["k"],"terminal",["graph"]),e("crtr.graph.first","GRAPH","First row","Move to the first graph row.",["g"],"terminal",["graph"]),e("crtr.graph.last","GRAPH","Last row","Move to the last graph row.",["shift+g"],"terminal",["graph"]),e("crtr.graph.collapse-or-manager","GRAPH","Collapse or manager","Collapse a node or move to its manager.",["h"],"terminal",["graph"]),e("crtr.graph.expand-or-child","GRAPH","Expand or child","Expand a node or move to its child.",["l"],"terminal",["graph"]),e("crtr.graph.focus","GRAPH","Focus node","Focus the selected node.",["enter"],"terminal",["graph"]),e("crtr.graph.revive","GRAPH","Revive node","Revive and open the selected dormant node.",["r"],"terminal",["graph"]),e("crtr.graph.focus-manager","GRAPH","Focus manager","Focus the selected node manager.",["m"],"terminal",["graph"]),e("crtr.graph.close-subtree","GRAPH","Close subtree","Ask to close the selected subtree.",["x"],"terminal",["graph"]),e("crtr.graph.dismiss","GRAPH","Dismiss graph","Close the graph overlay.",["escape"],"terminal",["graph"],"dismiss-modal"),e("crtr.graph.confirm.accept","GRAPH","Confirm close","Confirm closing the selected subtree.",["y"],"terminal",["graph.confirm"]),e("crtr.graph.confirm.cancel","GRAPH","Cancel close","Cancel closing the selected subtree.",["n","escape"],"terminal",["graph.confirm"],"dismiss-modal"),e("crtr.inspector.force-quit","Inspector","Force quit Inspector","Immediately leave the Inspector.",["ctrl+c"],"host-global",["inspector"],"leave-screen"),e("crtr.inspector.down","Inspector","Move down","Move the Inspector selection or scroll cursor down.",["j","down"],"terminal",["inspector"]),e("crtr.inspector.up","Inspector","Move up","Move the Inspector selection or scroll cursor up.",["k","up"],"terminal",["inspector"]),e("crtr.inspector.section-next","Inspector","Next section","Move to the next Inspector section.",["tab"],"terminal",["inspector"]),e("crtr.inspector.section-prev","Inspector","Previous section","Move to the previous Inspector section.",["shift+tab"],"terminal",["inspector"]),e("crtr.inspector.page-down","Inspector","Page down","Scroll the Inspector detail body down.",["ctrl+d","pagedown"],"terminal",["inspector"]),e("crtr.inspector.page-up","Inspector","Page up","Scroll the Inspector detail body up.",["ctrl+u","pageup"],"terminal",["inspector"]),e("crtr.inspector.toggle-detail","Inspector","Toggle item detail","Expand or collapse the selected cron or background job.",["enter"],"terminal",["inspector"]),e("crtr.inspector.cancel-item","Inspector","Cancel selected item","Arm cancellation for the selected cron, or stopping for the selected background job.",["x"],"terminal",["inspector"]),e("crtr.inspector.open-log","Inspector","Open job log","Follow the selected background job\u2019s log in a new tmux window.",["o"],"terminal",["inspector"]),e("crtr.inspector.confirm","Inspector","Confirm action","Confirm the armed Inspector action.",["y"],"terminal",["inspector"]),e("crtr.inspector.dismiss","Inspector","Dismiss action","Dismiss an Inspector confirmation or banner.",["escape"],"terminal",["inspector"],"dismiss-modal"),e("crtr.inspector.retarget","Inspector","Retarget","Inspect the selected cron anchor or creator node.",["t"],"terminal",["inspector"]),e("crtr.inspector.refresh","Inspector","Refresh","Refresh the Inspector now.",["g","r"],"terminal",["inspector"]),e("crtr.inspector.quit","Inspector","Quit","Leave the Inspector.",["q"],"terminal",["inspector"],"leave-screen"),...v(),...x(),...k()]);function v(){const t="browse";return[e("crtr.browse.quit","Browse and pickers","Quit browse","Leave canvas browse.",["q","escape","ctrl+c"],"terminal",[t],"leave-screen"),e("crtr.browse.down","Browse and pickers","Move down","Move to the next row.",["j","down"],"terminal",[t]),e("crtr.browse.up","Browse and pickers","Move up","Move to the previous row.",["k","up"],"terminal",[t]),e("crtr.browse.first","Browse and pickers","First row","Move to the first row.",["g"],"terminal",[t]),e("crtr.browse.last","Browse and pickers","Last row","Move to the last row.",["shift+g"],"terminal",[t]),e("crtr.browse.expand-or-child","Browse and pickers","Expand or child","Expand a row or move to its child.",["l","right"],"terminal",[t]),e("crtr.browse.collapse-or-parent","Browse and pickers","Collapse or parent","Collapse a row or move to its parent.",["h","left"],"terminal",[t]),e("crtr.browse.toggle-fold","Browse and pickers","Toggle fold","Toggle the selected fold.",["space"],"terminal",[t]),e("crtr.browse.tab-next","Browse and pickers","Next tab","Select the next browse tab.",["tab","]"],"terminal",[t]),e("crtr.browse.tab-previous","Browse and pickers","Previous tab","Select the previous browse tab.",["shift+tab","["],"terminal",[t]),...[1,2,3,4,5].map(o=>e(`crtr.browse.tab.${o}`,"Browse and pickers",`Tab ${o}`,`Select browse tab ${o}.`,[`${o}`],"terminal",[t])),e("crtr.browse.close-subtree","Browse and pickers","Close subtree","Ask to close the selected subtree.",["x"],"terminal",[t]),e("crtr.browse.confirm-close","Browse and pickers","Confirm close","Confirm closing the selected subtree.",["y"],"terminal",["browse.confirm"]),e("crtr.browse.sort","Browse and pickers","Change sort","Change the browse sort.",["s"],"terminal",[t]),e("crtr.browse.scope","Browse and pickers","Change scope","Toggle the browse cwd scope.",["c"],"terminal",[t]),e("crtr.browse.profile","Browse and pickers","Toggle profile","Toggle the browse profile scope.",["shift+p"],"terminal",[t]),e("crtr.browse.residents","Browse and pickers","Toggle residents","Toggle resident display.",["r"],"terminal",[t]),e("crtr.browse.preview","Browse and pickers","Toggle preview","Toggle the preview panel.",["v"],"terminal",[t]),e("crtr.browse.report","Browse and pickers","Toggle report","Swap the preview panel between the conversation and the node's newest report.",["shift+v"],"terminal",[t]),e("crtr.browse.pin","Browse and pickers","Pin node","Star or unstar the selected node.",["p"],"terminal",[t]),e("crtr.browse.search","Browse and pickers","Search","Open browse search.",["/"],"terminal",[t]),e("crtr.browse.revive-now","Browse and pickers","Revive now","Revive the selected node now.",["shift+k"],"terminal",[t]),e("crtr.browse.focus","Browse and pickers","Focus node","Focus the selected node.",["enter","o"],"terminal",[t]),e("crtr.browse.focus-background","Browse and pickers","Focus node (keep browsing)","Focus the selected node without leaving the navigator.",["shift+o"],"terminal",[t]),e("crtr.browse.yank-id","Browse and pickers","Yank node id","Copy the selected node id to the system clipboard.",["y"],"terminal",[t]),e("crtr.browse.search.cancel","Browse and pickers","Cancel search","Cancel browse search.",["escape"],"terminal",["browse.search"],"dismiss-modal"),e("crtr.browse.search.commit","Browse and pickers","Commit search","Apply browse search.",["enter"],"terminal",["browse.search"]),e("crtr.browse.search.delete","Browse and pickers","Delete search text","Delete the previous search character.",["backspace"],"terminal",["browse.search"]),e("crtr.browse.search.quit","Browse and pickers","Quit browse","Leave canvas browse from search.",["ctrl+c"],"terminal",["browse.search"],"leave-screen")]}i(v,"browseBindings");function x(){const t="profile.menu",o="profile.search";return[e("crtr.profile.menu.up","Profiles","Move up","Move to the previous profile.",["k","up"],"terminal",[t]),e("crtr.profile.menu.down","Profiles","Move down","Move to the next profile.",["j","down"],"terminal",[t]),e("crtr.profile.menu.select","Profiles","Select profile","Select the highlighted profile.",["enter"],"terminal",[t]),e("crtr.profile.menu.accept-default","Profiles","Accept default","Accept the default profile.",["escape"],"terminal",[t],"leave-screen"),e("crtr.profile.menu.abort","Profiles","Abort","Leave profile selection.",["ctrl+c"],"terminal",[t],"leave-screen"),...[1,2,3,4,5,6,7,8,9].map(s=>e(`crtr.profile.menu.slot.${s}`,"Profiles",`Profile slot ${s}`,`Select profile slot ${s}.`,[`${s}`],"terminal",[t])),e("crtr.profile.menu.create","Profiles","Create profile","Create a profile.",["c"],"terminal",[t]),e("crtr.profile.menu.search-existing","Profiles","Search profiles","Search existing profiles.",["s"],"terminal",[t]),e("crtr.profile.menu.use-root","Profiles","Use root profile","Use the root profile.",["r"],"terminal",[t]),e("crtr.profile.menu.set-default","Profiles","Set default","Set the selected profile as default.",["d"],"terminal",[t]),e("crtr.profile.menu.add-directory","Profiles","Add directory","Add a directory to the profile.",["a"],"terminal",[t]),e("crtr.profile.menu.unpin","Profiles","Unpin directory","Unpin the selected directory.",["u"],"terminal",[t]),e("crtr.profile.menu.manage","Profiles","Manage profiles","Open the profiles settings page in a popup.",["v"],"terminal",[t]),e("crtr.profile.search.up","Profiles","Move up","Move to the previous search result.",["up","ctrl+p"],"terminal",[o]),e("crtr.profile.search.down","Profiles","Move down","Move to the next search result.",["down","ctrl+n"],"terminal",[o]),e("crtr.profile.search.pick","Profiles","Pick profile","Pick the highlighted profile.",["enter"],"terminal",[o]),e("crtr.profile.search.back","Profiles","Back","Return to profile selection.",["escape"],"terminal",[o],"leave-screen"),e("crtr.profile.search.delete","Profiles","Delete filter text","Delete the previous filter character.",["backspace"],"terminal",[o]),e("crtr.profile.search.abort","Profiles","Abort","Leave profile search.",["ctrl+c"],"terminal",[o],"leave-screen")]}i(x,"profileBindings");function k(){return[e("crtr.setup.cancel","Setup","Cancel setup","Leave the setup wizard.",["q","ctrl+c","ctrl+d"],"terminal",b,"leave-screen"),e("crtr.setup.tab-next","Setup","Next tab","Select the next setup tab.",["tab","right"],"terminal",h),e("crtr.setup.tab-previous","Setup","Previous tab","Select the previous setup tab.",["shift+tab","left"],"terminal",h),e("crtr.setup.open","Setup","Open","Open the selected setup item.",["enter"],"terminal",["setup.login"]),e("crtr.setup.list-down","Setup","Move down","Move to the next setup item.",["j","down"],"terminal",["setup.list","setup.models","setup.models.dimension-picker","setup.models.route-form"]),e("crtr.setup.list-up","Setup","Move up","Move to the previous setup item.",["k","up"],"terminal",["setup.list","setup.models","setup.models.dimension-picker","setup.models.route-form"]),e("crtr.setup.toggle","Setup","Toggle","Toggle the selected setup item.",["space"],"terminal",["setup.list","setup.keybindings"]),e("crtr.setup.details","Setup","Show details","Show details for the selected item.",["?"],"terminal",["setup.list"]),e("crtr.setup.advance","Setup","Advance","Advance the setup flow.",["enter"],"terminal",["setup.list"]),e("crtr.setup.confirm.accept","Setup","Confirm","Accept the setup confirmation.",["y","enter"],"terminal",["setup.confirm","setup.models.confirm"]),e("crtr.setup.confirm.back","Setup","Go back","Cancel the setup confirmation.",["n","escape","q"],"terminal",["setup.confirm","setup.models.confirm"],"dismiss-modal"),e("crtr.setup.keybindings.edit","Setup","Edit binding","Edit the selected binding.",["enter"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.commit-edit","Setup","Commit edit","Commit the active binding edit.",["enter"],"terminal",["setup.keybindings.edit"]),e("crtr.setup.keybindings.cancel-edit","Setup","Cancel edit","Cancel the active binding edit.",["escape"],"terminal",["setup.keybindings.edit"],"dismiss-modal"),e("crtr.setup.keybindings.unbind","Setup","Unbind","Disable the selected binding.",["delete"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.reset-row","Setup","Reset binding","Reset the selected binding.",["r"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.reset-all","Setup","Reset all bindings","Reset all bindings to defaults.",["shift+r"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.save","Setup","Save bindings","Save keybinding changes.",["s"],"terminal",["setup.keybindings"],"save-keybindings"),e("crtr.setup.keybindings.discard","Setup","Discard changes","Discard keybinding changes.",["escape"],"terminal",["setup.keybindings"],"leave-screen"),e("crtr.setup.keybindings.page-up","Setup","Page up","Move up one keybinding page.",["pageup"],"terminal",["setup.keybindings","setup.keybindings.edit"]),e("crtr.setup.keybindings.page-down","Setup","Page down","Move down one keybinding page.",["pagedown"],"terminal",["setup.keybindings","setup.keybindings.edit"]),e("crtr.setup.keybindings.filter","Setup","Filter bindings","Open the keybinding filter.",["/"],"terminal",["setup.keybindings"]),e("crtr.setup.keybindings.filter-delete","Setup","Delete filter text","Delete the previous filter character.",["backspace"],"terminal",["setup.keybindings.filter"]),e("crtr.setup.keybindings.filter-clear","Setup","Clear filter","Clear the keybinding filter.",["escape"],"terminal",["setup.keybindings.filter"],"dismiss-modal"),e("crtr.setup.cell-previous","Setup","Previous field","Select the previous field or setup table cell.",["h"],"terminal",["setup.models","setup.keybindings"]),e("crtr.setup.cell-next","Setup","Next field","Select the next field or setup table cell.",["l"],"terminal",["setup.models","setup.keybindings"]),e("crtr.setup.models.open","Setup","Edit model","Edit the selected model cell or route field.",["enter"],"terminal",["setup.models","setup.models.route-form"]),e("crtr.setup.models.scope-next","Setup","Next model config scope","Edit the next applicable user, profile, or project config.",["s"],"terminal",["setup.models"]),e("crtr.setup.models.commit","Setup","Commit pick","Commit the provider, strength, model, or thinking-level pick.",["enter"],"terminal",["setup.models.picker","setup.models.dimension-picker"]),e("crtr.setup.models.cancel","Setup","Cancel pick","Cancel the model picker or route form.",["escape"],"terminal",["setup.models.picker","setup.models.dimension-picker","setup.models.route-form"],"dismiss-modal")]}i(k,"setupBindings");const S=new Set(w.map(t=>t.id));function C(t){return t.contexts.includes("attach")&&(t.inputKind==="terminal"||t.inputKind==="host-global")}i(C,"isAttachPaneBinding");const P=Object.freeze([{context:"graph",capability:"dismiss-modal"},{context:"graph.confirm",capability:"dismiss-modal"},{context:"inspector",capability:"leave-screen"},{context:"inspector",capability:"dismiss-modal"},{context:"attach.search",capability:"dismiss-modal"},{context:"browse",capability:"leave-screen"},{context:"browse.search",capability:"dismiss-modal"},{context:"profile.menu",capability:"leave-screen"},{context:"profile.search",capability:"leave-screen"},{context:"setup.login",capability:"leave-screen"},{context:"setup.list",capability:"leave-screen"},{context:"setup.input",capability:"leave-screen"},{context:"setup.confirm",capability:"dismiss-modal"},{context:"setup.keybindings",capability:"leave-screen"},{context:"setup.keybindings",capability:"save-keybindings"},{context:"setup.keybindings.edit",capability:"dismiss-modal"},{context:"setup.keybindings.filter",capability:"dismiss-modal"},{context:"setup.models",capability:"leave-screen"},{context:"setup.models.picker",capability:"dismiss-modal"},{context:"setup.models.dimension-picker",capability:"dismiss-modal"},{context:"setup.models.route-form",capability:"dismiss-modal"},{context:"setup.models.confirm",capability:"dismiss-modal"}]);export{w as BINDING_CATALOG,S as BINDING_IDS,P as SAFETY_REQUIREMENTS,C as isAttachPaneBinding};
@@ -0,0 +1,15 @@
1
+ import { OldToNewPathMap } from './paths.js';
2
+ export { OldToNewPathMap, oldToNewPathMap } from './paths.js';
3
+ export interface LayoutMigration {
4
+ map: OldToNewPathMap;
5
+ moved: number;
6
+ /** Exactly the filesystem operations that changed a source path. */
7
+ changes: string[];
8
+ /** Credential sources that did not exist; legitimate when the old volume never held one. */
9
+ absentCredentials: string[];
10
+ }
11
+ /** Rename within the volume; merge an existing directory on interrupted runs, never overwrite a file. */
12
+ export declare function movePath(from: string, to: string, migration: LayoutMigration): void;
13
+ export declare function sameFile(from: string, to: string): boolean;
14
+ export declare function daemonAnswers(socketPath: string): Promise<boolean>;
15
+ export declare function migrateLayout(dryRun: boolean): Promise<LayoutMigration | null>;
@@ -0,0 +1,4 @@
1
+ var U=Object.defineProperty;var p=(r,e)=>U(r,"name",{value:e,configurable:!0});import{DatabaseSync as D}from"node:sqlite";import{randomUUID as x}from"node:crypto";import{chmodSync as T,chownSync as A,closeSync as b,cpSync as C,existsSync as d,fsyncSync as L,lchownSync as R,lstatSync as m,mkdirSync as E,openSync as S,readFileSync as v,readlinkSync as P,readSync as j,readdirSync as h,renameSync as k,rmSync as I,rmdirSync as $,unlinkSync as W,writeSync as F}from"node:fs";import{request as z}from"node:http";import{dirname as w,join as s}from"node:path";import{LAYOUT_VERSION as M}from"../layout.js";import{InputError as _}from"../io.js";import{oldToNewPathMap as B}from"./paths.js";import{conversations as G,memoryAndProfiles as H,profileFolders as Q,repairMovedRepositories as V,worktrees as Y}from"./stores.js";import{storedPaths as J}from"./stored-paths.js";import{OldToNewPathMap as ge,oldToNewPathMap as ve}from"./paths.js";function y(r,e,n){if(d(r)&&r!==e){if(d(e)){if(!m(r).isDirectory()||!m(e).isDirectory())throw new Error(`migration destination already exists: ${e}`);for(const t of h(r))y(s(r,t),s(e,t),n);$(r);return}E(w(e),{recursive:!0}),k(r,e),n.moved++,n.changes.push(`${r} -> ${e}`)}}p(y,"movePath");function K(r){const{map:e}=r,n=s(e.old.canvas,"nodes"),t=s(e.old.canvas,"canvas.db"),c=s(e.old.root,"runtime","canvas.db"),a=d(t)?t:c;if(!d(a)){if(d(n))throw new Error("old node records exist without canvas.db");return}const i=new D(a,{readOnly:!d(t)});let l;try{if(a===t&&i.prepare("PRAGMA wal_checkpoint(TRUNCATE)").get().busy!==0)throw new Error("old canvas WAL is busy; stop every database user before migrating");l=new Map(i.prepare("SELECT node_id, grantee FROM nodes").all().map(o=>{const f=o.grantee==="user:local"?"terminal":o.grantee.startsWith("app:")?o.grantee.slice(4):"";if(!f)throw new Error(`node ${o.node_id} has no app assignment`);return[o.node_id,f]}))}finally{i.close()}for(const[o,f]of l)e.node(o,f);if(d(n)){for(const o of h(n)){const f=l.get(o);if(!f)throw new Error(`node directory ${o} has no canvas row`);const u=s(n,o);if(!m(u).isDirectory())throw new Error(`node path is not a directory: ${u}`);for(const g of["context","reports","attachments"])y(s(u,g),s(e.old.root,"apps",f,"nodes",o,g),r);for(const g of h(u))["worktree","view.sock","broker-launch.json","system-prompt.md","situational-context.md","injected-docs.json"].includes(g)||y(s(u,g),s(e.old.root,"runtime","nodes",o,g),r);h(u).length===0&&$(u)}h(n).length===0&&$(n)}}p(K,"records");const q=["auth.json","anthropic-credentials.json","openai-codex-credentials.json","crouter-operations.db"];function X(r,e,n){if(!d(r))return;if(!m(r).isFile())throw new Error(`credential source is not a regular file: ${r}`);const t=v(r);if(d(e)){if(!m(e).isFile()||!v(e).equals(t))throw new Error(`credential destination differs: ${e}`);return}E(w(e),{recursive:!0});const c=s(w(e),`.${x()}.tmp`);try{const a=S(c,"wx",384);try{for(let i=0;i<t.length;)i+=F(a,t,i,t.length-i);L(a)}finally{b(a)}if(k(c,e),!v(e).equals(t))throw new Error(`credential verification failed: ${e}`)}finally{d(c)&&W(c)}n.moved++,n.changes.push(`${r} -> ${e} (source retained)`)}p(X,"copyCredential");function O(r){if(!d(r))return;const e=new D(r);try{if(e.prepare("PRAGMA wal_checkpoint(TRUNCATE)").get().busy!==0)throw new Error(`SQLite WAL is busy: ${r}`)}finally{e.close()}}p(O,"checkpointDb");function Z(r,e){if(m(r).size!==m(e).size)return!1;const n=S(r,"r"),t=S(e,"r"),c=Buffer.allocUnsafe(64*1024),a=Buffer.allocUnsafe(c.length);try{for(;;){const i=j(n,c,0,c.length,null);if(i===0)return!0;let l=0;for(;l<i;){const o=j(t,a,l,i-l,null);if(o===0)return!1;l+=o}if(!c.subarray(0,i).equals(a.subarray(0,i)))return!1}}finally{b(n),b(t)}}p(Z,"sameFile");function N(r,e,n=!1){let t;try{t=m(e)}catch(o){if(o.code==="ENOENT")return!1;throw o}const c=m(r);if(c.isSymbolicLink())return t.isSymbolicLink()&&P(r)===P(e);if(c.isFile())return t.isFile()&&Z(r,e);if(!c.isDirectory()||!t.isDirectory())return!1;const a=h(r).filter(o=>!n||o!==".git"),i=h(e).filter(o=>!n||o!==".git"),l=new Set(i);return a.length===i.length&&a.every(o=>l.has(o)&&N(s(r,o),s(e,o),n))}p(N,"sameTree");function ee(r,e,n){if(!d(r))return;if(!m(r).isDirectory())throw new Error(`hosted work is not a directory: ${r}`);if(d(e)){if(N(r,e,!0))return;if(!m(e).isDirectory()||h(e).length!==0)throw new Error(`hosted work destination differs: ${e}`);$(e)}E(w(e),{recursive:!0});const t=s(w(e),`.work-${x()}.migrating`);try{if(C(r,t,{recursive:!0,verbatimSymlinks:!0,preserveTimestamps:!0}),!N(r,t))throw new Error(`hosted work copy verification failed: ${r}`);k(t,e),n.moved++,n.changes.push(`${r} -> ${e} (source retained)`)}finally{d(t)&&I(t,{recursive:!0,force:!0})}}p(ee,"copyHostedWork");function re(r){const{old:e}=r.map,n=s(e.root,"runtime"),t=s(n,"scope");for(const c of["canvas.db","canvas.db-wal","canvas.db-shm","requests","reviews","plugins","marketplaces","crtrd.log","crtrd.err","cache"])y(s(e.canvas,c),s(n,c),r);O(s(e.scope,"operations.db"));for(const c of["prompts","personas","config.json","profile-defaults.json","operations.db","operations.db-wal","operations.db-shm"])y(s(e.scope,c),s(t,c),r);for(const c of["support","prompt-reviews","plugins","marketplaces"])y(s(e.scope,c),s(n,c),r);y(s(e.canvas,"secrets"),s(n,"secrets"),r),O(s(e.agent,"crouter-operations.db"));for(const c of q)X(s(e.agent,c),s(n,"secrets",c),r);process.platform==="linux"&&ee(e.work,s(e.root,"user","files"),r)}p(re,"topLevel");function ne(r){if(process.platform!=="linux")return;if(process.getuid?.()!==0)throw new Error("Linux layout migration requires root for the ownership pass");const e=v("/etc/passwd","utf8").split(`
2
+ `).find(i=>i.startsWith("crtrd:")),n=v("/etc/group","utf8").split(`
3
+ `).find(i=>i.startsWith("nl-data:"));if(!e||!n)throw new Error("layout migration requires crtrd user and nl-data group");const t=Number(e.split(":")[2]),c=Number(n.split(":")[2]);if(!Number.isInteger(t)||!Number.isInteger(c))throw new Error("invalid migration user or group");const a=p((i,l)=>{if(!d(i))return;const o=m(i);if(o.isSymbolicLink()){R(i,t,l?c:o.gid);return}if(A(i,t,l?c:o.gid),o.isDirectory()){T(i,l?1528:448);for(const f of h(i))a(s(i,f),l)}else l&&T(i,o.mode&73?504:432)},"walk");a(s(r,"runtime"),!1),a(s(r,"user"),!0),a(s(r,"apps"),!0)}p(ne,"ownership");function te(r){return new Promise(e=>{const n=z({socketPath:r,path:"/healthz",method:"GET",timeout:1e3},t=>{t.resume(),e(!0)});n.on("timeout",()=>n.destroy(new Error("daemon probe timed out"))),n.on("error",t=>{t.code==="ENOENT"||t.code==="ECONNREFUSED"?e(!1):e(!0)}),n.end()})}p(te,"daemonAnswers");async function he(r){const e=B(),n=e.old,t=s(n.root,"runtime","layout");if(d(t)){if(v(t,"utf8").trim()!==M)throw new Error("unsupported runtime layout version");return null}const c=new Set([s(n.canvas,"crtrd.sock"),s(n.scope,"crtrd.sock"),process.platform==="linux"?"/run/crtr/api.sock":s(n.root,"runtime","api.sock")]);for(const u of c)if(await te(u))throw new _({error:"daemon_running",message:`cannot migrate while a daemon answers on ${u}`,next:"Stop the daemon that owns this volume, then run `crtr sys migrate` again."});if(Q(e),process.platform==="linux"&&!d(n.agent))throw new _({error:"credential_volume_missing",message:`the old credential volume is not mounted at ${n.agent}`,next:`Mount the old provider-auth volume at ${n.agent}, then run \`crtr sys migrate\` again.`});const a=q.map(u=>s(n.agent,u)).filter(u=>!d(u)),i={map:e,moved:0,changes:[],absentCredentials:a};if(r)return i;const l=[K,Y,re,V,H,G,J];for(const u of l)u(i);ne(n.root),E(w(t),{recursive:!0});const o=`${t}.${x()}.tmp`,f=S(o,"wx",384);try{if(process.platform==="linux"){const u=m(w(t));A(o,u.uid,u.gid)}F(f,`${M}
4
+ `),L(f)}finally{b(f)}return k(o,t),i}p(he,"migrateLayout");export{ge as OldToNewPathMap,te as daemonAnswers,he as migrateLayout,y as movePath,ve as oldToNewPathMap,Z as sameFile};
@@ -0,0 +1,26 @@
1
+ export interface OldLayout {
2
+ root: string;
3
+ targetRoot: string;
4
+ canvas: string;
5
+ scope: string;
6
+ agent: string;
7
+ storedCanvas: string;
8
+ storedScope: string;
9
+ storedAgent: string;
10
+ work: string;
11
+ }
12
+ /** Sources are physical paths; stored prefixes are paths seen by the old daemon. */
13
+ export declare function oldLayout(): OldLayout;
14
+ export declare class OldToNewPathMap {
15
+ readonly old: OldLayout;
16
+ private readonly entries;
17
+ private readonly retired;
18
+ constructor(old: OldLayout);
19
+ add(from: string, to: string): void;
20
+ /** A removed folder: the folder itself maps to `to`, and a stored path inside it with no finer entry is refused. */
21
+ retire(from: string, to: string): void;
22
+ node(nodeId: string, app: string): void;
23
+ /** Rewrites only approved old prefixes; later steps register profile and session paths. */
24
+ mapPath(path: string): string;
25
+ }
26
+ export declare function oldToNewPathMap(): OldToNewPathMap;
@@ -0,0 +1 @@
1
+ var f=Object.defineProperty;var d=(a,t)=>f(a,"name",{value:t,configurable:!0});import{existsSync as u}from"node:fs";import{homedir as g}from"node:os";import{isAbsolute as c,join as e,relative as l,resolve as h,sep as m}from"node:path";import{layoutRoot as w}from"../layout.js";function v(){const a=w(),t=process.platform==="linux",s=t&&a==="/"?"/volume":a,r=t?"/home/agent/.crouter":s,o=u(e(s,"canvas"))?e(s,"canvas"):s,n=t?"/home/agent/.pi/agent":h(process.env.PI_CODING_AGENT_DIR||e(g(),".pi","agent"));return{root:s,targetRoot:a,canvas:o,scope:s,agent:n,storedCanvas:o===s?r:e(r,"canvas"),storedScope:r,storedAgent:n,work:"/home/crtr/work"}}d(v,"oldLayout");class S{static{d(this,"OldToNewPathMap")}old;entries=new Map;retired=new Map;constructor(t){this.old=t;const s=e(t.targetRoot,"runtime"),r=e(s,"scope");for(const o of new Set([t.storedCanvas,t.storedScope,e(t.storedScope,"canvas")]))for(const n of["canvas.db","canvas.db-wal","canvas.db-shm","requests","reviews","plugins","marketplaces","secrets","crtrd.log","crtrd.err","cache"])this.add(e(o,n),e(s,n));for(const o of["prompts","personas","config.json","profile-defaults.json","operations.db","operations.db-wal","operations.db-shm"])this.add(e(t.storedScope,o),e(r,o));for(const o of["support","prompt-reviews","plugins","marketplaces"])this.add(e(t.storedScope,o),e(s,o));this.add(e(t.storedScope,"memory"),e(t.targetRoot,"user","memory")),this.add(t.storedScope,r),this.add(t.work,e(t.targetRoot,"user","files"));for(const o of["auth.json","anthropic-credentials.json","openai-codex-credentials.json","crouter-operations.db"])this.add(e(t.storedAgent,o),e(s,"secrets",o));for(const o of new Set([t.storedCanvas,t.storedScope,e(t.storedScope,"canvas")]))this.add(e(o,"secrets","runtime-client.json"),e(s,"secrets","runtime-client.json"))}add(t,s){if(!c(t)||!c(s))throw new Error("migration paths must be absolute");const r=this.entries.get(t);if(r&&r!==s)throw new Error(`conflicting migration path: ${t}`);this.entries.set(t,s)}retire(t,s){if(!c(t)||!c(s))throw new Error("migration paths must be absolute");const r=this.retired.get(t);if(r&&r!==s)throw new Error(`conflicting migration path: ${t}`);this.retired.set(t,s)}node(t,s){if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(t)||!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(s))throw new Error("unsafe migration node or app id");const r=e(this.old.targetRoot,"runtime","nodes",t),o=e(this.old.targetRoot,"apps",s,"nodes",t);for(const n of new Set([this.old.storedCanvas,this.old.storedScope,e(this.old.storedScope,"canvas")])){const p=e(n,"nodes",t);for(const i of["job","messages","meta.json","inbox.jsonl","passive.jsonl","transcript.jsonl","session.ptr"])this.add(e(p,i),e(r,i));for(const i of["context","reports","attachments","worktree"])this.add(e(p,i),e(o,i));this.add(e(p,"context","memory"),e(this.old.targetRoot,"apps",s,"memory","nodes",t))}}mapPath(t){if(!c(t))return t;const s=this.retired.get(t);if(s)return s;let r="";for(const o of this.entries.keys())(t===o||t.startsWith(o+m))&&o.length>r.length&&(r=o);for(const o of this.retired.keys())if(t.startsWith(o+m)&&o.length>r.length)throw new Error(`stored path names a removed folder: ${t}`);return r?h(this.entries.get(r),l(r,t)):t}}function R(){return new S(v())}d(R,"oldToNewPathMap");export{S as OldToNewPathMap,v as oldLayout,R as oldToNewPathMap};
@@ -0,0 +1,2 @@
1
+ import type { LayoutMigration } from './index.js';
2
+ export declare function storedPaths(migration: LayoutMigration): void;
@@ -0,0 +1,11 @@
1
+ var F=Object.defineProperty;var u=(s,i)=>F(s,"name",{value:i,configurable:!0});import{DatabaseSync as b}from"node:sqlite";import{closeSync as x,existsSync as y,fsyncSync as P,lstatSync as k,openSync as C,readFileSync as S,readdirSync as D,renameSync as J,unlinkSync as v,writeFileSync as B}from"node:fs";import{basename as M,dirname as L,join as p,relative as R,resolve as q,sep as N}from"node:path";function W(s,i){return typeof s=="string"?i.map.mapPath(s):Array.isArray(s)?s.map(o=>W(o,i)):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,r])=>[o,W(r,i)])):s}u(W,"mappedJson");function j(s,i){const o=JSON.parse(s),r=W(o,i);return JSON.stringify(r)===JSON.stringify(o)?s:JSON.stringify(r)}u(j,"rewriteJson");function O(s,i){return s.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(i)!==void 0}u(O,"tableExists");function T(s,i,o){if(!y(s))return;const r=new b(s);try{r.exec("BEGIN IMMEDIATE");try{for(const[a,d]of Object.entries(i)){if(!O(r,a))continue;const l=new Set(r.prepare(`PRAGMA table_info("${a}")`).all().map(t=>t.name)),f=[...(d.paths??[]).filter(t=>l.has(t)),...(d.json??[]).filter(t=>l.has(t))];if(f.length===0)continue;const e=r.prepare(`SELECT rowid AS migration_rowid, ${f.map(t=>`"${t}"`).join(", ")} FROM "${a}"`).all();for(const t of e){const n=[];for(const c of f){const h=t[c];if(typeof h!="string")continue;const E=(d.json??[]).includes(c)?j(h,o):o.map.mapPath(h);E!==h&&n.push([c,E])}n.length&&(r.prepare(`UPDATE "${a}" SET ${n.map(([c])=>`"${c}" = ?`).join(", ")} WHERE rowid = ?`).run(...n.map(([,c])=>c),t.migration_rowid),o.moved+=n.length,o.changes.push(`${s}:${a}:${String(t.migration_rowid)} (${n.map(([c])=>c).join(", ")})`))}}r.exec("COMMIT")}catch(a){throw r.exec("ROLLBACK"),a}}finally{r.close()}}u(T,"rewriteDb");const g={nodes:{paths:["cwd","fork_source_file","pi_session_file"],json:["launch_config_json","review_binding_json","metadata_json","outcome_detail_json"]},sessions:{paths:["transcript_path","fork_source_path"]},worktrees:{paths:["path","repo_root"],json:["sweep_observed_json","abandoned_json","land_intent_json","disposal_json"]},crons:{paths:["cwd"],json:["env_json","sink"]},human_action_deliveries:{paths:["cwd"],json:["argv_json","completion_json","last_failure_json"]},deliveries:{json:["adapter_json"]},reviews:{paths:["origin_session_file","review_dir","branch_file","output_path","file","presentation_dir"],json:["result_json","specification_json"]},human_requests:{paths:["request_dir","file","presentation_dir"],json:["specification_json","action_json","progress_json","feedback_json","result_json"]},run_events:{json:["body_json"]},webhook_deliveries:{json:["payload_json","document_json","last_failure_json","argv_json"]}},A={scope_owners:{paths:["root"]},profiles:{paths:["home"]},profile_projects:{paths:["path"]},profile_defaults:{paths:["directory"]},scope_bookkeeping:{paths:["active_canvas"]},scope_settings:{json:["raw_json"]}};function m(s,i,o){if(!y(s))return;const r=S(s,"utf8"),a=o(r);if(a===r)return;const d=k(s);if(!d.isFile())throw new Error(`migration path is not a regular file: ${s}`);const l=`${s}.migration-tmp`;if(y(l))throw new Error(`migration temporary file already exists: ${l}`);try{B(l,a,{flag:"wx",mode:d.mode});const f=C(l,"r");try{P(f)}finally{x(f)}J(l,s)}finally{y(l)&&v(l)}i.moved++,i.changes.push(`${s} (stored paths)`)}u(m,"rewriteFile");function _(s,i){if(y(s))for(const o of D(s,{withFileTypes:!0})){const r=p(s,o.name);o.isDirectory()?_(r,i):o.isFile()&&i(r)}}u(_,"walk");function H(s,i,o){const{map:r}=s,{old:a}=r,d=new Map,l=new Set;_(i,n=>{if(!n.includes("/conversations/")||!n.endsWith(".jsonl"))return;const c=M(n);d.has(c)?l.add(c):d.set(c,p(a.targetRoot,R(a.root,n)))});const f=u(n=>{if(typeof n=="string"){if(!n.startsWith(a.storedAgent+N+"sessions"+N)||r.mapPath(n)!==n)return;const c=M(n);if(l.has(c)||!d.has(c))throw new Error(`cannot recover old conversation path: ${n}`);r.add(n,d.get(c))}else if(Array.isArray(n))for(const c of n)f(c);else if(n!==null&&typeof n=="object")for(const c of Object.values(n))f(c)},"reference"),e=u(n=>{if(n.endsWith("/meta.json")||n.endsWith(".json")&&(n.includes("/tickets/")||n.includes("/requests/")))f(JSON.parse(S(n,"utf8")));else if(n.endsWith(".jsonl")&&n.includes("/conversations/")){const c=S(n,"utf8");f(JSON.parse(c.slice(0,c.indexOf(`
2
+ `)<0?void 0:c.indexOf(`
3
+ `))))}else if(n.endsWith(".md")&&n.includes("/memory/")){const c=S(n,"utf8");if(!c.startsWith(`---
4
+ `))return;const h=c.indexOf(`
5
+ ---`,4);if(h<0)return;for(const E of c.slice(0,h).split(`
6
+ `)){const w=E.match(/^\s*session_file:\s*["']?([^"'\n]+)["']?$/);w&&f(w[1])}}},"inspect");_(i,e),_(p(a.root,"user","memory"),e),_(p(o,"nodes"),e),_(p(o,"tickets"),e),_(p(o,"requests"),e);const t=p(o,"canvas.db");if(y(t)){const n=new b(t,{readOnly:!0});try{for(const[c,h]of Object.entries(g)){if(!O(n,c))continue;const E=new Set(n.prepare(`PRAGMA table_info("${c}")`).all().map(w=>w.name));for(const w of[...h.paths??[],...h.json??[]].filter($=>E.has($)))for(const $ of n.prepare(`SELECT "${w}" AS value FROM "${c}" WHERE "${w}" LIKE ?`).all(`%${a.storedAgent}/sessions/%`))(h.json??[]).includes(w)?f(JSON.parse($.value)):f($.value)}}finally{n.close()}}}u(H,"recoverSessionMappings");function V(s){const{root:i}=s.map.old,o=p(i,"runtime"),r=p(i,"apps");H(s,r,o),T(p(o,"canvas.db"),g,s),T(p(o,"scope","operations.db"),A,s);const a=new Set,d=p(o,"canvas.db");if(y(d)){const e=new b(d,{readOnly:!0});try{if(O(e,"nodes")&&e.prepare("PRAGMA table_info(nodes)").all().some(t=>t.name==="cwd"))for(const t of e.prepare("SELECT cwd FROM nodes").all())a.add(t.cwd)}finally{e.close()}}const l=p(o,"scope","operations.db");if(y(l)){const e=new b(l,{readOnly:!0});try{if(O(e,"profile_projects"))for(const t of e.prepare("SELECT path FROM profile_projects").all())a.add(t.path)}finally{e.close()}}for(const e of a){const t=s.map.old.targetRoot;let n=e.startsWith(t+"/")?q(i,R(t,e)):e;for(;n!==L(n);)T(p(n,".crouter","operations.db"),A,s),n=L(n)}_(p(r),e=>{e.endsWith("/.crouter/operations.db")&&T(e,A,s),e.endsWith("/meta.json")&&m(e,s,t=>j(t,s)),e.endsWith(".md")&&e.includes("/memory/")&&I(e,s),e.endsWith(".jsonl")&&e.includes("/conversations/")&&G(e,s)}),_(p(i,"user","memory"),e=>{e.endsWith(".md")&&I(e,s)}),_(p(i,"user","files"),e=>{e.endsWith("/.crouter/operations.db")&&T(e,A,s)}),_(p(o,"nodes"),e=>{e.endsWith("/meta.json")&&m(e,s,t=>j(t,s)),e.endsWith("/session.ptr")&&v(e)}),_(p(o,"tickets"),e=>{e.endsWith(".json")&&m(e,s,t=>j(t,s))}),_(p(o,"requests"),e=>{e.endsWith(".json")&&m(e,s,t=>j(t,s))});const f=p(o,"canvas.db");if(y(f)){const e=new b(f);try{e.exec("DROP TABLE IF EXISTS layout_header_rewrites")}finally{e.close()}}}u(V,"storedPaths");function I(s,i){m(s,i,o=>{if(!o.startsWith(`---
7
+ `))return o;const r=o.indexOf(`
8
+ ---`,4);return r<0?o:o.slice(0,r).replace(/^(\s*session_file:\s*)([^\n]+)$/gm,(d,l,f)=>{const e=f.match(/^(["'])(.*)\1$/),t=e?e[2]:f.trim(),n=i.map.mapPath(t);return n===t?d:`${l}${e?e[1]:""}${n}${e?e[1]:""}`})+o.slice(r)})}u(I,"rewriteMemory");function G(s,i){const o=p(i.map.old.root,"runtime","canvas.db");if(!y(o)){m(s,i,a=>{const d=a.indexOf(`
9
+ `),l=d<0?a:a.slice(0,d);return j(l,i)+(d<0?"":a.slice(d))});return}const r=new b(o);try{r.exec("CREATE TABLE IF NOT EXISTS layout_header_rewrites (path TEXT PRIMARY KEY, old_header TEXT NOT NULL, new_header TEXT NOT NULL)");const a=r.prepare("SELECT old_header, new_header FROM layout_header_rewrites WHERE path = ?").get(s),d=S(s,"utf8"),l=d.indexOf(`
10
+ `),f=l<0?d:d.slice(0,l),e=a?.new_header??j(f,i);if(a&&f!==a.old_header&&f!==e)throw new Error(`conversation header changed during migration: ${s}`);if(!a&&e!==f){const t=p(i.map.old.targetRoot,R(i.map.old.root,s)),n=Buffer.byteLength(e)-Buffer.byteLength(f);r.exec("BEGIN IMMEDIATE");try{r.prepare("INSERT INTO layout_header_rewrites (path, old_header, new_header) VALUES (?, ?, ?)").run(s,f,e),n!==0&&O(r,"sessions")&&r.prepare("UPDATE sessions SET event_offset = event_offset + ? WHERE transcript_path = ? AND event_offset > 0").run(n,t),r.exec("COMMIT")}catch(c){throw r.exec("ROLLBACK"),c}}f!==e&&m(s,i,t=>{const n=t.indexOf(`
11
+ `);if((n<0?t:t.slice(0,n))!==f)throw new Error(`conversation header changed during migration: ${s}`);return e+(n<0?"":t.slice(n))}),(a||e!==f)&&r.prepare("DELETE FROM layout_header_rewrites WHERE path = ?").run(s)}finally{r.close()}}u(G,"rewriteHeader");export{V as storedPaths};
@@ -0,0 +1,17 @@
1
+ import { profileSpace } from '../layout.js';
2
+ import type { LayoutMigration } from './index.js';
3
+ /**
4
+ * A profile is its scoped-state row; the row is authoritative even when an
5
+ * interrupted run already removed the old profile folder. There is no profile
6
+ * folder in the new layout: the old folder's own path (the profile's
7
+ * scope_owners.root) becomes its memory folder. Runs before any step moves a
8
+ * file, so a folder holding data with no new location refuses the whole run.
9
+ */
10
+ export declare function profileFolders(map: LayoutMigration['map']): Array<{
11
+ source: string;
12
+ target: ReturnType<typeof profileSpace>;
13
+ }>;
14
+ export declare function memoryAndProfiles(migration: LayoutMigration): void;
15
+ export declare function conversations(migration: LayoutMigration): void;
16
+ export declare function repairMovedRepositories(migration: LayoutMigration): void;
17
+ export declare function worktrees(migration: LayoutMigration): void;
@@ -0,0 +1,4 @@
1
+ var Z=Object.defineProperty;var w=(e,t)=>Z(e,"name",{value:t,configurable:!0});import{DatabaseSync as j}from"node:sqlite";import{closeSync as q,copyFileSync as J,existsSync as h,fsyncSync as Y,lstatSync as y,mkdirSync as N,openSync as G,readFileSync as P,readdirSync as _,renameSync as A,rmdirSync as b,unlinkSync as g,writeFileSync as z}from"node:fs";import{execFileSync as K}from"node:child_process";import{basename as H,dirname as $,isAbsolute as I,join as r,relative as S,resolve as L,sep as F}from"node:path";import{profileSpace as Q}from"../layout.js";import{movePath as k,sameFile as O}from"./index.js";function C(e,t){K("git",["-c",`safe.directory=${e}`,"-C",e,...t],{stdio:"pipe"})}w(C,"gitInRepo");function E(e,t){const{root:i,targetRoot:c}=t.map.old;return L(i,S(c,e))}w(E,"physical");function R(e){const{old:t}=e.map,i=r(t.canvas,"canvas.db"),c=r(t.root,"runtime","canvas.db"),o=h(i)?i:c;return h(o)?new j(o,{readOnly:!0}):null}w(R,"canvasDb");function x(e){return new Map(e.prepare("SELECT node_id, grantee FROM nodes").all().map(({node_id:t,grantee:i})=>{const c=i==="user:local"?"terminal":i.startsWith("app:")?i.slice(4):"";if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(c))throw new Error(`node ${t} has no valid app`);return[t,c]}))}w(x,"nodeApps");function B(e,t,i){if(h(e)){if(!h(t)){k(e,t,i);return}if(!y(e).isDirectory()||!y(t).isDirectory()){if(!y(e).isFile()||!y(t).isFile()||!O(e,t))throw new Error(`profile home file differs: ${e} and ${t}`);g(e);return}for(const c of _(e))B(r(e,c),r(t,c),i);b(e)}}w(B,"mergeHome");function V(e){const t=[r(e.old.scope,"operations.db"),r(e.old.root,"runtime","scope","operations.db")].find(h),i=t?new j(t,{readOnly:!0}):null,c=new Map;try{if(i&&i.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='profiles'").get())for(const s of i.prepare("SELECT id, grantee FROM profiles").all())c.set(s.id,s.grantee)}finally{i?.close()}const o=new Map;for(const[s,p]of c){const d=p==null||p==="user:local"?"terminal":p.startsWith("app:")?p.slice(4):"",l=Q(d,s),f=r(e.old.storedScope,"profiles",s);e.retire(f,l.memory),e.add(r(f,"memory"),l.memory),e.add(r(f,"env.json"),l.env),e.add(r(f,"home"),l.home),o.set(s,l)}const a=r(e.old.scope,"profiles");if(!h(a))return[];const n=[],u=[];for(const s of _(a)){const p=r(a,s);if(!y(p).isDirectory()){n.push(p);continue}if(s===".locks"){for(const l of _(p)){const f=r(p,l);(!l.endsWith(".lock")||!y(f).isFile())&&n.push(f)}continue}const d=o.get(s);if(!d){n.push(`${p} (no scoped-state profile row)`);continue}for(const l of _(p)){const f=r(p,l),m=y(f);l==="memory"||l==="home"?m.isDirectory()||n.push(f):(l==="env.json"||l==="profile.json"||l.endsWith(".lock"))&&m.isFile()||n.push(f)}u.push({source:p,target:d})}if(n.length)throw new Error(`profile folders hold data the new layout has no place for; move or delete each path, then rerun:
2
+ ${n.join(`
3
+ `)}`);return u}w(V,"profileFolders");function ae(e){const{map:t}=e;k(r(t.old.scope,"memory"),r(t.old.root,"user","memory"),e);const i=R(e);if(i)try{for(const[o,a]of x(i)){const n=r(t.old.root,"apps",a,"memory","nodes",o);k(r(t.old.root,"apps",a,"nodes",o,"context","memory"),n,e),k(r(t.old.canvas,"nodes",o,"context","memory"),n,e)}}finally{i.close()}for(const{source:o,target:a}of V(t)){k(r(o,"memory"),E(a.memory,e),e),k(r(o,"env.json"),E(a.env,e),e),B(r(o,"home"),E(a.home,e),e);for(const n of _(o))g(r(o,n));b(o),e.moved++,e.changes.push(`${o} (removed)`)}const c=r(t.old.scope,"profiles");if(h(c)){const o=r(c,".locks");if(h(o)){for(const a of _(o))g(r(o,a));b(o)}b(c)}}w(ae,"memoryAndProfiles");function X(e,t,i,c){if(!h(e)){if(!h(t))throw new Error(`session file missing from both migration paths: ${e}`);return}if(!y(e).isFile())throw new Error(`session path is not a file: ${e}`);if(N($(t),{recursive:!0}),h(t)){if(!y(t).isFile()||!O(e,t))throw new Error(`session destination differs: ${t}`);return}if(c){const o=r($(t),`.${H(t)}.migrating`);h(o)&&g(o),J(e,o);const a=G(o,"r");try{Y(a)}finally{q(a)}if(!O(e,o))throw new Error(`session copy verification failed: ${e}`);A(o,t),i.moved++,i.changes.push(`${e} -> ${t} (source retained)`);return}A(e,t),i.moved++,i.changes.push(`${e} -> ${t}`)}w(X,"moveSession");function ce(e){const t=R(e);if(t)try{const i=x(t),c=t.prepare("SELECT session_id, node_id, transcript_path FROM sessions WHERE transcript_path IS NOT NULL ORDER BY session_id, (unbound_at IS NULL) DESC, created_at DESC, rowid DESC").all(),o=new Map,a=new Map,n=new Map;for(const s of c){o.has(s.session_id)||o.set(s.session_id,s.node_id),n.set(s.transcript_path,(n.get(s.transcript_path)??0)+1);const p=a.get(s.transcript_path)??new Set;p.add(s.session_id),a.set(s.transcript_path,p)}const u=new Set;for(const{session_id:s,node_id:p,transcript_path:d}of c){if(u.has(d))continue;if(u.add(d),a.get(d).size!==1)throw new Error(`two conversations share a transcript: ${d}`);const l=n.get(d)>1?o.get(s):p,f=i.get(l);if(!f)throw new Error(`session belongs to unknown node: ${l}`);if(!I(d))throw new Error(`session path is not absolute: ${d}`);const m=r(e.map.old.targetRoot,"apps",f,"conversations",l,H(d));if(d===m)continue;e.map.add(d,m);const v=d===e.map.old.storedAgent||d.startsWith(e.map.old.storedAgent+F)?r(e.map.old.agent,S(e.map.old.storedAgent,d)):d;X(v,E(m,e),e,process.platform==="linux"&&(d===e.map.old.storedAgent||d.startsWith(e.map.old.storedAgent+F)))}}finally{t.close()}}w(ce,"conversations");function pe(e){if(process.platform!=="linux")return;const t=R(e);if(t)try{const i=t.prepare("SELECT node_id, path, repo_root FROM worktrees").all(),c=x(t);for(const o of i){const a=e.map.mapPath(o.repo_root);if(a===o.repo_root)continue;const n=c.get(o.node_id);if(!n)throw new Error(`worktree belongs to unknown node: ${o.node_id}`);const u=E(r(e.map.old.targetRoot,"apps",n,"nodes",o.node_id,"worktree"),e);if(!h(u))continue;C(E(a,e),["worktree","repair",u]);const s=o.path.startsWith(e.map.old.storedCanvas+F)?r(e.map.old.canvas,S(e.map.old.storedCanvas,o.path)):o.path;W(s,u,e)}}finally{t.close()}}w(pe,"repairMovedRepositories");function W(e,t,i){const c=w(o=>{for(const a of _(o)){const n=r(o,a);if(a===".git"&&n!==r(t,".git")&&y(n).isFile()){const u=P(n,"utf8");if(!u.startsWith("gitdir: "))throw new Error(`invalid submodule git link: ${n}`);const s=u.slice(8).trim(),p=L($(n),s),d=r(e,S(t,n)),l=L($(d),s),f=h(p)?p:l;if(!h(f))throw new Error(`submodule git directory missing: ${d}`);const m=i?.map.mapPath(f)??f,v=i&&m!==f?E(m,i):f;if(!h(v))throw new Error(`moved submodule git directory missing: ${v}`);p!==v&&z(n,`gitdir: ${S($(n),v)}
4
+ `);const D=r(v,"config"),M=P(D,"utf8");if(!/^\s*worktree\s*=.*$/m.test(M))throw new Error(`submodule has no worktree setting: ${D}`);const U=JSON.stringify(S(v,$(n))),T=M.replace(/^(\s*worktree\s*=).*$/m,`$1 ${U}`);T!==M&&z(D,T)}else a!==".git"&&y(n).isDirectory()&&c(n)}},"visit");c(t)}w(W,"repairSubmoduleLinks");function de(e){const t=R(e);if(t)try{const i=x(t),c=t.prepare("SELECT node_id, state, cleanup_state, path, repo_root FROM worktrees").all();for(const o of c){const a=i.get(o.node_id);if(!a)throw new Error(`worktree belongs to unknown node: ${o.node_id}`);if(!I(o.path))throw new Error(`worktree path is not absolute: ${o.path}`);const n=r(e.map.old.targetRoot,"apps",a,"nodes",o.node_id,"worktree");if(o.path===n)continue;e.map.add(o.path,n);const u=o.path===e.map.old.storedCanvas||o.path.startsWith(e.map.old.storedCanvas+F)?r(e.map.old.canvas,S(e.map.old.storedCanvas,o.path)):o.path,s=E(n,e);if(!h(u)){if(!h(s)&&!(o.state!=="open"&&o.cleanup_state==="complete"))throw new Error(`managed worktree missing from both migration paths: ${o.path}`);h(s)&&(C(o.repo_root,["worktree","repair",s]),W(u,s));continue}if(h(s))throw new Error(`managed worktree destination already exists: ${s}`);N($(s),{recursive:!0});try{C(o.repo_root,["worktree","move",u,s])}catch(p){if(!String(p.stderr??"").includes("submodule"))throw p;A(u,s),C(o.repo_root,["worktree","repair",s])}W(u,s),e.moved++,e.changes.push(`${u} -> ${s} (git worktree move)`)}}finally{t.close()}}w(de,"worktrees");export{ce as conversations,ae as memoryAndProfiles,V as profileFolders,pe as repairMovedRepositories,de as worktrees};
@@ -0,0 +1,26 @@
1
+ export declare const LAYOUT_VERSION = "1";
2
+ /** CRTR_HOME names the volume root, not the canvas records directory. */
3
+ export declare function layoutRoot(): string;
4
+ export declare function runtimeRoot(): string;
5
+ export declare function userRoot(): string;
6
+ export declare function appsRoot(): string;
7
+ export declare function secretsDir(): string;
8
+ export declare function profileSpace(app: string, id: string): {
9
+ memory: string;
10
+ env: string;
11
+ home: string;
12
+ };
13
+ export declare function socketDir(): string;
14
+ export declare function layoutVersionFile(): string;
15
+ export declare function userFilesRoot(): string;
16
+ export declare function appSpace(app: string): {
17
+ root: string;
18
+ memory: string;
19
+ conversations: string;
20
+ nodes: string;
21
+ files: string;
22
+ home: string;
23
+ };
24
+ /** A missing version on an occupied volume is never initialized by daemon startup. */
25
+ export declare function layoutNeedsMigration(): boolean;
26
+ export declare function initializeEmptyLayout(): void;
@@ -0,0 +1,2 @@
1
+ var y=Object.defineProperty;var t=(o,e)=>y(o,"name",{value:e,configurable:!0});import{existsSync as i,mkdirSync as a,readFileSync as h,statSync as w,writeFileSync as E}from"node:fs";import{homedir as f}from"node:os";import{basename as R,isAbsolute as S,join as r,resolve as m}from"node:path";import{envHomeOverride as _}from"../shared/env.js";import{readConfig as b}from"./config.js";const p="1";function u(){return m(_()||(process.platform==="linux"?"/":r(f(),".crouter")))}t(u,"layoutRoot");function s(){return r(u(),"runtime")}t(s,"runtimeRoot");function l(){return r(u(),"user")}t(l,"userRoot");function d(){return r(u(),"apps")}t(d,"appsRoot");function x(){return r(s(),"secrets")}t(x,"secretsDir");function T(o,e){if(!/^[a-z0-9]+(?:-[a-z0-9]+)*-[0-9a-f]{8}$/.test(e))throw new Error(`invalid profile id: ${e}`);const n=z(o);return{memory:r(n.memory,"profiles",e),env:r(x(),"env",R(n.root),e),home:n.home}}t(T,"profileSpace");function v(){return process.platform==="linux"?"/run/crtr":s()}t(v,"socketDir");function c(){return r(s(),"layout")}t(c,"layoutVersionFile");function U(){const o=b("user").paths?.user_files??(process.platform==="linux"?r(l(),"files"):f());if(!S(o))throw new Error("paths.user_files must be absolute");return m(o)}t(U,"userFilesRoot");function z(o){const e=o.startsWith("app:")?o.slice(4):o;if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(e)||e==="."||e==="..")throw new Error(`invalid app id: ${o}`);const n=r(d(),e);return{root:n,memory:r(n,"memory"),conversations:r(n,"conversations"),nodes:r(n,"nodes"),files:r(n,"files"),home:r(n,"home")}}t(z,"appSpace");function A(){if(process.env.CRTR_LAYOUT_REFUSE==="1")return!0;if(i(c())){if(h(c(),"utf8").trim()!==p)throw new Error("unsupported runtime layout version");return!1}const o=u(),e=process.platform==="linux"&&o==="/"&&i("/volume")?"/volume":o;return i(r(e,"canvas"))||i(r(e,"canvas.db"))?!0:i(r(s(),"canvas.db"))}t(A,"layoutNeedsMigration");function C(){if(A())throw new Error("layout_migration_required");for(const o of[s(),l(),d(),x()])a(o,{recursive:!0,mode:448});if(a(v(),{recursive:!0,mode:493}),process.platform==="linux"&&(w(v()).mode&511)!==493)throw new Error("launcher socket directory must be mode 0755");i(c())||E(c(),`${p}
2
+ `,{flag:"wx",mode:384})}t(C,"initializeEmptyLayout");export{p as LAYOUT_VERSION,z as appSpace,d as appsRoot,C as initializeEmptyLayout,A as layoutNeedsMigration,u as layoutRoot,c as layoutVersionFile,T as profileSpace,s as runtimeRoot,x as secretsDir,v as socketDir,U as userFilesRoot,l as userRoot};