@seed-ship/mcp-ui-solid 6.25.1 → 7.0.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.
- package/CHANGELOG.md +22 -0
- package/README.md +14 -0
- package/dist/adapters/connector.cjs +3 -3
- package/dist/adapters/connector.cjs.map +1 -1
- package/dist/adapters/connector.d.cts +108 -0
- package/dist/adapters/connector.d.ts +1 -2
- package/dist/adapters/connector.js +3 -3
- package/dist/adapters/connector.js.map +1 -1
- package/dist/adapters/index.d.cts +21 -0
- package/dist/adapters/index.d.ts +6 -7
- package/dist/adapters/macro-run.d.cts +99 -0
- package/dist/adapters/macro-run.d.ts +1 -2
- package/dist/adapters/presentation.d.cts +1 -2
- package/dist/adapters/presentation.d.ts +1 -2
- package/dist/adapters.d.cts +1 -1
- package/dist/adapters.d.ts +1 -1
- package/dist/components/ActionGroupRenderer.d.cts +38 -0
- package/dist/components/ActionGroupRenderer.d.ts +1 -2
- package/dist/components/ActionRenderer.d.cts +9 -0
- package/dist/components/ActionRenderer.d.ts +0 -1
- package/dist/components/AgentCard.d.cts +19 -0
- package/dist/components/AgentCard.d.ts +1 -2
- package/dist/components/AgentHandoff.d.cts +11 -0
- package/dist/components/AgentHandoff.d.ts +1 -2
- package/dist/components/ArtifactRenderer.d.cts +11 -0
- package/dist/components/ArtifactRenderer.d.ts +0 -1
- package/dist/components/AutocompleteDropdown.d.cts +70 -0
- package/dist/components/AutocompleteDropdown.d.ts +1 -2
- package/dist/components/AutocompleteFormField.d.cts +51 -0
- package/dist/components/AutocompleteFormField.d.ts +1 -2
- package/dist/components/BriefingDiff.d.cts +11 -0
- package/dist/components/BriefingDiff.d.ts +1 -2
- package/dist/components/CarouselRenderer.d.cts +12 -0
- package/dist/components/CarouselRenderer.d.ts +1 -2
- package/dist/components/ChartJSRenderer.d.cts +62 -0
- package/dist/components/ChartJSRenderer.d.ts +1 -2
- package/dist/components/ChatPrompt.d.cts +69 -0
- package/dist/components/ChatPrompt.d.ts +1 -2
- package/dist/components/CodeBlockRenderer.d.cts +23 -0
- package/dist/components/CodeBlockRenderer.d.ts +1 -2
- package/dist/components/ComponentToolbar.d.cts +46 -0
- package/dist/components/ComponentToolbar.d.ts +0 -1
- package/dist/components/DataPreviewSection.d.cts +11 -0
- package/dist/components/DataPreviewSection.d.ts +1 -2
- package/dist/components/DegradedFallback.d.cts +43 -0
- package/dist/components/DegradedFallback.d.ts +0 -1
- package/dist/components/DraggableGridItem.d.cts +94 -0
- package/dist/components/DraggableGridItem.d.ts +1 -2
- package/dist/components/EditableLayoutContext.d.cts +4 -0
- package/dist/components/EditableLayoutContext.d.ts +0 -1
- package/dist/components/EditableUIResourceRenderer.d.cts +42 -0
- package/dist/components/EditableUIResourceRenderer.d.ts +1 -2
- package/dist/components/ElicitationForm.d.cts +67 -0
- package/dist/components/ElicitationForm.d.ts +1 -2
- package/dist/components/ExpandableWrapper.d.cts +49 -0
- package/dist/components/ExpandableWrapper.d.ts +0 -1
- package/dist/components/FeedbackInline.d.cts +70 -0
- package/dist/components/FeedbackInline.d.ts +0 -1
- package/dist/components/FooterRenderer.d.cts +15 -0
- package/dist/components/FooterRenderer.d.ts +0 -1
- package/dist/components/FormFieldRenderer.d.cts +19 -0
- package/dist/components/FormFieldRenderer.d.ts +1 -2
- package/dist/components/FormRenderer.d.cts +14 -0
- package/dist/components/FormRenderer.d.ts +1 -2
- package/dist/components/GenerativeUIErrorBoundary.d.cts +58 -0
- package/dist/components/GenerativeUIErrorBoundary.d.ts +1 -2
- package/dist/components/GenerativeUIErrorBoundary.default.d.cts +1 -0
- package/dist/components/GenerativeUIErrorBoundary.default.d.ts +1 -2
- package/dist/components/GhostText.d.cts +112 -0
- package/dist/components/GhostText.d.ts +0 -1
- package/dist/components/GraphRenderer.d.cts +66 -0
- package/dist/components/GraphRenderer.d.ts +1 -2
- package/dist/components/GridRenderer.d.cts +49 -0
- package/dist/components/GridRenderer.d.ts +1 -2
- package/dist/components/IframeFallbackLink.d.cts +22 -0
- package/dist/components/IframeFallbackLink.d.ts +0 -1
- package/dist/components/ImageGalleryRenderer.d.cts +22 -0
- package/dist/components/ImageGalleryRenderer.d.ts +1 -2
- package/dist/components/LightboxOverlay.d.cts +31 -0
- package/dist/components/LightboxOverlay.d.ts +1 -2
- package/dist/components/MapRenderer.d.cts +77 -0
- package/dist/components/MapRenderer.d.ts +1 -2
- package/dist/components/MissingValue.d.cts +26 -0
- package/dist/components/MissingValue.d.ts +0 -1
- package/dist/components/ModalRenderer.d.cts +66 -0
- package/dist/components/ModalRenderer.d.ts +1 -2
- package/dist/components/PortalDropdownMenu.d.cts +55 -0
- package/dist/components/PortalDropdownMenu.d.ts +0 -1
- package/dist/components/PresentationFeedback.d.cts +112 -0
- package/dist/components/PresentationFeedback.d.ts +0 -1
- package/dist/components/RenderContext.d.cts +41 -0
- package/dist/components/RenderContext.d.ts +1 -2
- package/dist/components/ResizeHandle.d.cts +49 -0
- package/dist/components/ResizeHandle.d.ts +0 -1
- package/dist/components/SafeHtml.d.cts +45 -0
- package/dist/components/SafeHtml.d.ts +0 -1
- package/dist/components/ScratchpadPanel.d.cts +34 -0
- package/dist/components/ScratchpadPanel.d.ts +1 -2
- package/dist/components/SplitStepper.d.cts +11 -0
- package/dist/components/SplitStepper.d.ts +1 -2
- package/dist/components/StreamingUIRenderer.d.cts +58 -0
- package/dist/components/StreamingUIRenderer.d.ts +3 -4
- package/dist/components/UIResourceRenderer.d.cts +181 -0
- package/dist/components/UIResourceRenderer.d.ts +3 -4
- package/dist/components/UIResourceRenderer.default.d.cts +1 -0
- package/dist/components/UIResourceRenderer.default.d.ts +1 -2
- package/dist/components/VerifiedText.d.cts +22 -0
- package/dist/components/VerifiedText.d.ts +1 -2
- package/dist/components/VideoRenderer.d.cts +41 -0
- package/dist/components/VideoRenderer.d.ts +1 -2
- package/dist/components/chart-data-table.d.cts +68 -0
- package/dist/components/chart-data-table.d.ts +0 -1
- package/dist/components/chart-missing-plugin.d.cts +128 -0
- package/dist/components/chart-missing-plugin.d.ts +1 -2
- package/dist/components/index.d.cts +62 -0
- package/dist/components/index.d.ts +57 -58
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/context/AutocompleteContext.d.cts +76 -0
- package/dist/context/AutocompleteContext.d.ts +1 -2
- package/dist/context/MCPActionContext.d.cts +169 -0
- package/dist/context/MCPActionContext.d.ts +0 -1
- package/dist/context/MCPUIConfigContext.d.cts +201 -0
- package/dist/context/MCPUIConfigContext.d.ts +1 -2
- package/dist/context/MCPUIMathContext.d.cts +17 -0
- package/dist/context/MCPUIMathContext.d.ts +0 -1
- package/dist/context/MCPUIStringsContext.d.cts +802 -0
- package/dist/context/MCPUIStringsContext.d.ts +1 -2
- package/dist/context/MCPUITelemetryContext.d.cts +35 -0
- package/dist/context/MCPUITelemetryContext.d.ts +1 -2
- package/dist/context/index.d.cts +7 -0
- package/dist/context/index.d.ts +2 -3
- package/dist/hooks/createResponsiveGrid.d.cts +5 -0
- package/dist/hooks/createResponsiveGrid.d.ts +0 -1
- package/dist/hooks/index.d.cts +25 -0
- package/dist/hooks/index.d.ts +20 -21
- package/dist/hooks/useAction.d.cts +164 -0
- package/dist/hooks/useAction.d.ts +2 -3
- package/dist/hooks/useAutocomplete.d.cts +118 -0
- package/dist/hooks/useAutocomplete.d.ts +1 -2
- package/dist/hooks/useChatBus.d.cts +55 -0
- package/dist/hooks/useChatBus.d.ts +1 -2
- package/dist/hooks/useConditionalField.d.cts +34 -0
- package/dist/hooks/useConditionalField.d.ts +1 -2
- package/dist/hooks/useDataValidator.d.cts +41 -0
- package/dist/hooks/useDataValidator.d.ts +1 -2
- package/dist/hooks/useDragDrop.d.cts +99 -0
- package/dist/hooks/useDragDrop.d.ts +1 -2
- package/dist/hooks/useFormPersistence.d.cts +80 -0
- package/dist/hooks/useFormPersistence.d.ts +0 -1
- package/dist/hooks/useModal.d.cts +106 -0
- package/dist/hooks/useModal.d.ts +0 -1
- package/dist/hooks/useResize.d.cts +86 -0
- package/dist/hooks/useResize.d.ts +1 -2
- package/dist/hooks/useStreamingUI.d.cts +117 -0
- package/dist/hooks/useStreamingUI.d.ts +1 -2
- package/dist/hooks.d.cts +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/index.d.cts +91 -92
- package/dist/index.d.ts +91 -92
- package/dist/plugins/duckdb.d.cts +1 -2
- package/dist/plugins/duckdb.d.ts +1 -2
- package/dist/plugins/groq.d.cts +12 -0
- package/dist/plugins/groq.d.ts +1 -2
- package/dist/plugins/index.d.cts +9 -0
- package/dist/plugins/index.d.ts +3 -4
- package/dist/plugins/katex.d.cts +1 -2
- package/dist/plugins/katex.d.ts +1 -2
- package/dist/plugins/rest.d.cts +12 -0
- package/dist/plugins/rest.d.ts +1 -2
- package/dist/plugins/supabase.d.cts +12 -0
- package/dist/plugins/supabase.d.ts +1 -2
- package/dist/services/chat-bus.d.cts +100 -0
- package/dist/services/chat-bus.d.ts +1 -2
- package/dist/services/chat-prompt-controller.d.cts +92 -0
- package/dist/services/chat-prompt-controller.d.ts +1 -2
- package/dist/services/component-registry.d.cts +119 -0
- package/dist/services/component-registry.d.ts +1 -2
- package/dist/services/data-validator.d.cts +27 -0
- package/dist/services/data-validator.d.ts +1 -2
- package/dist/services/index.d.cts +9 -0
- package/dist/services/index.d.ts +4 -5
- package/dist/services/telemetry.d.cts +86 -0
- package/dist/services/telemetry.d.ts +1 -2
- package/dist/services/validation.d.cts +169 -0
- package/dist/services/validation.d.ts +1 -2
- package/dist/stores/scratchpad-store.d.cts +109 -0
- package/dist/stores/scratchpad-store.d.ts +1 -2
- package/dist/stores/server-capabilities-store.d.cts +171 -0
- package/dist/stores/server-capabilities-store.d.ts +0 -1
- package/dist/test-setup.d.cts +5 -0
- package/dist/test-setup.d.ts +0 -1
- package/dist/testing/index.d.cts +34 -0
- package/dist/testing/index.d.ts +1 -2
- package/dist/types/chat-bus.d.cts +783 -0
- package/dist/types/chat-bus.d.ts +4 -5
- package/dist/types/index.d.cts +1616 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types-export.d.cts +1 -2
- package/dist/types-export.d.ts +1 -2
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/degraded-projections.d.cts +119 -0
- package/dist/utils/degraded-projections.d.ts +0 -1
- package/dist/utils/duplicate-mount-registry.d.cts +83 -0
- package/dist/utils/duplicate-mount-registry.d.ts +0 -1
- package/dist/utils/escape-html.d.cts +12 -0
- package/dist/utils/escape-html.d.ts +0 -1
- package/dist/utils/format-string.d.cts +25 -0
- package/dist/utils/format-string.d.ts +0 -1
- package/dist/utils/iframe-coep.d.cts +53 -0
- package/dist/utils/iframe-coep.d.ts +1 -2
- package/dist/utils/logger.d.cts +57 -0
- package/dist/utils/logger.d.ts +0 -1
- package/dist/utils/math-markdown.d.cts +15 -0
- package/dist/utils/math-markdown.d.ts +1 -2
- package/dist/utils/missing-value.d.cts +78 -0
- package/dist/utils/missing-value.d.ts +0 -1
- package/dist/utils/pan-zoom.d.cts +234 -0
- package/dist/utils/pan-zoom.d.ts +0 -1
- package/dist/utils/perf.d.cts +18 -0
- package/dist/utils/perf.d.ts +0 -1
- package/dist/utils/safe-url.d.cts +33 -0
- package/dist/utils/safe-url.d.ts +0 -1
- package/dist/utils/sanitize-html.d.cts +142 -0
- package/dist/utils/sanitize-html.d.ts +0 -1
- package/dist/utils/stable-key.d.cts +32 -0
- package/dist/utils/stable-key.d.ts +0 -1
- package/dist/utils/theme.d.cts +10 -0
- package/dist/utils/theme.d.ts +0 -1
- package/dist/validation.d.cts +3 -4
- package/dist/validation.d.ts +3 -4
- package/docs/SECURITY-DEPENDENCIES.md +129 -1
- package/docs/ZOD4-STABLE-MIGRATION-2026-10-26.md +181 -0
- package/package.json +8 -7
- package/src/adapters/connector.ts +3 -3
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Bus — Event Emitter + Command Handler
|
|
3
|
+
* v2.4.0: Core primitives for the chat event/command bus
|
|
4
|
+
*
|
|
5
|
+
* @experimental — This API may change without major bump until v2.5.0.
|
|
6
|
+
*/
|
|
7
|
+
import type { ChatEventEmitter, ChatCommandHandler, ChatBus, ScratchpadSection, ClarificationEvent, ElicitationEvent, ChatPromptConfig } from "../types/chat-bus.cjs";
|
|
8
|
+
/**
|
|
9
|
+
* Create a typed event emitter with throttle and streamKey filtering support.
|
|
10
|
+
*
|
|
11
|
+
* @experimental
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const emitter = createEventEmitter<ChatEvents>()
|
|
15
|
+
* const unsub = emitter.on('onToken', (event) => console.log(event.token), { throttle: 100 })
|
|
16
|
+
* emitter.emit('onToken', { streamKey: 'abc', token: 'hello' })
|
|
17
|
+
* unsub()
|
|
18
|
+
*/
|
|
19
|
+
export declare function createEventEmitter(): ChatEventEmitter;
|
|
20
|
+
/**
|
|
21
|
+
* Create a typed command handler. The host app registers handlers,
|
|
22
|
+
* agents execute commands.
|
|
23
|
+
*
|
|
24
|
+
* @experimental
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const commands = createCommandHandler<ChatCommands>()
|
|
28
|
+
* commands.handle('injectPrompt', (text) => setInputValue(text))
|
|
29
|
+
* commands.exec('injectPrompt', 'Hello world')
|
|
30
|
+
*/
|
|
31
|
+
export declare function createCommandHandler(): ChatCommandHandler;
|
|
32
|
+
/**
|
|
33
|
+
* Create a complete ChatBus with events + commands.
|
|
34
|
+
*
|
|
35
|
+
* @experimental
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* const bus = createChatBus()
|
|
39
|
+
* bus.events.on('onStreamEnd', (event) => { ... })
|
|
40
|
+
* bus.commands.handle('sendPrompt', (text) => { ... })
|
|
41
|
+
*/
|
|
42
|
+
export declare function createChatBus(): ChatBus;
|
|
43
|
+
/**
|
|
44
|
+
* Merge sections from a ScratchpadEvent into existing state sections.
|
|
45
|
+
* Handles replace/append/upsert modes.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const newSections = mergeScratchpadSections(
|
|
49
|
+
* currentState.sections,
|
|
50
|
+
* event.sections,
|
|
51
|
+
* event.sectionMode
|
|
52
|
+
* )
|
|
53
|
+
*/
|
|
54
|
+
export declare function mergeScratchpadSections(existing: ScratchpadSection[], incoming: ScratchpadSection[] | undefined, mode?: 'replace' | 'append' | 'upsert'): ScratchpadSection[];
|
|
55
|
+
/**
|
|
56
|
+
* Convert a ClarificationEvent into a ChatPromptConfig.
|
|
57
|
+
* Universal bridge for apps receiving clarification events via SSE.
|
|
58
|
+
*
|
|
59
|
+
* Legacy runtime `file_id` (removed from the type in v5.0.0) is still
|
|
60
|
+
* transparently migrated into `metadata.file_id` when present, so payloads
|
|
61
|
+
* from older servers continue to work without upgrade pressure.
|
|
62
|
+
*
|
|
63
|
+
* @experimental
|
|
64
|
+
* @since v4.3.9
|
|
65
|
+
* @example
|
|
66
|
+
* bus.events.on('onClarificationNeeded', ({ clarification }) => {
|
|
67
|
+
* bus.commands.exec('showChatPrompt', clarificationToPromptConfig(clarification))
|
|
68
|
+
* })
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Convert an MCP `elicitation/create` payload into a `ChatPromptConfig`.
|
|
72
|
+
*
|
|
73
|
+
* Mapping rules :
|
|
74
|
+
* - Single `boolean` property → `type: 'confirm'`
|
|
75
|
+
* - Single property with `enum` of ≤4 values → `type: 'choice'` (one option per enum value)
|
|
76
|
+
* - Anything else → `type: 'form'` with one field per schema property
|
|
77
|
+
*
|
|
78
|
+
* JSON Schema primitive types map to mcp-ui form field types :
|
|
79
|
+
*
|
|
80
|
+
* | JSON Schema | mcp-ui FormFieldType |
|
|
81
|
+
* |---|---|
|
|
82
|
+
* | `type: 'string'` | `'text'` |
|
|
83
|
+
* | `type: 'string', format: 'email'` | `'email'` |
|
|
84
|
+
* | `type: 'string', format: 'date'` or `'date-time'` | `'date'` |
|
|
85
|
+
* | `type: 'string', enum: [...]` | `'select'` |
|
|
86
|
+
* | `type: 'number' \| 'integer'` | `'number'` |
|
|
87
|
+
* | `type: 'boolean'` | `'checkbox'` |
|
|
88
|
+
*
|
|
89
|
+
* Unknown shapes fall through to plain text with a `helpText` warning.
|
|
90
|
+
*
|
|
91
|
+
* @experimental
|
|
92
|
+
* @since v5.2.0
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* bus.events.on('onElicitation', ({ elicitation }) => {
|
|
96
|
+
* bus.commands.exec('showChatPrompt', elicitationToPromptConfig(elicitation))
|
|
97
|
+
* })
|
|
98
|
+
*/
|
|
99
|
+
export declare function elicitationToPromptConfig(event: ElicitationEvent): ChatPromptConfig;
|
|
100
|
+
export declare function clarificationToPromptConfig(event: ClarificationEvent): ChatPromptConfig;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @experimental — This API may change without major bump until v2.5.0.
|
|
6
6
|
*/
|
|
7
|
-
import type { ChatEventEmitter, ChatCommandHandler, ChatBus, ScratchpadSection, ClarificationEvent, ElicitationEvent, ChatPromptConfig } from
|
|
7
|
+
import type { ChatEventEmitter, ChatCommandHandler, ChatBus, ScratchpadSection, ClarificationEvent, ElicitationEvent, ChatPromptConfig } from "../types/chat-bus.js";
|
|
8
8
|
/**
|
|
9
9
|
* Create a typed event emitter with throttle and streamKey filtering support.
|
|
10
10
|
*
|
|
@@ -98,4 +98,3 @@ export declare function mergeScratchpadSections(existing: ScratchpadSection[], i
|
|
|
98
98
|
*/
|
|
99
99
|
export declare function elicitationToPromptConfig(event: ElicitationEvent): ChatPromptConfig;
|
|
100
100
|
export declare function clarificationToPromptConfig(event: ClarificationEvent): ChatPromptConfig;
|
|
101
|
-
//# sourceMappingURL=chat-bus.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createChatPromptController — centralised lifecycle for `showChatPrompt`
|
|
3
|
+
*
|
|
4
|
+
* @experimental
|
|
5
|
+
* @since v5.2.0
|
|
6
|
+
*
|
|
7
|
+
* The controller owns the resolver closure, AbortSignal wiring, and
|
|
8
|
+
* re-entrance policy in one primitive. Consumers go from ~20 LOC of manual
|
|
9
|
+
* wiring per app to :
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const ctrl = createChatPromptController()
|
|
13
|
+
* bus.commands.handle('showChatPrompt', ctrl.handle)
|
|
14
|
+
* // ...
|
|
15
|
+
* <Show when={ctrl.activePrompt()}>
|
|
16
|
+
* {(cfg) => (
|
|
17
|
+
* <ChatPrompt
|
|
18
|
+
* config={cfg()}
|
|
19
|
+
* onSubmit={ctrl.resolveActive}
|
|
20
|
+
* onDismiss={ctrl.dismissActive}
|
|
21
|
+
* />
|
|
22
|
+
* )}
|
|
23
|
+
* </Show>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* ## Re-entrance policy
|
|
27
|
+
*
|
|
28
|
+
* If a new `showChatPrompt` arrives while a previous Promise is still
|
|
29
|
+
* pending, the previous Promise rejects **synchronously** with a
|
|
30
|
+
* `PromptReplacedError` before the new prompt is installed. Callers that
|
|
31
|
+
* care can branch on `err instanceof PromptReplacedError` or `err.name ===
|
|
32
|
+
* 'PromptReplacedError'`.
|
|
33
|
+
*
|
|
34
|
+
* ## Abort semantics
|
|
35
|
+
*
|
|
36
|
+
* `handle(config, signal?)` honours `AbortSignal` :
|
|
37
|
+
*
|
|
38
|
+
* - If `signal.aborted === true` on entry → returns a rejected Promise with
|
|
39
|
+
* `new DOMException('Prompt aborted', 'AbortError')`, does NOT set
|
|
40
|
+
* `activePrompt`.
|
|
41
|
+
* - Otherwise registers a once-only listener that rejects with the same
|
|
42
|
+
* `DOMException` on abort, clearing the active state.
|
|
43
|
+
*
|
|
44
|
+
* `AbortError` is the Web Platform convention (matches `fetch()`,
|
|
45
|
+
* `Response.body.cancel()`, etc.) — callers can branch on `err.name ===
|
|
46
|
+
* 'AbortError'` without importing any mcp-ui type.
|
|
47
|
+
*/
|
|
48
|
+
import { type Accessor } from 'solid-js';
|
|
49
|
+
import type { ChatPromptConfig, ChatPromptResponse } from "../types/chat-bus.cjs";
|
|
50
|
+
/**
|
|
51
|
+
* Thrown when an active `showChatPrompt` Promise is rejected because a new
|
|
52
|
+
* prompt arrived before the previous one resolved. Consumers can use
|
|
53
|
+
* `instanceof PromptReplacedError` or `err.name === 'PromptReplacedError'` to
|
|
54
|
+
* branch (retry, bail, log).
|
|
55
|
+
*
|
|
56
|
+
* @experimental
|
|
57
|
+
* @since v5.2.0
|
|
58
|
+
*/
|
|
59
|
+
export declare class PromptReplacedError extends Error {
|
|
60
|
+
readonly name: "PromptReplacedError";
|
|
61
|
+
constructor(message?: string);
|
|
62
|
+
}
|
|
63
|
+
export interface ChatPromptController {
|
|
64
|
+
/**
|
|
65
|
+
* Register as the bus handler :
|
|
66
|
+
* `bus.commands.handle('showChatPrompt', ctrl.handle)`
|
|
67
|
+
*/
|
|
68
|
+
handle: (config: ChatPromptConfig, signal?: AbortSignal) => Promise<ChatPromptResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Reactive accessor for the currently active prompt config (null when no
|
|
71
|
+
* prompt is pending). Use in JSX to drive `<ChatPrompt>` rendering.
|
|
72
|
+
*/
|
|
73
|
+
activePrompt: Accessor<ChatPromptConfig | null>;
|
|
74
|
+
/** Call this from `<ChatPrompt>`'s `onSubmit` prop. */
|
|
75
|
+
resolveActive: (response: ChatPromptResponse) => void;
|
|
76
|
+
/** Call this from `<ChatPrompt>`'s `onDismiss` prop. */
|
|
77
|
+
dismissActive: () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Cancel the active prompt programmatically (e.g. on route change). Rejects
|
|
80
|
+
* the pending Promise with the supplied reason or an `AbortError`.
|
|
81
|
+
*/
|
|
82
|
+
abort: (reason?: string) => void;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a stateful controller that owns the active prompt Promise, the
|
|
86
|
+
* AbortSignal listener, and the re-entrance policy. See module JSDoc for
|
|
87
|
+
* full usage.
|
|
88
|
+
*
|
|
89
|
+
* @experimental
|
|
90
|
+
* @since v5.2.0
|
|
91
|
+
*/
|
|
92
|
+
export declare function createChatPromptController(): ChatPromptController;
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* 'AbortError'` without importing any mcp-ui type.
|
|
47
47
|
*/
|
|
48
48
|
import { type Accessor } from 'solid-js';
|
|
49
|
-
import type { ChatPromptConfig, ChatPromptResponse } from
|
|
49
|
+
import type { ChatPromptConfig, ChatPromptResponse } from "../types/chat-bus.js";
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when an active `showChatPrompt` Promise is rejected because a new
|
|
52
52
|
* prompt arrived before the previous one resolved. Consumers can use
|
|
@@ -90,4 +90,3 @@ export interface ChatPromptController {
|
|
|
90
90
|
* @since v5.2.0
|
|
91
91
|
*/
|
|
92
92
|
export declare function createChatPromptController(): ChatPromptController;
|
|
93
|
-
//# sourceMappingURL=chat-prompt-controller.d.ts.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Registry Service
|
|
3
|
+
* Phase 0: Static registry with Chart and Table definitions
|
|
4
|
+
* Phase 1: Dynamic registry populated from /api/mcp/tools/list
|
|
5
|
+
*
|
|
6
|
+
* Provides component schemas for LLM prompt engineering
|
|
7
|
+
*/
|
|
8
|
+
import type { ComponentRegistryEntry, ComponentType } from "../types.cjs";
|
|
9
|
+
/**
|
|
10
|
+
* Chart Component Registry Entry
|
|
11
|
+
*
|
|
12
|
+
* The historical export name is retained for source compatibility. The
|
|
13
|
+
* renderer is local-first: Chart.js is the native implementation, while the
|
|
14
|
+
* external QuickChart fallback is a host-level opt-in.
|
|
15
|
+
*/
|
|
16
|
+
export declare const QuickchartRegistry: ComponentRegistryEntry;
|
|
17
|
+
/**
|
|
18
|
+
* Table Component Registry Entry
|
|
19
|
+
*/
|
|
20
|
+
export declare const TableRegistry: ComponentRegistryEntry;
|
|
21
|
+
/**
|
|
22
|
+
* Metric Card Component Registry Entry
|
|
23
|
+
*/
|
|
24
|
+
export declare const MetricRegistry: ComponentRegistryEntry;
|
|
25
|
+
/**
|
|
26
|
+
* Text Component Registry Entry
|
|
27
|
+
*/
|
|
28
|
+
export declare const TextRegistry: ComponentRegistryEntry;
|
|
29
|
+
/**
|
|
30
|
+
* Grid Component Registry Entry
|
|
31
|
+
* Nested CSS Grid layout for organizing multiple components
|
|
32
|
+
*/
|
|
33
|
+
export declare const GridRegistry: ComponentRegistryEntry;
|
|
34
|
+
/**
|
|
35
|
+
* Action Component Registry Entry
|
|
36
|
+
* Interactive button or link that triggers tool calls
|
|
37
|
+
*/
|
|
38
|
+
export declare const ActionRegistry: ComponentRegistryEntry;
|
|
39
|
+
/**
|
|
40
|
+
* Footer Component Registry Entry
|
|
41
|
+
* Display execution metadata like timing and source count
|
|
42
|
+
*/
|
|
43
|
+
export declare const FooterRegistry: ComponentRegistryEntry;
|
|
44
|
+
/**
|
|
45
|
+
* Carousel Component Registry Entry
|
|
46
|
+
* Display multiple items with horizontal scrolling
|
|
47
|
+
*/
|
|
48
|
+
export declare const CarouselRegistry: ComponentRegistryEntry;
|
|
49
|
+
/**
|
|
50
|
+
* Artifact Component Registry Entry
|
|
51
|
+
* Display downloadable artifacts like generated files
|
|
52
|
+
*/
|
|
53
|
+
export declare const ArtifactRegistry: ComponentRegistryEntry;
|
|
54
|
+
/**
|
|
55
|
+
* Code Block Registry Entry
|
|
56
|
+
*/
|
|
57
|
+
export declare const CodeRegistry: ComponentRegistryEntry;
|
|
58
|
+
export declare const MapRegistry: ComponentRegistryEntry;
|
|
59
|
+
/**
|
|
60
|
+
* Graph Registry Entry (v6.12.0 — audit P1.5)
|
|
61
|
+
*/
|
|
62
|
+
export declare const GraphRegistry: ComponentRegistryEntry;
|
|
63
|
+
/**
|
|
64
|
+
* Form Registry Entry
|
|
65
|
+
*/
|
|
66
|
+
export declare const FormRegistry: ComponentRegistryEntry;
|
|
67
|
+
/**
|
|
68
|
+
* Modal Registry Entry
|
|
69
|
+
*/
|
|
70
|
+
export declare const ModalRegistry: ComponentRegistryEntry;
|
|
71
|
+
/**
|
|
72
|
+
* Action Group Registry Entry
|
|
73
|
+
*/
|
|
74
|
+
export declare const ActionGroupRegistry: ComponentRegistryEntry;
|
|
75
|
+
/**
|
|
76
|
+
* Image Gallery Registry Entry
|
|
77
|
+
*/
|
|
78
|
+
export declare const ImageGalleryRegistry: ComponentRegistryEntry;
|
|
79
|
+
/**
|
|
80
|
+
* Video Registry Entry
|
|
81
|
+
*/
|
|
82
|
+
export declare const VideoRegistry: ComponentRegistryEntry;
|
|
83
|
+
/**
|
|
84
|
+
* Iframe Registry Entry
|
|
85
|
+
*/
|
|
86
|
+
export declare const IframeRegistry: ComponentRegistryEntry;
|
|
87
|
+
/**
|
|
88
|
+
* Image Registry Entry
|
|
89
|
+
*/
|
|
90
|
+
export declare const ImageRegistry: ComponentRegistryEntry;
|
|
91
|
+
/**
|
|
92
|
+
* Link Registry Entry
|
|
93
|
+
*/
|
|
94
|
+
export declare const LinkRegistry: ComponentRegistryEntry;
|
|
95
|
+
/**
|
|
96
|
+
* Component Registry - All components indexed by type
|
|
97
|
+
*/
|
|
98
|
+
export declare const ComponentRegistry: Map<ComponentType, ComponentRegistryEntry>;
|
|
99
|
+
/**
|
|
100
|
+
* Get component registry entry by type
|
|
101
|
+
*/
|
|
102
|
+
export declare function getComponentEntry(type: ComponentType): ComponentRegistryEntry | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Get all component types
|
|
105
|
+
*/
|
|
106
|
+
export declare function getAllComponentTypes(): ComponentType[];
|
|
107
|
+
/**
|
|
108
|
+
* Get registry as JSON for LLM context
|
|
109
|
+
*/
|
|
110
|
+
export declare function getRegistryForLLM(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Validate component against registry schema
|
|
113
|
+
* (Future: Use Zod for runtime validation)
|
|
114
|
+
*/
|
|
115
|
+
export declare function validateAgainstRegistry(componentType: ComponentType, params: any): {
|
|
116
|
+
valid: boolean;
|
|
117
|
+
errors?: string[];
|
|
118
|
+
warnings?: string[];
|
|
119
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Provides component schemas for LLM prompt engineering
|
|
7
7
|
*/
|
|
8
|
-
import type { ComponentRegistryEntry, ComponentType } from
|
|
8
|
+
import type { ComponentRegistryEntry, ComponentType } from "../types.js";
|
|
9
9
|
/**
|
|
10
10
|
* Chart Component Registry Entry
|
|
11
11
|
*
|
|
@@ -117,4 +117,3 @@ export declare function validateAgainstRegistry(componentType: ComponentType, pa
|
|
|
117
117
|
errors?: string[];
|
|
118
118
|
warnings?: string[];
|
|
119
119
|
};
|
|
120
|
-
//# sourceMappingURL=component-registry.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Validator — anti-hallucination for LLM-generated text
|
|
3
|
+
* v3.1.0: Pure regex-based number verification against source data
|
|
4
|
+
*
|
|
5
|
+
* Compares numbers in LLM text to numbers in source data rows.
|
|
6
|
+
* Detects ~90% of numerical hallucinations with zero LLM cost, <1ms latency.
|
|
7
|
+
*/
|
|
8
|
+
import type { DataValidation, DataValidationOptions } from "../types/chat-bus.cjs";
|
|
9
|
+
/**
|
|
10
|
+
* Validate LLM-generated text against source data rows.
|
|
11
|
+
*
|
|
12
|
+
* Pure function — no IO, no LLM calls, no side effects.
|
|
13
|
+
* Returns which numbers in the text are verified vs hallucinated.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const rows = [{ type: 'Appartement', ventes: 22306, prix_m2: 3337 }]
|
|
18
|
+
* const result = validateAgainstSource(
|
|
19
|
+
* "On observe 22 306 ventes à 3 337 EUR/m². En 2023, 18 245 ventes.",
|
|
20
|
+
* rows
|
|
21
|
+
* )
|
|
22
|
+
* // result.valid === false
|
|
23
|
+
* // result.hallucinated === [{ value: 18245, ... }]
|
|
24
|
+
* // result.confidence === 0.67
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateAgainstSource(text: string, sourceRows: Record<string, unknown>[], options?: DataValidationOptions): DataValidation;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Compares numbers in LLM text to numbers in source data rows.
|
|
6
6
|
* Detects ~90% of numerical hallucinations with zero LLM cost, <1ms latency.
|
|
7
7
|
*/
|
|
8
|
-
import type { DataValidation, DataValidationOptions } from
|
|
8
|
+
import type { DataValidation, DataValidationOptions } from "../types/chat-bus.js";
|
|
9
9
|
/**
|
|
10
10
|
* Validate LLM-generated text against source data rows.
|
|
11
11
|
*
|
|
@@ -25,4 +25,3 @@ import type { DataValidation, DataValidationOptions } from '../types/chat-bus';
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
export declare function validateAgainstSource(text: string, sourceRows: Record<string, unknown>[], options?: DataValidationOptions): DataValidation;
|
|
28
|
-
//# sourceMappingURL=data-validator.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP UI Solid - Services
|
|
3
|
+
*
|
|
4
|
+
* Business logic for component validation and registry management
|
|
5
|
+
*/
|
|
6
|
+
export { validateComponent, validateLayout, validateIframeDomain, getIframeSandbox, isTrustedIframeDomain, DEFAULT_RESOURCE_LIMITS, DEFAULT_IFRAME_DOMAINS, TRUSTED_IFRAME_DOMAINS, } from "./validation.cjs";
|
|
7
|
+
export { ComponentRegistry } from "./component-registry.cjs";
|
|
8
|
+
export { createEventEmitter, createCommandHandler, createChatBus, mergeScratchpadSections } from "./chat-bus.cjs";
|
|
9
|
+
export { validateAgainstSource } from "./data-validator.cjs";
|
package/dist/services/index.d.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Business logic for component validation and registry management
|
|
5
5
|
*/
|
|
6
|
-
export { validateComponent, validateLayout, validateIframeDomain, getIframeSandbox, isTrustedIframeDomain, DEFAULT_RESOURCE_LIMITS, DEFAULT_IFRAME_DOMAINS, TRUSTED_IFRAME_DOMAINS, } from
|
|
7
|
-
export { ComponentRegistry } from
|
|
8
|
-
export { createEventEmitter, createCommandHandler, createChatBus, mergeScratchpadSections } from
|
|
9
|
-
export { validateAgainstSource } from
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
6
|
+
export { validateComponent, validateLayout, validateIframeDomain, getIframeSandbox, isTrustedIframeDomain, DEFAULT_RESOURCE_LIMITS, DEFAULT_IFRAME_DOMAINS, TRUSTED_IFRAME_DOMAINS, } from "./validation.js";
|
|
7
|
+
export { ComponentRegistry } from "./component-registry.js";
|
|
8
|
+
export { createEventEmitter, createCommandHandler, createChatBus, mergeScratchpadSections } from "./chat-bus.js";
|
|
9
|
+
export { validateAgainstSource } from "./data-validator.js";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI telemetry sink (B.5 — v5.6.0)
|
|
3
|
+
*
|
|
4
|
+
* Minimal OpenTelemetry-like Provider that lets a consumer (e.g. deposium
|
|
5
|
+
* `/admin/ui-telemetry`) collect lifecycle + error + action events from
|
|
6
|
+
* mcp-ui components without imposing any API change on apps that don't use
|
|
7
|
+
* it. Spec'd in `MCP-UI-AUDIT-2026-04-26.md` §M.6.
|
|
8
|
+
*
|
|
9
|
+
* Three hard rules:
|
|
10
|
+
* 1. Provider is OPTIONAL. When absent, `useTelemetry()` returns `null`
|
|
11
|
+
* and dispatch sites no-op. Existing apps see zero behavior change.
|
|
12
|
+
* 2. Sink is FAIL-OPEN. A `sink()` throw or rejected promise is caught
|
|
13
|
+
* silently — telemetry never crashes the renderer.
|
|
14
|
+
* 3. Events carry NO payload data. Only meta (type + id + counts + timing)
|
|
15
|
+
* to avoid PII / data leaks in centralized logs.
|
|
16
|
+
*/
|
|
17
|
+
import type { ComponentType } from "../types.cjs";
|
|
18
|
+
interface TelemetryEventBase {
|
|
19
|
+
/** Component instance id (from `UIComponent.id` or auto-generated). */
|
|
20
|
+
id: string;
|
|
21
|
+
/** ComponentType, e.g. 'chart' / 'metric' / 'iframe'. */
|
|
22
|
+
componentType: ComponentType;
|
|
23
|
+
/** Wall-clock timestamp (ms epoch) for cross-stack correlation. */
|
|
24
|
+
ts: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Discriminated union of all telemetry events emitted by mcp-ui.
|
|
28
|
+
* See §M.6.2 for field semantics + privacy rules.
|
|
29
|
+
*/
|
|
30
|
+
export type TelemetryEvent = ({
|
|
31
|
+
type: 'component:mounted';
|
|
32
|
+
} & TelemetryEventBase) | ({
|
|
33
|
+
type: 'component:rendered';
|
|
34
|
+
durationMs: number;
|
|
35
|
+
} & TelemetryEventBase) | ({
|
|
36
|
+
type: 'component:unmounted';
|
|
37
|
+
} & TelemetryEventBase) | ({
|
|
38
|
+
type: 'validation:failed';
|
|
39
|
+
errorCount: number;
|
|
40
|
+
firstErrorCode: string | null;
|
|
41
|
+
} & TelemetryEventBase) | ({
|
|
42
|
+
type: 'render:error';
|
|
43
|
+
errorMessage: string;
|
|
44
|
+
} & TelemetryEventBase) | ({
|
|
45
|
+
type: 'action:dispatched';
|
|
46
|
+
actionName: string;
|
|
47
|
+
} & TelemetryEventBase);
|
|
48
|
+
/**
|
|
49
|
+
* Consumer-supplied sink. Receives a batch of events (always an array,
|
|
50
|
+
* even for `bufferMs: 0` — single-element array in that case). Errors
|
|
51
|
+
* and rejected promises are caught silently by the dispatcher.
|
|
52
|
+
*/
|
|
53
|
+
export interface TelemetrySink {
|
|
54
|
+
(events: TelemetryEvent[]): void | Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
export interface TelemetryOptions {
|
|
57
|
+
/** Per-event base sampling rate, 0..1, default 1.0 (all events). */
|
|
58
|
+
sampleRate?: number;
|
|
59
|
+
/** Buffer events and flush after N ms (default 100). 0 = no buffer. */
|
|
60
|
+
bufferMs?: number;
|
|
61
|
+
/** Max buffered events before forced flush (default 50). */
|
|
62
|
+
bufferMax?: number;
|
|
63
|
+
/** Per-event-type override on sampling (high-volume types can be lower). */
|
|
64
|
+
sampleByType?: Partial<Record<TelemetryEvent['type'], number>>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Dispatcher returned by `createTelemetryDispatcher`. Used internally by
|
|
68
|
+
* the Provider, exposed only so tests can drive it without React/Solid.
|
|
69
|
+
*/
|
|
70
|
+
export interface TelemetryDispatcher {
|
|
71
|
+
/**
|
|
72
|
+
* Push an event. Sampling + buffering applied transparently. Never throws.
|
|
73
|
+
*/
|
|
74
|
+
dispatch(event: TelemetryEvent): void;
|
|
75
|
+
/**
|
|
76
|
+
* Force-flush the buffer. Useful on tab-hidden / unload, or for tests.
|
|
77
|
+
* Never throws.
|
|
78
|
+
*/
|
|
79
|
+
flush(): void;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Create a telemetry dispatcher. Pure function, no Solid context — exists
|
|
83
|
+
* separately from the Provider so it can be unit-tested in isolation.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createTelemetryDispatcher(sink: TelemetrySink, options?: TelemetryOptions): TelemetryDispatcher;
|
|
86
|
+
export {};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* 3. Events carry NO payload data. Only meta (type + id + counts + timing)
|
|
15
15
|
* to avoid PII / data leaks in centralized logs.
|
|
16
16
|
*/
|
|
17
|
-
import type { ComponentType } from
|
|
17
|
+
import type { ComponentType } from "../types.js";
|
|
18
18
|
interface TelemetryEventBase {
|
|
19
19
|
/** Component instance id (from `UIComponent.id` or auto-generated). */
|
|
20
20
|
id: string;
|
|
@@ -84,4 +84,3 @@ export interface TelemetryDispatcher {
|
|
|
84
84
|
*/
|
|
85
85
|
export declare function createTelemetryDispatcher(sink: TelemetrySink, options?: TelemetryOptions): TelemetryDispatcher;
|
|
86
86
|
export {};
|
|
87
|
-
//# sourceMappingURL=telemetry.d.ts.map
|