@seed-ship/mcp-ui-solid 6.24.0 → 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 +64 -0
- package/README.md +61 -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.cjs +6 -6
- package/dist/components/ActionGroupRenderer.cjs.map +1 -1
- package/dist/components/ActionGroupRenderer.d.cts +38 -0
- package/dist/components/ActionGroupRenderer.d.ts +1 -2
- package/dist/components/ActionGroupRenderer.js +6 -6
- package/dist/components/ActionGroupRenderer.js.map +1 -1
- 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.cjs +6 -6
- package/dist/components/AutocompleteDropdown.cjs.map +1 -1
- package/dist/components/AutocompleteDropdown.d.cts +70 -0
- package/dist/components/AutocompleteDropdown.d.ts +1 -2
- package/dist/components/AutocompleteDropdown.js +6 -6
- package/dist/components/AutocompleteDropdown.js.map +1 -1
- package/dist/components/AutocompleteFormField.cjs +6 -5
- package/dist/components/AutocompleteFormField.cjs.map +1 -1
- package/dist/components/AutocompleteFormField.d.cts +51 -0
- package/dist/components/AutocompleteFormField.d.ts +1 -2
- package/dist/components/AutocompleteFormField.d.ts.map +1 -1
- package/dist/components/AutocompleteFormField.js +6 -5
- package/dist/components/AutocompleteFormField.js.map +1 -1
- 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.cjs +216 -6
- package/dist/components/ChartJSRenderer.cjs.map +1 -1
- package/dist/components/ChartJSRenderer.d.cts +62 -0
- package/dist/components/ChartJSRenderer.d.ts +1 -2
- package/dist/components/ChartJSRenderer.d.ts.map +1 -1
- package/dist/components/ChartJSRenderer.js +217 -7
- package/dist/components/ChartJSRenderer.js.map +1 -1
- package/dist/components/ChatPrompt.cjs +5 -5
- package/dist/components/ChatPrompt.cjs.map +1 -1
- package/dist/components/ChatPrompt.d.cts +69 -0
- package/dist/components/ChatPrompt.d.ts +1 -2
- package/dist/components/ChatPrompt.js +5 -5
- package/dist/components/ChatPrompt.js.map +1 -1
- package/dist/components/CodeBlockRenderer.d.cts +23 -0
- package/dist/components/CodeBlockRenderer.d.ts +1 -2
- package/dist/components/ComponentToolbar.cjs +5 -5
- package/dist/components/ComponentToolbar.cjs.map +1 -1
- package/dist/components/ComponentToolbar.d.cts +46 -0
- package/dist/components/ComponentToolbar.d.ts +0 -1
- package/dist/components/ComponentToolbar.js +5 -5
- package/dist/components/ComponentToolbar.js.map +1 -1
- package/dist/components/DataPreviewSection.d.cts +11 -0
- package/dist/components/DataPreviewSection.d.ts +1 -2
- package/dist/components/DegradedFallback.cjs +1 -1
- package/dist/components/DegradedFallback.cjs.map +1 -1
- package/dist/components/DegradedFallback.d.cts +43 -0
- package/dist/components/DegradedFallback.d.ts +0 -1
- package/dist/components/DegradedFallback.js +1 -1
- package/dist/components/DegradedFallback.js.map +1 -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.cjs +10 -7
- package/dist/components/ExpandableWrapper.cjs.map +1 -1
- package/dist/components/ExpandableWrapper.d.cts +49 -0
- package/dist/components/ExpandableWrapper.d.ts +0 -1
- package/dist/components/ExpandableWrapper.d.ts.map +1 -1
- package/dist/components/ExpandableWrapper.js +10 -7
- package/dist/components/ExpandableWrapper.js.map +1 -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.cjs +13 -12
- package/dist/components/FormFieldRenderer.cjs.map +1 -1
- package/dist/components/FormFieldRenderer.d.cts +19 -0
- package/dist/components/FormFieldRenderer.d.ts +1 -2
- package/dist/components/FormFieldRenderer.d.ts.map +1 -1
- package/dist/components/FormFieldRenderer.js +13 -12
- package/dist/components/FormFieldRenderer.js.map +1 -1
- package/dist/components/FormRenderer.cjs +1 -1
- package/dist/components/FormRenderer.cjs.map +1 -1
- package/dist/components/FormRenderer.d.cts +14 -0
- package/dist/components/FormRenderer.d.ts +1 -2
- package/dist/components/FormRenderer.js +1 -1
- package/dist/components/FormRenderer.js.map +1 -1
- package/dist/components/GenerativeUIErrorBoundary.cjs +1 -1
- package/dist/components/GenerativeUIErrorBoundary.cjs.map +1 -1
- 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/GenerativeUIErrorBoundary.js +1 -1
- package/dist/components/GenerativeUIErrorBoundary.js.map +1 -1
- package/dist/components/GhostText.cjs +2 -2
- package/dist/components/GhostText.cjs.map +1 -1
- package/dist/components/GhostText.d.cts +112 -0
- package/dist/components/GhostText.d.ts +0 -1
- package/dist/components/GhostText.js +2 -2
- package/dist/components/GhostText.js.map +1 -1
- package/dist/components/GraphRenderer.cjs +100 -29
- package/dist/components/GraphRenderer.cjs.map +1 -1
- package/dist/components/GraphRenderer.d.cts +66 -0
- package/dist/components/GraphRenderer.d.ts +2 -3
- package/dist/components/GraphRenderer.d.ts.map +1 -1
- package/dist/components/GraphRenderer.js +100 -29
- package/dist/components/GraphRenderer.js.map +1 -1
- 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.cjs +2 -2
- package/dist/components/MissingValue.cjs.map +1 -1
- package/dist/components/MissingValue.d.cts +26 -0
- package/dist/components/MissingValue.d.ts +0 -1
- package/dist/components/MissingValue.js +2 -2
- package/dist/components/MissingValue.js.map +1 -1
- package/dist/components/ModalRenderer.cjs +39 -31
- package/dist/components/ModalRenderer.cjs.map +1 -1
- package/dist/components/ModalRenderer.d.cts +66 -0
- package/dist/components/ModalRenderer.d.ts +1 -2
- package/dist/components/ModalRenderer.d.ts.map +1 -1
- package/dist/components/ModalRenderer.js +40 -32
- package/dist/components/ModalRenderer.js.map +1 -1
- package/dist/components/PortalDropdownMenu.cjs +6 -3
- package/dist/components/PortalDropdownMenu.cjs.map +1 -1
- package/dist/components/PortalDropdownMenu.d.cts +55 -0
- package/dist/components/PortalDropdownMenu.d.ts +0 -1
- package/dist/components/PortalDropdownMenu.d.ts.map +1 -1
- package/dist/components/PortalDropdownMenu.js +7 -4
- package/dist/components/PortalDropdownMenu.js.map +1 -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.cjs +38 -44
- package/dist/components/ScratchpadPanel.cjs.map +1 -1
- package/dist/components/ScratchpadPanel.d.cts +34 -0
- package/dist/components/ScratchpadPanel.d.ts +1 -2
- package/dist/components/ScratchpadPanel.d.ts.map +1 -1
- package/dist/components/ScratchpadPanel.js +38 -44
- package/dist/components/ScratchpadPanel.js.map +1 -1
- 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.cjs +20 -20
- package/dist/components/UIResourceRenderer.cjs.map +1 -1
- 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/UIResourceRenderer.js +20 -20
- package/dist/components/UIResourceRenderer.js.map +1 -1
- 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.cjs +4 -4
- package/dist/components/chart-missing-plugin.cjs.map +1 -1
- package/dist/components/chart-missing-plugin.d.cts +128 -0
- package/dist/components/chart-missing-plugin.d.ts +4 -3
- package/dist/components/chart-missing-plugin.d.ts.map +1 -1
- package/dist/components/chart-missing-plugin.js +4 -4
- package/dist/components/chart-missing-plugin.js.map +1 -1
- 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.cjs +1 -1
- package/dist/utils/math-markdown.cjs.map +1 -1
- package/dist/utils/math-markdown.d.cts +15 -0
- package/dist/utils/math-markdown.d.ts +1 -2
- package/dist/utils/math-markdown.js +1 -1
- package/dist/utils/math-markdown.js.map +1 -1
- 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.cjs +91 -0
- package/dist/utils/theme.cjs.map +1 -0
- package/dist/utils/theme.d.cts +10 -0
- package/dist/utils/theme.d.ts +10 -0
- package/dist/utils/theme.d.ts.map +1 -0
- package/dist/utils/theme.js +91 -0
- package/dist/utils/theme.js.map +1 -0
- package/dist/validation.d.cts +3 -4
- package/dist/validation.d.ts +3 -4
- package/docs/SECURITY-DEPENDENCIES.md +209 -0
- package/docs/THEMING.md +205 -0
- package/docs/ZOD4-STABLE-MIGRATION-2026-10-26.md +181 -0
- package/package.json +12 -9
- package/src/adapters/connector.ts +3 -3
- package/src/components/ActionGroupRenderer.tsx +6 -6
- package/src/components/AutocompleteDropdown.tsx +17 -17
- package/src/components/AutocompleteFormField.tsx +10 -9
- package/src/components/ChartJSRenderer.tsx +483 -239
- package/src/components/ChatPrompt.tsx +16 -16
- package/src/components/ComponentToolbar.tsx +5 -5
- package/src/components/DegradedFallback.tsx +9 -9
- package/src/components/ExpandableWrapper.tsx +15 -11
- package/src/components/FormFieldRenderer.tsx +52 -51
- package/src/components/FormRenderer.tsx +12 -12
- package/src/components/GenerativeUIErrorBoundary.tsx +6 -6
- package/src/components/GhostText.tsx +7 -7
- package/src/components/GraphRenderer.tsx +83 -67
- package/src/components/MissingValue.tsx +2 -2
- package/src/components/ModalRenderer.tsx +11 -5
- package/src/components/PortalDropdownMenu.tsx +6 -2
- package/src/components/ScratchpadPanel.tsx +144 -141
- package/src/components/UIResourceRenderer.tsx +101 -101
- package/src/components/chart-missing-plugin.ts +5 -3
- package/src/styles/autocomplete.css +53 -53
- package/src/utils/math-markdown.ts +1 -1
- package/src/utils/theme.ts +101 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Validation Service
|
|
3
|
+
* Phase 0: Resource Limits & Schema Validation
|
|
4
|
+
*
|
|
5
|
+
* Validates LLM-generated components against:
|
|
6
|
+
* - JSON schema
|
|
7
|
+
* - Resource limits (data points, payload size, grid bounds)
|
|
8
|
+
* - Security constraints (domain whitelist, XSS prevention)
|
|
9
|
+
*/
|
|
10
|
+
import type { UIComponent, UILayout, ValidationResult, ResourceLimits, ChartComponentParams, TableComponentParams, FormFieldParams, IframePolicy, ValidationOptions } from "../types.cjs";
|
|
11
|
+
/**
|
|
12
|
+
* Default resource limits (configurable via env)
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_RESOURCE_LIMITS: ResourceLimits;
|
|
15
|
+
/**
|
|
16
|
+
* Default allowed iframe domains (whitelist)
|
|
17
|
+
* Must match CSP frame-src directive
|
|
18
|
+
* Updated Sprint 7: Added code, design, docs, and map providers
|
|
19
|
+
*
|
|
20
|
+
* This list is exported for transparency and can be extended via ValidationOptions
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEFAULT_IFRAME_DOMAINS: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Trusted iframe domains that require allow-same-origin to function.
|
|
25
|
+
* These domains need access to their own cookies/storage for auth.
|
|
26
|
+
* All other whitelisted domains get a restrictive sandbox without allow-same-origin.
|
|
27
|
+
*/
|
|
28
|
+
export declare const TRUSTED_IFRAME_DOMAINS: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Validate grid position bounds (1-12 columns)
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateGridPosition(position: UIComponent['position']): ValidationResult;
|
|
33
|
+
/**
|
|
34
|
+
* Validate chart component against resource limits
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateChartComponent(params: ChartComponentParams, limits?: ResourceLimits): ValidationResult;
|
|
37
|
+
/**
|
|
38
|
+
* Validate table component against resource limits
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateTableComponent(params: TableComponentParams, limits?: ResourceLimits): ValidationResult;
|
|
41
|
+
/**
|
|
42
|
+
* Validate payload size
|
|
43
|
+
*/
|
|
44
|
+
export declare function validatePayloadSize(component: UIComponent, limits?: ResourceLimits): ValidationResult;
|
|
45
|
+
/**
|
|
46
|
+
* Sanitize string to prevent XSS
|
|
47
|
+
* Basic implementation - DOMPurify used at render time
|
|
48
|
+
*/
|
|
49
|
+
export declare function sanitizeString(input: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Validate iframe domain against whitelist
|
|
52
|
+
*
|
|
53
|
+
* @param url - The URL to validate
|
|
54
|
+
* @param options - Optional validation options
|
|
55
|
+
* @param options.policy - 'strict' (default), 'extend', or 'allow-all'
|
|
56
|
+
* @param options.customDomains - Additional domains when policy is 'extend'
|
|
57
|
+
*/
|
|
58
|
+
export declare function validateIframeDomain(url: string, options?: {
|
|
59
|
+
policy?: IframePolicy;
|
|
60
|
+
customDomains?: string[];
|
|
61
|
+
}): ValidationResult;
|
|
62
|
+
/**
|
|
63
|
+
* Is this URL's host a trusted iframe host?
|
|
64
|
+
*
|
|
65
|
+
* A host matches when it equals an entry of `TRUSTED_IFRAME_DOMAINS` (plus
|
|
66
|
+
* `options.customTrustedDomains`) or is a subdomain of one. Trusted hosts
|
|
67
|
+
* need their own cookies/storage to authenticate, which is why they receive
|
|
68
|
+
* `allow-same-origin` in `getIframeSandbox` and deliberately do NOT receive
|
|
69
|
+
* the `credentialless` iframe attribute (an authenticated embed loaded
|
|
70
|
+
* without its cookies only shows a login screen).
|
|
71
|
+
*
|
|
72
|
+
* An unparsable URL is never trusted.
|
|
73
|
+
*
|
|
74
|
+
* @param url - The iframe URL
|
|
75
|
+
* @param options - Optional custom trusted domains, merged over the defaults
|
|
76
|
+
* @returns `true` when the URL's host is trusted
|
|
77
|
+
* @since v6.21.0 — extracted from `getIframeSandbox`, identical matching.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isTrustedIframeDomain(url: string, options?: {
|
|
80
|
+
customTrustedDomains?: string[];
|
|
81
|
+
}): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Get the appropriate sandbox attribute for an iframe URL.
|
|
84
|
+
*
|
|
85
|
+
* Trusted domains (Google, Deposium, payment, auth-requiring services) get
|
|
86
|
+
* `allow-same-origin` so they can access their own cookies/storage.
|
|
87
|
+
* All other whitelisted domains get a restrictive sandbox without it,
|
|
88
|
+
* preventing access to the parent page's localStorage/cookies.
|
|
89
|
+
*
|
|
90
|
+
* @param url - The iframe URL
|
|
91
|
+
* @param options - Optional custom trusted domains
|
|
92
|
+
* @returns sandbox attribute string
|
|
93
|
+
*/
|
|
94
|
+
export declare function getIframeSandbox(url: string, options?: {
|
|
95
|
+
customTrustedDomains?: string[];
|
|
96
|
+
}): string;
|
|
97
|
+
/**
|
|
98
|
+
* Validate entire component
|
|
99
|
+
*
|
|
100
|
+
* @param component - The component to validate
|
|
101
|
+
* @param options - Optional validation options (limits, iframePolicy, customIframeDomains)
|
|
102
|
+
*/
|
|
103
|
+
export declare function validateComponent(component: UIComponent, options?: ValidationOptions): ValidationResult;
|
|
104
|
+
/**
|
|
105
|
+
* Validate entire layout
|
|
106
|
+
*
|
|
107
|
+
* @param layout - The layout to validate
|
|
108
|
+
* @param options - Optional validation options (limits, iframePolicy, customIframeDomains)
|
|
109
|
+
*/
|
|
110
|
+
export declare function validateLayout(layout: UILayout, options?: ValidationOptions): ValidationResult;
|
|
111
|
+
/**
|
|
112
|
+
* The end-user form-validation wording.
|
|
113
|
+
*
|
|
114
|
+
* `validateFieldValue` / `validateFormData` are pure and SSR-safe (they are
|
|
115
|
+
* re-exported from the `@seed-ship/mcp-ui-solid/validation` subpath), so
|
|
116
|
+
* they cannot read `MCPUIStrings`. The wording is injected instead: both
|
|
117
|
+
* take an optional trailing `messages` partial, and `FormRenderer` feeds it
|
|
118
|
+
* from `useMCPUIStrings()` (keys `fieldRequired`, `fieldMinLength`, …).
|
|
119
|
+
*
|
|
120
|
+
* The STRUCTURAL validators (`validateComponent`, `validateLayout`, …) keep
|
|
121
|
+
* their English `ValidationError.message`: those are payload diagnostics
|
|
122
|
+
* addressed to whoever produced the payload, not end-user chrome.
|
|
123
|
+
*
|
|
124
|
+
* @since v6.20.0
|
|
125
|
+
*/
|
|
126
|
+
export interface FormValidationMessages {
|
|
127
|
+
/** Template \u2014 `{field}`. */
|
|
128
|
+
required: string;
|
|
129
|
+
/** Template \u2014 `{field}`. */
|
|
130
|
+
mustBeChecked: string;
|
|
131
|
+
/** Template \u2014 `{min}`. */
|
|
132
|
+
minLength: string;
|
|
133
|
+
/** Template \u2014 `{max}`. */
|
|
134
|
+
maxLength: string;
|
|
135
|
+
/** Value does not match `field.pattern`. */
|
|
136
|
+
invalidPattern: string;
|
|
137
|
+
/** Value is not a valid email address. */
|
|
138
|
+
invalidEmail: string;
|
|
139
|
+
/** Value is not a number. */
|
|
140
|
+
invalidNumber: string;
|
|
141
|
+
/** Template \u2014 `{min}`. */
|
|
142
|
+
minValue: string;
|
|
143
|
+
/** Template \u2014 `{max}`. */
|
|
144
|
+
maxValue: string;
|
|
145
|
+
/** Template \u2014 `{min}`. */
|
|
146
|
+
minDate: string;
|
|
147
|
+
/** Template \u2014 `{max}`. */
|
|
148
|
+
maxDate: string;
|
|
149
|
+
/** Value is not one of `field.options`. */
|
|
150
|
+
invalidOption: string;
|
|
151
|
+
/** Template \u2014 `{format}`. `field.valueFormatHint` still wins. */
|
|
152
|
+
invalidFormat: string;
|
|
153
|
+
}
|
|
154
|
+
/** English defaults for {@link FormValidationMessages}. */
|
|
155
|
+
export declare const DEFAULT_VALIDATION_MESSAGES: FormValidationMessages;
|
|
156
|
+
/**
|
|
157
|
+
* Validate a single form field value against field rules
|
|
158
|
+
*/
|
|
159
|
+
export declare function validateFieldValue(value: any, field: FormFieldParams, messages?: Partial<FormValidationMessages>): {
|
|
160
|
+
valid: boolean;
|
|
161
|
+
error?: string;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Validate entire form data against field definitions
|
|
165
|
+
*/
|
|
166
|
+
export declare function validateFormData(data: Record<string, any>, fields: FormFieldParams[], messages?: Partial<FormValidationMessages>): {
|
|
167
|
+
valid: boolean;
|
|
168
|
+
errors: Record<string, string>;
|
|
169
|
+
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - Resource limits (data points, payload size, grid bounds)
|
|
8
8
|
* - Security constraints (domain whitelist, XSS prevention)
|
|
9
9
|
*/
|
|
10
|
-
import type { UIComponent, UILayout, ValidationResult, ResourceLimits, ChartComponentParams, TableComponentParams, FormFieldParams, IframePolicy, ValidationOptions } from
|
|
10
|
+
import type { UIComponent, UILayout, ValidationResult, ResourceLimits, ChartComponentParams, TableComponentParams, FormFieldParams, IframePolicy, ValidationOptions } from "../types.js";
|
|
11
11
|
/**
|
|
12
12
|
* Default resource limits (configurable via env)
|
|
13
13
|
*/
|
|
@@ -167,4 +167,3 @@ export declare function validateFormData(data: Record<string, any>, fields: Form
|
|
|
167
167
|
valid: boolean;
|
|
168
168
|
errors: Record<string, string>;
|
|
169
169
|
};
|
|
170
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scratchpad Store — reactive state for HITL scratchpad
|
|
3
|
+
*
|
|
4
|
+
* @experimental
|
|
5
|
+
*
|
|
6
|
+
* **v5.2.0 :** the store is now a factory (`createScratchpadStore()`) with a
|
|
7
|
+
* module-level singleton kept as default. Two consumption modes :
|
|
8
|
+
*
|
|
9
|
+
* 1. **Singleton mode (default, zero-config)** — `dispatchScratchpad(event)` +
|
|
10
|
+
* `useScratchpadState()` read/write the module singleton. This is the v4.x
|
|
11
|
+
* path and keeps working unchanged.
|
|
12
|
+
*
|
|
13
|
+
* 2. **Multi-instance mode** — wrap a subtree in `<ScratchpadStoreProvider>`
|
|
14
|
+
* (it creates a scoped `ScratchpadStoreHandle` internally, or use your own
|
|
15
|
+
* via the `store` prop). `useScratchpadState()` auto-detects the context
|
|
16
|
+
* and reads from it; `ScratchpadPanel` mounted inside the provider reads
|
|
17
|
+
* the scoped store. Non-reactive callers (SSE parsers) should pass the
|
|
18
|
+
* handle explicitly — do NOT try to reach context from a non-reactive
|
|
19
|
+
* scope.
|
|
20
|
+
*/
|
|
21
|
+
import { type ParentComponent } from 'solid-js';
|
|
22
|
+
import type { ScratchpadState, ScratchpadEvent } from "../types/chat-bus.cjs";
|
|
23
|
+
export interface ScratchpadStoreHandle {
|
|
24
|
+
/** Mutate the store from an SSE/parser callback. */
|
|
25
|
+
dispatch: (event: ScratchpadEvent) => void;
|
|
26
|
+
/** Reactive accessor for the current scratchpad state (null when closed). */
|
|
27
|
+
state: () => ScratchpadState | null;
|
|
28
|
+
/** Reactive accessor for the pinned flag. */
|
|
29
|
+
pinned: () => boolean;
|
|
30
|
+
/** Close the scratchpad (equivalent to dispatching an action='close'). */
|
|
31
|
+
close: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create an isolated scratchpad store instance.
|
|
35
|
+
*
|
|
36
|
+
* Use this when you need two or more scratchpads live at the same time
|
|
37
|
+
* (e.g. chat scratchpad + admin dashboard scratchpad). Pair with
|
|
38
|
+
* `<ScratchpadStoreProvider store={...}>` to scope a SolidJS subtree.
|
|
39
|
+
*
|
|
40
|
+
* @experimental
|
|
41
|
+
* @since v5.2.0
|
|
42
|
+
*/
|
|
43
|
+
export declare function createScratchpadStore(): ScratchpadStoreHandle;
|
|
44
|
+
/**
|
|
45
|
+
* Function for the PARSER/STORE — mutates the **module-level singleton**
|
|
46
|
+
* scratchpad state. Use this when you only need one scratchpad at a time
|
|
47
|
+
* (single-instance consumer, the v4.x pattern).
|
|
48
|
+
*
|
|
49
|
+
* For multi-instance scenarios, prefer `createScratchpadStore()` and pass the
|
|
50
|
+
* handle around explicitly.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // In your SSE parser callback — ONE LINE
|
|
54
|
+
* onScratchpad: (data) => dispatchScratchpad(data as ScratchpadEvent)
|
|
55
|
+
*/
|
|
56
|
+
export declare function dispatchScratchpad(event: ScratchpadEvent): void;
|
|
57
|
+
/**
|
|
58
|
+
* Context for a scoped scratchpad store. Populated by
|
|
59
|
+
* `<ScratchpadStoreProvider>`. Read by `useScratchpadState()` with automatic
|
|
60
|
+
* fallback to the module-level singleton when the context is absent.
|
|
61
|
+
*
|
|
62
|
+
* @experimental
|
|
63
|
+
* @since v5.2.0
|
|
64
|
+
*/
|
|
65
|
+
export declare const ScratchpadStoreContext: import("solid-js").Context<ScratchpadStoreHandle | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* Provide a scoped `ScratchpadStoreHandle` to a SolidJS subtree. Children
|
|
68
|
+
* reading via `useScratchpadState()` or rendering a `<ScratchpadPanel>` will
|
|
69
|
+
* bind to this store instead of the module singleton.
|
|
70
|
+
*
|
|
71
|
+
* If no `store` prop is passed, a fresh store is created for the provider's
|
|
72
|
+
* lifetime. Pass `store` explicitly when you need the handle outside the
|
|
73
|
+
* tree (e.g. in an SSE parser that lives at the app root).
|
|
74
|
+
*
|
|
75
|
+
* @experimental
|
|
76
|
+
* @since v5.2.0
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* const chatStore = createScratchpadStore()
|
|
80
|
+
* const adminStore = createScratchpadStore()
|
|
81
|
+
*
|
|
82
|
+
* <ScratchpadStoreProvider store={chatStore}>
|
|
83
|
+
* <ChatInterface />
|
|
84
|
+
* </ScratchpadStoreProvider>
|
|
85
|
+
* <ScratchpadStoreProvider store={adminStore}>
|
|
86
|
+
* <AdminDashboard />
|
|
87
|
+
* </ScratchpadStoreProvider>
|
|
88
|
+
*/
|
|
89
|
+
export declare const ScratchpadStoreProvider: ParentComponent<{
|
|
90
|
+
store?: ScratchpadStoreHandle;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* Hook for the COMPONENT — reads the scratchpad state reactively.
|
|
94
|
+
*
|
|
95
|
+
* **v5.2.0 :** if called inside a `<ScratchpadStoreProvider>`, reads the
|
|
96
|
+
* scoped handle; otherwise falls back to the module singleton. Old v4.x
|
|
97
|
+
* consumers keep working unchanged.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const { state, pinned, close } = useScratchpadState()
|
|
101
|
+
* <Show when={state()}>
|
|
102
|
+
* <ScratchpadPanel state={state()!} pinned={pinned()} onClose={close} />
|
|
103
|
+
* </Show>
|
|
104
|
+
*/
|
|
105
|
+
export declare function useScratchpadState(): {
|
|
106
|
+
state: () => ScratchpadState | null;
|
|
107
|
+
pinned: () => boolean;
|
|
108
|
+
close: () => void;
|
|
109
|
+
};
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* scope.
|
|
20
20
|
*/
|
|
21
21
|
import { type ParentComponent } from 'solid-js';
|
|
22
|
-
import type { ScratchpadState, ScratchpadEvent } from
|
|
22
|
+
import type { ScratchpadState, ScratchpadEvent } from "../types/chat-bus.js";
|
|
23
23
|
export interface ScratchpadStoreHandle {
|
|
24
24
|
/** Mutate the store from an SSE/parser callback. */
|
|
25
25
|
dispatch: (event: ScratchpadEvent) => void;
|
|
@@ -107,4 +107,3 @@ export declare function useScratchpadState(): {
|
|
|
107
107
|
pinned: () => boolean;
|
|
108
108
|
close: () => void;
|
|
109
109
|
};
|
|
110
|
-
//# sourceMappingURL=scratchpad-store.d.ts.map
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Capabilities Store — reactive snapshot of the MCP `initialize`
|
|
3
|
+
* response echoed by the server.
|
|
4
|
+
*
|
|
5
|
+
* @experimental
|
|
6
|
+
* @since v5.3.0
|
|
7
|
+
*
|
|
8
|
+
* mcp-ui doesn't speak MCP protocol directly — the consumer's transport
|
|
9
|
+
* layer (stdio child process, HTTP/SSE client, ...) parses the
|
|
10
|
+
* `initialize` JSON-RPC response and pushes the relevant fields into this
|
|
11
|
+
* store via `setServerCapabilities(info)`. Components then read
|
|
12
|
+
* reactively via `useServerCapabilities()` to gate behavior :
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const { capabilities } = useServerCapabilities()
|
|
16
|
+
* <Show when={capabilities()?.tools?.listChanged}>
|
|
17
|
+
* <ToolListSubscriber />
|
|
18
|
+
* </Show>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ## Two consumption modes (mirrors `scratchpad-store`)
|
|
22
|
+
*
|
|
23
|
+
* 1. **Singleton mode (default)** — `setServerCapabilities(info)` mutates
|
|
24
|
+
* the module-level singleton. `useServerCapabilities()` reads from it.
|
|
25
|
+
* Use for single-MCP-server consumers (the common case).
|
|
26
|
+
*
|
|
27
|
+
* 2. **Multi-instance mode** — wrap a subtree in
|
|
28
|
+
* `<ServerCapabilitiesProvider>` to scope a separate handle. Pass
|
|
29
|
+
* `store={createServerCapabilitiesStore()}` explicitly when you need to
|
|
30
|
+
* drive it from a non-reactive scope (e.g. a transport adapter living
|
|
31
|
+
* at the app root).
|
|
32
|
+
*
|
|
33
|
+
* ## Note on `elicitation`
|
|
34
|
+
*
|
|
35
|
+
* Per MCP spec 2025-06-18, `elicitation` is a **CLIENT** capability, not
|
|
36
|
+
* a server one. Servers do not declare it. If you need to gate
|
|
37
|
+
* `<ElicitationForm>` rendering on whether the connected client *itself*
|
|
38
|
+
* supports elicitation — that's a separate concern (your own state, set
|
|
39
|
+
* by your transport layer based on its own configuration).
|
|
40
|
+
*/
|
|
41
|
+
import { type ParentComponent } from 'solid-js';
|
|
42
|
+
/**
|
|
43
|
+
* Server capabilities object as advertised in the MCP `initialize` response.
|
|
44
|
+
* Mirrors the spec 2025-06-18 `ServerCapabilities` shape with permissive
|
|
45
|
+
* `experimental` for forward compatibility.
|
|
46
|
+
*/
|
|
47
|
+
export interface ServerCapabilities {
|
|
48
|
+
experimental?: Record<string, unknown>;
|
|
49
|
+
logging?: Record<string, never>;
|
|
50
|
+
tools?: {
|
|
51
|
+
listChanged?: boolean;
|
|
52
|
+
};
|
|
53
|
+
prompts?: {
|
|
54
|
+
listChanged?: boolean;
|
|
55
|
+
};
|
|
56
|
+
resources?: {
|
|
57
|
+
listChanged?: boolean;
|
|
58
|
+
subscribe?: boolean;
|
|
59
|
+
};
|
|
60
|
+
completions?: Record<string, never>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Subset of the MCP `initialize` response relevant to the UI layer.
|
|
64
|
+
* Consumers may extend this via the `experimental` field.
|
|
65
|
+
*/
|
|
66
|
+
export interface ServerInitializeInfo {
|
|
67
|
+
protocolVersion: string;
|
|
68
|
+
serverInfo: {
|
|
69
|
+
name: string;
|
|
70
|
+
version: string;
|
|
71
|
+
title?: string;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
};
|
|
74
|
+
capabilities: ServerCapabilities;
|
|
75
|
+
instructions?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ServerCapabilitiesStoreHandle {
|
|
78
|
+
/** Push a fresh `initialize` snapshot into the store, or clear with `null`. */
|
|
79
|
+
set: (info: ServerInitializeInfo | null) => void;
|
|
80
|
+
/** Reactive accessor for the full info (null when no initialize received). */
|
|
81
|
+
info: () => ServerInitializeInfo | null;
|
|
82
|
+
/** Reactive accessor for just the `capabilities` field. */
|
|
83
|
+
capabilities: () => ServerCapabilities | null;
|
|
84
|
+
/** Reactive accessor for just the `serverInfo` field. */
|
|
85
|
+
serverInfo: () => ServerInitializeInfo['serverInfo'] | null;
|
|
86
|
+
/** Reactive accessor for the protocol version string. */
|
|
87
|
+
protocolVersion: () => string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Helper : returns true if the server advertised the named capability key
|
|
90
|
+
* with a truthy value (i.e. the key is present, even as an empty object).
|
|
91
|
+
*/
|
|
92
|
+
hasCapability: (key: keyof ServerCapabilities) => boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create an isolated server-capabilities store instance.
|
|
96
|
+
*
|
|
97
|
+
* Use this when you need to track multiple MCP servers in parallel (rare),
|
|
98
|
+
* or to drive the store from a non-reactive transport adapter. Pair with
|
|
99
|
+
* `<ServerCapabilitiesProvider store={...}>` to scope a SolidJS subtree.
|
|
100
|
+
*
|
|
101
|
+
* @experimental
|
|
102
|
+
* @since v5.3.0
|
|
103
|
+
*/
|
|
104
|
+
export declare function createServerCapabilitiesStore(): ServerCapabilitiesStoreHandle;
|
|
105
|
+
/**
|
|
106
|
+
* Push the parsed MCP `initialize` response into the module-level singleton
|
|
107
|
+
* store. Pass `null` to clear (e.g. on disconnect / server change).
|
|
108
|
+
*
|
|
109
|
+
* @experimental
|
|
110
|
+
* @since v5.3.0
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* // In your transport adapter, after receiving the initialize response :
|
|
114
|
+
* setServerCapabilities({
|
|
115
|
+
* protocolVersion: response.result.protocolVersion,
|
|
116
|
+
* serverInfo: response.result.serverInfo,
|
|
117
|
+
* capabilities: response.result.capabilities,
|
|
118
|
+
* instructions: response.result.instructions,
|
|
119
|
+
* })
|
|
120
|
+
*/
|
|
121
|
+
export declare function setServerCapabilities(info: ServerInitializeInfo | null): void;
|
|
122
|
+
/**
|
|
123
|
+
* Context for a scoped server-capabilities store. Populated by
|
|
124
|
+
* `<ServerCapabilitiesProvider>`. Read by `useServerCapabilities()` with
|
|
125
|
+
* automatic fallback to the module-level singleton when absent.
|
|
126
|
+
*
|
|
127
|
+
* @experimental
|
|
128
|
+
* @since v5.3.0
|
|
129
|
+
*/
|
|
130
|
+
export declare const ServerCapabilitiesContext: import("solid-js").Context<ServerCapabilitiesStoreHandle | undefined>;
|
|
131
|
+
/**
|
|
132
|
+
* Provide a scoped `ServerCapabilitiesStoreHandle` to a SolidJS subtree.
|
|
133
|
+
* Children calling `useServerCapabilities()` bind to this store instead of
|
|
134
|
+
* the module singleton.
|
|
135
|
+
*
|
|
136
|
+
* If no `store` prop is passed, a fresh store is created for the provider's
|
|
137
|
+
* lifetime. Pass `store` explicitly when you need the handle outside the
|
|
138
|
+
* tree (e.g. in a transport adapter living at the app root).
|
|
139
|
+
*
|
|
140
|
+
* @experimental
|
|
141
|
+
* @since v5.3.0
|
|
142
|
+
*/
|
|
143
|
+
export declare const ServerCapabilitiesProvider: ParentComponent<{
|
|
144
|
+
store?: ServerCapabilitiesStoreHandle;
|
|
145
|
+
}>;
|
|
146
|
+
/**
|
|
147
|
+
* Hook for components — reads the server capabilities reactively.
|
|
148
|
+
*
|
|
149
|
+
* If called inside a `<ServerCapabilitiesProvider>`, reads the scoped
|
|
150
|
+
* handle; otherwise falls back to the module singleton.
|
|
151
|
+
*
|
|
152
|
+
* @experimental
|
|
153
|
+
* @since v5.3.0
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* const { capabilities, serverInfo, hasCapability } = useServerCapabilities()
|
|
157
|
+
*
|
|
158
|
+
* <Show when={capabilities()}>
|
|
159
|
+
* <p>Connected to {serverInfo()?.name} v{serverInfo()?.version}</p>
|
|
160
|
+
* <Show when={hasCapability('tools')}>
|
|
161
|
+
* <ToolPalette />
|
|
162
|
+
* </Show>
|
|
163
|
+
* </Show>
|
|
164
|
+
*/
|
|
165
|
+
export declare function useServerCapabilities(): {
|
|
166
|
+
info: () => ServerInitializeInfo | null;
|
|
167
|
+
capabilities: () => ServerCapabilities | null;
|
|
168
|
+
serverInfo: () => ServerInitializeInfo['serverInfo'] | null;
|
|
169
|
+
protocolVersion: () => string | null;
|
|
170
|
+
hasCapability: (key: keyof ServerCapabilities) => boolean;
|
|
171
|
+
};
|
package/dist/test-setup.d.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Testing utilities for mcp-ui consumers.
|
|
3
|
+
*
|
|
4
|
+
* @experimental
|
|
5
|
+
* @since v4.3.9
|
|
6
|
+
*/
|
|
7
|
+
import type { ChatBus, ChatPromptConfig, ChatPromptResponse } from "../types/chat-bus.cjs";
|
|
8
|
+
export interface MockChatBusOptions {
|
|
9
|
+
/** Pre-programmed responses for showChatPrompt, consumed in FIFO order */
|
|
10
|
+
promptResponses?: ChatPromptResponse[];
|
|
11
|
+
/** Called when showChatPrompt is invoked (spy hook) */
|
|
12
|
+
onShowChatPrompt?: (config: ChatPromptConfig) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a ChatBus pre-wired with test fixtures.
|
|
16
|
+
*
|
|
17
|
+
* Pre-programmed `ChatPromptResponse`s are returned in FIFO order when the
|
|
18
|
+
* agent calls `showChatPrompt`. Useful for testing flows that depend on
|
|
19
|
+
* user choices without rendering any UI.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const bus = createMockChatBus({
|
|
23
|
+
* promptResponses: [
|
|
24
|
+
* { type: 'choice', value: 'yes', label: 'Yes' },
|
|
25
|
+
* ],
|
|
26
|
+
* })
|
|
27
|
+
* const response = await bus.commands.exec('showChatPrompt', {
|
|
28
|
+
* type: 'choice',
|
|
29
|
+
* title: 'Proceed?',
|
|
30
|
+
* config: { options: [{ value: 'yes', label: 'Yes' }] },
|
|
31
|
+
* })
|
|
32
|
+
* expect(response.value).toBe('yes')
|
|
33
|
+
*/
|
|
34
|
+
export declare function createMockChatBus(options?: MockChatBusOptions): ChatBus;
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @experimental
|
|
5
5
|
* @since v4.3.9
|
|
6
6
|
*/
|
|
7
|
-
import type { ChatBus, ChatPromptConfig, ChatPromptResponse } from
|
|
7
|
+
import type { ChatBus, ChatPromptConfig, ChatPromptResponse } from "../types/chat-bus.js";
|
|
8
8
|
export interface MockChatBusOptions {
|
|
9
9
|
/** Pre-programmed responses for showChatPrompt, consumed in FIFO order */
|
|
10
10
|
promptResponses?: ChatPromptResponse[];
|
|
@@ -32,4 +32,3 @@ export interface MockChatBusOptions {
|
|
|
32
32
|
* expect(response.value).toBe('yes')
|
|
33
33
|
*/
|
|
34
34
|
export declare function createMockChatBus(options?: MockChatBusOptions): ChatBus;
|
|
35
|
-
//# sourceMappingURL=index.d.ts.map
|