@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,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host-agnostic realtime (CloudEvents over SSE) port.
|
|
3
|
-
*
|
|
4
|
-
* Frontend biomes need to subscribe to server-pushed CloudEvents (session
|
|
5
|
-
* lifecycle, tool calls, notifications, …). The transport — the unified SSE
|
|
6
|
-
* connection, the Keycloak-minted bearer, the active-org header, cross-tab
|
|
7
|
-
* leader election, server-side scope subscriptions — is HOST-owned (today
|
|
8
|
-
* `@xemahq/realtime-client` wrapped by the host's `RealtimeProvider`). Biomes
|
|
9
|
-
* must NOT import that client or `EventSource` directly, exactly as they must
|
|
10
|
-
* not import `next/navigation` or `sonner`.
|
|
11
|
-
*
|
|
12
|
-
* Instead the host injects a concrete {@link RealtimeSource} when it builds the
|
|
13
|
-
* {@link HostBridge}; it is hung off `bridge.realtime`. Biomes reach it through
|
|
14
|
-
* the {@link useCloudEvent} / {@link useRealtimeStatus} / {@link useEventScope}
|
|
15
|
-
* kernel hooks — the same decoupling pattern as `bridge.navigation` /
|
|
16
|
-
* `bridge.capabilities`.
|
|
17
|
-
*
|
|
18
|
-
* Framework-agnostic: pure interface contracts, no React, no SSE, no fetch.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The subset of the CloudEvents-shape envelope a biome handler receives.
|
|
23
|
-
*
|
|
24
|
-
* Locally typed in the kernel (deliberately NOT imported from
|
|
25
|
-
* `@xemahq/realtime-client` / `@xemahq/events`) so `@xemahq/ui-kernel` stays
|
|
26
|
-
* transport-free and host-agnostic. The host's realtime client emits an object
|
|
27
|
-
* that is structurally assignable to this — value-identical to the client's
|
|
28
|
-
* `DeliveredEvent`, kept here as the kernel's stable contract.
|
|
29
|
-
*/
|
|
30
|
-
export interface RealtimeCloudEvent {
|
|
31
|
-
/** CloudEvents `id` — unique per delivered event, when the server stamps it. */
|
|
32
|
-
id?: string;
|
|
33
|
-
/** CloudEvents `type`, e.g. `session.lifecycle.changed`. The subscription key. */
|
|
34
|
-
type: string;
|
|
35
|
-
/** CloudEvents `source`, e.g. `/services/activity-feed-api` or `/biomes/<id>`. */
|
|
36
|
-
source?: string;
|
|
37
|
-
/** CloudEvents `subject`, e.g. `session/<session-id>`. */
|
|
38
|
-
subject?: string;
|
|
39
|
-
/** CloudEvents `data` payload. Biomes narrow this themselves. */
|
|
40
|
-
data?: unknown;
|
|
41
|
-
/** Org-id header echoed onto every delivered envelope. */
|
|
42
|
-
ehorgid: string;
|
|
43
|
-
/** Project-id header, when the event is project-scoped. */
|
|
44
|
-
ehprojectid?: string;
|
|
45
|
-
/** User-id header, when the event is user-scoped. */
|
|
46
|
-
ehuserid?: string;
|
|
47
|
-
/** Global delivery cursor. */
|
|
48
|
-
ehglobalseq?: string;
|
|
49
|
-
/** Per-org delivery cursor. */
|
|
50
|
-
ehorgseq?: string;
|
|
51
|
-
/** Per-project delivery cursor. */
|
|
52
|
-
ehprojectseq?: string;
|
|
53
|
-
/** Per-session delivery cursor. */
|
|
54
|
-
ehsessionseq?: string;
|
|
55
|
-
/** Frontend-only invalidation hint carried alongside the envelope. */
|
|
56
|
-
__hint?: unknown;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** Coarse realtime connection status for status indicators. */
|
|
60
|
-
export type RealtimeStatus =
|
|
61
|
-
| 'idle'
|
|
62
|
-
| 'connecting'
|
|
63
|
-
| 'connected'
|
|
64
|
-
| 'reconnecting'
|
|
65
|
-
| 'closed';
|
|
66
|
-
|
|
67
|
-
/** Coarse connection state surfaced to status UIs. */
|
|
68
|
-
export interface RealtimeConnectionState {
|
|
69
|
-
readonly status: RealtimeStatus;
|
|
70
|
-
/** Latest connectionId returned by the upstream `CONNECTED` frame. */
|
|
71
|
-
readonly connectionId?: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* A server-side scope a connection can subscribe to so it only receives the
|
|
76
|
-
* events for one project, session, or app, rather than the full org firehose.
|
|
77
|
-
* The host's transport reference-counts identical scopes across mounts.
|
|
78
|
-
*
|
|
79
|
-
* `app` is the app-surface scope: an external/app-facing biome subscribes to
|
|
80
|
-
* its app's event stream (delivery is authz-gated server-side by the subject's
|
|
81
|
-
* app membership). It is value-identical to the server `ScopeKind.app` and the
|
|
82
|
-
* host transport's `EventScopeOptions` — the kernel union is the last hop to
|
|
83
|
-
* carry it, so a decoupled/remote biome can type an app subscription.
|
|
84
|
-
*/
|
|
85
|
-
export interface RealtimeScope {
|
|
86
|
-
readonly kind: 'project' | 'session' | 'app';
|
|
87
|
-
readonly id: string;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Host-implemented realtime source. The host wires each method against its
|
|
92
|
-
* realtime transport (`@xemahq/realtime-client`'s `RealtimeContext`) and passes
|
|
93
|
-
* it in when building the {@link HostBridge}.
|
|
94
|
-
*
|
|
95
|
-
* Every method is a React hook (it reads transport context / state), so it
|
|
96
|
-
* MUST be called from a biome component's render — the kernel `useCloudEvent` /
|
|
97
|
-
* `useRealtimeStatus` / `useEventScope` hooks delegate straight through.
|
|
98
|
-
*/
|
|
99
|
-
export interface RealtimeSource {
|
|
100
|
-
/**
|
|
101
|
-
* Subscribe `handler` to every delivered CloudEvent whose `type` matches
|
|
102
|
-
* `eventType`, for the lifetime of the calling component. Per-`data` filtering
|
|
103
|
-
* (e.g. by `sessionId`) is the handler's responsibility. Mirrors the host
|
|
104
|
-
* client's `useCloudEvent`.
|
|
105
|
-
*/
|
|
106
|
-
useCloudEvent(eventType: string, handler: (event: RealtimeCloudEvent) => void): void;
|
|
107
|
-
/** Coarse connection state for a status indicator. */
|
|
108
|
-
useRealtimeStatus(): RealtimeConnectionState;
|
|
109
|
-
/**
|
|
110
|
-
* Subscribe the connection's unified SSE to a project/session scope while the
|
|
111
|
-
* calling component is mounted; auto-unsubscribes on unmount. Server-side
|
|
112
|
-
* subscriptions are reference-counted by the host transport.
|
|
113
|
-
*/
|
|
114
|
-
useEventScope(scope: RealtimeScope): void;
|
|
115
|
-
}
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Declarative session contribution types — every UI extension a frontend
|
|
3
|
-
* biome can drop into the agent-session shell. The host shell
|
|
4
|
-
* carries generic primitives; the registries declared here are how
|
|
5
|
-
* biomes (first-party or third-party) hook those primitives into a
|
|
6
|
-
* concrete user experience.
|
|
7
|
-
*
|
|
8
|
-
* Contract shape: each contribution is a small data object the biome
|
|
9
|
-
* adds to its `FrontendBiome.session.*` field. The host's session
|
|
10
|
-
* components call typed selector hooks (`useSessionSlashCommands`,
|
|
11
|
-
* `useSessionDrawerTabs`, …) which walk the biome registry and return
|
|
12
|
-
* the contributions whose `appliesTo` predicate passes for the current
|
|
13
|
-
* `SessionContext`.
|
|
14
|
-
*
|
|
15
|
-
* `appliesTo` is the single gating primitive — biomes use it to scope
|
|
16
|
-
* a contribution to explicit Agent, workspace, domain, or session status
|
|
17
|
-
* facts. Without it, every contribution applies everywhere.
|
|
18
|
-
*
|
|
19
|
-
* Naming convention: contribution ids MUST be namespaced as
|
|
20
|
-
* `<biome-id>/<contribution>` so cross-biome collisions surface
|
|
21
|
-
* deterministically at registration time (`RegistryDuplicateKeyError`).
|
|
22
|
-
*/
|
|
23
|
-
import type { HostBridge } from './host-bridge';
|
|
24
|
-
import type { ComponentType, ReactNode } from 'react';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Read-only snapshot of the session the contribution is evaluated
|
|
28
|
-
* against. Passed into every `appliesTo` predicate and every render
|
|
29
|
-
* function so contributions can adapt without subscribing to the host's
|
|
30
|
-
* query cache themselves.
|
|
31
|
-
*/
|
|
32
|
-
export interface SessionContext {
|
|
33
|
-
readonly sessionId: string;
|
|
34
|
-
readonly orgId: string;
|
|
35
|
-
readonly projectId: string;
|
|
36
|
-
/**
|
|
37
|
-
* Biome id that owns the session's profile (e.g. `'software-dev'`,
|
|
38
|
-
* `'design-system-builder'`). Biomes use this to filter contributions to
|
|
39
|
-
* sessions they care about.
|
|
40
|
-
*/
|
|
41
|
-
readonly biomeId?: string;
|
|
42
|
-
readonly status: string;
|
|
43
|
-
/**
|
|
44
|
-
* The resolved Agent contract that launched this session. This is
|
|
45
|
-
* runtime truth returned by the Agent resolver, never a UI-authored
|
|
46
|
-
* profile or a synthetic fallback.
|
|
47
|
-
*/
|
|
48
|
-
readonly agent?: SessionResolvedAgent;
|
|
49
|
-
/** Repository actually bound to the session, when one exists. */
|
|
50
|
-
readonly repositoryId?: string;
|
|
51
|
-
/**
|
|
52
|
-
* `true` while the session is in a state that accepts new work
|
|
53
|
-
* (running, waiting, idle); `false` for terminal/paused/failed states.
|
|
54
|
-
* Mirrors the legacy `isActive` boolean the host shell already passes
|
|
55
|
-
* around so contributions can disable destructive actions.
|
|
56
|
-
*/
|
|
57
|
-
readonly isActive: boolean;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* UI-safe projection of the resolved Agent contract. The host obtains this
|
|
62
|
-
* from the Agent resolver and passes it into the kernel; plugins only consume
|
|
63
|
-
* the explicit permission/workspace facts they need.
|
|
64
|
-
*/
|
|
65
|
-
export interface SessionResolvedAgent {
|
|
66
|
-
readonly ref: string;
|
|
67
|
-
readonly requiredCapabilities: ReadonlySet<string>;
|
|
68
|
-
readonly mayEditRepositories: boolean;
|
|
69
|
-
readonly mayWriteKnowledgeBase: boolean;
|
|
70
|
-
readonly hasOutputSurface: boolean;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Stable representation of a session console event passed into activity
|
|
75
|
-
* + tool-call renderers. Mirrors the host's `SessionConsoleEntry` minus
|
|
76
|
-
* host-specific fields — renderers should not depend on host internals.
|
|
77
|
-
*/
|
|
78
|
-
export interface SessionActivityEvent {
|
|
79
|
-
readonly id: string;
|
|
80
|
-
readonly kind: string;
|
|
81
|
-
readonly sequence?: number;
|
|
82
|
-
readonly createdAt: string;
|
|
83
|
-
readonly title: string;
|
|
84
|
-
readonly content?: string;
|
|
85
|
-
readonly detail?: string;
|
|
86
|
-
readonly status?: 'pending' | 'completed' | 'error';
|
|
87
|
-
readonly payload?: Record<string, unknown>;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Stable representation of a tool-call event passed into tool-call
|
|
92
|
-
* renderers. `name` is the tool's canonical id (e.g. `'bash_run'`,
|
|
93
|
-
* `'jira.create_issue'`); biomes MAY use namespaced names so their
|
|
94
|
-
* renderers don't collide with other biomes'.
|
|
95
|
-
*/
|
|
96
|
-
export interface SessionToolCallEvent {
|
|
97
|
-
readonly id: string;
|
|
98
|
-
readonly name: string;
|
|
99
|
-
readonly status: 'pending' | 'completed' | 'error';
|
|
100
|
-
readonly startedAt: string;
|
|
101
|
-
readonly completedAt?: string;
|
|
102
|
-
readonly args?: Record<string, unknown>;
|
|
103
|
-
readonly result?: unknown;
|
|
104
|
-
readonly error?: string;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// ── Slash commands ─────────────────────────────────────────────────────
|
|
108
|
-
|
|
109
|
-
export interface SlashCommandContext {
|
|
110
|
-
readonly session: SessionContext;
|
|
111
|
-
readonly bridge: HostBridge;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface SlashCommandContribution {
|
|
115
|
-
/** Namespaced id (`<biome-id>/<name>`). */
|
|
116
|
-
readonly id: string;
|
|
117
|
-
/** Command keyword users type after `/` (no slash; e.g. `'commit'`). */
|
|
118
|
-
readonly name: string;
|
|
119
|
-
/** Displayed label in the autocomplete popup. */
|
|
120
|
-
readonly label: string;
|
|
121
|
-
readonly description: string;
|
|
122
|
-
readonly icon?: ComponentType<{ className?: string | undefined }>;
|
|
123
|
-
/** Sort weight inside the autocomplete list (lower first; default 100). */
|
|
124
|
-
readonly weight?: number;
|
|
125
|
-
/** Hide the command unless the session matches. */
|
|
126
|
-
readonly appliesTo?: (ctx: SessionContext) => boolean;
|
|
127
|
-
/** Disable the command when the session is paused/terminal. */
|
|
128
|
-
readonly requiresActiveSession?: boolean;
|
|
129
|
-
/** Invoked when the user selects the command. */
|
|
130
|
-
readonly onSelect: (ctx: SlashCommandContext) => void | Promise<void>;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// ── Secondary drawer tabs ─────────────────────────────────────────────
|
|
134
|
-
|
|
135
|
-
export interface SecondaryDrawerTabContext {
|
|
136
|
-
readonly session: SessionContext;
|
|
137
|
-
readonly bridge: HostBridge;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface SecondaryDrawerTabContribution {
|
|
141
|
-
/** Namespaced id (`<biome-id>/<tab>`). */
|
|
142
|
-
readonly id: string;
|
|
143
|
-
/** Stable short key used by keyboard shortcuts (`'tools'`, `'git'`, …). */
|
|
144
|
-
readonly key: string;
|
|
145
|
-
readonly label: string;
|
|
146
|
-
readonly icon: ComponentType<{ className?: string | undefined }>;
|
|
147
|
-
/** Sort weight (lower first). Default 100. */
|
|
148
|
-
readonly order?: number;
|
|
149
|
-
readonly appliesTo?: (ctx: SessionContext) => boolean;
|
|
150
|
-
readonly render: (ctx: SecondaryDrawerTabContext) => ReactNode;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// ── Activity renderers ─────────────────────────────────────────────────
|
|
154
|
-
|
|
155
|
-
export interface ActivityRendererContext {
|
|
156
|
-
readonly session: SessionContext;
|
|
157
|
-
readonly event: SessionActivityEvent;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export interface ActivityRendererContribution {
|
|
161
|
-
/** Namespaced id (`<biome-id>/<renderer>`). */
|
|
162
|
-
readonly id: string;
|
|
163
|
-
/**
|
|
164
|
-
* Activity entry kind this renderer handles. Either an exact
|
|
165
|
-
* `SessionConsoleEntry.kind` value or a namespaced custom kind a
|
|
166
|
-
* biome emits through its own backend events.
|
|
167
|
-
*/
|
|
168
|
-
readonly entryKind: string;
|
|
169
|
-
/** Per-event predicate; defaults to "always handle this kind". */
|
|
170
|
-
readonly appliesTo?: (ctx: ActivityRendererContext) => boolean;
|
|
171
|
-
readonly render: (ctx: ActivityRendererContext) => ReactNode;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// ── Tool-call renderers ────────────────────────────────────────────────
|
|
175
|
-
|
|
176
|
-
export interface ToolCallRendererContext {
|
|
177
|
-
readonly session: SessionContext;
|
|
178
|
-
readonly event: SessionToolCallEvent;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export interface ToolCallRendererContribution {
|
|
182
|
-
/** Namespaced id (`<biome-id>/<renderer>`). */
|
|
183
|
-
readonly id: string;
|
|
184
|
-
/**
|
|
185
|
-
* Either an exact tool name (`'bash_run'`) OR a `'<prefix>.*'` glob
|
|
186
|
-
* matching any tool whose name starts with `<prefix>.` (e.g.
|
|
187
|
-
* `'jira.*'`). Exact matches win over globs; ties broken by `weight`.
|
|
188
|
-
*/
|
|
189
|
-
readonly toolName: string;
|
|
190
|
-
readonly icon?: ComponentType<{ className?: string | undefined }>;
|
|
191
|
-
readonly weight?: number;
|
|
192
|
-
readonly appliesTo?: (ctx: ToolCallRendererContext) => boolean;
|
|
193
|
-
/** Short label shown in the activity timeline row. */
|
|
194
|
-
readonly renderLabel?: (ctx: ToolCallRendererContext) => string;
|
|
195
|
-
/**
|
|
196
|
-
* Expanded card / inline body for the tool call. When omitted, the
|
|
197
|
-
* host falls back to a generic key-value dump of args + result.
|
|
198
|
-
*/
|
|
199
|
-
readonly render?: (ctx: ToolCallRendererContext) => ReactNode;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// ── Mutation bars ──────────────────────────────────────────────────────
|
|
203
|
-
|
|
204
|
-
export interface MutationBarContext {
|
|
205
|
-
readonly session: SessionContext;
|
|
206
|
-
readonly bridge: HostBridge;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Sticky bar rendered between the session header and the chat panel —
|
|
211
|
-
* used today by software-dev for the git branch + PR status row. Generic
|
|
212
|
-
* by design so a Jira biome could add an "Issue: PROJ-123 / In Review"
|
|
213
|
-
* bar, an aws biome could surface a deploy status, etc.
|
|
214
|
-
*/
|
|
215
|
-
export interface MutationBarContribution {
|
|
216
|
-
/** Namespaced id (`<biome-id>/<bar>`). */
|
|
217
|
-
readonly id: string;
|
|
218
|
-
/** Sort weight (lower renders higher). Default 100. */
|
|
219
|
-
readonly order?: number;
|
|
220
|
-
readonly appliesTo?: (ctx: SessionContext) => boolean;
|
|
221
|
-
readonly render: (ctx: MutationBarContext) => ReactNode;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// ── Header chips ───────────────────────────────────────────────────────
|
|
225
|
-
|
|
226
|
-
export interface HeaderChipContext {
|
|
227
|
-
readonly session: SessionContext;
|
|
228
|
-
readonly bridge: HostBridge;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Compact chips rendered in the session header row alongside the title
|
|
233
|
-
* (e.g. "Fork of #42", "PR #15", "Catalog entity: …"). Biomes use
|
|
234
|
-
* these for one-glance links to external systems.
|
|
235
|
-
*/
|
|
236
|
-
export interface HeaderChipContribution {
|
|
237
|
-
readonly id: string;
|
|
238
|
-
readonly order?: number;
|
|
239
|
-
readonly appliesTo?: (ctx: SessionContext) => boolean;
|
|
240
|
-
readonly render: (ctx: HeaderChipContext) => ReactNode;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// ── Attachment classes ─────────────────────────────────────────────────
|
|
244
|
-
|
|
245
|
-
export interface AttachmentPickResult {
|
|
246
|
-
/** Class id (`<biome-id>/<class>`). */
|
|
247
|
-
readonly classId: string;
|
|
248
|
-
/** Stable reference the backend uses to resolve the attachment. */
|
|
249
|
-
readonly ref: string;
|
|
250
|
-
/** Display label shown in the attachments list. */
|
|
251
|
-
readonly label: string;
|
|
252
|
-
/** Optional opaque payload forwarded to the attachment API. */
|
|
253
|
-
readonly payload?: Record<string, unknown>;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export interface AttachmentPickContext {
|
|
257
|
-
readonly session: SessionContext;
|
|
258
|
-
readonly bridge: HostBridge;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* A class of attachable resource a biome contributes. The contribution
|
|
263
|
-
* supplies a label, an icon, and a picker callback that resolves to a
|
|
264
|
-
* concrete attachment ref. The host calls `pickAndAttach` from its
|
|
265
|
-
* attachment dialog when the user selects this class.
|
|
266
|
-
*/
|
|
267
|
-
export interface AttachmentClassContribution {
|
|
268
|
-
readonly id: string;
|
|
269
|
-
readonly label: string;
|
|
270
|
-
readonly description?: string;
|
|
271
|
-
readonly icon?: ComponentType<{ className?: string | undefined }>;
|
|
272
|
-
readonly order?: number;
|
|
273
|
-
readonly appliesTo?: (ctx: SessionContext) => boolean;
|
|
274
|
-
readonly pickAndAttach: (
|
|
275
|
-
ctx: AttachmentPickContext,
|
|
276
|
-
) => Promise<AttachmentPickResult | null>;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// ── Aggregate session contributions ────────────────────────────────────
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* All session-level contributions a biome declares on its
|
|
283
|
-
* `FrontendBiome`. Every field is optional; a biome opts in only to
|
|
284
|
-
* the surfaces it cares about. The host walks the registry once per
|
|
285
|
-
* surface and assembles the active contributions for the current
|
|
286
|
-
* session context.
|
|
287
|
-
*/
|
|
288
|
-
export interface SessionContributions {
|
|
289
|
-
readonly slashCommands?: readonly SlashCommandContribution[];
|
|
290
|
-
readonly secondaryDrawerTabs?: readonly SecondaryDrawerTabContribution[];
|
|
291
|
-
readonly activityRenderers?: readonly ActivityRendererContribution[];
|
|
292
|
-
readonly toolCallRenderers?: readonly ToolCallRendererContribution[];
|
|
293
|
-
readonly mutationBars?: readonly MutationBarContribution[];
|
|
294
|
-
readonly headerChips?: readonly HeaderChipContribution[];
|
|
295
|
-
readonly attachmentClasses?: readonly AttachmentClassContribution[];
|
|
296
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unified mutation hook with automatic success/error toast notifications.
|
|
3
|
-
*
|
|
4
|
-
* Rebuilt on the {@link HostBridge}: toasts route through `bridge.toast` and
|
|
5
|
-
* error copy is decoded by the bridge's error decoder (falling back to the
|
|
6
|
-
* kernel {@link getUserFacingErrorMessage}). Biome code stays decoupled from
|
|
7
|
-
* any particular toast library or error-envelope shape.
|
|
8
|
-
*
|
|
9
|
-
* Requires `@tanstack/react-query` (an optional peer of the kernel) and a
|
|
10
|
-
* `QueryClientProvider` mounted above.
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* const mutation = useMutationWithErrorToast(
|
|
14
|
-
* { mutationFn: (vars) => apiFn(vars), onSuccess: () => invalidate() },
|
|
15
|
-
* { successTitle: 'Saved', errorTitle: 'Save failed' },
|
|
16
|
-
* );
|
|
17
|
-
*/
|
|
18
|
-
import { useMutation, type UseMutationOptions } from '@tanstack/react-query';
|
|
19
|
-
|
|
20
|
-
import { getUserFacingErrorMessage } from './errors';
|
|
21
|
-
import { useHostBridge } from './host-bridge';
|
|
22
|
-
|
|
23
|
-
export type MutationCoreOptions<
|
|
24
|
-
TData = unknown,
|
|
25
|
-
TError = Error,
|
|
26
|
-
TVariables = unknown,
|
|
27
|
-
TContext = unknown,
|
|
28
|
-
> = Omit<UseMutationOptions<TData, TError, TVariables, TContext>, 'onError'>;
|
|
29
|
-
|
|
30
|
-
export interface MutationToastOptions<TError = Error> {
|
|
31
|
-
/** Title for the success toast. Omit or pass null to suppress the success toast. */
|
|
32
|
-
successTitle?: string | null;
|
|
33
|
-
/** Optional description for the success toast. */
|
|
34
|
-
successDescription?: string;
|
|
35
|
-
/** Title for the error toast. Omit to suppress the error toast. */
|
|
36
|
-
errorTitle?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Custom error side-effect. Called before the auto-error-toast.
|
|
39
|
-
* Return `true` to suppress the automatic toast.
|
|
40
|
-
*/
|
|
41
|
-
onError?: (error: TError) => boolean | void;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function useMutationWithErrorToast<
|
|
45
|
-
TData = unknown,
|
|
46
|
-
TError extends Error = Error,
|
|
47
|
-
TVariables = unknown,
|
|
48
|
-
TContext = unknown,
|
|
49
|
-
>(
|
|
50
|
-
mutationOptions: MutationCoreOptions<TData, TError, TVariables, TContext>,
|
|
51
|
-
toastOptions?: MutationToastOptions<TError>,
|
|
52
|
-
) {
|
|
53
|
-
const bridge = useHostBridge();
|
|
54
|
-
const decodeError =
|
|
55
|
-
bridge.errors?.getUserFacingErrorMessage ?? getUserFacingErrorMessage;
|
|
56
|
-
|
|
57
|
-
const { onSuccess: userOnSuccess, ...coreMutationOptions } = mutationOptions;
|
|
58
|
-
const {
|
|
59
|
-
successTitle,
|
|
60
|
-
successDescription,
|
|
61
|
-
errorTitle,
|
|
62
|
-
onError: customOnError,
|
|
63
|
-
} = toastOptions ?? {};
|
|
64
|
-
|
|
65
|
-
return useMutation({
|
|
66
|
-
...coreMutationOptions,
|
|
67
|
-
onSuccess: (data, variables, context, mutation) => {
|
|
68
|
-
if (successTitle !== null && successTitle !== undefined) {
|
|
69
|
-
bridge.toast.success(successTitle, successDescription);
|
|
70
|
-
}
|
|
71
|
-
if (userOnSuccess) {
|
|
72
|
-
userOnSuccess(data, variables, context, mutation);
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
onError: (error: TError) => {
|
|
76
|
-
if (errorTitle !== undefined) {
|
|
77
|
-
const shouldSuppressToast = customOnError?.(error) === true;
|
|
78
|
-
if (!shouldSuppressToast) {
|
|
79
|
-
const errorMessage = decodeError(
|
|
80
|
-
error,
|
|
81
|
-
'Unable to complete this action.',
|
|
82
|
-
);
|
|
83
|
-
bridge.toast.error(errorTitle, errorMessage);
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
customOnError?.(error);
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
}
|