@north-light/crouter 0.3.198 → 0.3.200

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 (316) hide show
  1. package/dist/api/client.d.ts +18 -18
  2. package/dist/api/client.js +29 -37
  3. package/dist/api/dto/broker-ops.d.ts +3 -1
  4. package/dist/api/dto/broker.d.ts +13 -2
  5. package/dist/api/dto/broker.js +4 -4
  6. package/dist/api/dto/human.d.ts +6 -5
  7. package/dist/api/dto/inbox.d.ts +81 -34
  8. package/dist/api/dto/nodes.d.ts +8 -2
  9. package/dist/api/dto/profiles.d.ts +23 -0
  10. package/dist/api/dto/profiles.js +2 -2
  11. package/dist/api/dto/worktree.d.ts +3 -5
  12. package/dist/api/routes.d.ts +3 -5
  13. package/dist/api/routes.js +4 -6
  14. package/dist/builtin-memory/00-runtime-base.md +6 -6
  15. package/dist/builtin-memory/01-spine/01-no-manager.md +1 -1
  16. package/dist/builtin-memory/02-lifecycle/00-terminal.md +3 -3
  17. package/dist/builtin-memory/04-orchestration-kernel.md +6 -6
  18. package/dist/builtin-memory/05-kinds/design/00-base.md +1 -1
  19. package/dist/builtin-memory/05-kinds/plan/reviewers/security.md +2 -2
  20. package/dist/builtin-memory/05-kinds/review/00-base.md +2 -2
  21. package/dist/builtin-memory/05-kinds/review/01-orchestrator.md +1 -1
  22. package/dist/builtin-memory/05-kinds/spec/01-orchestrator.md +1 -1
  23. package/dist/builtin-memory/insights/capture.md +2 -2
  24. package/dist/builtin-memory/insights/init.md +3 -3
  25. package/dist/builtin-memory/internal/INDEX.md +1 -1
  26. package/dist/builtin-memory/internal/memory-loading.md +1 -1
  27. package/dist/builtin-memory/internal/nodes-and-canvas.md +2 -2
  28. package/dist/builtin-memory/internal/plugins.md +59 -2
  29. package/dist/builtin-memory/internal/storage-tiers.md +3 -1
  30. package/dist/builtin-memory/spec/roadmap.md +2 -2
  31. package/dist/builtin-memory/testing.md +1 -1
  32. package/dist/clients/attach/chrome/bash-jobs.js +3 -3
  33. package/dist/clients/attach/render/chat-view.d.ts +26 -1
  34. package/dist/clients/attach/render/chat-view.js +61 -11
  35. package/dist/clients/attach/render/page-block.d.ts +34 -0
  36. package/dist/clients/attach/render/page-block.js +226 -0
  37. package/dist/clients/attach/session/whip.d.ts +2 -0
  38. package/dist/clients/attach/session/whip.js +2 -0
  39. package/dist/clients/attach/viewer.js +1419 -993
  40. package/dist/clients/conversation/projection.js +18 -3
  41. package/dist/clients/inbox/__tests__/serial/inbox-controller.test.js +9 -6
  42. package/dist/clients/inbox/__tests__/serial/mount-panel.test.js +13 -21
  43. package/dist/clients/inbox/controller.js +10 -16
  44. package/dist/clients/inbox/page-adapter.d.ts +1 -3
  45. package/dist/clients/inbox/page-adapter.js +3 -4
  46. package/dist/clients/inbox/resolve.d.ts +1 -1
  47. package/dist/clients/inbox/resolve.js +3 -3
  48. package/dist/clients/inbox/review/document-surface.js +3 -1
  49. package/dist/clients/inbox/review/state.d.ts +2 -1
  50. package/dist/clients/inbox/review/state.js +5 -16
  51. package/dist/clients/inbox/tui/input.js +37 -19
  52. package/dist/clients/inbox/tui/panel.js +5 -31
  53. package/dist/clients/inbox/tui/render.d.ts +11 -0
  54. package/dist/clients/inbox/tui/render.js +71 -27
  55. package/dist/clients/inbox/tui/slots.d.ts +3 -1
  56. package/dist/clients/inbox/tui/slots.js +16 -12
  57. package/dist/clients/inbox/tui/types.d.ts +2 -7
  58. package/dist/clients/inbox/tui.js +2 -2
  59. package/dist/commands/__tests__/human.test.js +71 -114
  60. package/dist/commands/__tests__/node-message.test.js +14 -0
  61. package/dist/commands/attention.js +4 -4
  62. package/dist/commands/canvas-snapshot.js +1 -1
  63. package/dist/commands/canvas.js +1 -1
  64. package/dist/commands/dashboard.js +1 -1
  65. package/dist/commands/human/{html.d.ts → components.d.ts} +1 -1
  66. package/dist/commands/human/components.js +77 -0
  67. package/dist/commands/human/feedback.d.ts +2 -0
  68. package/dist/commands/human/feedback.js +108 -0
  69. package/dist/commands/human/prompts.d.ts +13 -5
  70. package/dist/commands/human/prompts.js +160 -97
  71. package/dist/commands/human/queue.js +57 -88
  72. package/dist/commands/human/shared.d.ts +2 -12
  73. package/dist/commands/human/shared.js +17 -11
  74. package/dist/commands/human.js +29 -21
  75. package/dist/commands/memory/origin.js +2 -2
  76. package/dist/commands/node/bash.js +4 -4
  77. package/dist/commands/node/inspect.js +3 -3
  78. package/dist/commands/node/lifecycle.js +1 -1
  79. package/dist/commands/node/message.js +2 -2
  80. package/dist/commands/node-worktree.js +8 -8
  81. package/dist/commands/pkg/browse.js +1 -1
  82. package/dist/commands/pkg/plugin-manage.js +129 -10
  83. package/dist/commands/profile/delete.js +41 -15
  84. package/dist/commands/profile.js +1 -1
  85. package/dist/commands/push.js +1 -1
  86. package/dist/commands/surface/node/focus.js +29 -14
  87. package/dist/commands/surface-edit.js +3 -3
  88. package/dist/commands/surface-inbox.d.ts +2 -0
  89. package/dist/commands/{human/inbox.js → surface-inbox.js} +14 -18
  90. package/dist/commands/surface.js +2 -1
  91. package/dist/commands/sys/doctor.js +60 -3
  92. package/dist/commands/sys/feedback.js +79 -25
  93. package/dist/commands/sys/settings.js +1 -1
  94. package/dist/core/__tests__/cron-broker-capacity.test.js +1 -1
  95. package/dist/core/__tests__/extension-abort.test.js +5 -2
  96. package/dist/core/__tests__/fixtures/fake-engine.d.ts +13 -2
  97. package/dist/core/__tests__/fixtures/fake-engine.js +47 -3
  98. package/dist/core/__tests__/helpers/harness.js +17 -55
  99. package/dist/core/__tests__/human-cancel-guard.test.js +31 -10
  100. package/dist/core/__tests__/human-deliver.test.js +31 -26
  101. package/dist/core/__tests__/human-node-not-supervised.test.js +1 -1
  102. package/dist/core/__tests__/plugin-page-components.test.js +157 -0
  103. package/dist/core/__tests__/seam/broker-crash-teardown.test.js +4 -5
  104. package/dist/core/__tests__/seam/dormancy-release.test.js +40 -0
  105. package/dist/core/__tests__/serial/flagship-lifecycle.test.js +2 -2
  106. package/dist/core/__tests__/serial/human-deliver-e2e.test.js +12 -6
  107. package/dist/core/__tests__/serial/live-mutation.test.js +1 -1
  108. package/dist/core/__tests__/serial/tmux-surface.test.js +4 -2
  109. package/dist/core/__tests__/serial/worktree.test.js +24 -198
  110. package/dist/core/__tests__/session-cycles.test.js +22 -0
  111. package/dist/core/__tests__/stop-guard.test.js +4 -4
  112. package/dist/core/__tests__/watchdog-abort-arms-retry.test.js +19 -4
  113. package/dist/core/bash-jobs.d.ts +6 -0
  114. package/dist/core/bash-jobs.js +10 -0
  115. package/dist/core/canvas/__tests__/attention.test.js +8 -5
  116. package/dist/core/canvas/__tests__/render-remote.test.js +5 -5
  117. package/dist/core/canvas/attention.js +8 -6
  118. package/dist/core/canvas/browse/model.d.ts +8 -2
  119. package/dist/core/canvas/browse/model.js +11 -4
  120. package/dist/core/canvas/canvas.d.ts +7 -0
  121. package/dist/core/canvas/canvas.js +37 -0
  122. package/dist/core/canvas/crons.d.ts +9 -0
  123. package/dist/core/canvas/crons.js +51 -0
  124. package/dist/core/canvas/node-order.d.ts +22 -1
  125. package/dist/core/canvas/node-order.js +26 -1
  126. package/dist/core/canvas/render-source.d.ts +5 -0
  127. package/dist/core/canvas/render-source.js +1 -0
  128. package/dist/core/canvas/types.d.ts +9 -3
  129. package/dist/core/command-plugins/bundle.d.ts +6 -1
  130. package/dist/core/command-plugins/bundle.js +26 -13
  131. package/dist/core/command.js +2 -1
  132. package/dist/core/config.d.ts +47 -1
  133. package/dist/core/config.js +137 -4
  134. package/dist/core/help.js +1 -1
  135. package/dist/core/human/__tests__/page-catalog.test.js +4 -0
  136. package/dist/core/human/__tests__/page-tickets.test.js +65 -52
  137. package/dist/core/human/__tests__/page.test.js +56 -98
  138. package/dist/core/human/__tests__/serial/inbox-core.test.js +6 -6
  139. package/dist/core/human/answer-text.js +3 -3
  140. package/dist/core/human/answer.d.ts +6 -4
  141. package/dist/core/human/answer.js +4 -10
  142. package/dist/core/human/component-docs.d.ts +11 -7
  143. package/dist/core/human/component-docs.js +361 -88
  144. package/dist/core/human/convention.d.ts +17 -3
  145. package/dist/core/human/convention.js +36 -5
  146. package/dist/core/human/feedback-companion.d.ts +20 -0
  147. package/dist/core/human/feedback-companion.js +98 -0
  148. package/dist/core/human/feedback.d.ts +65 -0
  149. package/dist/core/human/feedback.js +116 -0
  150. package/dist/core/human/page-catalog.d.ts +40 -5
  151. package/dist/core/human/page-catalog.js +102 -30
  152. package/dist/core/human/page-errors.d.ts +4 -0
  153. package/dist/core/human/page-errors.js +7 -0
  154. package/dist/core/human/page-eval.d.ts +20 -0
  155. package/dist/core/human/page-eval.js +123 -0
  156. package/dist/core/human/page-schema.d.ts +23 -191
  157. package/dist/core/human/page-schema.js +60 -89
  158. package/dist/core/human/page-synth.d.ts +1 -1
  159. package/dist/core/human/page-synth.js +15 -18
  160. package/dist/core/human/page.d.ts +12 -27
  161. package/dist/core/human/page.js +142 -474
  162. package/dist/core/human/root.d.ts +6 -2
  163. package/dist/core/human/root.js +12 -4
  164. package/dist/core/human/scan.d.ts +3 -4
  165. package/dist/core/human/scan.js +16 -15
  166. package/dist/core/human/summary.d.ts +1 -2
  167. package/dist/core/human/summary.js +2 -2
  168. package/dist/core/human/tickets.d.ts +20 -14
  169. package/dist/core/human/tickets.js +91 -31
  170. package/dist/core/human/types.d.ts +10 -2
  171. package/dist/core/preview-registry.js +8 -10
  172. package/dist/core/profiles/default-binding.d.ts +4 -0
  173. package/dist/core/profiles/default-binding.js +24 -0
  174. package/dist/core/profiles/deletion-reservation.d.ts +8 -0
  175. package/dist/core/profiles/deletion-reservation.js +38 -0
  176. package/dist/core/profiles/manifest.d.ts +3 -0
  177. package/dist/core/profiles/manifest.js +12 -0
  178. package/dist/core/profiles/select.js +2 -2
  179. package/dist/core/review/realize.js +3 -3
  180. package/dist/core/review/store.d.ts +6 -0
  181. package/dist/core/review/store.js +31 -0
  182. package/dist/core/runtime/bearings.d.ts +0 -4
  183. package/dist/core/runtime/bearings.js +4 -62
  184. package/dist/core/runtime/bin-contributions.d.ts +44 -0
  185. package/dist/core/runtime/bin-contributions.js +186 -0
  186. package/dist/core/runtime/broker/client-registry.d.ts +4 -0
  187. package/dist/core/runtime/broker/client-registry.js +13 -1
  188. package/dist/core/runtime/broker/extension-abort.d.ts +1 -1
  189. package/dist/core/runtime/broker/extension-abort.js +4 -2
  190. package/dist/core/runtime/broker/fault-retry.js +4 -0
  191. package/dist/core/runtime/broker/frame-dispatch.d.ts +3 -1
  192. package/dist/core/runtime/broker/frame-dispatch.js +5 -6
  193. package/dist/core/runtime/broker/read-ops.d.ts +1 -1
  194. package/dist/core/runtime/broker/read-ops.js +2 -2
  195. package/dist/core/runtime/broker/rebind.d.ts +1 -0
  196. package/dist/core/runtime/broker/rebind.js +6 -1
  197. package/dist/core/runtime/broker-extension-render.js +19 -0
  198. package/dist/core/runtime/broker-protocol.d.ts +14 -0
  199. package/dist/core/runtime/broker.d.ts +1 -1
  200. package/dist/core/runtime/broker.js +17 -6
  201. package/dist/core/runtime/front-door-env.d.ts +5 -0
  202. package/dist/core/runtime/front-door-env.js +16 -0
  203. package/dist/core/runtime/front-door.d.ts +1 -5
  204. package/dist/core/runtime/front-door.js +2 -5
  205. package/dist/core/runtime/host.d.ts +1 -1
  206. package/dist/core/runtime/invocation.d.ts +6 -0
  207. package/dist/core/runtime/invocation.js +10 -0
  208. package/dist/core/runtime/kickoff.js +34 -0
  209. package/dist/core/runtime/launch.d.ts +2 -6
  210. package/dist/core/runtime/node-read.js +4 -1
  211. package/dist/core/runtime/nodes.js +2 -0
  212. package/dist/core/runtime/promote.d.ts +1 -0
  213. package/dist/core/runtime/promote.js +3 -1
  214. package/dist/core/runtime/session-cycles.d.ts +6 -0
  215. package/dist/core/runtime/session-cycles.js +15 -1
  216. package/dist/core/runtime/session-visibility.d.ts +17 -8
  217. package/dist/core/runtime/session-visibility.js +19 -10
  218. package/dist/core/runtime/spawn-env.d.ts +9 -1
  219. package/dist/core/runtime/spawn-env.js +62 -2
  220. package/dist/core/runtime/stop-guard.d.ts +2 -2
  221. package/dist/core/runtime/stop-guard.js +2 -2
  222. package/dist/core/runtime/stop-signals.d.ts +1 -1
  223. package/dist/core/runtime/stop-signals.js +2 -2
  224. package/dist/core/runtime/tmux-bindings.js +1 -1
  225. package/dist/core/session-model/session-state.d.ts +4 -3
  226. package/dist/core/session-model/session-state.js +14 -1
  227. package/dist/core/user-settings.d.ts +21 -2
  228. package/dist/core/user-settings.js +32 -11
  229. package/dist/core/worktree.d.ts +15 -45
  230. package/dist/core/worktree.js +59 -261
  231. package/dist/daemon/api/__tests__/seam/profile-delete.test.d.ts +1 -0
  232. package/dist/daemon/api/__tests__/seam/profile-delete.test.js +386 -0
  233. package/dist/daemon/api/handlers/bash-jobs.js +1 -1
  234. package/dist/daemon/api/handlers/broker-ops.js +9 -5
  235. package/dist/daemon/api/handlers/feedback-comments.d.ts +2 -0
  236. package/dist/daemon/api/handlers/feedback-comments.js +207 -0
  237. package/dist/daemon/api/handlers/human.js +24 -20
  238. package/dist/daemon/api/handlers/inbox.d.ts +10 -0
  239. package/dist/daemon/api/handlers/inbox.js +39 -115
  240. package/dist/daemon/api/handlers/profiles.js +11 -29
  241. package/dist/daemon/api/map.d.ts +6 -1
  242. package/dist/daemon/api/map.js +23 -0
  243. package/dist/daemon/api/server.js +3 -1
  244. package/dist/daemon/companion-retire.d.ts +2 -0
  245. package/dist/daemon/companion-retire.js +33 -0
  246. package/dist/daemon/cron-run.js +14 -16
  247. package/dist/daemon/human/finish.d.ts +12 -7
  248. package/dist/daemon/human/finish.js +101 -38
  249. package/dist/daemon/human/sweep.js +5 -1
  250. package/dist/daemon/profile-delete.d.ts +7 -0
  251. package/dist/daemon/profile-delete.js +306 -0
  252. package/dist/daemon/reconcilers/broker-supervision.js +3 -1
  253. package/dist/daemon/review/deliver.js +3 -3
  254. package/dist/daemon/review/finish.d.ts +0 -2
  255. package/dist/daemon/review/finish.js +1 -29
  256. package/dist/pi-extensions/__tests__/canvas-bash-valve.test.js +56 -1
  257. package/dist/pi-extensions/__tests__/canvas-stophook-agentend.test.js +4 -4
  258. package/dist/pi-extensions/canvas-bash-valve.js +19 -5
  259. package/dist/pi-extensions/canvas-inbox-watcher.js +1 -1
  260. package/dist/pi-extensions/canvas-review-boundary.d.ts +4 -0
  261. package/dist/pi-extensions/canvas-review-boundary.js +18 -9
  262. package/dist/pi-extensions/canvas-stophook.js +4 -4
  263. package/dist/shared/generated-context.js +2 -2
  264. package/dist/types.d.ts +44 -2
  265. package/dist/types.js +7 -2
  266. package/package.json +6 -5
  267. package/runtime.lock.json +5 -33
  268. package/dist/builtin-memory/init.md +0 -38
  269. package/dist/builtin-memory/plan.md +0 -19
  270. package/dist/builtin-memory/spec.md +0 -19
  271. package/dist/commands/human/doc.d.ts +0 -2
  272. package/dist/commands/human/doc.js +0 -91
  273. package/dist/commands/human/html.js +0 -81
  274. package/dist/commands/human/inbox.d.ts +0 -2
  275. package/dist/core/human/__tests__/html-markdown.test.js +0 -52
  276. package/dist/core/human/__tests__/page-render.test.js +0 -66
  277. package/dist/core/human/html-markdown.d.ts +0 -3
  278. package/dist/core/human/html-markdown.js +0 -288
  279. package/dist/core/human/page-render.d.ts +0 -4
  280. package/dist/core/human/page-render.js +0 -105
  281. package/dist/pages/bundle.css +0 -1
  282. package/dist/pages/bundle.js +0 -1778
  283. package/dist/pages/comments.d.ts +0 -72
  284. package/dist/pages/comments.js +0 -176
  285. package/dist/pages/controls.d.ts +0 -98
  286. package/dist/pages/controls.js +0 -261
  287. package/dist/pages/elements/cards.d.ts +0 -28
  288. package/dist/pages/elements/cards.js +0 -915
  289. package/dist/pages/elements/chart.d.ts +0 -23
  290. package/dist/pages/elements/chart.js +0 -664
  291. package/dist/pages/elements/options.d.ts +0 -30
  292. package/dist/pages/elements/options.js +0 -742
  293. package/dist/pages/elements/pages.d.ts +0 -30
  294. package/dist/pages/elements/pages.js +0 -377
  295. package/dist/pages/elements/slot.d.ts +0 -26
  296. package/dist/pages/elements/slot.js +0 -112
  297. package/dist/pages/elements/table.d.ts +0 -36
  298. package/dist/pages/elements/table.js +0 -1043
  299. package/dist/pages/elements/text.d.ts +0 -31
  300. package/dist/pages/elements/text.js +0 -1175
  301. package/dist/pages/entry.d.ts +0 -8
  302. package/dist/pages/entry.js +0 -8
  303. package/dist/pages/host.d.ts +0 -134
  304. package/dist/pages/host.js +0 -165
  305. package/dist/pages/readonly.d.ts +0 -24
  306. package/dist/pages/readonly.js +0 -31
  307. package/dist/pages/register.d.ts +0 -2
  308. package/dist/pages/register.js +0 -3
  309. package/dist/pages/responses.d.ts +0 -37
  310. package/dist/pages/responses.js +0 -56
  311. package/dist/pages/slot-config.d.ts +0 -36
  312. package/dist/pages/slot-config.js +0 -50
  313. package/dist/pages/types.d.ts +0 -98
  314. package/dist/pages/types.js +0 -23
  315. /package/dist/{core/human/__tests__/html-markdown.test.d.ts → commands/__tests__/node-message.test.d.ts} +0 -0
  316. /package/dist/core/{human/__tests__/page-render.test.d.ts → __tests__/plugin-page-components.test.d.ts} +0 -0
@@ -0,0 +1,123 @@
1
+ import vm from 'node:vm';
2
+ import { PageAuthoringError } from './page-errors.js';
3
+ const EVAL_TIMEOUT_MS = 2000;
4
+ const MAX_DEPTH = 64;
5
+ const FRAGMENT = Symbol('page.fragment');
6
+ /** Generic static-extraction binding for the host hook. It must tolerate any product capability name while leaving unrelated free identifiers as errors. */
7
+ function hostStub() {
8
+ let proxy;
9
+ const callable = () => proxy;
10
+ proxy = new Proxy(callable, { get: () => proxy, apply: () => proxy });
11
+ return proxy;
12
+ }
13
+ /** A page is authored against React's classic runtime, so the compiled module calls
14
+ * `React.createElement`. Nothing here renders: the stub records the tree and returns
15
+ * initial values for the hooks a page might reach for, which is what a manifest wants. */
16
+ function stubReact() {
17
+ // A helper component is expanded here, while the render is still inside the vm, so a
18
+ // component that never returns is stopped by the same timeout as the page itself.
19
+ const createElement = (type, props, ...children) => {
20
+ const { key: _key, ref: _ref, ...rest } = props ?? {};
21
+ const flat = children.flat(Infinity);
22
+ if (typeof type === 'function')
23
+ return type({ ...rest, ...(flat.length === 0 ? {} : { children: flat }) });
24
+ return { $page_element: true, type, props: rest, children: flat };
25
+ };
26
+ return {
27
+ createElement,
28
+ Fragment: FRAGMENT,
29
+ useState: (initial) => [typeof initial === 'function' ? initial() : initial, () => { }],
30
+ useReducer: (_reducer, initial) => [initial, () => { }],
31
+ useMemo: (factory) => factory(),
32
+ useCallback: (fn) => fn,
33
+ useRef: (initial) => ({ current: initial }),
34
+ useEffect: () => { },
35
+ useLayoutEffect: () => { },
36
+ useId: () => 'page-id',
37
+ };
38
+ }
39
+ function isRawElement(value) {
40
+ return typeof value === 'object' && value !== null && value.$page_element === true;
41
+ }
42
+ /** Evaluate the compiled page module and return the element tree its default export renders.
43
+ *
44
+ * Each in-scope component name is bound to itself, so `<UserQuestion>` renders as the tag
45
+ * string `"UserQuestion"`. A name outside that set is not defined, and the page fails with
46
+ * the reference error rather than rendering a component the host does not have. */
47
+ export function evaluatePageTree(code, tags) {
48
+ const exported = {};
49
+ const base = {
50
+ React: stubReact(),
51
+ module: { exports: exported },
52
+ exports: exported,
53
+ console: { log: () => { }, warn: () => { }, error: () => { }, info: () => { }, debug: () => { } },
54
+ usePageHost: hostStub(),
55
+ };
56
+ for (const tag of tags)
57
+ base[tag] = tag;
58
+ const deadline = Date.now() + EVAL_TIMEOUT_MS;
59
+ let rendered;
60
+ try {
61
+ vm.createContext(base);
62
+ new vm.Script(code, { filename: 'page.tsx' }).runInContext(base, { timeout: EVAL_TIMEOUT_MS });
63
+ const component = base['module'].exports.default;
64
+ if (typeof component !== 'function')
65
+ throw new PageAuthoringError('page module must `export default` a component function');
66
+ // Render inside the context so a page that never returns is stopped by the timeout
67
+ // rather than hanging the caller.
68
+ rendered = new vm.Script('(module.exports.default)({})', { filename: 'page.tsx' }).runInContext(base, { timeout: EVAL_TIMEOUT_MS });
69
+ }
70
+ catch (error) {
71
+ if (error instanceof PageAuthoringError)
72
+ throw error;
73
+ const message = error instanceof Error ? error.message : String(error);
74
+ throw new PageAuthoringError(`page failed while rendering: ${message}`);
75
+ }
76
+ // The promise is built in the vm's realm, so identity checks against this realm's
77
+ // Promise do not hold; thenable is the honest test.
78
+ if (typeof rendered?.then === 'function')
79
+ throw new PageAuthoringError('page component is async; a page renders synchronously');
80
+ const normalize = (value, depth) => {
81
+ if (value === null || value === undefined || typeof value === 'boolean')
82
+ return [];
83
+ if (depth > MAX_DEPTH)
84
+ throw new PageAuthoringError('page nests deeper than a page can render; check for a component that renders itself');
85
+ if (Date.now() > deadline)
86
+ throw new PageAuthoringError('page took too long to render; check for a component that never finishes');
87
+ if (Array.isArray(value))
88
+ return value.flatMap((item) => normalize(item, depth + 1));
89
+ if (!isRawElement(value))
90
+ return [];
91
+ const { type, props, children } = value;
92
+ const nested = [...normalize(props['children'], depth + 1), ...children.flatMap((child) => normalize(child, depth + 1))];
93
+ if (type === FRAGMENT)
94
+ return nested;
95
+ if (typeof type !== 'string')
96
+ return nested;
97
+ const { children: _children, ...rest } = props;
98
+ return [{ tag: type, props: rest, children: nested }];
99
+ };
100
+ try {
101
+ return normalize(rendered, 0);
102
+ }
103
+ catch (error) {
104
+ if (error instanceof PageAuthoringError)
105
+ throw error;
106
+ const message = error instanceof Error ? error.message : String(error);
107
+ throw new PageAuthoringError(`page failed while rendering: ${message}`);
108
+ }
109
+ }
110
+ /** Keep only what can cross the wire. A manifest is JSON, so handlers and undefined values
111
+ * are dropped rather than rejected — a click handler is legitimate authoring, it simply has
112
+ * no meaning to a host reading the manifest. The round-trip also rebuilds the props in this
113
+ * realm: values born in the vm carry that realm's prototypes, which prototype-sensitive
114
+ * comparisons reject. */
115
+ export function jsonProps(props) {
116
+ try {
117
+ return JSON.parse(JSON.stringify(props));
118
+ }
119
+ catch (error) {
120
+ const message = error instanceof Error ? error.message : String(error);
121
+ throw new PageAuthoringError(`page prop cannot cross the wire: ${message}`);
122
+ }
123
+ }
@@ -3,47 +3,21 @@ import { BUILTIN_PAGE_KINDS } from './page-catalog.js';
3
3
  import type { ProductPageComponents } from '../../types.js';
4
4
  export declare const PAGE_SLOT_ID_PATTERN: RegExp;
5
5
  export declare const commentAnchorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
- kind: z.ZodLiteral<"whole">;
7
- }, z.core.$strict>, z.ZodObject<{
8
6
  kind: z.ZodLiteral<"option">;
9
7
  optionId: z.ZodString;
10
8
  }, z.core.$strict>, z.ZodObject<{
11
9
  kind: z.ZodLiteral<"row">;
12
10
  rowId: z.ZodString;
13
- }, z.core.$strict>, z.ZodObject<{
14
- kind: z.ZodLiteral<"column">;
15
- columnId: z.ZodString;
16
- }, z.core.$strict>, z.ZodObject<{
17
- kind: z.ZodLiteral<"card">;
18
- cardId: z.ZodString;
19
- }, z.core.$strict>, z.ZodObject<{
20
- kind: z.ZodLiteral<"range">;
21
- start: z.ZodNumber;
22
- end: z.ZodNumber;
23
- quote: z.ZodString;
24
11
  }, z.core.$strict>], "kind">;
25
12
  export type CommentAnchor = z.infer<typeof commentAnchorSchema>;
26
13
  export declare const commentSchema: z.ZodObject<{
27
14
  id: z.ZodString;
28
15
  anchor: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
- kind: z.ZodLiteral<"whole">;
30
- }, z.core.$strict>, z.ZodObject<{
31
16
  kind: z.ZodLiteral<"option">;
32
17
  optionId: z.ZodString;
33
18
  }, z.core.$strict>, z.ZodObject<{
34
19
  kind: z.ZodLiteral<"row">;
35
20
  rowId: z.ZodString;
36
- }, z.core.$strict>, z.ZodObject<{
37
- kind: z.ZodLiteral<"column">;
38
- columnId: z.ZodString;
39
- }, z.core.$strict>, z.ZodObject<{
40
- kind: z.ZodLiteral<"card">;
41
- cardId: z.ZodString;
42
- }, z.core.$strict>, z.ZodObject<{
43
- kind: z.ZodLiteral<"range">;
44
- start: z.ZodNumber;
45
- end: z.ZodNumber;
46
- quote: z.ZodString;
47
21
  }, z.core.$strict>], "kind">;
48
22
  text: z.ZodString;
49
23
  }, z.core.$strict>;
@@ -55,6 +29,7 @@ export declare const optionSchema: z.ZodObject<{
55
29
  }, z.core.$strict>;
56
30
  export declare const optionsConfigSchema: z.ZodObject<{
57
31
  label: z.ZodOptional<z.ZodString>;
32
+ body: z.ZodOptional<z.ZodString>;
58
33
  options: z.ZodArray<z.ZodObject<{
59
34
  id: z.ZodString;
60
35
  label: z.ZodString;
@@ -74,24 +49,11 @@ export declare const optionsResponseSchema: z.ZodObject<{
74
49
  comments: z.ZodArray<z.ZodObject<{
75
50
  id: z.ZodString;
76
51
  anchor: z.ZodDiscriminatedUnion<[z.ZodObject<{
77
- kind: z.ZodLiteral<"whole">;
78
- }, z.core.$strict>, z.ZodObject<{
79
52
  kind: z.ZodLiteral<"option">;
80
53
  optionId: z.ZodString;
81
54
  }, z.core.$strict>, z.ZodObject<{
82
55
  kind: z.ZodLiteral<"row">;
83
56
  rowId: z.ZodString;
84
- }, z.core.$strict>, z.ZodObject<{
85
- kind: z.ZodLiteral<"column">;
86
- columnId: z.ZodString;
87
- }, z.core.$strict>, z.ZodObject<{
88
- kind: z.ZodLiteral<"card">;
89
- cardId: z.ZodString;
90
- }, z.core.$strict>, z.ZodObject<{
91
- kind: z.ZodLiteral<"range">;
92
- start: z.ZodNumber;
93
- end: z.ZodNumber;
94
- quote: z.ZodString;
95
57
  }, z.core.$strict>], "kind">;
96
58
  text: z.ZodString;
97
59
  }, z.core.$strict>>;
@@ -101,7 +63,6 @@ export type OptionsResponse = z.infer<typeof optionsResponseSchema>;
101
63
  export declare const textConfigSchema: z.ZodObject<{
102
64
  label: z.ZodOptional<z.ZodString>;
103
65
  initialText: z.ZodString;
104
- editable: z.ZodOptional<z.ZodBoolean>;
105
66
  placeholder: z.ZodOptional<z.ZodString>;
106
67
  singleLine: z.ZodOptional<z.ZodBoolean>;
107
68
  }, z.core.$strict>;
@@ -109,30 +70,6 @@ export type TextConfig = z.infer<typeof textConfigSchema>;
109
70
  export declare const textResponseSchema: z.ZodObject<{
110
71
  text: z.ZodString;
111
72
  edited: z.ZodBoolean;
112
- comments: z.ZodArray<z.ZodObject<{
113
- id: z.ZodString;
114
- anchor: z.ZodDiscriminatedUnion<[z.ZodObject<{
115
- kind: z.ZodLiteral<"whole">;
116
- }, z.core.$strict>, z.ZodObject<{
117
- kind: z.ZodLiteral<"option">;
118
- optionId: z.ZodString;
119
- }, z.core.$strict>, z.ZodObject<{
120
- kind: z.ZodLiteral<"row">;
121
- rowId: z.ZodString;
122
- }, z.core.$strict>, z.ZodObject<{
123
- kind: z.ZodLiteral<"column">;
124
- columnId: z.ZodString;
125
- }, z.core.$strict>, z.ZodObject<{
126
- kind: z.ZodLiteral<"card">;
127
- cardId: z.ZodString;
128
- }, z.core.$strict>, z.ZodObject<{
129
- kind: z.ZodLiteral<"range">;
130
- start: z.ZodNumber;
131
- end: z.ZodNumber;
132
- quote: z.ZodString;
133
- }, z.core.$strict>], "kind">;
134
- text: z.ZodString;
135
- }, z.core.$strict>>;
136
73
  }, z.core.$strict>;
137
74
  export type TextResponse = z.infer<typeof textResponseSchema>;
138
75
  export declare const tableColumnSchema: z.ZodObject<{
@@ -153,37 +90,10 @@ export declare const tableRowsSchema: z.ZodArray<z.ZodObject<{
153
90
  id: z.ZodString;
154
91
  cells: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
155
92
  }, z.core.$strict>>;
156
- /** Stored table config: its data is always embedded. */
93
+ /** Table config: its data is always embedded. */
157
94
  export declare const tableConfigSchema: z.ZodObject<{
158
95
  label: z.ZodOptional<z.ZodString>;
159
- columns: z.ZodArray<z.ZodObject<{
160
- id: z.ZodString;
161
- label: z.ZodString;
162
- align: z.ZodOptional<z.ZodEnum<{
163
- right: "right";
164
- left: "left";
165
- }>>;
166
- mono: z.ZodOptional<z.ZodBoolean>;
167
- }, z.core.$strict>>;
168
- rows: z.ZodOptional<z.ZodArray<z.ZodObject<{
169
- id: z.ZodString;
170
- cells: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
171
- }, z.core.$strict>>>;
172
- rowSelect: z.ZodDefault<z.ZodEnum<{
173
- none: "none";
174
- single: "single";
175
- multi: "multi";
176
- }>>;
177
- columnSelect: z.ZodDefault<z.ZodEnum<{
178
- none: "none";
179
- single: "single";
180
- multi: "multi";
181
- }>>;
182
- }, z.core.$strict>;
183
- /** Authored table config: `source` is resolved before the manifest is stored. */
184
- export declare const authoredTableConfigSchema: z.ZodObject<{
185
- source: z.ZodString;
186
- label: z.ZodOptional<z.ZodString>;
96
+ body: z.ZodOptional<z.ZodString>;
187
97
  columns: z.ZodArray<z.ZodObject<{
188
98
  id: z.ZodString;
189
99
  label: z.ZodString;
@@ -209,31 +119,17 @@ export declare const authoredTableConfigSchema: z.ZodObject<{
209
119
  }>>;
210
120
  }, z.core.$strict>;
211
121
  export type TableConfig = z.infer<typeof tableConfigSchema>;
212
- export type AuthoredTableConfig = TableConfig | z.infer<typeof authoredTableConfigSchema>;
213
122
  export declare const tableResponseSchema: z.ZodObject<{
214
123
  selectedRowIds: z.ZodArray<z.ZodString>;
215
124
  selectedColumnIds: z.ZodArray<z.ZodString>;
216
125
  comments: z.ZodArray<z.ZodObject<{
217
126
  id: z.ZodString;
218
127
  anchor: z.ZodDiscriminatedUnion<[z.ZodObject<{
219
- kind: z.ZodLiteral<"whole">;
220
- }, z.core.$strict>, z.ZodObject<{
221
128
  kind: z.ZodLiteral<"option">;
222
129
  optionId: z.ZodString;
223
130
  }, z.core.$strict>, z.ZodObject<{
224
131
  kind: z.ZodLiteral<"row">;
225
132
  rowId: z.ZodString;
226
- }, z.core.$strict>, z.ZodObject<{
227
- kind: z.ZodLiteral<"column">;
228
- columnId: z.ZodString;
229
- }, z.core.$strict>, z.ZodObject<{
230
- kind: z.ZodLiteral<"card">;
231
- cardId: z.ZodString;
232
- }, z.core.$strict>, z.ZodObject<{
233
- kind: z.ZodLiteral<"range">;
234
- start: z.ZodNumber;
235
- end: z.ZodNumber;
236
- quote: z.ZodString;
237
133
  }, z.core.$strict>], "kind">;
238
134
  text: z.ZodString;
239
135
  }, z.core.$strict>>;
@@ -253,26 +149,10 @@ export declare const cardsSchema: z.ZodArray<z.ZodObject<{
253
149
  body: z.ZodOptional<z.ZodString>;
254
150
  tag: z.ZodOptional<z.ZodString>;
255
151
  }, z.core.$strict>>;
256
- /** Stored cards config: its data is always embedded. */
152
+ /** Cards config: its data is always embedded. */
257
153
  export declare const cardsConfigSchema: z.ZodObject<{
258
154
  label: z.ZodOptional<z.ZodString>;
259
- cards: z.ZodOptional<z.ZodArray<z.ZodObject<{
260
- id: z.ZodString;
261
- title: z.ZodString;
262
- subtitle: z.ZodOptional<z.ZodString>;
263
- body: z.ZodOptional<z.ZodString>;
264
- tag: z.ZodOptional<z.ZodString>;
265
- }, z.core.$strict>>>;
266
- mode: z.ZodEnum<{
267
- single: "single";
268
- multi: "multi";
269
- }>;
270
- columns: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
271
- }, z.core.$strict>;
272
- /** Authored cards config: `source` is resolved before the manifest is stored. */
273
- export declare const authoredCardsConfigSchema: z.ZodObject<{
274
- source: z.ZodString;
275
- label: z.ZodOptional<z.ZodString>;
155
+ body: z.ZodOptional<z.ZodString>;
276
156
  cards: z.ZodOptional<z.ZodArray<z.ZodObject<{
277
157
  id: z.ZodString;
278
158
  title: z.ZodString;
@@ -287,33 +167,8 @@ export declare const authoredCardsConfigSchema: z.ZodObject<{
287
167
  columns: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
288
168
  }, z.core.$strict>;
289
169
  export type CardsConfig = z.infer<typeof cardsConfigSchema>;
290
- export type AuthoredCardsConfig = CardsConfig | z.infer<typeof authoredCardsConfigSchema>;
291
170
  export declare const cardsResponseSchema: z.ZodObject<{
292
171
  selectedCardIds: z.ZodArray<z.ZodString>;
293
- comments: z.ZodArray<z.ZodObject<{
294
- id: z.ZodString;
295
- anchor: z.ZodDiscriminatedUnion<[z.ZodObject<{
296
- kind: z.ZodLiteral<"whole">;
297
- }, z.core.$strict>, z.ZodObject<{
298
- kind: z.ZodLiteral<"option">;
299
- optionId: z.ZodString;
300
- }, z.core.$strict>, z.ZodObject<{
301
- kind: z.ZodLiteral<"row">;
302
- rowId: z.ZodString;
303
- }, z.core.$strict>, z.ZodObject<{
304
- kind: z.ZodLiteral<"column">;
305
- columnId: z.ZodString;
306
- }, z.core.$strict>, z.ZodObject<{
307
- kind: z.ZodLiteral<"card">;
308
- cardId: z.ZodString;
309
- }, z.core.$strict>, z.ZodObject<{
310
- kind: z.ZodLiteral<"range">;
311
- start: z.ZodNumber;
312
- end: z.ZodNumber;
313
- quote: z.ZodString;
314
- }, z.core.$strict>], "kind">;
315
- text: z.ZodString;
316
- }, z.core.$strict>>;
317
172
  }, z.core.$strict>;
318
173
  export type CardsResponse = z.infer<typeof cardsResponseSchema>;
319
174
  export declare const chartSeriesSchema: z.ZodObject<{
@@ -321,7 +176,7 @@ export declare const chartSeriesSchema: z.ZodObject<{
321
176
  label: z.ZodOptional<z.ZodString>;
322
177
  }, z.core.$strict>;
323
178
  export declare const chartDataRowsSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
324
- /** Stored chart config: its data is always embedded. */
179
+ /** Chart config: its data is always embedded. */
325
180
  export declare const chartConfigSchema: z.ZodObject<{
326
181
  kind: z.ZodEnum<{
327
182
  line: "line";
@@ -336,26 +191,8 @@ export declare const chartConfigSchema: z.ZodObject<{
336
191
  title: z.ZodOptional<z.ZodString>;
337
192
  data: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
338
193
  }, z.core.$strict>;
339
- /** Authored chart config: `source` is resolved before the manifest is stored. */
340
- export declare const authoredChartConfigSchema: z.ZodObject<{
341
- source: z.ZodString;
342
- kind: z.ZodEnum<{
343
- line: "line";
344
- bar: "bar";
345
- area: "area";
346
- }>;
347
- x: z.ZodString;
348
- y: z.ZodArray<z.ZodObject<{
349
- field: z.ZodString;
350
- label: z.ZodOptional<z.ZodString>;
351
- }, z.core.$strict>>;
352
- title: z.ZodOptional<z.ZodString>;
353
- data: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
354
- }, z.core.$strict>;
355
194
  export type ChartConfig = z.infer<typeof chartConfigSchema>;
356
- export type AuthoredChartConfig = ChartConfig | z.infer<typeof authoredChartConfigSchema>;
357
195
  export type SlotConfig = OptionsConfig | TextConfig | TableConfig | CardsConfig | ChartConfig | Record<string, unknown>;
358
- export type AuthoredSlotConfig = OptionsConfig | TextConfig | AuthoredTableConfig | AuthoredCardsConfig | AuthoredChartConfig | Record<string, unknown>;
359
196
  export type SlotResponse = OptionsResponse | TextResponse | TableResponse | CardsResponse | Record<string, unknown>;
360
197
  export interface PageSlot {
361
198
  id?: string;
@@ -363,50 +200,45 @@ export interface PageSlot {
363
200
  step: number;
364
201
  config: SlotConfig;
365
202
  unvalidated?: true;
366
- /** Product registration declares this slot display-only. */
203
+ /** Product registration declares this component display-only, so it carries no response. */
367
204
  display?: true;
368
205
  }
369
- /** A page before submit may contain filesystem `source` paths. */
370
- export interface AuthoredPageSlot extends Omit<PageSlot, 'config'> {
371
- config: AuthoredSlotConfig;
372
- }
373
206
  export interface PageSource {
374
207
  sessionName?: string;
375
208
  askedBy?: string;
376
- blockedSince?: string;
209
+ emittedAt?: string;
377
210
  profileName?: string;
378
211
  nodeId?: string;
379
212
  }
213
+ export interface PageDelivery {
214
+ placement: 'inline' | 'panel';
215
+ inbox: boolean;
216
+ reply: boolean;
217
+ }
380
218
  export interface PageManifest {
381
- schema: 'crtr.page/v1';
382
- dialect: 'md' | 'html';
219
+ schema: 'crtr.page/v2';
220
+ dialect: 'jsx' | 'html';
383
221
  title: string;
384
222
  subtitle?: string;
385
- placement: 'inline' | 'panel';
386
- document: 'page.md' | 'page.html';
223
+ delivery: PageDelivery;
224
+ document: 'page.tsx' | 'page.html';
387
225
  steps: number;
388
- /** Persisted slots never carry a source path. */
389
226
  slots: PageSlot[];
390
227
  source?: PageSource;
391
228
  }
392
- /** A page before submit may carry filesystem source paths in its built-in slots. */
393
- export interface AuthoredPageManifest extends Omit<PageManifest, 'slots'> {
394
- slots: AuthoredPageSlot[];
395
- }
396
229
  export declare const BUILTIN_PAGE_CONFIG_SCHEMAS: Record<(typeof BUILTIN_PAGE_KINDS)[number], z.ZodType>;
397
230
  export declare const BUILTIN_PAGE_RESPONSE_SCHEMAS: Partial<Record<(typeof BUILTIN_PAGE_KINDS)[number], z.ZodType>>;
398
231
  export declare function issueText(error: z.ZodError): string;
399
232
  /** The canonical response-bearing predicate used by every page consumer. */
400
233
  export declare function isResponseBearingSlot(slot: PageSlot): boolean;
401
- /** Validate a persisted manifest. Source paths are rejected: pages render only embedded data. */
402
- export declare function validatePageManifest(parsed: unknown, productComponents?: ProductPageComponents): PageManifest;
403
- /** Validate an authored manifest before submit. Source paths are resolved by `snapshotPageSources`. */
404
- export declare function validateAuthoredPageManifest(parsed: unknown, productComponents?: ProductPageComponents): AuthoredPageManifest;
405
- export declare function createPageManifestSchema(productComponents?: ProductPageComponents): z.ZodType<PageManifest>;
406
- /** Built-in-only manifest schema; product-aware callers use createPageManifestSchema. */
234
+ /** Validate a persisted manifest. Publish-time validation made its slots authoritative, so reads do not resolve a component catalog. */
235
+ export declare function validatePageManifest(parsed: unknown): PageManifest;
236
+ /** Validate a manifest derived from an authored page, where the display flag comes from the registration rather than the source. */
237
+ export declare function validateAuthoredPageManifest(parsed: unknown, productComponents?: ProductPageComponents): PageManifest;
238
+ export declare function createPageManifestSchema(): z.ZodType<PageManifest>;
407
239
  export declare const pageManifestSchema: z.ZodType<PageManifest, unknown, z.core.$ZodTypeInternals<PageManifest, unknown>>;
408
240
  export type PageResponses = Record<string, SlotResponse>;
409
241
  /** Validate a complete final response map. */
410
242
  export declare function validatePageResponses(manifest: PageManifest, responses: unknown): PageResponses;
411
- /** Validate an autosaved response map, permitting omitted response-bearing slots. */
243
+ /** Validate an autosaved response map, permitting omitted response-bearing components. */
412
244
  export declare function validatePartialPageResponses(manifest: PageManifest, responses: unknown): PageResponses;