@xemahq/ui-kernel 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/errors/http-error-status.d.ts +17 -0
  2. package/dist/errors/http-error-status.d.ts.map +1 -0
  3. package/dist/errors/http-error-status.js +59 -0
  4. package/dist/errors/http-error-status.js.map +1 -0
  5. package/dist/errors/index.d.ts +2 -0
  6. package/dist/errors/index.d.ts.map +1 -0
  7. package/dist/errors/index.js +2 -0
  8. package/dist/errors/index.js.map +1 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/biome-host/errors.d.ts.map +1 -1
  14. package/dist/lib/biome-host/errors.js +1 -19
  15. package/dist/lib/biome-host/errors.js.map +1 -1
  16. package/dist/offline/index.d.ts.map +1 -1
  17. package/dist/offline/index.js.map +1 -1
  18. package/dist/offline/online-controller.d.ts.map +1 -1
  19. package/dist/offline/online-controller.js +6 -1
  20. package/dist/offline/online-controller.js.map +1 -1
  21. package/dist/offline/outbox.d.ts.map +1 -1
  22. package/dist/offline/outbox.js +2 -24
  23. package/dist/offline/outbox.js.map +1 -1
  24. package/package.json +1 -2
  25. package/src/index.ts +0 -17
  26. package/src/lib/biome-host/agent-validation.ts +0 -239
  27. package/src/lib/biome-host/biome-builders.ts +0 -112
  28. package/src/lib/biome-host/biome-mode.ts +0 -6
  29. package/src/lib/biome-host/biome-navigation.ts +0 -37
  30. package/src/lib/biome-host/biome-registry.ts +0 -299
  31. package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
  32. package/src/lib/biome-host/biome-scope.tsx +0 -52
  33. package/src/lib/biome-host/biome-scoped-query.ts +0 -134
  34. package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
  35. package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
  36. package/src/lib/biome-host/define-web-biome.ts +0 -222
  37. package/src/lib/biome-host/errors.ts +0 -220
  38. package/src/lib/biome-host/frontend-biome.ts +0 -256
  39. package/src/lib/biome-host/host-bridge.ts +0 -281
  40. package/src/lib/biome-host/host-sources.ts +0 -54
  41. package/src/lib/biome-host/i18n-hooks.ts +0 -51
  42. package/src/lib/biome-host/i18n-port.test.ts +0 -50
  43. package/src/lib/biome-host/i18n-port.ts +0 -96
  44. package/src/lib/biome-host/index.ts +0 -35
  45. package/src/lib/biome-host/realtime-hooks.ts +0 -75
  46. package/src/lib/biome-host/realtime-port.ts +0 -115
  47. package/src/lib/biome-host/session-contributions.ts +0 -296
  48. package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
  49. package/src/lib/biome-host/use-page-state.ts +0 -248
  50. package/src/lib/capabilities/capability-context.ts +0 -25
  51. package/src/lib/capabilities/capability-provider.tsx +0 -73
  52. package/src/lib/capabilities/index.ts +0 -17
  53. package/src/lib/capabilities/types.ts +0 -69
  54. package/src/lib/capabilities/use-capability.ts +0 -79
  55. package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
  56. package/src/lib/contribution-registry/contribution-registry.ts +0 -204
  57. package/src/lib/contribution-registry/index.ts +0 -9
  58. package/src/lib/contribution-registry/renderable-registry.ts +0 -142
  59. package/src/lib/system-bus/capability-invoke.ts +0 -92
  60. package/src/lib/system-bus/deeplink.ts +0 -210
  61. package/src/lib/system-bus/enums.ts +0 -86
  62. package/src/lib/system-bus/host-ports.ts +0 -93
  63. package/src/lib/system-bus/index.ts +0 -16
  64. package/src/lib/system-bus/intent-registry.ts +0 -109
  65. package/src/lib/system-bus/intents.ts +0 -113
  66. package/src/lib/system-bus/palette.ts +0 -78
  67. package/src/lib/system-bus/system-bus-builder.ts +0 -159
  68. package/src/lib/system-bus/system-bus.ts +0 -37
  69. package/src/lib/system-bus/windows.ts +0 -51
  70. package/src/offline/id.ts +0 -16
  71. package/src/offline/index.ts +0 -54
  72. package/src/offline/mutation.ts +0 -75
  73. package/src/offline/offline-status-badge.tsx +0 -51
  74. package/src/offline/online-controller.ts +0 -105
  75. package/src/offline/outbox.test.ts +0 -172
  76. package/src/offline/outbox.ts +0 -348
  77. package/src/offline/react-hooks.ts +0 -40
  78. package/src/offline/react.tsx +0 -32
  79. package/src/offline/storage.ts +0 -112
  80. package/src/offline/types.ts +0 -77
  81. package/src/org-db/components/DbResultTable.tsx +0 -176
  82. package/src/org-db/index.ts +0 -1
  83. package/src/pdf/index.ts +0 -11
  84. package/src/registry/index.ts +0 -9
  85. package/src/registry/lib/agent-validation-host.ts +0 -36
  86. package/src/registry/lib/biome-slot.tsx +0 -50
  87. package/src/registry/lib/biomes-enabled-context.ts +0 -20
  88. package/src/registry/lib/extension-points.ts +0 -134
  89. package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
  90. package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
  91. package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
  92. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
  93. package/src/registry/lib/primitives/index.ts +0 -18
  94. package/src/registry/lib/session-context-builder.ts +0 -84
  95. package/src/registry/lib/session-context-provider.tsx +0 -33
  96. package/src/registry/lib/session-context.ts +0 -21
  97. package/src/registry/lib/session-selectors.ts +0 -272
  98. package/src/session/comments/CommentRail.tsx +0 -164
  99. package/src/session/index.ts +0 -3
  100. package/src/session/lib/cn.ts +0 -11
  101. package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
  102. package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
  103. package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
  104. package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
  105. package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
  106. package/src/session-kit/approvals/Obligation.tsx +0 -111
  107. package/src/session-kit/approvals/ScopedBody.tsx +0 -392
  108. package/src/session-kit/approvals/approval-icons.ts +0 -31
  109. package/src/session-kit/approvals/approval-model.ts +0 -204
  110. package/src/session-kit/approvals/index.ts +0 -22
  111. package/src/session-kit/approvals/obligation-display.ts +0 -100
  112. package/src/session-kit/approvals/risk-accent.ts +0 -47
  113. package/src/session-kit/approvals/scope-icons.ts +0 -19
  114. package/src/session-kit/combobox/Combobox.tsx +0 -358
  115. package/src/session-kit/combobox/use-click-outside.ts +0 -21
  116. package/src/session-kit/display/ContextHeader.tsx +0 -148
  117. package/src/session-kit/display/FileDiffCard.tsx +0 -140
  118. package/src/session-kit/display/MD.tsx +0 -162
  119. package/src/session-kit/display/MessageTurn.tsx +0 -157
  120. package/src/session-kit/display/ThinkingPanel.tsx +0 -81
  121. package/src/session-kit/display/TodoChecklist.tsx +0 -120
  122. package/src/session-kit/display/TokenMeter.tsx +0 -89
  123. package/src/session-kit/display/ToolStrip.tsx +0 -278
  124. package/src/session-kit/display/TypingDots.tsx +0 -24
  125. package/src/session-kit/index.ts +0 -44
  126. package/src/session-kit/lib/enums.ts +0 -66
  127. package/src/session-kit/lib/portal-accent.ts +0 -30
  128. package/src/session-kit/lib/status-dot.ts +0 -68
  129. package/src/session-kit/primitives/Avatar.tsx +0 -44
  130. package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
  131. package/src/session-kit/primitives/RiskPill.tsx +0 -95
  132. package/src/session-kit/primitives/ScopeDot.tsx +0 -47
  133. package/src/session-kit/primitives/Segmented.tsx +0 -71
  134. package/src/ui/branding/app-branding-context.ts +0 -20
  135. package/src/ui/branding/app-branding-provider.tsx +0 -123
  136. package/src/ui/branding/sanitize.ts +0 -89
  137. package/src/ui/breakpoints.ts +0 -14
  138. package/src/ui/capture/document-preview.tsx +0 -166
  139. package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
  140. package/src/ui/capture/field-spec-to-zod.ts +0 -174
  141. package/src/ui/capture/field-spec-validate.ts +0 -236
  142. package/src/ui/capture/field-spec.test.ts +0 -49
  143. package/src/ui/capture/field-spec.ts +0 -274
  144. package/src/ui/capture/index.ts +0 -51
  145. package/src/ui/capture/schema-field-input.tsx +0 -620
  146. package/src/ui/capture/schema-form.tsx +0 -149
  147. package/src/ui/capture/submit-values.test.ts +0 -70
  148. package/src/ui/capture/submit-values.ts +0 -63
  149. package/src/ui/capture/use-prefill.ts +0 -186
  150. package/src/ui/capture/use-schema-validation.ts +0 -145
  151. package/src/ui/capture/use-wizard.ts +0 -180
  152. package/src/ui/capture/value-format.ts +0 -32
  153. package/src/ui/capture/wizard.tsx +0 -105
  154. package/src/ui/charts/bar-chart.tsx +0 -139
  155. package/src/ui/charts/chart-frame.tsx +0 -125
  156. package/src/ui/charts/chart-types.ts +0 -52
  157. package/src/ui/charts/chart-utils.ts +0 -190
  158. package/src/ui/charts/charts.test.tsx +0 -204
  159. package/src/ui/charts/donut-chart.tsx +0 -129
  160. package/src/ui/charts/index.ts +0 -27
  161. package/src/ui/charts/line-chart.tsx +0 -202
  162. package/src/ui/charts/sparkline.tsx +0 -109
  163. package/src/ui/chrome/AsyncBoundary.tsx +0 -74
  164. package/src/ui/chrome/EmptyState.tsx +0 -257
  165. package/src/ui/chrome/ErrorCard.tsx +0 -63
  166. package/src/ui/chrome/LoadingState.tsx +0 -61
  167. package/src/ui/chrome/PageHeader.tsx +0 -137
  168. package/src/ui/chrome/RecordCardList.tsx +0 -98
  169. package/src/ui/chrome/StateCard.tsx +0 -150
  170. package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
  171. package/src/ui/chrome/page-shell.spec.tsx +0 -117
  172. package/src/ui/chrome/page-shell.tsx +0 -221
  173. package/src/ui/chrome/scope-badge.tsx +0 -40
  174. package/src/ui/chrome/status-badge.tsx +0 -79
  175. package/src/ui/cn.ts +0 -32
  176. package/src/ui/design-tokens.ts +0 -372
  177. package/src/ui/hooks/use-debounced-value.ts +0 -16
  178. package/src/ui/hooks/use-is-mobile.ts +0 -28
  179. package/src/ui/index.ts +0 -110
  180. package/src/ui/pdf/pdf-preview.tsx +0 -122
  181. package/src/ui/primitives/alert-dialog.tsx +0 -104
  182. package/src/ui/primitives/async-combobox.tsx +0 -182
  183. package/src/ui/primitives/badge-variants.ts +0 -21
  184. package/src/ui/primitives/badge.tsx +0 -25
  185. package/src/ui/primitives/button-variants.ts +0 -31
  186. package/src/ui/primitives/button.tsx +0 -29
  187. package/src/ui/primitives/card.tsx +0 -43
  188. package/src/ui/primitives/checkbox.tsx +0 -26
  189. package/src/ui/primitives/collapsible.tsx +0 -9
  190. package/src/ui/primitives/dialog.tsx +0 -103
  191. package/src/ui/primitives/dropdown-menu.tsx +0 -179
  192. package/src/ui/primitives/form-stepper.tsx +0 -94
  193. package/src/ui/primitives/form-stepper.types.ts +0 -15
  194. package/src/ui/primitives/input.tsx +0 -22
  195. package/src/ui/primitives/label.tsx +0 -17
  196. package/src/ui/primitives/overflow-tabs.tsx +0 -331
  197. package/src/ui/primitives/popover.tsx +0 -33
  198. package/src/ui/primitives/preview-device-frame.tsx +0 -213
  199. package/src/ui/primitives/radio-group.tsx +0 -36
  200. package/src/ui/primitives/resizable.tsx +0 -67
  201. package/src/ui/primitives/scroll-area.tsx +0 -38
  202. package/src/ui/primitives/select.tsx +0 -143
  203. package/src/ui/primitives/separator.tsx +0 -20
  204. package/src/ui/primitives/sheet.tsx +0 -107
  205. package/src/ui/primitives/skeleton.tsx +0 -99
  206. package/src/ui/primitives/switch.tsx +0 -27
  207. package/src/ui/primitives/table.tsx +0 -72
  208. package/src/ui/primitives/tabs.tsx +0 -53
  209. package/src/ui/primitives/tag-multi-select.tsx +0 -261
  210. package/src/ui/primitives/textarea.tsx +0 -21
  211. package/src/ui/primitives/tooltip.tsx +0 -30
  212. package/src/ui/primitives/url-preview-chrome.tsx +0 -103
  213. package/src/vista/GenericCatalogueSurface.tsx +0 -179
  214. package/src/vista/SurfaceFallbackCard.tsx +0 -109
  215. package/src/vista/VistaPanel.tsx +0 -163
  216. package/src/vista/form-payload.spec.ts +0 -139
  217. package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
  218. package/src/vista/html/CustomUiFrame.tsx +0 -206
  219. package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
  220. package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
  221. package/src/vista/html/custom-ui-frame-contract.ts +0 -88
  222. package/src/vista/html/custom-ui-intents.spec.ts +0 -135
  223. package/src/vista/html/custom-ui-intents.ts +0 -155
  224. package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
  225. package/src/vista/html/custom-ui-srcdoc.ts +0 -193
  226. package/src/vista/html/index.ts +0 -13
  227. package/src/vista/index.ts +0 -52
  228. package/src/vista/surface-catalogue.spec.ts +0 -140
  229. package/src/vista/surface-catalogue.ts +0 -90
  230. package/src/vista/surface-icons.ts +0 -57
  231. package/src/vista/surface-registry.ts +0 -56
  232. package/src/vista/surfaces/ChartSurface.tsx +0 -34
  233. package/src/vista/surfaces/FilesSurface.tsx +0 -202
  234. package/src/vista/surfaces/FormSurface.tsx +0 -380
  235. package/src/vista/surfaces/HtmlSurface.tsx +0 -43
  236. package/src/vista/surfaces/TableSurface.tsx +0 -100
  237. package/src/vista/surfaces/UrlSurface.tsx +0 -40
  238. package/src/vista/surfaces/blob-surfaces.tsx +0 -139
  239. package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
  240. package/src/vista/surfaces/elicitation-transport.ts +0 -367
  241. package/src/vista/surfaces/file-surface-utils.ts +0 -69
  242. package/src/vista/surfaces/index.ts +0 -24
  243. package/src/vista/surfaces/register-surfaces.tsx +0 -139
  244. package/src/vista/surfaces/text-surfaces.tsx +0 -132
  245. package/src/vista/use-vista-tabs.ts +0 -196
  246. package/src/vista/vista-code-renderer-context.ts +0 -16
  247. package/src/vista/vista-code-renderer.tsx +0 -35
  248. package/src/vista/vista-file-context.ts +0 -14
  249. package/src/vista/vista-file-source.tsx +0 -141
  250. package/src/vista/vista-form-context.ts +0 -20
  251. package/src/vista/vista-form-host.tsx +0 -48
  252. package/src/vista/vista-model.ts +0 -137
  253. package/src/vista/vista-open-context.tsx +0 -27
  254. package/src/vista/vista-open-state.ts +0 -11
  255. package/src/vista/vista-payloads.ts +0 -635
  256. package/src/vista/vista-tabs-manifest.ts +0 -138
  257. package/src/vista/vista-tools.ts +0 -232
@@ -1,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
- }
@@ -1,78 +0,0 @@
1
- import { type PaletteEntrySource } from './enums';
2
-
3
- import type { CapabilityRef } from '@xemahq/kernel-contracts/capability';
4
-
5
- /**
6
- * Command-palette plane of the SystemBus.
7
- *
8
- * The palette is the UNION of two sources (tagged by
9
- * {@link PaletteEntrySource}):
10
- * 1. every capability the actor may invoke — sourced from
11
- * `capability-registry-api` (the host's capability-registry client);
12
- * 2. every registered cross-biome intent action — sourced from the
13
- * SystemBus `intents` registry.
14
- *
15
- * The palette performs NO authorization. The capability source is already
16
- * actor-scoped server-side (the registry returns only capabilities the
17
- * subject can see); selecting an entry routes through `capability.invoke`,
18
- * where the backend router makes the final allow/deny decision. The
19
- * palette is pure presentation orchestration.
20
- */
21
-
22
- /** A palette entry backed by a capability descriptor. */
23
- export interface CapabilityPaletteEntry {
24
- readonly source: PaletteEntrySource.Capability;
25
- /** Stable id (the capability ref doubles as the id). */
26
- readonly id: string;
27
- /** Human label rendered in the palette row. */
28
- readonly label: string;
29
- /** Optional one-line description from the capability descriptor. */
30
- readonly summary?: string;
31
- /** The capability the entry invokes when selected. */
32
- readonly capabilityRef: CapabilityRef;
33
- }
34
-
35
- /** A palette entry backed by a registered cross-biome intent. */
36
- export interface IntentPaletteEntry {
37
- readonly source: PaletteEntrySource.Intent;
38
- /** Stable id, unique across registered intents. */
39
- readonly id: string;
40
- /** Human label rendered in the palette row. */
41
- readonly label: string;
42
- /** Biome that provides the intent action. */
43
- readonly biomeId: string;
44
- }
45
-
46
- /** Discriminated union of palette entries. */
47
- export type PaletteEntry = CapabilityPaletteEntry | IntentPaletteEntry;
48
-
49
- /**
50
- * Query against the palette. `text` is matched by the host's own ranker
51
- * (the contract does not prescribe a fuzzy algorithm). `sources` narrows
52
- * to a subset of {@link PaletteEntrySource}; omitted means "all sources".
53
- */
54
- export interface PaletteQuery {
55
- readonly text: string;
56
- readonly sources?: readonly PaletteEntrySource[];
57
- }
58
-
59
- /**
60
- * The `palette` surface of the SystemBus. Framework-agnostic — no React.
61
- * The host wires a capability-registry client + the SystemBus intent
62
- * registry behind `query`. `subscribe` lets a palette UI re-render when
63
- * either source changes (a biome registers an intent, the registry
64
- * refreshes).
65
- */
66
- export interface PaletteBus {
67
- /**
68
- * Resolve palette entries matching `query`, ranked by the host. Async
69
- * because the capability source may hit `capability-registry-api`.
70
- */
71
- query(query: PaletteQuery): Promise<readonly PaletteEntry[]>;
72
- /**
73
- * Subscribe to palette-source changes. Returns an unsubscribe fn. Fires
74
- * when a biome registers/unregisters an intent or the capability source
75
- * is refreshed — so a palette overlay can re-query without polling.
76
- */
77
- subscribe(listener: () => void): () => void;
78
- }
@@ -1,159 +0,0 @@
1
- import {
2
- parseDeeplink,
3
- type DeeplinkBus,
4
- type ParsedDeeplink,
5
- } from './deeplink';
6
- import { PaletteEntrySource } from './enums';
7
- import {
8
- type CapabilityInvoker,
9
- type DeeplinkResolver,
10
- type PaletteSource,
11
- type WindowManager,
12
- } from './host-ports';
13
- import { IntentRegistry } from './intent-registry';
14
- import {
15
- type IntentPaletteEntry,
16
- type PaletteBus,
17
- type PaletteEntry,
18
- type PaletteQuery,
19
- } from './palette';
20
-
21
- import type { SystemBus } from './system-bus';
22
-
23
- /**
24
- * Host-supplied ports needed to build a real {@link SystemBus}. The kernel
25
- * ships the framework-agnostic pieces (`IntentRegistry`, `parseDeeplink`);
26
- * the host supplies the concrete backend + shell behind these ports. NONE
27
- * are optional — a missing port is a wiring bug and `buildSystemBus` fails
28
- * fast.
29
- */
30
- export interface SystemBusPorts {
31
- /** Relays `capability.invoke` to the backend capability-router. */
32
- readonly capability: CapabilityInvoker;
33
- /** Sources the capability half of the palette from the registry. */
34
- readonly palette: PaletteSource;
35
- /** Realises the window plane (open / focus / close / arrange). */
36
- readonly windows: WindowManager;
37
- /** Navigates the running shell to a parsed deeplink target. */
38
- readonly deeplink: DeeplinkResolver;
39
- }
40
-
41
- function assertPort<T>(value: T | undefined, name: string): T {
42
- if (value === undefined || value === null) {
43
- throw new Error(
44
- `[xema-ui-kernel] SystemBus port "${name}" was not supplied. ` +
45
- 'The host MUST provide every SystemBus port (capability / palette / ' +
46
- 'windows / deeplink) — there is no silent no-op fallback.',
47
- );
48
- }
49
- return value;
50
- }
51
-
52
- /**
53
- * Build the palette bus by unioning the host's capability source with the
54
- * SystemBus intent registry. The capability half is already actor-scoped
55
- * server-side; the intent half is flattened from every registration's
56
- * provided actions. The host's `PaletteSource.queryCapabilities` applies
57
- * its own ranking to the capability rows; intent rows are filtered here by
58
- * a case-insensitive label/biome substring match (the contract leaves the
59
- * ranker to the host — substring is the deterministic floor).
60
- *
61
- * Pure orchestration: no authorization. Selecting a capability entry
62
- * routes through `capability.invoke` where the backend decides allow/deny.
63
- */
64
- function buildPaletteBus(
65
- capabilitySource: PaletteSource,
66
- intents: IntentRegistry,
67
- ): PaletteBus {
68
- function intentEntries(query: PaletteQuery): IntentPaletteEntry[] {
69
- if (query.sources && !query.sources.includes(PaletteEntrySource.Intent)) {
70
- return [];
71
- }
72
- const needle = query.text.trim().toLowerCase();
73
- const out: IntentPaletteEntry[] = [];
74
- // The IntentRegistry exposes registrations only through `resolve(kind)`;
75
- // for a palette we want every provided action regardless of kind, so we
76
- // read the public snapshot the registry exposes via `snapshot()`.
77
- for (const registration of intents.snapshot()) {
78
- for (const action of registration.provides) {
79
- if (
80
- needle.length > 0 &&
81
- !action.label.toLowerCase().includes(needle) &&
82
- !registration.biomeId.toLowerCase().includes(needle)
83
- ) {
84
- continue;
85
- }
86
- out.push({
87
- source: PaletteEntrySource.Intent,
88
- id: `${registration.biomeId}:${action.id}`,
89
- label: action.label,
90
- biomeId: registration.biomeId,
91
- });
92
- }
93
- }
94
- return out;
95
- }
96
-
97
- return {
98
- async query(query: PaletteQuery): Promise<readonly PaletteEntry[]> {
99
- const wantsCapabilities =
100
- !query.sources || query.sources.includes(PaletteEntrySource.Capability);
101
- const capabilityEntries = wantsCapabilities
102
- ? await capabilitySource.queryCapabilities(query)
103
- : [];
104
- return [...capabilityEntries, ...intentEntries(query)];
105
- },
106
- subscribe(listener: () => void): () => void {
107
- const offCapabilities = capabilitySource.subscribe(listener);
108
- const offIntents = intents.subscribe(listener);
109
- return () => {
110
- offCapabilities();
111
- offIntents();
112
- };
113
- },
114
- };
115
- }
116
-
117
- function buildDeeplinkBus(resolver: DeeplinkResolver): DeeplinkBus {
118
- return {
119
- parse(raw: string): ParsedDeeplink {
120
- return parseDeeplink(raw);
121
- },
122
- async resolve(target: string | ParsedDeeplink): Promise<void> {
123
- // Parse-first so a malformed deeplink fails fast in the kernel parser
124
- // before the host navigation ever runs.
125
- const parsed =
126
- typeof target === 'string' ? parseDeeplink(target) : target;
127
- await resolver.resolve(parsed);
128
- },
129
- };
130
- }
131
-
132
- /**
133
- * Construct the real {@link SystemBus} from the host's ports plus the
134
- * kernel's framework-agnostic runtime (`IntentRegistry` + `parseDeeplink`).
135
- * The `intents` registry is owned by the bus instance so biome
136
- * registrations and palette intent rows share one source of truth.
137
- *
138
- * Fail-fast: every port is required. No port may be silently stubbed. This
139
- * is the framework-agnostic builder — any host adapter (Next.js, React-
140
- * Router, …) wires its concrete ports and calls this.
141
- */
142
- export function buildSystemBus(ports: SystemBusPorts): SystemBus {
143
- const capability = assertPort(ports.capability, 'capability');
144
- const paletteSource = assertPort(ports.palette, 'palette');
145
- const windows = assertPort(ports.windows, 'windows');
146
- const deeplinkResolver = assertPort(ports.deeplink, 'deeplink');
147
-
148
- // Concrete type (not the `IntentBus` interface): the palette builder
149
- // reads `intents.snapshot()`, which is an `IntentRegistry` affordance.
150
- const intents: IntentRegistry = new IntentRegistry();
151
-
152
- return {
153
- capability,
154
- intents,
155
- palette: buildPaletteBus(paletteSource, intents),
156
- deeplink: buildDeeplinkBus(deeplinkResolver),
157
- windows,
158
- };
159
- }