@xemahq/ui-kernel 0.11.1 → 0.12.0

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 (257) hide show
  1. package/dist/errors/http-error-status.d.ts +17 -0
  2. package/dist/errors/http-error-status.d.ts.map +1 -0
  3. package/dist/errors/http-error-status.js +59 -0
  4. package/dist/errors/http-error-status.js.map +1 -0
  5. package/dist/errors/index.d.ts +2 -0
  6. package/dist/errors/index.d.ts.map +1 -0
  7. package/dist/errors/index.js +2 -0
  8. package/dist/errors/index.js.map +1 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/biome-host/errors.d.ts.map +1 -1
  14. package/dist/lib/biome-host/errors.js +1 -19
  15. package/dist/lib/biome-host/errors.js.map +1 -1
  16. package/dist/offline/index.d.ts.map +1 -1
  17. package/dist/offline/index.js.map +1 -1
  18. package/dist/offline/online-controller.d.ts.map +1 -1
  19. package/dist/offline/online-controller.js +6 -1
  20. package/dist/offline/online-controller.js.map +1 -1
  21. package/dist/offline/outbox.d.ts.map +1 -1
  22. package/dist/offline/outbox.js +2 -24
  23. package/dist/offline/outbox.js.map +1 -1
  24. package/package.json +1 -2
  25. package/src/index.ts +0 -17
  26. package/src/lib/biome-host/agent-validation.ts +0 -239
  27. package/src/lib/biome-host/biome-builders.ts +0 -112
  28. package/src/lib/biome-host/biome-mode.ts +0 -6
  29. package/src/lib/biome-host/biome-navigation.ts +0 -37
  30. package/src/lib/biome-host/biome-registry.ts +0 -299
  31. package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
  32. package/src/lib/biome-host/biome-scope.tsx +0 -52
  33. package/src/lib/biome-host/biome-scoped-query.ts +0 -134
  34. package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
  35. package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
  36. package/src/lib/biome-host/define-web-biome.ts +0 -222
  37. package/src/lib/biome-host/errors.ts +0 -220
  38. package/src/lib/biome-host/frontend-biome.ts +0 -256
  39. package/src/lib/biome-host/host-bridge.ts +0 -281
  40. package/src/lib/biome-host/host-sources.ts +0 -54
  41. package/src/lib/biome-host/i18n-hooks.ts +0 -51
  42. package/src/lib/biome-host/i18n-port.test.ts +0 -50
  43. package/src/lib/biome-host/i18n-port.ts +0 -96
  44. package/src/lib/biome-host/index.ts +0 -35
  45. package/src/lib/biome-host/realtime-hooks.ts +0 -75
  46. package/src/lib/biome-host/realtime-port.ts +0 -115
  47. package/src/lib/biome-host/session-contributions.ts +0 -296
  48. package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
  49. package/src/lib/biome-host/use-page-state.ts +0 -248
  50. package/src/lib/capabilities/capability-context.ts +0 -25
  51. package/src/lib/capabilities/capability-provider.tsx +0 -73
  52. package/src/lib/capabilities/index.ts +0 -17
  53. package/src/lib/capabilities/types.ts +0 -69
  54. package/src/lib/capabilities/use-capability.ts +0 -79
  55. package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
  56. package/src/lib/contribution-registry/contribution-registry.ts +0 -204
  57. package/src/lib/contribution-registry/index.ts +0 -9
  58. package/src/lib/contribution-registry/renderable-registry.ts +0 -142
  59. package/src/lib/system-bus/capability-invoke.ts +0 -92
  60. package/src/lib/system-bus/deeplink.ts +0 -210
  61. package/src/lib/system-bus/enums.ts +0 -86
  62. package/src/lib/system-bus/host-ports.ts +0 -93
  63. package/src/lib/system-bus/index.ts +0 -16
  64. package/src/lib/system-bus/intent-registry.ts +0 -109
  65. package/src/lib/system-bus/intents.ts +0 -113
  66. package/src/lib/system-bus/palette.ts +0 -78
  67. package/src/lib/system-bus/system-bus-builder.ts +0 -159
  68. package/src/lib/system-bus/system-bus.ts +0 -37
  69. package/src/lib/system-bus/windows.ts +0 -51
  70. package/src/offline/id.ts +0 -16
  71. package/src/offline/index.ts +0 -54
  72. package/src/offline/mutation.ts +0 -75
  73. package/src/offline/offline-status-badge.tsx +0 -51
  74. package/src/offline/online-controller.ts +0 -105
  75. package/src/offline/outbox.test.ts +0 -172
  76. package/src/offline/outbox.ts +0 -348
  77. package/src/offline/react-hooks.ts +0 -40
  78. package/src/offline/react.tsx +0 -32
  79. package/src/offline/storage.ts +0 -112
  80. package/src/offline/types.ts +0 -77
  81. package/src/org-db/components/DbResultTable.tsx +0 -176
  82. package/src/org-db/index.ts +0 -1
  83. package/src/pdf/index.ts +0 -11
  84. package/src/registry/index.ts +0 -9
  85. package/src/registry/lib/agent-validation-host.ts +0 -36
  86. package/src/registry/lib/biome-slot.tsx +0 -50
  87. package/src/registry/lib/biomes-enabled-context.ts +0 -20
  88. package/src/registry/lib/extension-points.ts +0 -134
  89. package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
  90. package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
  91. package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
  92. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
  93. package/src/registry/lib/primitives/index.ts +0 -18
  94. package/src/registry/lib/session-context-builder.ts +0 -84
  95. package/src/registry/lib/session-context-provider.tsx +0 -33
  96. package/src/registry/lib/session-context.ts +0 -21
  97. package/src/registry/lib/session-selectors.ts +0 -272
  98. package/src/session/comments/CommentRail.tsx +0 -164
  99. package/src/session/index.ts +0 -3
  100. package/src/session/lib/cn.ts +0 -11
  101. package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
  102. package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
  103. package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
  104. package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
  105. package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
  106. package/src/session-kit/approvals/Obligation.tsx +0 -111
  107. package/src/session-kit/approvals/ScopedBody.tsx +0 -392
  108. package/src/session-kit/approvals/approval-icons.ts +0 -31
  109. package/src/session-kit/approvals/approval-model.ts +0 -204
  110. package/src/session-kit/approvals/index.ts +0 -22
  111. package/src/session-kit/approvals/obligation-display.ts +0 -100
  112. package/src/session-kit/approvals/risk-accent.ts +0 -47
  113. package/src/session-kit/approvals/scope-icons.ts +0 -19
  114. package/src/session-kit/combobox/Combobox.tsx +0 -358
  115. package/src/session-kit/combobox/use-click-outside.ts +0 -21
  116. package/src/session-kit/display/ContextHeader.tsx +0 -148
  117. package/src/session-kit/display/FileDiffCard.tsx +0 -140
  118. package/src/session-kit/display/MD.tsx +0 -162
  119. package/src/session-kit/display/MessageTurn.tsx +0 -157
  120. package/src/session-kit/display/ThinkingPanel.tsx +0 -81
  121. package/src/session-kit/display/TodoChecklist.tsx +0 -120
  122. package/src/session-kit/display/TokenMeter.tsx +0 -89
  123. package/src/session-kit/display/ToolStrip.tsx +0 -278
  124. package/src/session-kit/display/TypingDots.tsx +0 -24
  125. package/src/session-kit/index.ts +0 -44
  126. package/src/session-kit/lib/enums.ts +0 -66
  127. package/src/session-kit/lib/portal-accent.ts +0 -30
  128. package/src/session-kit/lib/status-dot.ts +0 -68
  129. package/src/session-kit/primitives/Avatar.tsx +0 -44
  130. package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
  131. package/src/session-kit/primitives/RiskPill.tsx +0 -95
  132. package/src/session-kit/primitives/ScopeDot.tsx +0 -47
  133. package/src/session-kit/primitives/Segmented.tsx +0 -71
  134. package/src/ui/branding/app-branding-context.ts +0 -20
  135. package/src/ui/branding/app-branding-provider.tsx +0 -123
  136. package/src/ui/branding/sanitize.ts +0 -89
  137. package/src/ui/breakpoints.ts +0 -14
  138. package/src/ui/capture/document-preview.tsx +0 -166
  139. package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
  140. package/src/ui/capture/field-spec-to-zod.ts +0 -174
  141. package/src/ui/capture/field-spec-validate.ts +0 -236
  142. package/src/ui/capture/field-spec.test.ts +0 -49
  143. package/src/ui/capture/field-spec.ts +0 -274
  144. package/src/ui/capture/index.ts +0 -51
  145. package/src/ui/capture/schema-field-input.tsx +0 -620
  146. package/src/ui/capture/schema-form.tsx +0 -149
  147. package/src/ui/capture/submit-values.test.ts +0 -70
  148. package/src/ui/capture/submit-values.ts +0 -63
  149. package/src/ui/capture/use-prefill.ts +0 -186
  150. package/src/ui/capture/use-schema-validation.ts +0 -145
  151. package/src/ui/capture/use-wizard.ts +0 -180
  152. package/src/ui/capture/value-format.ts +0 -32
  153. package/src/ui/capture/wizard.tsx +0 -105
  154. package/src/ui/charts/bar-chart.tsx +0 -139
  155. package/src/ui/charts/chart-frame.tsx +0 -125
  156. package/src/ui/charts/chart-types.ts +0 -52
  157. package/src/ui/charts/chart-utils.ts +0 -190
  158. package/src/ui/charts/charts.test.tsx +0 -204
  159. package/src/ui/charts/donut-chart.tsx +0 -129
  160. package/src/ui/charts/index.ts +0 -27
  161. package/src/ui/charts/line-chart.tsx +0 -202
  162. package/src/ui/charts/sparkline.tsx +0 -109
  163. package/src/ui/chrome/AsyncBoundary.tsx +0 -74
  164. package/src/ui/chrome/EmptyState.tsx +0 -257
  165. package/src/ui/chrome/ErrorCard.tsx +0 -63
  166. package/src/ui/chrome/LoadingState.tsx +0 -61
  167. package/src/ui/chrome/PageHeader.tsx +0 -137
  168. package/src/ui/chrome/RecordCardList.tsx +0 -98
  169. package/src/ui/chrome/StateCard.tsx +0 -150
  170. package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
  171. package/src/ui/chrome/page-shell.spec.tsx +0 -117
  172. package/src/ui/chrome/page-shell.tsx +0 -221
  173. package/src/ui/chrome/scope-badge.tsx +0 -40
  174. package/src/ui/chrome/status-badge.tsx +0 -79
  175. package/src/ui/cn.ts +0 -32
  176. package/src/ui/design-tokens.ts +0 -372
  177. package/src/ui/hooks/use-debounced-value.ts +0 -16
  178. package/src/ui/hooks/use-is-mobile.ts +0 -28
  179. package/src/ui/index.ts +0 -110
  180. package/src/ui/pdf/pdf-preview.tsx +0 -122
  181. package/src/ui/primitives/alert-dialog.tsx +0 -104
  182. package/src/ui/primitives/async-combobox.tsx +0 -182
  183. package/src/ui/primitives/badge-variants.ts +0 -21
  184. package/src/ui/primitives/badge.tsx +0 -25
  185. package/src/ui/primitives/button-variants.ts +0 -31
  186. package/src/ui/primitives/button.tsx +0 -29
  187. package/src/ui/primitives/card.tsx +0 -43
  188. package/src/ui/primitives/checkbox.tsx +0 -26
  189. package/src/ui/primitives/collapsible.tsx +0 -9
  190. package/src/ui/primitives/dialog.tsx +0 -103
  191. package/src/ui/primitives/dropdown-menu.tsx +0 -179
  192. package/src/ui/primitives/form-stepper.tsx +0 -94
  193. package/src/ui/primitives/form-stepper.types.ts +0 -15
  194. package/src/ui/primitives/input.tsx +0 -22
  195. package/src/ui/primitives/label.tsx +0 -17
  196. package/src/ui/primitives/overflow-tabs.tsx +0 -331
  197. package/src/ui/primitives/popover.tsx +0 -33
  198. package/src/ui/primitives/preview-device-frame.tsx +0 -213
  199. package/src/ui/primitives/radio-group.tsx +0 -36
  200. package/src/ui/primitives/resizable.tsx +0 -67
  201. package/src/ui/primitives/scroll-area.tsx +0 -38
  202. package/src/ui/primitives/select.tsx +0 -143
  203. package/src/ui/primitives/separator.tsx +0 -20
  204. package/src/ui/primitives/sheet.tsx +0 -107
  205. package/src/ui/primitives/skeleton.tsx +0 -99
  206. package/src/ui/primitives/switch.tsx +0 -27
  207. package/src/ui/primitives/table.tsx +0 -72
  208. package/src/ui/primitives/tabs.tsx +0 -53
  209. package/src/ui/primitives/tag-multi-select.tsx +0 -261
  210. package/src/ui/primitives/textarea.tsx +0 -21
  211. package/src/ui/primitives/tooltip.tsx +0 -30
  212. package/src/ui/primitives/url-preview-chrome.tsx +0 -103
  213. package/src/vista/GenericCatalogueSurface.tsx +0 -179
  214. package/src/vista/SurfaceFallbackCard.tsx +0 -109
  215. package/src/vista/VistaPanel.tsx +0 -163
  216. package/src/vista/form-payload.spec.ts +0 -139
  217. package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
  218. package/src/vista/html/CustomUiFrame.tsx +0 -206
  219. package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
  220. package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
  221. package/src/vista/html/custom-ui-frame-contract.ts +0 -88
  222. package/src/vista/html/custom-ui-intents.spec.ts +0 -135
  223. package/src/vista/html/custom-ui-intents.ts +0 -155
  224. package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
  225. package/src/vista/html/custom-ui-srcdoc.ts +0 -193
  226. package/src/vista/html/index.ts +0 -13
  227. package/src/vista/index.ts +0 -52
  228. package/src/vista/surface-catalogue.spec.ts +0 -140
  229. package/src/vista/surface-catalogue.ts +0 -90
  230. package/src/vista/surface-icons.ts +0 -57
  231. package/src/vista/surface-registry.ts +0 -56
  232. package/src/vista/surfaces/ChartSurface.tsx +0 -34
  233. package/src/vista/surfaces/FilesSurface.tsx +0 -202
  234. package/src/vista/surfaces/FormSurface.tsx +0 -380
  235. package/src/vista/surfaces/HtmlSurface.tsx +0 -43
  236. package/src/vista/surfaces/TableSurface.tsx +0 -100
  237. package/src/vista/surfaces/UrlSurface.tsx +0 -40
  238. package/src/vista/surfaces/blob-surfaces.tsx +0 -139
  239. package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
  240. package/src/vista/surfaces/elicitation-transport.ts +0 -367
  241. package/src/vista/surfaces/file-surface-utils.ts +0 -69
  242. package/src/vista/surfaces/index.ts +0 -24
  243. package/src/vista/surfaces/register-surfaces.tsx +0 -139
  244. package/src/vista/surfaces/text-surfaces.tsx +0 -132
  245. package/src/vista/use-vista-tabs.ts +0 -196
  246. package/src/vista/vista-code-renderer-context.ts +0 -16
  247. package/src/vista/vista-code-renderer.tsx +0 -35
  248. package/src/vista/vista-file-context.ts +0 -14
  249. package/src/vista/vista-file-source.tsx +0 -141
  250. package/src/vista/vista-form-context.ts +0 -20
  251. package/src/vista/vista-form-host.tsx +0 -48
  252. package/src/vista/vista-model.ts +0 -137
  253. package/src/vista/vista-open-context.tsx +0 -27
  254. package/src/vista/vista-open-state.ts +0 -11
  255. package/src/vista/vista-payloads.ts +0 -635
  256. package/src/vista/vista-tabs-manifest.ts +0 -138
  257. package/src/vista/vista-tools.ts +0 -232
@@ -1,220 +0,0 @@
1
- /**
2
- * Canonical user-facing error decoder — ONE implementation biomes, the host
3
- * shell, and the kernel's {@link ErrorCard} default all share.
4
- *
5
- * Biomes were each re-implementing "pull a human message off an error"
6
- * (envelope shapes, status-code copy, "failed to fetch"). This is the single
7
- * host-agnostic decoder. It is a PURE function: no fetch, no i18n, no config,
8
- * no `instanceof` against host classes. It recognises the two error shapes the
9
- * Xema frontend produces by their structural signature:
10
- *
11
- * - the host's `ApiClientError` (`name === 'ApiClientError'`, `statusCode`,
12
- * `message`, optional `errorType`), thrown by the hand-rolled HTTP client;
13
- * - Orval's generated `ClientError` (`name === 'ClientError'`, `status`,
14
- * `message`, `body`), thrown by the generated clients. Its `body` carries
15
- * the backend `{ message, code, details }` envelope (and the workflow
16
- * wallet-missing / `session_busy` special cases).
17
- *
18
- * Hosts that previously kept their own `getUserFacingErrorMessage` should
19
- * re-export THIS one (or delete theirs and import it) so there is a single
20
- * decoder. {@link ErrorCard} defaults to it, so biomes get envelope-aware copy
21
- * without wiring anything.
22
- */
23
-
24
- function collapseWhitespace(value: string): string {
25
- return value.split(/\s+/).join(' ').trim();
26
- }
27
-
28
- function getGenericErrorMessage(message: string, fallback: string): string {
29
- const normalized = collapseWhitespace(message);
30
- if (/failed to fetch/i.test(normalized)) {
31
- return 'Could not reach the service. Check your connection and try again.';
32
- }
33
- return normalized || fallback;
34
- }
35
-
36
- function normalizeValidationMessage(rawMessage: string): string {
37
- const parts = rawMessage
38
- .split(',')
39
- .map((part) => collapseWhitespace(part))
40
- .filter(Boolean);
41
-
42
- if (parts.length === 0) {
43
- return 'Some required fields are missing or invalid. Please review your input and try again.';
44
- }
45
-
46
- const preview = parts.slice(0, 2).join('; ');
47
- const suffix = parts.length > 2 ? '; and more.' : '.';
48
- return `Some required fields are missing or invalid (${preview}${suffix})`;
49
- }
50
-
51
- /** Structural signature of the host's `ApiClientError`. */
52
- interface ApiClientErrorLike {
53
- readonly name: string;
54
- readonly statusCode: number;
55
- readonly message: string;
56
- readonly errorType?: string;
57
- }
58
-
59
- function isApiClientErrorLike(error: unknown): error is ApiClientErrorLike {
60
- if (!error || typeof error !== 'object') {
61
- return false;
62
- }
63
- const record = error as Record<string, unknown>;
64
- return (
65
- record['name'] === 'ApiClientError' &&
66
- typeof record['statusCode'] === 'number' &&
67
- typeof record['message'] === 'string'
68
- );
69
- }
70
-
71
- /** Structural signature of an Orval-generated `ClientError`. */
72
- interface OrvalClientErrorLike {
73
- readonly name: string;
74
- readonly status: number;
75
- readonly message: string;
76
- readonly body: unknown;
77
- }
78
-
79
- function isOrvalClientErrorLike(error: unknown): error is OrvalClientErrorLike {
80
- if (!error || typeof error !== 'object') {
81
- return false;
82
- }
83
- const record = error as Record<string, unknown>;
84
- return (
85
- record['name'] === 'ClientError' &&
86
- typeof record['status'] === 'number' &&
87
- typeof record['message'] === 'string' &&
88
- Object.hasOwn(record, 'body')
89
- );
90
- }
91
-
92
- interface WorkflowErrorEnvelope {
93
- readonly code?: string;
94
- readonly message?: string;
95
- readonly details?: Record<string, unknown>;
96
- }
97
-
98
- function readStringList(value: unknown): string[] | null {
99
- if (!Array.isArray(value)) {
100
- return null;
101
- }
102
- if (value.some((entry) => typeof entry !== 'string')) {
103
- return null;
104
- }
105
- return value;
106
- }
107
-
108
- function normalizeWorkflowWalletMissingMessage(envelope: WorkflowErrorEnvelope): string | null {
109
- if (envelope.code !== 'WORKFLOW_WALLET_NOT_FOUND') {
110
- return null;
111
- }
112
- const missing = readStringList(envelope.details?.['missing']);
113
- if (missing === null || missing.length === 0) {
114
- return 'One or more required wallets are missing for this project.';
115
- }
116
- return `Missing wallet${missing.length > 1 ? 's' : ''}: ${missing.join(', ')}. Add ${
117
- missing.length > 1 ? 'them' : 'it'
118
- } in Project Settings -> Wallets.`;
119
- }
120
-
121
- function getApiClientErrorMessage(error: ApiClientErrorLike, fallback: string): string {
122
- if (error.statusCode === 0) {
123
- return collapseWhitespace(error.message) || fallback;
124
- }
125
- if (error.statusCode === 400) {
126
- const raw = collapseWhitespace(error.message);
127
- if (raw.includes(' must ') || raw.includes('regular expression')) {
128
- return normalizeValidationMessage(raw);
129
- }
130
- return raw || 'The request is invalid. Please check your input and try again.';
131
- }
132
- if (error.statusCode === 401) {
133
- return 'Your session expired. Please sign in again.';
134
- }
135
- if (error.statusCode === 403) {
136
- return 'You do not have permission to perform this action.';
137
- }
138
- if (error.statusCode === 404) {
139
- return 'The requested resource was not found.';
140
- }
141
- if (error.statusCode >= 500) {
142
- return 'The service is temporarily unavailable. Please try again in a moment.';
143
- }
144
- return collapseWhitespace(error.message) || fallback;
145
- }
146
-
147
- function getOrvalClientErrorMessage(error: OrvalClientErrorLike, fallback: string): string {
148
- if (error.status >= 500) {
149
- return 'The service is temporarily unavailable. Please try again in a moment.';
150
- }
151
- // session-api refuses mutations while a prompt turn is in flight; the 409
152
- // body is `{ error: 'session_busy', retryAfterTurnDone: true }`. Surface a
153
- // clear retry hint instead of the generic "Conflict" copy.
154
- if (error.status === 409) {
155
- const body = error.body;
156
- if (body && typeof body === 'object') {
157
- const record = body as Record<string, unknown>;
158
- if (record['error'] === 'session_busy') {
159
- return 'Your last message is still running. Wait for the agent to finish, then try again.';
160
- }
161
- }
162
- }
163
- const body = error.body;
164
- if (body && typeof body === 'object') {
165
- const record = body as Record<string, unknown>;
166
- const payload: WorkflowErrorEnvelope = (() => {
167
- const message = record['message'];
168
- if (message && typeof message === 'object') {
169
- return message;
170
- }
171
- return {
172
- code: typeof record['code'] === 'string' ? record['code'] : undefined,
173
- message: typeof record['message'] === 'string' ? record['message'] : undefined,
174
- details:
175
- record['details'] && typeof record['details'] === 'object'
176
- ? (record['details'] as Record<string, unknown>)
177
- : undefined,
178
- };
179
- })();
180
-
181
- const workflowWalletMessage = normalizeWorkflowWalletMissingMessage(payload);
182
- if (workflowWalletMessage !== null) {
183
- return workflowWalletMessage;
184
- }
185
- if (typeof payload.message === 'string' && payload.message.trim().length > 0) {
186
- return collapseWhitespace(payload.message);
187
- }
188
- if (typeof record['message'] === 'string' && record['message'].trim().length > 0) {
189
- return collapseWhitespace(record['message']);
190
- }
191
- }
192
- return getGenericErrorMessage(error.message, fallback);
193
- }
194
-
195
- /**
196
- * Decode any thrown value into a human, user-facing message. The single decoder
197
- * for biomes, the host shell, and {@link ErrorCard}'s default.
198
- *
199
- * @param error Any thrown value (string, `Error`, `ApiClientError`, Orval
200
- * `ClientError`, or unknown).
201
- * @param fallback Copy returned when nothing better can be extracted.
202
- */
203
- export function getUserFacingErrorMessage(
204
- error: unknown,
205
- fallback = 'Something went wrong. Please try again.',
206
- ): string {
207
- if (typeof error === 'string') {
208
- return collapseWhitespace(error) || fallback;
209
- }
210
- if (isApiClientErrorLike(error)) {
211
- return getApiClientErrorMessage(error, fallback);
212
- }
213
- if (isOrvalClientErrorLike(error)) {
214
- return getOrvalClientErrorMessage(error, fallback);
215
- }
216
- if (error instanceof Error) {
217
- return getGenericErrorMessage(error.message, fallback);
218
- }
219
- return fallback;
220
- }
@@ -1,256 +0,0 @@
1
- import type { HostBridge } from './host-bridge';
2
- import type { SessionContributions } from './session-contributions';
3
- import type { ComponentType, ReactNode } from 'react';
4
-
5
- /**
6
- * Runtime contribution types a `target: 'web'` biome composes. Web
7
- * biomes default-export a `FrontendBiomeFactory` from their package
8
- * (the import specifier is `xema-biome.json#name`); the SPA's
9
- * auto-generated `xema:web-biome-loaders` virtual module imports each
10
- * factory at bootstrap, calls it with the host's `HostBridge`, and
11
- * registers the resulting `FrontendBiome` into the singleton
12
- * `biomeRegistry`.
13
- */
14
-
15
- export interface NavItemContribution {
16
- /** Stable id used for active-state matching + analytics. */
17
- readonly id: string;
18
- /** Displayed label. */
19
- readonly label: string;
20
- /** Route path the nav item links to. */
21
- readonly route: string;
22
- /**
23
- * Optional icon component. Typed with `className: string | undefined` so
24
- * any host icon kit whose props include `className` (lucide-react,
25
- * heroicons, custom SVG components) is assignable under
26
- * `exactOptionalPropertyTypes: true`. The host renders with whatever
27
- * className it computes from its own theme.
28
- */
29
- readonly icon?: ComponentType<{ className?: string | undefined }>;
30
- /**
31
- * Semantic menu category the biome declares its INTENT to live in (e.g.
32
- * `build`, `operate`, `knowledge`, `account`). The HOST owns the menu
33
- * information-architecture: it maps a category to a concrete rail group,
34
- * heading, and order. Authors declare WHAT a surface is, not WHERE in the
35
- * global menu it renders — so the platform can re-organise the menu without
36
- * editing every biome. When omitted, the host falls back to its own
37
- * taxonomy (keyed on the nav-item id).
38
- */
39
- readonly category?: string;
40
- }
41
-
42
- /**
43
- * Access tier required to render a route. The host resolver enforces it
44
- * declaratively — nav-hide is NOT a security boundary, a deeplink bypasses it.
45
- * Precedence (least → most privileged): `member` < `org-admin` <
46
- * `platform-admin`. Defaults to `member` when a route omits the field.
47
- *
48
- * `public` is NOT a privilege tier — it is the *no-auth* marker: a `public`
49
- * route requires no Keycloak session at all and mounts OUTSIDE the host's
50
- * authenticated route group. It is value-locked to `RouteScope` `'public'`
51
- * (`defineWebBiome` rejects any other pairing at define time), so a route is
52
- * public in BOTH senses or in neither. Closed set — a new member is a
53
- * one-line change to {@link ROUTE_ACCESS_VALUES} and one `case` in the host
54
- * resolver's exhaustive `hasRouteAccess` switch (the switch has no `default`,
55
- * so an unhandled member is a compile error, never a silent allow).
56
- *
57
- * The tuple below is the SINGLE source of truth: the type is derived from it,
58
- * so a member cannot exist in the type without also being enumerable at
59
- * runtime — which is what lets a host prove exhaustiveness in a test rather
60
- * than by inspection. Order is least → most privileged; `public` is the
61
- * no-auth marker and is deliberately last.
62
- */
63
- export const ROUTE_ACCESS_VALUES = [
64
- 'member',
65
- 'org-admin',
66
- 'platform-admin',
67
- 'public',
68
- ] as const;
69
-
70
- /** Access tier required to render a route. See {@link ROUTE_ACCESS_VALUES}. */
71
- export type RouteAccess = (typeof ROUTE_ACCESS_VALUES)[number];
72
-
73
- /**
74
- * Where a route mounts in the host's URL/auth topology. Closed set — adding a
75
- * member is a one-line change here (and the single mapping in `defineWebBiome`
76
- * plus one resolver partition in the host).
77
- *
78
- * - `org` — mounts at the org root, inside the authenticated group.
79
- * - `project` — mounts under the project-scoped route prefix, inside the
80
- * authenticated group.
81
- * - `public` — mounts OUTSIDE the authenticated group; no Keycloak session,
82
- * no login redirect, no org switcher. Locked to `RouteAccess` `'public'`.
83
- *
84
- * Single source of truth for the closed set; the type is derived from it.
85
- */
86
- export const ROUTE_SCOPE_VALUES = ['org', 'project', 'public'] as const;
87
-
88
- /** Where a route mounts. See {@link ROUTE_SCOPE_VALUES}. */
89
- export type RouteScope = (typeof ROUTE_SCOPE_VALUES)[number];
90
-
91
- /**
92
- * Whether a page renders wrapped in the host application shell (app rail,
93
- * topbar, org switcher) or standalone. Closed set — a new member is a one-line
94
- * change here. Defaults to `'host'` when a page omits it.
95
- *
96
- * - `host` — the default; the host renders its chrome around the page.
97
- * - `none` — the host renders the page with NO app rail, topbar, or org
98
- * switcher (a full-bleed surface). `public` routes are structurally
99
- * chromeless (their route group ships no shell); `none` also lets an
100
- * authenticated route opt out of the shell.
101
- *
102
- * Single source of truth for the closed set; the type is derived from it.
103
- * Chrome is ORTHOGONAL to access: `chrome: 'none'` on an authenticated route
104
- * is the embedded-app case and grants no privilege change whatsoever.
105
- */
106
- export const PAGE_CHROME_VALUES = ['host', 'none'] as const;
107
-
108
- /** Host-shell mode a page renders in. See {@link PAGE_CHROME_VALUES}. */
109
- export type PageChrome = (typeof PAGE_CHROME_VALUES)[number];
110
-
111
- export interface RouteContribution {
112
- /** React-router path. May include params. */
113
- readonly path: string;
114
- /** Element factory — host calls it inside the route tree. */
115
- readonly element: () => ReactNode;
116
- /**
117
- * Whether the route is project-scoped (mounted under /projects/:projectId)
118
- * or org-scoped (mounted at the org root). REQUIRED — the host nav resolver
119
- * partitions the rail strictly by this flag and drops any nav item whose
120
- * route can't be matched (fail-loud). A silent default would re-introduce the
121
- * "project pages showing at org level" class of bug, so every route MUST
122
- * declare its scope explicitly.
123
- */
124
- readonly projectScoped: boolean;
125
- /**
126
- * Access tier required to render this route. The host resolver enforces it
127
- * declaratively. Defaults to `'member'` when omitted. `'public'` marks a
128
- * no-auth route the host mounts outside its authenticated group.
129
- */
130
- readonly access?: RouteAccess;
131
- /**
132
- * Whether the host wraps this route in its application shell. Defaults to
133
- * `'host'` when omitted; `'none'` renders the page with no app rail,
134
- * topbar, or org switcher. See {@link PageChrome}.
135
- */
136
- readonly chrome?: PageChrome;
137
- }
138
-
139
- /**
140
- * Slot fillers — biomes contribute UI fragments rendered by named
141
- * `<BiomeSlot name="…">` boundaries placed in the host app shell.
142
- * Initial slots: 'org-header-actions', 'project-overview-cards',
143
- * 'run-detail-side-panel', 'settings-tabs', 'session-actions'.
144
- */
145
- export interface PanelContribution {
146
- /** Slot name the contribution renders into. */
147
- readonly slot: string;
148
- /** Stable id for ordering + replacement. */
149
- readonly id: string;
150
- /** React node factory — host calls it inside the slot. */
151
- readonly render: () => ReactNode;
152
- /** Sort weight within the slot (lower first). Defaults to 100. */
153
- readonly weight?: number;
154
- }
155
-
156
- /**
157
- * Lifecycle context passed to `FrontendBiome.init`. The host invokes
158
- * `init()` exactly once after the biome's factory returns and before
159
- * any session contribution is read. Biomes use it to wire any
160
- * imperative one-time work (Orval client setup, feature-flag registration,
161
- * background-cache prefetch) — declarative contributions go on the
162
- * `FrontendBiome` itself, not here.
163
- */
164
- export interface BiomeInitContext {
165
- readonly bridge: HostBridge;
166
- /** Biome id, mirrored from `FrontendBiome.id` for convenience. */
167
- readonly biomeId: string;
168
- }
169
-
170
- export interface FrontendBiome {
171
- /** Stable biome id; matches xema-biome.json `xema.id`. */
172
- readonly id: string;
173
- /** Displayed name. */
174
- readonly displayName: string;
175
- /**
176
- * One-shot initializer invoked after registration. Used for imperative
177
- * setup that doesn't fit a declarative contribution (e.g. seeding a
178
- * shared cache, mounting a side-effect listener). Idempotent: the
179
- * registry guarantees `init()` runs at most once per biome per SPA
180
- * session, even across HMR reloads.
181
- */
182
- readonly init?: (ctx: BiomeInitContext) => void | Promise<void>;
183
- /**
184
- * Optional teardown counterpart to `init()`. Invoked when the biome
185
- * is explicitly unregistered (admin disable flow). Biomes MUST NOT
186
- * rely on `dispose()` running on tab close — browsers don't guarantee
187
- * it. Use it for live-subscription cleanup, not for persistence.
188
- */
189
- readonly dispose?: () => void | Promise<void>;
190
- readonly navItems?: readonly NavItemContribution[];
191
- readonly routes?: readonly RouteContribution[];
192
- readonly panels?: readonly PanelContribution[];
193
- /**
194
- * Declarative contributions to the agent-session shell. See
195
- * `session-contributions.ts` for the full taxonomy. Each contribution
196
- * is a small data object; the host's session components read them
197
- * through typed selector hooks and render the matching primitives.
198
- */
199
- readonly session?: SessionContributions;
200
- /**
201
- * Output renderer contributions. Each entry binds a biome-defined
202
- * artifact `OutputKind` (e.g. `catalog_entity_info`) to the React
203
- * component that renders it inside `<OutputCard>`. The host's renderer
204
- * registry overlays biome contributions on top of the built-in set —
205
- * built-in kinds (`markdown_doc`, `json_payload`, …) cannot be
206
- * overridden, but new kinds light up the moment the biome's frontend
207
- * loads.
208
- *
209
- * See `packages/output-contracts` for the `OutputKind` taxonomy and
210
- * `submodules/xema-host-web/src/components/outputs/renderer-registry.tsx`
211
- * for the resolver. Biome renderers receive the same `OutputItem`
212
- * shape as built-ins.
213
- */
214
- readonly outputRenderers?: readonly OutputRendererContribution[];
215
- }
216
-
217
- /**
218
- * One biome → one renderer for a biome-defined `OutputKind`. The
219
- * `outputKind` string MUST be unique across all biomes; the renderer
220
- * registry refuses to register a duplicate at bootstrap (fail-fast,
221
- * surfaced in the dev console + biome admin UI).
222
- *
223
- * The `render` factory mirrors `RouteContribution.element` /
224
- * `PanelContribution.render` — typed as a thunk so the host can defer
225
- * import-cost until the renderer actually fires.
226
- */
227
- export interface OutputRendererContribution {
228
- /**
229
- * The artifact `OutputKind` this renderer handles. Free-form string
230
- * because biome-defined kinds are not in the built-in enum; the
231
- * registry validates it doesn't collide with a built-in kind at
232
- * registration time.
233
- */
234
- readonly outputKind: string;
235
- /**
236
- * React component that renders the artifact body inside `<OutputCard>`.
237
- * Receives the resolved `OutputItem` as a prop. Biomes import the
238
- * `OutputRendererProps` type from
239
- * `submodules/xema-host-web/src/components/outputs/renderer-registry.tsx`
240
- * (re-exported through the host's biome SDK barrel).
241
- */
242
- readonly render: () => ComponentType<{ readonly output: unknown }>;
243
- }
244
-
245
- /**
246
- * Biome module export contract. Each biome's entry module exports a
247
- * default function of this shape; the host bootstrap calls it with its
248
- * concrete `HostBridge` implementation, then registers the returned
249
- * `FrontendBiome` with `biomeRegistry`.
250
- *
251
- * This factory shape keeps biome code free of any direct dependency
252
- * on host-shell primitives (router, auth client, toast library), which
253
- * is what allows the same biome package to load into one host runtime
254
- * today and a different host runtime tomorrow.
255
- */
256
- export type FrontendBiomeFactory = (bridge: HostBridge) => FrontendBiome;