@xemahq/ui-kernel 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/ui/chrome/page-shell.d.ts +1 -1
  2. package/dist/ui/chrome/page-shell.d.ts.map +1 -1
  3. package/dist/ui/chrome/page-shell.js +9 -4
  4. package/dist/ui/chrome/page-shell.js.map +1 -1
  5. package/package.json +6 -4
  6. package/src/index.ts +0 -17
  7. package/src/lib/biome-host/agent-validation.ts +0 -239
  8. package/src/lib/biome-host/biome-builders.ts +0 -112
  9. package/src/lib/biome-host/biome-mode.ts +0 -6
  10. package/src/lib/biome-host/biome-navigation.ts +0 -37
  11. package/src/lib/biome-host/biome-registry.ts +0 -299
  12. package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
  13. package/src/lib/biome-host/biome-scope.tsx +0 -52
  14. package/src/lib/biome-host/biome-scoped-query.ts +0 -134
  15. package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
  16. package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
  17. package/src/lib/biome-host/define-web-biome.ts +0 -222
  18. package/src/lib/biome-host/errors.ts +0 -220
  19. package/src/lib/biome-host/frontend-biome.ts +0 -256
  20. package/src/lib/biome-host/host-bridge.ts +0 -281
  21. package/src/lib/biome-host/host-sources.ts +0 -54
  22. package/src/lib/biome-host/i18n-hooks.ts +0 -51
  23. package/src/lib/biome-host/i18n-port.test.ts +0 -50
  24. package/src/lib/biome-host/i18n-port.ts +0 -96
  25. package/src/lib/biome-host/index.ts +0 -35
  26. package/src/lib/biome-host/realtime-hooks.ts +0 -75
  27. package/src/lib/biome-host/realtime-port.ts +0 -115
  28. package/src/lib/biome-host/session-contributions.ts +0 -296
  29. package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
  30. package/src/lib/biome-host/use-page-state.ts +0 -248
  31. package/src/lib/capabilities/capability-context.ts +0 -25
  32. package/src/lib/capabilities/capability-provider.tsx +0 -73
  33. package/src/lib/capabilities/index.ts +0 -17
  34. package/src/lib/capabilities/types.ts +0 -69
  35. package/src/lib/capabilities/use-capability.ts +0 -79
  36. package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
  37. package/src/lib/contribution-registry/contribution-registry.ts +0 -204
  38. package/src/lib/contribution-registry/index.ts +0 -9
  39. package/src/lib/contribution-registry/renderable-registry.ts +0 -142
  40. package/src/lib/system-bus/capability-invoke.ts +0 -92
  41. package/src/lib/system-bus/deeplink.ts +0 -210
  42. package/src/lib/system-bus/enums.ts +0 -86
  43. package/src/lib/system-bus/host-ports.ts +0 -93
  44. package/src/lib/system-bus/index.ts +0 -16
  45. package/src/lib/system-bus/intent-registry.ts +0 -109
  46. package/src/lib/system-bus/intents.ts +0 -113
  47. package/src/lib/system-bus/palette.ts +0 -78
  48. package/src/lib/system-bus/system-bus-builder.ts +0 -159
  49. package/src/lib/system-bus/system-bus.ts +0 -37
  50. package/src/lib/system-bus/windows.ts +0 -51
  51. package/src/offline/id.ts +0 -16
  52. package/src/offline/index.ts +0 -54
  53. package/src/offline/mutation.ts +0 -75
  54. package/src/offline/offline-status-badge.tsx +0 -51
  55. package/src/offline/online-controller.ts +0 -105
  56. package/src/offline/outbox.test.ts +0 -172
  57. package/src/offline/outbox.ts +0 -348
  58. package/src/offline/react-hooks.ts +0 -40
  59. package/src/offline/react.tsx +0 -32
  60. package/src/offline/storage.ts +0 -112
  61. package/src/offline/types.ts +0 -77
  62. package/src/org-db/components/DbResultTable.tsx +0 -176
  63. package/src/org-db/index.ts +0 -1
  64. package/src/pdf/index.ts +0 -11
  65. package/src/registry/index.ts +0 -9
  66. package/src/registry/lib/agent-validation-host.ts +0 -36
  67. package/src/registry/lib/biome-slot.tsx +0 -50
  68. package/src/registry/lib/biomes-enabled-context.ts +0 -20
  69. package/src/registry/lib/extension-points.ts +0 -134
  70. package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
  71. package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
  72. package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
  73. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
  74. package/src/registry/lib/primitives/index.ts +0 -18
  75. package/src/registry/lib/session-context-builder.ts +0 -84
  76. package/src/registry/lib/session-context-provider.tsx +0 -33
  77. package/src/registry/lib/session-context.ts +0 -21
  78. package/src/registry/lib/session-selectors.ts +0 -272
  79. package/src/session/comments/CommentRail.tsx +0 -164
  80. package/src/session/index.ts +0 -3
  81. package/src/session/lib/cn.ts +0 -11
  82. package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
  83. package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
  84. package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
  85. package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
  86. package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
  87. package/src/session-kit/approvals/Obligation.tsx +0 -111
  88. package/src/session-kit/approvals/ScopedBody.tsx +0 -392
  89. package/src/session-kit/approvals/approval-icons.ts +0 -31
  90. package/src/session-kit/approvals/approval-model.ts +0 -204
  91. package/src/session-kit/approvals/index.ts +0 -22
  92. package/src/session-kit/approvals/obligation-display.ts +0 -100
  93. package/src/session-kit/approvals/risk-accent.ts +0 -47
  94. package/src/session-kit/approvals/scope-icons.ts +0 -19
  95. package/src/session-kit/combobox/Combobox.tsx +0 -358
  96. package/src/session-kit/combobox/use-click-outside.ts +0 -21
  97. package/src/session-kit/display/ContextHeader.tsx +0 -148
  98. package/src/session-kit/display/FileDiffCard.tsx +0 -140
  99. package/src/session-kit/display/MD.tsx +0 -162
  100. package/src/session-kit/display/MessageTurn.tsx +0 -157
  101. package/src/session-kit/display/ThinkingPanel.tsx +0 -81
  102. package/src/session-kit/display/TodoChecklist.tsx +0 -120
  103. package/src/session-kit/display/TokenMeter.tsx +0 -89
  104. package/src/session-kit/display/ToolStrip.tsx +0 -278
  105. package/src/session-kit/display/TypingDots.tsx +0 -24
  106. package/src/session-kit/index.ts +0 -44
  107. package/src/session-kit/lib/enums.ts +0 -66
  108. package/src/session-kit/lib/portal-accent.ts +0 -30
  109. package/src/session-kit/lib/status-dot.ts +0 -68
  110. package/src/session-kit/primitives/Avatar.tsx +0 -44
  111. package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
  112. package/src/session-kit/primitives/RiskPill.tsx +0 -95
  113. package/src/session-kit/primitives/ScopeDot.tsx +0 -47
  114. package/src/session-kit/primitives/Segmented.tsx +0 -71
  115. package/src/ui/branding/app-branding-context.ts +0 -20
  116. package/src/ui/branding/app-branding-provider.tsx +0 -123
  117. package/src/ui/branding/sanitize.ts +0 -89
  118. package/src/ui/breakpoints.ts +0 -14
  119. package/src/ui/capture/document-preview.tsx +0 -166
  120. package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
  121. package/src/ui/capture/field-spec-to-zod.ts +0 -174
  122. package/src/ui/capture/field-spec-validate.ts +0 -236
  123. package/src/ui/capture/field-spec.test.ts +0 -49
  124. package/src/ui/capture/field-spec.ts +0 -274
  125. package/src/ui/capture/index.ts +0 -51
  126. package/src/ui/capture/schema-field-input.tsx +0 -620
  127. package/src/ui/capture/schema-form.tsx +0 -149
  128. package/src/ui/capture/submit-values.test.ts +0 -70
  129. package/src/ui/capture/submit-values.ts +0 -63
  130. package/src/ui/capture/use-prefill.ts +0 -186
  131. package/src/ui/capture/use-schema-validation.ts +0 -145
  132. package/src/ui/capture/use-wizard.ts +0 -180
  133. package/src/ui/capture/value-format.ts +0 -32
  134. package/src/ui/capture/wizard.tsx +0 -105
  135. package/src/ui/charts/bar-chart.tsx +0 -139
  136. package/src/ui/charts/chart-frame.tsx +0 -125
  137. package/src/ui/charts/chart-types.ts +0 -52
  138. package/src/ui/charts/chart-utils.ts +0 -190
  139. package/src/ui/charts/charts.test.tsx +0 -204
  140. package/src/ui/charts/donut-chart.tsx +0 -129
  141. package/src/ui/charts/index.ts +0 -27
  142. package/src/ui/charts/line-chart.tsx +0 -202
  143. package/src/ui/charts/sparkline.tsx +0 -109
  144. package/src/ui/chrome/AsyncBoundary.tsx +0 -74
  145. package/src/ui/chrome/EmptyState.tsx +0 -257
  146. package/src/ui/chrome/ErrorCard.tsx +0 -63
  147. package/src/ui/chrome/LoadingState.tsx +0 -61
  148. package/src/ui/chrome/PageHeader.tsx +0 -137
  149. package/src/ui/chrome/RecordCardList.tsx +0 -98
  150. package/src/ui/chrome/StateCard.tsx +0 -150
  151. package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
  152. package/src/ui/chrome/page-shell.tsx +0 -189
  153. package/src/ui/chrome/scope-badge.tsx +0 -40
  154. package/src/ui/chrome/status-badge.tsx +0 -79
  155. package/src/ui/cn.ts +0 -32
  156. package/src/ui/design-tokens.ts +0 -372
  157. package/src/ui/hooks/use-debounced-value.ts +0 -16
  158. package/src/ui/hooks/use-is-mobile.ts +0 -28
  159. package/src/ui/index.ts +0 -110
  160. package/src/ui/pdf/pdf-preview.tsx +0 -122
  161. package/src/ui/primitives/alert-dialog.tsx +0 -104
  162. package/src/ui/primitives/async-combobox.tsx +0 -182
  163. package/src/ui/primitives/badge-variants.ts +0 -21
  164. package/src/ui/primitives/badge.tsx +0 -25
  165. package/src/ui/primitives/button-variants.ts +0 -31
  166. package/src/ui/primitives/button.tsx +0 -29
  167. package/src/ui/primitives/card.tsx +0 -43
  168. package/src/ui/primitives/checkbox.tsx +0 -26
  169. package/src/ui/primitives/collapsible.tsx +0 -9
  170. package/src/ui/primitives/dialog.tsx +0 -103
  171. package/src/ui/primitives/dropdown-menu.tsx +0 -179
  172. package/src/ui/primitives/form-stepper.tsx +0 -94
  173. package/src/ui/primitives/form-stepper.types.ts +0 -15
  174. package/src/ui/primitives/input.tsx +0 -22
  175. package/src/ui/primitives/label.tsx +0 -17
  176. package/src/ui/primitives/overflow-tabs.tsx +0 -331
  177. package/src/ui/primitives/popover.tsx +0 -33
  178. package/src/ui/primitives/preview-device-frame.tsx +0 -213
  179. package/src/ui/primitives/radio-group.tsx +0 -36
  180. package/src/ui/primitives/resizable.tsx +0 -67
  181. package/src/ui/primitives/scroll-area.tsx +0 -38
  182. package/src/ui/primitives/select.tsx +0 -143
  183. package/src/ui/primitives/separator.tsx +0 -20
  184. package/src/ui/primitives/sheet.tsx +0 -107
  185. package/src/ui/primitives/skeleton.tsx +0 -99
  186. package/src/ui/primitives/switch.tsx +0 -27
  187. package/src/ui/primitives/table.tsx +0 -72
  188. package/src/ui/primitives/tabs.tsx +0 -53
  189. package/src/ui/primitives/tag-multi-select.tsx +0 -261
  190. package/src/ui/primitives/textarea.tsx +0 -21
  191. package/src/ui/primitives/tooltip.tsx +0 -30
  192. package/src/ui/primitives/url-preview-chrome.tsx +0 -103
  193. package/src/vista/GenericCatalogueSurface.tsx +0 -179
  194. package/src/vista/SurfaceFallbackCard.tsx +0 -109
  195. package/src/vista/VistaPanel.tsx +0 -163
  196. package/src/vista/form-payload.spec.ts +0 -139
  197. package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
  198. package/src/vista/html/CustomUiFrame.tsx +0 -206
  199. package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
  200. package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
  201. package/src/vista/html/custom-ui-frame-contract.ts +0 -88
  202. package/src/vista/html/custom-ui-intents.spec.ts +0 -135
  203. package/src/vista/html/custom-ui-intents.ts +0 -155
  204. package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
  205. package/src/vista/html/custom-ui-srcdoc.ts +0 -193
  206. package/src/vista/html/index.ts +0 -13
  207. package/src/vista/index.ts +0 -52
  208. package/src/vista/surface-catalogue.spec.ts +0 -140
  209. package/src/vista/surface-catalogue.ts +0 -90
  210. package/src/vista/surface-icons.ts +0 -57
  211. package/src/vista/surface-registry.ts +0 -56
  212. package/src/vista/surfaces/ChartSurface.tsx +0 -34
  213. package/src/vista/surfaces/FilesSurface.tsx +0 -202
  214. package/src/vista/surfaces/FormSurface.tsx +0 -380
  215. package/src/vista/surfaces/HtmlSurface.tsx +0 -43
  216. package/src/vista/surfaces/TableSurface.tsx +0 -100
  217. package/src/vista/surfaces/UrlSurface.tsx +0 -40
  218. package/src/vista/surfaces/blob-surfaces.tsx +0 -139
  219. package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
  220. package/src/vista/surfaces/elicitation-transport.ts +0 -367
  221. package/src/vista/surfaces/file-surface-utils.ts +0 -69
  222. package/src/vista/surfaces/index.ts +0 -24
  223. package/src/vista/surfaces/register-surfaces.tsx +0 -139
  224. package/src/vista/surfaces/text-surfaces.tsx +0 -132
  225. package/src/vista/use-vista-tabs.ts +0 -196
  226. package/src/vista/vista-code-renderer-context.ts +0 -16
  227. package/src/vista/vista-code-renderer.tsx +0 -35
  228. package/src/vista/vista-file-context.ts +0 -14
  229. package/src/vista/vista-file-source.tsx +0 -141
  230. package/src/vista/vista-form-context.ts +0 -20
  231. package/src/vista/vista-form-host.tsx +0 -48
  232. package/src/vista/vista-model.ts +0 -137
  233. package/src/vista/vista-open-context.tsx +0 -27
  234. package/src/vista/vista-open-state.ts +0 -11
  235. package/src/vista/vista-payloads.ts +0 -635
  236. package/src/vista/vista-tabs-manifest.ts +0 -138
  237. package/src/vista/vista-tools.ts +0 -232
@@ -1,202 +0,0 @@
1
- /**
2
- * `SurfaceKind.Files` — the grouped file browser, and the pinned first tab of
3
- * every file-backed Vista panel.
4
- *
5
- * Moved out of the thin session workspace (`WorkspaceFileBrowser` +
6
- * `workspace-model`'s grouping/extension helpers) so the Design-System-Builder
7
- * file tab, the session workspace, and any agent-opened `files` surface draw the
8
- * SAME browser. Grouped by folder with a caption header; each row is a
9
- * colour-coded extension tile + filename + change badges. Clicking a row opens
10
- * the file as its own tab through {@link useVistaOpen}.
11
- */
12
- import { ChevronRight, Folder } from 'lucide-react';
13
-
14
-
15
- import { fileSurface } from '../vista-model';
16
- import { useVistaOpen } from '../vista-open-state';
17
- import { fileExtMeta, groupFilesByFolder } from './file-surface-utils';
18
-
19
- import type { VistaFileEntry, VistaFilesPayload } from '../vista-payloads';
20
- import type { ReactElement } from 'react';
21
-
22
- export function FilesSurface({
23
- files,
24
- }: Readonly<VistaFilesPayload>): ReactElement {
25
- const open = useVistaOpen();
26
- const groups = groupFilesByFolder(files);
27
- if (groups.length === 0) {
28
- return (
29
- <div
30
- style={{
31
- height: '100%',
32
- display: 'grid',
33
- placeItems: 'center',
34
- fontSize: 12.5,
35
- color: 'hsl(var(--ink-4))',
36
- }}
37
- >
38
- No files in the workspace yet.
39
- </div>
40
- );
41
- }
42
- return (
43
- <div style={{ height: '100%', overflowY: 'auto', padding: '14px 12px' }}>
44
- {groups.map((group) => (
45
- <section key={group.dir || 'root'} style={{ marginBottom: 16 }}>
46
- <div
47
- style={{
48
- display: 'flex',
49
- alignItems: 'center',
50
- gap: 6,
51
- padding: '0 8px 8px',
52
- }}
53
- >
54
- <Folder size={12} style={{ color: 'hsl(var(--ink-4))' }} />
55
- <span
56
- className="cap"
57
- style={{ fontSize: 9.5, letterSpacing: '0.07em' }}
58
- >
59
- {group.dir ? group.dir.replaceAll('/', ' / ') : 'Root'}
60
- </span>
61
- </div>
62
- <div style={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
63
- {group.files.map((file) => (
64
- <FileRow
65
- key={file.path}
66
- file={file}
67
- onOpen={
68
- open === null
69
- ? null
70
- : () => {
71
- open(fileSurface(file.path));
72
- }
73
- }
74
- />
75
- ))}
76
- </div>
77
- </section>
78
- ))}
79
- </div>
80
- );
81
- }
82
-
83
- function FileRow({
84
- file,
85
- onOpen,
86
- }: Readonly<{
87
- file: VistaFileEntry;
88
- onOpen: (() => void) | null;
89
- }>): ReactElement {
90
- const name = file.path.split('/').pop() ?? file.path;
91
- const meta = fileExtMeta(name);
92
- const changed = file.add !== undefined || file.del !== undefined;
93
- const body = (
94
- <>
95
- <span
96
- style={{
97
- width: 28,
98
- height: 28,
99
- borderRadius: 8,
100
- flexShrink: 0,
101
- display: 'grid',
102
- placeItems: 'center',
103
- background: `color-mix(in oklch, ${meta.color} 13%, transparent)`,
104
- border: `1px solid color-mix(in oklch, ${meta.color} 26%, transparent)`,
105
- }}
106
- >
107
- <span
108
- className="mono"
109
- style={{
110
- fontSize: 8,
111
- fontWeight: 700,
112
- color: meta.color,
113
- letterSpacing: '0.02em',
114
- }}
115
- >
116
- {meta.tag}
117
- </span>
118
- </span>
119
- <span style={{ flex: 1, minWidth: 0 }}>
120
- <span
121
- style={{
122
- display: 'block',
123
- fontSize: 13,
124
- fontWeight: 500,
125
- color: 'hsl(var(--ink))',
126
- overflow: 'hidden',
127
- textOverflow: 'ellipsis',
128
- whiteSpace: 'nowrap',
129
- }}
130
- >
131
- {name}
132
- </span>
133
- {changed && (
134
- <span
135
- className="mono"
136
- style={{ fontSize: 10, color: 'hsl(var(--ink-4))' }}
137
- >
138
- changed
139
- </span>
140
- )}
141
- </span>
142
- {changed && (
143
- <span style={{ display: 'inline-flex', gap: 6, flexShrink: 0 }}>
144
- {file.add !== undefined && file.add > 0 && (
145
- <span
146
- className="mono"
147
- style={{ fontSize: 10.5, color: 'hsl(var(--success))' }}
148
- >
149
- +{file.add}
150
- </span>
151
- )}
152
- {file.del !== undefined && file.del > 0 && (
153
- <span
154
- className="mono"
155
- style={{
156
- fontSize: 10.5,
157
- color: 'hsl(var(--destructive, var(--danger)))',
158
- }}
159
- >
160
- −{file.del}
161
- </span>
162
- )}
163
- </span>
164
- )}
165
- {onOpen !== null && (
166
- <ChevronRight
167
- size={13}
168
- style={{ color: 'hsl(var(--ink-4))', flexShrink: 0, opacity: 0.6 }}
169
- />
170
- )}
171
- </>
172
- );
173
-
174
- const rowStyle = {
175
- display: 'flex',
176
- alignItems: 'center',
177
- gap: 11,
178
- width: '100%',
179
- padding: '8px 9px',
180
- borderRadius: 9,
181
- textAlign: 'left',
182
- } as const;
183
-
184
- if (onOpen === null) {
185
- return <div style={rowStyle}>{body}</div>;
186
- }
187
- return (
188
- <button
189
- type="button"
190
- onClick={onOpen}
191
- style={{ ...rowStyle, transition: 'background 140ms ease' }}
192
- onMouseEnter={(e) => {
193
- e.currentTarget.style.background = 'hsl(var(--paper-elev))';
194
- }}
195
- onMouseLeave={(e) => {
196
- e.currentTarget.style.background = 'transparent';
197
- }}
198
- >
199
- {body}
200
- </button>
201
- );
202
- }
@@ -1,380 +0,0 @@
1
- /**
2
- * `SurfaceKind.Form` — the secure-elicitation surface (Canopy §8.4).
3
- *
4
- * The agent asks for a credential it must never see. This surface renders the
5
- * connector's ONBOARDING form (or, for `oauth2` / `app_install`, the consent
6
- * link), captures the values in local state, and POSTs them BROWSER → OWNING
7
- * SERVICE with the SUBJECT's own JWT. The agent learns only
8
- * `{ submitted, ref }`.
9
- *
10
- * ── What makes the value unreachable from the agent ─────────────────────────
11
- * • the only outbound channel is `host.onOutcome(VistaFormOutcome)`, whose
12
- * type has three scalar members and no place a value could be assigned;
13
- * • the values live in this component's `useState`; the single reader is
14
- * `submitElicitationFields`, which takes them as a parameter and returns an
15
- * outcome — the values are not reachable from any return or any throw;
16
- * • the payload has NO URL authority. The exact endpoints are derived from
17
- * the trusted elicitation API base URL supplied by `VistaFormHost`;
18
- * • secret fields are DECLARED (`spec.isSecret`) and render write-only; the
19
- * surface holds no cache and no read path repopulates them.
20
- *
21
- * Nothing here is provider-aware. Whether the flow is a field form or an OAuth
22
- * handoff is decided by the payload the owning service produced.
23
- */
24
- import {
25
- AlertTriangle,
26
- CheckCircle2,
27
- ExternalLink,
28
- Loader2,
29
- ShieldCheck,
30
- } from 'lucide-react';
31
- import {
32
- useCallback,
33
- useEffect,
34
- useState,
35
- type ReactElement,
36
- type ReactNode,
37
- } from 'react';
38
-
39
- import {
40
- readElicitationStatus,
41
- resolveTrustedElicitationEndpoints,
42
- resolveTrustedElicitationLaunchUrl,
43
- submitElicitationFields,
44
- VistaFormSubmitError,
45
- } from './elicitation-transport';
46
- import { SchemaForm } from '../../ui/capture/schema-form';
47
- import { captureValuesToStringMap } from '../../ui/capture/submit-values';
48
- import { useSchemaValidation } from '../../ui/capture/use-schema-validation';
49
- import { cn } from '../../ui/cn';
50
- import { Button } from '../../ui/primitives/button';
51
- import { useVistaFormHost, type VistaFormOutcome } from '../vista-form-context';
52
-
53
- import type { CaptureValues } from '../../ui/capture/field-spec';
54
- import type { VistaFormPayload } from '../vista-payloads';
55
-
56
- /** Explicit lifecycle. No implicit "maybe submitted" state. */
57
- enum FormPhase {
58
- Editing = 'editing',
59
- Working = 'working',
60
- Settled = 'settled',
61
- }
62
-
63
- export function FormSurface(payload: Readonly<VistaFormPayload>): ReactElement {
64
- const host = useVistaFormHost();
65
- const [values, setValues] = useState<CaptureValues>({});
66
- const [phase, setPhase] = useState<FormPhase>(FormPhase.Editing);
67
- const [serviceError, setServiceError] = useState<string | null>(null);
68
- const [showFieldErrors, setShowFieldErrors] = useState(false);
69
- const [outcome, setOutcome] = useState<VistaFormOutcome | null>(null);
70
- const { errors, isValid } = useSchemaValidation(payload.fields, values);
71
- let transportConfigurationError: string | null = null;
72
- let launchUrl: string | undefined;
73
- if (host !== null) {
74
- try {
75
- // Validate the trust anchor before retrieving a bearer token or accepting
76
- // a submit action. The transport repeats this check at the fetch boundary.
77
- resolveTrustedElicitationEndpoints(
78
- host.elicitationApiBaseUrl,
79
- payload.ref,
80
- );
81
- if (payload.launch !== undefined) {
82
- launchUrl = resolveTrustedElicitationLaunchUrl(
83
- host.elicitationApiBaseUrl,
84
- payload.launch.path,
85
- );
86
- }
87
- } catch (error) {
88
- transportConfigurationError =
89
- error instanceof Error
90
- ? error.message
91
- : 'The trusted elicitation service is not configured safely.';
92
- }
93
- }
94
-
95
- const settle = useCallback(
96
- (next: VistaFormOutcome): void => {
97
- // The values are dropped the moment the elicitation settles: nothing in
98
- // this component may outlive the submission holding secret material.
99
- setValues({});
100
- setOutcome(next);
101
- setPhase(FormPhase.Settled);
102
- host?.onOutcome(next);
103
- },
104
- [host],
105
- );
106
-
107
- const failed = useCallback((error: unknown): void => {
108
- setServiceError(
109
- error instanceof VistaFormSubmitError || error instanceof Error
110
- ? error.message
111
- : 'The submission could not be completed.',
112
- );
113
- setPhase(FormPhase.Editing);
114
- }, []);
115
-
116
- const handleSubmit = useCallback((): void => {
117
- if (host === null) {
118
- return;
119
- }
120
- setShowFieldErrors(true);
121
- if (!isValid) {
122
- return;
123
- }
124
- setServiceError(null);
125
- setPhase(FormPhase.Working);
126
- // The values object is a PARAMETER here and nowhere else. It is never
127
- // returned, logged, or handed to a callback.
128
- void host
129
- .getAccessToken()
130
- .then((accessToken) =>
131
- submitElicitationFields({
132
- apiBaseUrl: host.elicitationApiBaseUrl,
133
- ref: payload.ref,
134
- accessToken,
135
- fields: captureValuesToStringMap(payload.fields, values),
136
- }),
137
- )
138
- .then(settle, failed);
139
- }, [host, isValid, payload.fields, payload.ref, settle, failed, values]);
140
-
141
- const handleCheckStatus = useCallback((): void => {
142
- if (host === null) {
143
- return;
144
- }
145
- setServiceError(null);
146
- setPhase(FormPhase.Working);
147
- void host
148
- .getAccessToken()
149
- .then((accessToken) =>
150
- readElicitationStatus({
151
- apiBaseUrl: host.elicitationApiBaseUrl,
152
- ref: payload.ref,
153
- accessToken,
154
- }),
155
- )
156
- .then((next) => {
157
- if (next === null) {
158
- setServiceError(
159
- 'Not completed yet — finish the steps in the other window, then check again.',
160
- );
161
- setPhase(FormPhase.Editing);
162
- return;
163
- }
164
- settle(next);
165
- }, failed);
166
- }, [host, payload.ref, settle, failed]);
167
-
168
- // The consent/install window is a separate browsing context, so the only
169
- // signal this tab gets is the user returning to it. Re-checking on focus is
170
- // an event, not a timer — there is no polling loop and no timeout.
171
- const isLaunch = payload.launch !== undefined;
172
- useEffect(() => {
173
- if (!isLaunch || phase === FormPhase.Settled || host === null) {
174
- return;
175
- }
176
- const onFocus = (): void => handleCheckStatus();
177
- const addEventListener: unknown = Reflect.get(globalThis, 'addEventListener');
178
- if (typeof addEventListener !== 'function') {
179
- return;
180
- }
181
- Reflect.apply(addEventListener, globalThis, ['focus', onFocus]);
182
- return () => {
183
- const removeEventListener: unknown = Reflect.get(
184
- globalThis,
185
- 'removeEventListener',
186
- );
187
- if (typeof removeEventListener === 'function') {
188
- Reflect.apply(removeEventListener, globalThis, ['focus', onFocus]);
189
- }
190
- };
191
- // `handleCheckStatus` is stable per (host, payload) and re-subscribing on a
192
- // phase change is intended: a settled surface stops listening.
193
- }, [isLaunch, phase, host, handleCheckStatus]);
194
-
195
- if (host === null) {
196
- return (
197
- <Shell heading={payload.heading} purpose={payload.purpose}>
198
- <Notice tone="error" title="This form cannot be submitted here">
199
- No form host is mounted for this panel, so there is no way to sign the
200
- request as you. Open the request from a surface that provides one.
201
- </Notice>
202
- </Shell>
203
- );
204
- }
205
-
206
- if (transportConfigurationError !== null) {
207
- return (
208
- <Shell heading={payload.heading} purpose={payload.purpose}>
209
- <Notice
210
- tone="error"
211
- title="The secure service is not configured safely"
212
- >
213
- {transportConfigurationError}
214
- </Notice>
215
- </Shell>
216
- );
217
- }
218
-
219
- if (phase === FormPhase.Settled && outcome !== null) {
220
- return (
221
- <Shell heading={payload.heading} purpose={payload.purpose}>
222
- <div className="flex items-start gap-2 rounded-md border border-rule bg-paper-elev p-3">
223
- <CheckCircle2 className="mt-0.5 h-4 w-4 shrink-0 text-primary" />
224
- <div className="space-y-0.5">
225
- <p className="text-body-1 font-medium text-ink">Submitted.</p>
226
- <p className="text-caption text-ink-3">
227
- The value went straight to the service and was never shown to the
228
- agent
229
- {outcome.connectionId === null
230
- ? '.'
231
- : `. Connection ${outcome.connectionId} is ready.`}
232
- </p>
233
- </div>
234
- </div>
235
- </Shell>
236
- );
237
- }
238
-
239
- const working = phase === FormPhase.Working;
240
-
241
- return (
242
- <Shell heading={payload.heading} purpose={payload.purpose}>
243
- {payload.launch !== undefined ? (
244
- <>
245
- {payload.launch.hint !== undefined && (
246
- <p className="text-body-1 text-ink-3">{payload.launch.hint}</p>
247
- )}
248
- <div className="flex flex-wrap items-center gap-2">
249
- <Button
250
- onClick={() => {
251
- // `launchUrl` was derived from the host trust anchor above; the
252
- // payload contributes only a validated same-origin path.
253
- globalThis.open(launchUrl, '_blank', 'noopener,noreferrer');
254
- }}
255
- className="gap-1.5"
256
- disabled={working}
257
- >
258
- <ExternalLink className="h-4 w-4" />
259
- {payload.launch.label}
260
- </Button>
261
- <Button
262
- variant="outline"
263
- onClick={handleCheckStatus}
264
- disabled={working}
265
- >
266
- {working && <Loader2 className="mr-1 h-4 w-4 animate-spin" />}
267
- I&apos;ve finished — check
268
- </Button>
269
- </div>
270
- </>
271
- ) : (
272
- <>
273
- {payload.fields.length === 0 && (
274
- <Notice tone="warn" title="No form fields were declared">
275
- This connector declares no onboarding form. Submitting will ask
276
- the service, which is the authority on whether that is allowed.
277
- </Notice>
278
- )}
279
- <SchemaForm
280
- fields={payload.fields}
281
- values={values}
282
- onChange={setValues}
283
- disabled={working}
284
- {...(showFieldErrors ? { errors } : {})}
285
- />
286
- <div className="flex items-center gap-2">
287
- <Button onClick={handleSubmit} disabled={working}>
288
- {working && <Loader2 className="mr-1 h-4 w-4 animate-spin" />}
289
- {payload.submitLabel ?? 'Submit securely'}
290
- </Button>
291
- </div>
292
- </>
293
- )}
294
-
295
- {serviceError !== null && (
296
- <Notice tone="error" title="The service rejected this">
297
- {serviceError}
298
- </Notice>
299
- )}
300
- </Shell>
301
- );
302
- }
303
-
304
- function Shell({
305
- heading,
306
- purpose,
307
- children,
308
- }: Readonly<{
309
- heading?: string;
310
- purpose: string;
311
- children: ReactNode;
312
- }>): ReactElement {
313
- return (
314
- <div className="h-full overflow-auto">
315
- <div className="mx-auto max-w-2xl space-y-4 p-6">
316
- <div className="space-y-1">
317
- <h2 className="text-subtitle font-semibold text-ink">
318
- {heading ?? 'Secure request'}
319
- </h2>
320
- {purpose.length > 0 && (
321
- <p className="text-body-1 text-ink-2">{purpose}</p>
322
- )}
323
- <p className="flex items-center gap-1.5 text-caption text-ink-3">
324
- <ShieldCheck className="h-3.5 w-3.5" />
325
- Sent straight to the service with your own sign-in. The agent never
326
- sees what you type.
327
- </p>
328
- </div>
329
- {children}
330
- </div>
331
- </div>
332
- );
333
- }
334
-
335
- function Notice({
336
- tone,
337
- title,
338
- children,
339
- }: Readonly<{
340
- tone: 'error' | 'warn';
341
- title: string;
342
- children: ReactNode;
343
- }>): ReactElement {
344
- return (
345
- <div
346
- role="alert"
347
- className={cn(
348
- 'flex items-start gap-2 rounded-md border p-3',
349
- tone === 'error'
350
- ? 'border-destructive/40 bg-destructive/10'
351
- : 'border-rule bg-paper-elev',
352
- )}
353
- >
354
- <AlertTriangle
355
- className={cn(
356
- 'mt-0.5 h-4 w-4 shrink-0',
357
- tone === 'error' ? 'text-destructive' : 'text-ink-3',
358
- )}
359
- />
360
- <div className="space-y-0.5">
361
- <p
362
- className={cn(
363
- 'text-body-1 font-medium',
364
- tone === 'error' ? 'text-destructive' : 'text-ink',
365
- )}
366
- >
367
- {title}
368
- </p>
369
- <p
370
- className={cn(
371
- 'text-body-1',
372
- tone === 'error' ? 'text-destructive/90' : 'text-ink-3',
373
- )}
374
- >
375
- {children}
376
- </p>
377
- </div>
378
- </div>
379
- );
380
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * `SurfaceKind.Html` — the "render anything, safely" surface.
3
- *
4
- * It draws through the promoted {@link CustomUiFrame}: an opaque-origin,
5
- * `allow-scripts`-only sandbox iframe with a `<meta>` CSP of
6
- * `default-src 'none'; script-src <pinned>; style-src 'unsafe-inline';
7
- * base-uri 'none'; form-action 'none'`.
8
- *
9
- * Two forms, one frame:
10
- * • `{ document }` — untrusted, agent-authored HTML. `script-src 'none'`, and
11
- * the frame is mounted with {@link NO_CUSTOM_UI_INTENTS}: it can render, and
12
- * it can do NOTHING else. This is what an agent's `html` tab uses.
13
- * • `{ compiledOutput, integrity }` — a server-compiled, SRI-pinned chunk.
14
- * `script-src '<sha384-…>'` executes exactly those bytes and nothing else.
15
- *
16
- * A surface that wants intents (App Forge's runtime views) mounts
17
- * `CustomUiFrame` directly with its own closed set; the generic `html` TAB
18
- * deliberately grants none — an agent-authored document must not be able to
19
- * drive the host.
20
- */
21
-
22
- import { NO_CUSTOM_UI_INTENTS } from '../html/custom-ui-intents';
23
- import { CustomUiFrame } from '../html/CustomUiFrame';
24
-
25
- import type { VistaHtmlPayload } from '../vista-payloads';
26
- import type { ReactElement } from 'react';
27
-
28
- export function HtmlSurface(payload: VistaHtmlPayload): ReactElement {
29
- const content =
30
- 'document' in payload
31
- ? { document: payload.document }
32
- : { compiledOutput: payload.compiledOutput, integrity: payload.integrity };
33
- const styleCss = 'document' in payload ? undefined : payload.styleCss;
34
- return (
35
- <CustomUiFrame
36
- content={content}
37
- intents={NO_CUSTOM_UI_INTENTS}
38
- title="Rendered view"
39
- className="h-full p-2"
40
- {...(styleCss === undefined ? {} : { styleCss })}
41
- />
42
- );
43
- }