@xemahq/ui-kernel 0.9.0 → 0.9.2

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 (444) hide show
  1. package/README.md +2 -2
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/biome-host/biome-builders.d.ts.map +1 -1
  7. package/dist/lib/biome-host/biome-builders.js +3 -1
  8. package/dist/lib/biome-host/biome-builders.js.map +1 -1
  9. package/dist/lib/biome-host/biome-registry.d.ts.map +1 -1
  10. package/dist/lib/biome-host/biome-registry.js +14 -9
  11. package/dist/lib/biome-host/biome-registry.js.map +1 -1
  12. package/dist/lib/biome-host/biome-scope-hooks.d.ts +11 -0
  13. package/dist/lib/biome-host/biome-scope-hooks.d.ts.map +1 -0
  14. package/dist/lib/biome-host/biome-scope-hooks.js +25 -0
  15. package/dist/lib/biome-host/biome-scope-hooks.js.map +1 -0
  16. package/dist/lib/biome-host/biome-scope.d.ts +1 -10
  17. package/dist/lib/biome-host/biome-scope.d.ts.map +1 -1
  18. package/dist/lib/biome-host/biome-scope.js +1 -24
  19. package/dist/lib/biome-host/biome-scope.js.map +1 -1
  20. package/dist/lib/biome-host/biome-scoped-query.d.ts +1 -1
  21. package/dist/lib/biome-host/biome-scoped-query.d.ts.map +1 -1
  22. package/dist/lib/biome-host/biome-scoped-query.js +1 -1
  23. package/dist/lib/biome-host/biome-scoped-query.js.map +1 -1
  24. package/dist/lib/biome-host/create-biome-orval-config.js +2 -2
  25. package/dist/lib/biome-host/create-biome-orval-config.js.map +1 -1
  26. package/dist/lib/biome-host/errors.js.map +1 -1
  27. package/dist/lib/biome-host/index.d.ts +1 -1
  28. package/dist/lib/biome-host/index.d.ts.map +1 -1
  29. package/dist/lib/biome-host/index.js +1 -1
  30. package/dist/lib/biome-host/index.js.map +1 -1
  31. package/dist/lib/biome-host/session-profiles.d.ts.map +1 -1
  32. package/dist/lib/biome-host/session-profiles.js +4 -1
  33. package/dist/lib/biome-host/session-profiles.js.map +1 -1
  34. package/dist/lib/capabilities/capability-context.d.ts +9 -0
  35. package/dist/lib/capabilities/capability-context.d.ts.map +1 -0
  36. package/dist/lib/capabilities/capability-context.js +13 -0
  37. package/dist/lib/capabilities/capability-context.js.map +1 -0
  38. package/dist/lib/capabilities/capability-provider.d.ts +2 -8
  39. package/dist/lib/capabilities/capability-provider.d.ts.map +1 -1
  40. package/dist/lib/capabilities/capability-provider.js +1 -12
  41. package/dist/lib/capabilities/capability-provider.js.map +1 -1
  42. package/dist/lib/capabilities/index.d.ts +1 -0
  43. package/dist/lib/capabilities/index.d.ts.map +1 -1
  44. package/dist/lib/capabilities/index.js +1 -0
  45. package/dist/lib/capabilities/index.js.map +1 -1
  46. package/dist/lib/capabilities/use-capability.d.ts.map +1 -1
  47. package/dist/lib/capabilities/use-capability.js +1 -1
  48. package/dist/lib/capabilities/use-capability.js.map +1 -1
  49. package/dist/lib/contribution-registry/contribution-registry.d.ts +24 -0
  50. package/dist/lib/contribution-registry/contribution-registry.d.ts.map +1 -0
  51. package/dist/lib/contribution-registry/contribution-registry.js +67 -0
  52. package/dist/lib/contribution-registry/contribution-registry.js.map +1 -0
  53. package/dist/lib/contribution-registry/index.d.ts +3 -0
  54. package/dist/lib/contribution-registry/index.d.ts.map +1 -0
  55. package/dist/lib/contribution-registry/index.js +3 -0
  56. package/dist/lib/contribution-registry/index.js.map +1 -0
  57. package/dist/lib/contribution-registry/renderable-registry.d.ts +33 -0
  58. package/dist/lib/contribution-registry/renderable-registry.d.ts.map +1 -0
  59. package/dist/lib/contribution-registry/renderable-registry.js +51 -0
  60. package/dist/lib/contribution-registry/renderable-registry.js.map +1 -0
  61. package/dist/lib/system-bus/deeplink.js.map +1 -1
  62. package/dist/lib/system-bus/host-ports.d.ts +2 -1
  63. package/dist/lib/system-bus/host-ports.d.ts.map +1 -1
  64. package/dist/lib/system-bus/intent-registry.d.ts.map +1 -1
  65. package/dist/lib/system-bus/intent-registry.js.map +1 -1
  66. package/dist/offline/index.d.ts +2 -1
  67. package/dist/offline/index.d.ts.map +1 -1
  68. package/dist/offline/index.js +2 -1
  69. package/dist/offline/index.js.map +1 -1
  70. package/dist/offline/offline-status-badge.js +1 -1
  71. package/dist/offline/offline-status-badge.js.map +1 -1
  72. package/dist/offline/outbox.js.map +1 -1
  73. package/dist/offline/react-hooks.d.ts +7 -0
  74. package/dist/offline/react-hooks.d.ts.map +1 -0
  75. package/dist/offline/react-hooks.js +25 -0
  76. package/dist/offline/react-hooks.js.map +1 -0
  77. package/dist/offline/react.d.ts +0 -4
  78. package/dist/offline/react.d.ts.map +1 -1
  79. package/dist/offline/react.js +2 -24
  80. package/dist/offline/react.js.map +1 -1
  81. package/dist/offline/storage.d.ts.map +1 -1
  82. package/dist/offline/storage.js +8 -5
  83. package/dist/offline/storage.js.map +1 -1
  84. package/dist/registry/index.d.ts +1 -0
  85. package/dist/registry/index.d.ts.map +1 -1
  86. package/dist/registry/index.js +1 -0
  87. package/dist/registry/index.js.map +1 -1
  88. package/dist/registry/lib/primitives/SessionEventCard.d.ts.map +1 -1
  89. package/dist/registry/lib/primitives/SessionEventCard.js +1 -1
  90. package/dist/registry/lib/primitives/SessionEventCard.js.map +1 -1
  91. package/dist/registry/lib/session-context-provider.d.ts +1 -3
  92. package/dist/registry/lib/session-context-provider.d.ts.map +1 -1
  93. package/dist/registry/lib/session-context-provider.js +2 -15
  94. package/dist/registry/lib/session-context-provider.js.map +1 -1
  95. package/dist/registry/lib/session-context.d.ts +5 -0
  96. package/dist/registry/lib/session-context.d.ts.map +1 -0
  97. package/dist/registry/lib/session-context.js +15 -0
  98. package/dist/registry/lib/session-context.js.map +1 -0
  99. package/dist/registry/lib/session-selectors.d.ts.map +1 -1
  100. package/dist/registry/lib/session-selectors.js +3 -1
  101. package/dist/registry/lib/session-selectors.js.map +1 -1
  102. package/dist/ui/branding/app-branding-context.d.ts +9 -0
  103. package/dist/ui/branding/app-branding-context.d.ts.map +1 -0
  104. package/dist/ui/branding/app-branding-context.js +10 -0
  105. package/dist/ui/branding/app-branding-context.js.map +1 -0
  106. package/dist/ui/branding/app-branding-provider.d.ts +0 -6
  107. package/dist/ui/branding/app-branding-provider.d.ts.map +1 -1
  108. package/dist/ui/branding/app-branding-provider.js +1 -8
  109. package/dist/ui/branding/app-branding-provider.js.map +1 -1
  110. package/dist/ui/capture/field-spec-to-zod.d.ts +1 -0
  111. package/dist/ui/capture/field-spec-to-zod.d.ts.map +1 -1
  112. package/dist/ui/capture/field-spec-to-zod.js +19 -0
  113. package/dist/ui/capture/field-spec-to-zod.js.map +1 -1
  114. package/dist/ui/capture/field-spec-validate.d.ts +4 -0
  115. package/dist/ui/capture/field-spec-validate.d.ts.map +1 -0
  116. package/dist/ui/capture/field-spec-validate.js +129 -0
  117. package/dist/ui/capture/field-spec-validate.js.map +1 -0
  118. package/dist/ui/capture/field-spec.d.ts +13 -1
  119. package/dist/ui/capture/field-spec.d.ts.map +1 -1
  120. package/dist/ui/capture/field-spec.js +25 -0
  121. package/dist/ui/capture/field-spec.js.map +1 -1
  122. package/dist/ui/capture/index.d.ts +4 -2
  123. package/dist/ui/capture/index.d.ts.map +1 -1
  124. package/dist/ui/capture/index.js +4 -2
  125. package/dist/ui/capture/index.js.map +1 -1
  126. package/dist/ui/capture/schema-field-input.d.ts.map +1 -1
  127. package/dist/ui/capture/schema-field-input.js +40 -13
  128. package/dist/ui/capture/schema-field-input.js.map +1 -1
  129. package/dist/ui/capture/submit-values.d.ts +6 -0
  130. package/dist/ui/capture/submit-values.d.ts.map +1 -0
  131. package/dist/ui/capture/submit-values.js +28 -0
  132. package/dist/ui/capture/submit-values.js.map +1 -0
  133. package/dist/ui/capture/use-prefill.d.ts.map +1 -1
  134. package/dist/ui/capture/use-prefill.js +3 -1
  135. package/dist/ui/capture/use-prefill.js.map +1 -1
  136. package/dist/ui/capture/use-wizard.d.ts +1 -1
  137. package/dist/ui/capture/use-wizard.d.ts.map +1 -1
  138. package/dist/ui/capture/use-wizard.js +1 -1
  139. package/dist/ui/capture/use-wizard.js.map +1 -1
  140. package/dist/ui/capture/wizard.d.ts.map +1 -1
  141. package/dist/ui/capture/wizard.js.map +1 -1
  142. package/dist/ui/index.d.ts +6 -1
  143. package/dist/ui/index.d.ts.map +1 -1
  144. package/dist/ui/index.js +6 -1
  145. package/dist/ui/index.js.map +1 -1
  146. package/dist/ui/primitives/alert-dialog.js +1 -1
  147. package/dist/ui/primitives/alert-dialog.js.map +1 -1
  148. package/dist/ui/primitives/badge-variants.d.ts +4 -0
  149. package/dist/ui/primitives/badge-variants.d.ts.map +1 -0
  150. package/dist/ui/primitives/badge-variants.js +15 -0
  151. package/dist/ui/primitives/badge-variants.js.map +1 -0
  152. package/dist/ui/primitives/badge.d.ts +3 -5
  153. package/dist/ui/primitives/badge.d.ts.map +1 -1
  154. package/dist/ui/primitives/badge.js +2 -15
  155. package/dist/ui/primitives/badge.js.map +1 -1
  156. package/dist/ui/primitives/button-variants.d.ts +5 -0
  157. package/dist/ui/primitives/button-variants.d.ts.map +1 -0
  158. package/dist/ui/primitives/button-variants.js +24 -0
  159. package/dist/ui/primitives/button-variants.js.map +1 -0
  160. package/dist/ui/primitives/button.d.ts +3 -6
  161. package/dist/ui/primitives/button.d.ts.map +1 -1
  162. package/dist/ui/primitives/button.js +2 -24
  163. package/dist/ui/primitives/button.js.map +1 -1
  164. package/dist/ui/primitives/form-stepper.d.ts +1 -13
  165. package/dist/ui/primitives/form-stepper.d.ts.map +1 -1
  166. package/dist/ui/primitives/form-stepper.js +1 -6
  167. package/dist/ui/primitives/form-stepper.js.map +1 -1
  168. package/dist/ui/primitives/form-stepper.types.d.ts +14 -0
  169. package/dist/ui/primitives/form-stepper.types.d.ts.map +1 -0
  170. package/dist/ui/primitives/form-stepper.types.js +7 -0
  171. package/dist/ui/primitives/form-stepper.types.js.map +1 -0
  172. package/dist/ui/primitives/overflow-tabs.d.ts +5 -0
  173. package/dist/ui/primitives/overflow-tabs.d.ts.map +1 -1
  174. package/dist/ui/primitives/overflow-tabs.js +4 -4
  175. package/dist/ui/primitives/overflow-tabs.js.map +1 -1
  176. package/dist/ui/primitives/preview-device-frame.js +1 -1
  177. package/dist/ui/primitives/preview-device-frame.js.map +1 -1
  178. package/dist/ui/primitives/tag-multi-select.d.ts.map +1 -1
  179. package/dist/ui/primitives/tag-multi-select.js +1 -1
  180. package/dist/ui/primitives/tag-multi-select.js.map +1 -1
  181. package/dist/ui/primitives/url-preview-chrome.d.ts +8 -0
  182. package/dist/ui/primitives/url-preview-chrome.d.ts.map +1 -0
  183. package/dist/ui/primitives/url-preview-chrome.js +40 -0
  184. package/dist/ui/primitives/url-preview-chrome.js.map +1 -0
  185. package/dist/vista/GenericCatalogueSurface.d.ts +10 -0
  186. package/dist/vista/GenericCatalogueSurface.d.ts.map +1 -0
  187. package/dist/vista/GenericCatalogueSurface.js +80 -0
  188. package/dist/vista/GenericCatalogueSurface.js.map +1 -0
  189. package/dist/vista/SurfaceFallbackCard.d.ts +9 -0
  190. package/dist/vista/SurfaceFallbackCard.d.ts.map +1 -0
  191. package/dist/vista/SurfaceFallbackCard.js +44 -0
  192. package/dist/vista/SurfaceFallbackCard.js.map +1 -0
  193. package/dist/vista/VistaPanel.d.ts +21 -0
  194. package/dist/vista/VistaPanel.d.ts.map +1 -0
  195. package/dist/vista/VistaPanel.js +31 -0
  196. package/dist/vista/VistaPanel.js.map +1 -0
  197. package/dist/vista/html/CustomUiFrame.d.ts +20 -0
  198. package/dist/vista/html/CustomUiFrame.d.ts.map +1 -0
  199. package/dist/vista/html/CustomUiFrame.js +69 -0
  200. package/dist/vista/html/CustomUiFrame.js.map +1 -0
  201. package/dist/vista/html/custom-ui-frame-bridge.d.ts +13 -0
  202. package/dist/vista/html/custom-ui-frame-bridge.d.ts.map +1 -0
  203. package/dist/vista/html/custom-ui-frame-bridge.js +30 -0
  204. package/dist/vista/html/custom-ui-frame-bridge.js.map +1 -0
  205. package/dist/vista/html/custom-ui-frame-contract.d.ts +29 -0
  206. package/dist/vista/html/custom-ui-frame-contract.d.ts.map +1 -0
  207. package/dist/vista/html/custom-ui-frame-contract.js +16 -0
  208. package/dist/vista/html/custom-ui-frame-contract.js.map +1 -0
  209. package/dist/vista/html/custom-ui-intents.d.ts +20 -0
  210. package/dist/vista/html/custom-ui-intents.d.ts.map +1 -0
  211. package/dist/vista/html/custom-ui-intents.js +57 -0
  212. package/dist/vista/html/custom-ui-intents.js.map +1 -0
  213. package/dist/vista/html/custom-ui-srcdoc.d.ts +17 -0
  214. package/dist/vista/html/custom-ui-srcdoc.d.ts.map +1 -0
  215. package/dist/vista/html/custom-ui-srcdoc.js +70 -0
  216. package/dist/vista/html/custom-ui-srcdoc.js.map +1 -0
  217. package/dist/vista/html/index.d.ts +6 -0
  218. package/dist/vista/html/index.d.ts.map +1 -0
  219. package/dist/vista/html/index.js +6 -0
  220. package/dist/vista/html/index.js.map +1 -0
  221. package/dist/vista/index.d.ts +22 -0
  222. package/dist/vista/index.d.ts.map +1 -0
  223. package/dist/vista/index.js +22 -0
  224. package/dist/vista/index.js.map +1 -0
  225. package/dist/vista/surface-catalogue.d.ts +5 -0
  226. package/dist/vista/surface-catalogue.d.ts.map +1 -0
  227. package/dist/vista/surface-catalogue.js +30 -0
  228. package/dist/vista/surface-catalogue.js.map +1 -0
  229. package/dist/vista/surface-icons.d.ts +7 -0
  230. package/dist/vista/surface-icons.d.ts.map +1 -0
  231. package/dist/vista/surface-icons.js +26 -0
  232. package/dist/vista/surface-icons.js.map +1 -0
  233. package/dist/vista/surface-registry.d.ts +7 -0
  234. package/dist/vista/surface-registry.d.ts.map +1 -0
  235. package/dist/vista/surface-registry.js +7 -0
  236. package/dist/vista/surface-registry.js.map +1 -0
  237. package/dist/vista/surfaces/ChartSurface.d.ts +4 -0
  238. package/dist/vista/surfaces/ChartSurface.d.ts.map +1 -0
  239. package/dist/vista/surfaces/ChartSurface.js +17 -0
  240. package/dist/vista/surfaces/ChartSurface.js.map +1 -0
  241. package/dist/vista/surfaces/FilesSurface.d.ts +4 -0
  242. package/dist/vista/surfaces/FilesSurface.d.ts.map +1 -0
  243. package/dist/vista/surfaces/FilesSurface.js +77 -0
  244. package/dist/vista/surfaces/FilesSurface.js.map +1 -0
  245. package/dist/vista/surfaces/FormSurface.d.ts +4 -0
  246. package/dist/vista/surfaces/FormSurface.d.ts.map +1 -0
  247. package/dist/vista/surfaces/FormSurface.js +124 -0
  248. package/dist/vista/surfaces/FormSurface.js.map +1 -0
  249. package/dist/vista/surfaces/HtmlSurface.d.ts +4 -0
  250. package/dist/vista/surfaces/HtmlSurface.d.ts.map +1 -0
  251. package/dist/vista/surfaces/HtmlSurface.js +11 -0
  252. package/dist/vista/surfaces/HtmlSurface.js.map +1 -0
  253. package/dist/vista/surfaces/TableSurface.d.ts +4 -0
  254. package/dist/vista/surfaces/TableSurface.d.ts.map +1 -0
  255. package/dist/vista/surfaces/TableSurface.js +42 -0
  256. package/dist/vista/surfaces/TableSurface.js.map +1 -0
  257. package/dist/vista/surfaces/UrlSurface.d.ts +4 -0
  258. package/dist/vista/surfaces/UrlSurface.d.ts.map +1 -0
  259. package/dist/vista/surfaces/UrlSurface.js +7 -0
  260. package/dist/vista/surfaces/UrlSurface.js.map +1 -0
  261. package/dist/vista/surfaces/blob-surfaces.d.ts +6 -0
  262. package/dist/vista/surfaces/blob-surfaces.d.ts.map +1 -0
  263. package/dist/vista/surfaces/blob-surfaces.js +38 -0
  264. package/dist/vista/surfaces/blob-surfaces.js.map +1 -0
  265. package/dist/vista/surfaces/elicitation-transport.d.ts +27 -0
  266. package/dist/vista/surfaces/elicitation-transport.d.ts.map +1 -0
  267. package/dist/vista/surfaces/elicitation-transport.js +193 -0
  268. package/dist/vista/surfaces/elicitation-transport.js.map +1 -0
  269. package/dist/vista/surfaces/file-surface-utils.d.ts +13 -0
  270. package/dist/vista/surfaces/file-surface-utils.d.ts.map +1 -0
  271. package/dist/vista/surfaces/file-surface-utils.js +46 -0
  272. package/dist/vista/surfaces/file-surface-utils.js.map +1 -0
  273. package/dist/vista/surfaces/index.d.ts +12 -0
  274. package/dist/vista/surfaces/index.d.ts.map +1 -0
  275. package/dist/vista/surfaces/index.js +12 -0
  276. package/dist/vista/surfaces/index.js.map +1 -0
  277. package/dist/vista/surfaces/register-surfaces.d.ts +2 -0
  278. package/dist/vista/surfaces/register-surfaces.d.ts.map +1 -0
  279. package/dist/vista/surfaces/register-surfaces.js +80 -0
  280. package/dist/vista/surfaces/register-surfaces.js.map +1 -0
  281. package/dist/vista/surfaces/text-surfaces.d.ts +8 -0
  282. package/dist/vista/surfaces/text-surfaces.d.ts.map +1 -0
  283. package/dist/vista/surfaces/text-surfaces.js +54 -0
  284. package/dist/vista/surfaces/text-surfaces.js.map +1 -0
  285. package/dist/vista/use-vista-tabs.d.ts +30 -0
  286. package/dist/vista/use-vista-tabs.d.ts.map +1 -0
  287. package/dist/vista/use-vista-tabs.js +77 -0
  288. package/dist/vista/use-vista-tabs.js.map +1 -0
  289. package/dist/vista/vista-code-renderer-context.d.ts +9 -0
  290. package/dist/vista/vista-code-renderer-context.d.ts.map +1 -0
  291. package/dist/vista/vista-code-renderer-context.js +6 -0
  292. package/dist/vista/vista-code-renderer-context.js.map +1 -0
  293. package/dist/vista/vista-code-renderer.d.ts +7 -0
  294. package/dist/vista/vista-code-renderer.d.ts.map +1 -0
  295. package/dist/vista/vista-code-renderer.js +6 -0
  296. package/dist/vista/vista-code-renderer.js.map +1 -0
  297. package/dist/vista/vista-file-context.d.ts +8 -0
  298. package/dist/vista/vista-file-context.d.ts.map +1 -0
  299. package/dist/vista/vista-file-context.js +6 -0
  300. package/dist/vista/vista-file-context.js.map +1 -0
  301. package/dist/vista/vista-file-source.d.ts +15 -0
  302. package/dist/vista/vista-file-source.d.ts.map +1 -0
  303. package/dist/vista/vista-file-source.js +66 -0
  304. package/dist/vista/vista-file-source.js.map +1 -0
  305. package/dist/vista/vista-form-context.d.ts +13 -0
  306. package/dist/vista/vista-form-context.d.ts.map +1 -0
  307. package/dist/vista/vista-form-context.js +6 -0
  308. package/dist/vista/vista-form-context.js.map +1 -0
  309. package/dist/vista/vista-form-host.d.ts +7 -0
  310. package/dist/vista/vista-form-host.d.ts.map +1 -0
  311. package/dist/vista/vista-form-host.js +6 -0
  312. package/dist/vista/vista-form-host.js.map +1 -0
  313. package/dist/vista/vista-model.d.ts +12 -0
  314. package/dist/vista/vista-model.d.ts.map +1 -0
  315. package/dist/vista/vista-model.js +72 -0
  316. package/dist/vista/vista-model.js.map +1 -0
  317. package/dist/vista/vista-open-context.d.ts +7 -0
  318. package/dist/vista/vista-open-context.d.ts.map +1 -0
  319. package/dist/vista/vista-open-context.js +6 -0
  320. package/dist/vista/vista-open-context.js.map +1 -0
  321. package/dist/vista/vista-open-state.d.ts +5 -0
  322. package/dist/vista/vista-open-state.d.ts.map +1 -0
  323. package/dist/vista/vista-open-state.js +6 -0
  324. package/dist/vista/vista-open-state.js.map +1 -0
  325. package/dist/vista/vista-payloads.d.ts +106 -0
  326. package/dist/vista/vista-payloads.d.ts.map +1 -0
  327. package/dist/vista/vista-payloads.js +302 -0
  328. package/dist/vista/vista-payloads.js.map +1 -0
  329. package/dist/vista/vista-tabs-manifest.d.ts +17 -0
  330. package/dist/vista/vista-tabs-manifest.d.ts.map +1 -0
  331. package/dist/vista/vista-tabs-manifest.js +60 -0
  332. package/dist/vista/vista-tabs-manifest.js.map +1 -0
  333. package/dist/vista/vista-tools.d.ts +41 -0
  334. package/dist/vista/vista-tools.d.ts.map +1 -0
  335. package/dist/vista/vista-tools.js +113 -0
  336. package/dist/vista/vista-tools.js.map +1 -0
  337. package/package.json +4 -4
  338. package/src/index.ts +5 -0
  339. package/src/lib/biome-host/biome-builders.ts +4 -1
  340. package/src/lib/biome-host/biome-registry.ts +31 -12
  341. package/src/lib/biome-host/biome-scope-hooks.ts +39 -0
  342. package/src/lib/biome-host/biome-scope.tsx +1 -68
  343. package/src/lib/biome-host/biome-scoped-query.ts +4 -1
  344. package/src/lib/biome-host/create-biome-orval-config.ts +2 -2
  345. package/src/lib/biome-host/errors.ts +1 -1
  346. package/src/lib/biome-host/index.ts +1 -1
  347. package/src/lib/biome-host/session-profiles.ts +7 -1
  348. package/src/lib/capabilities/capability-context.ts +25 -0
  349. package/src/lib/capabilities/capability-provider.tsx +5 -34
  350. package/src/lib/capabilities/index.ts +1 -0
  351. package/src/lib/capabilities/use-capability.ts +4 -1
  352. package/src/lib/contribution-registry/contribution-registry.spec.ts +141 -0
  353. package/src/lib/contribution-registry/contribution-registry.ts +202 -0
  354. package/src/lib/contribution-registry/index.ts +9 -0
  355. package/src/lib/contribution-registry/renderable-registry.ts +142 -0
  356. package/src/lib/system-bus/deeplink.ts +1 -1
  357. package/src/lib/system-bus/host-ports.ts +2 -1
  358. package/src/lib/system-bus/intent-registry.ts +1 -2
  359. package/src/offline/index.ts +4 -2
  360. package/src/offline/offline-status-badge.tsx +1 -1
  361. package/src/offline/outbox.test.ts +23 -16
  362. package/src/offline/outbox.ts +1 -1
  363. package/src/offline/react-hooks.ts +37 -0
  364. package/src/offline/react.tsx +1 -40
  365. package/src/offline/storage.ts +11 -6
  366. package/src/registry/index.ts +1 -0
  367. package/src/registry/lib/primitives/SessionEventCard.tsx +4 -2
  368. package/src/registry/lib/session-context-provider.tsx +8 -25
  369. package/src/registry/lib/session-context.ts +21 -0
  370. package/src/registry/lib/session-selectors.ts +3 -1
  371. package/src/ui/branding/app-branding-context.ts +20 -0
  372. package/src/ui/branding/app-branding-provider.tsx +5 -27
  373. package/src/ui/capture/field-spec-to-zod.ts +22 -0
  374. package/src/ui/capture/field-spec-validate.ts +147 -0
  375. package/src/ui/capture/field-spec.ts +62 -0
  376. package/src/ui/capture/index.ts +9 -1
  377. package/src/ui/capture/schema-field-input.tsx +141 -15
  378. package/src/ui/capture/submit-values.test.ts +70 -0
  379. package/src/ui/capture/submit-values.ts +63 -0
  380. package/src/ui/capture/use-prefill.ts +4 -1
  381. package/src/ui/capture/use-wizard.ts +2 -2
  382. package/src/ui/capture/wizard.tsx +2 -1
  383. package/src/ui/index.ts +11 -2
  384. package/src/ui/primitives/alert-dialog.tsx +1 -1
  385. package/src/ui/primitives/badge-variants.ts +21 -0
  386. package/src/ui/primitives/badge.tsx +3 -19
  387. package/src/ui/primitives/button-variants.ts +31 -0
  388. package/src/ui/primitives/button.tsx +3 -28
  389. package/src/ui/primitives/form-stepper.tsx +1 -16
  390. package/src/ui/primitives/form-stepper.types.ts +15 -0
  391. package/src/ui/primitives/overflow-tabs.tsx +24 -4
  392. package/src/ui/primitives/preview-device-frame.tsx +1 -1
  393. package/src/ui/primitives/tag-multi-select.tsx +3 -4
  394. package/src/ui/primitives/url-preview-chrome.tsx +102 -0
  395. package/src/vista/GenericCatalogueSurface.tsx +177 -0
  396. package/src/vista/SurfaceFallbackCard.tsx +109 -0
  397. package/src/vista/VistaPanel.tsx +155 -0
  398. package/src/vista/form-payload.spec.ts +139 -0
  399. package/src/vista/html/CustomUiFrame.spec.tsx +125 -0
  400. package/src/vista/html/CustomUiFrame.tsx +204 -0
  401. package/src/vista/html/custom-ui-frame-bridge.spec.ts +191 -0
  402. package/src/vista/html/custom-ui-frame-bridge.ts +92 -0
  403. package/src/vista/html/custom-ui-frame-contract.ts +88 -0
  404. package/src/vista/html/custom-ui-intents.spec.ts +133 -0
  405. package/src/vista/html/custom-ui-intents.ts +151 -0
  406. package/src/vista/html/custom-ui-srcdoc.spec.ts +151 -0
  407. package/src/vista/html/custom-ui-srcdoc.ts +193 -0
  408. package/src/vista/html/index.ts +13 -0
  409. package/src/vista/index.ts +52 -0
  410. package/src/vista/surface-catalogue.spec.ts +140 -0
  411. package/src/vista/surface-catalogue.ts +84 -0
  412. package/src/vista/surface-icons.ts +57 -0
  413. package/src/vista/surface-registry.ts +56 -0
  414. package/src/vista/surfaces/ChartSurface.tsx +34 -0
  415. package/src/vista/surfaces/FilesSurface.tsx +202 -0
  416. package/src/vista/surfaces/FormSurface.tsx +363 -0
  417. package/src/vista/surfaces/HtmlSurface.tsx +43 -0
  418. package/src/vista/surfaces/TableSurface.tsx +99 -0
  419. package/src/vista/surfaces/UrlSurface.tsx +40 -0
  420. package/src/vista/surfaces/blob-surfaces.tsx +129 -0
  421. package/src/vista/surfaces/elicitation-transport.spec.ts +369 -0
  422. package/src/vista/surfaces/elicitation-transport.ts +353 -0
  423. package/src/vista/surfaces/file-surface-utils.ts +62 -0
  424. package/src/vista/surfaces/index.ts +24 -0
  425. package/src/vista/surfaces/register-surfaces.tsx +137 -0
  426. package/src/vista/surfaces/text-surfaces.tsx +119 -0
  427. package/src/vista/use-vista-tabs.ts +188 -0
  428. package/src/vista/vista-code-renderer-context.ts +16 -0
  429. package/src/vista/vista-code-renderer.tsx +34 -0
  430. package/src/vista/vista-file-context.ts +14 -0
  431. package/src/vista/vista-file-source.tsx +140 -0
  432. package/src/vista/vista-form-context.ts +20 -0
  433. package/src/vista/vista-form-host.tsx +53 -0
  434. package/src/vista/vista-model.ts +130 -0
  435. package/src/vista/vista-open-context.tsx +32 -0
  436. package/src/vista/vista-open-state.ts +11 -0
  437. package/src/vista/vista-payloads.ts +512 -0
  438. package/src/vista/vista-tabs-manifest.ts +123 -0
  439. package/src/vista/vista-tools.ts +220 -0
  440. package/dist/lib/biome-host/response-envelope.d.ts +0 -3
  441. package/dist/lib/biome-host/response-envelope.d.ts.map +0 -1
  442. package/dist/lib/biome-host/response-envelope.js +0 -21
  443. package/dist/lib/biome-host/response-envelope.js.map +0 -1
  444. package/src/lib/biome-host/response-envelope.ts +0 -69
@@ -0,0 +1,512 @@
1
+ /**
2
+ * Payload contracts + narrowing validators for the CLOSED first-party
3
+ * {@link SurfaceKind} set.
4
+ *
5
+ * Every validator is total and NEVER throws: it returns the narrowed payload or
6
+ * `null`, and `null` routes the envelope to `SurfaceFallbackCard` with
7
+ * `ContributionFallbackReason.InvalidPayload`. That is the contract the
8
+ * renderable registry depends on — a malformed payload degrades visibly, it is
9
+ * never coerced into a half-rendered surface.
10
+ *
11
+ * ── File-backed vs. inline ──────────────────────────────────────────────────
12
+ * Text/binary surfaces accept EITHER an inline `content`/`url` OR a workspace
13
+ * `path` resolved through the host-supplied {@link VistaFileSource}. Exactly one
14
+ * must be present — supplying both is a contradiction and is rejected, not
15
+ * silently preferred one way.
16
+ */
17
+ import { validateCaptureFields } from '../ui/capture/field-spec-validate';
18
+
19
+ import type { CaptureFieldSpec } from '../ui/capture/field-spec';
20
+ import type { PreviewDevice } from '../ui/primitives/preview-device-frame';
21
+
22
+ /** A record with unknown values — the shape every validator starts from. */
23
+ type UnknownRecord = Readonly<Record<string, unknown>>;
24
+
25
+ function asRecord(value: unknown): UnknownRecord | null {
26
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
27
+ ? (value as UnknownRecord)
28
+ : null;
29
+ }
30
+
31
+ function optionalString(value: unknown): string | undefined | null {
32
+ if (value === undefined) return undefined;
33
+ return typeof value === 'string' ? value : null;
34
+ }
35
+
36
+ /**
37
+ * Narrow a "exactly one of `a` / `b`" pair of optional strings. Returns the
38
+ * pair when exactly one is a string, else `null`.
39
+ */
40
+ function exactlyOne(
41
+ a: unknown,
42
+ b: unknown,
43
+ ): Readonly<{ a?: string; b?: string }> | null {
44
+ const left = typeof a === 'string' ? a : undefined;
45
+ const right = typeof b === 'string' ? b : undefined;
46
+ if ((left === undefined) === (right === undefined)) return null;
47
+ return left === undefined ? { b: right } : { a: left };
48
+ }
49
+
50
+ /** Where a text-backed surface reads its body from. */
51
+ export interface VistaTextPayload {
52
+ /** Inline body. Mutually exclusive with {@link path}. */
53
+ readonly content?: string;
54
+ /** Workspace-relative path resolved through the host `VistaFileSource`. */
55
+ readonly path?: string;
56
+ /** Optional language hint for a `code` surface (presentation only). */
57
+ readonly language?: string;
58
+ }
59
+
60
+ export function validateTextPayload(raw: unknown): VistaTextPayload | null {
61
+ const record = asRecord(raw);
62
+ if (record === null) return null;
63
+ const source = exactlyOne(record.content, record.path);
64
+ if (source === null) return null;
65
+ const language = optionalString(record.language);
66
+ if (language === null) return null;
67
+ const base: VistaTextPayload =
68
+ source.a === undefined ? { path: source.b } : { content: source.a };
69
+ return language === undefined ? base : { ...base, language };
70
+ }
71
+
72
+ /** Where a binary surface (image / media / pdf) reads its bytes from. */
73
+ export interface VistaBlobPayload {
74
+ /** Already-resolved fetchable URL (`https:`, `blob:`, `data:`). */
75
+ readonly url?: string;
76
+ /** Workspace-relative path resolved through the host `VistaFileSource`. */
77
+ readonly path?: string;
78
+ /** Alt text / accessible label. */
79
+ readonly alt?: string;
80
+ /** MIME type. Required by `media` (audio vs. video); optional elsewhere. */
81
+ readonly contentType?: string;
82
+ }
83
+
84
+ export function validateBlobPayload(raw: unknown): VistaBlobPayload | null {
85
+ const record = asRecord(raw);
86
+ if (record === null) return null;
87
+ const source = exactlyOne(record.url, record.path);
88
+ if (source === null) return null;
89
+ const alt = optionalString(record.alt);
90
+ if (alt === null) return null;
91
+ const contentType = optionalString(record.contentType);
92
+ if (contentType === null) return null;
93
+ const payload: {
94
+ url?: string;
95
+ path?: string;
96
+ alt?: string;
97
+ contentType?: string;
98
+ } = source.a === undefined ? { path: source.b } : { url: source.a };
99
+ if (alt !== undefined) payload.alt = alt;
100
+ if (contentType !== undefined) payload.contentType = contentType;
101
+ return payload;
102
+ }
103
+
104
+ /** `SurfaceKind.Url` — a live external URL inside mock browser chrome. */
105
+ export interface VistaUrlPayload {
106
+ readonly url: string;
107
+ /** Device bezel to render the frame in. Defaults to `desktop`. */
108
+ readonly device?: PreviewDevice;
109
+ /** Bump to force the frame to reload without changing the URL. */
110
+ readonly reloadNonce?: number;
111
+ }
112
+
113
+ const PREVIEW_DEVICES: readonly PreviewDevice[] = [
114
+ 'desktop',
115
+ 'tablet',
116
+ 'mobile',
117
+ 'presentation',
118
+ 'a4',
119
+ ];
120
+
121
+ export function validateUrlPayload(raw: unknown): VistaUrlPayload | null {
122
+ const record = asRecord(raw);
123
+ if (record === null) return null;
124
+ if (typeof record.url !== 'string' || record.url.length === 0) return null;
125
+ const payload: { url: string; device?: PreviewDevice; reloadNonce?: number } =
126
+ { url: record.url };
127
+ if (record.device !== undefined) {
128
+ if (!PREVIEW_DEVICES.includes(record.device as PreviewDevice)) return null;
129
+ payload.device = record.device as PreviewDevice;
130
+ }
131
+ if (record.reloadNonce !== undefined) {
132
+ if (typeof record.reloadNonce !== 'number') return null;
133
+ payload.reloadNonce = record.reloadNonce;
134
+ }
135
+ return payload;
136
+ }
137
+
138
+ /**
139
+ * `SurfaceKind.Html` — UNTRUSTED HTML. Two mutually-exclusive forms:
140
+ *
141
+ * • `document` — an agent-authored HTML document. Rendered with
142
+ * `script-src 'none'`: markup and styles render, script NEVER runs.
143
+ * • `compiledOutput` + `integrity` — a server-compiled, SRI-pinned custom-UI
144
+ * chunk (App Forge Wave-12). Rendered with `script-src '<sha384-…>'`: ONLY
145
+ * those exact bytes execute.
146
+ *
147
+ * Both run in an opaque-origin, `allow-scripts`-only sandbox frame.
148
+ */
149
+ export type VistaHtmlPayload =
150
+ | { readonly document: string }
151
+ | {
152
+ readonly compiledOutput: string;
153
+ readonly integrity: string;
154
+ readonly styleCss?: string;
155
+ };
156
+
157
+ /** `sha384-<base64>` — the only SRI token form the frame CSP accepts. */
158
+ const SRI_TOKEN = /^sha384-[A-Za-z0-9+/]+={0,2}$/;
159
+
160
+ export function validateHtmlPayload(raw: unknown): VistaHtmlPayload | null {
161
+ const record = asRecord(raw);
162
+ if (record === null) return null;
163
+ const hasDocument = typeof record.document === 'string';
164
+ const hasChunk = typeof record.compiledOutput === 'string';
165
+ if (hasDocument === hasChunk) return null;
166
+ if (hasDocument) return { document: record.document as string };
167
+ // A compiled chunk WITHOUT a well-formed integrity token is rejected: the
168
+ // CSP hash source is what makes executing it safe, so there is no
169
+ // "run it unpinned" path.
170
+ if (typeof record.integrity !== 'string' || !SRI_TOKEN.test(record.integrity))
171
+ return null;
172
+ const styleCss = optionalString(record.styleCss);
173
+ if (styleCss === null) return null;
174
+ const payload = {
175
+ compiledOutput: record.compiledOutput as string,
176
+ integrity: record.integrity,
177
+ };
178
+ return styleCss === undefined ? payload : { ...payload, styleCss };
179
+ }
180
+
181
+ /** `SurfaceKind.Json` — an inspectable JSON tree. */
182
+ export interface VistaJsonPayload {
183
+ readonly data: unknown;
184
+ }
185
+
186
+ export function validateJsonPayload(raw: unknown): VistaJsonPayload | null {
187
+ const record = asRecord(raw);
188
+ if (record === null) return null;
189
+ if (!('data' in record)) return null;
190
+ return { data: record.data };
191
+ }
192
+
193
+ /** `SurfaceKind.Table` — generic columns + rows. */
194
+ export interface VistaTablePayload {
195
+ readonly columns: readonly string[];
196
+ readonly rows: readonly (readonly unknown[])[];
197
+ }
198
+
199
+ export function validateTablePayload(raw: unknown): VistaTablePayload | null {
200
+ const record = asRecord(raw);
201
+ if (record === null) return null;
202
+ if (!Array.isArray(record.columns) || !Array.isArray(record.rows))
203
+ return null;
204
+ if (!record.columns.every((c) => typeof c === 'string')) return null;
205
+ if (!record.rows.every((r) => Array.isArray(r))) return null;
206
+ return {
207
+ columns: record.columns,
208
+ rows: record.rows as readonly (readonly unknown[])[],
209
+ };
210
+ }
211
+
212
+ /** Chart shapes the `chart` surface draws. Closed set. */
213
+ export enum VistaChartKind {
214
+ Bar = 'bar',
215
+ Line = 'line',
216
+ Donut = 'donut',
217
+ }
218
+
219
+ /** One labelled point. Value-identical to the kernel `ChartDatum`. */
220
+ export interface VistaChartDatum {
221
+ readonly label: string;
222
+ readonly value: number;
223
+ }
224
+
225
+ /** One named series. */
226
+ export interface VistaChartSeries {
227
+ readonly name: string;
228
+ readonly points: readonly VistaChartDatum[];
229
+ }
230
+
231
+ /**
232
+ * `SurfaceKind.Chart`. At least one series is REQUIRED — `bar`/`donut` render
233
+ * the first one, so an empty `series` would have no defined rendering.
234
+ */
235
+ export interface VistaChartPayload {
236
+ readonly kind: VistaChartKind;
237
+ readonly title: string;
238
+ readonly series: readonly [VistaChartSeries, ...VistaChartSeries[]];
239
+ }
240
+
241
+ const CHART_KINDS: readonly string[] = Object.values(VistaChartKind);
242
+
243
+ export function validateChartPayload(raw: unknown): VistaChartPayload | null {
244
+ const record = asRecord(raw);
245
+ if (record === null) return null;
246
+ if (typeof record.kind !== 'string' || !CHART_KINDS.includes(record.kind))
247
+ return null;
248
+ if (typeof record.title !== 'string' || record.title.length === 0)
249
+ return null;
250
+ if (!Array.isArray(record.series) || record.series.length === 0) return null;
251
+ const series: VistaChartSeries[] = [];
252
+ for (const entry of record.series) {
253
+ const row = asRecord(entry);
254
+ if (row === null || typeof row.name !== 'string') return null;
255
+ if (!Array.isArray(row.points)) return null;
256
+ const points: VistaChartDatum[] = [];
257
+ for (const point of row.points) {
258
+ const p = asRecord(point);
259
+ if (p === null || typeof p.label !== 'string') return null;
260
+ if (typeof p.value !== 'number') return null;
261
+ points.push({ label: p.label, value: p.value });
262
+ }
263
+ series.push({ name: row.name, points });
264
+ }
265
+ return {
266
+ kind: record.kind as VistaChartKind,
267
+ title: record.title,
268
+ series: series as [VistaChartSeries, ...VistaChartSeries[]],
269
+ };
270
+ }
271
+
272
+ /** `SurfaceKind.Diff` — a unified diff, inline or file-backed. */
273
+ export type VistaDiffPayload = VistaTextPayload;
274
+ export const validateDiffPayload = validateTextPayload;
275
+
276
+ /** One row in the {@link SurfaceKind.Files} browser. */
277
+ export interface VistaFileEntry {
278
+ /** Workspace-relative path (also the row key). */
279
+ readonly path: string;
280
+ /** Lines added (present only for changed files). */
281
+ readonly add?: number;
282
+ /** Lines deleted (present only for changed files). */
283
+ readonly del?: number;
284
+ }
285
+
286
+ /** `SurfaceKind.Files` — a file tree over a workspace / artifact set. */
287
+ export interface VistaFilesPayload {
288
+ readonly files: readonly VistaFileEntry[];
289
+ }
290
+
291
+ export function validateFilesPayload(raw: unknown): VistaFilesPayload | null {
292
+ const record = asRecord(raw);
293
+ if (record === null) return null;
294
+ if (!Array.isArray(record.files)) return null;
295
+ const files: VistaFileEntry[] = [];
296
+ for (const entry of record.files) {
297
+ const row = asRecord(entry);
298
+ if (row === null || typeof row.path !== 'string') return null;
299
+ const file: { path: string; add?: number; del?: number } = {
300
+ path: row.path,
301
+ };
302
+ if (row.add !== undefined) {
303
+ if (typeof row.add !== 'number') return null;
304
+ file.add = row.add;
305
+ }
306
+ if (row.del !== undefined) {
307
+ if (typeof row.del !== 'number') return null;
308
+ file.del = row.del;
309
+ }
310
+ files.push(file);
311
+ }
312
+ return { files };
313
+ }
314
+
315
+ /**
316
+ * `SurfaceKind.BiomeRoute` — a biome's REAL React route, addressed by the
317
+ * existing `xema://biome/<biomeId>/<route>` deeplink. Validation here is
318
+ * structural only; the HOST parses the deeplink and enforces route access.
319
+ */
320
+ export interface VistaBiomeRoutePayload {
321
+ readonly deeplink: string;
322
+ }
323
+
324
+ export function validateBiomeRoutePayload(
325
+ raw: unknown,
326
+ ): VistaBiomeRoutePayload | null {
327
+ const record = asRecord(raw);
328
+ if (record === null) return null;
329
+ return typeof record.deeplink === 'string' && record.deeplink.length > 0
330
+ ? { deeplink: record.deeplink }
331
+ : null;
332
+ }
333
+
334
+ /** `SurfaceKind.Object` — a `xema://<scope>/<kind>/<slug>` entity. */
335
+ export interface VistaObjectPayload {
336
+ readonly ref: string;
337
+ }
338
+
339
+ export function validateObjectPayload(raw: unknown): VistaObjectPayload | null {
340
+ const record = asRecord(raw);
341
+ if (record === null) return null;
342
+ return typeof record.ref === 'string' && record.ref.length > 0
343
+ ? { ref: record.ref }
344
+ : null;
345
+ }
346
+
347
+ /** `SurfaceKind.Graph` — the capability graph, optionally anchored. */
348
+ export interface VistaGraphPayload {
349
+ /** Anchor the view on a resource/capability ref. Absent = whole snapshot. */
350
+ readonly anchorRef?: string;
351
+ /** Traversal depth from the anchor. */
352
+ readonly depth?: number;
353
+ }
354
+
355
+ export function validateGraphPayload(raw: unknown): VistaGraphPayload | null {
356
+ const record = asRecord(raw);
357
+ if (record === null) return null;
358
+ const anchorRef = optionalString(record.anchorRef);
359
+ if (anchorRef === null) return null;
360
+ if (record.depth !== undefined && typeof record.depth !== 'number')
361
+ return null;
362
+ const payload: { anchorRef?: string; depth?: number } = {};
363
+ if (anchorRef !== undefined) payload.anchorRef = anchorRef;
364
+ if (record.depth !== undefined) payload.depth = record.depth;
365
+ return payload;
366
+ }
367
+
368
+ /** `SurfaceKind.Web` — a first-party in-app route rendered inside the tab. */
369
+ export interface VistaWebPayload {
370
+ /** Host-relative path (leading `/`). */
371
+ readonly href: string;
372
+ }
373
+
374
+ export function validateWebPayload(raw: unknown): VistaWebPayload | null {
375
+ const record = asRecord(raw);
376
+ if (record === null) return null;
377
+ return typeof record.href === 'string' && record.href.startsWith('/')
378
+ ? { href: record.href }
379
+ : null;
380
+ }
381
+
382
+ /**
383
+ * The consent / install handoff of a {@link VistaFormPayload}.
384
+ *
385
+ * Present when the connector's app auth is `oauth2` or `app_install`: there is
386
+ * no field form to fill, only a link the user follows in another window. It is
387
+ * fully generic — the owning service supplies a path under the host-configured
388
+ * trusted service origin, so no provider is special-cased in the renderer and
389
+ * an agent-controlled payload never selects a network authority.
390
+ */
391
+ export interface VistaFormLaunch {
392
+ /** Root-relative consent / install path on the trusted elicitation service. */
393
+ readonly path: string;
394
+ /** Button copy, e.g. "Install Acme" / "Continue to Acme". */
395
+ readonly label: string;
396
+ /** Optional explanation rendered above the button. */
397
+ readonly hint?: string;
398
+ }
399
+
400
+ /**
401
+ * `SurfaceKind.Form` — the SECURE ELICITATION surface.
402
+ *
403
+ * The agent opens it to walk a user through providing a credential it must
404
+ * never see. Two mutually-exclusive modes, chosen by the presence of
405
+ * {@link launch}:
406
+ *
407
+ * • FIELD mode — render `fields`, POST them through the host's trusted
408
+ * elicitation-service base URL with the user's own JWT;
409
+ * • LAUNCH mode — render the consent/install link, then confirm completion
410
+ * through that same trusted service.
411
+ *
412
+ * Both settle into the same `{ submitted, ref }` shape, so the agent's view of
413
+ * the world does not depend on which mode ran.
414
+ */
415
+ export interface VistaFormPayload {
416
+ /** Opaque, non-secret elicitation reference. The agent polls this. */
417
+ readonly ref: string;
418
+ /** Why the credential is being asked for — shown to the user verbatim. */
419
+ readonly purpose: string;
420
+ /** The onboarding form's fields. MAY be empty — the service is the authority. */
421
+ readonly fields: readonly CaptureFieldSpec[];
422
+ /** Optional heading override (defaults to the tab title). */
423
+ readonly heading?: string;
424
+ /** Submit-button copy for field mode. */
425
+ readonly submitLabel?: string;
426
+ /** Present ⇒ LAUNCH mode (oauth2 / app_install). */
427
+ readonly launch?: VistaFormLaunch;
428
+ }
429
+
430
+ const VISTA_FORM_REF_PATTERN = /^[A-Za-z0-9_-]{1,256}$/;
431
+
432
+ /** Whether a value is one opaque base64url elicitation path segment. */
433
+ export function isValidVistaFormRef(value: unknown): value is string {
434
+ return typeof value === 'string' && VISTA_FORM_REF_PATTERN.test(value);
435
+ }
436
+
437
+ export function validateFormPayload(raw: unknown): VistaFormPayload | null {
438
+ const record = asRecord(raw);
439
+ if (record === null) return null;
440
+ // The service generates base64url refs. Keeping the accepted alphabet closed
441
+ // makes the ref safe as exactly one URL path segment; dot segments, slashes,
442
+ // percent escapes and Unicode lookalikes are all rejected.
443
+ if (!isValidVistaFormRef(record.ref)) {
444
+ return null;
445
+ }
446
+ if (typeof record.purpose !== 'string') return null;
447
+ // Deliberately reject the old contract rather than silently ignoring its
448
+ // payload-selected network targets.
449
+ if ('submitUrl' in record || 'statusUrl' in record) return null;
450
+
451
+ const fields = validateCaptureFields(record.fields);
452
+ if (fields === null) return null;
453
+
454
+ const heading = optionalString(record.heading);
455
+ if (heading === null) return null;
456
+ const submitLabel = optionalString(record.submitLabel);
457
+ if (submitLabel === null) return null;
458
+
459
+ let launch: VistaFormLaunch | undefined;
460
+ if (record.launch !== undefined) {
461
+ const raw_ = asRecord(record.launch);
462
+ if (raw_ === null) return null;
463
+ if ('url' in raw_) return null;
464
+ if (
465
+ typeof raw_.path !== 'string' ||
466
+ !raw_.path.startsWith('/') ||
467
+ raw_.path.startsWith('//') ||
468
+ raw_.path.includes('\\')
469
+ ) {
470
+ return null;
471
+ }
472
+ if (typeof raw_.label !== 'string' || raw_.label.length === 0) return null;
473
+ const hint = optionalString(raw_.hint);
474
+ if (hint === null) return null;
475
+ launch =
476
+ hint === undefined
477
+ ? { path: raw_.path, label: raw_.label }
478
+ : { path: raw_.path, label: raw_.label, hint };
479
+ }
480
+
481
+ const payload: {
482
+ ref: string;
483
+ purpose: string;
484
+ fields: readonly CaptureFieldSpec[];
485
+ heading?: string;
486
+ submitLabel?: string;
487
+ launch?: VistaFormLaunch;
488
+ } = { ref: record.ref, purpose: record.purpose, fields };
489
+ if (heading !== undefined) payload.heading = heading;
490
+ if (submitLabel !== undefined) payload.submitLabel = submitLabel;
491
+ if (launch !== undefined) payload.launch = launch;
492
+ return payload;
493
+ }
494
+
495
+ /** `SurfaceKind.App` — a runtime App-Platform app rendered in its own frame. */
496
+ export interface VistaAppPayload {
497
+ readonly appId: string;
498
+ /** In-app route, defaults to the app's entry route. */
499
+ readonly path?: string;
500
+ }
501
+
502
+ export function validateAppPayload(raw: unknown): VistaAppPayload | null {
503
+ const record = asRecord(raw);
504
+ if (record === null) return null;
505
+ if (typeof record.appId !== 'string' || record.appId.length === 0)
506
+ return null;
507
+ const path = optionalString(record.path);
508
+ if (path === null) return null;
509
+ return path === undefined
510
+ ? { appId: record.appId }
511
+ : { appId: record.appId, path };
512
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * `.tabs.json` — the agent-authored tab manifest for a file-backed Vista panel.
3
+ *
4
+ * Lifted VERBATIM (guards included) out of the 4970-line Design-System-Builder
5
+ * page, generalised over the artifact prefix, and re-keyed onto the kernel
6
+ * {@link SurfaceKind} (Canopy §8.5). It is the ONE parser for this format; the
7
+ * page no longer carries its own.
8
+ *
9
+ * ── The guards (all preserved, all fail-closed) ─────────────────────────────
10
+ * 1. `version` MUST be exactly `1`.
11
+ * 2. `tabs` MUST be an array.
12
+ * 3. Every entry's `path` MUST be a string INSIDE the caller's artifact
13
+ * prefix — an agent cannot point a tab at an arbitrary workspace file.
14
+ * 4. No `..` anywhere in a path — no traversal out of the prefix.
15
+ * 5. A declared `kind` MUST be a member of {@link DECLARABLE_SURFACE_KINDS}.
16
+ * {@link SurfaceKind.Files} is UI-owned (the pinned browser tab) and can
17
+ * NEVER be declared by an agent.
18
+ * 6. ANY violation rejects the WHOLE manifest (returns `null`) — the caller
19
+ * falls back to auto-discovery. A malformed file behaves exactly as an
20
+ * absent one; there is no partial acceptance and no silent coercion.
21
+ *
22
+ * Kind vocabulary note: the legacy `plain` literal is GONE. Plain text is
23
+ * {@link SurfaceKind.Code} (a mono pane) — one kind, one renderer, no alias.
24
+ */
25
+ import { SurfaceKind } from '@xemahq/kernel-contracts/surface';
26
+
27
+ import { surfaceKindForPath } from './vista-model';
28
+
29
+ /**
30
+ * The kinds an agent may declare in `.tabs.json`. Every one is file-backed.
31
+ * `files` is deliberately absent (UI-owned); so are the host-coupled kinds
32
+ * (`web`, `biome-route`, `object`, `graph`, `app`, `form`), which are not
33
+ * addressable by a workspace path and are opened through `vista_open` instead.
34
+ */
35
+ export const DECLARABLE_SURFACE_KINDS: readonly SurfaceKind[] = [
36
+ SurfaceKind.Html,
37
+ SurfaceKind.Markdown,
38
+ SurfaceKind.Code,
39
+ SurfaceKind.Json,
40
+ SurfaceKind.Diff,
41
+ SurfaceKind.Pdf,
42
+ SurfaceKind.Image,
43
+ SurfaceKind.Media,
44
+ ];
45
+
46
+ /** One declared tab. */
47
+ export interface VistaTabSpec {
48
+ readonly path: string;
49
+ readonly kind: SurfaceKind;
50
+ readonly label?: string;
51
+ }
52
+
53
+ /** The parsed manifest. */
54
+ export interface VistaTabsManifest {
55
+ readonly version: 1;
56
+ readonly tabs: readonly VistaTabSpec[];
57
+ /** Path of the tab the agent wants selected on open. */
58
+ readonly selectedPath?: string;
59
+ }
60
+
61
+ /** Options for {@link parseVistaTabsManifest}. */
62
+ export interface VistaTabsManifestOptions {
63
+ /**
64
+ * Prefix every declared path MUST start with (e.g. `'deliverables/'`). The
65
+ * containment guard — an agent can only curate tabs over its own artifacts.
66
+ */
67
+ readonly pathPrefix: string;
68
+ }
69
+
70
+ function parseEntry(
71
+ entry: unknown,
72
+ pathPrefix: string,
73
+ ): VistaTabSpec | null {
74
+ if (!entry || typeof entry !== 'object') return null;
75
+ const record = entry as Record<string, unknown>;
76
+ if (typeof record.path !== 'string') return null;
77
+ // Containment: inside the artifact prefix, and no traversal out of it.
78
+ if (!record.path.startsWith(pathPrefix)) return null;
79
+ if (record.path.includes('..')) return null;
80
+ const kind =
81
+ typeof record.kind === 'string'
82
+ ? (record.kind as SurfaceKind)
83
+ : surfaceKindForPath(record.path);
84
+ // `files` is UI-owned (the pinned file browser) and must never be declared by
85
+ // the agent — an out-of-set kind rejects the whole manifest.
86
+ if (!DECLARABLE_SURFACE_KINDS.includes(kind)) return null;
87
+ const label = typeof record.label === 'string' ? record.label : undefined;
88
+ return label === undefined
89
+ ? { path: record.path, kind }
90
+ : { path: record.path, kind, label };
91
+ }
92
+
93
+ /**
94
+ * Parse a `.tabs.json` body. Returns `null` on ANY shape violation — the caller
95
+ * falls back to auto-discovery. No silent coercion: a malformed file is as if
96
+ * it were absent (the user sees the default view instead of a broken state).
97
+ */
98
+ export function parseVistaTabsManifest(
99
+ raw: string,
100
+ { pathPrefix }: VistaTabsManifestOptions,
101
+ ): VistaTabsManifest | null {
102
+ let parsed: unknown;
103
+ try {
104
+ parsed = JSON.parse(raw) as unknown;
105
+ } catch {
106
+ return null;
107
+ }
108
+ if (!parsed || typeof parsed !== 'object') return null;
109
+ const record = parsed as Record<string, unknown>;
110
+ if (record.version !== 1) return null;
111
+ if (!Array.isArray(record.tabs)) return null;
112
+ const tabs: VistaTabSpec[] = [];
113
+ for (const entry of record.tabs) {
114
+ const tab = parseEntry(entry, pathPrefix);
115
+ if (tab === null) return null;
116
+ tabs.push(tab);
117
+ }
118
+ const selectedPath =
119
+ typeof record.selectedPath === 'string' ? record.selectedPath : undefined;
120
+ return selectedPath === undefined
121
+ ? { version: 1, tabs }
122
+ : { version: 1, tabs, selectedPath };
123
+ }