@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.
- package/dist/errors/http-error-status.d.ts +17 -0
- package/dist/errors/http-error-status.d.ts.map +1 -0
- package/dist/errors/http-error-status.js +59 -0
- package/dist/errors/http-error-status.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/biome-host/errors.d.ts.map +1 -1
- package/dist/lib/biome-host/errors.js +1 -19
- package/dist/lib/biome-host/errors.js.map +1 -1
- package/dist/offline/index.d.ts.map +1 -1
- package/dist/offline/index.js.map +1 -1
- package/dist/offline/online-controller.d.ts.map +1 -1
- package/dist/offline/online-controller.js +6 -1
- package/dist/offline/online-controller.js.map +1 -1
- package/dist/offline/outbox.d.ts.map +1 -1
- package/dist/offline/outbox.js +2 -24
- package/dist/offline/outbox.js.map +1 -1
- package/package.json +1 -2
- package/src/index.ts +0 -17
- package/src/lib/biome-host/agent-validation.ts +0 -239
- package/src/lib/biome-host/biome-builders.ts +0 -112
- package/src/lib/biome-host/biome-mode.ts +0 -6
- package/src/lib/biome-host/biome-navigation.ts +0 -37
- package/src/lib/biome-host/biome-registry.ts +0 -299
- package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
- package/src/lib/biome-host/biome-scope.tsx +0 -52
- package/src/lib/biome-host/biome-scoped-query.ts +0 -134
- package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
- package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
- package/src/lib/biome-host/define-web-biome.ts +0 -222
- package/src/lib/biome-host/errors.ts +0 -220
- package/src/lib/biome-host/frontend-biome.ts +0 -256
- package/src/lib/biome-host/host-bridge.ts +0 -281
- package/src/lib/biome-host/host-sources.ts +0 -54
- package/src/lib/biome-host/i18n-hooks.ts +0 -51
- package/src/lib/biome-host/i18n-port.test.ts +0 -50
- package/src/lib/biome-host/i18n-port.ts +0 -96
- package/src/lib/biome-host/index.ts +0 -35
- package/src/lib/biome-host/realtime-hooks.ts +0 -75
- package/src/lib/biome-host/realtime-port.ts +0 -115
- package/src/lib/biome-host/session-contributions.ts +0 -296
- package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
- package/src/lib/biome-host/use-page-state.ts +0 -248
- package/src/lib/capabilities/capability-context.ts +0 -25
- package/src/lib/capabilities/capability-provider.tsx +0 -73
- package/src/lib/capabilities/index.ts +0 -17
- package/src/lib/capabilities/types.ts +0 -69
- package/src/lib/capabilities/use-capability.ts +0 -79
- package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
- package/src/lib/contribution-registry/contribution-registry.ts +0 -204
- package/src/lib/contribution-registry/index.ts +0 -9
- package/src/lib/contribution-registry/renderable-registry.ts +0 -142
- package/src/lib/system-bus/capability-invoke.ts +0 -92
- package/src/lib/system-bus/deeplink.ts +0 -210
- package/src/lib/system-bus/enums.ts +0 -86
- package/src/lib/system-bus/host-ports.ts +0 -93
- package/src/lib/system-bus/index.ts +0 -16
- package/src/lib/system-bus/intent-registry.ts +0 -109
- package/src/lib/system-bus/intents.ts +0 -113
- package/src/lib/system-bus/palette.ts +0 -78
- package/src/lib/system-bus/system-bus-builder.ts +0 -159
- package/src/lib/system-bus/system-bus.ts +0 -37
- package/src/lib/system-bus/windows.ts +0 -51
- package/src/offline/id.ts +0 -16
- package/src/offline/index.ts +0 -54
- package/src/offline/mutation.ts +0 -75
- package/src/offline/offline-status-badge.tsx +0 -51
- package/src/offline/online-controller.ts +0 -105
- package/src/offline/outbox.test.ts +0 -172
- package/src/offline/outbox.ts +0 -348
- package/src/offline/react-hooks.ts +0 -40
- package/src/offline/react.tsx +0 -32
- package/src/offline/storage.ts +0 -112
- package/src/offline/types.ts +0 -77
- package/src/org-db/components/DbResultTable.tsx +0 -176
- package/src/org-db/index.ts +0 -1
- package/src/pdf/index.ts +0 -11
- package/src/registry/index.ts +0 -9
- package/src/registry/lib/agent-validation-host.ts +0 -36
- package/src/registry/lib/biome-slot.tsx +0 -50
- package/src/registry/lib/biomes-enabled-context.ts +0 -20
- package/src/registry/lib/extension-points.ts +0 -134
- package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
- package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
- package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
- package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
- package/src/registry/lib/primitives/index.ts +0 -18
- package/src/registry/lib/session-context-builder.ts +0 -84
- package/src/registry/lib/session-context-provider.tsx +0 -33
- package/src/registry/lib/session-context.ts +0 -21
- package/src/registry/lib/session-selectors.ts +0 -272
- package/src/session/comments/CommentRail.tsx +0 -164
- package/src/session/index.ts +0 -3
- package/src/session/lib/cn.ts +0 -11
- package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
- package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
- package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
- package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
- package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
- package/src/session-kit/approvals/Obligation.tsx +0 -111
- package/src/session-kit/approvals/ScopedBody.tsx +0 -392
- package/src/session-kit/approvals/approval-icons.ts +0 -31
- package/src/session-kit/approvals/approval-model.ts +0 -204
- package/src/session-kit/approvals/index.ts +0 -22
- package/src/session-kit/approvals/obligation-display.ts +0 -100
- package/src/session-kit/approvals/risk-accent.ts +0 -47
- package/src/session-kit/approvals/scope-icons.ts +0 -19
- package/src/session-kit/combobox/Combobox.tsx +0 -358
- package/src/session-kit/combobox/use-click-outside.ts +0 -21
- package/src/session-kit/display/ContextHeader.tsx +0 -148
- package/src/session-kit/display/FileDiffCard.tsx +0 -140
- package/src/session-kit/display/MD.tsx +0 -162
- package/src/session-kit/display/MessageTurn.tsx +0 -157
- package/src/session-kit/display/ThinkingPanel.tsx +0 -81
- package/src/session-kit/display/TodoChecklist.tsx +0 -120
- package/src/session-kit/display/TokenMeter.tsx +0 -89
- package/src/session-kit/display/ToolStrip.tsx +0 -278
- package/src/session-kit/display/TypingDots.tsx +0 -24
- package/src/session-kit/index.ts +0 -44
- package/src/session-kit/lib/enums.ts +0 -66
- package/src/session-kit/lib/portal-accent.ts +0 -30
- package/src/session-kit/lib/status-dot.ts +0 -68
- package/src/session-kit/primitives/Avatar.tsx +0 -44
- package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
- package/src/session-kit/primitives/RiskPill.tsx +0 -95
- package/src/session-kit/primitives/ScopeDot.tsx +0 -47
- package/src/session-kit/primitives/Segmented.tsx +0 -71
- package/src/ui/branding/app-branding-context.ts +0 -20
- package/src/ui/branding/app-branding-provider.tsx +0 -123
- package/src/ui/branding/sanitize.ts +0 -89
- package/src/ui/breakpoints.ts +0 -14
- package/src/ui/capture/document-preview.tsx +0 -166
- package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
- package/src/ui/capture/field-spec-to-zod.ts +0 -174
- package/src/ui/capture/field-spec-validate.ts +0 -236
- package/src/ui/capture/field-spec.test.ts +0 -49
- package/src/ui/capture/field-spec.ts +0 -274
- package/src/ui/capture/index.ts +0 -51
- package/src/ui/capture/schema-field-input.tsx +0 -620
- package/src/ui/capture/schema-form.tsx +0 -149
- package/src/ui/capture/submit-values.test.ts +0 -70
- package/src/ui/capture/submit-values.ts +0 -63
- package/src/ui/capture/use-prefill.ts +0 -186
- package/src/ui/capture/use-schema-validation.ts +0 -145
- package/src/ui/capture/use-wizard.ts +0 -180
- package/src/ui/capture/value-format.ts +0 -32
- package/src/ui/capture/wizard.tsx +0 -105
- package/src/ui/charts/bar-chart.tsx +0 -139
- package/src/ui/charts/chart-frame.tsx +0 -125
- package/src/ui/charts/chart-types.ts +0 -52
- package/src/ui/charts/chart-utils.ts +0 -190
- package/src/ui/charts/charts.test.tsx +0 -204
- package/src/ui/charts/donut-chart.tsx +0 -129
- package/src/ui/charts/index.ts +0 -27
- package/src/ui/charts/line-chart.tsx +0 -202
- package/src/ui/charts/sparkline.tsx +0 -109
- package/src/ui/chrome/AsyncBoundary.tsx +0 -74
- package/src/ui/chrome/EmptyState.tsx +0 -257
- package/src/ui/chrome/ErrorCard.tsx +0 -63
- package/src/ui/chrome/LoadingState.tsx +0 -61
- package/src/ui/chrome/PageHeader.tsx +0 -137
- package/src/ui/chrome/RecordCardList.tsx +0 -98
- package/src/ui/chrome/StateCard.tsx +0 -150
- package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
- package/src/ui/chrome/page-shell.spec.tsx +0 -117
- package/src/ui/chrome/page-shell.tsx +0 -221
- package/src/ui/chrome/scope-badge.tsx +0 -40
- package/src/ui/chrome/status-badge.tsx +0 -79
- package/src/ui/cn.ts +0 -32
- package/src/ui/design-tokens.ts +0 -372
- package/src/ui/hooks/use-debounced-value.ts +0 -16
- package/src/ui/hooks/use-is-mobile.ts +0 -28
- package/src/ui/index.ts +0 -110
- package/src/ui/pdf/pdf-preview.tsx +0 -122
- package/src/ui/primitives/alert-dialog.tsx +0 -104
- package/src/ui/primitives/async-combobox.tsx +0 -182
- package/src/ui/primitives/badge-variants.ts +0 -21
- package/src/ui/primitives/badge.tsx +0 -25
- package/src/ui/primitives/button-variants.ts +0 -31
- package/src/ui/primitives/button.tsx +0 -29
- package/src/ui/primitives/card.tsx +0 -43
- package/src/ui/primitives/checkbox.tsx +0 -26
- package/src/ui/primitives/collapsible.tsx +0 -9
- package/src/ui/primitives/dialog.tsx +0 -103
- package/src/ui/primitives/dropdown-menu.tsx +0 -179
- package/src/ui/primitives/form-stepper.tsx +0 -94
- package/src/ui/primitives/form-stepper.types.ts +0 -15
- package/src/ui/primitives/input.tsx +0 -22
- package/src/ui/primitives/label.tsx +0 -17
- package/src/ui/primitives/overflow-tabs.tsx +0 -331
- package/src/ui/primitives/popover.tsx +0 -33
- package/src/ui/primitives/preview-device-frame.tsx +0 -213
- package/src/ui/primitives/radio-group.tsx +0 -36
- package/src/ui/primitives/resizable.tsx +0 -67
- package/src/ui/primitives/scroll-area.tsx +0 -38
- package/src/ui/primitives/select.tsx +0 -143
- package/src/ui/primitives/separator.tsx +0 -20
- package/src/ui/primitives/sheet.tsx +0 -107
- package/src/ui/primitives/skeleton.tsx +0 -99
- package/src/ui/primitives/switch.tsx +0 -27
- package/src/ui/primitives/table.tsx +0 -72
- package/src/ui/primitives/tabs.tsx +0 -53
- package/src/ui/primitives/tag-multi-select.tsx +0 -261
- package/src/ui/primitives/textarea.tsx +0 -21
- package/src/ui/primitives/tooltip.tsx +0 -30
- package/src/ui/primitives/url-preview-chrome.tsx +0 -103
- package/src/vista/GenericCatalogueSurface.tsx +0 -179
- package/src/vista/SurfaceFallbackCard.tsx +0 -109
- package/src/vista/VistaPanel.tsx +0 -163
- package/src/vista/form-payload.spec.ts +0 -139
- package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
- package/src/vista/html/CustomUiFrame.tsx +0 -206
- package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
- package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
- package/src/vista/html/custom-ui-frame-contract.ts +0 -88
- package/src/vista/html/custom-ui-intents.spec.ts +0 -135
- package/src/vista/html/custom-ui-intents.ts +0 -155
- package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
- package/src/vista/html/custom-ui-srcdoc.ts +0 -193
- package/src/vista/html/index.ts +0 -13
- package/src/vista/index.ts +0 -52
- package/src/vista/surface-catalogue.spec.ts +0 -140
- package/src/vista/surface-catalogue.ts +0 -90
- package/src/vista/surface-icons.ts +0 -57
- package/src/vista/surface-registry.ts +0 -56
- package/src/vista/surfaces/ChartSurface.tsx +0 -34
- package/src/vista/surfaces/FilesSurface.tsx +0 -202
- package/src/vista/surfaces/FormSurface.tsx +0 -380
- package/src/vista/surfaces/HtmlSurface.tsx +0 -43
- package/src/vista/surfaces/TableSurface.tsx +0 -100
- package/src/vista/surfaces/UrlSurface.tsx +0 -40
- package/src/vista/surfaces/blob-surfaces.tsx +0 -139
- package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
- package/src/vista/surfaces/elicitation-transport.ts +0 -367
- package/src/vista/surfaces/file-surface-utils.ts +0 -69
- package/src/vista/surfaces/index.ts +0 -24
- package/src/vista/surfaces/register-surfaces.tsx +0 -139
- package/src/vista/surfaces/text-surfaces.tsx +0 -132
- package/src/vista/use-vista-tabs.ts +0 -196
- package/src/vista/vista-code-renderer-context.ts +0 -16
- package/src/vista/vista-code-renderer.tsx +0 -35
- package/src/vista/vista-file-context.ts +0 -14
- package/src/vista/vista-file-source.tsx +0 -141
- package/src/vista/vista-form-context.ts +0 -20
- package/src/vista/vista-form-host.tsx +0 -48
- package/src/vista/vista-model.ts +0 -137
- package/src/vista/vista-open-context.tsx +0 -27
- package/src/vista/vista-open-state.ts +0 -11
- package/src/vista/vista-payloads.ts +0 -635
- package/src/vista/vista-tabs-manifest.ts +0 -138
- 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;
|