@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.
Files changed (237) hide show
  1. package/dist/ui/chrome/page-shell.d.ts +1 -1
  2. package/dist/ui/chrome/page-shell.d.ts.map +1 -1
  3. package/dist/ui/chrome/page-shell.js +9 -4
  4. package/dist/ui/chrome/page-shell.js.map +1 -1
  5. package/package.json +6 -4
  6. package/src/index.ts +0 -17
  7. package/src/lib/biome-host/agent-validation.ts +0 -239
  8. package/src/lib/biome-host/biome-builders.ts +0 -112
  9. package/src/lib/biome-host/biome-mode.ts +0 -6
  10. package/src/lib/biome-host/biome-navigation.ts +0 -37
  11. package/src/lib/biome-host/biome-registry.ts +0 -299
  12. package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
  13. package/src/lib/biome-host/biome-scope.tsx +0 -52
  14. package/src/lib/biome-host/biome-scoped-query.ts +0 -134
  15. package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
  16. package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
  17. package/src/lib/biome-host/define-web-biome.ts +0 -222
  18. package/src/lib/biome-host/errors.ts +0 -220
  19. package/src/lib/biome-host/frontend-biome.ts +0 -256
  20. package/src/lib/biome-host/host-bridge.ts +0 -281
  21. package/src/lib/biome-host/host-sources.ts +0 -54
  22. package/src/lib/biome-host/i18n-hooks.ts +0 -51
  23. package/src/lib/biome-host/i18n-port.test.ts +0 -50
  24. package/src/lib/biome-host/i18n-port.ts +0 -96
  25. package/src/lib/biome-host/index.ts +0 -35
  26. package/src/lib/biome-host/realtime-hooks.ts +0 -75
  27. package/src/lib/biome-host/realtime-port.ts +0 -115
  28. package/src/lib/biome-host/session-contributions.ts +0 -296
  29. package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
  30. package/src/lib/biome-host/use-page-state.ts +0 -248
  31. package/src/lib/capabilities/capability-context.ts +0 -25
  32. package/src/lib/capabilities/capability-provider.tsx +0 -73
  33. package/src/lib/capabilities/index.ts +0 -17
  34. package/src/lib/capabilities/types.ts +0 -69
  35. package/src/lib/capabilities/use-capability.ts +0 -79
  36. package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
  37. package/src/lib/contribution-registry/contribution-registry.ts +0 -204
  38. package/src/lib/contribution-registry/index.ts +0 -9
  39. package/src/lib/contribution-registry/renderable-registry.ts +0 -142
  40. package/src/lib/system-bus/capability-invoke.ts +0 -92
  41. package/src/lib/system-bus/deeplink.ts +0 -210
  42. package/src/lib/system-bus/enums.ts +0 -86
  43. package/src/lib/system-bus/host-ports.ts +0 -93
  44. package/src/lib/system-bus/index.ts +0 -16
  45. package/src/lib/system-bus/intent-registry.ts +0 -109
  46. package/src/lib/system-bus/intents.ts +0 -113
  47. package/src/lib/system-bus/palette.ts +0 -78
  48. package/src/lib/system-bus/system-bus-builder.ts +0 -159
  49. package/src/lib/system-bus/system-bus.ts +0 -37
  50. package/src/lib/system-bus/windows.ts +0 -51
  51. package/src/offline/id.ts +0 -16
  52. package/src/offline/index.ts +0 -54
  53. package/src/offline/mutation.ts +0 -75
  54. package/src/offline/offline-status-badge.tsx +0 -51
  55. package/src/offline/online-controller.ts +0 -105
  56. package/src/offline/outbox.test.ts +0 -172
  57. package/src/offline/outbox.ts +0 -348
  58. package/src/offline/react-hooks.ts +0 -40
  59. package/src/offline/react.tsx +0 -32
  60. package/src/offline/storage.ts +0 -112
  61. package/src/offline/types.ts +0 -77
  62. package/src/org-db/components/DbResultTable.tsx +0 -176
  63. package/src/org-db/index.ts +0 -1
  64. package/src/pdf/index.ts +0 -11
  65. package/src/registry/index.ts +0 -9
  66. package/src/registry/lib/agent-validation-host.ts +0 -36
  67. package/src/registry/lib/biome-slot.tsx +0 -50
  68. package/src/registry/lib/biomes-enabled-context.ts +0 -20
  69. package/src/registry/lib/extension-points.ts +0 -134
  70. package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
  71. package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
  72. package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
  73. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
  74. package/src/registry/lib/primitives/index.ts +0 -18
  75. package/src/registry/lib/session-context-builder.ts +0 -84
  76. package/src/registry/lib/session-context-provider.tsx +0 -33
  77. package/src/registry/lib/session-context.ts +0 -21
  78. package/src/registry/lib/session-selectors.ts +0 -272
  79. package/src/session/comments/CommentRail.tsx +0 -164
  80. package/src/session/index.ts +0 -3
  81. package/src/session/lib/cn.ts +0 -11
  82. package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
  83. package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
  84. package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
  85. package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
  86. package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
  87. package/src/session-kit/approvals/Obligation.tsx +0 -111
  88. package/src/session-kit/approvals/ScopedBody.tsx +0 -392
  89. package/src/session-kit/approvals/approval-icons.ts +0 -31
  90. package/src/session-kit/approvals/approval-model.ts +0 -204
  91. package/src/session-kit/approvals/index.ts +0 -22
  92. package/src/session-kit/approvals/obligation-display.ts +0 -100
  93. package/src/session-kit/approvals/risk-accent.ts +0 -47
  94. package/src/session-kit/approvals/scope-icons.ts +0 -19
  95. package/src/session-kit/combobox/Combobox.tsx +0 -358
  96. package/src/session-kit/combobox/use-click-outside.ts +0 -21
  97. package/src/session-kit/display/ContextHeader.tsx +0 -148
  98. package/src/session-kit/display/FileDiffCard.tsx +0 -140
  99. package/src/session-kit/display/MD.tsx +0 -162
  100. package/src/session-kit/display/MessageTurn.tsx +0 -157
  101. package/src/session-kit/display/ThinkingPanel.tsx +0 -81
  102. package/src/session-kit/display/TodoChecklist.tsx +0 -120
  103. package/src/session-kit/display/TokenMeter.tsx +0 -89
  104. package/src/session-kit/display/ToolStrip.tsx +0 -278
  105. package/src/session-kit/display/TypingDots.tsx +0 -24
  106. package/src/session-kit/index.ts +0 -44
  107. package/src/session-kit/lib/enums.ts +0 -66
  108. package/src/session-kit/lib/portal-accent.ts +0 -30
  109. package/src/session-kit/lib/status-dot.ts +0 -68
  110. package/src/session-kit/primitives/Avatar.tsx +0 -44
  111. package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
  112. package/src/session-kit/primitives/RiskPill.tsx +0 -95
  113. package/src/session-kit/primitives/ScopeDot.tsx +0 -47
  114. package/src/session-kit/primitives/Segmented.tsx +0 -71
  115. package/src/ui/branding/app-branding-context.ts +0 -20
  116. package/src/ui/branding/app-branding-provider.tsx +0 -123
  117. package/src/ui/branding/sanitize.ts +0 -89
  118. package/src/ui/breakpoints.ts +0 -14
  119. package/src/ui/capture/document-preview.tsx +0 -166
  120. package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
  121. package/src/ui/capture/field-spec-to-zod.ts +0 -174
  122. package/src/ui/capture/field-spec-validate.ts +0 -236
  123. package/src/ui/capture/field-spec.test.ts +0 -49
  124. package/src/ui/capture/field-spec.ts +0 -274
  125. package/src/ui/capture/index.ts +0 -51
  126. package/src/ui/capture/schema-field-input.tsx +0 -620
  127. package/src/ui/capture/schema-form.tsx +0 -149
  128. package/src/ui/capture/submit-values.test.ts +0 -70
  129. package/src/ui/capture/submit-values.ts +0 -63
  130. package/src/ui/capture/use-prefill.ts +0 -186
  131. package/src/ui/capture/use-schema-validation.ts +0 -145
  132. package/src/ui/capture/use-wizard.ts +0 -180
  133. package/src/ui/capture/value-format.ts +0 -32
  134. package/src/ui/capture/wizard.tsx +0 -105
  135. package/src/ui/charts/bar-chart.tsx +0 -139
  136. package/src/ui/charts/chart-frame.tsx +0 -125
  137. package/src/ui/charts/chart-types.ts +0 -52
  138. package/src/ui/charts/chart-utils.ts +0 -190
  139. package/src/ui/charts/charts.test.tsx +0 -204
  140. package/src/ui/charts/donut-chart.tsx +0 -129
  141. package/src/ui/charts/index.ts +0 -27
  142. package/src/ui/charts/line-chart.tsx +0 -202
  143. package/src/ui/charts/sparkline.tsx +0 -109
  144. package/src/ui/chrome/AsyncBoundary.tsx +0 -74
  145. package/src/ui/chrome/EmptyState.tsx +0 -257
  146. package/src/ui/chrome/ErrorCard.tsx +0 -63
  147. package/src/ui/chrome/LoadingState.tsx +0 -61
  148. package/src/ui/chrome/PageHeader.tsx +0 -137
  149. package/src/ui/chrome/RecordCardList.tsx +0 -98
  150. package/src/ui/chrome/StateCard.tsx +0 -150
  151. package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
  152. package/src/ui/chrome/page-shell.tsx +0 -189
  153. package/src/ui/chrome/scope-badge.tsx +0 -40
  154. package/src/ui/chrome/status-badge.tsx +0 -79
  155. package/src/ui/cn.ts +0 -32
  156. package/src/ui/design-tokens.ts +0 -372
  157. package/src/ui/hooks/use-debounced-value.ts +0 -16
  158. package/src/ui/hooks/use-is-mobile.ts +0 -28
  159. package/src/ui/index.ts +0 -110
  160. package/src/ui/pdf/pdf-preview.tsx +0 -122
  161. package/src/ui/primitives/alert-dialog.tsx +0 -104
  162. package/src/ui/primitives/async-combobox.tsx +0 -182
  163. package/src/ui/primitives/badge-variants.ts +0 -21
  164. package/src/ui/primitives/badge.tsx +0 -25
  165. package/src/ui/primitives/button-variants.ts +0 -31
  166. package/src/ui/primitives/button.tsx +0 -29
  167. package/src/ui/primitives/card.tsx +0 -43
  168. package/src/ui/primitives/checkbox.tsx +0 -26
  169. package/src/ui/primitives/collapsible.tsx +0 -9
  170. package/src/ui/primitives/dialog.tsx +0 -103
  171. package/src/ui/primitives/dropdown-menu.tsx +0 -179
  172. package/src/ui/primitives/form-stepper.tsx +0 -94
  173. package/src/ui/primitives/form-stepper.types.ts +0 -15
  174. package/src/ui/primitives/input.tsx +0 -22
  175. package/src/ui/primitives/label.tsx +0 -17
  176. package/src/ui/primitives/overflow-tabs.tsx +0 -331
  177. package/src/ui/primitives/popover.tsx +0 -33
  178. package/src/ui/primitives/preview-device-frame.tsx +0 -213
  179. package/src/ui/primitives/radio-group.tsx +0 -36
  180. package/src/ui/primitives/resizable.tsx +0 -67
  181. package/src/ui/primitives/scroll-area.tsx +0 -38
  182. package/src/ui/primitives/select.tsx +0 -143
  183. package/src/ui/primitives/separator.tsx +0 -20
  184. package/src/ui/primitives/sheet.tsx +0 -107
  185. package/src/ui/primitives/skeleton.tsx +0 -99
  186. package/src/ui/primitives/switch.tsx +0 -27
  187. package/src/ui/primitives/table.tsx +0 -72
  188. package/src/ui/primitives/tabs.tsx +0 -53
  189. package/src/ui/primitives/tag-multi-select.tsx +0 -261
  190. package/src/ui/primitives/textarea.tsx +0 -21
  191. package/src/ui/primitives/tooltip.tsx +0 -30
  192. package/src/ui/primitives/url-preview-chrome.tsx +0 -103
  193. package/src/vista/GenericCatalogueSurface.tsx +0 -179
  194. package/src/vista/SurfaceFallbackCard.tsx +0 -109
  195. package/src/vista/VistaPanel.tsx +0 -163
  196. package/src/vista/form-payload.spec.ts +0 -139
  197. package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
  198. package/src/vista/html/CustomUiFrame.tsx +0 -206
  199. package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
  200. package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
  201. package/src/vista/html/custom-ui-frame-contract.ts +0 -88
  202. package/src/vista/html/custom-ui-intents.spec.ts +0 -135
  203. package/src/vista/html/custom-ui-intents.ts +0 -155
  204. package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
  205. package/src/vista/html/custom-ui-srcdoc.ts +0 -193
  206. package/src/vista/html/index.ts +0 -13
  207. package/src/vista/index.ts +0 -52
  208. package/src/vista/surface-catalogue.spec.ts +0 -140
  209. package/src/vista/surface-catalogue.ts +0 -90
  210. package/src/vista/surface-icons.ts +0 -57
  211. package/src/vista/surface-registry.ts +0 -56
  212. package/src/vista/surfaces/ChartSurface.tsx +0 -34
  213. package/src/vista/surfaces/FilesSurface.tsx +0 -202
  214. package/src/vista/surfaces/FormSurface.tsx +0 -380
  215. package/src/vista/surfaces/HtmlSurface.tsx +0 -43
  216. package/src/vista/surfaces/TableSurface.tsx +0 -100
  217. package/src/vista/surfaces/UrlSurface.tsx +0 -40
  218. package/src/vista/surfaces/blob-surfaces.tsx +0 -139
  219. package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
  220. package/src/vista/surfaces/elicitation-transport.ts +0 -367
  221. package/src/vista/surfaces/file-surface-utils.ts +0 -69
  222. package/src/vista/surfaces/index.ts +0 -24
  223. package/src/vista/surfaces/register-surfaces.tsx +0 -139
  224. package/src/vista/surfaces/text-surfaces.tsx +0 -132
  225. package/src/vista/use-vista-tabs.ts +0 -196
  226. package/src/vista/vista-code-renderer-context.ts +0 -16
  227. package/src/vista/vista-code-renderer.tsx +0 -35
  228. package/src/vista/vista-file-context.ts +0 -14
  229. package/src/vista/vista-file-source.tsx +0 -141
  230. package/src/vista/vista-form-context.ts +0 -20
  231. package/src/vista/vista-form-host.tsx +0 -48
  232. package/src/vista/vista-model.ts +0 -137
  233. package/src/vista/vista-open-context.tsx +0 -27
  234. package/src/vista/vista-open-state.ts +0 -11
  235. package/src/vista/vista-payloads.ts +0 -635
  236. package/src/vista/vista-tabs-manifest.ts +0 -138
  237. package/src/vista/vista-tools.ts +0 -232
@@ -1,210 +0,0 @@
1
- import { DeeplinkTargetKind } from './enums';
2
-
3
- /**
4
- * Typed parse/resolve of the SystemBus `xema://` deeplink scheme.
5
- *
6
- * The deeplink scheme addresses *places in the running shell*. It is a
7
- * distinct, narrower grammar from the kernel's `XemaObjectRef`
8
- * (`xema://<scope>/<kind>/<slug>`): a deeplink's first segment is a
9
- * {@link DeeplinkTargetKind} discriminator, not a scope path. The two
10
- * schemes share the `xema://` scheme prefix but never the same body —
11
- * `parseDeeplink` rejects anything whose head is not a known target kind,
12
- * so an `XemaObjectRef` is only valid as a deeplink when wrapped as
13
- * `xema://object/<XemaObjectRef-without-scheme>`.
14
- *
15
- * Grammar:
16
- * xema://biome/<biomeId>/<route...>?<ctx> → BiomeRoute
17
- * xema://object/<scope>/<kind>/<slug>[@<ver>] → Object
18
- * xema://capability/<capability-ref>?<input> → Capability
19
- * xema://window/<windowId> → Window
20
- *
21
- * Every parse is fail-fast: an unknown target kind, a missing required
22
- * segment, or a malformed query is a {@link DeeplinkParseError}, never a
23
- * silent fallback.
24
- */
25
-
26
- const DEEPLINK_SCHEME = 'xema://';
27
-
28
- /** Structured, fail-fast error raised by `parseDeeplink`. */
29
- export class DeeplinkParseError extends Error {
30
- public readonly code = 'DEEPLINK_INVALID';
31
- public readonly raw: string;
32
- public readonly reason: string;
33
-
34
- public constructor(raw: string, reason: string) {
35
- super(`Invalid deeplink "${raw}": ${reason}`);
36
- this.name = 'DeeplinkParseError';
37
- this.raw = raw;
38
- this.reason = reason;
39
- }
40
- }
41
-
42
- /** A parsed `xema://biome/...` deeplink. */
43
- export interface BiomeRouteDeeplink {
44
- readonly kind: DeeplinkTargetKind.BiomeRoute;
45
- readonly biomeId: string;
46
- /** The route path within the biome, with a leading slash. */
47
- readonly route: string;
48
- /** Parsed `?ctx` query params, empty when absent. */
49
- readonly ctx: Readonly<Record<string, string>>;
50
- }
51
-
52
- /** A parsed `xema://object/...` deeplink. The body is the scheme-less
53
- * `XemaObjectRef` (e.g. `system/capability/kb.page.read@1`). */
54
- export interface ObjectDeeplink {
55
- readonly kind: DeeplinkTargetKind.Object;
56
- /** Full `XemaObjectRef` (`xema://` re-prefixed) for handing to the
57
- * kernel object resolver. */
58
- readonly objectRef: `xema://${string}`;
59
- }
60
-
61
- /** A parsed `xema://capability/...` deeplink. */
62
- export interface CapabilityDeeplink {
63
- readonly kind: DeeplinkTargetKind.Capability;
64
- /** The raw capability ref string (validated by the kernel
65
- * `parseCapabilityRef` when the host launches it). */
66
- readonly capabilityRef: string;
67
- /** Parsed `?...` query params used as launch input, empty when absent. */
68
- readonly input: Readonly<Record<string, string>>;
69
- }
70
-
71
- /** A parsed `xema://window/...` deeplink. */
72
- export interface WindowDeeplink {
73
- readonly kind: DeeplinkTargetKind.Window;
74
- readonly windowId: string;
75
- }
76
-
77
- /** Discriminated union of every deeplink target. */
78
- export type ParsedDeeplink =
79
- | BiomeRouteDeeplink
80
- | ObjectDeeplink
81
- | CapabilityDeeplink
82
- | WindowDeeplink;
83
-
84
- function parseQuery(search: string): Record<string, string> {
85
- const out: Record<string, string> = {};
86
- if (search.length === 0) {
87
- return out;
88
- }
89
- for (const pair of search.split('&')) {
90
- if (pair.length === 0) {
91
- continue;
92
- }
93
- const eq = pair.indexOf('=');
94
- if (eq === -1) {
95
- out[decodeURIComponent(pair)] = '';
96
- } else {
97
- out[decodeURIComponent(pair.slice(0, eq))] = decodeURIComponent(
98
- pair.slice(eq + 1),
99
- );
100
- }
101
- }
102
- return out;
103
- }
104
-
105
- /**
106
- * Parse a `xema://` deeplink string into a typed, discriminated
107
- * {@link ParsedDeeplink}. Throws {@link DeeplinkParseError} on any
108
- * malformed input — never returns null, never coerces.
109
- */
110
- export function parseDeeplink(raw: string): ParsedDeeplink {
111
- if (typeof raw !== 'string' || !raw.startsWith(DEEPLINK_SCHEME)) {
112
- throw new DeeplinkParseError(
113
- String(raw),
114
- `must start with "${DEEPLINK_SCHEME}"`,
115
- );
116
- }
117
- const afterScheme = raw.slice(DEEPLINK_SCHEME.length);
118
- if (afterScheme.length === 0) {
119
- throw new DeeplinkParseError(raw, 'empty body after scheme');
120
- }
121
-
122
- const qIndex = afterScheme.indexOf('?');
123
- const path = qIndex === -1 ? afterScheme : afterScheme.slice(0, qIndex);
124
- const search = qIndex === -1 ? '' : afterScheme.slice(qIndex + 1);
125
- const segments = path.split('/').filter((s) => s.length > 0);
126
-
127
- const head = segments[0];
128
- if (head === undefined) {
129
- throw new DeeplinkParseError(raw, 'missing target-kind head segment');
130
- }
131
-
132
- switch (head) {
133
- case DeeplinkTargetKind.BiomeRoute: {
134
- const biomeId = segments[1];
135
- if (biomeId === undefined) {
136
- throw new DeeplinkParseError(raw, 'biome deeplink missing <biomeId>');
137
- }
138
- const routeSegments = segments.slice(2);
139
- const route = `/${routeSegments.join('/')}`;
140
- return {
141
- kind: DeeplinkTargetKind.BiomeRoute,
142
- biomeId,
143
- route,
144
- ctx: parseQuery(search),
145
- };
146
- }
147
- case DeeplinkTargetKind.Object: {
148
- const body = segments.slice(1).join('/');
149
- if (body.length === 0) {
150
- throw new DeeplinkParseError(
151
- raw,
152
- 'object deeplink missing <XemaObjectRef>',
153
- );
154
- }
155
- return {
156
- kind: DeeplinkTargetKind.Object,
157
- objectRef: `${DEEPLINK_SCHEME}${body}`,
158
- };
159
- }
160
- case DeeplinkTargetKind.Capability: {
161
- const capabilityRef = segments.slice(1).join('/');
162
- if (capabilityRef.length === 0) {
163
- throw new DeeplinkParseError(
164
- raw,
165
- 'capability deeplink missing <capability-ref>',
166
- );
167
- }
168
- return {
169
- kind: DeeplinkTargetKind.Capability,
170
- capabilityRef,
171
- input: parseQuery(search),
172
- };
173
- }
174
- case DeeplinkTargetKind.Window: {
175
- const windowId = segments[1];
176
- if (windowId === undefined) {
177
- throw new DeeplinkParseError(raw, 'window deeplink missing <windowId>');
178
- }
179
- return { kind: DeeplinkTargetKind.Window, windowId };
180
- }
181
- default:
182
- throw new DeeplinkParseError(
183
- raw,
184
- `unknown deeplink target kind "${head}" (expected one of: ${Object.values(
185
- DeeplinkTargetKind,
186
- ).join(', ')})`,
187
- );
188
- }
189
- }
190
-
191
- /**
192
- * The `deeplink` surface of the SystemBus. `parse` is pure
193
- * (framework-agnostic) and re-exported from the runtime as
194
- * {@link parseDeeplink}. `resolve` navigates the running shell to the
195
- * parsed target; the host supplies the concrete navigation. Resolution
196
- * is orchestration only — for a capability target the actual auth check
197
- * happens when `capability.invoke` reaches the backend router.
198
- */
199
- export interface DeeplinkBus {
200
- /** Parse a `xema://` deeplink string. Throws on malformed input. */
201
- parse(raw: string): ParsedDeeplink;
202
- /**
203
- * Navigate the running shell to the deeplink target. The host
204
- * implements the actual navigation (biome route push, object detail
205
- * open, capability launch, window focus). Rejects if the target cannot
206
- * be resolved (e.g. unknown biome / window) — fail-fast, no silent
207
- * no-op.
208
- */
209
- resolve(target: string | ParsedDeeplink): Promise<void>;
210
- }
@@ -1,86 +0,0 @@
1
- /**
2
- * Closed sets for the `SystemBus` contract.
3
- *
4
- * Every closed domain the SystemBus exposes is a real TypeScript enum so
5
- * the contract is stable across hosts and serialises predictably. The
6
- * `ObjectKind` domain deliberately REUSES the kernel's
7
- * {@link XemaObjectKind} rather than re-declaring a parallel set — see
8
- * `intents.ts`. The enums below describe SystemBus-specific closed
9
- * domains that have no kernel equivalent.
10
- */
11
-
12
- /**
13
- * The kind of target a `xema://` deeplink addresses. The deeplink scheme
14
- * is intentionally narrower than the full `XemaObjectRef` grammar — a
15
- * deeplink resolves to a *place in the running shell* (a biome route, an
16
- * object detail page, a capability launcher, a window), not to every
17
- * addressable object. New target kinds are added here by one-line kernel
18
- * change; an unknown target kind is a fail-fast parse error.
19
- */
20
- export enum DeeplinkTargetKind {
21
- /** `xema://biome/<biomeId>/<route>?<ctx>` — navigate to a biome route. */
22
- BiomeRoute = 'biome-route',
23
- /** `xema://object/<xema-object-ref>` — open an object's detail surface. */
24
- Object = 'object',
25
- /** `xema://capability/<capability-ref>?<input>` — launch a capability. */
26
- Capability = 'capability',
27
- /** `xema://window/<windowId>` — focus an already-open window. */
28
- Window = 'window',
29
- }
30
-
31
- /**
32
- * Window operations the host window manager exposes through
33
- * `SystemBus.windows`. Closed set — a host that cannot honour an op
34
- * (e.g. a single-window mobile shell) fails fast rather than silently
35
- * degrading; the SystemBus never invents a partial window model.
36
- */
37
- export enum WindowOp {
38
- Open = 'open',
39
- Focus = 'focus',
40
- Close = 'close',
41
- Arrange = 'arrange',
42
- }
43
-
44
- /**
45
- * Layout arrangements a host may apply to its open windows when
46
- * `WindowOp.Arrange` is requested. Closed set so the contract is stable
47
- * across desktop / tiling / tabbed shells.
48
- */
49
- export enum WindowArrangement {
50
- /** Tile all open windows in a grid. */
51
- Tile = 'tile',
52
- /** Stack windows with the focused one on top. */
53
- Stack = 'stack',
54
- /** Cascade windows with a fixed offset. */
55
- Cascade = 'cascade',
56
- /** Maximise the focused window, hide the rest. */
57
- Maximize = 'maximize',
58
- }
59
-
60
- /**
61
- * The kind of action an intent provides. An intent contributes either a
62
- * cross-biome *capability* launch ("Send to Slack" → a capability ref)
63
- * or an in-shell *deeplink* navigation ("Open with Document Buddy" → a
64
- * biome route). Closed set — these are the only two ways one biome can
65
- * hand an object to another without importing it.
66
- */
67
- export enum ActionRefKind {
68
- /** Resolves to a `CapabilityRef` invoked through `capability.invoke`. */
69
- Capability = 'capability',
70
- /** Resolves to a `xema://` deeplink navigated through `deeplink`. */
71
- Deeplink = 'deeplink',
72
- }
73
-
74
- /**
75
- * The source that contributed a palette entry. The palette is the union
76
- * of (a) every capability the actor may invoke (sourced from
77
- * `capability-registry-api`) and (b) every registered cross-biome intent
78
- * action. This enum tags each entry's provenance so the UI can group /
79
- * filter and so the host knows which subsystem resolves the entry.
80
- */
81
- export enum PaletteEntrySource {
82
- /** Backed by a capability descriptor from `capability-registry-api`. */
83
- Capability = 'capability',
84
- /** Backed by a registered intent (`intents.register`). */
85
- Intent = 'intent',
86
- }
@@ -1,93 +0,0 @@
1
- import type {
2
- CapabilityInvokeMeta,
3
- CapabilityInvokeResult,
4
- } from './capability-invoke';
5
- import type { ParsedDeeplink } from './deeplink';
6
- import type { WindowArrangement } from './enums';
7
- import type { PaletteEntry, PaletteQuery } from './palette';
8
- import type { OpenWindowRequest, WindowId, WindowState } from './windows';
9
- import type { CapabilityRef } from '@xemahq/kernel-contracts/capability';
10
-
11
- /**
12
- * Framework-agnostic host ports the concrete host implements so the
13
- * SystemBus sub-buses can be constructed by the framework-agnostic
14
- * `buildSystemBus` assembler (shipped by this kernel).
15
- *
16
- * These ports carry NO React, NO router, NO transport client — they are
17
- * the seam between "the SystemBus contract" (kernel) and "this host's
18
- * real backend + shell" (the Next.js App Router host). The assembler wires a
19
- * `SystemBus` out of `IntentRegistry` + `parseDeeplink` (both already in
20
- * the kernel) PLUS these three host-supplied ports. A missing port is a
21
- * wiring bug and MUST fail fast at bridge construction — never a silent
22
- * no-op.
23
- *
24
- * None of these ports authorize. `CapabilityInvoker` relays to the
25
- * backend capability-router (the single authority); `PaletteSource`
26
- * indexes an already-actor-scoped registry; `WindowManager` is pure
27
- * shell orchestration; `DeeplinkResolver` navigates. Policy lives in the
28
- * backend, full stop.
29
- */
30
-
31
- /**
32
- * Port the host implements to relay a `capability.invoke` to the backend
33
- * capability-router. The adapter wraps this into `SystemBus.capability`.
34
- *
35
- * The host implementation POSTs the router's invoke endpoint with the
36
- * Gate-E `ExecutionContext` built from {@link CapabilityInvokeMeta}. It
37
- * MUST surface a policy denial as the typed result (`output === undefined`
38
- * + populated `auditId`) and MUST reject on transport failure (fail-fast).
39
- * It adds NO authorization of its own.
40
- */
41
- export interface CapabilityInvoker {
42
- invoke<TInput = unknown, TOutput = unknown>(
43
- ref: CapabilityRef,
44
- input: TInput,
45
- meta: CapabilityInvokeMeta,
46
- ): Promise<CapabilityInvokeResult<TOutput>>;
47
- }
48
-
49
- /**
50
- * Port the host implements to source the capability half of the command
51
- * palette from `capability-registry-api` (already actor-scoped
52
- * server-side). The intent half is sourced by the adapter from the
53
- * SystemBus `IntentRegistry`; the adapter merges both behind
54
- * `SystemBus.palette`.
55
- *
56
- * `queryCapabilities` returns ONLY capability-backed entries; the adapter
57
- * unions them with intent entries and applies the host ranker.
58
- * `subscribe` fires when the capability source refreshes so a palette
59
- * overlay can re-query without polling. Returns an unsubscribe fn.
60
- */
61
- export interface PaletteSource {
62
- queryCapabilities(query: PaletteQuery): Promise<readonly PaletteEntry[]>;
63
- subscribe(listener: () => void): () => void;
64
- }
65
-
66
- /**
67
- * Port the host implements to realise the window plane. The adapter
68
- * exposes it verbatim as `SystemBus.windows`. Every op maps to a closed
69
- * {@link WindowArrangement}/`WindowOp`; an op a host cannot honour MUST
70
- * reject fail-fast rather than silently no-op.
71
- */
72
- export interface WindowManager {
73
- open(request: OpenWindowRequest): Promise<WindowId>;
74
- focus(id: WindowId): Promise<void>;
75
- close(id: WindowId): Promise<void>;
76
- arrange(arrangement: WindowArrangement): Promise<void>;
77
- list(): readonly WindowState[];
78
- subscribe(listener: () => void): () => void;
79
- }
80
-
81
- /**
82
- * Port the host implements to navigate the running shell to a parsed
83
- * deeplink target. The adapter combines kernel `parseDeeplink` (pure)
84
- * with this host-supplied `resolve` to build `SystemBus.deeplink`.
85
- *
86
- * `resolve` receives the ALREADY-PARSED, validated target (the adapter
87
- * parses first, so a malformed deeplink fails fast before the host sees
88
- * it). It MUST reject when the target cannot be resolved (unknown biome /
89
- * window) — fail-fast, never a silent no-op.
90
- */
91
- export interface DeeplinkResolver {
92
- resolve(target: ParsedDeeplink): Promise<void>;
93
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * SystemBus — the framework-agnostic OS-orchestration contract plane
3
- * Pure types + a small framework-agnostic runtime
4
- * ({@link IntentRegistry} + {@link parseDeeplink}). No React, no Vite, no
5
- * Next.js, no React-Router, no transport client.
6
- */
7
- export * from './enums';
8
- export * from './capability-invoke';
9
- export * from './intents';
10
- export * from './intent-registry';
11
- export * from './deeplink';
12
- export * from './palette';
13
- export * from './windows';
14
- export * from './host-ports';
15
- export * from './system-bus';
16
- export * from './system-bus-builder';
@@ -1,109 +0,0 @@
1
- import {
2
- parseXemaObjectRef,
3
- type XemaObjectKind,
4
- type XemaObjectRef,
5
- } from '@xemahq/kernel-contracts/object';
6
-
7
- import { ActionRefKind } from './enums';
8
-
9
- import type { IntentBus, IntentRegistration, ResolvedIntent } from './intents';
10
-
11
- const VALID_ACTION_KINDS: ReadonlySet<ActionRefKind> = new Set([
12
- ActionRefKind.Capability,
13
- ActionRefKind.Deeplink,
14
- ]);
15
-
16
- function assertValidRegistration(registration: IntentRegistration): void {
17
- if (!registration.biomeId) {
18
- throw new Error('[xema-ui-kernel] IntentRegistration.biomeId is required.');
19
- }
20
- for (const action of registration.provides) {
21
- if (!VALID_ACTION_KINDS.has(action.kind)) {
22
- throw new Error(
23
- `[xema-ui-kernel] IntentRegistration from "${registration.biomeId}" ` +
24
- `has an ActionRef with unknown kind "${action.kind}". ` +
25
- `Expected one of: ${[...VALID_ACTION_KINDS].join(', ')}.`,
26
- );
27
- }
28
- }
29
- }
30
-
31
- /**
32
- * Framework-agnostic, in-memory implementation of {@link IntentBus}.
33
- *
34
- * No React, no router — a plain registry a host can instantiate once and
35
- * expose through `SystemBus.intents`. Registration order is preserved so
36
- * `resolve` returns actions deterministically (first-registered first).
37
- * Re-registering the same `biomeId` REPLACES its prior contribution while
38
- * keeping its original ordering slot (HMR / re-bootstrap safe).
39
- *
40
- * Pure orchestration: it indexes and resolves contributions and performs
41
- * no authorization. Whether the actor may run a resolved action is decided
42
- * when the action fires.
43
- */
44
- export class IntentRegistry implements IntentBus {
45
- /** Insertion-ordered map: biomeId → its registration. */
46
- private readonly registrations = new Map<string, IntentRegistration>();
47
- private readonly listeners = new Set<() => void>();
48
-
49
- register(registration: IntentRegistration): void {
50
- assertValidRegistration(registration);
51
- // Map preserves first-insertion order; deleting then setting on an
52
- // update would move it to the end, so only delete when truly replacing.
53
- this.registrations.set(registration.biomeId, registration);
54
- this.notify();
55
- }
56
-
57
- unregister(biomeId: string): boolean {
58
- const removed = this.registrations.delete(biomeId);
59
- if (removed) {
60
- this.notify();
61
- }
62
- return removed;
63
- }
64
-
65
- resolve(kind: XemaObjectKind): readonly ResolvedIntent[] {
66
- const out: ResolvedIntent[] = [];
67
- for (const registration of this.registrations.values()) {
68
- if (!registration.handles.includes(kind)) {
69
- continue;
70
- }
71
- for (const action of registration.provides) {
72
- out.push({ biomeId: registration.biomeId, action });
73
- }
74
- }
75
- return out;
76
- }
77
-
78
- resolveForObject(ref: XemaObjectRef): readonly ResolvedIntent[] {
79
- // Fail-fast on a malformed ref rather than returning an empty menu —
80
- // a bad ref is a wiring bug, not "no handlers".
81
- const { kind } = parseXemaObjectRef(ref);
82
- return this.resolve(kind);
83
- }
84
-
85
- /**
86
- * Insertion-ordered snapshot of every current registration. The command
87
- * palette needs every provided action regardless of object kind (unlike
88
- * `resolve`, which filters by a single kind), so it reads this snapshot
89
- * and flattens `provides`. Returns a defensive shallow copy — callers
90
- * MUST NOT mutate the registry through it.
91
- */
92
- snapshot(): readonly IntentRegistration[] {
93
- return [...this.registrations.values()];
94
- }
95
-
96
- /** Subscribe to registry changes; returns an unsubscribe fn. */
97
- subscribe(listener: () => void): () => void {
98
- this.listeners.add(listener);
99
- return () => {
100
- this.listeners.delete(listener);
101
- };
102
- }
103
-
104
- private notify(): void {
105
- for (const listener of this.listeners) {
106
- listener();
107
- }
108
- }
109
- }
@@ -1,113 +0,0 @@
1
- import { type ActionRefKind } from './enums';
2
-
3
- import type { CapabilityRef } from '@xemahq/kernel-contracts/capability';
4
- import type {
5
- XemaObjectKind,
6
- XemaObjectRef,
7
- } from '@xemahq/kernel-contracts/object';
8
-
9
- /**
10
- * Cross-biome intent registry — the "Open with… / Send to…" plane.
11
- *
12
- * A biome registers the object kinds it can *handle* and the actions it
13
- * *provides*. When the user invokes "Open with… / Send to…" on an object,
14
- * `intents.resolve(kind)` returns every action any biome registered for
15
- * that kind. This is how one biome hands an object to another WITHOUT
16
- * importing it — the macOS "Open With" / Share-Sheet analogy from the
17
- * platform design.
18
- *
19
- * The registry is pure orchestration: it indexes contributions and
20
- * resolves them. It performs NO authorization — whether the actor may
21
- * actually run a resolved action is decided when the action fires
22
- * (`capability.invoke` → backend router for capability actions; the host
23
- * navigation guard for deeplink actions).
24
- */
25
-
26
- /**
27
- * A resolvable cross-biome action. Discriminated on {@link ActionRefKind}
28
- * so a single resolved list can mix capability launches and deeplink
29
- * navigations. Closed via the enum — there is no third way to hand an
30
- * object across biomes.
31
- */
32
- export type ActionRef =
33
- | {
34
- readonly kind: ActionRefKind.Capability;
35
- /** Stable id, unique within the providing biome. */
36
- readonly id: string;
37
- /** Human label rendered in the "Send to…" menu. */
38
- readonly label: string;
39
- /** The capability the action invokes. */
40
- readonly capabilityRef: CapabilityRef;
41
- }
42
- | {
43
- readonly kind: ActionRefKind.Deeplink;
44
- /** Stable id, unique within the providing biome. */
45
- readonly id: string;
46
- /** Human label rendered in the "Open with…" menu. */
47
- readonly label: string;
48
- /**
49
- * Deeplink template the action navigates to. The host substitutes
50
- * the selected object's ref into the template before navigating
51
- * (e.g. `xema://biome/document-buddy/edit?object={ref}`).
52
- */
53
- readonly deeplinkTemplate: string;
54
- };
55
-
56
- /**
57
- * One biome's intent contribution. `handles` is the closed set of object
58
- * kinds this biome can receive; `provides` is the set of actions it
59
- * offers for those kinds. Both reference the kernel's {@link XemaObjectKind}
60
- * so the contract never drifts from the canonical object universe.
61
- */
62
- export interface IntentRegistration {
63
- /** Biome that owns this registration (provenance + dedup key). */
64
- readonly biomeId: string;
65
- /** Object kinds this biome can be a target of ("Open with…"). */
66
- readonly handles: readonly XemaObjectKind[];
67
- /** Actions this biome provides for the handled kinds. */
68
- readonly provides: readonly ActionRef[];
69
- }
70
-
71
- /**
72
- * A resolved intent action for a specific object kind — an {@link ActionRef}
73
- * tagged with the biome that provides it. Returned by `intents.resolve`.
74
- */
75
- export interface ResolvedIntent {
76
- readonly biomeId: string;
77
- readonly action: ActionRef;
78
- }
79
-
80
- /**
81
- * The `intents` surface of the SystemBus. Framework-agnostic runtime
82
- * registry — no React, no router. Hosts drive it at biome bootstrap
83
- * (`register`) and at "Open with…" menu build time (`resolve`).
84
- */
85
- export interface IntentBus {
86
- /**
87
- * Register a biome's intent contribution. Idempotent per `biomeId`:
88
- * re-registering the same biome REPLACES its prior contribution (HMR /
89
- * re-bootstrap safe). Fail-fast on a malformed registration (e.g. an
90
- * `ActionRef` whose `kind` is outside {@link ActionRefKind}).
91
- */
92
- register(registration: IntentRegistration): void;
93
-
94
- /**
95
- * Remove a biome's intent contribution (admin disable / unregister).
96
- * Returns `true` if a registration was removed.
97
- */
98
- unregister(biomeId: string): boolean;
99
-
100
- /**
101
- * Resolve every action any biome registered for `kind`, in stable
102
- * registration order. Returns an empty array when no biome handles the
103
- * kind — the caller renders an empty "Open with…" menu, never an error.
104
- */
105
- resolve(kind: XemaObjectKind): readonly ResolvedIntent[];
106
-
107
- /**
108
- * Resolve actions for a concrete object ref. Convenience over
109
- * `resolve(kind)` that parses the kind out of the `XemaObjectRef` and
110
- * is the entry point the "Open with…" menu uses on a selected object.
111
- */
112
- resolveForObject(ref: XemaObjectRef): readonly ResolvedIntent[];
113
- }