@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,272 +0,0 @@
1
- /**
2
- * Typed selector hooks the host session shell calls to read biome
3
- * contributions for the current session. Each selector:
4
- *
5
- * 1. Walks `biomeRegistry.list()` once.
6
- * 2. Filters by the contribution's `appliesTo` predicate against the
7
- * current `SessionContext`.
8
- * 3. Sorts deterministically (`weight`/`order`, then `id`).
9
- * 4. Re-runs whenever the registry revision changes (biome add /
10
- * remove) or the session context changes.
11
- *
12
- * Selectors return frozen arrays — consumers should not mutate them.
13
- *
14
- * Naming: each selector is named after the contribution surface
15
- * (`useSessionSlashCommands`, `useSessionDrawerTabs`, …) so the call
16
- * site reads as "give me all session X for this context".
17
- */
18
- import { useMemo } from 'react';
19
-
20
- import {
21
- type ActivityRendererContribution,
22
- type AttachmentClassContribution,
23
- type HeaderChipContribution,
24
- type MutationBarContribution,
25
- type SecondaryDrawerTabContribution,
26
- type SessionActivityEvent,
27
- type SessionContext,
28
- type SessionToolCallEvent,
29
- type SlashCommandContribution,
30
- type ToolCallRendererContribution,
31
- biomeRegistry,
32
- useBiomeRegistryRevision,
33
- } from '../../index';
34
-
35
- function sortByWeight<
36
- T extends {
37
- readonly id: string;
38
- readonly weight?: number;
39
- readonly order?: number;
40
- },
41
- >(items: readonly T[]): readonly T[] {
42
- return [...items].sort((a, b) => {
43
- const aw = a.weight ?? a.order ?? 100;
44
- const bw = b.weight ?? b.order ?? 100;
45
- if (aw !== bw) {
46
- return aw - bw;
47
- }
48
- return a.id.localeCompare(b.id);
49
- });
50
- }
51
-
52
- type PredicateOf<T> = T extends {
53
- readonly appliesTo?: (...args: infer A) => boolean;
54
- }
55
- ? (...args: A) => boolean
56
- : never;
57
-
58
- function applies<
59
- T extends { readonly appliesTo?: (...args: never[]) => boolean },
60
- >(item: T, args: Parameters<PredicateOf<T>>): boolean {
61
- const predicate = item.appliesTo as PredicateOf<T> | undefined;
62
- return predicate === undefined ? true : predicate(...args);
63
- }
64
-
65
- // ── Slash commands ────────────────────────────────────────────────────
66
-
67
- export function useSessionSlashCommands(
68
- session: SessionContext,
69
- ): readonly SlashCommandContribution[] {
70
- const revision = useBiomeRegistryRevision();
71
- return useMemo(() => {
72
- const out: SlashCommandContribution[] = [];
73
- for (const biome of biomeRegistry.list()) {
74
- for (const cmd of biome.session?.slashCommands ?? []) {
75
- if (!applies(cmd, [session])) {
76
- continue;
77
- }
78
- out.push(cmd);
79
- }
80
- }
81
- return Object.freeze(sortByWeight(out));
82
- // eslint-disable-next-line react-hooks/exhaustive-deps
83
- }, [revision, session]);
84
- }
85
-
86
- // ── Secondary drawer tabs ─────────────────────────────────────────────
87
-
88
- export function useSessionDrawerTabs(
89
- session: SessionContext,
90
- ): readonly SecondaryDrawerTabContribution[] {
91
- const revision = useBiomeRegistryRevision();
92
- return useMemo(() => {
93
- const out: SecondaryDrawerTabContribution[] = [];
94
- for (const biome of biomeRegistry.list()) {
95
- for (const tab of biome.session?.secondaryDrawerTabs ?? []) {
96
- if (!applies(tab, [session])) {
97
- continue;
98
- }
99
- out.push(tab);
100
- }
101
- }
102
- return Object.freeze(sortByWeight(out));
103
- // eslint-disable-next-line react-hooks/exhaustive-deps
104
- }, [revision, session]);
105
- }
106
-
107
- // ── Activity renderers ────────────────────────────────────────────────
108
-
109
- /**
110
- * Hook returning the **first** activity renderer whose `entryKind`
111
- * matches the event AND whose `appliesTo` predicate passes. Returns
112
- * `null` if no biome handles this entry kind — the host then falls
113
- * back to its generic renderer.
114
- *
115
- * Ties broken by `id` so biome authors can predict which renderer
116
- * wins. To force a specific biome to win, use a lexicographically
117
- * smaller id (e.g. `'00-debug/…'`).
118
- */
119
- export function useActivityRenderer(
120
- session: SessionContext,
121
- event: SessionActivityEvent,
122
- ): ActivityRendererContribution | null {
123
- const revision = useBiomeRegistryRevision();
124
- return useMemo(() => {
125
- const candidates: ActivityRendererContribution[] = [];
126
- for (const biome of biomeRegistry.list()) {
127
- for (const r of biome.session?.activityRenderers ?? []) {
128
- if (r.entryKind !== event.kind) {
129
- continue;
130
- }
131
- if (!applies(r, [{ session, event }])) {
132
- continue;
133
- }
134
- candidates.push(r);
135
- }
136
- }
137
- if (candidates.length === 0) {
138
- return null;
139
- }
140
- return sortByWeight(candidates)[0] ?? null;
141
- // eslint-disable-next-line react-hooks/exhaustive-deps
142
- }, [revision, session, event]);
143
- }
144
-
145
- // ── Tool-call renderers ───────────────────────────────────────────────
146
-
147
- type ToolMatch = 'exact' | 'glob' | 'none';
148
-
149
- function matchToolName(toolName: string, eventName: string): ToolMatch {
150
- if (toolName === eventName) {
151
- return 'exact';
152
- }
153
- if (toolName.endsWith('.*') && eventName.startsWith(toolName.slice(0, -1))) {
154
- return 'glob';
155
- }
156
- return 'none';
157
- }
158
-
159
- function collectToolCallCandidates(
160
- session: SessionContext,
161
- event: SessionToolCallEvent,
162
- ): {
163
- exact: ToolCallRendererContribution[];
164
- glob: ToolCallRendererContribution[];
165
- } {
166
- const exact: ToolCallRendererContribution[] = [];
167
- const glob: ToolCallRendererContribution[] = [];
168
- for (const biome of biomeRegistry.list()) {
169
- for (const r of biome.session?.toolCallRenderers ?? []) {
170
- const match = matchToolName(r.toolName, event.name);
171
- if (match === 'none') {
172
- continue;
173
- }
174
- if (!applies(r, [{ session, event }])) {
175
- continue;
176
- }
177
- if (match === 'exact') {
178
- exact.push(r);
179
- } else {
180
- glob.push(r);
181
- }
182
- }
183
- }
184
- return { exact, glob };
185
- }
186
-
187
- /**
188
- * Tool-call renderer resolution. Exact `toolName` matches outrank glob
189
- * (`'<prefix>.*'`) matches; ties broken by `weight`, then `id`. Returns
190
- * `null` if no biome handles this tool — host falls back to its
191
- * generic key-value renderer.
192
- */
193
- export function useToolCallRenderer(
194
- session: SessionContext,
195
- event: SessionToolCallEvent,
196
- ): ToolCallRendererContribution | null {
197
- const revision = useBiomeRegistryRevision();
198
- return useMemo(() => {
199
- const { exact, glob } = collectToolCallCandidates(session, event);
200
- if (exact.length > 0) {
201
- return sortByWeight(exact)[0] ?? null;
202
- }
203
- if (glob.length > 0) {
204
- return sortByWeight(glob)[0] ?? null;
205
- }
206
- return null;
207
- // eslint-disable-next-line react-hooks/exhaustive-deps
208
- }, [revision, session, event]);
209
- }
210
-
211
- // ── Mutation bars ─────────────────────────────────────────────────────
212
-
213
- export function useSessionMutationBars(
214
- session: SessionContext,
215
- ): readonly MutationBarContribution[] {
216
- const revision = useBiomeRegistryRevision();
217
- return useMemo(() => {
218
- const out: MutationBarContribution[] = [];
219
- for (const biome of biomeRegistry.list()) {
220
- for (const bar of biome.session?.mutationBars ?? []) {
221
- if (!applies(bar, [session])) {
222
- continue;
223
- }
224
- out.push(bar);
225
- }
226
- }
227
- return Object.freeze(sortByWeight(out));
228
- // eslint-disable-next-line react-hooks/exhaustive-deps
229
- }, [revision, session]);
230
- }
231
-
232
- // ── Header chips ──────────────────────────────────────────────────────
233
-
234
- export function useSessionHeaderChips(
235
- session: SessionContext,
236
- ): readonly HeaderChipContribution[] {
237
- const revision = useBiomeRegistryRevision();
238
- return useMemo(() => {
239
- const out: HeaderChipContribution[] = [];
240
- for (const biome of biomeRegistry.list()) {
241
- for (const chip of biome.session?.headerChips ?? []) {
242
- if (!applies(chip, [session])) {
243
- continue;
244
- }
245
- out.push(chip);
246
- }
247
- }
248
- return Object.freeze(sortByWeight(out));
249
- // eslint-disable-next-line react-hooks/exhaustive-deps
250
- }, [revision, session]);
251
- }
252
-
253
- // ── Attachment classes ────────────────────────────────────────────────
254
-
255
- export function useSessionAttachmentClasses(
256
- session: SessionContext,
257
- ): readonly AttachmentClassContribution[] {
258
- const revision = useBiomeRegistryRevision();
259
- return useMemo(() => {
260
- const out: AttachmentClassContribution[] = [];
261
- for (const biome of biomeRegistry.list()) {
262
- for (const cls of biome.session?.attachmentClasses ?? []) {
263
- if (!applies(cls, [session])) {
264
- continue;
265
- }
266
- out.push(cls);
267
- }
268
- }
269
- return Object.freeze(sortByWeight(out));
270
- // eslint-disable-next-line react-hooks/exhaustive-deps
271
- }, [revision, session]);
272
- }
@@ -1,164 +0,0 @@
1
- import { cn } from '../lib/cn';
2
-
3
- import type { ReactNode } from 'react';
4
-
5
- /**
6
- * Generic, data-layer-agnostic comment shape. Host surfaces map their
7
- * own DTOs (KB `DocumentCommentResponseDto`, workflow `InquiryReply`,
8
- * …) into this before handing the array to `CommentRail`.
9
- */
10
- export interface RailComment {
11
- readonly id: string;
12
- readonly body: string;
13
- /** Anchored quote text shown above the body. Omit for whole-doc comments. */
14
- readonly quotedText?: string;
15
- /** `true` once the comment is resolved/closed. */
16
- readonly resolved: boolean;
17
- /** Optional author label (name / "Agent" / …). */
18
- readonly authorLabel?: string;
19
- }
20
-
21
- /**
22
- * Headless anchored-comment rail shared by every interactive-session
23
- * surface (Document Buddy today; workflow review once `ReviewRail`
24
- * migrates). It owns ONLY layout + rendering — no data fetching, no
25
- * mutations. The host passes:
26
- *
27
- * • `comments` — already-mapped `RailComment[]`
28
- * • `onResolve` — resolve callback (host owns the mutation)
29
- * • `composerSlot` — the host's composer node (host owns its state)
30
- * • `headerSlot` — optional extra header content
31
- *
32
- * Keeping it headless is what lets the same component render both KB
33
- * document comments and workflow review threads without either data
34
- * stack leaking into the package layer.
35
- */
36
- export function CommentRail({
37
- comments,
38
- title = 'Comments',
39
- emptyHint,
40
- composerSlot,
41
- headerSlot,
42
- onResolve,
43
- resolvingId,
44
- renderResolveIcon,
45
- renderResolvedIcon,
46
- }: {
47
- readonly comments: readonly RailComment[];
48
- readonly title?: string;
49
- readonly emptyHint?: ReactNode;
50
- readonly composerSlot?: ReactNode;
51
- readonly headerSlot?: ReactNode;
52
- readonly onResolve?: (id: string) => void;
53
- readonly resolvingId?: string | null;
54
- /** Host supplies the icon set so the package carries no icon dep. */
55
- readonly renderResolveIcon?: (busy: boolean) => ReactNode;
56
- readonly renderResolvedIcon?: () => ReactNode;
57
- }) {
58
- const open = comments.filter((c) => !c.resolved);
59
- const resolved = comments.filter((c) => c.resolved);
60
-
61
- return (
62
- <div className="flex h-full min-h-0 flex-col gap-2 bg-paper p-3 text-[12px]">
63
- <div className="flex items-center gap-2">
64
- <span className="font-medium text-ink">{title}</span>
65
- {open.length > 0 && (
66
- <span className="rounded-full bg-ink/10 px-2 py-0.5 text-[11px] text-ink-2">
67
- {open.length}
68
- </span>
69
- )}
70
- {headerSlot}
71
- </div>
72
-
73
- {composerSlot}
74
-
75
- {comments.length === 0 && !composerSlot && emptyHint && (
76
- <div className="text-ink-3">{emptyHint}</div>
77
- )}
78
-
79
- <div className="flex min-h-0 flex-1 flex-col gap-2 overflow-auto pr-1">
80
- {open.map((comment) => (
81
- <CommentRow
82
- key={comment.id}
83
- comment={comment}
84
- onResolve={onResolve}
85
- busy={resolvingId === comment.id}
86
- renderResolveIcon={renderResolveIcon}
87
- renderResolvedIcon={renderResolvedIcon}
88
- />
89
- ))}
90
- {resolved.length > 0 && (
91
- <div className="mt-1 text-[11px] uppercase tracking-wide text-ink-3">
92
- Resolved
93
- </div>
94
- )}
95
- {resolved.map((comment) => (
96
- <CommentRow
97
- key={comment.id}
98
- comment={comment}
99
- onResolve={onResolve}
100
- busy={resolvingId === comment.id}
101
- renderResolveIcon={renderResolveIcon}
102
- renderResolvedIcon={renderResolvedIcon}
103
- />
104
- ))}
105
- </div>
106
- </div>
107
- );
108
- }
109
-
110
- function CommentRow({
111
- comment,
112
- onResolve,
113
- busy,
114
- renderResolveIcon,
115
- renderResolvedIcon,
116
- }: {
117
- readonly comment: RailComment;
118
- readonly onResolve?: ((id: string) => void) | undefined;
119
- readonly busy: boolean;
120
- readonly renderResolveIcon?: ((busy: boolean) => ReactNode) | undefined;
121
- readonly renderResolvedIcon?: (() => ReactNode) | undefined;
122
- }) {
123
- return (
124
- <div
125
- className={cn(
126
- 'rounded-md border p-2',
127
- comment.resolved
128
- ? 'border-rule/60 bg-paper-elev/30 opacity-70'
129
- : 'border-rule/70 bg-paper-elev/40',
130
- )}
131
- >
132
- {comment.quotedText && (
133
- <div className="mb-1 border-l-2 border-[hsl(var(--comment-anchor))] pl-2 text-[11px] italic text-ink-3">
134
- “{comment.quotedText.slice(0, 120)}
135
- {comment.quotedText.length > 120 ? '…' : ''}”
136
- </div>
137
- )}
138
- <div className="flex items-start justify-between gap-2">
139
- <div className="flex flex-col gap-0.5">
140
- {comment.authorLabel && (
141
- <span className="text-[11px] font-medium text-ink-2">
142
- {comment.authorLabel}
143
- </span>
144
- )}
145
- <span className="whitespace-pre-wrap text-ink">{comment.body}</span>
146
- </div>
147
- {!comment.resolved && onResolve && (
148
- <button
149
- type="button"
150
- title="Resolve"
151
- disabled={busy}
152
- onClick={() => onResolve(comment.id)}
153
- className="flex h-6 w-6 shrink-0 items-center justify-center rounded text-ink-3 hover:bg-ink/5 hover:text-ink disabled:opacity-50"
154
- >
155
- {renderResolveIcon ? renderResolveIcon(busy) : busy ? '…' : '✓'}
156
- </button>
157
- )}
158
- {comment.resolved && renderResolvedIcon && (
159
- <span className="shrink-0 text-ink-3">{renderResolvedIcon()}</span>
160
- )}
161
- </div>
162
- </div>
163
- );
164
- }
@@ -1,3 +0,0 @@
1
- export { cn } from './lib/cn';
2
- export { SessionWorkspaceShell } from './shell/SessionWorkspaceShell';
3
- export { CommentRail, type RailComment } from './comments/CommentRail';
@@ -1,11 +0,0 @@
1
- import { clsx, type ClassValue } from 'clsx';
2
- import { twMerge } from 'tailwind-merge';
3
-
4
- /**
5
- * Tailwind-aware class merge. Local copy so this package stays
6
- * self-contained (no `@/lib/utils` host import) — the host shell has
7
- * its own identical `cn`, and the duplication is one trivial line.
8
- */
9
- export function cn(...inputs: ClassValue[]): string {
10
- return twMerge(clsx(inputs));
11
- }
@@ -1,147 +0,0 @@
1
- import { cn } from '../lib/cn';
2
-
3
- import type { CSSProperties, ReactNode, MouseEvent, RefObject } from 'react';
4
-
5
- interface SessionWorkspaceShellProps {
6
- /**
7
- * Container ref from `useHorizontalSplit`. The shell forwards mouse
8
- * coordinates to the hook through this ref.
9
- */
10
- readonly splitContainerRef: RefObject<HTMLDivElement>;
11
- /** Width of the left (chat) pane as a percentage 0-100. */
12
- readonly chatPanePercent: number;
13
- /** True while the resize handle is being dragged — applies cursor styling. */
14
- readonly isResizing: boolean;
15
- /** Mouse-down handler for the resize handle. */
16
- readonly startResize: (event: MouseEvent<HTMLElement>) => void;
17
-
18
- /** Mount for the Chat surface in the left pane. */
19
- readonly chatSlot: ReactNode;
20
- /**
21
- * Mount for the right (preview) pane. Pass `null` for sessions that
22
- * have no preview surface — the shell hides the right pane entirely
23
- * (and the resize handle along with it) so chat takes the full
24
- * width. Used by Document Buddy sessions, whose mechanic is a
25
- * file-backed sync loop, not a previewed project.
26
- */
27
- readonly previewSlot: ReactNode;
28
-
29
- /**
30
- * Optional header strip at the top of the RIGHT pane. Used for
31
- * preview-pane toolbars (KB references, attachments, actions menu).
32
- */
33
- readonly rightHeaderSlot?: ReactNode;
34
-
35
- /**
36
- * Optional content rendered *below* the chat surface, inside the left
37
- * pane. Used for things like Brainstorming's `PendingCommentsBar`.
38
- */
39
- readonly chatFooterSlot?: ReactNode;
40
-
41
- /**
42
- * When true, the left pane and resize handle are hidden — the preview
43
- * occupies the full width. Pages own this state.
44
- */
45
- readonly previewFullscreen?: boolean;
46
-
47
- /** Optional override for the minimum left pane width (default 320px). */
48
- readonly minLeftPaneWidth?: number;
49
- }
50
-
51
- /**
52
- * Two-pane workspace layout shared by interactive session-like pages
53
- * (sessions, design-system-builds, document buddy, …). The left pane renders
54
- * the chat surface; the right pane always renders the preview slot.
55
- *
56
- * Auxiliary surfaces (Activity, Files, …) are no longer panes — they are
57
- * surfaced through the floating `InspectorDock` and the right-pane
58
- * overflow menu, so the shell stays a clean chat ⇄ preview split.
59
- *
60
- * Lives in `@xemahq/ui-kernel/session` so every session-like
61
- * surface composes the identical layout. Biome extensibility lands
62
- * inside the slot content (chat, preview) via the host's
63
- * `HostExtensionSlots` SDK plumbing — the shell itself stays free of
64
- * biome coupling.
65
- */
66
- export function SessionWorkspaceShell({
67
- splitContainerRef,
68
- chatPanePercent,
69
- isResizing,
70
- startResize,
71
- chatSlot,
72
- previewSlot,
73
- rightHeaderSlot,
74
- chatFooterSlot,
75
- previewFullscreen = false,
76
- minLeftPaneWidth = 320,
77
- }: SessionWorkspaceShellProps) {
78
- // `previewSlot === null` means the session declared no preview
79
- // surface (Document Buddy). Hide the right pane + resize handle and
80
- // let the chat pane occupy the full width.
81
- const hasPreviewSlot = previewSlot !== null;
82
- // Below `lg` the two panes stack vertically (flex-col) and each takes the
83
- // full width; the chat pane's fixed width / minWidth split only applies at
84
- // `lg`+ where the resize handle is available. The width values ride on CSS
85
- // variables so the inline style never forces a side-by-side split on a
86
- // phone (Tailwind applies them only at the `lg` breakpoint).
87
- const leftPaneStyle: CSSProperties | undefined = hasPreviewSlot
88
- ? ({
89
- '--sws-min-left': `${minLeftPaneWidth}px`,
90
- '--sws-chat-pct': `${chatPanePercent}%`,
91
- } as CSSProperties)
92
- : undefined;
93
- return (
94
- <div
95
- ref={splitContainerRef}
96
- className={cn(
97
- 'relative flex h-full w-full flex-col overflow-hidden lg:flex-row',
98
- isResizing && 'cursor-col-resize',
99
- )}
100
- >
101
- {!previewFullscreen && (
102
- <div
103
- className={cn(
104
- 'flex w-full min-h-0 flex-col overflow-hidden bg-paper',
105
- hasPreviewSlot
106
- ? 'flex-1 lg:h-full lg:w-[var(--sws-chat-pct)] lg:min-w-[var(--sws-min-left)] lg:flex-none'
107
- : 'h-full',
108
- )}
109
- style={leftPaneStyle}
110
- >
111
- <div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
112
- <div className="relative min-h-0 min-w-0 flex-1">{chatSlot}</div>
113
- {chatFooterSlot}
114
- </div>
115
- </div>
116
- )}
117
-
118
- {!previewFullscreen && hasPreviewSlot && (
119
- <div className="relative hidden w-px shrink-0 bg-rule/30 lg:block">
120
- {/* Invisible 8px hot-environment for easier grabbing; visible divider
121
- stays a single hair-line. On hover we tint only a 1px
122
- accent column so the cursor change is the primary signal,
123
- not a fat coloured strip. */}
124
- <button
125
- type="button"
126
- onMouseDown={startResize}
127
- aria-label="Resize chat and preview panels"
128
- title="Drag to resize"
129
- className="group absolute inset-y-0 left-1/2 w-2 -translate-x-1/2 cursor-col-resize"
130
- >
131
- <span
132
- aria-hidden
133
- className="absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-transparent transition-colors group-hover:bg-primary/40"
134
- />
135
- </button>
136
- </div>
137
- )}
138
-
139
- {hasPreviewSlot && (
140
- <div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-paper">
141
- {rightHeaderSlot}
142
- <div className="min-h-0 flex-1 overflow-hidden">{previewSlot}</div>
143
- </div>
144
- )}
145
- </div>
146
- );
147
- }
@@ -1,89 +0,0 @@
1
- /**
2
- * Minimal action button used by the approval surfaces (card / sticky bar /
3
- * Center). The kit carries no button primitive, so this is a small,
4
- * inline-styled control matching the design's `Btn` (ghost / soft /
5
- * primary, with an optional accent override for critical-tier approve).
6
- *
7
- * Kept inside the approvals folder because it is only the approval
8
- * actions — it is NOT a general-purpose kit button.
9
- */
10
- import type { CSSProperties, ReactElement, ReactNode } from 'react';
11
-
12
- export type ApprovalButtonVariant = 'ghost' | 'soft' | 'primary';
13
- export type ApprovalButtonSize = 'xs' | 'sm';
14
-
15
- export interface ApprovalButtonProps {
16
- readonly variant?: ApprovalButtonVariant;
17
- readonly size?: ApprovalButtonSize;
18
- /** Accent for the `primary` variant background (e.g. portal/risk accent). */
19
- readonly accent?: string;
20
- readonly icon?: ReactNode;
21
- readonly disabled?: boolean;
22
- readonly onClick?: () => void;
23
- readonly children: ReactNode;
24
- }
25
-
26
- const PAD: Record<ApprovalButtonSize, string> = {
27
- xs: '3px 9px',
28
- sm: '5px 11px',
29
- };
30
-
31
- const FONT: Record<ApprovalButtonSize, number> = { xs: 12, sm: 12.5 };
32
-
33
- export function ApprovalButton({
34
- variant = 'ghost',
35
- size = 'sm',
36
- accent = 'hsl(var(--primary))',
37
- icon,
38
- disabled = false,
39
- onClick,
40
- children,
41
- }: ApprovalButtonProps): ReactElement {
42
- const base: CSSProperties = {
43
- display: 'inline-flex',
44
- alignItems: 'center',
45
- gap: 5,
46
- padding: PAD[size],
47
- fontSize: FONT[size],
48
- fontWeight: 550,
49
- borderRadius: 7,
50
- cursor: disabled ? 'not-allowed' : 'pointer',
51
- opacity: disabled ? 0.5 : 1,
52
- whiteSpace: 'nowrap',
53
- lineHeight: 1.2,
54
- };
55
- const variantStyle = resolveVariantStyle(variant, accent);
56
- return (
57
- <button
58
- type="button"
59
- disabled={disabled}
60
- onClick={onClick}
61
- style={{ ...base, ...variantStyle }}
62
- >
63
- {icon}
64
- {children}
65
- </button>
66
- );
67
- }
68
-
69
- function resolveVariantStyle(
70
- variant: ApprovalButtonVariant,
71
- accent: string,
72
- ): CSSProperties {
73
- switch (variant) {
74
- case 'primary':
75
- return { background: accent, color: '#fff', border: '1px solid transparent' };
76
- case 'soft':
77
- return {
78
- background: 'hsl(var(--muted))',
79
- color: 'hsl(var(--ink))',
80
- border: '1px solid hsl(var(--rule))',
81
- };
82
- case 'ghost':
83
- return {
84
- background: 'transparent',
85
- color: 'hsl(var(--ink-2))',
86
- border: '1px solid transparent',
87
- };
88
- }
89
- }