@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.
Files changed (236) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +14 -0
  3. package/dist/adapters/connector.cjs +3 -3
  4. package/dist/adapters/connector.cjs.map +1 -1
  5. package/dist/adapters/connector.d.cts +108 -0
  6. package/dist/adapters/connector.d.ts +1 -2
  7. package/dist/adapters/connector.js +3 -3
  8. package/dist/adapters/connector.js.map +1 -1
  9. package/dist/adapters/index.d.cts +21 -0
  10. package/dist/adapters/index.d.ts +6 -7
  11. package/dist/adapters/macro-run.d.cts +99 -0
  12. package/dist/adapters/macro-run.d.ts +1 -2
  13. package/dist/adapters/presentation.d.cts +1 -2
  14. package/dist/adapters/presentation.d.ts +1 -2
  15. package/dist/adapters.d.cts +1 -1
  16. package/dist/adapters.d.ts +1 -1
  17. package/dist/components/ActionGroupRenderer.d.cts +38 -0
  18. package/dist/components/ActionGroupRenderer.d.ts +1 -2
  19. package/dist/components/ActionRenderer.d.cts +9 -0
  20. package/dist/components/ActionRenderer.d.ts +0 -1
  21. package/dist/components/AgentCard.d.cts +19 -0
  22. package/dist/components/AgentCard.d.ts +1 -2
  23. package/dist/components/AgentHandoff.d.cts +11 -0
  24. package/dist/components/AgentHandoff.d.ts +1 -2
  25. package/dist/components/ArtifactRenderer.d.cts +11 -0
  26. package/dist/components/ArtifactRenderer.d.ts +0 -1
  27. package/dist/components/AutocompleteDropdown.d.cts +70 -0
  28. package/dist/components/AutocompleteDropdown.d.ts +1 -2
  29. package/dist/components/AutocompleteFormField.d.cts +51 -0
  30. package/dist/components/AutocompleteFormField.d.ts +1 -2
  31. package/dist/components/BriefingDiff.d.cts +11 -0
  32. package/dist/components/BriefingDiff.d.ts +1 -2
  33. package/dist/components/CarouselRenderer.d.cts +12 -0
  34. package/dist/components/CarouselRenderer.d.ts +1 -2
  35. package/dist/components/ChartJSRenderer.d.cts +62 -0
  36. package/dist/components/ChartJSRenderer.d.ts +1 -2
  37. package/dist/components/ChatPrompt.d.cts +69 -0
  38. package/dist/components/ChatPrompt.d.ts +1 -2
  39. package/dist/components/CodeBlockRenderer.d.cts +23 -0
  40. package/dist/components/CodeBlockRenderer.d.ts +1 -2
  41. package/dist/components/ComponentToolbar.d.cts +46 -0
  42. package/dist/components/ComponentToolbar.d.ts +0 -1
  43. package/dist/components/DataPreviewSection.d.cts +11 -0
  44. package/dist/components/DataPreviewSection.d.ts +1 -2
  45. package/dist/components/DegradedFallback.d.cts +43 -0
  46. package/dist/components/DegradedFallback.d.ts +0 -1
  47. package/dist/components/DraggableGridItem.d.cts +94 -0
  48. package/dist/components/DraggableGridItem.d.ts +1 -2
  49. package/dist/components/EditableLayoutContext.d.cts +4 -0
  50. package/dist/components/EditableLayoutContext.d.ts +0 -1
  51. package/dist/components/EditableUIResourceRenderer.d.cts +42 -0
  52. package/dist/components/EditableUIResourceRenderer.d.ts +1 -2
  53. package/dist/components/ElicitationForm.d.cts +67 -0
  54. package/dist/components/ElicitationForm.d.ts +1 -2
  55. package/dist/components/ExpandableWrapper.d.cts +49 -0
  56. package/dist/components/ExpandableWrapper.d.ts +0 -1
  57. package/dist/components/FeedbackInline.d.cts +70 -0
  58. package/dist/components/FeedbackInline.d.ts +0 -1
  59. package/dist/components/FooterRenderer.d.cts +15 -0
  60. package/dist/components/FooterRenderer.d.ts +0 -1
  61. package/dist/components/FormFieldRenderer.d.cts +19 -0
  62. package/dist/components/FormFieldRenderer.d.ts +1 -2
  63. package/dist/components/FormRenderer.d.cts +14 -0
  64. package/dist/components/FormRenderer.d.ts +1 -2
  65. package/dist/components/GenerativeUIErrorBoundary.d.cts +58 -0
  66. package/dist/components/GenerativeUIErrorBoundary.d.ts +1 -2
  67. package/dist/components/GenerativeUIErrorBoundary.default.d.cts +1 -0
  68. package/dist/components/GenerativeUIErrorBoundary.default.d.ts +1 -2
  69. package/dist/components/GhostText.d.cts +112 -0
  70. package/dist/components/GhostText.d.ts +0 -1
  71. package/dist/components/GraphRenderer.d.cts +66 -0
  72. package/dist/components/GraphRenderer.d.ts +1 -2
  73. package/dist/components/GridRenderer.d.cts +49 -0
  74. package/dist/components/GridRenderer.d.ts +1 -2
  75. package/dist/components/IframeFallbackLink.d.cts +22 -0
  76. package/dist/components/IframeFallbackLink.d.ts +0 -1
  77. package/dist/components/ImageGalleryRenderer.d.cts +22 -0
  78. package/dist/components/ImageGalleryRenderer.d.ts +1 -2
  79. package/dist/components/LightboxOverlay.d.cts +31 -0
  80. package/dist/components/LightboxOverlay.d.ts +1 -2
  81. package/dist/components/MapRenderer.d.cts +77 -0
  82. package/dist/components/MapRenderer.d.ts +1 -2
  83. package/dist/components/MissingValue.d.cts +26 -0
  84. package/dist/components/MissingValue.d.ts +0 -1
  85. package/dist/components/ModalRenderer.d.cts +66 -0
  86. package/dist/components/ModalRenderer.d.ts +1 -2
  87. package/dist/components/PortalDropdownMenu.d.cts +55 -0
  88. package/dist/components/PortalDropdownMenu.d.ts +0 -1
  89. package/dist/components/PresentationFeedback.d.cts +112 -0
  90. package/dist/components/PresentationFeedback.d.ts +0 -1
  91. package/dist/components/RenderContext.d.cts +41 -0
  92. package/dist/components/RenderContext.d.ts +1 -2
  93. package/dist/components/ResizeHandle.d.cts +49 -0
  94. package/dist/components/ResizeHandle.d.ts +0 -1
  95. package/dist/components/SafeHtml.d.cts +45 -0
  96. package/dist/components/SafeHtml.d.ts +0 -1
  97. package/dist/components/ScratchpadPanel.d.cts +34 -0
  98. package/dist/components/ScratchpadPanel.d.ts +1 -2
  99. package/dist/components/SplitStepper.d.cts +11 -0
  100. package/dist/components/SplitStepper.d.ts +1 -2
  101. package/dist/components/StreamingUIRenderer.d.cts +58 -0
  102. package/dist/components/StreamingUIRenderer.d.ts +3 -4
  103. package/dist/components/UIResourceRenderer.d.cts +181 -0
  104. package/dist/components/UIResourceRenderer.d.ts +3 -4
  105. package/dist/components/UIResourceRenderer.default.d.cts +1 -0
  106. package/dist/components/UIResourceRenderer.default.d.ts +1 -2
  107. package/dist/components/VerifiedText.d.cts +22 -0
  108. package/dist/components/VerifiedText.d.ts +1 -2
  109. package/dist/components/VideoRenderer.d.cts +41 -0
  110. package/dist/components/VideoRenderer.d.ts +1 -2
  111. package/dist/components/chart-data-table.d.cts +68 -0
  112. package/dist/components/chart-data-table.d.ts +0 -1
  113. package/dist/components/chart-missing-plugin.d.cts +128 -0
  114. package/dist/components/chart-missing-plugin.d.ts +1 -2
  115. package/dist/components/index.d.cts +62 -0
  116. package/dist/components/index.d.ts +57 -58
  117. package/dist/components.d.cts +2 -2
  118. package/dist/components.d.ts +2 -2
  119. package/dist/context/AutocompleteContext.d.cts +76 -0
  120. package/dist/context/AutocompleteContext.d.ts +1 -2
  121. package/dist/context/MCPActionContext.d.cts +169 -0
  122. package/dist/context/MCPActionContext.d.ts +0 -1
  123. package/dist/context/MCPUIConfigContext.d.cts +201 -0
  124. package/dist/context/MCPUIConfigContext.d.ts +1 -2
  125. package/dist/context/MCPUIMathContext.d.cts +17 -0
  126. package/dist/context/MCPUIMathContext.d.ts +0 -1
  127. package/dist/context/MCPUIStringsContext.d.cts +802 -0
  128. package/dist/context/MCPUIStringsContext.d.ts +1 -2
  129. package/dist/context/MCPUITelemetryContext.d.cts +35 -0
  130. package/dist/context/MCPUITelemetryContext.d.ts +1 -2
  131. package/dist/context/index.d.cts +7 -0
  132. package/dist/context/index.d.ts +2 -3
  133. package/dist/hooks/createResponsiveGrid.d.cts +5 -0
  134. package/dist/hooks/createResponsiveGrid.d.ts +0 -1
  135. package/dist/hooks/index.d.cts +25 -0
  136. package/dist/hooks/index.d.ts +20 -21
  137. package/dist/hooks/useAction.d.cts +164 -0
  138. package/dist/hooks/useAction.d.ts +2 -3
  139. package/dist/hooks/useAutocomplete.d.cts +118 -0
  140. package/dist/hooks/useAutocomplete.d.ts +1 -2
  141. package/dist/hooks/useChatBus.d.cts +55 -0
  142. package/dist/hooks/useChatBus.d.ts +1 -2
  143. package/dist/hooks/useConditionalField.d.cts +34 -0
  144. package/dist/hooks/useConditionalField.d.ts +1 -2
  145. package/dist/hooks/useDataValidator.d.cts +41 -0
  146. package/dist/hooks/useDataValidator.d.ts +1 -2
  147. package/dist/hooks/useDragDrop.d.cts +99 -0
  148. package/dist/hooks/useDragDrop.d.ts +1 -2
  149. package/dist/hooks/useFormPersistence.d.cts +80 -0
  150. package/dist/hooks/useFormPersistence.d.ts +0 -1
  151. package/dist/hooks/useModal.d.cts +106 -0
  152. package/dist/hooks/useModal.d.ts +0 -1
  153. package/dist/hooks/useResize.d.cts +86 -0
  154. package/dist/hooks/useResize.d.ts +1 -2
  155. package/dist/hooks/useStreamingUI.d.cts +117 -0
  156. package/dist/hooks/useStreamingUI.d.ts +1 -2
  157. package/dist/hooks.d.cts +1 -1
  158. package/dist/hooks.d.ts +1 -1
  159. package/dist/index.d.cts +91 -92
  160. package/dist/index.d.ts +91 -92
  161. package/dist/plugins/duckdb.d.cts +1 -2
  162. package/dist/plugins/duckdb.d.ts +1 -2
  163. package/dist/plugins/groq.d.cts +12 -0
  164. package/dist/plugins/groq.d.ts +1 -2
  165. package/dist/plugins/index.d.cts +9 -0
  166. package/dist/plugins/index.d.ts +3 -4
  167. package/dist/plugins/katex.d.cts +1 -2
  168. package/dist/plugins/katex.d.ts +1 -2
  169. package/dist/plugins/rest.d.cts +12 -0
  170. package/dist/plugins/rest.d.ts +1 -2
  171. package/dist/plugins/supabase.d.cts +12 -0
  172. package/dist/plugins/supabase.d.ts +1 -2
  173. package/dist/services/chat-bus.d.cts +100 -0
  174. package/dist/services/chat-bus.d.ts +1 -2
  175. package/dist/services/chat-prompt-controller.d.cts +92 -0
  176. package/dist/services/chat-prompt-controller.d.ts +1 -2
  177. package/dist/services/component-registry.d.cts +119 -0
  178. package/dist/services/component-registry.d.ts +1 -2
  179. package/dist/services/data-validator.d.cts +27 -0
  180. package/dist/services/data-validator.d.ts +1 -2
  181. package/dist/services/index.d.cts +9 -0
  182. package/dist/services/index.d.ts +4 -5
  183. package/dist/services/telemetry.d.cts +86 -0
  184. package/dist/services/telemetry.d.ts +1 -2
  185. package/dist/services/validation.d.cts +169 -0
  186. package/dist/services/validation.d.ts +1 -2
  187. package/dist/stores/scratchpad-store.d.cts +109 -0
  188. package/dist/stores/scratchpad-store.d.ts +1 -2
  189. package/dist/stores/server-capabilities-store.d.cts +171 -0
  190. package/dist/stores/server-capabilities-store.d.ts +0 -1
  191. package/dist/test-setup.d.cts +5 -0
  192. package/dist/test-setup.d.ts +0 -1
  193. package/dist/testing/index.d.cts +34 -0
  194. package/dist/testing/index.d.ts +1 -2
  195. package/dist/types/chat-bus.d.cts +783 -0
  196. package/dist/types/chat-bus.d.ts +4 -5
  197. package/dist/types/index.d.cts +1616 -0
  198. package/dist/types/index.d.ts +0 -1
  199. package/dist/types-export.d.cts +1 -2
  200. package/dist/types-export.d.ts +1 -2
  201. package/dist/types.d.cts +1 -1
  202. package/dist/types.d.ts +1 -1
  203. package/dist/utils/degraded-projections.d.cts +119 -0
  204. package/dist/utils/degraded-projections.d.ts +0 -1
  205. package/dist/utils/duplicate-mount-registry.d.cts +83 -0
  206. package/dist/utils/duplicate-mount-registry.d.ts +0 -1
  207. package/dist/utils/escape-html.d.cts +12 -0
  208. package/dist/utils/escape-html.d.ts +0 -1
  209. package/dist/utils/format-string.d.cts +25 -0
  210. package/dist/utils/format-string.d.ts +0 -1
  211. package/dist/utils/iframe-coep.d.cts +53 -0
  212. package/dist/utils/iframe-coep.d.ts +1 -2
  213. package/dist/utils/logger.d.cts +57 -0
  214. package/dist/utils/logger.d.ts +0 -1
  215. package/dist/utils/math-markdown.d.cts +15 -0
  216. package/dist/utils/math-markdown.d.ts +1 -2
  217. package/dist/utils/missing-value.d.cts +78 -0
  218. package/dist/utils/missing-value.d.ts +0 -1
  219. package/dist/utils/pan-zoom.d.cts +234 -0
  220. package/dist/utils/pan-zoom.d.ts +0 -1
  221. package/dist/utils/perf.d.cts +18 -0
  222. package/dist/utils/perf.d.ts +0 -1
  223. package/dist/utils/safe-url.d.cts +33 -0
  224. package/dist/utils/safe-url.d.ts +0 -1
  225. package/dist/utils/sanitize-html.d.cts +142 -0
  226. package/dist/utils/sanitize-html.d.ts +0 -1
  227. package/dist/utils/stable-key.d.cts +32 -0
  228. package/dist/utils/stable-key.d.ts +0 -1
  229. package/dist/utils/theme.d.cts +10 -0
  230. package/dist/utils/theme.d.ts +0 -1
  231. package/dist/validation.d.cts +3 -4
  232. package/dist/validation.d.ts +3 -4
  233. package/docs/SECURITY-DEPENDENCIES.md +129 -1
  234. package/docs/ZOD4-STABLE-MIGRATION-2026-10-26.md +181 -0
  235. package/package.json +8 -7
  236. package/src/adapters/connector.ts +3 -3
@@ -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 '../types';
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 '../types/chat-bus';
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
+ };
@@ -169,4 +169,3 @@ export declare function useServerCapabilities(): {
169
169
  protocolVersion: () => string | null;
170
170
  hasCapability: (key: keyof ServerCapabilities) => boolean;
171
171
  };
172
- //# sourceMappingURL=server-capabilities-store.d.ts.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Test Setup - Global mocks for vitest
3
+ * Sprint Ultimate U.4: SSR Hydration Tests
4
+ */
5
+ export {};
@@ -3,4 +3,3 @@
3
3
  * Sprint Ultimate U.4: SSR Hydration Tests
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=test-setup.d.ts.map
@@ -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;
@@ -4,7 +4,7 @@
4
4
  * @experimental
5
5
  * @since v4.3.9
6
6
  */
7
- import type { ChatBus, ChatPromptConfig, ChatPromptResponse } from '../types/chat-bus';
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