@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
@@ -0,0 +1,166 @@
1
+ import { createLocalJWKSet, decodeProtectedHeader, jwtVerify } from 'jose';
2
+ /** App-memory form keys omit the app id. */
3
+ export const ENFORCED = new Set(['crtr:llm', 'crtr:act', 'crtr:memory:read:app', 'crtr:memory:rw:app', 'crtr:files:read:user:.', 'crtr:files:rw:user:.']);
4
+ const id = /^[A-Za-z0-9_-]{1,64}$/;
5
+ function validPath(path, directoryOnly = false) {
6
+ if (path === '.' && directoryOnly)
7
+ return true;
8
+ return path.length > 0 && !path.startsWith('/') && !path.includes('..') && !path.includes(':') &&
9
+ !path.includes('\\') && !/\s/.test(path) &&
10
+ !path.split('/').some((part, index, parts) => part === '.' || (part === '' && index !== parts.length - 1)) &&
11
+ (!directoryOnly || !path.endsWith('/'));
12
+ }
13
+ function selector(value) {
14
+ if (value === 'crtr:llm' || value === 'crtr:act' || value === 'crtr:schedule')
15
+ return { kind: value.slice(5), value };
16
+ if (value === 'crtr:files:share')
17
+ return { kind: 'share', value };
18
+ if (value === 'crtr:memory:manage:user')
19
+ return { kind: 'memory', access: 'manage', holder: 'user' };
20
+ let match = /^crtr:memory:(read|rw):user(?::(.+))?$/.exec(value);
21
+ if (match && (match[2] === undefined || validPath(match[2])))
22
+ return { kind: 'memory', access: match[1], holder: 'user', path: match[2] };
23
+ match = /^crtr:memory:(read|rw):app:([A-Za-z0-9_-]{1,64})(?::profile:([A-Za-z0-9_-]{1,64})(?::(.+))?)?$/.exec(value);
24
+ if (match && (match[4] === undefined || validPath(match[4]))) {
25
+ return { kind: 'memory', access: match[1], holder: `app:${match[2]}`, profile: match[3], path: match[4] };
26
+ }
27
+ match = /^crtr:files:(read|rw):(user|app:[A-Za-z0-9_-]{1,64}):(.+)$/.exec(value);
28
+ if (match && validPath(match[3], true))
29
+ return { kind: 'files', access: match[1], holder: match[2], path: match[3] };
30
+ match = /^crtr:(conversations|objects):read:app:([A-Za-z0-9_-]{1,64})$/.exec(value);
31
+ if (match)
32
+ return { kind: match[1], value };
33
+ match = /^crtr:peer:([A-Za-z0-9_-]{1,64})$/.exec(value);
34
+ if (match)
35
+ return { kind: 'peer', value };
36
+ match = /^([^:]+):([^:]+)$/.exec(value);
37
+ if (match && match[1] !== 'crtr' && id.test(match[1]) && id.test(match[2]))
38
+ return { kind: 'provider', value };
39
+ throw new TypeError(`Unsupported scope: ${value}`);
40
+ }
41
+ export function parseScope(value, grantee) {
42
+ const parsed = selector(value);
43
+ if (grantee && (parsed.kind === 'memory' || parsed.kind === 'files') && parsed.holder.startsWith('app:') && parsed.holder !== grantee) {
44
+ throw new TypeError(`Unsupported scope: ${value}`);
45
+ }
46
+ return value;
47
+ }
48
+ function containsPath(held, requested) {
49
+ if (held === undefined)
50
+ return true;
51
+ if (requested === undefined)
52
+ return false;
53
+ return held === requested || (held.endsWith('/') && requested.startsWith(held));
54
+ }
55
+ export function covers(held, requested) {
56
+ const h = selector(held);
57
+ const r = selector(requested);
58
+ if (h.kind !== r.kind)
59
+ return false;
60
+ if (h.kind === 'memory' && r.kind === 'memory') {
61
+ return h.holder === r.holder && (h.access === r.access || h.access === 'manage' || (h.access === 'rw' && r.access === 'read')) &&
62
+ (h.profile === undefined || h.profile === r.profile) && containsPath(h.path, r.path);
63
+ }
64
+ if (h.kind === 'files' && r.kind === 'files') {
65
+ return h.holder === r.holder && (h.access === 'rw' || r.access === 'read') &&
66
+ (h.path === '.' || h.path === r.path || r.path.startsWith(`${h.path}/`));
67
+ }
68
+ return held === requested;
69
+ }
70
+ /** Keys are scoped to one configured issuer; failed refreshes keep the last successful set. */
71
+ export class JwksCache {
72
+ issuer;
73
+ fetcher;
74
+ keys;
75
+ lastUnknownRefresh = -Infinity;
76
+ discovery;
77
+ constructor(issuer, fetcher = fetch, jwksUri) {
78
+ this.issuer = issuer;
79
+ this.fetcher = fetcher;
80
+ if (jwksUri)
81
+ this.discovery = { jwks_uri: jwksUri };
82
+ }
83
+ async load() {
84
+ if (!this.discovery) {
85
+ const response = await this.fetcher(`${this.issuer.replace(/\/$/, '')}/.well-known/openid-configuration`);
86
+ if (!response.ok)
87
+ throw new Error(`Directory discovery failed: ${response.status}`);
88
+ const value = await response.json();
89
+ if (!value || typeof value !== 'object' || !('jwks_uri' in value) || typeof value.jwks_uri !== 'string')
90
+ throw new Error('Directory discovery has no jwks_uri');
91
+ this.discovery = { jwks_uri: value.jwks_uri };
92
+ }
93
+ const response = await this.fetcher(this.discovery.jwks_uri);
94
+ if (!response.ok)
95
+ throw new Error(`Directory JWKS failed: ${response.status}`);
96
+ const keys = await response.json();
97
+ if (!keys || typeof keys !== 'object' || !('keys' in keys) || !Array.isArray(keys.keys))
98
+ throw new Error('Invalid directory JWKS');
99
+ this.keys = keys;
100
+ return this.keys;
101
+ }
102
+ async forKid(kid) {
103
+ if (!this.keys)
104
+ return this.load();
105
+ if (this.keys.keys.some((key) => key.kid === kid))
106
+ return this.keys;
107
+ if (Date.now() - this.lastUnknownRefresh >= 30_000) {
108
+ this.lastUnknownRefresh = Date.now();
109
+ await this.load();
110
+ }
111
+ return this.keys;
112
+ }
113
+ }
114
+ function validatePrincipal(value, kind) {
115
+ return typeof value === 'string' && value.startsWith(`${kind}:`) && id.test(value.slice(kind.length + 1));
116
+ }
117
+ function keySet(jwks, kid) {
118
+ return jwks instanceof JwksCache ? jwks.forKid(kid) : Promise.resolve(jwks);
119
+ }
120
+ export async function verifyAccessToken(options) {
121
+ const header = decodeProtectedHeader(options.token);
122
+ if (header.typ !== 'at+jwt' || header.alg !== 'ES256')
123
+ throw new Error('Invalid access token header');
124
+ const keys = await keySet(options.jwks, header.kid);
125
+ const { payload } = await jwtVerify(options.token, createLocalJWKSet(keys), {
126
+ issuer: options.issuer, audience: options.audience, algorithms: ['ES256'], typ: 'at+jwt',
127
+ });
128
+ if (payload.aud !== options.audience || !validatePrincipal(payload.sub, 'user') || !validatePrincipal(payload.grantee, 'app') ||
129
+ typeof payload.client_id !== 'string' || !id.test(payload.client_id) || typeof payload.grant !== 'string' ||
130
+ typeof payload.exp !== 'number') {
131
+ throw new Error('Invalid access token claims');
132
+ }
133
+ return payload;
134
+ }
135
+ /** The directory's grant-sync notice: ES256 with the directory signing key named
136
+ * by `kid`, no `typ`, `aud` = the runtime's registered URL, a lifetime of at most
137
+ * five minutes, and a `jti` the runtime uses to answer replays without a sync. */
138
+ export async function verifySyncNotice(options) {
139
+ const header = decodeProtectedHeader(options.token);
140
+ if (header.alg !== 'ES256')
141
+ throw new Error('Invalid sync notice algorithm');
142
+ if (typeof header.kid !== 'string' || header.kid === '')
143
+ throw new Error('Sync notice has no key id');
144
+ const keys = await keySet(options.jwks, header.kid);
145
+ const { payload } = await jwtVerify(options.token, createLocalJWKSet(keys), {
146
+ issuer: options.issuer, audience: options.audience, algorithms: ['ES256'], requiredClaims: ['exp', 'iat', 'jti'],
147
+ maxTokenAge: 300, clockTolerance: 30,
148
+ });
149
+ if (payload.aud !== options.audience || payload.purpose !== 'grant_sync' || typeof payload.jti !== 'string' || payload.jti === '' ||
150
+ typeof payload.exp !== 'number' || typeof payload.iat !== 'number' || payload.exp - payload.iat > 300) {
151
+ throw new Error('Invalid sync notice claims');
152
+ }
153
+ return payload;
154
+ }
155
+ export async function verifyIdToken(options) {
156
+ const header = decodeProtectedHeader(options.token);
157
+ if (header.alg !== 'ES256')
158
+ throw new Error('Invalid ID token algorithm');
159
+ const keys = await keySet(options.jwks, header.kid);
160
+ const { payload } = await jwtVerify(options.token, createLocalJWKSet(keys), {
161
+ issuer: options.issuer, audience: options.audience, algorithms: ['ES256'],
162
+ });
163
+ if (payload.aud !== options.audience || typeof payload.exp !== 'number' || !validatePrincipal(payload.sub, 'user'))
164
+ throw new Error('Invalid ID token claims');
165
+ return payload;
166
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@north-light/crouter-identity",
3
+ "version": "0.3.350",
4
+ "description": "Northlight access-token verification and scope rules",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "sideEffects": false,
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.json"
20
+ },
21
+ "dependencies": {
22
+ "jose": "^6.2.1"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/vallum-security/crouter.git",
30
+ "directory": "packages/crouter-identity"
31
+ },
32
+ "license": "GPL-3.0-only"
33
+ }
package/runtime.lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@north-light/crouter",
3
- "version": "0.3.349",
3
+ "version": "0.3.350",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/crouter",
9
- "version": "0.3.349",
9
+ "version": "0.3.350",
10
10
  "hasInstallScript": true,
11
11
  "license": "GPL-3.0-only",
12
12
  "workspaces": [
@@ -18,8 +18,10 @@
18
18
  "@earendil-works/pi-ai": "0.87.1",
19
19
  "@earendil-works/pi-coding-agent": "0.87.1",
20
20
  "@earendil-works/pi-tui": "0.87.1",
21
+ "@north-light/crouter-identity": "^0.3.350",
21
22
  "cron-parser": "^5.6.0",
22
23
  "esbuild": "^0.27.7",
24
+ "jose": "^6.2.12",
23
25
  "proper-lockfile": "4.1.2",
24
26
  "string-width": "^7.0.0",
25
27
  "tar": "^7.5.22",
@@ -32,6 +34,7 @@
32
34
  "bin": {
33
35
  "crouter": "bin/crouter",
34
36
  "crtr": "bin/crtr",
37
+ "crtr-launcher": "bin/crtr-launcher",
35
38
  "crtrd": "bin/crtrd"
36
39
  },
37
40
  "devDependencies": {
@@ -4324,6 +4327,10 @@
4324
4327
  "resolved": "packages/crouter-env-docker",
4325
4328
  "link": true
4326
4329
  },
4330
+ "node_modules/@north-light/crouter-identity": {
4331
+ "resolved": "packages/crouter-identity",
4332
+ "link": true
4333
+ },
4327
4334
  "node_modules/@north-light/crouter-plugin": {
4328
4335
  "resolved": "packages/crouter-plugin",
4329
4336
  "link": true
@@ -7485,6 +7492,15 @@
7485
7492
  "jiti": "lib/jiti-cli.mjs"
7486
7493
  }
7487
7494
  },
7495
+ "node_modules/jose": {
7496
+ "version": "6.2.12",
7497
+ "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.12.tgz",
7498
+ "integrity": "sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw==",
7499
+ "license": "MIT",
7500
+ "funding": {
7501
+ "url": "https://github.com/sponsors/panva"
7502
+ }
7503
+ },
7488
7504
  "node_modules/json-bigint": {
7489
7505
  "version": "1.0.0",
7490
7506
  "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
@@ -10869,28 +10885,38 @@
10869
10885
  },
10870
10886
  "packages/crouter-api": {
10871
10887
  "name": "@north-light/crouter-api",
10872
- "version": "0.3.349",
10888
+ "version": "0.3.350",
10873
10889
  "license": "GPL-3.0-only"
10874
10890
  },
10875
10891
  "packages/crouter-env-docker": {
10876
10892
  "name": "@north-light/crouter-env-docker",
10877
- "version": "0.3.349",
10893
+ "version": "0.3.350",
10878
10894
  "license": "GPL-3.0-only"
10879
10895
  },
10896
+ "packages/crouter-identity": {
10897
+ "name": "@north-light/crouter-identity",
10898
+ "version": "0.3.350",
10899
+ "license": "GPL-3.0-only",
10900
+ "dependencies": {
10901
+ "jose": "^6.2.1"
10902
+ }
10903
+ },
10880
10904
  "packages/crouter-plugin": {
10881
10905
  "name": "@north-light/crouter-plugin",
10882
- "version": "0.3.349",
10906
+ "version": "0.3.350",
10883
10907
  "license": "GPL-3.0-only",
10884
10908
  "dependencies": {
10885
- "@north-light/crouter-api": "^0.3.349"
10909
+ "@north-light/crouter-api": "^0.3.350"
10886
10910
  }
10887
10911
  },
10888
10912
  "packages/crouter-sdk": {
10889
10913
  "name": "@north-light/crouter-sdk",
10890
- "version": "0.3.349",
10914
+ "version": "0.3.350",
10891
10915
  "license": "GPL-3.0-only",
10892
10916
  "dependencies": {
10893
- "@north-light/crouter-api": "^0.3.349"
10917
+ "@north-light/crouter-api": "^0.3.350",
10918
+ "@north-light/crouter-identity": "^0.3.350",
10919
+ "jose": "^6.2.1"
10894
10920
  }
10895
10921
  }
10896
10922
  }
@@ -0,0 +1,16 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { existsSync, mkdirSync } from 'node:fs';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ if (process.platform !== 'linux') throw new Error('The native addon builds only on Linux');
7
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
8
+ const header = resolve(dirname(process.execPath), '../include/node');
9
+ if (!existsSync(join(header, 'node_api.h'))) throw new Error(`Node headers not found: ${header}`);
10
+ // The build passes its staging directory; run by hand it writes into dist/.
11
+ const target = resolve(process.argv[2] ?? join(root, 'dist/native/linux/addon.node'));
12
+ mkdirSync(dirname(target), { recursive: true });
13
+ const args = ['-std=c11', '-O2', '-fPIC', '-shared', '-Wall', '-Wextra', '-Werror', `-I${header}`, join(root, 'src/native/linux/addon.c'), '-o', target];
14
+ const result = spawnSync('cc', args, { stdio: 'inherit' });
15
+ if (result.error) throw result.error;
16
+ if (result.status !== 0) throw new Error(`cc failed: ${result.status ?? result.signal}`);
@@ -7,6 +7,14 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import { ENTRY_NAMES, GENERATION_ID, MANIFEST_KEYS, PACKAGE_NAME, MANIFEST_SCHEMA, contained, isSealed, publishedMarkerPath, runtimeHome, sortInventory, validateManifestShape } from '../bin/runtime-generation-manifest.mjs';
9
9
  import { patchPiTreeRootOrdering } from './patch-pi-tree-root-ordering.mjs';
10
+ import { smokeValidate } from './runtime-smoke.mjs';
11
+ import { scrubInheritedBrokerEnv, unsafeIsolationReason } from './lib/isolation-env.mjs';
12
+
13
+ scrubInheritedBrokerEnv();
14
+ // CI has no account store to protect, and its checkout sits inside the runner's
15
+ // home while the lanes move HOME elsewhere; test-env-scrub skips CI the same way.
16
+ const unsafeReason = process.env.CI ? null : unsafeIsolationReason();
17
+ if (unsafeReason) throw new Error(`Unsafe crouter runtime install: ${unsafeReason}`);
10
18
 
11
19
  const PACKAGE_ROOT = process.argv[2] ? resolve(process.argv[2]) : resolve(dirname(fileURLToPath(import.meta.url)), '..');
12
20
  const RUNTIME_HOME = runtimeHome();
@@ -129,12 +137,6 @@ async function removeStage(root) {
129
137
  await rm(root, { recursive: true, force: true });
130
138
  }
131
139
 
132
- async function smokeValidate(stage) {
133
- await run(process.execPath, ['--input-type=module', '--eval', "await import('./dist/index.js')"], stage);
134
- const lazyPiModule = 'node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js';
135
- await lstat(join(stage, lazyPiModule));
136
- await run(process.execPath, ['--input-type=module', '--eval', `await import('./${lazyPiModule}')`], stage);
137
- }
138
140
 
139
141
  /** Atomically mark generation `id` eligible as a sibling-fallback candidate
140
142
  * (see `runtime-generation-manifest.mjs`'s `publishedMarkerPath` for the
@@ -436,7 +438,7 @@ async function install() {
436
438
  platform: process.platform,
437
439
  arch: process.arch,
438
440
  createdAt: new Date().toISOString(),
439
- entries: { cli: 'dist/cli.js', daemon: 'dist/daemon/crtrd-cli.js', broker: 'dist/core/runtime/broker-cli.js' },
441
+ entries: { cli: 'dist/cli.js', daemon: 'dist/daemon/crtrd-cli.js', broker: 'dist/core/runtime/broker-cli.js', launcher: 'dist/launcher/main.js' },
440
442
  files,
441
443
  };
442
444
  if (JSON.stringify(Object.keys(manifest).sort()) !== JSON.stringify(MANIFEST_KEYS) || manifest.packageName !== PACKAGE_NAME) throw new Error('generated runtime manifest has an invalid schema or package identity');
@@ -0,0 +1,42 @@
1
+ import { realpathSync } from 'node:fs';
2
+ import { tmpdir, userInfo } from 'node:os';
3
+ import { isAbsolute, relative, sep } from 'node:path';
4
+
5
+ // A node's shell inherits broker identity and pi paths. Neither an installer
6
+ // nor a test lane is that broker; nested processes must resolve their own roots.
7
+ export function scrubInheritedBrokerEnv(env = process.env) {
8
+ for (const key of Object.keys(env)) {
9
+ if (key.startsWith('PI_') || (key.startsWith('CRTR_') &&
10
+ key !== 'CRTR_HOME' && key !== 'CRTR_RUNTIME_HOME' && key !== 'CRTR_NO_DAEMON_AUTOSTART')) {
11
+ delete env[key];
12
+ }
13
+ }
14
+ }
15
+
16
+ // A normal host install uses the account HOME. When HOME is overridden, no
17
+ // working directory or configured write root may still point into that account.
18
+ export function unsafeIsolationReason({ requireTemporaryHome = false, requireCrtrHome = false } = {}) {
19
+ const inside = (home, target) => {
20
+ const rel = relative(home, target);
21
+ return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
22
+ };
23
+ try {
24
+ const home = realpathSync(process.env.HOME);
25
+ const accountHome = realpathSync(userInfo().homedir);
26
+ if (home === accountHome) return requireTemporaryHome ? 'HOME is the account home' : null;
27
+ if (requireCrtrHome && !process.env.CRTR_HOME) return 'CRTR_HOME is missing';
28
+ for (const [name, path] of [
29
+ ['cwd', process.cwd()], ['TMPDIR', tmpdir()],
30
+ ...(process.env.CRTR_HOME ? [['CRTR_HOME', process.env.CRTR_HOME]] : []),
31
+ ...(process.env.CRTR_RUNTIME_HOME ? [['CRTR_RUNTIME_HOME', process.env.CRTR_RUNTIME_HOME]] : []),
32
+ ]) {
33
+ const target = realpathSync(path);
34
+ if (inside(accountHome, target) && !inside(home, target)) {
35
+ return `${name} is inside the account home but outside HOME`;
36
+ }
37
+ }
38
+ return null;
39
+ } catch {
40
+ return 'HOME, account home, cwd, TMPDIR, CRTR_HOME, or CRTR_RUNTIME_HOME cannot be resolved';
41
+ }
42
+ }
@@ -0,0 +1,49 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { mkdtemp, readdir, realpath, rm } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { isAbsolute, join, relative, resolve, sep } from 'node:path';
5
+ import { promisify } from 'node:util';
6
+
7
+ const exec = promisify(execFile);
8
+
9
+ // npm ci can succeed with workspace links whose targets were omitted from
10
+ // npm pack. Reject those before publishing or selecting a generation.
11
+ async function validateLinks(root, directory = root) {
12
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
13
+ const path = join(directory, entry.name);
14
+ if (entry.isDirectory()) await validateLinks(root, path);
15
+ else if (entry.isSymbolicLink()) {
16
+ let target;
17
+ try { target = await realpath(path); }
18
+ catch (error) { throw new Error(`Broken runtime symlink: ${relative(root, path)}`, { cause: error }); }
19
+ const rel = relative(root, target);
20
+ if (isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`)) {
21
+ throw new Error(`Runtime symlink escapes generation: ${relative(root, path)}`);
22
+ }
23
+ }
24
+ }
25
+ }
26
+
27
+ export async function smokeValidate(stage) {
28
+ stage = await realpath(resolve(stage));
29
+ await validateLinks(stage);
30
+ const home = await mkdtemp(join(tmpdir(), 'crtr-runtime-smoke-'));
31
+ const env = Object.fromEntries(Object.entries(process.env).filter(([key]) =>
32
+ !key.startsWith('CRTR_') && !key.startsWith('PI_') && key !== 'NODE_OPTIONS'));
33
+ Object.assign(env, {
34
+ HOME: home, CRTR_HOME: join(home, 'canvas'),
35
+ CRTR_NO_DAEMON_AUTOSTART: '1', PI_CODING_AGENT_DIR: join(home, 'pi'),
36
+ });
37
+ try {
38
+ // Load the actual daemon and broker graphs without starting either. The
39
+ // public index alone does not reach daemon-only dependencies.
40
+ await exec(process.execPath, ['--input-type=module', '--eval', `
41
+ await import('./dist/index.js');
42
+ await import('./dist/daemon/crtrd.js');
43
+ await import('./dist/core/runtime/broker.js');
44
+ await import('./node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js');
45
+ `], { cwd: stage, env, timeout: 30_000, maxBuffer: 1024 * 1024 });
46
+ } finally {
47
+ await rm(home, { recursive: true, force: true });
48
+ }
49
+ }