@yourgpt/copilot-sdk 2.0.1 → 2.0.2-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +42 -0
  2. package/dist/{ThreadManager-JT0sqSSD.d.ts → ThreadManager-Dkp_eLty.d.ts} +1 -1
  3. package/dist/{ThreadManager-CUq5Ocu2.d.cts → ThreadManager-LfFRhr4e.d.cts} +1 -1
  4. package/dist/anthropic-6F5GRE3B.js +4 -0
  5. package/dist/anthropic-6F5GRE3B.js.map +1 -0
  6. package/dist/anthropic-DGalr_Fw.d.cts +17 -0
  7. package/dist/anthropic-DkCEDYOt.d.ts +17 -0
  8. package/dist/anthropic-NMTRABEH.cjs +21 -0
  9. package/dist/anthropic-NMTRABEH.cjs.map +1 -0
  10. package/dist/brave-DdnWb7Gb.d.cts +17 -0
  11. package/dist/brave-DsI9n7Wr.d.ts +17 -0
  12. package/dist/brave-OYKCOZEM.cjs +21 -0
  13. package/dist/brave-OYKCOZEM.cjs.map +1 -0
  14. package/dist/brave-XSASGGH2.js +4 -0
  15. package/dist/brave-XSASGGH2.js.map +1 -0
  16. package/dist/chunk-2FAWEBZS.cjs +88 -0
  17. package/dist/chunk-2FAWEBZS.cjs.map +1 -0
  18. package/dist/chunk-53UGJNHN.js +92 -0
  19. package/dist/chunk-53UGJNHN.js.map +1 -0
  20. package/dist/chunk-6T5XXJEP.cjs +80 -0
  21. package/dist/chunk-6T5XXJEP.cjs.map +1 -0
  22. package/dist/chunk-7K7HZMP4.cjs +1170 -0
  23. package/dist/chunk-7K7HZMP4.cjs.map +1 -0
  24. package/dist/chunk-7W7QLZNC.js +72 -0
  25. package/dist/chunk-7W7QLZNC.js.map +1 -0
  26. package/dist/{chunk-JM7PB2LP.js → chunk-7XFFRV7D.js} +10 -66
  27. package/dist/chunk-7XFFRV7D.js.map +1 -0
  28. package/dist/chunk-ASV6JLYG.cjs +99 -0
  29. package/dist/chunk-ASV6JLYG.cjs.map +1 -0
  30. package/dist/chunk-BH7MNDWW.js +1152 -0
  31. package/dist/chunk-BH7MNDWW.js.map +1 -0
  32. package/dist/chunk-BKO7DSPU.js +67 -0
  33. package/dist/chunk-BKO7DSPU.js.map +1 -0
  34. package/dist/chunk-CBAHCI4R.cjs +76 -0
  35. package/dist/chunk-CBAHCI4R.cjs.map +1 -0
  36. package/dist/chunk-CEKAYA2Q.cjs +74 -0
  37. package/dist/chunk-CEKAYA2Q.cjs.map +1 -0
  38. package/dist/chunk-CEOMTQTP.js +85 -0
  39. package/dist/chunk-CEOMTQTP.js.map +1 -0
  40. package/dist/chunk-DABZYCVX.js +84 -0
  41. package/dist/chunk-DABZYCVX.js.map +1 -0
  42. package/dist/chunk-DGUM43GV.js +10 -0
  43. package/dist/chunk-DGUM43GV.js.map +1 -0
  44. package/dist/chunk-G4SF2PNQ.js +33 -0
  45. package/dist/chunk-G4SF2PNQ.js.map +1 -0
  46. package/dist/chunk-GANCV72Z.cjs +110 -0
  47. package/dist/chunk-GANCV72Z.cjs.map +1 -0
  48. package/dist/{chunk-BLSI67J6.cjs → chunk-H5XMKBBA.cjs} +425 -30
  49. package/dist/chunk-H5XMKBBA.cjs.map +1 -0
  50. package/dist/{chunk-CJ7UWN2Y.js → chunk-IXFV6AW6.js} +397 -7
  51. package/dist/chunk-IXFV6AW6.js.map +1 -0
  52. package/dist/chunk-JEQ2X3Z6.cjs +12 -0
  53. package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
  54. package/dist/chunk-JO4BHPAD.cjs +40 -0
  55. package/dist/chunk-JO4BHPAD.cjs.map +1 -0
  56. package/dist/chunk-MEBXW75C.cjs +89 -0
  57. package/dist/chunk-MEBXW75C.cjs.map +1 -0
  58. package/dist/chunk-MNDGIW47.js +76 -0
  59. package/dist/chunk-MNDGIW47.js.map +1 -0
  60. package/dist/chunk-PPFHA6IL.js +83 -0
  61. package/dist/chunk-PPFHA6IL.js.map +1 -0
  62. package/dist/chunk-RQ74USYU.js +128 -0
  63. package/dist/chunk-RQ74USYU.js.map +1 -0
  64. package/dist/chunk-TXLIY7GF.cjs +132 -0
  65. package/dist/chunk-TXLIY7GF.cjs.map +1 -0
  66. package/dist/chunk-UIWFYMAO.cjs +82 -0
  67. package/dist/chunk-UIWFYMAO.cjs.map +1 -0
  68. package/dist/{chunk-4PRWNAXQ.cjs → chunk-UOWLKFXK.cjs} +27 -89
  69. package/dist/chunk-UOWLKFXK.cjs.map +1 -0
  70. package/dist/chunk-VD74IPKB.js +106 -0
  71. package/dist/chunk-VD74IPKB.js.map +1 -0
  72. package/dist/chunk-W73FBYIH.cjs +87 -0
  73. package/dist/chunk-W73FBYIH.cjs.map +1 -0
  74. package/dist/chunk-XGITAEXU.js +93 -0
  75. package/dist/chunk-XGITAEXU.js.map +1 -0
  76. package/dist/chunk-XWOHNY3F.cjs +96 -0
  77. package/dist/chunk-XWOHNY3F.cjs.map +1 -0
  78. package/dist/chunk-ZPYQDMUX.js +79 -0
  79. package/dist/chunk-ZPYQDMUX.js.map +1 -0
  80. package/dist/core/index.cjs +156 -84
  81. package/dist/core/index.d.cts +16 -4
  82. package/dist/core/index.d.ts +16 -4
  83. package/dist/core/index.js +13 -1
  84. package/dist/exa-72KFY5A7.cjs +21 -0
  85. package/dist/exa-72KFY5A7.cjs.map +1 -0
  86. package/dist/exa-Dp9U-WTc.d.ts +17 -0
  87. package/dist/exa-NNVPBC2M.js +4 -0
  88. package/dist/exa-NNVPBC2M.js.map +1 -0
  89. package/dist/exa-jJSPhyUW.d.cts +17 -0
  90. package/dist/google-CHU2yycE.d.cts +17 -0
  91. package/dist/google-CTEK6SV2.js +4 -0
  92. package/dist/google-CTEK6SV2.js.map +1 -0
  93. package/dist/google-Da8IQxaI.d.ts +17 -0
  94. package/dist/google-IIUXFFVF.cjs +21 -0
  95. package/dist/google-IIUXFFVF.cjs.map +1 -0
  96. package/dist/index-2VtgKM8S.d.cts +206 -0
  97. package/dist/index-pWEH7pUE.d.ts +206 -0
  98. package/dist/mcp/index.cjs +670 -0
  99. package/dist/mcp/index.cjs.map +1 -0
  100. package/dist/mcp/index.d.cts +779 -0
  101. package/dist/mcp/index.d.ts +779 -0
  102. package/dist/mcp/index.js +574 -0
  103. package/dist/mcp/index.js.map +1 -0
  104. package/dist/openai-6KTCQ7PZ.cjs +21 -0
  105. package/dist/openai-6KTCQ7PZ.cjs.map +1 -0
  106. package/dist/openai-7W2PCNW5.js +4 -0
  107. package/dist/openai-7W2PCNW5.js.map +1 -0
  108. package/dist/openai-Cam8hF4f.d.ts +17 -0
  109. package/dist/openai-HVSCuXgO.d.cts +17 -0
  110. package/dist/react/index.cjs +75 -42
  111. package/dist/react/index.d.cts +270 -45
  112. package/dist/react/index.d.ts +270 -45
  113. package/dist/react/index.js +15 -2
  114. package/dist/searxng-AXLVGY7Z.js +4 -0
  115. package/dist/searxng-AXLVGY7Z.js.map +1 -0
  116. package/dist/searxng-EJKNY236.cjs +21 -0
  117. package/dist/searxng-EJKNY236.cjs.map +1 -0
  118. package/dist/searxng-K0qtY9vp.d.ts +17 -0
  119. package/dist/searxng-QGOte_Gq.d.cts +17 -0
  120. package/dist/serper-3JYJHJX6.js +4 -0
  121. package/dist/serper-3JYJHJX6.js.map +1 -0
  122. package/dist/serper-63FT4AOL.cjs +21 -0
  123. package/dist/serper-63FT4AOL.cjs.map +1 -0
  124. package/dist/serper-7Czya3PW.d.ts +17 -0
  125. package/dist/serper-JzdaSnS9.d.cts +17 -0
  126. package/dist/styles.css +38 -0
  127. package/dist/tavily-AWFP4RM7.cjs +21 -0
  128. package/dist/tavily-AWFP4RM7.cjs.map +1 -0
  129. package/dist/tavily-C8cXXojE.d.cts +17 -0
  130. package/dist/tavily-CIWAAZPH.js +4 -0
  131. package/dist/tavily-CIWAAZPH.js.map +1 -0
  132. package/dist/tavily-DdSGVgkE.d.ts +17 -0
  133. package/dist/themes/catppuccin.css +2 -0
  134. package/dist/themes/claude.css +2 -0
  135. package/dist/themes/linear.css +2 -0
  136. package/dist/themes/modern-minimal.css +2 -0
  137. package/dist/themes/posthog.css +2 -0
  138. package/dist/themes/supabase.css +2 -0
  139. package/dist/themes/twitter.css +2 -0
  140. package/dist/themes/vercel.css +2 -0
  141. package/dist/tools/anthropic/index.cjs +61 -0
  142. package/dist/tools/anthropic/index.cjs.map +1 -0
  143. package/dist/tools/anthropic/index.d.cts +67 -0
  144. package/dist/tools/anthropic/index.d.ts +67 -0
  145. package/dist/tools/anthropic/index.js +56 -0
  146. package/dist/tools/anthropic/index.js.map +1 -0
  147. package/dist/tools/brave/index.cjs +85 -0
  148. package/dist/tools/brave/index.cjs.map +1 -0
  149. package/dist/tools/brave/index.d.cts +91 -0
  150. package/dist/tools/brave/index.d.ts +91 -0
  151. package/dist/tools/brave/index.js +80 -0
  152. package/dist/tools/brave/index.js.map +1 -0
  153. package/dist/tools/exa/index.cjs +90 -0
  154. package/dist/tools/exa/index.cjs.map +1 -0
  155. package/dist/tools/exa/index.d.cts +92 -0
  156. package/dist/tools/exa/index.d.ts +92 -0
  157. package/dist/tools/exa/index.js +85 -0
  158. package/dist/tools/exa/index.js.map +1 -0
  159. package/dist/tools/google/index.cjs +81 -0
  160. package/dist/tools/google/index.cjs.map +1 -0
  161. package/dist/tools/google/index.d.cts +81 -0
  162. package/dist/tools/google/index.d.ts +81 -0
  163. package/dist/tools/google/index.js +76 -0
  164. package/dist/tools/google/index.js.map +1 -0
  165. package/dist/tools/openai/index.cjs +83 -0
  166. package/dist/tools/openai/index.cjs.map +1 -0
  167. package/dist/tools/openai/index.d.cts +84 -0
  168. package/dist/tools/openai/index.d.ts +84 -0
  169. package/dist/tools/openai/index.js +78 -0
  170. package/dist/tools/openai/index.js.map +1 -0
  171. package/dist/tools/searxng/index.cjs +85 -0
  172. package/dist/tools/searxng/index.cjs.map +1 -0
  173. package/dist/tools/searxng/index.d.cts +91 -0
  174. package/dist/tools/searxng/index.d.ts +91 -0
  175. package/dist/tools/searxng/index.js +80 -0
  176. package/dist/tools/searxng/index.js.map +1 -0
  177. package/dist/tools/serper/index.cjs +85 -0
  178. package/dist/tools/serper/index.cjs.map +1 -0
  179. package/dist/tools/serper/index.d.cts +91 -0
  180. package/dist/tools/serper/index.d.ts +91 -0
  181. package/dist/tools/serper/index.js +80 -0
  182. package/dist/tools/serper/index.js.map +1 -0
  183. package/dist/tools/tavily/index.cjs +91 -0
  184. package/dist/tools/tavily/index.cjs.map +1 -0
  185. package/dist/tools/tavily/index.d.cts +95 -0
  186. package/dist/tools/tavily/index.d.ts +95 -0
  187. package/dist/tools/tavily/index.js +86 -0
  188. package/dist/tools/tavily/index.js.map +1 -0
  189. package/dist/tools/web-search/index.cjs +31 -0
  190. package/dist/tools/web-search/index.cjs.map +1 -0
  191. package/dist/tools/web-search/index.d.cts +3 -0
  192. package/dist/tools/web-search/index.d.ts +3 -0
  193. package/dist/tools/web-search/index.js +14 -0
  194. package/dist/tools/web-search/index.js.map +1 -0
  195. package/dist/{types-BtAaOV07.d.cts → tools-DDWrco4h.d.cts} +43 -367
  196. package/dist/{types-BtAaOV07.d.ts → tools-DDWrco4h.d.ts} +43 -367
  197. package/dist/types-B20VCJXL.d.cts +347 -0
  198. package/dist/types-B20VCJXL.d.ts +347 -0
  199. package/dist/types-Cizh9K_f.d.ts +441 -0
  200. package/dist/types-DG2ya08y.d.cts +367 -0
  201. package/dist/types-DG2ya08y.d.ts +367 -0
  202. package/dist/types-DjSfYNKj.d.cts +441 -0
  203. package/dist/types-ZguuKEs_.d.cts +127 -0
  204. package/dist/types-ZguuKEs_.d.ts +127 -0
  205. package/dist/ui/index.cjs +1075 -148
  206. package/dist/ui/index.cjs.map +1 -1
  207. package/dist/ui/index.d.cts +410 -4
  208. package/dist/ui/index.d.ts +410 -4
  209. package/dist/ui/index.js +1007 -96
  210. package/dist/ui/index.js.map +1 -1
  211. package/package.json +52 -2
  212. package/dist/chunk-4PRWNAXQ.cjs.map +0 -1
  213. package/dist/chunk-BLSI67J6.cjs.map +0 -1
  214. package/dist/chunk-CJ7UWN2Y.js.map +0 -1
  215. package/dist/chunk-JM7PB2LP.js.map +0 -1
@@ -0,0 +1,347 @@
1
+ /**
2
+ * MCP-UI Type Definitions
3
+ *
4
+ * This module defines types for MCP-UI support, enabling MCP tools
5
+ * to return interactive UI components (forms, charts, product selectors, etc.)
6
+ * that render directly in the chat interface.
7
+ *
8
+ * @see https://github.com/idosal/mcp-ui
9
+ * @see https://shopify.engineering/mcp-ui-breaking-the-text-wall
10
+ */
11
+ /**
12
+ * MCP UI Resource MIME types
13
+ *
14
+ * - `text/html`: Inline HTML content rendered in iframe
15
+ * - `text/uri-list`: External URL to load in iframe
16
+ * - `application/vnd.mcp-ui.remote-dom`: Remote DOM rendering (advanced)
17
+ */
18
+ type MCPUIResourceMimeType = "text/html" | "text/uri-list" | "application/vnd.mcp-ui.remote-dom";
19
+ /**
20
+ * MCP UI Resource metadata
21
+ *
22
+ * Optional configuration for how the UI should be displayed.
23
+ */
24
+ interface MCPUIResourceMetadata {
25
+ /** Title shown above the UI component */
26
+ title?: string;
27
+ /** Width of the iframe (e.g., "100%", "400px") */
28
+ width?: string;
29
+ /** Height of the iframe (e.g., "200px", "auto") */
30
+ height?: string;
31
+ /**
32
+ * Custom iframe sandbox permissions
33
+ * @default ["allow-scripts", "allow-forms"]
34
+ */
35
+ sandbox?: string[];
36
+ /** Additional CSS classes for styling */
37
+ className?: string;
38
+ }
39
+ /**
40
+ * MCP UI Resource
41
+ *
42
+ * Represents a UI component returned by an MCP tool.
43
+ * Can be inline HTML, an external URL, or Remote DOM content.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * // Inline HTML
48
+ * const resource: MCPUIResource = {
49
+ * uri: "ui://shop/product/123",
50
+ * mimeType: "text/html",
51
+ * content: "<div class='product-card'>...</div>",
52
+ * metadata: { height: "300px" }
53
+ * };
54
+ *
55
+ * // External URL
56
+ * const urlResource: MCPUIResource = {
57
+ * uri: "ui://dashboard/chart",
58
+ * mimeType: "text/uri-list",
59
+ * content: "https://charts.example.com/embed/abc123",
60
+ * metadata: { height: "400px", title: "Sales Chart" }
61
+ * };
62
+ * ```
63
+ */
64
+ interface MCPUIResource {
65
+ /** Unique URI identifying this UI resource (e.g., ui://server/resource-id) */
66
+ uri: string;
67
+ /** MIME type determining how to render the content */
68
+ mimeType: MCPUIResourceMimeType;
69
+ /** Content: inline HTML for text/html, URL for text/uri-list */
70
+ content?: string;
71
+ /** Base64-encoded content (alternative to content) */
72
+ blob?: string;
73
+ /** Display configuration */
74
+ metadata?: MCPUIResourceMetadata;
75
+ }
76
+ /**
77
+ * MCP UI Resource content type for tool results
78
+ *
79
+ * This is the content array item format returned by MCP tools.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * // MCP tool returning UI
84
+ * return {
85
+ * content: [
86
+ * { type: "text", text: "Here's the product:" },
87
+ * {
88
+ * type: "ui",
89
+ * resource: {
90
+ * uri: "ui://shop/product/123",
91
+ * mimeType: "text/html",
92
+ * content: "<div>...</div>"
93
+ * }
94
+ * }
95
+ * ]
96
+ * };
97
+ * ```
98
+ */
99
+ interface MCPUIResourceContent {
100
+ type: "ui";
101
+ resource: MCPUIResource;
102
+ }
103
+ /**
104
+ * Tool intent - Request to call another MCP tool
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Button click triggers tool call
109
+ * window.parent.postMessage({
110
+ * type: "tool",
111
+ * name: "add_to_cart",
112
+ * arguments: { productId: "123", quantity: 1 }
113
+ * }, "*");
114
+ * ```
115
+ */
116
+ interface MCPUIToolIntent {
117
+ type: "tool";
118
+ /** Name of the tool to call */
119
+ name: string;
120
+ /** Arguments to pass to the tool */
121
+ arguments?: Record<string, unknown>;
122
+ }
123
+ /**
124
+ * Action intent - Semantic action for the agent to interpret
125
+ *
126
+ * Unlike tool intents, these don't directly call tools but let the
127
+ * AI agent decide how to handle the action.
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * // User selects a product variant
132
+ * window.parent.postMessage({
133
+ * type: "intent",
134
+ * action: "select_variant",
135
+ * data: { variantId: "blue-xl", productId: "123" }
136
+ * }, "*");
137
+ * ```
138
+ */
139
+ interface MCPUIActionIntent {
140
+ type: "intent";
141
+ /** Semantic action name */
142
+ action: string;
143
+ /** Action data */
144
+ data?: Record<string, unknown>;
145
+ }
146
+ /**
147
+ * Prompt intent - Add text to the chat input
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * // "Ask about this" button
152
+ * window.parent.postMessage({
153
+ * type: "prompt",
154
+ * text: "Tell me more about product X"
155
+ * }, "*");
156
+ * ```
157
+ */
158
+ interface MCPUIPromptIntent {
159
+ type: "prompt";
160
+ /** Text to add to chat input */
161
+ text: string;
162
+ }
163
+ /**
164
+ * Notify intent - Show a notification/toast
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * // Show success message
169
+ * window.parent.postMessage({
170
+ * type: "notify",
171
+ * message: "Added to cart!",
172
+ * level: "success"
173
+ * }, "*");
174
+ * ```
175
+ */
176
+ interface MCPUINotifyIntent {
177
+ type: "notify";
178
+ /** Notification message */
179
+ message: string;
180
+ /** Notification level */
181
+ level?: "info" | "success" | "warning" | "error";
182
+ }
183
+ /**
184
+ * Link intent - Open a URL (with user consent)
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * // "View full details" button
189
+ * window.parent.postMessage({
190
+ * type: "link",
191
+ * url: "https://shop.example.com/product/123"
192
+ * }, "*");
193
+ * ```
194
+ */
195
+ interface MCPUILinkIntent {
196
+ type: "link";
197
+ /** URL to open */
198
+ url: string;
199
+ /** Open in new tab (default: true) */
200
+ newTab?: boolean;
201
+ }
202
+ /**
203
+ * Union of all MCP-UI intent types
204
+ *
205
+ * These are messages sent from the UI iframe to the host application
206
+ * via postMessage.
207
+ */
208
+ type MCPUIIntent = MCPUIToolIntent | MCPUIActionIntent | MCPUIPromptIntent | MCPUINotifyIntent | MCPUILinkIntent;
209
+ /**
210
+ * Message envelope for postMessage communication
211
+ *
212
+ * All messages from UI iframes should include a source identifier
213
+ * for validation.
214
+ */
215
+ interface MCPUIMessage {
216
+ /** Source identifier for validation */
217
+ source?: "mcp-ui";
218
+ /** The intent payload */
219
+ intent: MCPUIIntent;
220
+ }
221
+ /**
222
+ * Intent handler callback signature
223
+ */
224
+ type MCPUIIntentHandler<T extends MCPUIIntent = MCPUIIntent> = (intent: T, context?: MCPUIIntentContext) => void | Promise<void>;
225
+ /**
226
+ * Context passed to intent handlers
227
+ */
228
+ interface MCPUIIntentContext {
229
+ /** Source tool name that rendered the UI */
230
+ toolName?: string;
231
+ /** Tool call ID */
232
+ toolCallId?: string;
233
+ /** Original UI resource */
234
+ resource?: MCPUIResource;
235
+ }
236
+ /**
237
+ * Configuration for useMCPUIIntents hook
238
+ */
239
+ interface UseMCPUIIntentsConfig {
240
+ /**
241
+ * Handler for tool intents - call another MCP tool
242
+ */
243
+ onToolCall?: (name: string, args?: Record<string, unknown>, context?: MCPUIIntentContext) => void | Promise<void>;
244
+ /**
245
+ * Handler for action intents - semantic actions for agent interpretation
246
+ */
247
+ onIntent?: (action: string, data?: Record<string, unknown>, context?: MCPUIIntentContext) => void | Promise<void>;
248
+ /**
249
+ * Handler for prompt intents - add text to chat input
250
+ */
251
+ onPrompt?: (text: string, context?: MCPUIIntentContext) => void;
252
+ /**
253
+ * Handler for notify intents - show notifications
254
+ */
255
+ onNotify?: (message: string, level?: "info" | "success" | "warning" | "error", context?: MCPUIIntentContext) => void;
256
+ /**
257
+ * Handler for link intents - open URLs
258
+ * Return false to prevent default behavior
259
+ */
260
+ onLink?: (url: string, newTab?: boolean, context?: MCPUIIntentContext) => boolean | void;
261
+ /**
262
+ * Whether to require user consent for sensitive intents
263
+ * @default true for "tool" and "link" intents
264
+ */
265
+ requireConsent?: {
266
+ tool?: boolean;
267
+ link?: boolean;
268
+ };
269
+ }
270
+ /**
271
+ * Return type for useMCPUIIntents hook
272
+ */
273
+ interface UseMCPUIIntentsReturn {
274
+ /**
275
+ * Handle an intent from a UI component
276
+ * This should be passed to MCPUIFrame's onIntent prop
277
+ */
278
+ handleIntent: (intent: MCPUIIntent, context?: MCPUIIntentContext) => void | Promise<void>;
279
+ }
280
+ /**
281
+ * Props for MCPUIFrame component
282
+ */
283
+ interface MCPUIFrameProps {
284
+ /** UI resource to render */
285
+ resource: MCPUIResource;
286
+ /**
287
+ * Callback when UI emits an intent
288
+ * @param intent The intent from the UI
289
+ */
290
+ onIntent?: (intent: MCPUIIntent) => void;
291
+ /**
292
+ * Callback when an error occurs
293
+ * @param error The error
294
+ */
295
+ onError?: (error: Error) => void;
296
+ /**
297
+ * Callback when iframe loads
298
+ */
299
+ onLoad?: () => void;
300
+ /** Additional CSS class names */
301
+ className?: string;
302
+ /** Inline styles */
303
+ style?: React.CSSProperties;
304
+ /**
305
+ * Override default sandbox permissions
306
+ * @default "allow-scripts allow-forms"
307
+ */
308
+ sandbox?: string;
309
+ /**
310
+ * Whether to show a loading state while iframe loads
311
+ * @default true
312
+ */
313
+ showLoading?: boolean;
314
+ /**
315
+ * Test ID for testing
316
+ */
317
+ testId?: string;
318
+ }
319
+ /**
320
+ * Type guard for MCPUIResourceContent
321
+ */
322
+ declare function isMCPUIResourceContent(content: unknown): content is MCPUIResourceContent;
323
+ /**
324
+ * Type guard for MCPUIIntent
325
+ */
326
+ declare function isMCPUIIntent(data: unknown): data is MCPUIIntent;
327
+ /**
328
+ * Type guard for MCPUIMessage (postMessage envelope)
329
+ */
330
+ declare function isMCPUIMessage(data: unknown): data is MCPUIMessage;
331
+ /**
332
+ * Parse a postMessage event data to MCPUIIntent
333
+ * Returns null if the data is not a valid MCP-UI message
334
+ */
335
+ declare function parseMCPUIMessage(data: unknown): MCPUIIntent | null;
336
+ /**
337
+ * Default iframe sandbox permissions
338
+ * Provides a secure default that allows interactivity
339
+ */
340
+ declare const DEFAULT_MCP_UI_SANDBOX = "allow-scripts allow-forms";
341
+ /**
342
+ * Restricted sandbox for untrusted content
343
+ * More secure but limits functionality
344
+ */
345
+ declare const RESTRICTED_MCP_UI_SANDBOX = "allow-scripts";
346
+
347
+ export { DEFAULT_MCP_UI_SANDBOX as D, type MCPUIResource as M, RESTRICTED_MCP_UI_SANDBOX as R, type UseMCPUIIntentsConfig as U, type MCPUIResourceContent as a, type MCPUIResourceMimeType as b, type MCPUIResourceMetadata as c, type MCPUIIntent as d, type MCPUIToolIntent as e, type MCPUIActionIntent as f, type MCPUIPromptIntent as g, type MCPUINotifyIntent as h, type MCPUILinkIntent as i, type MCPUIMessage as j, type MCPUIIntentHandler as k, type MCPUIIntentContext as l, type UseMCPUIIntentsReturn as m, type MCPUIFrameProps as n, isMCPUIResourceContent as o, isMCPUIIntent as p, isMCPUIMessage as q, parseMCPUIMessage as r };
@@ -0,0 +1,347 @@
1
+ /**
2
+ * MCP-UI Type Definitions
3
+ *
4
+ * This module defines types for MCP-UI support, enabling MCP tools
5
+ * to return interactive UI components (forms, charts, product selectors, etc.)
6
+ * that render directly in the chat interface.
7
+ *
8
+ * @see https://github.com/idosal/mcp-ui
9
+ * @see https://shopify.engineering/mcp-ui-breaking-the-text-wall
10
+ */
11
+ /**
12
+ * MCP UI Resource MIME types
13
+ *
14
+ * - `text/html`: Inline HTML content rendered in iframe
15
+ * - `text/uri-list`: External URL to load in iframe
16
+ * - `application/vnd.mcp-ui.remote-dom`: Remote DOM rendering (advanced)
17
+ */
18
+ type MCPUIResourceMimeType = "text/html" | "text/uri-list" | "application/vnd.mcp-ui.remote-dom";
19
+ /**
20
+ * MCP UI Resource metadata
21
+ *
22
+ * Optional configuration for how the UI should be displayed.
23
+ */
24
+ interface MCPUIResourceMetadata {
25
+ /** Title shown above the UI component */
26
+ title?: string;
27
+ /** Width of the iframe (e.g., "100%", "400px") */
28
+ width?: string;
29
+ /** Height of the iframe (e.g., "200px", "auto") */
30
+ height?: string;
31
+ /**
32
+ * Custom iframe sandbox permissions
33
+ * @default ["allow-scripts", "allow-forms"]
34
+ */
35
+ sandbox?: string[];
36
+ /** Additional CSS classes for styling */
37
+ className?: string;
38
+ }
39
+ /**
40
+ * MCP UI Resource
41
+ *
42
+ * Represents a UI component returned by an MCP tool.
43
+ * Can be inline HTML, an external URL, or Remote DOM content.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * // Inline HTML
48
+ * const resource: MCPUIResource = {
49
+ * uri: "ui://shop/product/123",
50
+ * mimeType: "text/html",
51
+ * content: "<div class='product-card'>...</div>",
52
+ * metadata: { height: "300px" }
53
+ * };
54
+ *
55
+ * // External URL
56
+ * const urlResource: MCPUIResource = {
57
+ * uri: "ui://dashboard/chart",
58
+ * mimeType: "text/uri-list",
59
+ * content: "https://charts.example.com/embed/abc123",
60
+ * metadata: { height: "400px", title: "Sales Chart" }
61
+ * };
62
+ * ```
63
+ */
64
+ interface MCPUIResource {
65
+ /** Unique URI identifying this UI resource (e.g., ui://server/resource-id) */
66
+ uri: string;
67
+ /** MIME type determining how to render the content */
68
+ mimeType: MCPUIResourceMimeType;
69
+ /** Content: inline HTML for text/html, URL for text/uri-list */
70
+ content?: string;
71
+ /** Base64-encoded content (alternative to content) */
72
+ blob?: string;
73
+ /** Display configuration */
74
+ metadata?: MCPUIResourceMetadata;
75
+ }
76
+ /**
77
+ * MCP UI Resource content type for tool results
78
+ *
79
+ * This is the content array item format returned by MCP tools.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * // MCP tool returning UI
84
+ * return {
85
+ * content: [
86
+ * { type: "text", text: "Here's the product:" },
87
+ * {
88
+ * type: "ui",
89
+ * resource: {
90
+ * uri: "ui://shop/product/123",
91
+ * mimeType: "text/html",
92
+ * content: "<div>...</div>"
93
+ * }
94
+ * }
95
+ * ]
96
+ * };
97
+ * ```
98
+ */
99
+ interface MCPUIResourceContent {
100
+ type: "ui";
101
+ resource: MCPUIResource;
102
+ }
103
+ /**
104
+ * Tool intent - Request to call another MCP tool
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Button click triggers tool call
109
+ * window.parent.postMessage({
110
+ * type: "tool",
111
+ * name: "add_to_cart",
112
+ * arguments: { productId: "123", quantity: 1 }
113
+ * }, "*");
114
+ * ```
115
+ */
116
+ interface MCPUIToolIntent {
117
+ type: "tool";
118
+ /** Name of the tool to call */
119
+ name: string;
120
+ /** Arguments to pass to the tool */
121
+ arguments?: Record<string, unknown>;
122
+ }
123
+ /**
124
+ * Action intent - Semantic action for the agent to interpret
125
+ *
126
+ * Unlike tool intents, these don't directly call tools but let the
127
+ * AI agent decide how to handle the action.
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * // User selects a product variant
132
+ * window.parent.postMessage({
133
+ * type: "intent",
134
+ * action: "select_variant",
135
+ * data: { variantId: "blue-xl", productId: "123" }
136
+ * }, "*");
137
+ * ```
138
+ */
139
+ interface MCPUIActionIntent {
140
+ type: "intent";
141
+ /** Semantic action name */
142
+ action: string;
143
+ /** Action data */
144
+ data?: Record<string, unknown>;
145
+ }
146
+ /**
147
+ * Prompt intent - Add text to the chat input
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * // "Ask about this" button
152
+ * window.parent.postMessage({
153
+ * type: "prompt",
154
+ * text: "Tell me more about product X"
155
+ * }, "*");
156
+ * ```
157
+ */
158
+ interface MCPUIPromptIntent {
159
+ type: "prompt";
160
+ /** Text to add to chat input */
161
+ text: string;
162
+ }
163
+ /**
164
+ * Notify intent - Show a notification/toast
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * // Show success message
169
+ * window.parent.postMessage({
170
+ * type: "notify",
171
+ * message: "Added to cart!",
172
+ * level: "success"
173
+ * }, "*");
174
+ * ```
175
+ */
176
+ interface MCPUINotifyIntent {
177
+ type: "notify";
178
+ /** Notification message */
179
+ message: string;
180
+ /** Notification level */
181
+ level?: "info" | "success" | "warning" | "error";
182
+ }
183
+ /**
184
+ * Link intent - Open a URL (with user consent)
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * // "View full details" button
189
+ * window.parent.postMessage({
190
+ * type: "link",
191
+ * url: "https://shop.example.com/product/123"
192
+ * }, "*");
193
+ * ```
194
+ */
195
+ interface MCPUILinkIntent {
196
+ type: "link";
197
+ /** URL to open */
198
+ url: string;
199
+ /** Open in new tab (default: true) */
200
+ newTab?: boolean;
201
+ }
202
+ /**
203
+ * Union of all MCP-UI intent types
204
+ *
205
+ * These are messages sent from the UI iframe to the host application
206
+ * via postMessage.
207
+ */
208
+ type MCPUIIntent = MCPUIToolIntent | MCPUIActionIntent | MCPUIPromptIntent | MCPUINotifyIntent | MCPUILinkIntent;
209
+ /**
210
+ * Message envelope for postMessage communication
211
+ *
212
+ * All messages from UI iframes should include a source identifier
213
+ * for validation.
214
+ */
215
+ interface MCPUIMessage {
216
+ /** Source identifier for validation */
217
+ source?: "mcp-ui";
218
+ /** The intent payload */
219
+ intent: MCPUIIntent;
220
+ }
221
+ /**
222
+ * Intent handler callback signature
223
+ */
224
+ type MCPUIIntentHandler<T extends MCPUIIntent = MCPUIIntent> = (intent: T, context?: MCPUIIntentContext) => void | Promise<void>;
225
+ /**
226
+ * Context passed to intent handlers
227
+ */
228
+ interface MCPUIIntentContext {
229
+ /** Source tool name that rendered the UI */
230
+ toolName?: string;
231
+ /** Tool call ID */
232
+ toolCallId?: string;
233
+ /** Original UI resource */
234
+ resource?: MCPUIResource;
235
+ }
236
+ /**
237
+ * Configuration for useMCPUIIntents hook
238
+ */
239
+ interface UseMCPUIIntentsConfig {
240
+ /**
241
+ * Handler for tool intents - call another MCP tool
242
+ */
243
+ onToolCall?: (name: string, args?: Record<string, unknown>, context?: MCPUIIntentContext) => void | Promise<void>;
244
+ /**
245
+ * Handler for action intents - semantic actions for agent interpretation
246
+ */
247
+ onIntent?: (action: string, data?: Record<string, unknown>, context?: MCPUIIntentContext) => void | Promise<void>;
248
+ /**
249
+ * Handler for prompt intents - add text to chat input
250
+ */
251
+ onPrompt?: (text: string, context?: MCPUIIntentContext) => void;
252
+ /**
253
+ * Handler for notify intents - show notifications
254
+ */
255
+ onNotify?: (message: string, level?: "info" | "success" | "warning" | "error", context?: MCPUIIntentContext) => void;
256
+ /**
257
+ * Handler for link intents - open URLs
258
+ * Return false to prevent default behavior
259
+ */
260
+ onLink?: (url: string, newTab?: boolean, context?: MCPUIIntentContext) => boolean | void;
261
+ /**
262
+ * Whether to require user consent for sensitive intents
263
+ * @default true for "tool" and "link" intents
264
+ */
265
+ requireConsent?: {
266
+ tool?: boolean;
267
+ link?: boolean;
268
+ };
269
+ }
270
+ /**
271
+ * Return type for useMCPUIIntents hook
272
+ */
273
+ interface UseMCPUIIntentsReturn {
274
+ /**
275
+ * Handle an intent from a UI component
276
+ * This should be passed to MCPUIFrame's onIntent prop
277
+ */
278
+ handleIntent: (intent: MCPUIIntent, context?: MCPUIIntentContext) => void | Promise<void>;
279
+ }
280
+ /**
281
+ * Props for MCPUIFrame component
282
+ */
283
+ interface MCPUIFrameProps {
284
+ /** UI resource to render */
285
+ resource: MCPUIResource;
286
+ /**
287
+ * Callback when UI emits an intent
288
+ * @param intent The intent from the UI
289
+ */
290
+ onIntent?: (intent: MCPUIIntent) => void;
291
+ /**
292
+ * Callback when an error occurs
293
+ * @param error The error
294
+ */
295
+ onError?: (error: Error) => void;
296
+ /**
297
+ * Callback when iframe loads
298
+ */
299
+ onLoad?: () => void;
300
+ /** Additional CSS class names */
301
+ className?: string;
302
+ /** Inline styles */
303
+ style?: React.CSSProperties;
304
+ /**
305
+ * Override default sandbox permissions
306
+ * @default "allow-scripts allow-forms"
307
+ */
308
+ sandbox?: string;
309
+ /**
310
+ * Whether to show a loading state while iframe loads
311
+ * @default true
312
+ */
313
+ showLoading?: boolean;
314
+ /**
315
+ * Test ID for testing
316
+ */
317
+ testId?: string;
318
+ }
319
+ /**
320
+ * Type guard for MCPUIResourceContent
321
+ */
322
+ declare function isMCPUIResourceContent(content: unknown): content is MCPUIResourceContent;
323
+ /**
324
+ * Type guard for MCPUIIntent
325
+ */
326
+ declare function isMCPUIIntent(data: unknown): data is MCPUIIntent;
327
+ /**
328
+ * Type guard for MCPUIMessage (postMessage envelope)
329
+ */
330
+ declare function isMCPUIMessage(data: unknown): data is MCPUIMessage;
331
+ /**
332
+ * Parse a postMessage event data to MCPUIIntent
333
+ * Returns null if the data is not a valid MCP-UI message
334
+ */
335
+ declare function parseMCPUIMessage(data: unknown): MCPUIIntent | null;
336
+ /**
337
+ * Default iframe sandbox permissions
338
+ * Provides a secure default that allows interactivity
339
+ */
340
+ declare const DEFAULT_MCP_UI_SANDBOX = "allow-scripts allow-forms";
341
+ /**
342
+ * Restricted sandbox for untrusted content
343
+ * More secure but limits functionality
344
+ */
345
+ declare const RESTRICTED_MCP_UI_SANDBOX = "allow-scripts";
346
+
347
+ export { DEFAULT_MCP_UI_SANDBOX as D, type MCPUIResource as M, RESTRICTED_MCP_UI_SANDBOX as R, type UseMCPUIIntentsConfig as U, type MCPUIResourceContent as a, type MCPUIResourceMimeType as b, type MCPUIResourceMetadata as c, type MCPUIIntent as d, type MCPUIToolIntent as e, type MCPUIActionIntent as f, type MCPUIPromptIntent as g, type MCPUINotifyIntent as h, type MCPUILinkIntent as i, type MCPUIMessage as j, type MCPUIIntentHandler as k, type MCPUIIntentContext as l, type UseMCPUIIntentsReturn as m, type MCPUIFrameProps as n, isMCPUIResourceContent as o, isMCPUIIntent as p, isMCPUIMessage as q, parseMCPUIMessage as r };