@xemahq/ui-kernel 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/chrome/page-shell.d.ts +1 -1
- package/dist/ui/chrome/page-shell.d.ts.map +1 -1
- package/dist/ui/chrome/page-shell.js +9 -4
- package/dist/ui/chrome/page-shell.js.map +1 -1
- package/package.json +6 -4
- 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.tsx +0 -189
- 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,50 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { makeTranslator } from './i18n-port';
|
|
4
|
-
|
|
5
|
-
const en = {
|
|
6
|
-
title: 'Dashboard',
|
|
7
|
-
greeting: 'Hello, {name}',
|
|
8
|
-
radar: { title: 'Radar', empty: 'No leads yet' },
|
|
9
|
-
} as const;
|
|
10
|
-
|
|
11
|
-
describe('makeTranslator', () => {
|
|
12
|
-
it('resolves flat and nested dot-path keys', () => {
|
|
13
|
-
const t = makeTranslator(en);
|
|
14
|
-
expect(t('title')).toBe('Dashboard');
|
|
15
|
-
expect(t('radar.title')).toBe('Radar');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('interpolates {name} placeholders', () => {
|
|
19
|
-
const t = makeTranslator(en);
|
|
20
|
-
expect(t('greeting', { name: 'Ada' })).toBe('Hello, Ada');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('leaves an unknown placeholder verbatim (visible authoring bug)', () => {
|
|
24
|
-
const t = makeTranslator({ msg: 'Hi {who}' });
|
|
25
|
-
expect(t('msg', {})).toBe('Hi {who}');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('applies a namespace prefix', () => {
|
|
29
|
-
const t = makeTranslator(en, { namespace: 'radar' });
|
|
30
|
-
expect(t('title')).toBe('Radar');
|
|
31
|
-
expect(t('empty')).toBe('No leads yet');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('returns the raw key for a missing message (never blank, never throws)', () => {
|
|
35
|
-
const t = makeTranslator(en);
|
|
36
|
-
expect(t('does.not.exist')).toBe('does.not.exist');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('falls back message-by-message to the default-locale catalog', () => {
|
|
40
|
-
const pt = { title: 'Painel' }; // partial locale — no greeting
|
|
41
|
-
const t = makeTranslator(pt, { fallback: en });
|
|
42
|
-
expect(t('title')).toBe('Painel'); // primary wins
|
|
43
|
-
expect(t('greeting', { name: 'Ada' })).toBe('Hello, Ada'); // fallback fills the gap
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('coerces numeric params to strings', () => {
|
|
47
|
-
const t = makeTranslator({ count: '{n} items' });
|
|
48
|
-
expect(t('count', { n: 3 })).toBe('3 items');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kernel i18n contract + a framework-free translator core.
|
|
3
|
-
*
|
|
4
|
-
* Xema's locale is DATA-driven (per-org / per-app / per-user settings), not
|
|
5
|
-
* URL-driven, so the kernel deliberately does NOT depend on next-intl / react-
|
|
6
|
-
* intl. A biome localises its UI through the host-injected {@link I18nSource}
|
|
7
|
-
* (reached via the `useT` / `useLocale` kernel hooks) exactly the way it reaches
|
|
8
|
-
* realtime / navigation — the biome never imports an i18n library, and the host
|
|
9
|
-
* owns catalog loading + the authoritative locale source.
|
|
10
|
-
*
|
|
11
|
-
* The {@link makeTranslator} core here is pure and host-agnostic: a host (or a
|
|
12
|
-
* biome, or a test) builds a `Translator` from a nested-JSON catalog with no
|
|
13
|
-
* framework in the loop.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** Interpolation values for a message's `{name}` placeholders. */
|
|
17
|
-
export type TranslateParams = Readonly<Record<string, string | number>>;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Resolve one message key to a localized string, interpolating `{name}`
|
|
21
|
-
* placeholders. Missing keys return the key itself (visible, never a throw or a
|
|
22
|
-
* blank) — the standard i18n contract, not a silent business-logic fallback.
|
|
23
|
-
*/
|
|
24
|
-
export type Translator = (key: string, params?: TranslateParams) => string;
|
|
25
|
-
|
|
26
|
-
/** A nested message catalog: dot-path keys map to strings (or sub-catalogs). */
|
|
27
|
-
export interface Catalog {
|
|
28
|
-
readonly [segment: string]: string | Catalog;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface MakeTranslatorOptions {
|
|
32
|
-
/** Prefix every lookup with this namespace path (e.g. `"radar"`). */
|
|
33
|
-
readonly namespace?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Default-locale catalog consulted per-key when the primary catalog lacks a
|
|
36
|
-
* message — so a partially-translated locale falls back message-by-message
|
|
37
|
-
* instead of dropping to the raw key.
|
|
38
|
-
*/
|
|
39
|
-
readonly fallback?: Catalog;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function lookup(catalog: Catalog, path: readonly string[]): string | undefined {
|
|
43
|
-
let node: string | Catalog | undefined = catalog;
|
|
44
|
-
for (const segment of path) {
|
|
45
|
-
if (node === undefined || typeof node === 'string') {
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
node = node[segment];
|
|
49
|
-
}
|
|
50
|
-
return typeof node === 'string' ? node : undefined;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function interpolate(message: string, params?: TranslateParams): string {
|
|
54
|
-
if (!params) {
|
|
55
|
-
return message;
|
|
56
|
-
}
|
|
57
|
-
// Replace `{name}` tokens; an unknown token is left verbatim (visible), never
|
|
58
|
-
// blanked — a missing param is an authoring bug that should be obvious.
|
|
59
|
-
return message.replaceAll(/\{(\w+)\}/g, (whole, name: string) =>
|
|
60
|
-
Object.prototype.hasOwnProperty.call(params, name) ? String(params[name]) : whole,
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Build a {@link Translator} over a catalog. Pure — no React, no framework, no
|
|
66
|
-
* global state. Resolution order per key: primary catalog → fallback catalog →
|
|
67
|
-
* the key itself.
|
|
68
|
-
*/
|
|
69
|
-
export function makeTranslator(
|
|
70
|
-
catalog: Catalog,
|
|
71
|
-
options?: MakeTranslatorOptions,
|
|
72
|
-
): Translator {
|
|
73
|
-
const prefix = options?.namespace ? options.namespace.split('.') : [];
|
|
74
|
-
const fallback = options?.fallback;
|
|
75
|
-
return (key, params) => {
|
|
76
|
-
const path = [...prefix, ...key.split('.')];
|
|
77
|
-
const message =
|
|
78
|
-
lookup(catalog, path) ?? (fallback ? lookup(fallback, path) : undefined) ?? key;
|
|
79
|
-
return interpolate(message, params);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Host-implemented i18n source. The host wires these against its locale provider
|
|
85
|
-
* (authoritative locale from org/app/user settings + catalog loading); biomes
|
|
86
|
-
* reach them through the kernel {@link useT} / {@link useLocale} hooks.
|
|
87
|
-
*
|
|
88
|
-
* Every method is a React hook (reads locale/catalog context), so it MUST be
|
|
89
|
-
* called from a component's render.
|
|
90
|
-
*/
|
|
91
|
-
export interface I18nSource {
|
|
92
|
-
/** A {@link Translator} for the active locale, optionally namespaced. */
|
|
93
|
-
useTranslator(namespace?: string): Translator;
|
|
94
|
-
/** The active BCP-47 locale tag (e.g. `"pt-PT"`). */
|
|
95
|
-
useLocale(): string;
|
|
96
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Biome-host contract surface — the framework-agnostic shape every
|
|
3
|
-
* frontend biome composes against, plus the singleton runtime registry
|
|
4
|
-
* that hosts populate at bootstrap.
|
|
5
|
-
*
|
|
6
|
-
* Host-framework-agnostic: no Vite, no Next.js, no React-Router. React
|
|
7
|
-
* itself IS used (it is the shared component model for any host) — the
|
|
8
|
-
* contracts traffic in `ReactNode`/`ComponentType`, expose a React
|
|
9
|
-
* context (`HostBridgeContext`/`useHostBridge`), and the registry ships
|
|
10
|
-
* a `useSyncExternalStore` revision hook. The concrete host adapter only
|
|
11
|
-
* wires framework-specific navigation against these contracts (e.g. the
|
|
12
|
-
* Next.js App Router host); the agnostic host sources (`AuthSource`,
|
|
13
|
-
* `ToastSource`), nav merging, and the `SystemBus` builder all live here.
|
|
14
|
-
*/
|
|
15
|
-
export * from './frontend-biome';
|
|
16
|
-
export * from './host-bridge';
|
|
17
|
-
export * from './biome-navigation';
|
|
18
|
-
export * from './biome-scope';
|
|
19
|
-
export * from './biome-scope-hooks';
|
|
20
|
-
export * from './biome-scoped-query';
|
|
21
|
-
export * from './biome-builders';
|
|
22
|
-
export * from './define-web-biome';
|
|
23
|
-
export * from './create-biome-orval-config';
|
|
24
|
-
export * from './biome-registry';
|
|
25
|
-
export * from './session-contributions';
|
|
26
|
-
export * from './host-sources';
|
|
27
|
-
export * from './biome-mode';
|
|
28
|
-
export * from './agent-validation';
|
|
29
|
-
export * from './realtime-port';
|
|
30
|
-
export * from './realtime-hooks';
|
|
31
|
-
export * from './i18n-port';
|
|
32
|
-
export * from './i18n-hooks';
|
|
33
|
-
export * from './errors';
|
|
34
|
-
export * from './use-mutation-with-error-toast';
|
|
35
|
-
export * from './use-page-state';
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kernel-side realtime hooks. Biomes call these INSTEAD of importing the host's
|
|
3
|
-
* realtime client (`@xemahq/realtime-client`) directly, so biome code stays
|
|
4
|
-
* decoupled from the SSE transport — the same decoupling `useHostBridge`
|
|
5
|
-
* already provides for navigation / auth / capabilities.
|
|
6
|
-
*
|
|
7
|
-
* Each hook reads the host-injected {@link RealtimeSource} off
|
|
8
|
-
* `bridge.realtime` and delegates straight through. The host owns the transport
|
|
9
|
-
* (connection, token refresh, org header, scope refcounting); the kernel owns
|
|
10
|
-
* only the contract + this thin delegation.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { useHostBridge } from './host-bridge';
|
|
14
|
-
|
|
15
|
-
import type {
|
|
16
|
-
RealtimeCloudEvent,
|
|
17
|
-
RealtimeConnectionState,
|
|
18
|
-
RealtimeScope,
|
|
19
|
-
RealtimeSource,
|
|
20
|
-
} from './realtime-port';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Resolve the host-injected realtime transport, failing fast with an actionable
|
|
24
|
-
* message if the host has not wired `bridge.realtime`. `bridge.realtime` is an
|
|
25
|
-
* optional port (a host without a realtime transport omits it), so the kernel
|
|
26
|
-
* hooks must not silently no-op — a biome that calls them expects live events.
|
|
27
|
-
*/
|
|
28
|
-
function requireRealtime(realtime: RealtimeSource | undefined): RealtimeSource {
|
|
29
|
-
if (!realtime) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
'useCloudEvent/useRealtimeStatus/useEventScope require a realtime ' +
|
|
32
|
-
'transport, but the host has not wired `bridge.realtime`. The host ' +
|
|
33
|
-
'must provide a RealtimeSource (e.g. backed by @xemahq/realtime-client) ' +
|
|
34
|
-
'on the HostBridge to use kernel realtime hooks.',
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
return realtime;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Subscribe to delivered CloudEvents of a given `type` for the lifetime of the
|
|
42
|
-
* calling component. Pass a stable `handler` (e.g. via `useCallback`) — the
|
|
43
|
-
* host re-subscribes when the handler identity changes. Narrow `event.data`
|
|
44
|
-
* inside the handler; the kernel does not parse payloads.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* useCloudEvent('session.lifecycle.changed', (event) => {
|
|
48
|
-
* const data = event.data as { sessionId?: string } | undefined;
|
|
49
|
-
* if (data?.sessionId !== sessionId) return;
|
|
50
|
-
* refetch();
|
|
51
|
-
* });
|
|
52
|
-
*/
|
|
53
|
-
export function useCloudEvent(
|
|
54
|
-
eventType: string,
|
|
55
|
-
handler: (event: RealtimeCloudEvent) => void,
|
|
56
|
-
): void {
|
|
57
|
-
const bridge = useHostBridge();
|
|
58
|
-
requireRealtime(bridge.realtime).useCloudEvent(eventType, handler);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Coarse realtime connection state for a status indicator. */
|
|
62
|
-
export function useRealtimeStatus(): RealtimeConnectionState {
|
|
63
|
-
const bridge = useHostBridge();
|
|
64
|
-
return requireRealtime(bridge.realtime).useRealtimeStatus();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Subscribe the connection to a project/session {@link RealtimeScope} while the
|
|
69
|
-
* calling component is mounted. Scopes are reference-counted by the host, so
|
|
70
|
-
* multiple components asking for the same scope share one server subscription.
|
|
71
|
-
*/
|
|
72
|
-
export function useEventScope(scope: RealtimeScope): void {
|
|
73
|
-
const bridge = useHostBridge();
|
|
74
|
-
requireRealtime(bridge.realtime).useEventScope(scope);
|
|
75
|
-
}
|
|
@@ -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
|
-
}
|