@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 +1,2 @@
1
- var j=Object.defineProperty;var o=(e,t)=>j(e,"name",{value:t,configurable:!0});import{createHash as T}from"node:crypto";import{existsSync as g,readFileSync as M,rmSync as R}from"node:fs";import{injectedDocsPath as S}from"../canvas/paths.js";import{atomicWriteJson as z,realpathOrSelf as d}from"../fs-utils.js";import{rungRank as w}from"./schema.js";const D=w("content"),f=new Map;function h(){return{preferenceSnapshot:null,exposures:new Map}}o(h,"emptyContextExposureState");function b(e,t){return{state:e,source:t}}o(b,"exposureTarget");function u(e){return typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=D}o(u,"validRank");function F(e){return Math.max(e?.system??0,e?.transcript??0)}o(F,"activeRank");function C(e,t,r){return F(e.exposures.get(t))>=w(r)}o(C,"exposedAtOrAbove");function m(e,t,r){const n=w(r);if(n===0)return;const s=e.state.exposures.get(t)??{};(s[e.source]??0)>=n||e.state.exposures.set(t,{...s,[e.source]:n})}o(m,"registerExposure");function v(e){const t=e.trim();return t===""?null:`content-sha256:${T("sha256").update(t).digest("hex")}`}o(v,"contentExposureIdentity");function G(e,t,r,n){if(C(e,d(t),n))return!0;const s=v(r);return s!==null&&C(e,s,n)}o(G,"documentExposedAtOrAbove");function L(e,t,r,n){m(e,d(t),n);const s=v(r);s!==null&&m(e,s,n)}o(L,"registerDocumentExposure");function O(e,t){const r=e.exposures.get(t);r!==void 0&&(u(r.system)?e.exposures.set(t,{system:r.system}):e.exposures.delete(t))}o(O,"dropTranscriptExposure");function N(e,t,r){O(e,d(t));const n=v(r);n!==null&&O(e,n)}o(N,"demoteDocumentTranscriptExposure");function Q(e,t){return e.preferenceSnapshot===null&&(e.preferenceSnapshot=t),e.preferenceSnapshot}o(Q,"freezePreferenceSnapshot");function U(e){return{preferenceSnapshot:e.preferenceSnapshot,exposures:new Map([...e.exposures].map(([t,r])=>[t,{...r}]))}}o(U,"cloneContextExposureState");function V(e){return[...e.exposures.values()].some(t=>u(t.transcript))}o(V,"hasTranscriptExposure");function J(e){const t=h(),r=b(t,"transcript");for(const[n,s]of e.exposures){const p=s.transcript;u(p)&&m(r,n,p===1?"name":p===2?"preview":"content")}return t}o(J,"cloneTranscriptExposureState");function k(e,t){e.preferenceSnapshot=t.preferenceSnapshot,e.exposures.clear();for(const[r,n]of t.exposures)e.exposures.set(r,{...n})}o(k,"replaceContextExposureState");function X(e,t){if(e.preferenceSnapshot!==t.preferenceSnapshot||e.exposures.size!==t.exposures.size)return!1;for(const[r,n]of e.exposures){const s=t.exposures.get(r);if(n.system!==s?.system||n.transcript!==s?.transcript)return!1}return!0}o(X,"contextExposureStatesEqual");function Y(e,t){if(e.preferenceSnapshot!==null&&t.preferenceSnapshot!==null&&e.preferenceSnapshot!==t.preferenceSnapshot)throw new Error("context exposure state contains conflicting preference snapshots");e.preferenceSnapshot===null&&t.preferenceSnapshot!==null&&(e.preferenceSnapshot=t.preferenceSnapshot);for(const[r,n]of t.exposures){const s=e.exposures.get(r)??{},p=Math.max(s.system??0,n.system??0),a=Math.max(s.transcript??0,n.transcript??0);e.exposures.set(r,{...p>0?{system:p}:{},...a>0?{transcript:a}:{}})}}o(Y,"mergeContextExposureState");function Z(e){let t=f.get(e);return t===void 0&&(t=$(e),f.set(e,t)),t}o(Z,"sharedContextExposureState");function $(e){const t=S(e);let r;try{r=JSON.parse(M(t,"utf8"))}catch(c){if(c.code==="ENOENT")return h();throw new Error(`failed to read context exposure state at ${t}: ${c instanceof Error?c.message:String(c)}`)}const n=h(),s=b(n,"transcript");if(Array.isArray(r)){for(const c of r){if(typeof c!="string")throw new Error(`invalid v1 context exposure state at ${t}`);m(s,c,"content")}return n}if(r===null||typeof r!="object")throw new Error(`invalid context exposure state at ${t}`);const p=r;if(p.v===3){const c=p.preferenceSnapshot,i=p.exposures;if(c!==null&&typeof c!="string"||i===null||typeof i!="object"||Array.isArray(i))throw new Error(`invalid v3 context exposure state at ${t}`);n.preferenceSnapshot=c;for(const[E,y]of Object.entries(i)){if(y===null||typeof y!="object"||Array.isArray(y))throw new Error(`invalid v3 exposure entry '${E}' at ${t}`);const A=y,x=A.system,l=A.transcript;if(x!==void 0&&!u(x)||l!==void 0&&!u(l)||x===void 0&&l===void 0)throw new Error(`invalid v3 exposure ranks for '${E}' at ${t}`);n.exposures.set(E,{...u(x)?{system:x}:{},...u(l)?{transcript:l}:{}})}return n}if(p.v!==2)throw new Error(`unsupported context exposure state at ${t}`);const a=p.docs;if(a===null||typeof a!="object"||Array.isArray(a))throw new Error(`invalid v2 context exposure state at ${t}`);for(const[c,i]of Object.entries(a)){if(!u(i))throw new Error(`invalid v2 exposure rank for '${c}' at ${t}`);m(s,c,i===1?"name":i===2?"preview":"content")}return n}o($,"loadContextExposureState");function P(e,t){z(S(e),{v:3,preferenceSnapshot:t.preferenceSnapshot,exposures:Object.fromEntries(t.exposures)})}o(P,"saveContextExposureState");function I(e){const t=f.get(e);t!==void 0&&k(t,h()),R(S(e),{force:!0})}o(I,"clearContextExposureState");function ee(e,t){if(g(S(e))){const s=$(e),p=f.get(e);p===void 0?f.set(e,s):k(p,s);return}const r=t===null?h():J($(t)),n=f.get(e);n===void 0?f.set(e,r):k(n,r),P(e,r)}o(ee,"initializeForkContextExposure");export{I as clearContextExposureState,U as cloneContextExposureState,J as cloneTranscriptExposureState,v as contentExposureIdentity,X as contextExposureStatesEqual,N as demoteDocumentTranscriptExposure,G as documentExposedAtOrAbove,h as emptyContextExposureState,C as exposedAtOrAbove,b as exposureTarget,Q as freezePreferenceSnapshot,V as hasTranscriptExposure,ee as initializeForkContextExposure,$ as loadContextExposureState,Y as mergeContextExposureState,L as registerDocumentExposure,m as registerExposure,k as replaceContextExposureState,P as saveContextExposureState,Z as sharedContextExposureState};
1
+ var T=Object.defineProperty;var s=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createHash as M}from"node:crypto";import{injectedDocsPath as S,nodeRunDir as d}from"../canvas/paths.js";import{realpathOrSelf as w}from"../fs-utils.js";import{existsBeneath as g,readFileBeneath as B,setModeBeneath as R,statBeneath as z,unlinkBeneath as D,writeFileBeneath as N}from"../spaces/open-beneath.js";import{rungRank as v}from"./schema.js";function V(e){return{preferenceSnapshot:e.preferenceSnapshot,exposures:Object.fromEntries(e.exposures)}}s(V,"snapshotContextExposure");function W(e){if(e===null||typeof e!="object"||e.preferenceSnapshot!==null&&typeof e.preferenceSnapshot!="string"||e.exposures===null||typeof e.exposures!="object"||Array.isArray(e.exposures))throw new Error("invalid context exposure snapshot");const t=x();t.preferenceSnapshot=e.preferenceSnapshot;for(const[r,n]of Object.entries(e.exposures)){if(n===null||typeof n!="object"||Array.isArray(n)||n.system===void 0&&n.transcript===void 0||n.system!==void 0&&!u(n.system)||n.transcript!==void 0&&!u(n.transcript))throw new Error(`invalid context exposure ranks for '${r}'`);t.exposures.set(r,{...n})}return t}s(W,"restoreContextExposure");const F=v("content"),a=new Map;function x(){return{preferenceSnapshot:null,exposures:new Map}}s(x,"emptyContextExposureState");function $(e,t,r){return r===void 0?{state:e,source:t}:{state:e,source:t,loads:r}}s($,"exposureTarget");function u(e){return typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=F}s(u,"validRank");function J(e){return Math.max(e?.system??0,e?.transcript??0)}s(J,"activeRank");function O(e,t,r){return J(e.exposures.get(t))>=v(r)}s(O,"exposedAtOrAbove");function y(e,t,r){const n=v(r);if(n===0)return;const o=e.state.exposures.get(t)??{};(o[e.source]??0)>=n||e.state.exposures.set(t,{...o,[e.source]:n})}s(y,"registerExposure");function b(e){const t=e.trim();return t===""?null:`content-sha256:${M("sha256").update(t).digest("hex")}`}s(b,"contentExposureIdentity");function P(e,t,r,n){if(O(e,w(t),n))return!0;const o=b(r);return o!==null&&O(e,o,n)}s(P,"documentExposedAtOrAbove");function X(e,t,r){const{path:n,body:o}=t;r==="content"&&e.loads!==void 0&&!P(e.state,n,o,"content")&&e.loads.push({name:t.name,scope:t.scope}),y(e,w(n),r);const p=b(o);p!==null&&y(e,p,r)}s(X,"registerDocumentExposure");function j(e,t){const r=e.exposures.get(t);r!==void 0&&(u(r.system)?e.exposures.set(t,{system:r.system}):e.exposures.delete(t))}s(j,"dropTranscriptExposure");function Y(e,t,r){j(e,w(t));const n=b(r);n!==null&&j(e,n)}s(Y,"demoteDocumentTranscriptExposure");function Z(e,t){return e.preferenceSnapshot===null&&(e.preferenceSnapshot=t),e.preferenceSnapshot}s(Z,"freezePreferenceSnapshot");function I(e){return{preferenceSnapshot:e.preferenceSnapshot,exposures:new Map([...e.exposures].map(([t,r])=>[t,{...r}]))}}s(I,"cloneContextExposureState");function ee(e){return[...e.exposures.values()].some(t=>u(t.transcript))}s(ee,"hasTranscriptExposure");function q(e){const t=x(),r=$(t,"transcript");for(const[n,o]of e.exposures){const p=o.transcript;u(p)&&y(r,n,p===1?"name":p===2?"preview":"content")}return t}s(q,"cloneTranscriptExposureState");function k(e,t){e.preferenceSnapshot=t.preferenceSnapshot,e.exposures.clear();for(const[r,n]of t.exposures)e.exposures.set(r,{...n})}s(k,"replaceContextExposureState");function te(e,t){if(e.preferenceSnapshot!==t.preferenceSnapshot||e.exposures.size!==t.exposures.size)return!1;for(const[r,n]of e.exposures){const o=t.exposures.get(r);if(n.system!==o?.system||n.transcript!==o?.transcript)return!1}return!0}s(te,"contextExposureStatesEqual");function re(e,t){if(e.preferenceSnapshot!==null&&t.preferenceSnapshot!==null&&e.preferenceSnapshot!==t.preferenceSnapshot)throw new Error("context exposure state contains conflicting preference snapshots");e.preferenceSnapshot===null&&t.preferenceSnapshot!==null&&(e.preferenceSnapshot=t.preferenceSnapshot);for(const[r,n]of t.exposures){const o=e.exposures.get(r)??{},p=Math.max(o.system??0,n.system??0),i=Math.max(o.transcript??0,n.transcript??0);e.exposures.set(r,{...p>0?{system:p}:{},...i>0?{transcript:i}:{}})}}s(re,"mergeContextExposureState");function ne(e){let t=a.get(e);return t===void 0&&(t=x(),a.set(e,t)),t}s(ne,"sharedContextExposureState");function C(e){const t=S(e);let r;try{r=JSON.parse(B(d(e),t).toString("utf8"))}catch(c){if(c.code==="ENOENT")return x();throw new Error(`failed to read context exposure state at ${t}: ${c instanceof Error?c.message:String(c)}`)}const n=x(),o=$(n,"transcript");if(Array.isArray(r)){for(const c of r){if(typeof c!="string")throw new Error(`invalid v1 context exposure state at ${t}`);y(o,c,"content")}return n}if(r===null||typeof r!="object")throw new Error(`invalid context exposure state at ${t}`);const p=r;if(p.v===3){const c=p.preferenceSnapshot,f=p.exposures;if(c!==null&&typeof c!="string"||f===null||typeof f!="object"||Array.isArray(f))throw new Error(`invalid v3 context exposure state at ${t}`);n.preferenceSnapshot=c;for(const[E,m]of Object.entries(f)){if(m===null||typeof m!="object"||Array.isArray(m))throw new Error(`invalid v3 exposure entry '${E}' at ${t}`);const A=m,h=A.system,l=A.transcript;if(h!==void 0&&!u(h)||l!==void 0&&!u(l)||h===void 0&&l===void 0)throw new Error(`invalid v3 exposure ranks for '${E}' at ${t}`);n.exposures.set(E,{...u(h)?{system:h}:{},...u(l)?{transcript:l}:{}})}return n}if(p.v!==2)throw new Error(`unsupported context exposure state at ${t}`);const i=p.docs;if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`invalid v2 context exposure state at ${t}`);for(const[c,f]of Object.entries(i)){if(!u(f))throw new Error(`invalid v2 exposure rank for '${c}' at ${t}`);y(o,c,f===1?"name":f===2?"preview":"content")}return n}s(C,"loadContextExposureState");function H(e,t){const r=d(e),n=S(e);let o=384;try{o=z(r,n).mode&511}catch(i){if(i.code!=="ENOENT")throw i}const p=`${JSON.stringify({v:3,preferenceSnapshot:t.preferenceSnapshot,exposures:Object.fromEntries(t.exposures)},null,2)}
2
+ `;N(r,n,p,{atomic:!0,mode:o}),R(r,n,o)}s(H,"saveContextExposureState");function oe(e){const t=a.get(e);t!==void 0&&k(t,x());try{D(d(e),S(e))}catch(r){if(r.code!=="ENOENT")throw r}}s(oe,"clearContextExposureState");function se(e,t){if(g(d(e),S(e))){const o=C(e),p=a.get(e);p===void 0?a.set(e,o):k(p,o);return}const r=t===null?x():q(C(t)),n=a.get(e);n===void 0?a.set(e,r):k(n,r),H(e,r)}s(se,"initializeForkContextExposure");export{oe as clearContextExposureState,I as cloneContextExposureState,q as cloneTranscriptExposureState,b as contentExposureIdentity,te as contextExposureStatesEqual,Y as demoteDocumentTranscriptExposure,P as documentExposedAtOrAbove,x as emptyContextExposureState,O as exposedAtOrAbove,$ as exposureTarget,Z as freezePreferenceSnapshot,ee as hasTranscriptExposure,se as initializeForkContextExposure,C as loadContextExposureState,re as mergeContextExposureState,X as registerDocumentExposure,y as registerExposure,k as replaceContextExposureState,W as restoreContextExposure,H as saveContextExposureState,ne as sharedContextExposureState,V as snapshotContextExposure};
@@ -1 +1 @@
1
- var h=Object.defineProperty;var o=(e,n)=>h(e,"name",{value:n,configurable:!0});import{buildMemoryTree as a}from"../memory/tree.js";import{parseSubstrateDoc as x,previewLine as D}from"./schema.js";import{documentExposedAtOrAbove as b,registerDocumentExposure as w}from"./injected-store.js";function A(e){return`dir://${e}`}o(A,"dirDedupKey");function E(e){const n=new Map;for(const t of e)n.has(t.name)||n.set(t.name,t);return n}o(E,"docsByName");const f=new WeakMap;function p(e){const n=f.get(e);if(n!==void 0)return n;const t=a([...e.values()]);return f.set(e,t),t}o(p,"treeFor");function y(e,n){return n!==""&&p(e).isDirectory(n)}o(y,"isDirName");function v(e){const n=[],t=e.split("/");for(let r=t.length-1;r>=1;r--)n.push(t.slice(0,r).join("/"));return n}o(v,"ancestorDirsOf");function O(e,n){return[...y(e,n)?[n]:[],...v(n)]}o(O,"docListingDirs");function d(e,n,t){const r=x(e);return r?.unlisted||t&&n!==null&&b(n.state,e.path,e.body,"preview")?null:(n!==null&&w(n,e.path,e.body,"preview"),r===null?"":D(r))}o(d,"previewSuffix");function m(e,n){return n===null||n===""?`[[${e}]]`:`[[${e}]]: ${n}`}o(m,"line");function S(e,n,t,r,l){const s=p(e).node(n);if(s===null)return[];const c=[];for(const u of s.childDocuments){const i=d(u.document,t,r);i!==null&&(l?.(u.document),c.push(m(u.name,i)))}for(const u of s.childDirectories){const i=u.document===null?null:d(u.document,t,r);u.document!==null&&i!==null&&l?.(u.document),c.push(m(u.name,i))}return c}o(S,"renderDirListing");export{v as ancestorDirsOf,A as dirDedupKey,O as docListingDirs,E as docsByName,y as isDirName,S as renderDirListing};
1
+ var h=Object.defineProperty;var o=(e,n)=>h(e,"name",{value:n,configurable:!0});import{buildMemoryTree as x}from"../memory/tree.js";import{parseSubstrateDoc as D,previewLine as a}from"./schema.js";import{documentExposedAtOrAbove as b,registerDocumentExposure as w}from"./injected-store.js";function A(e){return`dir://${e}`}o(A,"dirDedupKey");function E(e){const n=new Map;for(const t of e)n.has(t.name)||n.set(t.name,t);return n}o(E,"docsByName");const f=new WeakMap;function p(e){const n=f.get(e);if(n!==void 0)return n;const t=x([...e.values()]);return f.set(e,t),t}o(p,"treeFor");function v(e,n){return n!==""&&p(e).isDirectory(n)}o(v,"isDirName");function y(e){const n=[],t=e.split("/");for(let r=t.length-1;r>=1;r--)n.push(t.slice(0,r).join("/"));return n}o(y,"ancestorDirsOf");function O(e,n){return[...v(e,n)?[n]:[],...y(n)]}o(O,"docListingDirs");function d(e,n,t){const r=D(e);return r?.unlisted||t&&n!==null&&b(n.state,e.path,e.body,"preview")?null:(n!==null&&w(n,e,"preview"),r===null?"":a(r))}o(d,"previewSuffix");function m(e,n){return n===null||n===""?`[[${e}]]`:`[[${e}]]: ${n}`}o(m,"line");function S(e,n,t,r,l){const s=p(e).node(n);if(s===null)return[];const c=[];for(const u of s.childDocuments){const i=d(u.document,t,r);i!==null&&(l?.(u.document),c.push(m(u.name,i)))}for(const u of s.childDirectories){const i=u.document===null?null:d(u.document,t,r);u.document!==null&&i!==null&&l?.(u.document),c.push(m(u.name,i))}return c}o(S,"renderDirListing");export{y as ancestorDirsOf,A as dirDedupKey,O as docListingDirs,E as docsByName,v as isDirName,S as renderDirListing};
@@ -0,0 +1,6 @@
1
+ import type { MemoryReadEventDTO } from '../../api/dto/analytics.js';
2
+ import type { MemoryLoad } from './injected-store.js';
3
+ export declare function memoryEvents(loads: readonly MemoryLoad[], type: MemoryReadEventDTO['type'], at?: string): MemoryReadEventDTO[];
4
+ /** One POST for all of `events`; resolves (never rejects) whether or not crtrd
5
+ * recorded them. Sends nothing when there is nothing to record. */
6
+ export declare function sendMemoryEvents(nodeId: string, events: MemoryReadEventDTO[]): Promise<void>;
@@ -0,0 +1 @@
1
+ var i=Object.defineProperty;var r=(o,t)=>i(o,"name",{value:t,configurable:!0});import{localClient as c}from"../../api/node-transport.js";function s(o,t,e=new Date().toISOString()){return o.map(({name:n,scope:a})=>({name:n,scope:a,at:e,type:t}))}r(s,"memoryEvents");async function u(o,t){if(t.length!==0)try{await c({autostart:!1,coldStartPollWindowMs:0,timeoutMs:500}).recordMemoryReads(o,{events:t})}catch{}}r(u,"sendMemoryEvents");export{s as memoryEvents,u as sendMemoryEvents};
@@ -1 +1 @@
1
- var s=Object.defineProperty;var n=(e,t)=>s(e,"name",{value:t,configurable:!0});import{getNode as i}from"../canvas/index.js";import{emptyContextExposureState as c,exposureTarget as u}from"./injected-store.js";import{assembleNodeSubject as p}from"./subject.js";import{renderOnReadDocsForSubject as a,renderWorkspaceOpenDocsForSubject as l}from"./on-read.js";function x(e,t,o=u(c(),"transcript")){let r;try{r=p(e)}catch{return""}return r===null?"":a(r,t,o)}n(x,"renderOnReadDocs");function D(e,t=u(c(),"transcript")){try{const o=p(e),r=i(e);return o===null||r===null?"":l(o,r.cwd,r.profile_id??null,t)}catch{return""}}n(D,"renderWorkspaceOpenDocs");export{x as renderOnReadDocs,D as renderWorkspaceOpenDocs};
1
+ var i=Object.defineProperty;var n=(e,t)=>i(e,"name",{value:t,configurable:!0});import{getNode as m}from"../canvas/index.js";import{appForNode as s}from"../canvas/node-agent-paths.js";import{automaticMemoryTarget as a}from"../spaces/permissions.js";import{emptyContextExposureState as c,exposureTarget as p}from"./injected-store.js";import{assembleNodeSubject as u}from"./subject.js";import{renderOnReadDocsForSubject as f,renderWorkspaceOpenDocsForSubject as l}from"./on-read.js";function S(e,t,o=p(c(),"transcript")){let r;try{r=u(e)}catch{return""}return r===null?"":f(r,t,o)}n(S,"renderOnReadDocs");function y(e,t=p(c(),"transcript")){const o=u(e),r=m(e);return o===null||r===null?"":l(o,r.cwd,r.profile_id??null,t,void 0,a({...r,grantee:s(e)}))}n(y,"renderWorkspaceOpenDocs");export{S as renderOnReadDocs,y as renderWorkspaceOpenDocs};
@@ -57,8 +57,8 @@ export declare function contentReadAttachments(doc: Pick<SubstrateDoc, 'name' |
57
57
  export declare function renderAutoLoadedContext(blocks: readonly string[]): string;
58
58
  /** Surface docs whose `read` entries match a successfully read file, using
59
59
  * the caller-supplied daemon snapshot subject. */
60
- export declare function renderOnReadDocBlocksForSubject(subject: NodeConfigSubject, readFilePath: string, target?: ExposureTarget, accounting?: DeliveryAccounting): string[];
61
- export declare function renderOnReadDocsForSubject(subject: NodeConfigSubject, readFilePath: string, target?: ExposureTarget, accounting?: DeliveryAccounting): string;
60
+ export declare function renderOnReadDocBlocksForSubject(subject: NodeConfigSubject, readFilePath: string, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string[];
61
+ export declare function renderOnReadDocsForSubject(subject: NodeConfigSubject, readFilePath: string, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string;
62
62
  /** Workspace boot docs using the snapshot's cwd/profile instead of a canvas
63
63
  * lookup. The shared exposure target prevents a later read from repeating a
64
64
  * document already loaded here.
@@ -67,7 +67,7 @@ export declare function renderOnReadDocsForSubject(subject: NodeConfigSubject, r
67
67
  * relationship cap BEFORE filtering, ordering, rendering, and exposure
68
68
  * registration. A later explicit `crtr memory read` can still raise a document
69
69
  * that workspace-open disclosed at a lower rung. */
70
- export declare function renderWorkspaceOpenDocsForSubject(subject: NodeConfigSubject, cwd: string, profileId: string | null, target?: ExposureTarget, accounting?: DeliveryAccounting): string;
70
+ export declare function renderWorkspaceOpenDocsForSubject(subject: NodeConfigSubject, cwd: string, profileId: string | null, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string;
71
71
  /** Inner `<memory>` blocks for the memory-read event: docs whose
72
72
  * `memory-read` entries match the doc a `crtr memory read` just resolved
73
73
  * (known by its exact canonical `name` — no mount-stripped or other alias;
@@ -80,13 +80,13 @@ export declare function memoryReadDocBlocks(excludeRealpath: string, name: strin
80
80
  /** Surface docs whose `command` entries match an executed bash command.
81
81
  * The corpus is the resolved cwd/profile set; a command has no file from which
82
82
  * to discover enclosing project stores. */
83
- export declare function renderOnCommandDocsForSubject(subject: NodeConfigSubject, command: string, target?: ExposureTarget, accounting?: DeliveryAccounting): string;
83
+ export declare function renderOnCommandDocsForSubject(subject: NodeConfigSubject, command: string, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string;
84
84
  /** Surface docs whose `pre-command` entries match a bash command that has NOT
85
85
  * run yet. The exact twin of the post-execution renderer above, and its empty
86
86
  * string is load-bearing: `''` means every matching doc is already exposed at
87
87
  * its matching rung or above, which is the release — the caller lets the
88
88
  * command through. */
89
- export declare function renderPreCommandDocsForSubject(subject: NodeConfigSubject, command: string, target?: ExposureTarget, accounting?: DeliveryAccounting): string;
89
+ export declare function renderPreCommandDocsForSubject(subject: NodeConfigSubject, command: string, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string;
90
90
  /** Whether this command matches a `command` surface before its node-config
91
91
  * gate is evaluated. A matching gate still requires a subject lookup. */
92
92
  export declare function corpusHasCommandSurfaceForCommand(command: string): boolean;
@@ -98,4 +98,4 @@ export declare function corpusHasPreCommandSurfaceForCommand(command: string): b
98
98
  * ledger still claims it was delivered, so without this pass a doc could be
99
99
  * held once and then silently absent for the rest of the session. Lives here
100
100
  * rather than in the extension because the corpus accessor is private. */
101
- export declare function demotePreCommandExposures(state: ContextExposureState): void;
101
+ export declare function demotePreCommandExposures(state: ContextExposureState, memoryTarget?: MemoryTarget): void;
@@ -1,9 +1,9 @@
1
- var T=Object.defineProperty;var i=(e,n)=>T(e,"name",{value:n,configurable:!0});import{sep as w}from"node:path";import{realpathOrSelf as E}from"../fs-utils.js";import{ambientMemoryTarget as B,listAllMemoryDocs as M,loadMemoryTargetView as P}from"../memory-resolver.js";import{commandEntryMatches as j,owningRootOf as S,preCommandEntryMatches as L}from"./surface-match.js";import{demoteDocumentTranscriptExposure as W,documentExposedAtOrAbove as q,emptyContextExposureState as H,exposedAtOrAbove as I,exposureTarget as K,registerDocumentExposure as V,registerExposure as z}from"./injected-store.js";import{planDelivery as b}from"./plan.js";import{parseSubstrateDoc as G,previewLine as J,rungRank as O}from"./schema.js";import{dirDedupKey as A,docListingDirs as Q,docsByName as F,isDirName as U,renderDirListing as X}from"./listings.js";import{cachedEventCorpusInclusive as Y}from"./session-cache.js";function h(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}i(h,"attr");function C(){try{return Y(M,G)}catch{return[]}}i(C,"resolvedDocs");function Z(e,n){if(n==="none")return null;let r=`kind="${h(e.kind)}" name="${h(e.name)}"`;if(n==="content"){const t=e.body.trim();if(t!=="")return`<memory ${r}>
2
- ${t}
3
- </memory>`}else if(n==="preview"){const t=J(e);t!==""&&(r+=` readWhen="${h(t)}"`)}return`<memory ${r} />`}i(Z,"renderDocEnvelope");function l(e){return e.docs.filter(n=>n.winner).map(n=>({doc:n.doc,rung:n.finalRung,source:n.source}))}i(l,"planWinners");function R(e){return F(e.docs.map(({source:n})=>n))}i(R,"planListingCorpus");function _(e,n){return`<memory-listing dir="${h(e)}">
1
+ var P=Object.defineProperty;var i=(e,n)=>P(e,"name",{value:n,configurable:!0});import{sep as w}from"node:path";import{realpathOrSelf as E}from"../fs-utils.js";import{ambientMemoryTarget as j,listAllMemoryDocs as L,loadMemoryTargetView as S}from"../memory-resolver.js";import{commandEntryMatches as W,owningRootOf as O,preCommandEntryMatches as q}from"./surface-match.js";import{demoteDocumentTranscriptExposure as T,documentExposedAtOrAbove as H,emptyContextExposureState as I,exposedAtOrAbove as K,exposureTarget as V,registerDocumentExposure as z,registerExposure as G}from"./injected-store.js";import{planDelivery as C}from"./plan.js";import{parseSubstrateDoc as A,previewLine as J,rungRank as F}from"./schema.js";import{dirDedupKey as R,docListingDirs as Q,docsByName as $,isDirName as U,renderDirListing as X}from"./listings.js";import{cachedEventCorpusInclusive as Y}from"./session-cache.js";function g(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}i(g,"attr");function D(){try{return Y(L,A)}catch{return[]}}i(D,"resolvedDocs");function Z(e,n){if(n==="none")return null;let t=`kind="${g(e.kind)}" name="${g(e.name)}"`;if(n==="content"){const r=e.body.trim();if(r!=="")return`<memory ${t}>
2
+ ${r}
3
+ </memory>`}else if(n==="preview"){const r=J(e);r!==""&&(t+=` readWhen="${g(r)}"`)}return`<memory ${t} />`}i(Z,"renderDocEnvelope");function p(e){return e.docs.filter(n=>n.winner).map(n=>({doc:n.doc,rung:n.finalRung,source:n.source}))}i(p,"planWinners");function N(e){return $(e.docs.map(({source:n})=>n))}i(N,"planListingCorpus");function _(e,n){return`<memory-listing dir="${g(e)}">
4
4
  ${n.join(`
5
5
  `)}
6
- </memory-listing>`}i(_,"listingBlock");function fe(){return{deliveries:new Map}}i(fe,"deliveryAccounting");function $(e,n,r,t,o){if(e===void 0||r==="none")return;const c=E(n.path),a=e.deliveries.get(c);a!==void 0&&O(a.rung)>=O(r)||e.deliveries.set(c,{rung:r,...t===void 0?{}:{cause:t},...o===void 0?{}:{source:o}})}i($,"accountDelivery");function ee(e,n){const{target:r,byName:t}=n,o=Q(t,e.name),c=o[0]===e.name,a=[];let s;for(const[y,u]of o.entries()){if(!U(t,u))continue;const m=c&&y===0;if(!m&&I(r.state,A(u),"preview"))continue;if(n.listings==="tree"){n.dirs?.push(u);continue}const d=m&&n.explicit===!0,g=X(t,u,r,!d,k=>$(n.accounting,k,"preview","directory listing attached to content delivery",k));g.length!==0&&(z(r,A(u),"preview"),d?s=g:a.push(_(u,g)))}return a.push(...re(E(e.path),e.name,{...n,deliveryCause:"memory-read companion of content delivery"})),{blocks:a,...s===void 0?{}:{listing:s}}}i(ee,"contentReadAttachments");function p(e,n){const{target:r}=n,t=[];for(const{doc:o,rung:c,source:a}of e){if(q(r.state,o.path,o.body,c))continue;const s=Z(o,c);s!==null&&(V(r,o.path,o.body,c),$(n.accounting,o,c,n.deliveryCause,a),c==="content"&&t.push(...ee(o,{...n,deliveryCause:"memory-read companion of content delivery"}).blocks),t.push(s))}return t}i(p,"renderWinnerBlocks");function D(e,n,r,t){return{subject:e,target:n,byName:R(r),listings:"blocks",accounting:t}}i(D,"eventAttachmentOptions");function f(){return K(H(),"transcript")}i(f,"transientTranscriptTarget");function x(e){return e.length===0?"":`<auto-loaded-context>
6
+ </memory-listing>`}i(_,"listingBlock");function fe(){return{deliveries:new Map}}i(fe,"deliveryAccounting");function B(e,n,t,r,o){if(e===void 0||t==="none")return;const c=E(n.path),a=e.deliveries.get(c);a!==void 0&&F(a.rung)>=F(t)||e.deliveries.set(c,{rung:t,...r===void 0?{}:{cause:r},...o===void 0?{}:{source:o}})}i(B,"accountDelivery");function ee(e,n){const{target:t,byName:r}=n,o=Q(r,e.name),c=o[0]===e.name,a=[];let s;for(const[h,u]of o.entries()){if(!U(r,u))continue;const m=c&&h===0;if(!m&&K(t.state,R(u),"preview"))continue;if(n.listings==="tree"){n.dirs?.push(u);continue}const l=m&&n.explicit===!0,d=X(r,u,t,!l,b=>B(n.accounting,b,"preview","directory listing attached to content delivery",b));d.length!==0&&(G(t,R(u),"preview"),l?s=d:a.push(_(u,d)))}return a.push(...re(E(e.path),e.name,{...n,deliveryCause:"memory-read companion of content delivery"})),{blocks:a,...s===void 0?{}:{listing:s}}}i(ee,"contentReadAttachments");function f(e,n){const{target:t}=n,r=[];for(const{doc:o,rung:c,source:a}of e){if(H(t.state,o.path,o.body,c))continue;const s=Z(o,c);s!==null&&(z(t,o,c),B(n.accounting,o,c,n.deliveryCause,a),c==="content"&&r.push(...ee(o,{...n,deliveryCause:"memory-read companion of content delivery"}).blocks),r.push(s))}return r}i(f,"renderWinnerBlocks");function k(e,n,t,r,o){return{subject:e,target:n,byName:N(t),listings:"blocks",accounting:r,memoryTarget:o}}i(k,"eventAttachmentOptions");function y(){return V(I(),"transcript")}i(y,"transientTranscriptTarget");function x(e){return e.length===0?"":`<auto-loaded-context>
7
7
  ${e.join(`
8
8
  `)}
9
- </auto-loaded-context>`}i(x,"renderAutoLoadedContext");function v(e,n,r,t){return t===void 0?b(e,B(),n,r,C()):b(e,t,n,r)}i(v,"eventPlan");function ne(e,n,r=f(),t){const o=v(e,"read",{absoluteFile:n});return p(l(o),D(o.subject,r,o,t))}i(ne,"renderOnReadDocBlocksForSubject");function ye(e,n,r=f(),t){return x(ne(e,n,r,t))}i(ye,"renderOnReadDocsForSubject");function ge(e,n,r,t=f(),o){const c={cwd:n,profileId:r,nodeId:null};let a,s;try{a=l(b(e,c,"workspace-open")),s=F(P(c,{quiet:!0}).docs)}catch{return""}return a.sort((y,u)=>{const m=S(y.doc)??"",d=S(u.doc)??"";return m.split(w).filter(Boolean).length-d.split(w).filter(Boolean).length||m.localeCompare(d)||y.doc.path.localeCompare(u.doc.path)}),x(p(a,{subject:e,target:t,byName:s,memoryTarget:c,listings:"blocks",accounting:o}))}i(ge,"renderWorkspaceOpenDocsForSubject");function re(e,n,r){const t=v(r.subject,"memory-read",{resolvedCanonicalName:n,resolvedDocPath:e},r.memoryTarget);return p(l(t),{...r,byName:r.byName??R(t)})}i(re,"memoryReadDocBlocks");function he(e,n,r=f(),t){const o=v(e,"command",{command:n});return x(p(l(o),D(e,r,o,t)))}i(he,"renderOnCommandDocsForSubject");function xe(e,n,r=f(),t){const o=v(e,"pre-command",{command:n});return x(p(l(o),D(e,r,o,t)))}i(xe,"renderPreCommandDocsForSubject");function te(e){return e.surfaces.some(n=>n.on==="pre-command")}i(te,"carriesPreCommandEntry");function N(e,n){const r=n==="command"?j:L;return C().some(({doc:t})=>t.surfaces.some(o=>r(o,e)))}i(N,"hasCommandSurfaceForCommand");function ve(e){return N(e,"command")}i(ve,"corpusHasCommandSurfaceForCommand");function be(e){return N(e,"pre-command")}i(be,"corpusHasPreCommandSurfaceForCommand");function Ce(e){for(const{doc:n}of C())te(n)&&W(e,n.path,n.body)}i(Ce,"demotePreCommandExposures");export{$ as accountDelivery,ee as contentReadAttachments,ve as corpusHasCommandSurfaceForCommand,be as corpusHasPreCommandSurfaceForCommand,fe as deliveryAccounting,Ce as demotePreCommandExposures,re as memoryReadDocBlocks,x as renderAutoLoadedContext,he as renderOnCommandDocsForSubject,ne as renderOnReadDocBlocksForSubject,ye as renderOnReadDocsForSubject,xe as renderPreCommandDocsForSubject,ge as renderWorkspaceOpenDocsForSubject};
9
+ </auto-loaded-context>`}i(x,"renderAutoLoadedContext");function v(e,n,t,r){return r===void 0?C(e,j(),n,t,D()):C(e,r,n,t)}i(v,"eventPlan");function ne(e,n,t=y(),r,o){const c=v(e,"read",{absoluteFile:n},o);return f(p(c),k(c.subject,t,c,r,o))}i(ne,"renderOnReadDocBlocksForSubject");function ye(e,n,t=y(),r,o){return x(ne(e,n,t,r,o))}i(ye,"renderOnReadDocsForSubject");function he(e,n,t,r=y(),o,c){const a=c===void 0?{cwd:n,profileId:t,nodeId:null}:{...c,cwd:n,profileId:t,nodeId:null};let s,h;try{s=p(C(e,a,"workspace-open")),h=$(S(a,{quiet:!0}).docs)}catch{return""}return s.sort((u,m)=>{const l=O(u.doc)??"",d=O(m.doc)??"";return l.split(w).filter(Boolean).length-d.split(w).filter(Boolean).length||l.localeCompare(d)||u.doc.path.localeCompare(m.doc.path)}),x(f(s,{subject:e,target:r,byName:h,memoryTarget:a,listings:"blocks",accounting:o}))}i(he,"renderWorkspaceOpenDocsForSubject");function re(e,n,t){const r=v(t.subject,"memory-read",{resolvedCanonicalName:n,resolvedDocPath:e},t.memoryTarget);return f(p(r),{...t,byName:t.byName??N(r)})}i(re,"memoryReadDocBlocks");function ge(e,n,t=y(),r,o){const c=v(e,"command",{command:n},o);return x(f(p(c),k(e,t,c,r,o)))}i(ge,"renderOnCommandDocsForSubject");function xe(e,n,t=y(),r,o){const c=v(e,"pre-command",{command:n},o);return x(f(p(c),k(e,t,c,r,o)))}i(xe,"renderPreCommandDocsForSubject");function te(e){return e.surfaces.some(n=>n.on==="pre-command")}i(te,"carriesPreCommandEntry");function M(e,n){const t=n==="command"?W:q;return D().some(({doc:r})=>r.surfaces.some(o=>t(o,e)))}i(M,"hasCommandSurfaceForCommand");function ve(e){return M(e,"command")}i(ve,"corpusHasCommandSurfaceForCommand");function be(e){return M(e,"pre-command")}i(be,"corpusHasPreCommandSurfaceForCommand");function Ce(e,n){const t=n===void 0?D():S(n,{quiet:!0}).docs.map(r=>({doc:A(r)})).filter(r=>r.doc!==null);for(const{doc:r}of t)te(r)&&T(e,r.path,r.body)}i(Ce,"demotePreCommandExposures");export{B as accountDelivery,ee as contentReadAttachments,ve as corpusHasCommandSurfaceForCommand,be as corpusHasPreCommandSurfaceForCommand,fe as deliveryAccounting,Ce as demotePreCommandExposures,re as memoryReadDocBlocks,x as renderAutoLoadedContext,ge as renderOnCommandDocsForSubject,ne as renderOnReadDocBlocksForSubject,ye as renderOnReadDocsForSubject,xe as renderPreCommandDocsForSubject,he as renderWorkspaceOpenDocsForSubject};
@@ -1 +1 @@
1
- var P=Object.defineProperty;var a=(e,t)=>P(e,"name",{value:t,configurable:!0});import{homedir as b}from"node:os";import{dirname as w,parse as k,sep as S}from"node:path";import{parseFrontmatterGeneric as R}from"../frontmatter.js";import{readText as D,realpathOrSelf as l}from"../fs-utils.js";import{listProjectMemoryDocs as G,loadMemoryTargetView as M,loadStoreMemoryDocs as E,openProjectMemoryStore as x}from"../memory-resolver.js";import{userScopeRoot as C}from"../scope.js";import{gatePasses as O,surfaceEntryGatePasses as A}from"./gate.js";import{minRung as $,parseSubstrateDoc as F,rungAtLeast as y}from"./schema.js";import{matchingSurfaceEntry as L,surfaceEntryParticipates as N}from"./surface-match.js";function B(e){return e.nodeLocal?"knowledge":e.kind}a(B,"bootPartitionOf");function ie(e,t,n,o={},r){const s=I(n,o),u=T(n,r??K(t,n),s).map(({doc:c,source:f})=>U(c,f,e,n,s));return Q(n,u),{event:n,subject:e,target:t,docs:u}}a(ie,"planDelivery");function I(e,t){if(e!=="read"||t.absoluteFile===void 0)return{...t,readFrontmatter:t.readFrontmatter??{}};const n=l(t.absoluteFile);return{...t,absoluteFile:n,readFrontmatter:t.readFrontmatter??J(n)}}a(I,"resolvePayload");function J(e){if(!/\.(md|mdx|markdown)$/i.test(e))return{};try{return R(D(e)).data??{}}catch{return{}}}a(J,"readFileFrontmatter");function T(e,t,n){if(e==="read"){const o=n.absoluteFile;return o===void 0?[...t]:[...q(o),...t].filter(({doc:r})=>l(r.path)!==o)}if(e==="memory-read"&&n.resolvedDocPath!==void 0){const o=n.resolvedDocPath;return t.filter(({doc:r})=>l(r.path)!==o)}return[...t]}a(T,"considerFor");const _=new Set(["node_modules",".git","dist","build",".next",".cache",".yalc"]);function j(e){return e.split(S).some(t=>_.has(t))}a(j,"isJunkAncestor");function q(e){const t=[],n=new Set,o=l(b()),r=l(C()),s=k(e).root;let i=w(e);for(;;){if(i!==o&&i!==r&&!j(i)){const c=x(i);if(c.mountStatus==="ready"&&!n.has(c.storeRoot)){n.add(c.storeRoot);for(const f of E(c,!0)){const m=F(f);m!==null&&t.push({doc:m,source:f})}}}if(i===o||i===s)break;const u=w(i);if(u===i)break;i=u}return t}a(q,"enclosingProjectDocs");function K(e,t){const n=t==="workspace-open"?G(e.cwd,e.profileId):M(e,{quiet:!0}).docs,o=[];for(const r of n){const s=F(r);s!==null&&o.push({doc:s,source:r})}return t!=="boot"?o:[...o.filter(r=>r.doc.scope!=="node"),...o.filter(r=>r.doc.scope==="node")]}a(K,"loadEventCorpus");function U(e,t,n,o,r){const s={absoluteFile:r.absoluteFile,readFrontmatter:r.readFrontmatter,resolvedCanonicalName:r.resolvedCanonicalName,routingAnchor:t.routingAnchor,command:r.command},i=V(e,n),u=e.surfaces.filter(d=>d.on===o).map(d=>({entry:d,matched:N(d,e,n,o,s),gate:W(d,n)})),c=L(e,n,o,s),f=c?.at??"none",m=e.scope==="node",p=(o==="boot"||o==="workspace-open")&&!m?e.projectMemory:null,g=p===null?f:$(f,p);let h=i.pass?g:"none";return o==="boot"&&m&&i.pass&&!y(h,"name")&&!e.surfaces.some(d=>d.on==="boot")&&(h="name"),{name:e.name,kind:e.kind,scope:e.scope,storePath:e.path,nodeLocal:m,authoredEntries:u,matchedEntry:c,authoredRung:f,projectMemoryCap:p,cappedRung:g,docGate:i,entryGate:z(u,c),finalRung:h,winner:!1,shadowedBy:null,doc:e,source:t}}a(U,"decide");function V(e,t){if(e.gate===void 0)return{pass:!0};if(t===null)return{pass:!1,reason:"gated document with no node config to match"};try{return O(e,t)?{pass:!0}:{pass:!1,reason:"document gate does not match this node config"}}catch(n){return{pass:!1,reason:`document gate failed to evaluate: ${String(n)}`}}}a(V,"documentGateOutcome");function W(e,t){return e.gate===void 0?{pass:!0}:A(e,t)?{pass:!0}:{pass:!1,reason:"entry gate does not match this node config"}}a(W,"entryGateOutcome");function z(e,t){if(e.length===0)return null;if(t!==null)return{pass:!0};const n=e.find(o=>!o.gate.pass);return n===void 0?{pass:!0}:n.gate}a(z,"recordEntryGate");function H(e,t){return e.docGate.pass?t==="boot"?e.projectMemoryCap!=="none":y(e.finalRung,"name"):!1}a(H,"participates");function Q(e,t){const n=new Map;for(const o of t){if(!H(o,e))continue;const r=e==="boot"?`${B(o)}:${o.name}`:o.name,s=n.get(r);if(s===void 0){n.set(r,o),o.winner=!0;continue}o.shadowedBy={name:s.name,scope:s.scope,path:s.storePath}}}a(Q,"resolveWinners");export{B as bootPartitionOf,ie as planDelivery};
1
+ var b=Object.defineProperty;var c=(e,t)=>b(e,"name",{value:t,configurable:!0});import{homedir as k}from"node:os";import{dirname as F,parse as R,sep as D}from"node:path";import{parseFrontmatterGeneric as G}from"../frontmatter.js";import{readText as E,realpathOrSelf as l}from"../fs-utils.js";import{loadMemoryTargetView as S,loadStoreMemoryDocs as M,openProjectMemoryStore as x}from"../memory-resolver.js";import{userScopeRoot as C}from"../scope.js";import{gatePasses as O,surfaceEntryGatePasses as A}from"./gate.js";import{minRung as $,parseSubstrateDoc as y,rungAtLeast as P}from"./schema.js";import{matchingSurfaceEntry as L,surfaceEntryParticipates as N}from"./surface-match.js";function j(e){return e.nodeLocal?"knowledge":e.kind}c(j,"bootPartitionOf");function ae(e,t,o,n={},r){const s=q(o,n),a=J(o,r??K(t,o),s,t).map(({doc:u,source:i})=>U(u,i,e,o,s));return Q(o,a),{event:o,subject:e,target:t,docs:a}}c(ae,"planDelivery");function q(e,t){if(e!=="read"||t.absoluteFile===void 0)return{...t,readFrontmatter:t.readFrontmatter??{}};const o=l(t.absoluteFile);return{...t,absoluteFile:o,readFrontmatter:t.readFrontmatter??B(o)}}c(q,"resolvePayload");function B(e){if(!/\.(md|mdx|markdown)$/i.test(e))return{};try{return G(E(e)).data??{}}catch{return{}}}c(B,"readFileFrontmatter");function J(e,t,o,n){if(e==="read"){const r=o.absoluteFile;return r===void 0?[...t]:[...I(r,n),...t].filter(({doc:s})=>l(s.path)!==r)}if(e==="memory-read"&&o.resolvedDocPath!==void 0){const r=o.resolvedDocPath;return t.filter(({doc:s})=>l(s.path)!==r)}return[...t]}c(J,"considerFor");const T=new Set(["node_modules",".git","dist","build",".next",".cache",".yalc"]);function _(e){return e.split(D).some(t=>T.has(t))}c(_,"isJunkAncestor");function I(e,t){const o=[],n=new Set,r=l(k()),s=l(C()),m=R(e).root;let a=F(e);for(;;){if(a!==r&&a!==s&&!_(a)){const i=x(a);if(i.mountStatus==="ready"&&!n.has(i.storeRoot)&&t.allowsProject?.(i.repositoryRoot??i.ownerDir??i.storeRoot)!==!1&&t.allowsStore?.(i)!==!1){n.add(i.storeRoot);for(const f of M(i,!0)){if(t.allowsStore?.(i,f.name)===!1)continue;const p=y(f);p!==null&&o.push({doc:p,source:f})}}}if(a===r||a===m)break;const u=F(a);if(u===a)break;a=u}return o}c(I,"enclosingProjectDocs");function K(e,t){const o=t==="workspace-open"?S(e,{quiet:!0,scope:"project"}).docs:S(e,{quiet:!0}).docs,n=[];for(const r of o){const s=y(r);s!==null&&n.push({doc:s,source:r})}return t!=="boot"?n:[...n.filter(r=>r.doc.scope!=="node"),...n.filter(r=>r.doc.scope==="node")]}c(K,"loadEventCorpus");function U(e,t,o,n,r){const s={absoluteFile:r.absoluteFile,readFrontmatter:r.readFrontmatter,resolvedCanonicalName:r.resolvedCanonicalName,routingAnchor:t.routingAnchor,command:r.command},m=V(e,o),a=e.surfaces.filter(d=>d.on===n).map(d=>({entry:d,matched:N(d,e,o,n,s),gate:W(d,o)})),u=L(e,o,n,s),i=u?.at??"none",f=e.scope==="node",h=(n==="boot"||n==="workspace-open")&&!f?e.projectMemory:null,w=h===null?i:$(i,h);let g=m.pass?w:"none";return n==="boot"&&f&&m.pass&&!P(g,"name")&&!e.surfaces.some(d=>d.on==="boot")&&(g="name"),{name:e.name,kind:e.kind,scope:e.scope,storePath:e.path,nodeLocal:f,authoredEntries:a,matchedEntry:u,authoredRung:i,projectMemoryCap:h,cappedRung:w,docGate:m,entryGate:z(a,u),finalRung:g,winner:!1,shadowedBy:null,doc:e,source:t}}c(U,"decide");function V(e,t){if(e.gate===void 0)return{pass:!0};if(t===null)return{pass:!1,reason:"gated document with no node config to match"};try{return O(e,t)?{pass:!0}:{pass:!1,reason:"document gate does not match this node config"}}catch(o){return{pass:!1,reason:`document gate failed to evaluate: ${String(o)}`}}}c(V,"documentGateOutcome");function W(e,t){return e.gate===void 0?{pass:!0}:A(e,t)?{pass:!0}:{pass:!1,reason:"entry gate does not match this node config"}}c(W,"entryGateOutcome");function z(e,t){if(e.length===0)return null;if(t!==null)return{pass:!0};const o=e.find(n=>!n.gate.pass);return o===void 0?{pass:!0}:o.gate}c(z,"recordEntryGate");function H(e,t){return e.docGate.pass?t==="boot"?e.projectMemoryCap!=="none":P(e.finalRung,"name"):!1}c(H,"participates");function Q(e,t){const o=new Map;for(const n of t){if(!H(n,e))continue;const r=e==="boot"?`${j(n)}:${n.name}`:n.name,s=o.get(r);if(s===void 0){o.set(r,n),n.winner=!0;continue}n.shadowedBy={name:s.name,scope:s.scope,path:s.storePath}}}c(Q,"resolveWinners");export{j as bootPartitionOf,ae as planDelivery};
@@ -1 +1 @@
1
- var c=Object.defineProperty;var t=(e,r)=>c(e,"name",{value:r,configurable:!0});import{interpolateNodePaths as u}from"../canvas/paths.js";import{assembleNodeSubject as n}from"./subject.js";import{emptyContextExposureState as s,exposureTarget as p}from"./injected-store.js";import{renderPreferencesForSubject as i,renderKnowledgeForSubject as m}from"./render.js";function x(e){const r=n(e);return u(i(r).block,e)}t(x,"renderPreferencesSection");function S(e,r=p(s(),"transcript")){const o=n(e);return o===null?"":m(o,e,r)}t(S,"renderKnowledgeBlock");export{S as renderKnowledgeBlock,x as renderPreferencesSection};
1
+ var m=Object.defineProperty;var t=(e,r)=>m(e,"name",{value:r,configurable:!0});import{appForNode as n,interpolateNodePaths as p}from"../canvas/node-agent-paths.js";import{getNode as u}from"../canvas/canvas.js";import{automaticMemoryTarget as i}from"../spaces/permissions.js";import{assembleNodeSubject as c}from"./subject.js";import{emptyContextExposureState as f,exposureTarget as s}from"./injected-store.js";import{renderPreferencesForSubject as a,renderKnowledgeForSubject as l}from"./render.js";function P(e){const r=c(e);return p(a(r).block,e)}t(P,"renderPreferencesSection");function d(e,r=s(f(),"transcript")){const o=c(e);return o===null?"":l(o,e,r,void 0,n(e),i({...u(e),grantee:n(e)}))}t(d,"renderKnowledgeBlock");export{d as renderKnowledgeBlock,P as renderPreferencesSection};
@@ -1,3 +1,4 @@
1
+ import { type MemoryTarget } from '../memory-resolver.js';
1
2
  import { type ExposureTarget } from './injected-store.js';
2
3
  import { type SubstrateDoc } from './schema.js';
3
4
  import type { NodeConfigSubject } from './subject-fields.js';
@@ -10,7 +11,7 @@ import { type DeliveryAccounting } from './on-read.js';
10
11
  * header). Emitted for BOTH base and orchestrator modes per the CTO's ruling —
11
12
  * mode is irrelevant to which sub-kinds are spawnable. */
12
13
  export declare function buildSubPersonaMenu(kind: string): string;
13
- export declare function renderPreferencesForSubject(subject: NodeConfigSubject | null, target?: ExposureTarget, accounting?: DeliveryAccounting): {
14
+ export declare function renderPreferencesForSubject(subject: NodeConfigSubject | null, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): {
14
15
  block: string;
15
16
  contentDocs: SubstrateDoc[];
16
17
  tree: string;
@@ -27,7 +28,7 @@ export declare function renderPreferencesForSubject(subject: NodeConfigSubject |
27
28
  * renders: floored docs never reach the `content` rung). Procedural guidance and factual
28
29
  * references both live here as `knowledge`. Returns '' when nothing is
29
30
  * eligible. */
30
- export declare function renderKnowledgeForSubject(subject: NodeConfigSubject, nodeId: string, target?: ExposureTarget, accounting?: DeliveryAccounting): string;
31
+ export declare function renderKnowledgeForSubject(subject: NodeConfigSubject, nodeId: string, target?: ExposureTarget, accounting?: DeliveryAccounting, grantee?: string, memoryTarget?: MemoryTarget): string;
31
32
  /** What a node's configuration change newly exposes, rendered as up to three
32
33
  * blocks in one string: the shipped protocol prose, a `<memory kind="preference">`
33
34
  * block, and a `<memory kind="knowledge">` block — each dropped when empty, ''
@@ -37,4 +38,4 @@ export declare function renderKnowledgeForSubject(subject: NodeConfigSubject, no
37
38
  * against the active exposure maximum. A lower rung or removal yields nothing
38
39
  * because content already loaded into this context cannot be withdrawn.
39
40
  * Rendered deltas register as transcript exposure through `target`. */
40
- export declare function renderConfigChangeDelta(subject: NodeConfigSubject, nodeId: string, target: ExposureTarget): string;
41
+ export declare function renderConfigChangeDelta(subject: NodeConfigSubject, nodeId: string, target: ExposureTarget, grantee?: string, memoryTarget?: MemoryTarget): string;
@@ -1,65 +1,65 @@
1
- var q=Object.defineProperty;var u=(e,t)=>q(e,"name",{value:t,configurable:!0});import{sep as z}from"node:path";import{interpolateNodePaths as T}from"../canvas/paths.js";import{ambientMemoryTarget as J,listAllMemoryDocs as Q,loadMemoryTargetView as X,resolveMemoryDoc as Z}from"../memory-resolver.js";import{buildMemoryTree as C}from"../memory/tree.js";import{subKindsAvailableTo as ee}from"../config.js";import{projectScopeRoots as ne}from"../scope.js";import{documentExposedAtOrAbove as v,emptyContextExposureState as te,exposureTarget as oe,registerDocumentExposure as O,registerExposure as re}from"./injected-store.js";import{bootPartitionOf as se,planDelivery as ie}from"./plan.js";import{parseSubstrateDoc as P,previewLine as ce,rungAtLeast as M,rungRank as N}from"./schema.js";import{accountDelivery as S,contentReadAttachments as ae}from"./on-read.js";import{dirDedupKey as ue,docsByName as le}from"./listings.js";import{cachedEventCorpusInclusive as fe}from"./session-cache.js";function A(e){if(e===null)return[];let t;try{t=X({cwd:process.cwd(),profileId:null,nodeId:e},{scope:"node",quiet:!0}).docs}catch{return[]}const n=[];for(const r of t){const o=P(r);o!==null&&n.push({doc:o,source:r})}return n}u(A,"nodeStoreCorpus");function de(e){let t;try{t=fe(Q,P).filter(n=>n.doc.scope!=="node")}catch{return A(e)}return[...t,...A(e)]}u(de,"bootCorpus");function E(e,t){return ie(e,{...J(),nodeId:t},"boot",{},de(t))}u(E,"bootPlan");function g(e,t){return e.docs.filter(n=>n.winner&&se(n)===t).map(n=>({...n.doc,source:n.source,bootRung:n.finalRung}))}u(g,"bootWinners");function R(e){return D(e.bootRung)&&(e.bootRung!=="content"||e.body.trim()!=="")}u(R,"rendersAtBoot");function _(e){if(e.scope==="node")return 1e3;if(e.scope==="builtin")return 0;if(e.scope==="user")return 1;if(e.scope==="profile")return 2;const t=ne();if(t.length===0)return 3;const n=t.findIndex(o=>e.path.startsWith(o+z)),r=n===-1?0:n;return 3+(t.length-1-r)}u(_,"scopeGeneralityRank");function B(e){const t=e.source.physicalRelativePath.replace(/\.md$/i,"").split("/");return e.source.representation==="directory-index"&&t.pop(),t}u(B,"physicalSegments");function me(e,t){const n=B(e),r=B(t),o=Math.min(n.length,r.length);for(let i=0;i<o;i++){const a=n[i].localeCompare(r[i]);if(a!==0)return a}return n.length-r.length}u(me,"compareTreePosition");function w(e){return e.scope!=="builtin"&&e.plugin===void 0}u(w,"isAgentEditable");function pe(e,t,n){if(t.length===0)return[];const r=new Map(e.map(a=>[a.path,a])),o=C(e.map(a=>a.source)),i=new Map;for(const a of t){const l=o.node(a);if(l===null)continue;let d=!1;const m=[...l.childDocuments.map(p=>p.document),...l.childDirectories.flatMap(p=>p.document===null?[]:[p.document])];for(const p of m){const f=r.get(p.path);f===void 0||i.has(f.path)||f.bootRung==="content"||M(f.bootRung,"preview")||f.unlisted||M(f.projectMemory,"preview")&&(v(n.state,f.path,f.body,"preview")||(i.set(f.path,{...f,bootRung:"preview"}),d=!0))}d&&re(n,ue(a),"preview")}return[...i.values()]}u(pe,"exposedDirEntries");function b(e,t,n,r,o=e,i){const a=r??oe(te(),"transcript"),l=[],d=[];for(const s of e)s.bootRung==="content"?l.push(s):d.push(s);l.sort((s,$)=>_(s)-_($)||me(s,$)||s.name.localeCompare($.name));const m=l.filter(s=>!v(a.state,s.path,s.body,"content")),p=m.map(s=>s.body.trim()).filter(s=>s!=="").join(`
1
+ var J=Object.defineProperty;var l=(e,o)=>J(e,"name",{value:o,configurable:!0});import{sep as Q}from"node:path";import{interpolateNodePaths as M}from"../canvas/paths.js";import{ambientMemoryTarget as X,listAllMemoryDocs as Z,loadMemoryTargetView as N,resolveMemoryDoc as ee}from"../memory-resolver.js";import{buildMemoryTree as S}from"../memory/tree.js";import{subKindsAvailableTo as ne}from"../config.js";import{projectScopeRoots as te}from"../scope.js";import{documentExposedAtOrAbove as R,emptyContextExposureState as oe,exposureTarget as re,registerDocumentExposure as T,registerExposure as se}from"./injected-store.js";import{bootPartitionOf as ie,planDelivery as ce}from"./plan.js";import{parseSubstrateDoc as D,previewLine as ae,rungAtLeast as A,rungRank as _}from"./schema.js";import{accountDelivery as B,contentReadAttachments as ue}from"./on-read.js";import{dirDedupKey as le,docsByName as fe}from"./listings.js";import{cachedEventCorpusInclusive as de}from"./session-cache.js";function j(e,o,n){if(e===null)return[];let r;try{r=N({...n??{cwd:process.cwd(),profileId:null},nodeId:e,grantee:o},{scope:"node",quiet:!0}).docs}catch{return[]}const t=[];for(const s of r){const a=D(s);a!==null&&t.push({doc:a,source:s})}return t}l(j,"nodeStoreCorpus");function pe(e,o,n){let r;try{r=(n===void 0?de(Z,D):N({...n,nodeId:null},{quiet:!0}).docs.map(t=>({source:t,doc:D(t)})).filter(t=>t.doc!==null)).filter(t=>t.doc.scope!=="node")}catch{return j(e,o,n)}return[...r,...j(e,o,n)]}l(pe,"bootCorpus");function x(e,o,n,r){return ce(e,{...r??X(),nodeId:o,grantee:n},"boot",{},pe(o,n,r))}l(x,"bootPlan");function g(e,o){return e.docs.filter(n=>n.winner&&ie(n)===o).map(n=>({...n.doc,source:n.source,bootRung:n.finalRung}))}l(g,"bootWinners");function C(e){return O(e.bootRung)&&(e.bootRung!=="content"||e.body.trim()!=="")}l(C,"rendersAtBoot");function L(e){if(e.scope==="node")return 1e3;if(e.scope==="builtin")return 0;if(e.scope==="user")return 1;if(e.scope==="profile")return 2;const o=te();if(o.length===0)return 3;const n=o.findIndex(t=>e.path.startsWith(t+Q)),r=n===-1?0:n;return 3+(o.length-1-r)}l(L,"scopeGeneralityRank");function I(e){const o=e.source.physicalRelativePath.replace(/\.md$/i,"").split("/");return e.source.representation==="directory-index"&&o.pop(),o}l(I,"physicalSegments");function me(e,o){const n=I(e),r=I(o),t=Math.min(n.length,r.length);for(let s=0;s<t;s++){const a=n[s].localeCompare(r[s]);if(a!==0)return a}return n.length-r.length}l(me,"compareTreePosition");function k(e){return e.scope!=="builtin"&&e.plugin===void 0}l(k,"isAgentEditable");function he(e,o,n){if(o.length===0)return[];const r=new Map(e.map(a=>[a.path,a])),t=S(e.map(a=>a.source)),s=new Map;for(const a of o){const c=t.node(a);if(c===null)continue;let f=!1;const h=[...c.childDocuments.map(p=>p.document),...c.childDirectories.flatMap(p=>p.document===null?[]:[p.document])];for(const p of h){const d=r.get(p.path);d===void 0||s.has(d.path)||d.bootRung==="content"||A(d.bootRung,"preview")||d.unlisted||A(d.projectMemory,"preview")&&(R(n.state,d.path,d.body,"preview")||(s.set(d.path,{...d,bootRung:"preview"}),f=!0))}f&&se(n,le(a),"preview")}return[...s.values()]}l(he,"exposedDirEntries");function $(e,o,n,r,t=e,s,a){const c=r??re(oe(),"transcript"),f=[],h=[];for(const i of e)i.bootRung==="content"?f.push(i):h.push(i);f.sort((i,E)=>L(i)-L(E)||me(i,E)||i.name.localeCompare(E.name));const p=f.filter(i=>!R(c.state,i.path,i.body,"content")),d=p.map(i=>i.body.trim()).filter(i=>i!=="").join(`
2
2
 
3
- `);for(const s of m)R(s)&&(O(a,s.path,s.body,s.bootRung),S(i,s,s.bootRung,void 0,s.source));const f={subject:n??null,target:a,byName:le(o.map(s=>s.source)),listings:"tree",dirs:[],accounting:i},h=m.flatMap(s=>ae(s,f).blocks),c=pe(o,f.dirs??[],a),y=new Map(c.map(s=>[s.path,s])),V=new Set(d.map(s=>s.path)),x=[...d.map(s=>y.get(s.path)??s),...c.filter(s=>!V.has(s.path))];for(const s of x)R(s)&&(O(a,s.path,s.body,s.bootRung),S(i,s,s.bootRung,y.has(s.path)?"directory listing attached to content delivery":void 0,s.source));return{contentProse:p,tree:he(x,t),contentDocs:m,attachmentBlocks:h}}u(b,"renderGrouped");function j(e){const t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}u(j,"leafSegment");function D(e){return N(e)>=N("name")}u(D,"isVisible");function L(e,t){const n=e.childDirectories.map(l=>L(l,t)),r=[];let o=0;for(const l of e.childDocuments){const d=t.get(l.document.path);d!==void 0&&(D(d.bootRung)?r.push({name:l.name,order:l.order,doc:d}):o+=1)}const i=e.document===null?null:t.get(e.document.path)??null;let a=null;return i!==null&&(D(i.bootRung)?a=i:o+=1),{name:e.name,segment:j(e.name),order:e.order,own:a,children:n,leaves:r,hiddenHere:o,renders:!1,ownCount:0}}u(L,"planDir");function G(e,t){let n=e.hiddenHere;for(const i of e.children)n+=G(i,e.name==="");const r=e.own!==null||e.leaves.length>0,o=e.children.some(i=>i.renders);return e.renders=r||o||t||e.name==="",e.ownCount=e.renders?n:0,e.renders?0:n}u(G,"resolveDir");function I(e){return e.kind==="dir"?e.node.order:e.kind==="leaf"?e.entry.order:""}u(I,"itemOrder");function K(e){return e.kind==="dir"?e.node.name:e.kind==="leaf"?e.entry.name:""}u(K,"itemName");function F(e,t,n,r){const o=e.bootRung==="preview"?ce(e):"";r.push(o===""?`${n}${t}`:`${n}${t} # read when: ${o}`)}u(F,"renderDocEntry");function W(e,t,n){const r=[];for(const o of e.children)o.renders&&r.push({kind:"dir",node:o});for(const o of e.leaves)r.push({kind:"leaf",entry:o});r.sort((o,i)=>I(o).localeCompare(I(i))||K(o).localeCompare(K(i))),e.ownCount>0&&r.push({kind:"more",count:e.ownCount}),r.forEach((o,i)=>{const a=i===r.length-1,l=t+(a?"\u2514\u2500 ":"\u251C\u2500 "),d=t+(a?" ":"\u2502 ");switch(o.kind){case"more":n.push(`${l}[+${o.count} more]`);break;case"dir":{const m=`${o.node.segment}/`;o.node.own===null?n.push(`${l}${m}`):F(o.node.own,m,l,n),W(o.node,d,n);break}case"leaf":F(o.entry.doc,j(o.entry.name),l,n);break}})}u(W,"renderChildren");function he(e,t){if(e.length===0)return"";const n=new Map;for(const i of e)n.has(i.path)||n.set(i.path,i);const r=L(C(e.map(i=>i.source)).root,n);G(r,!1);const o=[t];return W(r,"",o),o.join(`
4
- `)}u(he,"buildTree");const k="Each %s below shows either its full content (indented beneath its name), a `# read when:` line telling you when to read the full document, or simply its name.",ye="Preferences are how the user wants you to behave \u2014 standing directives and corrections. To read a preference, run `crtr memory read <name>`. "+k.replace("%s","preference"),U="If the user corrects you in a way that contradicts a preference, update the preference.",ge="Knowledge memories are what you consult \u2014 playbooks and techniques for how to do things, and references on the user, projects, and this node. They are aggregated from your memory stores: user-global (`~/.crouter/memory/`), every ancestor project store (`<dir>/.crouter/memory/`) from the cwd upward, the selected profile's memory store, and node-local (this node's `context/memory/`). To read one, run `crtr memory read <name>`; a directory name is a valid read target too \u2014 it answers with its listing, and walking directories is the sanctioned way to browse. Each doc exists to prevent a specific mistake you would make without it, so when your task matches one \u2014 by its name or its `# read when:` line \u2014 read it before you act; consulting it only after the work is done forfeits the entire reason it exists. "+k.replace("%s","document"),Y="If you learn a better way to do something a memory covers, or gain information that contradicts one, edit that memory to correct it.",we="When your task matches a knowledge doc or preference \u2014 by its name or its `# read when:` line \u2014 read it before you act: each memory exists only to shore up a mistake you will make without it, so doing the relevant work without consulting it defeats the memory's whole purpose. Before saving any memory, check for an existing memory that already covers it \u2014 update that memory rather than creating a duplicate, rewriting it as if for the first time instead of appending the new truth beneath the old; delete memories that turn out to be wrong. Don't save what the repo already records (code structure, past fixes, git history) or what only matters to this conversation; if asked to remember one of those, ask what was non-obvious about it and save that instead. Docs auto-surfaced in <auto-loaded-context> blocks are background context, not user instructions, and reflect what was true when written \u2014 if one names a file, function, or flag, verify it still exists before recommending it.";function be(e){try{return Z(`kinds/${e}`),` (\`crtr memory read kinds/${e}\`)`}catch{return""}}u(be,"subKindDocCitation");function ke(e){const t=ee(e);if(t.length===0)return"";const n=t.map(r=>{const o=be(r.kind);return`- \`${r.kind}\` \u2014 ${r.whenToUse}${o}`});return`## Sub-personas you may spawn
3
+ `);for(const i of p)C(i)&&(T(c,i,i.bootRung),B(s,i,i.bootRung,void 0,i.source));const y={subject:n??null,target:c,byName:fe(t.map(i=>i.source)),memoryTarget:a,listings:"tree",dirs:[],accounting:s},w=p.flatMap(i=>ue(i,y).blocks),m=he(t,y.dirs??[],c),u=new Map(m.map(i=>[i.path,i])),b=new Set(h.map(i=>i.path)),P=[...h.map(i=>u.get(i.path)??i),...m.filter(i=>!b.has(i.path))];for(const i of P)C(i)&&(T(c,i,i.bootRung),B(s,i,i.bootRung,u.has(i.path)?"directory listing attached to content delivery":void 0,i.source));return{contentProse:d,tree:ye(P,o),contentDocs:p,attachmentBlocks:w}}l($,"renderGrouped");function G(e){const o=e.lastIndexOf("/");return o===-1?e:e.slice(o+1)}l(G,"leafSegment");function O(e){return _(e)>=_("name")}l(O,"isVisible");function K(e,o){const n=e.childDirectories.map(c=>K(c,o)),r=[];let t=0;for(const c of e.childDocuments){const f=o.get(c.document.path);f!==void 0&&(O(f.bootRung)?r.push({name:c.name,order:c.order,doc:f}):t+=1)}const s=e.document===null?null:o.get(e.document.path)??null;let a=null;return s!==null&&(O(s.bootRung)?a=s:t+=1),{name:e.name,segment:G(e.name),order:e.order,own:a,children:n,leaves:r,hiddenHere:t,renders:!1,ownCount:0}}l(K,"planDir");function F(e,o){let n=e.hiddenHere;for(const s of e.children)n+=F(s,e.name==="");const r=e.own!==null||e.leaves.length>0,t=e.children.some(s=>s.renders);return e.renders=r||t||o||e.name==="",e.ownCount=e.renders?n:0,e.renders?0:n}l(F,"resolveDir");function W(e){return e.kind==="dir"?e.node.order:e.kind==="leaf"?e.entry.order:""}l(W,"itemOrder");function U(e){return e.kind==="dir"?e.node.name:e.kind==="leaf"?e.entry.name:""}l(U,"itemName");function Y(e,o,n,r){const t=e.bootRung==="preview"?ae(e):"";r.push(t===""?`${n}${o}`:`${n}${o} # read when: ${t}`)}l(Y,"renderDocEntry");function q(e,o,n){const r=[];for(const t of e.children)t.renders&&r.push({kind:"dir",node:t});for(const t of e.leaves)r.push({kind:"leaf",entry:t});r.sort((t,s)=>W(t).localeCompare(W(s))||U(t).localeCompare(U(s))),e.ownCount>0&&r.push({kind:"more",count:e.ownCount}),r.forEach((t,s)=>{const a=s===r.length-1,c=o+(a?"\u2514\u2500 ":"\u251C\u2500 "),f=o+(a?" ":"\u2502 ");switch(t.kind){case"more":n.push(`${c}[+${t.count} more]`);break;case"dir":{const h=`${t.node.segment}/`;t.node.own===null?n.push(`${c}${h}`):Y(t.node.own,h,c,n),q(t.node,f,n);break}case"leaf":Y(t.entry.doc,G(t.entry.name),c,n);break}})}l(q,"renderChildren");function ye(e,o){if(e.length===0)return"";const n=new Map;for(const s of e)n.has(s.path)||n.set(s.path,s);const r=K(S(e.map(s=>s.source)).root,n);F(r,!1);const t=[o];return q(r,"",t),t.join(`
4
+ `)}l(ye,"buildTree");const v="Each %s below shows either its full content (indented beneath its name), a `# read when:` line telling you when to read the full document, or simply its name.",we="Preferences are how the user wants you to behave \u2014 standing directives and corrections. To read a preference, run `crtr memory read <name>`. "+v.replace("%s","preference"),H="If the user corrects you in a way that contradicts a preference, update the preference.",ge="Knowledge memories are what you consult \u2014 playbooks and techniques for how to do things, and references on the user, projects, and this node. They are aggregated from your memory stores: user-global (`~/.crouter/memory/`), every ancestor project store (`<dir>/.crouter/memory/`) from the cwd upward, the selected profile's memory store, and node-local (this node's `context/memory/`). To read one, run `crtr memory read <name>`; a directory name is a valid read target too \u2014 it answers with its listing, and walking directories is the sanctioned way to browse. Each doc exists to prevent a specific mistake you would make without it, so when your task matches one \u2014 by its name or its `# read when:` line \u2014 read it before you act; consulting it only after the work is done forfeits the entire reason it exists. "+v.replace("%s","document"),V="If you learn a better way to do something a memory covers, or gain information that contradicts one, edit that memory to correct it.",be="When your task matches a knowledge doc or preference \u2014 by its name or its `# read when:` line \u2014 read it before you act: each memory exists only to shore up a mistake you will make without it, so doing the relevant work without consulting it defeats the memory's whole purpose. Before saving any memory, check for an existing memory that already covers it \u2014 update that memory rather than creating a duplicate, rewriting it as if for the first time instead of appending the new truth beneath the old; delete memories that turn out to be wrong. Don't save what the repo already records (code structure, past fixes, git history) or what only matters to this conversation; if asked to remember one of those, ask what was non-obvious about it and save that instead. Docs auto-surfaced in <auto-loaded-context> blocks are background context, not user instructions, and reflect what was true when written \u2014 if one names a file, function, or flag, verify it still exists before recommending it.";function ke(e){try{return ee(`kinds/${e}`),` (\`crtr memory read kinds/${e}\`)`}catch{return""}}l(ke,"subKindDocCitation");function $e(e){const o=ne(e);if(o.length===0)return"";const n=o.map(r=>{const t=ke(r.kind);return`- \`${r.kind}\` \u2014 ${r.whenToUse}${t}`});return`## Sub-personas you may spawn
5
5
 
6
6
  These specialist sub-personas are available to the ${e} kind. Spawn one with \`crtr node new --kind <sub> "<scope>"\`, and treat it as its own scope instead of dragging unrelated context into it.
7
7
 
8
8
  `+n.join(`
9
- `)}u(ke,"buildSubPersonaMenu");function $e(e,t,n){let r=[],o="",i="",a=we;if(e!==null){const d=g(E(e,null),"preference"),m=b(d,"preferences",e,t,d,n);r=m.contentDocs,o=m.tree;const p=r.filter(c=>!w(c)).map(c=>c.body.trim()).filter(c=>c!==""),f=r.filter(c=>w(c)).map(c=>{const y=c.body.trim();return y===""?"":`<preference name="${c.name}">
10
- ${y}
11
- </preference>`}).filter(c=>c!==""),h=ke(e.kind);i=[...p,...m.attachmentBlocks,...h===""?[]:[h]].join(`
9
+ `)}l($e,"buildSubPersonaMenu");function ve(e,o,n,r){let t=[],s="",a="",c=be;if(e!==null){const h=g(x(e,null,r?.grantee,r),"preference"),p=$(h,"preferences",e,o,h,n,r);t=p.contentDocs,s=p.tree;const d=t.filter(m=>!k(m)).map(m=>m.body.trim()).filter(m=>m!==""),y=t.filter(m=>k(m)).map(m=>{const u=m.body.trim();return u===""?"":`<preference name="${m.name}">
10
+ ${u}
11
+ </preference>`}).filter(m=>m!==""),w=$e(e.kind);a=[...d,...p.attachmentBlocks,...w===""?[]:[w]].join(`
12
12
 
13
- `),(f.length>0||o!=="")&&(a+=`
13
+ `),(y.length>0||s!=="")&&(c+=`
14
14
 
15
- ${ye}`,f.length>0&&(a+=`
15
+ ${we}`,y.length>0&&(c+=`
16
16
 
17
- ${f.join(`
17
+ ${y.join(`
18
18
 
19
- `)}`),o!==""&&(a+=`
19
+ `)}`),s!==""&&(c+=`
20
20
 
21
- ${o}`),a+=`
21
+ ${s}`),c+=`
22
22
 
23
- ${U}`)}const l=`<memory kind="preference">
24
- ${a}
25
- </memory>`;return{block:i===""?l:`${i}
23
+ ${H}`)}const f=`<memory kind="preference">
24
+ ${c}
25
+ </memory>`;return{block:a===""?f:`${a}
26
26
 
27
- ${l}`,contentDocs:r,tree:o}}u($e,"buildPreferencesBlock");function Le(e,t,n){return $e(e,t,n)}u(Le,"renderPreferencesForSubject");function Ge(e,t,n,r){const o=g(E(e,t),"knowledge"),{contentProse:i,tree:a,attachmentBlocks:l}=b(o,"knowledge",e,n,o,r),d=[i,...l].filter(p=>p!=="").join(`
27
+ ${f}`,contentDocs:t,tree:s}}l(ve,"buildPreferencesBlock");function Ie(e,o,n,r){return ve(e,o,n,r)}l(Ie,"renderPreferencesForSubject");function Ge(e,o,n,r,t,s){const a=g(x(e,o,t,s),"knowledge"),{contentProse:c,tree:f,attachmentBlocks:h}=$(a,"knowledge",e,n,a,r,s),p=[c,...h].filter(y=>y!=="").join(`
28
28
 
29
- `);if(d===""&&a==="")return"";let m=ge;return d!==""&&(m+=`
29
+ `);if(p===""&&f==="")return"";let d=ge;return p!==""&&(d+=`
30
30
 
31
- ${d}`),a!==""&&(m+=`
31
+ ${p}`),f!==""&&(d+=`
32
32
 
33
- ${a}`),m+=`
33
+ ${f}`),d+=`
34
34
 
35
- ${Y}`,T(`<memory kind="knowledge">
36
- ${m}
37
- </memory>`,t)}u(Ge,"renderKnowledgeForSubject");const ve="Your node configuration changed. This operating protocol is in force for you now:",Ee="Your new configuration puts these preferences in force \u2014 standing directives and corrections from the user. To read one, run `crtr memory read <name>`. "+k.replace("%s","preference"),Re="Your new configuration exposes these knowledge documents \u2014 consult them exactly like the rest of your catalog (`crtr memory read <name>`). "+k.replace("%s","document");function H(e,t){return t.filter(n=>R(n)&&!v(e.state,n.path,n.body,n.bootRung))}u(H,"undelivered");function Ie(e,t,n){const r=E(e,t),o=H(n,g(r,"preference")),{contentDocs:i,tree:a,attachmentBlocks:l}=b(o,"preferences",e,n,g(r,"preference")),d=i.filter(c=>!w(c)).map(c=>c.body.trim()).filter(c=>c!==""),m=i.filter(c=>w(c)).map(c=>{const y=c.body.trim();return y===""?"":`<preference name="${c.name}">
38
- ${y}
39
- </preference>`}).filter(c=>c!==""),p=[];if((d.length>0||l.length>0)&&p.push(`${ve}
35
+ ${V}`,M(`<memory kind="knowledge">
36
+ ${d}
37
+ </memory>`,o,t)}l(Ge,"renderKnowledgeForSubject");const Ee="Your node configuration changed. This operating protocol is in force for you now:",Re="Your new configuration puts these preferences in force \u2014 standing directives and corrections from the user. To read one, run `crtr memory read <name>`. "+v.replace("%s","preference"),De="Your new configuration exposes these knowledge documents \u2014 consult them exactly like the rest of your catalog (`crtr memory read <name>`). "+v.replace("%s","document");function z(e,o){return o.filter(n=>C(n)&&!R(e.state,n.path,n.body,n.bootRung))}l(z,"undelivered");function Ke(e,o,n,r,t){const s=x(e,o,r,t),a=z(n,g(s,"preference")),{contentDocs:c,tree:f,attachmentBlocks:h}=$(a,"preferences",e,n,g(s,"preference"),void 0,t),p=c.filter(u=>!k(u)).map(u=>u.body.trim()).filter(u=>u!==""),d=c.filter(u=>k(u)).map(u=>{const b=u.body.trim();return b===""?"":`<preference name="${u.name}">
38
+ ${b}
39
+ </preference>`}).filter(u=>u!==""),y=[];if((p.length>0||h.length>0)&&y.push(`${Ee}
40
40
 
41
- ${[...d,...l].join(`
41
+ ${[...p,...h].join(`
42
42
 
43
- `)}`),m.length>0||a!==""){let c=Ee;m.length>0&&(c+=`
43
+ `)}`),d.length>0||f!==""){let u=Re;d.length>0&&(u+=`
44
44
 
45
- ${m.join(`
45
+ ${d.join(`
46
46
 
47
- `)}`),a!==""&&(c+=`
47
+ `)}`),f!==""&&(u+=`
48
48
 
49
- ${a}`),c+=`
49
+ ${f}`),u+=`
50
50
 
51
- ${U}`,p.push(`<memory kind="preference">
52
- ${c}
53
- </memory>`)}const f=b(H(n,g(r,"knowledge")),"knowledge",e,n,g(r,"knowledge")),h=[f.contentProse,...f.attachmentBlocks].filter(c=>c!=="").join(`
51
+ ${H}`,y.push(`<memory kind="preference">
52
+ ${u}
53
+ </memory>`)}const w=$(z(n,g(s,"knowledge")),"knowledge",e,n,g(s,"knowledge"),void 0,t),m=[w.contentProse,...w.attachmentBlocks].filter(u=>u!=="").join(`
54
54
 
55
- `);if(h!==""||f.tree!==""){let c=Re;h!==""&&(c+=`
55
+ `);if(m!==""||w.tree!==""){let u=De;m!==""&&(u+=`
56
56
 
57
- ${h}`),f.tree!==""&&(c+=`
57
+ ${m}`),w.tree!==""&&(u+=`
58
58
 
59
- ${f.tree}`),c+=`
59
+ ${w.tree}`),u+=`
60
60
 
61
- ${Y}`,p.push(`<memory kind="knowledge">
62
- ${c}
63
- </memory>`)}return p.length===0?"":T(p.join(`
61
+ ${V}`,y.push(`<memory kind="knowledge">
62
+ ${u}
63
+ </memory>`)}return y.length===0?"":M(y.join(`
64
64
 
65
- `),t)}u(Ie,"renderConfigChangeDelta");export{ke as buildSubPersonaMenu,Ie as renderConfigChangeDelta,Ge as renderKnowledgeForSubject,Le as renderPreferencesForSubject};
65
+ `),o,r)}l(Ke,"renderConfigChangeDelta");export{$e as buildSubPersonaMenu,Ke as renderConfigChangeDelta,Ge as renderKnowledgeForSubject,Ie as renderPreferencesForSubject};
@@ -2,6 +2,10 @@ import { type ProfileProjectMemory } from '../../api/dto/profiles.js';
2
2
  import type { MemoryDoc, MemoryScope } from '../memory-resolver.js';
3
3
  export declare const KINDS: readonly ["knowledge", "preference"];
4
4
  export type DocKind = (typeof KINDS)[number];
5
+ export declare const PRIVACY_LEVELS: readonly ["public", "friends", "private"];
6
+ export type PrivacyLevel = (typeof PRIVACY_LEVELS)[number];
7
+ /** Missing or malformed privacy is treated conservatively on reads; lint rejects malformed values. */
8
+ export declare function effectivePrivacy(fm: Record<string, unknown> | null): PrivacyLevel;
5
9
  /** Is `v` one of the two valid document kinds? */
6
10
  export declare function isDocKind(v: unknown): v is DocKind;
7
11
  export declare const RUNGS: readonly ["none", "name", "preview", "content"];
@@ -51,6 +55,8 @@ export type GatePredicate = Record<string, unknown>;
51
55
  export interface SubstrateSchema {
52
56
  /** Which of the two semantic kinds (knowledge | preference). */
53
57
  kind: DocKind;
58
+ /** App access level; legacy documents without the field resolve to private. */
59
+ privacy: PrivacyLevel;
54
60
  /** The read-routing line — a single sentence answering WHEN to read this doc
55
61
  * and WHY it is worth the read: "When <circumstance>, this <kind> should be
56
62
  * read because <broader downstream payoff>." (design §4). This is
@@ -1 +1 @@
1
- var l=Object.defineProperty;var t=(e,n)=>l(e,"name",{value:n,configurable:!0});import{PROFILE_PROJECT_MEMORY_VALUES as m}from"../../api/dto/profiles.js";const y=["knowledge","preference"];function g(e){return typeof e=="string"&&y.includes(e)}t(g,"isDocKind");const h=m;function a(e){return h.indexOf(e)}t(a,"rungRank");function F(e,n){return a(e)>=a(n)}t(F,"rungAtLeast");function D(e,n){return a(e)<=a(n)?e:n}t(D,"minRung");import{normalizeNameSegment as j,normalizeDocName as G,resolveLocalName as O}from"../memory/identity.js";const x=["boot","workspace-open","read","memory-read","command","pre-command"],A=["name","preview","content"];function R(e){return e===null||!g(e.kind)?null:{kind:e.kind,whenAndWhyToRead:p(e["when-and-why-to-read"]),shortForm:p(e["short-form"]),unlisted:e.unlisted===!0,surfaces:k(e.surfaces),gate:f(e.gate),slash:e.slash===!0,rationale:S(e.rationale)}}t(R,"parseSubstrateFrontmatter");function w(e){const n=R(e.frontmatter);return n===null?null:{...n,name:e.name,scope:e.scope,plugin:e.plugin,path:e.path,body:e.body,projectMemory:e.projectMemory}}t(w,"parseSubstrateDoc");function L(e){const n=w(e);if(n!==null)return n.kind;const r=e.frontmatter?.kind;return typeof r=="string"?r:"knowledge"}t(L,"effectiveDocKind");function M(e){const n=e.whenAndWhyToRead.trim().replace(/\.+$/,"");return n===""?"":`${n}.`}t(M,"previewLine");function p(e){return typeof e=="string"?e:""}t(p,"strField");function S(e){return typeof e=="string"&&e.trim()!==""?e:void 0}t(S,"parseRationale");function f(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}t(f,"parseGate");function k(e){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(r===null||typeof r!="object"||Array.isArray(r))continue;const i=r,o=i.on;if(typeof o!="string"||!x.includes(o))continue;const u=i.at;if(typeof u!="string"||!A.includes(u))continue;const s=b(i.match),c=o==="read"?f(i["match-frontmatter"]):void 0,d=f(i.gate);(o==="read"||o==="memory-read"||o==="command"||o==="pre-command")&&s===void 0&&c===void 0||n.push({on:o,at:u,...s!==void 0?{match:s}:{},...c!==void 0?{matchFrontmatter:c}:{},...d!==void 0?{gate:d}:{}})}return n}t(k,"parseSurfaces");function b(e){if(typeof e=="string"){const n=e.trim();return n===""?void 0:[n]}if(Array.isArray(e)){const n=e.filter(r=>typeof r=="string"&&r.trim()!=="").map(r=>r.trim());return n.length>0?n:void 0}}t(b,"parseMatchGlobs");export{y as KINDS,h as RUNGS,x as SURFACE_EVENTS,A as SURFACE_RUNGS,L as effectiveDocKind,g as isDocKind,D as minRung,G as normalizeDocName,j as normalizeNameSegment,w as parseSubstrateDoc,R as parseSubstrateFrontmatter,k as parseSurfaces,M as previewLine,O as resolveDocName,F as rungAtLeast,a as rungRank};
1
+ var l=Object.defineProperty;var t=(e,n)=>l(e,"name",{value:n,configurable:!0});import{PROFILE_PROJECT_MEMORY_VALUES as m}from"../../api/dto/profiles.js";const y=["knowledge","preference"],g=["public","friends","private"];function h(e){const n=e?.privacy;return typeof n=="string"&&g.includes(n)?n:"private"}t(h,"effectivePrivacy");function x(e){return typeof e=="string"&&y.includes(e)}t(x,"isDocKind");const A=m;function a(e){return A.indexOf(e)}t(a,"rungRank");function D(e,n){return a(e)>=a(n)}t(D,"rungAtLeast");function _(e,n){return a(e)<=a(n)?e:n}t(_,"minRung");import{normalizeNameSegment as G,normalizeDocName as O,resolveLocalName as P}from"../memory/identity.js";const R=["boot","workspace-open","read","memory-read","command","pre-command"],S=["name","preview","content"];function w(e){return e===null||!x(e.kind)?null:{kind:e.kind,privacy:h(e),whenAndWhyToRead:d(e["when-and-why-to-read"]),shortForm:d(e["short-form"]),unlisted:e.unlisted===!0,surfaces:E(e.surfaces),gate:p(e.gate),slash:e.slash===!0,rationale:k(e.rationale)}}t(w,"parseSubstrateFrontmatter");function b(e){const n=w(e.frontmatter);return n===null?null:{...n,name:e.name,scope:e.scope,plugin:e.plugin,path:e.path,body:e.body,projectMemory:e.projectMemory}}t(b,"parseSubstrateDoc");function M(e){const n=b(e);if(n!==null)return n.kind;const r=e.frontmatter?.kind;return typeof r=="string"?r:"knowledge"}t(M,"effectiveDocKind");function U(e){const n=e.whenAndWhyToRead.trim().replace(/\.+$/,"");return n===""?"":`${n}.`}t(U,"previewLine");function d(e){return typeof e=="string"?e:""}t(d,"strField");function k(e){return typeof e=="string"&&e.trim()!==""?e:void 0}t(k,"parseRationale");function p(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}t(p,"parseGate");function E(e){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(r===null||typeof r!="object"||Array.isArray(r))continue;const i=r,o=i.on;if(typeof o!="string"||!R.includes(o))continue;const u=i.at;if(typeof u!="string"||!S.includes(u))continue;const s=N(i.match),c=o==="read"?p(i["match-frontmatter"]):void 0,f=p(i.gate);(o==="read"||o==="memory-read"||o==="command"||o==="pre-command")&&s===void 0&&c===void 0||n.push({on:o,at:u,...s!==void 0?{match:s}:{},...c!==void 0?{matchFrontmatter:c}:{},...f!==void 0?{gate:f}:{}})}return n}t(E,"parseSurfaces");function N(e){if(typeof e=="string"){const n=e.trim();return n===""?void 0:[n]}if(Array.isArray(e)){const n=e.filter(r=>typeof r=="string"&&r.trim()!=="").map(r=>r.trim());return n.length>0?n:void 0}}t(N,"parseMatchGlobs");export{y as KINDS,g as PRIVACY_LEVELS,A as RUNGS,R as SURFACE_EVENTS,S as SURFACE_RUNGS,M as effectiveDocKind,h as effectivePrivacy,x as isDocKind,_ as minRung,O as normalizeDocName,G as normalizeNameSegment,b as parseSubstrateDoc,w as parseSubstrateFrontmatter,E as parseSurfaces,U as previewLine,P as resolveDocName,D as rungAtLeast,a as rungRank};
@@ -1 +1 @@
1
- var T=Object.defineProperty;var a=(r,e)=>T(r,"name",{value:e,configurable:!0});import{getMarkdownTheme as p,getSelectListTheme as k,getSettingsListTheme as R}from"@earendil-works/pi-coding-agent";import{truncateToWidth as s,visibleWidth as d}from"@earendil-works/pi-tui";const L=a(r=>`\x1B[32m${r}\x1B[39m`,"ansiGreen"),W=a(r=>`\x1B[33m${r}\x1B[39m`,"ansiYellow"),m={fg(r,e){switch(r){case"border":return p().hr(e);case"accent":return p().heading(e);case"dim":return R().description(e);case"muted":return k().description(e);case"mdLink":return p().link(e);case"mdLinkUrl":return p().linkUrl(e);case"success":return L(e);case"warning":return W(e)}},bg(r,e){return`\x1B[7m${e}\x1B[27m`},bold(r){return p().bold(r)}};function A(r,e){const t=r.trim();if(t==="")return[""];if(e<=1)return[s(t,e)];const o=[];let n="";for(const i of t.split(/\s+/)){if(n===""){n=i;continue}const c=`${n} ${i}`;s(c,e)===c?n=c:(o.push(s(n,e)),n=i)}return n!==""&&o.push(s(n,e)),o.length>0?o:[""]}a(A,"wrapText");function E(r,e){return r.map(t=>s(t,e))}a(E,"renderRows");function b(r,e){const t=d(r);return t>=e?s(r,e):`${r}${" ".repeat(e-t)}`}a(b,"padAnsi");function $(r){return m.fg("border","\u2500".repeat(Math.max(0,r)))}a($,"rule");function G(r,e,t){if(r<=0)return{start:0,end:0};const o=Math.max(1,Math.min(t,r)),n=Math.max(0,Math.min(e-Math.floor(o/2),r-o));return{start:n,end:Math.min(r,n+o)}}a(G,"visibleRange");function O(r,e){if(e<4)return r.map(c=>s(c,e));const t=e-4,o=m.fg("border","\u2502"),n=m.fg("border",`\u250C${"\u2500".repeat(e-2)}\u2510`),i=m.fg("border",`\u2514${"\u2500".repeat(e-2)}\u2518`);return[n,...r.map(c=>`${o} ${b(s(c,t),t)} ${o}`),i]}a(O,"framed");function U(r,e){return e>=r.length?r:r.slice(r.length-e)}a(U,"fitTail");const v=4;function w(r){const{width:e,height:t,title:o,meta:n,body:i,footer:c}=r,u=m.fg("accent",m.bold(o)),l=n?m.fg("dim",n):"",f=e-d(u)-d(l),x=l!==""&&f>=2?`${u}${" ".repeat(f)}${l}`:s(u,e),h=Math.max(1,t-v),g=i.slice(0,h);for(;g.length<h;)g.push("");return[s(x,e),$(e),...g.map(M=>s(M,e)),$(e),s(c,e)]}a(w,"pageFrame");function y(r,e,t,o){const n=m.fg("border","\u2502"),i=Math.max(r.length,t.length),c=[];for(let u=0;u<i;u+=1){const l=b(r[u]??"",e),f=s(t[u]??"",o);c.push(`${l} ${n} ${f}`)}return c}a(y,"columns");export{v as PAGE_CHROME_ROWS,y as columns,U as fitTail,O as framed,b as padAnsi,w as pageFrame,E as renderRows,$ as rule,m as theme,G as visibleRange,A as wrapText};
1
+ var T=Object.defineProperty;var i=(r,e)=>T(r,"name",{value:e,configurable:!0});import{getMarkdownTheme as p,getSelectListTheme as k,getSettingsListTheme as C}from"@earendil-works/pi-coding-agent";import{truncateToWidth as s,visibleWidth as g}from"@earendil-works/pi-tui";import{detectColorCaps as R}from"./draw.js";const L=i(r=>`\x1B[32m${r}\x1B[39m`,"ansiGreen"),W=i(r=>`\x1B[33m${r}\x1B[39m`,"ansiYellow"),m={fg(r,e){if(!R().color)return e;switch(r){case"border":return p().hr(e);case"accent":return p().heading(e);case"dim":return C().description(e);case"muted":return k().description(e);case"mdLink":return p().link(e);case"mdLinkUrl":return p().linkUrl(e);case"success":return L(e);case"warning":return W(e)}},bg(r,e){return`\x1B[7m${e}\x1B[27m`},bold(r){return p().bold(r)}};function G(r,e){const t=r.trim();if(t==="")return[""];if(e<=1)return[s(t,e)];const o=[];let n="";for(const a of t.split(/\s+/)){if(n===""){n=a;continue}const c=`${n} ${a}`;s(c,e)===c?n=c:(o.push(s(n,e)),n=a)}return n!==""&&o.push(s(n,e)),o.length>0?o:[""]}i(G,"wrapText");function O(r,e){return r.map(t=>s(t,e))}i(O,"renderRows");function b(r,e){const t=g(r);return t>=e?s(r,e):`${r}${" ".repeat(e-t)}`}i(b,"padAnsi");function $(r){return m.fg("border","\u2500".repeat(Math.max(0,r)))}i($,"rule");function U(r,e,t){if(r<=0)return{start:0,end:0};const o=Math.max(1,Math.min(t,r)),n=Math.max(0,Math.min(e-Math.floor(o/2),r-o));return{start:n,end:Math.min(r,n+o)}}i(U,"visibleRange");function w(r,e){if(e<4)return r.map(c=>s(c,e));const t=e-4,o=m.fg("border","\u2502"),n=m.fg("border",`\u250C${"\u2500".repeat(e-2)}\u2510`),a=m.fg("border",`\u2514${"\u2500".repeat(e-2)}\u2518`);return[n,...r.map(c=>`${o} ${b(s(c,t),t)} ${o}`),a]}i(w,"framed");function y(r,e){return e>=r.length?r:r.slice(r.length-e)}i(y,"fitTail");const v=4;function F(r){const{width:e,height:t,title:o,meta:n,body:a,footer:c}=r,u=m.fg("accent",m.bold(o)),l=n?m.fg("dim",n):"",f=e-g(u)-g(l),x=l!==""&&f>=2?`${u}${" ".repeat(f)}${l}`:s(u,e),h=Math.max(1,t-v),d=a.slice(0,h);for(;d.length<h;)d.push("");return[s(x,e),$(e),...d.map(M=>s(M,e)),$(e),s(c,e)]}i(F,"pageFrame");function H(r,e,t,o){const n=m.fg("border","\u2502"),a=Math.max(r.length,t.length),c=[];for(let u=0;u<a;u+=1){const l=b(r[u]??"",e),f=s(t[u]??"",o);c.push(`${l} ${n} ${f}`)}return c}i(H,"columns");export{v as PAGE_CHROME_ROWS,H as columns,y as fitTail,w as framed,b as padAnsi,F as pageFrame,O as renderRows,$ as rule,m as theme,U as visibleRange,G as wrapText};
@@ -343,6 +343,18 @@ export declare const CONFIG_SETTINGS_COVERAGE: {
343
343
  surface: "specialized";
344
344
  owner: string;
345
345
  };
346
+ paths: {
347
+ surface: "specialized";
348
+ owner: string;
349
+ };
350
+ store: {
351
+ surface: "specialized";
352
+ owner: string;
353
+ };
354
+ runtime: {
355
+ surface: "specialized";
356
+ owner: string;
357
+ };
346
358
  spawnEnv: {
347
359
  surface: "specialized";
348
360
  owner: string;
@@ -1 +1 @@
1
- var v=Object.defineProperty;var s=(e,t)=>v(e,"name",{value:t,configurable:!0});import{CONDENSED_HISTORY_MODES as u,MOUSE_MODE_DEFAULTS as p,WHIP_MESSAGE_MODES as d}from"../types.js";function i(e,t,o){const r=e.indexOf(t),a=r>=0?r:0;return e[(a+o+e.length)%e.length]}s(i,"cycleChoice");function c(e,t,o){const r=e.indexOf(t);return r>=0?e[(r+o+e.length)%e.length]:o>=0?e.find(a=>a>t)??e[0]:[...e].reverse().find(a=>a<t)??e[e.length-1]}s(c,"cycleNumber");function n(e,t){return e==="true"?!0:e==="false"?!1:`${t} must be true or false`}s(n,"booleanFromString");function f(e,t){if(!/^\d+$/.test(e))return`${t} must be an integer >= 0`;const o=Number(e);return Number.isSafeInteger(o)?o:`${t} must be an integer >= 0`}s(f,"nonNegativeIntegerFromString");function _(e,t){const o=f(e,t);return typeof o=="string"||o<1?`${t} must be an integer >= 1`:o}s(_,"positiveIntegerFromString");const m=[!1,"notify","apply"],w=[0,1,6,12,24,48,72,168],b=[1,2,3,4,5,6,8,10,12],l="openai-codex";function g(e,t){const o=e.providerOptions[t];if(o!==void 0)return o;const r={};return e.providerOptions[t]=r,r}s(g,"providerOptionsFor");const x=[1,2,3,4,5,6],h={schema_version:{surface:"specialized",owner:"internal schema migration"},marketplaces:{surface:"specialized",owner:"Plugins and pkg market commands"},plugins:{surface:"specialized",owner:"Plugins tab and pkg plugin commands"},auto_update:{surface:"settings",settings:{crtr:{key:"auto_update.crtr",label:"crouter updates",description:"Notify about crouter releases, install them automatically, or turn checks off.",valueConstraint:"true|false|notify|apply; true stores notify",applies:"Applies on the next crouter command.",group:"updates",order:70,format:s(e=>e.auto_update.crtr===!1?"off":e.auto_update.crtr,"format"),cycle:s((e,t)=>{e.auto_update.crtr=i(m,e.auto_update.crtr,t)},"cycle"),setFromString:s((e,t)=>{const o=t==="true"?"notify":t;return o!=="notify"&&o!=="apply"&&o!=="false"?"auto_update.crtr must be notify, apply, or false":(e.auto_update.crtr=o==="false"?!1:o,null)},"setFromString")},content:{key:"auto_update.content",label:"Content updates",description:"Notify about plugin and marketplace updates, apply them automatically, or turn checks off.",valueConstraint:"false|notify|apply",applies:"Applies on the next crouter command.",group:"updates",order:80,format:s(e=>e.auto_update.content===!1?"off":e.auto_update.content,"format"),cycle:s((e,t)=>{e.auto_update.content=i(m,e.auto_update.content,t)},"cycle"),setFromString:s((e,t)=>t!=="notify"&&t!=="apply"&&t!=="false"?"auto_update.content must be notify, apply, or false":(e.auto_update.content=t==="false"?!1:t,null),"setFromString")},interval_hours:{key:"auto_update.interval_hours",label:"Update interval",description:"Minimum hours between automatic update checks. Zero checks on every command.",valueConstraint:"integer >= 0",applies:"Applies on the next crouter command.",group:"updates",order:90,format:s(e=>`${e.auto_update.interval_hours}h`,"format"),cycle:s((e,t)=>{e.auto_update.interval_hours=c(w,e.auto_update.interval_hours,t)},"cycle"),setFromString:s((e,t)=>{const o=f(t,"auto_update.interval_hours");return typeof o=="string"?o:(e.auto_update.interval_hours=o,null)},"setFromString")}}},max_panes_per_window:{surface:"settings",setting:{key:"max_panes_per_window",label:"Maximum panes",description:"Maximum human-review panes placed in one tmux window before using another window.",valueConstraint:"integer >= 1",applies:"Applies to the next pane placement.",group:"panes",order:20,format:s(e=>String(e.max_panes_per_window),"format"),cycle:s((e,t)=>{e.max_panes_per_window=c(b,e.max_panes_per_window,t)},"cycle"),setFromString:s((e,t)=>{const o=_(t,"max_panes_per_window");return typeof o=="string"?o:(e.max_panes_per_window=o,null)},"setFromString")}},auto_open_child_viewers:{surface:"settings",setting:{key:"auto_open_child_viewers",label:"Open child panes",description:"Open each managed child beside its watched parent. Off keeps new children running in the background.",valueConstraint:"true|false",applies:"Applies to the next managed child created; independent roots still open their attended viewer.",group:"panes",order:10,format:s(e=>e.auto_open_child_viewers?"on":"off","format"),cycle:s(e=>{e.auto_open_child_viewers=!e.auto_open_child_viewers},"cycle"),setFromString:s((e,t)=>{const o=n(t,"auto_open_child_viewers");return typeof o=="string"?o:(e.auto_open_child_viewers=o,null)},"setFromString")}},brokerThresholds:{surface:"specialized",owner:"Broker limits tab"},lifecycle:{surface:"specialized",owner:"sys config set lifecycle.unattendedParkMs"},completion_bell:{surface:"settings",setting:{key:"completion_bell",label:"Completion bell",description:"Ring a short sound when the node in an attached viewer finishes a turn.",valueConstraint:"true|false",applies:"Applies on the next turn end.",group:"display",order:41,format:s(e=>e.completion_bell?"on":"off","format"),cycle:s(e=>{e.completion_bell=!e.completion_bell},"cycle"),setFromString:s((e,t)=>{const o=n(t,"completion_bell");return typeof o=="string"?o:(e.completion_bell=o,null)},"setFromString")}},working_gerunds:{surface:"specialized",owner:"sys config set working_gerunds"},whip_mode:{surface:"settings",setting:{key:"whip_mode",label:"Whip mode",description:"Play the whip animation when you send a prompt and when a viewer opens for an agent with an initial prompt.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:39,format:s(e=>e.whip_mode?"on":"off","format"),cycle:s(e=>{e.whip_mode=!e.whip_mode},"cycle"),setFromString:s((e,t)=>{const o=n(t,"whip_mode");return typeof o=="string"?o:(e.whip_mode=o,null)},"setFromString")}},page_surface:{surface:"settings",setting:{key:"page_surface",label:"Page human surface",description:"This host reads pages in a browser rather than a terminal. Agents are told the page module runs as written, HTML pages are offered, and document review and live display leave the command tree.",valueConstraint:"true|false",applies:"Applies when human command help is assembled.",group:"display",order:37,format:s(e=>e.page_surface?"on":"off","format"),cycle:s(e=>{e.page_surface=!e.page_surface},"cycle"),setFromString:s((e,t)=>{const o=n(t,"page_surface");return typeof o=="string"?o:(e.page_surface=o,null)},"setFromString")}},whip_messages:{surface:"specialized",owner:"sys config set whip_messages"},whip_message_mode:{surface:"settings",setting:{key:"whip_message_mode",label:"Whip message",description:"What the whip action sends: a random line from whip_messages, or the fixed \u201CGo faster\u201D.",valueConstraint:d.join("|"),applies:"Applies on the next attach.",group:"display",order:40,format:s(e=>e.whip_message_mode==="go-faster"?"go faster":"random","format"),cycle:s((e,t)=>{e.whip_message_mode=i(d,e.whip_message_mode,t)},"cycle"),setFromString:s((e,t)=>d.includes(t)?(e.whip_message_mode=t,null):`whip_message_mode must be one of: ${d.join("|")}`,"setFromString")}},mouse_mode_default:{surface:"settings",setting:{key:"mouse_mode_default",label:"Default mouse mode",description:"Initial mouse wheel scrolling for each attached viewer.",valueConstraint:p.join("|"),applies:"Applies on the next attach.",group:"display",order:38,format:s(e=>e.mouse_mode_default==="tmux"?"follow tmux":e.mouse_mode_default,"format"),cycle:s((e,t)=>{e.mouse_mode_default=i(p,e.mouse_mode_default,t)},"cycle"),setFromString:s((e,t)=>p.includes(t)?(e.mouse_mode_default=t,null):`mouse_mode_default must be one of: ${p.join("|")}`,"setFromString")}},live_cycles:{surface:"settings",setting:{key:"live_cycles",label:"Live cycles",description:"Trailing refresh cycles rendered at full fidelity; older cycles condense to text.",valueConstraint:"integer >= 1",applies:"Applies on the next attach.",group:"display",order:50,format:s(e=>String(e.live_cycles),"format"),cycle:s((e,t)=>{e.live_cycles=c(x,e.live_cycles,t)},"cycle"),setFromString:s((e,t)=>{const o=_(t,"live_cycles");return typeof o=="string"?o:(e.live_cycles=o,null)},"setFromString")}},condensed_history:{surface:"settings",setting:{key:"condensed_history",label:"Condensed history",description:"Messages retained from condensed cycles. Tool calls are never kept.",valueConstraint:u.join("|"),applies:"Applies on the next attach.",group:"display",order:60,format:s(e=>e.condensed_history,"format"),cycle:s((e,t)=>{e.condensed_history=i(u,e.condensed_history,t)},"cycle"),setFromString:s((e,t)=>u.includes(t)?(e.condensed_history=t,null):`condensed_history must be one of: ${u.join("|")}`,"setFromString")}},bash_tool_purpose:{surface:"settings",setting:{key:"bash_tool_purpose",label:"Bash purpose field",description:"Expose the optional purpose label to agents in the bash tool schema. Off removes the field without disabling the bash valve.",valueConstraint:"true|false",applies:"Applies on the next node session.",group:"display",order:25,format:s(e=>e.bash_tool_purpose?"on":"off","format"),cycle:s(e=>{e.bash_tool_purpose=!e.bash_tool_purpose},"cycle"),setFromString:s((e,t)=>{const o=n(t,"bash_tool_purpose");return typeof o=="string"?o:(e.bash_tool_purpose=o,null)},"setFromString")}},fold_finished_tools:{surface:"settings",setting:{key:"fold_finished_tools",label:"Fold finished tools",description:"Fold every settled tool call to its call line. Toggle live with /fold-tools.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:30,format:s(e=>e.fold_finished_tools?"on":"off","format"),cycle:s(e=>{e.fold_finished_tools=!e.fold_finished_tools},"cycle"),setFromString:s((e,t)=>{const o=n(t,"fold_finished_tools");return typeof o=="string"?o:(e.fold_finished_tools=o,null)},"setFromString")}},summarize_tool_calls:{surface:"settings",setting:{key:"summarize_tool_calls",label:"Summarize tool calls",description:"Replace completed folded tool-call groups with a one-line broker summary when available.",valueConstraint:"true|false",applies:"Applies when the next visible message closes a tool-call group.",group:"display",order:35,format:s(e=>e.summarize_tool_calls?"on":"off","format"),cycle:s(e=>{e.summarize_tool_calls=!e.summarize_tool_calls},"cycle"),setFromString:s((e,t)=>{const o=n(t,"summarize_tool_calls");return typeof o=="string"?o:(e.summarize_tool_calls=o,null)},"setFromString")}},detailed_tool_recaps:{surface:"settings",setting:{key:"detailed_tool_recaps",label:"Detailed tool recaps",description:"Show each memory read and edited file in folded tool recaps. Off shows a compact count line instead.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:36,format:s(e=>e.detailed_tool_recaps?"on":"off","format"),cycle:s(e=>{e.detailed_tool_recaps=!e.detailed_tool_recaps},"cycle"),setFromString:s((e,t)=>{const o=n(t,"detailed_tool_recaps");return typeof o=="string"?o:(e.detailed_tool_recaps=o,null)},"setFromString")}},keybindings:{surface:"specialized",owner:"Keybindings tab"},tmux_passthrough:{surface:"specialized",owner:"Keybindings tab"},providerOptions:{surface:"settings",settings:{"openai-codex.fastMode":{key:`providerOptions.${l}.fastMode`,label:"Codex fast mode",description:"Serve Codex turns at the ChatGPT priority tier: about 1.5x faster generation for about 2x the credits. Displayed cost does not reflect the premium.",valueConstraint:"true|false",applies:"Applies on each node's next turn.",group:"providers",order:40,format:s(e=>e.providerOptions[l]?.fastMode?"on":"off","format"),cycle:s(e=>{const t=g(e,l);t.fastMode=!t.fastMode},"cycle"),setFromString:s((e,t)=>{const o=n(t,`providerOptions.${l}.fastMode`);return typeof o=="string"?o:(g(e,l).fastMode=o,null)},"setFromString")}}},modelLadders:{surface:"specialized",owner:"Models tab"},modelRoutes:{surface:"specialized",owner:"Models route declarations"},modelRouting:{surface:"specialized",owner:"Models route declarations"},kinds:{surface:"specialized",owner:"Models tab and kind registry"},page_components:{surface:"specialized",owner:"Page component catalog: product-registered page component kinds"},remoteCanvas:{surface:"specialized",owner:"canvas config commands"},api:{surface:"specialized",owner:"sys connect"},spawnEnv:{surface:"specialized",owner:"spawn environment allow-list"},bin:{surface:"specialized",owner:"bare-binary contributions on every node PATH"},humanActions:{surface:"specialized",owner:"scope-configured human completion actions"}},O=Object.keys(h);function S(){const e=[];for(const t of Object.values(h))t.surface==="settings"&&("setting"in t?e.push(t.setting):e.push(...Object.values(t.settings)));return e.sort((t,o)=>t.order-o.order)}s(S,"collectUserSettings");const y=S();function A(e){return y.find(t=>t.key===e)}s(A,"findUserSetting");function E(e){return y.filter(t=>t.group===e)}s(E,"userSettingsInGroup");export{h as CONFIG_SETTINGS_COVERAGE,O as SCOPE_CONFIG_KEYS,y as USER_SETTINGS,A as findUserSetting,E as userSettingsInGroup};
1
+ var v=Object.defineProperty;var s=(e,t)=>v(e,"name",{value:t,configurable:!0});import{CONDENSED_HISTORY_MODES as u,MOUSE_MODE_DEFAULTS as p,WHIP_MESSAGE_MODES as d}from"../types.js";function i(e,t,o){const r=e.indexOf(t),a=r>=0?r:0;return e[(a+o+e.length)%e.length]}s(i,"cycleChoice");function c(e,t,o){const r=e.indexOf(t);return r>=0?e[(r+o+e.length)%e.length]:o>=0?e.find(a=>a>t)??e[0]:[...e].reverse().find(a=>a<t)??e[e.length-1]}s(c,"cycleNumber");function n(e,t){return e==="true"?!0:e==="false"?!1:`${t} must be true or false`}s(n,"booleanFromString");function f(e,t){if(!/^\d+$/.test(e))return`${t} must be an integer >= 0`;const o=Number(e);return Number.isSafeInteger(o)?o:`${t} must be an integer >= 0`}s(f,"nonNegativeIntegerFromString");function _(e,t){const o=f(e,t);return typeof o=="string"||o<1?`${t} must be an integer >= 1`:o}s(_,"positiveIntegerFromString");const m=[!1,"notify","apply"],w=[0,1,6,12,24,48,72,168],b=[1,2,3,4,5,6,8,10,12],l="openai-codex";function g(e,t){const o=e.providerOptions[t];if(o!==void 0)return o;const r={};return e.providerOptions[t]=r,r}s(g,"providerOptionsFor");const x=[1,2,3,4,5,6],h={schema_version:{surface:"specialized",owner:"internal schema migration"},marketplaces:{surface:"specialized",owner:"Plugins and pkg market commands"},plugins:{surface:"specialized",owner:"Plugins tab and pkg plugin commands"},auto_update:{surface:"settings",settings:{crtr:{key:"auto_update.crtr",label:"crouter updates",description:"Notify about crouter releases, install them automatically, or turn checks off.",valueConstraint:"true|false|notify|apply; true stores notify",applies:"Applies on the next crouter command.",group:"updates",order:70,format:s(e=>e.auto_update.crtr===!1?"off":e.auto_update.crtr,"format"),cycle:s((e,t)=>{e.auto_update.crtr=i(m,e.auto_update.crtr,t)},"cycle"),setFromString:s((e,t)=>{const o=t==="true"?"notify":t;return o!=="notify"&&o!=="apply"&&o!=="false"?"auto_update.crtr must be notify, apply, or false":(e.auto_update.crtr=o==="false"?!1:o,null)},"setFromString")},content:{key:"auto_update.content",label:"Content updates",description:"Notify about plugin and marketplace updates, apply them automatically, or turn checks off.",valueConstraint:"false|notify|apply",applies:"Applies on the next crouter command.",group:"updates",order:80,format:s(e=>e.auto_update.content===!1?"off":e.auto_update.content,"format"),cycle:s((e,t)=>{e.auto_update.content=i(m,e.auto_update.content,t)},"cycle"),setFromString:s((e,t)=>t!=="notify"&&t!=="apply"&&t!=="false"?"auto_update.content must be notify, apply, or false":(e.auto_update.content=t==="false"?!1:t,null),"setFromString")},interval_hours:{key:"auto_update.interval_hours",label:"Update interval",description:"Minimum hours between automatic update checks. Zero checks on every command.",valueConstraint:"integer >= 0",applies:"Applies on the next crouter command.",group:"updates",order:90,format:s(e=>`${e.auto_update.interval_hours}h`,"format"),cycle:s((e,t)=>{e.auto_update.interval_hours=c(w,e.auto_update.interval_hours,t)},"cycle"),setFromString:s((e,t)=>{const o=f(t,"auto_update.interval_hours");return typeof o=="string"?o:(e.auto_update.interval_hours=o,null)},"setFromString")}}},max_panes_per_window:{surface:"settings",setting:{key:"max_panes_per_window",label:"Maximum panes",description:"Maximum human-review panes placed in one tmux window before using another window.",valueConstraint:"integer >= 1",applies:"Applies to the next pane placement.",group:"panes",order:20,format:s(e=>String(e.max_panes_per_window),"format"),cycle:s((e,t)=>{e.max_panes_per_window=c(b,e.max_panes_per_window,t)},"cycle"),setFromString:s((e,t)=>{const o=_(t,"max_panes_per_window");return typeof o=="string"?o:(e.max_panes_per_window=o,null)},"setFromString")}},auto_open_child_viewers:{surface:"settings",setting:{key:"auto_open_child_viewers",label:"Open child panes",description:"Open each managed child beside its watched parent. Off keeps new children running in the background.",valueConstraint:"true|false",applies:"Applies to the next managed child created; independent roots still open their attended viewer.",group:"panes",order:10,format:s(e=>e.auto_open_child_viewers?"on":"off","format"),cycle:s(e=>{e.auto_open_child_viewers=!e.auto_open_child_viewers},"cycle"),setFromString:s((e,t)=>{const o=n(t,"auto_open_child_viewers");return typeof o=="string"?o:(e.auto_open_child_viewers=o,null)},"setFromString")}},brokerThresholds:{surface:"specialized",owner:"Broker limits tab"},lifecycle:{surface:"specialized",owner:"sys config set lifecycle.unattendedParkMs"},completion_bell:{surface:"settings",setting:{key:"completion_bell",label:"Completion bell",description:"Ring a short sound when the node in an attached viewer finishes a turn.",valueConstraint:"true|false",applies:"Applies on the next turn end.",group:"display",order:41,format:s(e=>e.completion_bell?"on":"off","format"),cycle:s(e=>{e.completion_bell=!e.completion_bell},"cycle"),setFromString:s((e,t)=>{const o=n(t,"completion_bell");return typeof o=="string"?o:(e.completion_bell=o,null)},"setFromString")}},working_gerunds:{surface:"specialized",owner:"sys config set working_gerunds"},whip_mode:{surface:"settings",setting:{key:"whip_mode",label:"Whip mode",description:"Play the whip animation when you send a prompt and when a viewer opens for an agent with an initial prompt.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:39,format:s(e=>e.whip_mode?"on":"off","format"),cycle:s(e=>{e.whip_mode=!e.whip_mode},"cycle"),setFromString:s((e,t)=>{const o=n(t,"whip_mode");return typeof o=="string"?o:(e.whip_mode=o,null)},"setFromString")}},page_surface:{surface:"settings",setting:{key:"page_surface",label:"Page human surface",description:"This host reads pages in a browser rather than a terminal. Agents are told the page module runs as written, HTML pages are offered, and document review and live display leave the command tree.",valueConstraint:"true|false",applies:"Applies when human command help is assembled.",group:"display",order:37,format:s(e=>e.page_surface?"on":"off","format"),cycle:s(e=>{e.page_surface=!e.page_surface},"cycle"),setFromString:s((e,t)=>{const o=n(t,"page_surface");return typeof o=="string"?o:(e.page_surface=o,null)},"setFromString")}},whip_messages:{surface:"specialized",owner:"sys config set whip_messages"},whip_message_mode:{surface:"settings",setting:{key:"whip_message_mode",label:"Whip message",description:"What the whip action sends: a random line from whip_messages, or the fixed \u201CGo faster\u201D.",valueConstraint:d.join("|"),applies:"Applies on the next attach.",group:"display",order:40,format:s(e=>e.whip_message_mode==="go-faster"?"go faster":"random","format"),cycle:s((e,t)=>{e.whip_message_mode=i(d,e.whip_message_mode,t)},"cycle"),setFromString:s((e,t)=>d.includes(t)?(e.whip_message_mode=t,null):`whip_message_mode must be one of: ${d.join("|")}`,"setFromString")}},mouse_mode_default:{surface:"settings",setting:{key:"mouse_mode_default",label:"Default mouse mode",description:"Initial mouse wheel scrolling for each attached viewer.",valueConstraint:p.join("|"),applies:"Applies on the next attach.",group:"display",order:38,format:s(e=>e.mouse_mode_default==="tmux"?"follow tmux":e.mouse_mode_default,"format"),cycle:s((e,t)=>{e.mouse_mode_default=i(p,e.mouse_mode_default,t)},"cycle"),setFromString:s((e,t)=>p.includes(t)?(e.mouse_mode_default=t,null):`mouse_mode_default must be one of: ${p.join("|")}`,"setFromString")}},live_cycles:{surface:"settings",setting:{key:"live_cycles",label:"Live cycles",description:"Trailing refresh cycles rendered at full fidelity; older cycles condense to text.",valueConstraint:"integer >= 1",applies:"Applies on the next attach.",group:"display",order:50,format:s(e=>String(e.live_cycles),"format"),cycle:s((e,t)=>{e.live_cycles=c(x,e.live_cycles,t)},"cycle"),setFromString:s((e,t)=>{const o=_(t,"live_cycles");return typeof o=="string"?o:(e.live_cycles=o,null)},"setFromString")}},condensed_history:{surface:"settings",setting:{key:"condensed_history",label:"Condensed history",description:"Messages retained from condensed cycles. Tool calls are never kept.",valueConstraint:u.join("|"),applies:"Applies on the next attach.",group:"display",order:60,format:s(e=>e.condensed_history,"format"),cycle:s((e,t)=>{e.condensed_history=i(u,e.condensed_history,t)},"cycle"),setFromString:s((e,t)=>u.includes(t)?(e.condensed_history=t,null):`condensed_history must be one of: ${u.join("|")}`,"setFromString")}},bash_tool_purpose:{surface:"settings",setting:{key:"bash_tool_purpose",label:"Bash purpose field",description:"Expose the optional purpose label to agents in the bash tool schema. Off removes the field without disabling the bash valve.",valueConstraint:"true|false",applies:"Applies on the next node session.",group:"display",order:25,format:s(e=>e.bash_tool_purpose?"on":"off","format"),cycle:s(e=>{e.bash_tool_purpose=!e.bash_tool_purpose},"cycle"),setFromString:s((e,t)=>{const o=n(t,"bash_tool_purpose");return typeof o=="string"?o:(e.bash_tool_purpose=o,null)},"setFromString")}},fold_finished_tools:{surface:"settings",setting:{key:"fold_finished_tools",label:"Fold finished tools",description:"Fold every settled tool call to its call line. Toggle live with /fold-tools.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:30,format:s(e=>e.fold_finished_tools?"on":"off","format"),cycle:s(e=>{e.fold_finished_tools=!e.fold_finished_tools},"cycle"),setFromString:s((e,t)=>{const o=n(t,"fold_finished_tools");return typeof o=="string"?o:(e.fold_finished_tools=o,null)},"setFromString")}},summarize_tool_calls:{surface:"settings",setting:{key:"summarize_tool_calls",label:"Summarize tool calls",description:"Replace completed folded tool-call groups with a one-line broker summary when available.",valueConstraint:"true|false",applies:"Applies when the next visible message closes a tool-call group.",group:"display",order:35,format:s(e=>e.summarize_tool_calls?"on":"off","format"),cycle:s(e=>{e.summarize_tool_calls=!e.summarize_tool_calls},"cycle"),setFromString:s((e,t)=>{const o=n(t,"summarize_tool_calls");return typeof o=="string"?o:(e.summarize_tool_calls=o,null)},"setFromString")}},detailed_tool_recaps:{surface:"settings",setting:{key:"detailed_tool_recaps",label:"Detailed tool recaps",description:"Show each memory read and edited file in folded tool recaps. Off shows a compact count line instead.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:36,format:s(e=>e.detailed_tool_recaps?"on":"off","format"),cycle:s(e=>{e.detailed_tool_recaps=!e.detailed_tool_recaps},"cycle"),setFromString:s((e,t)=>{const o=n(t,"detailed_tool_recaps");return typeof o=="string"?o:(e.detailed_tool_recaps=o,null)},"setFromString")}},keybindings:{surface:"specialized",owner:"Keybindings tab"},tmux_passthrough:{surface:"specialized",owner:"Keybindings tab"},providerOptions:{surface:"settings",settings:{"openai-codex.fastMode":{key:`providerOptions.${l}.fastMode`,label:"Codex fast mode",description:"Serve Codex turns at the ChatGPT priority tier: about 1.5x faster generation for about 2x the credits. Displayed cost does not reflect the premium.",valueConstraint:"true|false",applies:"Applies on each node's next turn.",group:"providers",order:40,format:s(e=>e.providerOptions[l]?.fastMode?"on":"off","format"),cycle:s(e=>{const t=g(e,l);t.fastMode=!t.fastMode},"cycle"),setFromString:s((e,t)=>{const o=n(t,`providerOptions.${l}.fastMode`);return typeof o=="string"?o:(g(e,l).fastMode=o,null)},"setFromString")}}},modelLadders:{surface:"specialized",owner:"Models tab"},modelRoutes:{surface:"specialized",owner:"Models route declarations"},modelRouting:{surface:"specialized",owner:"Models route declarations"},kinds:{surface:"specialized",owner:"Models tab and kind registry"},page_components:{surface:"specialized",owner:"Page component catalog: product-registered page component kinds"},remoteCanvas:{surface:"specialized",owner:"canvas config commands"},api:{surface:"specialized",owner:"sys connect"},paths:{surface:"specialized",owner:"runtime layout"},store:{surface:"specialized",owner:"daemon conversation store"},runtime:{surface:"specialized",owner:"app-facing listener"},spawnEnv:{surface:"specialized",owner:"spawn environment allow-list"},bin:{surface:"specialized",owner:"bare-binary contributions on every node PATH"},humanActions:{surface:"specialized",owner:"scope-configured human completion actions"}},O=Object.keys(h);function S(){const e=[];for(const t of Object.values(h))t.surface==="settings"&&("setting"in t?e.push(t.setting):e.push(...Object.values(t.settings)));return e.sort((t,o)=>t.order-o.order)}s(S,"collectUserSettings");const y=S();function z(e){return y.find(t=>t.key===e)}s(z,"findUserSetting");function A(e){return y.filter(t=>t.group===e)}s(A,"userSettingsInGroup");export{h as CONFIG_SETTINGS_COVERAGE,O as SCOPE_CONFIG_KEYS,y as USER_SETTINGS,z as findUserSetting,A as userSettingsInGroup};