@xemahq/ui-kernel 0.1.4

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 (208) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +72 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +19 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/biome-host/biome-mode.d.ts +2 -0
  8. package/dist/lib/biome-host/biome-mode.d.ts.map +1 -0
  9. package/dist/lib/biome-host/biome-mode.js +3 -0
  10. package/dist/lib/biome-host/biome-mode.js.map +1 -0
  11. package/dist/lib/biome-host/biome-registry.d.ts +30 -0
  12. package/dist/lib/biome-host/biome-registry.d.ts.map +1 -0
  13. package/dist/lib/biome-host/biome-registry.js +134 -0
  14. package/dist/lib/biome-host/biome-registry.js.map +1 -0
  15. package/dist/lib/biome-host/composition-validation.d.ts +22 -0
  16. package/dist/lib/biome-host/composition-validation.d.ts.map +1 -0
  17. package/dist/lib/biome-host/composition-validation.js +127 -0
  18. package/dist/lib/biome-host/composition-validation.js.map +1 -0
  19. package/dist/lib/biome-host/frontend-biome.d.ts +47 -0
  20. package/dist/lib/biome-host/frontend-biome.d.ts.map +1 -0
  21. package/dist/lib/biome-host/frontend-biome.js +3 -0
  22. package/dist/lib/biome-host/frontend-biome.js.map +1 -0
  23. package/dist/lib/biome-host/host-bridge.d.ts +55 -0
  24. package/dist/lib/biome-host/host-bridge.d.ts.map +1 -0
  25. package/dist/lib/biome-host/host-bridge.js +16 -0
  26. package/dist/lib/biome-host/host-bridge.js.map +1 -0
  27. package/dist/lib/biome-host/host-sources.d.ts +12 -0
  28. package/dist/lib/biome-host/host-sources.d.ts.map +1 -0
  29. package/dist/lib/biome-host/host-sources.js +3 -0
  30. package/dist/lib/biome-host/host-sources.js.map +1 -0
  31. package/dist/lib/biome-host/index.d.ts +10 -0
  32. package/dist/lib/biome-host/index.d.ts.map +1 -0
  33. package/dist/lib/biome-host/index.js +26 -0
  34. package/dist/lib/biome-host/index.js.map +1 -0
  35. package/dist/lib/biome-host/nav.d.ts +17 -0
  36. package/dist/lib/biome-host/nav.d.ts.map +1 -0
  37. package/dist/lib/biome-host/nav.js +52 -0
  38. package/dist/lib/biome-host/nav.js.map +1 -0
  39. package/dist/lib/biome-host/session-contributions.d.ts +143 -0
  40. package/dist/lib/biome-host/session-contributions.d.ts.map +1 -0
  41. package/dist/lib/biome-host/session-contributions.js +3 -0
  42. package/dist/lib/biome-host/session-contributions.js.map +1 -0
  43. package/dist/lib/biome-host/session-profiles.d.ts +18 -0
  44. package/dist/lib/biome-host/session-profiles.d.ts.map +1 -0
  45. package/dist/lib/biome-host/session-profiles.js +39 -0
  46. package/dist/lib/biome-host/session-profiles.js.map +1 -0
  47. package/dist/lib/system-bus/capability-invoke.d.ts +18 -0
  48. package/dist/lib/system-bus/capability-invoke.d.ts.map +1 -0
  49. package/dist/lib/system-bus/capability-invoke.js +3 -0
  50. package/dist/lib/system-bus/capability-invoke.js.map +1 -0
  51. package/dist/lib/system-bus/deeplink.d.ts +33 -0
  52. package/dist/lib/system-bus/deeplink.d.ts.map +1 -0
  53. package/dist/lib/system-bus/deeplink.js +99 -0
  54. package/dist/lib/system-bus/deeplink.js.map +1 -0
  55. package/dist/lib/system-bus/enums.d.ts +27 -0
  56. package/dist/lib/system-bus/enums.d.ts.map +1 -0
  57. package/dist/lib/system-bus/enums.js +35 -0
  58. package/dist/lib/system-bus/enums.js.map +1 -0
  59. package/dist/lib/system-bus/host-ports.d.ts +24 -0
  60. package/dist/lib/system-bus/host-ports.d.ts.map +1 -0
  61. package/dist/lib/system-bus/host-ports.js +3 -0
  62. package/dist/lib/system-bus/host-ports.js.map +1 -0
  63. package/dist/lib/system-bus/index.d.ts +11 -0
  64. package/dist/lib/system-bus/index.d.ts.map +1 -0
  65. package/dist/lib/system-bus/index.js +27 -0
  66. package/dist/lib/system-bus/index.js.map +1 -0
  67. package/dist/lib/system-bus/intent-registry.d.ts +14 -0
  68. package/dist/lib/system-bus/intent-registry.d.ts.map +1 -0
  69. package/dist/lib/system-bus/intent-registry.js +66 -0
  70. package/dist/lib/system-bus/intent-registry.js.map +1 -0
  71. package/dist/lib/system-bus/intents.d.ts +30 -0
  72. package/dist/lib/system-bus/intents.d.ts.map +1 -0
  73. package/dist/lib/system-bus/intents.js +3 -0
  74. package/dist/lib/system-bus/intents.js.map +1 -0
  75. package/dist/lib/system-bus/palette.d.ts +25 -0
  76. package/dist/lib/system-bus/palette.d.ts.map +1 -0
  77. package/dist/lib/system-bus/palette.js +3 -0
  78. package/dist/lib/system-bus/palette.js.map +1 -0
  79. package/dist/lib/system-bus/system-bus-builder.d.ts +10 -0
  80. package/dist/lib/system-bus/system-bus-builder.d.ts.map +1 -0
  81. package/dist/lib/system-bus/system-bus-builder.js +82 -0
  82. package/dist/lib/system-bus/system-bus-builder.js.map +1 -0
  83. package/dist/lib/system-bus/system-bus.d.ts +13 -0
  84. package/dist/lib/system-bus/system-bus.d.ts.map +1 -0
  85. package/dist/lib/system-bus/system-bus.js +3 -0
  86. package/dist/lib/system-bus/system-bus.js.map +1 -0
  87. package/dist/lib/system-bus/windows.d.ts +21 -0
  88. package/dist/lib/system-bus/windows.d.ts.map +1 -0
  89. package/dist/lib/system-bus/windows.js +3 -0
  90. package/dist/lib/system-bus/windows.js.map +1 -0
  91. package/dist/org-db/components/DbResultTable.d.ts +13 -0
  92. package/dist/org-db/components/DbResultTable.d.ts.map +1 -0
  93. package/dist/org-db/components/DbResultTable.js +58 -0
  94. package/dist/org-db/components/DbResultTable.js.map +1 -0
  95. package/dist/org-db/index.d.ts +2 -0
  96. package/dist/org-db/index.d.ts.map +1 -0
  97. package/dist/org-db/index.js +6 -0
  98. package/dist/org-db/index.js.map +1 -0
  99. package/dist/registry/index.d.ts +9 -0
  100. package/dist/registry/index.d.ts.map +1 -0
  101. package/dist/registry/index.js +25 -0
  102. package/dist/registry/index.js.map +1 -0
  103. package/dist/registry/lib/biome-slot.d.ts +7 -0
  104. package/dist/registry/lib/biome-slot.d.ts.map +1 -0
  105. package/dist/registry/lib/biome-slot.js +18 -0
  106. package/dist/registry/lib/biome-slot.js.map +1 -0
  107. package/dist/registry/lib/biomes-enabled-context.d.ts +3 -0
  108. package/dist/registry/lib/biomes-enabled-context.d.ts.map +1 -0
  109. package/dist/registry/lib/biomes-enabled-context.js +11 -0
  110. package/dist/registry/lib/biomes-enabled-context.js.map +1 -0
  111. package/dist/registry/lib/composition-validation-host.d.ts +3 -0
  112. package/dist/registry/lib/composition-validation-host.d.ts.map +1 -0
  113. package/dist/registry/lib/composition-validation-host.js +10 -0
  114. package/dist/registry/lib/composition-validation-host.js.map +1 -0
  115. package/dist/registry/lib/extension-points.d.ts +15 -0
  116. package/dist/registry/lib/extension-points.d.ts.map +1 -0
  117. package/dist/registry/lib/extension-points.js +17 -0
  118. package/dist/registry/lib/extension-points.js.map +1 -0
  119. package/dist/registry/lib/primitives/SessionEventCard.d.ts +14 -0
  120. package/dist/registry/lib/primitives/SessionEventCard.d.ts.map +1 -0
  121. package/dist/registry/lib/primitives/SessionEventCard.js +60 -0
  122. package/dist/registry/lib/primitives/SessionEventCard.js.map +1 -0
  123. package/dist/registry/lib/primitives/SessionEventTimeline.d.ts +13 -0
  124. package/dist/registry/lib/primitives/SessionEventTimeline.d.ts.map +1 -0
  125. package/dist/registry/lib/primitives/SessionEventTimeline.js +35 -0
  126. package/dist/registry/lib/primitives/SessionEventTimeline.js.map +1 -0
  127. package/dist/registry/lib/primitives/SessionMutationBar.d.ts +10 -0
  128. package/dist/registry/lib/primitives/SessionMutationBar.d.ts.map +1 -0
  129. package/dist/registry/lib/primitives/SessionMutationBar.js +37 -0
  130. package/dist/registry/lib/primitives/SessionMutationBar.js.map +1 -0
  131. package/dist/registry/lib/primitives/SessionTabbedDrawer.d.ts +19 -0
  132. package/dist/registry/lib/primitives/SessionTabbedDrawer.d.ts.map +1 -0
  133. package/dist/registry/lib/primitives/SessionTabbedDrawer.js +75 -0
  134. package/dist/registry/lib/primitives/SessionTabbedDrawer.js.map +1 -0
  135. package/dist/registry/lib/primitives/index.d.ts +5 -0
  136. package/dist/registry/lib/primitives/index.d.ts.map +1 -0
  137. package/dist/registry/lib/primitives/index.js +21 -0
  138. package/dist/registry/lib/primitives/index.js.map +1 -0
  139. package/dist/registry/lib/session-context-builder.d.ts +13 -0
  140. package/dist/registry/lib/session-context-builder.d.ts.map +1 -0
  141. package/dist/registry/lib/session-context-builder.js +39 -0
  142. package/dist/registry/lib/session-context-builder.js.map +1 -0
  143. package/dist/registry/lib/session-context-provider.d.ts +10 -0
  144. package/dist/registry/lib/session-context-provider.d.ts.map +1 -0
  145. package/dist/registry/lib/session-context-provider.js +24 -0
  146. package/dist/registry/lib/session-context-provider.js.map +1 -0
  147. package/dist/registry/lib/session-selectors.d.ts +9 -0
  148. package/dist/registry/lib/session-selectors.d.ts.map +1 -0
  149. package/dist/registry/lib/session-selectors.js +149 -0
  150. package/dist/registry/lib/session-selectors.js.map +1 -0
  151. package/dist/session/comments/CommentRail.d.ts +20 -0
  152. package/dist/session/comments/CommentRail.d.ts.map +1 -0
  153. package/dist/session/comments/CommentRail.js +16 -0
  154. package/dist/session/comments/CommentRail.js.map +1 -0
  155. package/dist/session/index.d.ts +4 -0
  156. package/dist/session/index.d.ts.map +1 -0
  157. package/dist/session/index.js +10 -0
  158. package/dist/session/index.js.map +1 -0
  159. package/dist/session/lib/cn.d.ts +3 -0
  160. package/dist/session/lib/cn.d.ts.map +1 -0
  161. package/dist/session/lib/cn.js +9 -0
  162. package/dist/session/lib/cn.js.map +1 -0
  163. package/dist/session/shell/SessionWorkspaceShell.d.ts +16 -0
  164. package/dist/session/shell/SessionWorkspaceShell.d.ts.map +1 -0
  165. package/dist/session/shell/SessionWorkspaceShell.js +15 -0
  166. package/dist/session/shell/SessionWorkspaceShell.js.map +1 -0
  167. package/package.json +84 -0
  168. package/src/index.ts +2 -0
  169. package/src/lib/biome-host/biome-mode.ts +6 -0
  170. package/src/lib/biome-host/biome-registry.ts +245 -0
  171. package/src/lib/biome-host/composition-validation.ts +215 -0
  172. package/src/lib/biome-host/frontend-biome.ts +162 -0
  173. package/src/lib/biome-host/host-bridge.ts +178 -0
  174. package/src/lib/biome-host/host-sources.ts +41 -0
  175. package/src/lib/biome-host/index.ts +23 -0
  176. package/src/lib/biome-host/nav.ts +83 -0
  177. package/src/lib/biome-host/session-contributions.ts +293 -0
  178. package/src/lib/biome-host/session-profiles.ts +99 -0
  179. package/src/lib/system-bus/capability-invoke.ts +92 -0
  180. package/src/lib/system-bus/deeplink.ts +200 -0
  181. package/src/lib/system-bus/enums.ts +86 -0
  182. package/src/lib/system-bus/host-ports.ts +96 -0
  183. package/src/lib/system-bus/index.ts +16 -0
  184. package/src/lib/system-bus/intent-registry.ts +106 -0
  185. package/src/lib/system-bus/intents.ts +109 -0
  186. package/src/lib/system-bus/palette.ts +77 -0
  187. package/src/lib/system-bus/system-bus-builder.ts +157 -0
  188. package/src/lib/system-bus/system-bus.ts +37 -0
  189. package/src/lib/system-bus/windows.ts +51 -0
  190. package/src/org-db/components/DbResultTable.tsx +143 -0
  191. package/src/org-db/index.ts +1 -0
  192. package/src/registry/index.ts +8 -0
  193. package/src/registry/lib/biome-slot.tsx +47 -0
  194. package/src/registry/lib/biomes-enabled-context.ts +20 -0
  195. package/src/registry/lib/composition-validation-host.ts +37 -0
  196. package/src/registry/lib/extension-points.ts +134 -0
  197. package/src/registry/lib/primitives/SessionEventCard.tsx +138 -0
  198. package/src/registry/lib/primitives/SessionEventTimeline.tsx +89 -0
  199. package/src/registry/lib/primitives/SessionMutationBar.tsx +76 -0
  200. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +155 -0
  201. package/src/registry/lib/primitives/index.ts +18 -0
  202. package/src/registry/lib/session-context-builder.ts +68 -0
  203. package/src/registry/lib/session-context-provider.tsx +50 -0
  204. package/src/registry/lib/session-selectors.ts +231 -0
  205. package/src/session/comments/CommentRail.tsx +164 -0
  206. package/src/session/index.ts +3 -0
  207. package/src/session/lib/cn.ts +11 -0
  208. package/src/session/shell/SessionWorkspaceShell.tsx +141 -0
@@ -0,0 +1,157 @@
1
+ import { PaletteEntrySource } from './enums';
2
+ import {
3
+ parseDeeplink,
4
+ type DeeplinkBus,
5
+ type ParsedDeeplink,
6
+ } from './deeplink';
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
+ import type { SystemBus } from './system-bus';
21
+
22
+ /**
23
+ * Host-supplied ports needed to build a real {@link SystemBus}. The kernel
24
+ * ships the framework-agnostic pieces (`IntentRegistry`, `parseDeeplink`);
25
+ * the host supplies the concrete backend + shell behind these ports. NONE
26
+ * are optional — a missing port is a wiring bug and `buildSystemBus` fails
27
+ * fast.
28
+ */
29
+ export interface SystemBusPorts {
30
+ /** Relays `capability.invoke` to the backend capability-router. */
31
+ readonly capability: CapabilityInvoker;
32
+ /** Sources the capability half of the palette from the registry. */
33
+ readonly palette: PaletteSource;
34
+ /** Realises the window plane (open / focus / close / arrange). */
35
+ readonly windows: WindowManager;
36
+ /** Navigates the running shell to a parsed deeplink target. */
37
+ readonly deeplink: DeeplinkResolver;
38
+ }
39
+
40
+ function assertPort<T>(value: T | undefined, name: string): T {
41
+ if (value === undefined || value === null) {
42
+ throw new Error(
43
+ `[xema-ui-kernel] SystemBus port "${name}" was not supplied. ` +
44
+ 'The host MUST provide every SystemBus port (capability / palette / ' +
45
+ 'windows / deeplink) — there is no silent no-op fallback.',
46
+ );
47
+ }
48
+ return value;
49
+ }
50
+
51
+ /**
52
+ * Build the palette bus by unioning the host's capability source with the
53
+ * SystemBus intent registry. The capability half is already actor-scoped
54
+ * server-side; the intent half is flattened from every registration's
55
+ * provided actions. The host's `PaletteSource.queryCapabilities` applies
56
+ * its own ranking to the capability rows; intent rows are filtered here by
57
+ * a case-insensitive label/biome substring match (the contract leaves the
58
+ * ranker to the host — substring is the deterministic floor).
59
+ *
60
+ * Pure orchestration: no authorization. Selecting a capability entry
61
+ * routes through `capability.invoke` where the backend decides allow/deny.
62
+ */
63
+ function buildPaletteBus(
64
+ capabilitySource: PaletteSource,
65
+ intents: IntentRegistry,
66
+ ): PaletteBus {
67
+ function intentEntries(query: PaletteQuery): IntentPaletteEntry[] {
68
+ if (query.sources && !query.sources.includes(PaletteEntrySource.Intent)) {
69
+ return [];
70
+ }
71
+ const needle = query.text.trim().toLowerCase();
72
+ const out: IntentPaletteEntry[] = [];
73
+ // The IntentRegistry exposes registrations only through `resolve(kind)`;
74
+ // for a palette we want every provided action regardless of kind, so we
75
+ // read the public snapshot the registry exposes via `snapshot()`.
76
+ for (const registration of intents.snapshot()) {
77
+ for (const action of registration.provides) {
78
+ if (
79
+ needle.length > 0 &&
80
+ !action.label.toLowerCase().includes(needle) &&
81
+ !registration.biomeId.toLowerCase().includes(needle)
82
+ ) {
83
+ continue;
84
+ }
85
+ out.push({
86
+ source: PaletteEntrySource.Intent,
87
+ id: `${registration.biomeId}:${action.id}`,
88
+ label: action.label,
89
+ biomeId: registration.biomeId,
90
+ });
91
+ }
92
+ }
93
+ return out;
94
+ }
95
+
96
+ return {
97
+ async query(query: PaletteQuery): Promise<readonly PaletteEntry[]> {
98
+ const wantsCapabilities =
99
+ !query.sources || query.sources.includes(PaletteEntrySource.Capability);
100
+ const capabilityEntries = wantsCapabilities
101
+ ? await capabilitySource.queryCapabilities(query)
102
+ : [];
103
+ return [...capabilityEntries, ...intentEntries(query)];
104
+ },
105
+ subscribe(listener: () => void): () => void {
106
+ const offCapabilities = capabilitySource.subscribe(listener);
107
+ const offIntents = intents.subscribe(listener);
108
+ return () => {
109
+ offCapabilities();
110
+ offIntents();
111
+ };
112
+ },
113
+ };
114
+ }
115
+
116
+ function buildDeeplinkBus(resolver: DeeplinkResolver): DeeplinkBus {
117
+ return {
118
+ parse(raw: string): ParsedDeeplink {
119
+ return parseDeeplink(raw);
120
+ },
121
+ async resolve(target: string | ParsedDeeplink): Promise<void> {
122
+ // Parse-first so a malformed deeplink fails fast in the kernel parser
123
+ // before the host navigation ever runs.
124
+ const parsed = typeof target === 'string' ? parseDeeplink(target) : target;
125
+ await resolver.resolve(parsed);
126
+ },
127
+ };
128
+ }
129
+
130
+ /**
131
+ * Construct the real {@link SystemBus} from the host's ports plus the
132
+ * kernel's framework-agnostic runtime (`IntentRegistry` + `parseDeeplink`).
133
+ * The `intents` registry is owned by the bus instance so biome
134
+ * registrations and palette intent rows share one source of truth.
135
+ *
136
+ * Fail-fast: every port is required. No port may be silently stubbed. This
137
+ * is the framework-agnostic builder — any host adapter (Next.js, React-
138
+ * Router, …) wires its concrete ports and calls this.
139
+ */
140
+ export function buildSystemBus(ports: SystemBusPorts): SystemBus {
141
+ const capability = assertPort(ports.capability, 'capability');
142
+ const paletteSource = assertPort(ports.palette, 'palette');
143
+ const windows = assertPort(ports.windows, 'windows');
144
+ const deeplinkResolver = assertPort(ports.deeplink, 'deeplink');
145
+
146
+ // Concrete type (not the `IntentBus` interface): the palette builder
147
+ // reads `intents.snapshot()`, which is an `IntentRegistry` affordance.
148
+ const intents: IntentRegistry = new IntentRegistry();
149
+
150
+ return {
151
+ capability,
152
+ intents,
153
+ palette: buildPaletteBus(paletteSource, intents),
154
+ deeplink: buildDeeplinkBus(deeplinkResolver),
155
+ windows,
156
+ };
157
+ }
@@ -0,0 +1,37 @@
1
+ import type { CapabilityBus } from './capability-invoke';
2
+ import type { DeeplinkBus } from './deeplink';
3
+ import type { IntentBus } from './intents';
4
+ import type { PaletteBus } from './palette';
5
+ import type { WindowBus } from './windows';
6
+
7
+ /**
8
+ * `SystemBus` — the framework-agnostic OS-orchestration plane every
9
+ * frontend biome reaches through its {@link HostBridge}.
10
+ *
11
+ * **Pure orchestration. Zero policy.** The SystemBus routes intent,
12
+ * navigation, capability invocation, palette, and windowing. It NEVER
13
+ * authorizes, denies, or duplicates policy. Every `capability.invoke`
14
+ * routes through the backend capability-router, which is the single
15
+ * authority on auth / tenancy / policy / audit. The SystemBus's job is to
16
+ * carry orchestration metadata faithfully and relay the router's outcome —
17
+ * a denial surfaces as an observable result (`output === undefined` +
18
+ * `auditId`), never a silent swallow.
19
+ *
20
+ * The contract is framework-agnostic on purpose: it imports no Vite, no
21
+ * Next.js, no React-Router, and no generated transport client. A concrete
22
+ * host (Vite SPA today, Next.js tomorrow) implements each sub-bus against
23
+ * its router, its capability-router client, and its window manager. Biome
24
+ * code is identical across hosts.
25
+ */
26
+ export interface SystemBus {
27
+ /** Capability invocation → backend router (backend enforces; bus adds none). */
28
+ readonly capability: CapabilityBus;
29
+ /** Cross-biome "Open with… / Send to…" intent registry. */
30
+ readonly intents: IntentBus;
31
+ /** Command palette = capabilities ∪ registered intents. */
32
+ readonly palette: PaletteBus;
33
+ /** Typed `xema://` deeplink parse + resolve. */
34
+ readonly deeplink: DeeplinkBus;
35
+ /** Host window manager (open / focus / close / arrange). */
36
+ readonly windows: WindowBus;
37
+ }
@@ -0,0 +1,51 @@
1
+ import { WindowArrangement, WindowOp } from './enums';
2
+
3
+ /**
4
+ * Window-management plane of the SystemBus.
5
+ *
6
+ * A "window" is a host-managed surface hosting a biome route or object.
7
+ * The contract is framework-agnostic: the host (desktop shell, tiling WM,
8
+ * tabbed SPA) decides how a window is physically realised, but every host
9
+ * exposes the same closed {@link WindowOp} verb set. The SystemBus carries
10
+ * no authorization here — windowing is pure shell orchestration.
11
+ */
12
+
13
+ /** Identifier of an open window, minted by the host on `open`. */
14
+ export type WindowId = string;
15
+
16
+ /** A request to open a new window onto a deeplink target. */
17
+ export interface OpenWindowRequest {
18
+ /** The `xema://` deeplink the new window should display. */
19
+ readonly target: string;
20
+ /** Optional human title; the host falls back to the target's own title. */
21
+ readonly title?: string;
22
+ }
23
+
24
+ /** Snapshot of an open window. */
25
+ export interface WindowState {
26
+ readonly id: WindowId;
27
+ readonly target: string;
28
+ readonly title: string;
29
+ readonly focused: boolean;
30
+ }
31
+
32
+ /**
33
+ * The `windows` surface of the SystemBus. Each method maps to a closed
34
+ * {@link WindowOp}. Operations a host cannot honour reject fail-fast
35
+ * rather than silently no-op, so callers never assume a window exists
36
+ * when it does not.
37
+ */
38
+ export interface WindowBus {
39
+ /** {@link WindowOp.Open} — open a new window; resolves with its id. */
40
+ open(request: OpenWindowRequest): Promise<WindowId>;
41
+ /** {@link WindowOp.Focus} — bring a window to the foreground. Rejects on unknown id. */
42
+ focus(id: WindowId): Promise<void>;
43
+ /** {@link WindowOp.Close} — close a window. Rejects on unknown id. */
44
+ close(id: WindowId): Promise<void>;
45
+ /** {@link WindowOp.Arrange} — apply a layout to all open windows. */
46
+ arrange(arrangement: WindowArrangement): Promise<void>;
47
+ /** Current snapshot of open windows (for a window-list UI). */
48
+ list(): readonly WindowState[];
49
+ /** Subscribe to window-set changes; returns an unsubscribe fn. */
50
+ subscribe(listener: () => void): () => void;
51
+ }
@@ -0,0 +1,143 @@
1
+ import { useMemo } from 'react';
2
+
3
+ export interface DbResultTableProps {
4
+ columns: Array<{ name: string; type?: string }>;
5
+ rows: unknown[][];
6
+ rowCount: number;
7
+ truncated: boolean;
8
+ durationMs?: number;
9
+ statement?: string;
10
+ }
11
+
12
+ function toDisplayValue(value: unknown): string {
13
+ if (value === null || value === undefined) return '';
14
+ if (typeof value === 'string') return value;
15
+ if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
16
+ return String(value);
17
+ }
18
+ if (value instanceof Date) return value.toISOString();
19
+ try {
20
+ return JSON.stringify(value);
21
+ } catch {
22
+ return String(value);
23
+ }
24
+ }
25
+
26
+ function escapeCsvValue(value: string): string {
27
+ if (value.includes('"') || value.includes(',') || value.includes('\n')) {
28
+ return `"${value.replace(/"/g, '""')}"`;
29
+ }
30
+ return value;
31
+ }
32
+
33
+ export function DbResultTable(props: DbResultTableProps) {
34
+ const { columns, rows, rowCount, truncated, durationMs, statement } = props;
35
+
36
+ const csvContent = useMemo(() => {
37
+ const header = columns.map((column) => escapeCsvValue(column.name)).join(',');
38
+ const dataLines = rows.map((row) =>
39
+ row
40
+ .map((cell) => {
41
+ const printable = cell === null || cell === undefined ? '' : toDisplayValue(cell);
42
+ return escapeCsvValue(printable);
43
+ })
44
+ .join(','),
45
+ );
46
+ return [header, ...dataLines].join('\n');
47
+ }, [columns, rows]);
48
+
49
+ const displayedCount = rows.length;
50
+
51
+ const handleDownloadCsv = () => {
52
+ const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
53
+ const url = URL.createObjectURL(blob);
54
+ const link = document.createElement('a');
55
+ link.href = url;
56
+ link.download = 'query-results.csv';
57
+ document.body.appendChild(link);
58
+ link.click();
59
+ document.body.removeChild(link);
60
+ URL.revokeObjectURL(url);
61
+ };
62
+
63
+ return (
64
+ <section className="rounded-lg border border-border bg-card text-card-foreground">
65
+ {statement ? (
66
+ <details className="border-b border-border px-4 py-3">
67
+ <summary className="cursor-pointer text-sm font-medium text-foreground">SQL statement</summary>
68
+ <pre className="mt-3 overflow-x-auto rounded-md bg-muted p-3 text-xs leading-6 text-muted-foreground">
69
+ <code>{statement}</code>
70
+ </pre>
71
+ </details>
72
+ ) : null}
73
+
74
+ {truncated ? (
75
+ <div className="border-b border-amber-300/60 bg-amber-100/60 px-4 py-3 text-sm text-amber-900">
76
+ Showing first {displayedCount} rows of {rowCount} total - download CSV for full results.
77
+ </div>
78
+ ) : null}
79
+
80
+ <div className="flex items-center justify-between gap-3 border-b border-border px-4 py-3">
81
+ <div className="text-sm text-muted-foreground">
82
+ {rowCount === 0 ? 'No rows returned' : `${displayedCount} row${displayedCount === 1 ? '' : 's'} shown`}
83
+ </div>
84
+ <button
85
+ type="button"
86
+ className="inline-flex items-center rounded-md border border-input bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-accent"
87
+ onClick={handleDownloadCsv}
88
+ >
89
+ Download CSV
90
+ </button>
91
+ </div>
92
+
93
+ {rowCount === 0 ? (
94
+ <div className="px-4 py-8 text-center text-sm text-muted-foreground">No rows returned</div>
95
+ ) : (
96
+ <div className="overflow-x-auto">
97
+ <table className="min-w-full border-collapse text-sm">
98
+ <thead>
99
+ <tr className="border-b border-border bg-muted/40">
100
+ {columns.map((column) => (
101
+ <th key={column.name} className="px-4 py-3 text-left font-medium text-foreground">
102
+ <div className="flex flex-wrap items-center gap-2">
103
+ <span>{column.name}</span>
104
+ {column.type ? (
105
+ <span className="rounded-full border border-border bg-background px-2 py-0.5 text-[11px] font-normal uppercase tracking-wide text-muted-foreground">
106
+ {column.type}
107
+ </span>
108
+ ) : null}
109
+ </div>
110
+ </th>
111
+ ))}
112
+ </tr>
113
+ </thead>
114
+ <tbody>
115
+ {rows.map((row, rowIndex) => (
116
+ <tr key={`row-${rowIndex}`} className="border-b border-border/70 align-top">
117
+ {columns.map((column, colIndex) => {
118
+ const cell = row[colIndex];
119
+ return (
120
+ <td key={`${column.name}-${rowIndex}`} className="px-4 py-2 text-muted-foreground">
121
+ {cell === null || cell === undefined ? (
122
+ <span className="italic text-muted-foreground">null</span>
123
+ ) : (
124
+ <span className="break-all text-foreground">{toDisplayValue(cell)}</span>
125
+ )}
126
+ </td>
127
+ );
128
+ })}
129
+ </tr>
130
+ ))}
131
+ </tbody>
132
+ </table>
133
+ </div>
134
+ )}
135
+
136
+ {typeof durationMs === 'number' ? (
137
+ <footer className="border-t border-border px-4 py-2 text-xs text-muted-foreground">
138
+ Query ran in {Math.max(0, Math.round(durationMs))} ms
139
+ </footer>
140
+ ) : null}
141
+ </section>
142
+ );
143
+ }
@@ -0,0 +1 @@
1
+ export { DbResultTable, type DbResultTableProps } from './components/DbResultTable';
@@ -0,0 +1,8 @@
1
+ export * from './lib/extension-points';
2
+ export * from './lib/composition-validation-host';
3
+ export * from './lib/biome-slot';
4
+ export * from './lib/biomes-enabled-context';
5
+ export * from './lib/session-selectors';
6
+ export * from './lib/session-context-builder';
7
+ export * from './lib/session-context-provider';
8
+ export * from './lib/primitives';
@@ -0,0 +1,47 @@
1
+ import { Fragment, type ReactElement } from 'react';
2
+
3
+ import { biomeRegistry, useBiomeRegistryRevision } from '../../index';
4
+
5
+ import { useBiomesEnabled } from './biomes-enabled-context';
6
+
7
+ export interface BiomeSlotProps {
8
+ /** Slot name biomes target via `PanelContribution.slot`. */
9
+ readonly name: string;
10
+ /** Optional fallback rendered when no biome contributes to this slot. */
11
+ readonly fallback?: ReactElement | null;
12
+ }
13
+
14
+ /**
15
+ * Renders every biome-contributed panel registered for `name`, sorted
16
+ * by `weight`. When no biome contributes, renders `fallback` (or null).
17
+ *
18
+ * Reactive: subscribes to the biome registry's revision counter via
19
+ * `useBiomeRegistryRevision()`, so the slot re-renders automatically
20
+ * when a biome registers or unregisters (i.e. when `bootstrapBiomes()`
21
+ * finishes after the host shell has already painted, or when the admin
22
+ * UI disables a biome at runtime).
23
+ *
24
+ * Master-disable: if the surrounding host wraps the tree in
25
+ * `<BiomeHostProvider biomes="disabled">`, this slot short-circuits
26
+ * to its fallback regardless of registry state.
27
+ *
28
+ * Bridge access: biome panels reach host services via `useHostBridge()`,
29
+ * which reads from `HostBridgeContext`. The host shell mounts the
30
+ * provider above the route tree once; `<BiomeSlot>` does not own the
31
+ * provider so a host can place slots anywhere without nesting providers.
32
+ */
33
+ export function BiomeSlot(props: BiomeSlotProps): ReactElement | null {
34
+ // Subscribe so this slot re-renders when biomes register/change.
35
+ useBiomeRegistryRevision();
36
+ const enabled = useBiomesEnabled();
37
+ if (!enabled) return props.fallback ?? null;
38
+ const panels = biomeRegistry.panelsForSlot(props.name);
39
+ if (panels.length === 0) return props.fallback ?? null;
40
+ return (
41
+ <Fragment>
42
+ {panels.map((panel) => (
43
+ <Fragment key={panel.id}>{panel.render()}</Fragment>
44
+ ))}
45
+ </Fragment>
46
+ );
47
+ }
@@ -0,0 +1,20 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ /**
4
+ * React-side mirror of `biomeRegistry.isEnabled()`. Hosts that embed
5
+ * `@xemahq/ui-kernel/registry` without participating in Xema's biome
6
+ * ecosystem flip this to `false` via
7
+ * `<BiomeHostProvider biomes="disabled">`. `BiomeSlot` and
8
+ * `useBiomeRoutes` consult this context for cheap render-time
9
+ * short-circuit; the singleton registry's `isEnabled()` flag covers the
10
+ * imperative paths (`bootstrapBiomes`, `register`, `unregister`).
11
+ *
12
+ * Default is `true` — a host that mounts no provider gets the standard
13
+ * biome-enabled surface. Embedding hosts opt out explicitly.
14
+ */
15
+ export const BiomesEnabledContext = createContext<boolean>(true);
16
+ BiomesEnabledContext.displayName = 'BiomesEnabledContext';
17
+
18
+ export function useBiomesEnabled(): boolean {
19
+ return useContext(BiomesEnabledContext);
20
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Host-slot-aware composition validation.
3
+ *
4
+ * The kernel's `validateBiomeComposition` is host-agnostic: it takes the
5
+ * set of known slot ids as input. This thin wrapper binds it to the host
6
+ * shell's actual slot catalog (`HostExtensionSlots`) so callers don't have
7
+ * to assemble the set themselves. It is the function the host bootstrap
8
+ * calls after every enabled biome has registered.
9
+ */
10
+
11
+ import {
12
+ type CompositionDiagnostic,
13
+ type FrontendBiome,
14
+ validateBiomeComposition,
15
+ } from '../../index';
16
+
17
+ import { HostExtensionSlots } from './extension-points';
18
+
19
+ /**
20
+ * Every slot id the host shell renders a `<BiomeSlot>` for. A panel
21
+ * targeting anything outside this set (and not a `<owner>/<name>`
22
+ * biome-owned slot) is flagged as unknown.
23
+ */
24
+ const HOST_SLOT_IDS: ReadonlySet<string> = new Set(
25
+ Object.values(HostExtensionSlots),
26
+ );
27
+
28
+ /**
29
+ * Validate the merged composition of the given biomes against the host
30
+ * slot catalog. Returns structured diagnostics; never throws, never logs
31
+ * (the caller owns the fail-fast / surface policy).
32
+ */
33
+ export function validateHostBiomeComposition(
34
+ biomes: readonly FrontendBiome[],
35
+ ): readonly CompositionDiagnostic[] {
36
+ return validateBiomeComposition(biomes, { knownSlots: HOST_SLOT_IDS });
37
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Catalog of frontend extension points the host shell exposes to biomes.
3
+ *
4
+ * The host renders `<BiomeSlot name="…">` boundaries at the call sites
5
+ * below; biomes register `panels` against the same slot id in their
6
+ * `FrontendBiome` contribution, and the registry stitches the two
7
+ * together at runtime. The host itself is biome-agnostic — it knows
8
+ * nothing about which biome (if any) fills a given slot.
9
+ *
10
+ * Routes work the same way: biomes push `RouteContribution`s and the
11
+ * host calls `useBiomeRoutes()` to mount them. Nav items merge into
12
+ * `getNavSections()` likewise.
13
+ *
14
+ * ── Adding a new host extension point ────────────────────────────────
15
+ * 1. Add a new entry to `HostExtensionSlots` below with a JSDoc that
16
+ * describes WHERE the slot is rendered, WHAT biomes should put in
17
+ * it, and any in-scope CONTEXT (e.g., "run-detail page — runId is
18
+ * readable via the host bridge's location").
19
+ * 2. Mount `<BiomeSlot name={HostExtensionSlots.X} />` in the host
20
+ * page.
21
+ * 3. Document the slot in `data/docs/public/biomes/04-frontend-extensions.md`.
22
+ *
23
+ * Removing a host slot is a breaking change — bump the kernel package
24
+ * major version.
25
+ *
26
+ * ── Biome-owned extension points (cross-biome extension) ────────────
27
+ * Biomes can ALSO expose their own slots so OTHER biomes can extend
28
+ * THEM. The convention is to namespace biome-owned slot ids as
29
+ * `<biome-id>/<slot-name>` (e.g., `software-dev/page-actions`)
30
+ * and to publish the typed catalog from the biome's own package
31
+ * alongside its `FrontendBiomeFactory`. Other biomes import the
32
+ * exported constants directly. Result: the host doesn't see biome
33
+ * internals, biomes don't import each other's source — they meet at
34
+ * the slot-id strings, which are typed by the publishing biome.
35
+ *
36
+ * Slot-name collisions are caught at runtime by the registry's
37
+ * fail-fast duplicate-key guard, so two biomes can't shadow each
38
+ * other accidentally.
39
+ */
40
+ export const HostExtensionSlots = {
41
+ // ── Org-level shell ────────────────────────────────────────────────
42
+ /**
43
+ * Top-bar actions to the right of the org switcher. Visible on every
44
+ * authenticated page. Use for org-wide quick actions or status
45
+ * indicators (e.g., catalog instance health, Slack-notifier badge).
46
+ */
47
+ OrgHeaderActions: 'org-header-actions',
48
+
49
+ /**
50
+ * Cards on the public Biomes-overview page. Use for biome authors
51
+ * to advertise capabilities outside the authenticated app shell.
52
+ * (Reserved — host wiring may land later; safe to register today.)
53
+ */
54
+ BiomesOverviewCards: 'biomes-overview-cards',
55
+
56
+ // ── Project home ───────────────────────────────────────────────────
57
+ /**
58
+ * Cards on the project home dashboard, between the SetupChecklist
59
+ * and the ActivityTimeline. Use for biome-shipped status cards or
60
+ * quick-launch tiles. `bridge.auth.getProjectId()` is in scope.
61
+ */
62
+ ProjectOverviewCards: 'project-overview-cards',
63
+
64
+ /**
65
+ * Secondary cards on the project home, rendered below the activity
66
+ * timeline. Use for less prominent biome surfaces (recent runs,
67
+ * insights, recommendations).
68
+ */
69
+ ProjectOverviewSecondary: 'project-overview-secondary',
70
+
71
+ /**
72
+ * CTAs rendered into the dashboard's empty-state row when the project
73
+ * has no recent activity. Biomes can suggest "first run" actions.
74
+ */
75
+ DashboardEmptyState: 'dashboard-empty-state',
76
+
77
+ // ── Run detail ─────────────────────────────────────────────────────
78
+ /**
79
+ * Header chip row on the workflow run-detail page, alongside the
80
+ * status badge. Use for biome-shipped meta-actions (open in
81
+ * external system, copy entity ref, …).
82
+ */
83
+ RunDetailActions: 'run-detail-actions',
84
+
85
+ /**
86
+ * Side-panel cards on the workflow run-detail page, under the
87
+ * `ActivitySidebar`. Use for run-context biome surfaces (extracted
88
+ * entity refs, diff stats, biome-side telemetry). The current
89
+ * `runId` is readable from `bridge.navigation.useLocation()`.
90
+ */
91
+ RunDetailSidePanel: 'run-detail-side-panel',
92
+
93
+ // ── Interactive sessions ───────────────────────────────────────────
94
+ /**
95
+ * Action chips in the session detail page, alongside session controls.
96
+ * Use for biome shortcuts that are meaningful inside a session
97
+ * (open repo, open catalog entity, post to Slack, …).
98
+ */
99
+ SessionActions: 'session-actions',
100
+
101
+ /**
102
+ * Side-panel cards on the session detail page. Use for biome-driven
103
+ * context (related catalog entities, recent commits, …).
104
+ */
105
+ SessionSidePanel: 'session-side-panel',
106
+
107
+ /**
108
+ * Right-pane header strip in the session workspace (sessions +
109
+ * design-system-builder sessions). Sits to the LEFT of the host's hardcoded
110
+ * KB · Attachments · More · ActionsMenu icons. Use for compact
111
+ * icon-button actions tied to the preview surface — e.g.
112
+ * software-dev-web's Git commit/push/PR icons, a Slack "share
113
+ * preview" button, a catalog "open entity" link.
114
+ */
115
+ SessionRightHeader: 'session-right-header',
116
+
117
+ // ── Settings ───────────────────────────────────────────────────────
118
+ /**
119
+ * Tabs on the project Settings page. Each biome that contributes a
120
+ * panel here is rendered as a tab section under "Biomes". Use for
121
+ * per-project biome configuration (catalog instance URL +
122
+ * credentials ref, Slack channel mapping, …).
123
+ */
124
+ SettingsTabs: 'settings-tabs',
125
+ } as const;
126
+
127
+ /**
128
+ * Union of every host-defined slot id. Biome authors can use this in
129
+ * their `panels[].slot` field for compile-time spell-checking — but
130
+ * the runtime accepts any string, so biome-owned slots (`<biome-id>/x`)
131
+ * stay valid without modifying this catalog.
132
+ */
133
+ export type HostExtensionSlot =
134
+ (typeof HostExtensionSlots)[keyof typeof HostExtensionSlots];