@frontmcp/uipack 0.12.2 → 1.0.0-beta.10

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 (298) hide show
  1. package/CLAUDE.md +56 -154
  2. package/README.md +367 -62
  3. package/adapters/base-template.d.ts +30 -0
  4. package/adapters/base-template.d.ts.map +1 -0
  5. package/adapters/cdn-info.d.ts +34 -0
  6. package/adapters/cdn-info.d.ts.map +1 -0
  7. package/adapters/constants.d.ts +18 -0
  8. package/adapters/constants.d.ts.map +1 -0
  9. package/adapters/content-detector.d.ts +19 -0
  10. package/adapters/content-detector.d.ts.map +1 -0
  11. package/adapters/content-renderers.d.ts +27 -0
  12. package/adapters/content-renderers.d.ts.map +1 -0
  13. package/adapters/index.d.ts +14 -7
  14. package/adapters/index.d.ts.map +1 -1
  15. package/adapters/index.js +2343 -426
  16. package/adapters/render-failure.d.ts +18 -0
  17. package/adapters/render-failure.d.ts.map +1 -0
  18. package/adapters/response-builder.d.ts +34 -104
  19. package/adapters/response-builder.d.ts.map +1 -1
  20. package/adapters/serving-mode.d.ts +28 -91
  21. package/adapters/serving-mode.d.ts.map +1 -1
  22. package/adapters/template-renderer.d.ts +50 -0
  23. package/adapters/template-renderer.d.ts.map +1 -0
  24. package/adapters/type-detector.d.ts +18 -0
  25. package/adapters/type-detector.d.ts.map +1 -0
  26. package/bridge-runtime/index.js +1 -1
  27. package/component/index.d.ts +14 -0
  28. package/component/index.d.ts.map +1 -0
  29. package/component/index.js +2043 -0
  30. package/component/loader.d.ts +36 -0
  31. package/component/loader.d.ts.map +1 -0
  32. package/component/renderer.d.ts +30 -0
  33. package/component/renderer.d.ts.map +1 -0
  34. package/component/transpiler.d.ts +49 -0
  35. package/component/transpiler.d.ts.map +1 -0
  36. package/component/types.d.ts +82 -0
  37. package/component/types.d.ts.map +1 -0
  38. package/esm/adapters/index.mjs +2337 -422
  39. package/esm/bridge-runtime/index.mjs +1 -1
  40. package/esm/component/index.mjs +2013 -0
  41. package/esm/index.mjs +3446 -13935
  42. package/esm/package.json +4 -13
  43. package/esm/resolver/index.mjs +661 -0
  44. package/esm/shell/index.mjs +1406 -0
  45. package/esm/types/index.mjs +11 -11
  46. package/esm/utils/index.mjs +53 -8
  47. package/index.d.ts +12 -40
  48. package/index.d.ts.map +1 -1
  49. package/index.js +3579 -14218
  50. package/package.json +4 -13
  51. package/resolver/cdn-registry.d.ts +39 -0
  52. package/resolver/cdn-registry.d.ts.map +1 -0
  53. package/resolver/esm-sh.resolver.d.ts +54 -0
  54. package/resolver/esm-sh.resolver.d.ts.map +1 -0
  55. package/resolver/import-map.d.ts +47 -0
  56. package/resolver/import-map.d.ts.map +1 -0
  57. package/resolver/import-parser.d.ts +28 -0
  58. package/resolver/import-parser.d.ts.map +1 -0
  59. package/resolver/import-rewriter.d.ts +29 -0
  60. package/resolver/import-rewriter.d.ts.map +1 -0
  61. package/resolver/index.d.ts +15 -0
  62. package/resolver/index.d.ts.map +1 -0
  63. package/resolver/index.js +708 -0
  64. package/resolver/types.d.ts +191 -0
  65. package/resolver/types.d.ts.map +1 -0
  66. package/shell/builder.d.ts +31 -0
  67. package/shell/builder.d.ts.map +1 -0
  68. package/shell/csp.d.ts +37 -0
  69. package/shell/csp.d.ts.map +1 -0
  70. package/shell/custom-shell-applier.d.ts +33 -0
  71. package/shell/custom-shell-applier.d.ts.map +1 -0
  72. package/shell/custom-shell-resolver.d.ts +47 -0
  73. package/shell/custom-shell-resolver.d.ts.map +1 -0
  74. package/shell/custom-shell-types.d.ts +75 -0
  75. package/shell/custom-shell-types.d.ts.map +1 -0
  76. package/shell/custom-shell-validator.d.ts +26 -0
  77. package/shell/custom-shell-validator.d.ts.map +1 -0
  78. package/shell/data-injector.d.ts +40 -0
  79. package/shell/data-injector.d.ts.map +1 -0
  80. package/shell/index.d.ts +19 -0
  81. package/shell/index.d.ts.map +1 -0
  82. package/shell/index.js +1453 -0
  83. package/shell/types.d.ts +54 -0
  84. package/shell/types.d.ts.map +1 -0
  85. package/types/index.d.ts +1 -3
  86. package/types/index.d.ts.map +1 -1
  87. package/types/index.js +11 -11
  88. package/types/ui-config.d.ts +50 -11
  89. package/types/ui-config.d.ts.map +1 -1
  90. package/types/ui-runtime.d.ts +8 -82
  91. package/types/ui-runtime.d.ts.map +1 -1
  92. package/utils/index.d.ts +9 -3
  93. package/utils/index.d.ts.map +1 -1
  94. package/utils/index.js +59 -7
  95. package/adapters/platform-meta.constants.d.ts +0 -26
  96. package/adapters/platform-meta.constants.d.ts.map +0 -1
  97. package/adapters/platform-meta.d.ts +0 -234
  98. package/adapters/platform-meta.d.ts.map +0 -1
  99. package/base-template/bridge.d.ts +0 -90
  100. package/base-template/bridge.d.ts.map +0 -1
  101. package/base-template/default-base-template.d.ts +0 -91
  102. package/base-template/default-base-template.d.ts.map +0 -1
  103. package/base-template/index.d.ts +0 -15
  104. package/base-template/index.d.ts.map +0 -1
  105. package/base-template/index.js +0 -1393
  106. package/base-template/polyfills.d.ts +0 -31
  107. package/base-template/polyfills.d.ts.map +0 -1
  108. package/base-template/theme-styles.d.ts +0 -74
  109. package/base-template/theme-styles.d.ts.map +0 -1
  110. package/build/builders/base-builder.d.ts +0 -124
  111. package/build/builders/base-builder.d.ts.map +0 -1
  112. package/build/builders/esbuild-config.d.ts +0 -94
  113. package/build/builders/esbuild-config.d.ts.map +0 -1
  114. package/build/builders/hybrid-builder.d.ts +0 -93
  115. package/build/builders/hybrid-builder.d.ts.map +0 -1
  116. package/build/builders/index.d.ts +0 -17
  117. package/build/builders/index.d.ts.map +0 -1
  118. package/build/builders/inline-builder.d.ts +0 -83
  119. package/build/builders/inline-builder.d.ts.map +0 -1
  120. package/build/builders/static-builder.d.ts +0 -78
  121. package/build/builders/static-builder.d.ts.map +0 -1
  122. package/build/builders/types.d.ts +0 -341
  123. package/build/builders/types.d.ts.map +0 -1
  124. package/build/cdn-resources.d.ts +0 -244
  125. package/build/cdn-resources.d.ts.map +0 -1
  126. package/build/hybrid-data.d.ts +0 -127
  127. package/build/hybrid-data.d.ts.map +0 -1
  128. package/build/index.d.ts +0 -299
  129. package/build/index.d.ts.map +0 -1
  130. package/build/index.js +0 -8699
  131. package/build/ui-components-browser.d.ts +0 -64
  132. package/build/ui-components-browser.d.ts.map +0 -1
  133. package/build/widget-manifest.d.ts +0 -362
  134. package/build/widget-manifest.d.ts.map +0 -1
  135. package/bundler/cache.d.ts +0 -173
  136. package/bundler/cache.d.ts.map +0 -1
  137. package/bundler/file-cache/component-builder.d.ts +0 -167
  138. package/bundler/file-cache/component-builder.d.ts.map +0 -1
  139. package/bundler/file-cache/hash-calculator.d.ts +0 -155
  140. package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  141. package/bundler/file-cache/index.d.ts +0 -12
  142. package/bundler/file-cache/index.d.ts.map +0 -1
  143. package/bundler/file-cache/storage/filesystem.d.ts +0 -149
  144. package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  145. package/bundler/file-cache/storage/index.d.ts +0 -11
  146. package/bundler/file-cache/storage/index.d.ts.map +0 -1
  147. package/bundler/file-cache/storage/interface.d.ts +0 -152
  148. package/bundler/file-cache/storage/interface.d.ts.map +0 -1
  149. package/bundler/file-cache/storage/redis.d.ts +0 -139
  150. package/bundler/file-cache/storage/redis.d.ts.map +0 -1
  151. package/bundler/index.d.ts +0 -35
  152. package/bundler/index.d.ts.map +0 -1
  153. package/bundler/index.js +0 -2953
  154. package/bundler/sandbox/enclave-adapter.d.ts +0 -121
  155. package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  156. package/bundler/sandbox/executor.d.ts +0 -14
  157. package/bundler/sandbox/executor.d.ts.map +0 -1
  158. package/bundler/sandbox/policy.d.ts +0 -62
  159. package/bundler/sandbox/policy.d.ts.map +0 -1
  160. package/bundler/types.d.ts +0 -702
  161. package/bundler/types.d.ts.map +0 -1
  162. package/dependency/cdn-registry.d.ts +0 -98
  163. package/dependency/cdn-registry.d.ts.map +0 -1
  164. package/dependency/import-map.d.ts +0 -186
  165. package/dependency/import-map.d.ts.map +0 -1
  166. package/dependency/import-parser.d.ts +0 -82
  167. package/dependency/import-parser.d.ts.map +0 -1
  168. package/dependency/index.d.ts +0 -17
  169. package/dependency/index.d.ts.map +0 -1
  170. package/dependency/index.js +0 -3180
  171. package/dependency/resolver.d.ts +0 -164
  172. package/dependency/resolver.d.ts.map +0 -1
  173. package/dependency/schemas.d.ts +0 -486
  174. package/dependency/schemas.d.ts.map +0 -1
  175. package/dependency/template-loader.d.ts +0 -204
  176. package/dependency/template-loader.d.ts.map +0 -1
  177. package/dependency/template-processor.d.ts +0 -118
  178. package/dependency/template-processor.d.ts.map +0 -1
  179. package/dependency/types.d.ts +0 -739
  180. package/dependency/types.d.ts.map +0 -1
  181. package/esm/base-template/index.mjs +0 -1359
  182. package/esm/build/index.mjs +0 -8601
  183. package/esm/bundler/index.mjs +0 -2895
  184. package/esm/dependency/index.mjs +0 -3068
  185. package/esm/handlebars/index.mjs +0 -587
  186. package/esm/registry/index.mjs +0 -6305
  187. package/esm/renderers/index.mjs +0 -1557
  188. package/esm/runtime/index.mjs +0 -5361
  189. package/esm/styles/index.mjs +0 -171
  190. package/esm/theme/index.mjs +0 -756
  191. package/esm/tool-template/index.mjs +0 -3652
  192. package/esm/validation/index.mjs +0 -542
  193. package/handlebars/expression-extractor.d.ts +0 -147
  194. package/handlebars/expression-extractor.d.ts.map +0 -1
  195. package/handlebars/helpers.d.ts +0 -339
  196. package/handlebars/helpers.d.ts.map +0 -1
  197. package/handlebars/index.d.ts +0 -195
  198. package/handlebars/index.d.ts.map +0 -1
  199. package/handlebars/index.js +0 -659
  200. package/preview/claude-preview.d.ts +0 -67
  201. package/preview/claude-preview.d.ts.map +0 -1
  202. package/preview/generic-preview.d.ts +0 -66
  203. package/preview/generic-preview.d.ts.map +0 -1
  204. package/preview/index.d.ts +0 -36
  205. package/preview/index.d.ts.map +0 -1
  206. package/preview/openai-preview.d.ts +0 -70
  207. package/preview/openai-preview.d.ts.map +0 -1
  208. package/preview/types.d.ts +0 -199
  209. package/preview/types.d.ts.map +0 -1
  210. package/registry/index.d.ts +0 -46
  211. package/registry/index.d.ts.map +0 -1
  212. package/registry/index.js +0 -6342
  213. package/registry/render-template.d.ts +0 -91
  214. package/registry/render-template.d.ts.map +0 -1
  215. package/registry/tool-ui.registry.d.ts +0 -294
  216. package/registry/tool-ui.registry.d.ts.map +0 -1
  217. package/registry/uri-utils.d.ts +0 -56
  218. package/registry/uri-utils.d.ts.map +0 -1
  219. package/renderers/cache.d.ts +0 -145
  220. package/renderers/cache.d.ts.map +0 -1
  221. package/renderers/html.renderer.d.ts +0 -123
  222. package/renderers/html.renderer.d.ts.map +0 -1
  223. package/renderers/index.d.ts +0 -36
  224. package/renderers/index.d.ts.map +0 -1
  225. package/renderers/index.js +0 -1603
  226. package/renderers/mdx-client.renderer.d.ts +0 -124
  227. package/renderers/mdx-client.renderer.d.ts.map +0 -1
  228. package/renderers/registry.d.ts +0 -133
  229. package/renderers/registry.d.ts.map +0 -1
  230. package/renderers/types.d.ts +0 -343
  231. package/renderers/types.d.ts.map +0 -1
  232. package/renderers/utils/detect.d.ts +0 -107
  233. package/renderers/utils/detect.d.ts.map +0 -1
  234. package/renderers/utils/hash.d.ts +0 -40
  235. package/renderers/utils/hash.d.ts.map +0 -1
  236. package/renderers/utils/index.d.ts +0 -9
  237. package/renderers/utils/index.d.ts.map +0 -1
  238. package/renderers/utils/transpiler.d.ts +0 -70
  239. package/renderers/utils/transpiler.d.ts.map +0 -1
  240. package/runtime/adapters/html.adapter.d.ts +0 -59
  241. package/runtime/adapters/html.adapter.d.ts.map +0 -1
  242. package/runtime/adapters/index.d.ts +0 -26
  243. package/runtime/adapters/index.d.ts.map +0 -1
  244. package/runtime/adapters/mdx.adapter.d.ts +0 -73
  245. package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  246. package/runtime/adapters/types.d.ts +0 -95
  247. package/runtime/adapters/types.d.ts.map +0 -1
  248. package/runtime/csp.d.ts +0 -48
  249. package/runtime/csp.d.ts.map +0 -1
  250. package/runtime/index.d.ts +0 -17
  251. package/runtime/index.d.ts.map +0 -1
  252. package/runtime/index.js +0 -5432
  253. package/runtime/mcp-bridge.d.ts +0 -101
  254. package/runtime/mcp-bridge.d.ts.map +0 -1
  255. package/runtime/renderer-runtime.d.ts +0 -133
  256. package/runtime/renderer-runtime.d.ts.map +0 -1
  257. package/runtime/sanitizer.d.ts +0 -180
  258. package/runtime/sanitizer.d.ts.map +0 -1
  259. package/runtime/types.d.ts +0 -415
  260. package/runtime/types.d.ts.map +0 -1
  261. package/runtime/wrapper.d.ts +0 -421
  262. package/runtime/wrapper.d.ts.map +0 -1
  263. package/styles/index.d.ts +0 -8
  264. package/styles/index.d.ts.map +0 -1
  265. package/styles/index.js +0 -222
  266. package/styles/variants.d.ts +0 -51
  267. package/styles/variants.d.ts.map +0 -1
  268. package/theme/cdn.d.ts +0 -195
  269. package/theme/cdn.d.ts.map +0 -1
  270. package/theme/css-to-theme.d.ts +0 -64
  271. package/theme/css-to-theme.d.ts.map +0 -1
  272. package/theme/index.d.ts +0 -19
  273. package/theme/index.d.ts.map +0 -1
  274. package/theme/index.js +0 -814
  275. package/theme/platforms.d.ts +0 -102
  276. package/theme/platforms.d.ts.map +0 -1
  277. package/theme/presets/github-openai.d.ts +0 -50
  278. package/theme/presets/github-openai.d.ts.map +0 -1
  279. package/theme/presets/index.d.ts +0 -11
  280. package/theme/presets/index.d.ts.map +0 -1
  281. package/theme/theme.d.ts +0 -396
  282. package/theme/theme.d.ts.map +0 -1
  283. package/tool-template/builder.d.ts +0 -213
  284. package/tool-template/builder.d.ts.map +0 -1
  285. package/tool-template/index.d.ts +0 -16
  286. package/tool-template/index.d.ts.map +0 -1
  287. package/tool-template/index.js +0 -3690
  288. package/validation/error-box.d.ts +0 -56
  289. package/validation/error-box.d.ts.map +0 -1
  290. package/validation/index.d.ts +0 -13
  291. package/validation/index.d.ts.map +0 -1
  292. package/validation/index.js +0 -576
  293. package/validation/schema-paths.d.ts +0 -118
  294. package/validation/schema-paths.d.ts.map +0 -1
  295. package/validation/template-validator.d.ts +0 -143
  296. package/validation/template-validator.d.ts.map +0 -1
  297. package/validation/wrapper.d.ts +0 -97
  298. package/validation/wrapper.d.ts.map +0 -1
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Render Failure Type Guard
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ /**
7
+ * Shape of a UI render failure result.
8
+ */
9
+ export interface UIRenderFailure {
10
+ reason: string;
11
+ }
12
+ /**
13
+ * Type guard for UI render failure objects.
14
+ *
15
+ * A render failure is an object with a `reason` string and no `meta` property.
16
+ */
17
+ export declare function isUIRenderFailure(result: unknown): result is UIRenderFailure;
18
+ //# sourceMappingURL=render-failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-failure.d.ts","sourceRoot":"","sources":["../../src/adapters/render-failure.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,eAAe,CAM5E"}
@@ -1,121 +1,51 @@
1
1
  /**
2
- * @file response-builder.ts
3
- * @description Tool response content builder for different serving modes and platforms.
2
+ * Response Builder
4
3
  *
5
- * This module consolidates all the content formatting logic for tool responses,
6
- * handling the various output formats based on serving mode and platform capabilities.
4
+ * Formats MCP tool response content with UI data per the MCP Apps protocol.
7
5
  *
8
- * For platforms with useStructuredContent=true (all widget-supporting platforms):
9
- * - content: [{ type: 'text', text: '<!DOCTYPE html>...' }] (single block with raw HTML)
10
- * - structuredContent: raw tool output (set by SDK, not this module)
6
+ * @packageDocumentation
11
7
  */
12
- import type { WidgetServingMode } from '../types';
13
- import type { AIPlatformType } from './platform-meta';
8
+ import type { AdapterPlatformType } from './serving-mode';
14
9
  /**
15
- * Text content block for MCP responses.
10
+ * Formatted tool response with UI content.
16
11
  */
17
- export interface TextContentBlock {
18
- type: 'text';
19
- text: string;
12
+ export interface ToolResponseContent {
13
+ /** Text content blocks */
14
+ content: Array<{
15
+ type: 'text';
16
+ text: string;
17
+ }>;
18
+ /** Structured content for clients that support it */
19
+ structuredContent?: Record<string, unknown>;
20
+ /** Response format hint */
21
+ format?: string;
22
+ /** Whether the text content was cleared in favor of structured */
23
+ contentCleared?: boolean;
24
+ /** UI metadata to merge into _meta */
25
+ _meta?: Record<string, unknown>;
20
26
  }
21
27
  /**
22
- * Options for building tool response content.
28
+ * Options for building a tool response with UI content.
23
29
  */
24
- export interface BuildToolResponseOptions {
25
- /**
26
- * The raw output from the tool execution.
27
- */
30
+ export interface BuildToolResponseContentOptions {
31
+ /** Raw tool output */
28
32
  rawOutput: unknown;
29
- /**
30
- * Rendered HTML content (for inline mode).
31
- */
33
+ /** Rendered HTML content (if available) */
32
34
  htmlContent?: string;
33
- /**
34
- * The effective serving mode (after resolution from 'auto').
35
- */
36
- servingMode: Exclude<WidgetServingMode, 'auto'>;
37
- /**
38
- * Whether to use structuredContent format.
39
- * When true, raw HTML is returned in content and rawOutput goes to structuredContent.
40
- */
35
+ /** The effective serving mode */
36
+ servingMode: string;
37
+ /** Whether to include structuredContent */
41
38
  useStructuredContent: boolean;
42
- /**
43
- * The detected platform type.
44
- */
45
- platformType: AIPlatformType;
46
- }
47
- /**
48
- * Result of building tool response content.
49
- */
50
- export interface ToolResponseContent {
51
- /**
52
- * The content blocks to include in the response.
53
- * For structuredContent format: single TextContent with raw HTML.
54
- * For widget format: empty (widget reads from _meta).
55
- */
56
- content: TextContentBlock[];
57
- /**
58
- * Structured content containing raw tool output.
59
- * Set when useStructuredContent is true.
60
- */
61
- structuredContent?: unknown;
62
- /**
63
- * Metadata to merge into result._meta.
64
- */
65
- meta?: Record<string, unknown>;
66
- /**
67
- * Whether the content was cleared (widget platform handles display).
68
- */
69
- contentCleared: boolean;
70
- /**
71
- * Format used for the response.
72
- */
73
- format: 'structured-content' | 'widget' | 'markdown' | 'json-only';
39
+ /** The platform type */
40
+ platformType: AdapterPlatformType;
74
41
  }
75
42
  /**
76
- * Build the content blocks for a tool response based on serving mode and platform.
77
- *
78
- * This function consolidates the content formatting logic that was previously
79
- * spread across the call-tool.flow.ts finalize stage.
80
- *
81
- * @example
82
- * ```typescript
83
- * // OpenAI/ext-apps: HTML goes directly in content
84
- * const openaiResult = buildToolResponseContent({
85
- * rawOutput: { temperature: 72 },
86
- * htmlContent: '<!DOCTYPE html>...',
87
- * servingMode: 'inline',
88
- * useStructuredContent: true,
89
- * platformType: 'openai',
90
- * });
91
- * // result.content = [{ type: 'text', text: '<!DOCTYPE html>...' }]
92
- * // result.structuredContent = { temperature: 72 }
93
- * // result.format = 'structured-content'
94
- *
95
- * // Claude/generic platforms: JSON in content, HTML via _meta['ui/html']
96
- * const claudeResult = buildToolResponseContent({
97
- * rawOutput: { temperature: 72 },
98
- * htmlContent: '<!DOCTYPE html>...',
99
- * servingMode: 'inline',
100
- * useStructuredContent: true,
101
- * platformType: 'claude',
102
- * });
103
- * // result.content = [{ type: 'text', text: '{"temperature":72}' }]
104
- * // result.structuredContent = { temperature: 72 }
105
- * // Note: HTML is set in _meta['ui/html'] by the call-tool flow, not this function
106
- * // result.format = 'structured-content'
43
+ * Build a formatted tool response with UI content.
107
44
  *
108
- * // Platform without widget support (gemini, unknown)
109
- * const geminiResult = buildToolResponseContent({
110
- * rawOutput: { temperature: 72 },
111
- * htmlContent: '<!DOCTYPE html>...',
112
- * servingMode: 'inline',
113
- * useStructuredContent: false,
114
- * platformType: 'gemini',
115
- * });
116
- * // result.content = [{ type: 'text', text: '{"temperature":72}' }]
117
- * // result.format = 'json-only'
118
- * ```
45
+ * Includes:
46
+ * - `content`: Text summary of the output
47
+ * - `structuredContent`: Raw output as structured data (when supported)
48
+ * - `_meta`: Platform-specific HTML key with rendered content
119
49
  */
120
- export declare function buildToolResponseContent(options: BuildToolResponseOptions): ToolResponseContent;
50
+ export declare function buildToolResponseContent(options: BuildToolResponseContentOptions): ToolResponseContent;
121
51
  //# sourceMappingURL=response-builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"response-builder.d.ts","sourceRoot":"","sources":["../../src/adapters/response-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQtD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAEhD;;;OAGG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAE5B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,MAAM,EAAE,oBAAoB,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;CACpE;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,wBAAwB,GAAG,mBAAmB,CAmG/F"}
1
+ {"version":3,"file":"response-builder.d.ts","sourceRoot":"","sources":["../../src/adapters/response-builder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0BAA0B;IAC1B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,sBAAsB;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,oBAAoB,EAAE,OAAO,CAAC;IAC9B,wBAAwB;IACxB,YAAY,EAAE,mBAAmB,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,mBAAmB,CAkCtG"}
@@ -1,107 +1,44 @@
1
1
  /**
2
- * @file serving-mode.ts
3
- * @description Serving mode resolution for auto-detection based on client capabilities.
2
+ * Serving Mode Resolution
4
3
  *
5
- * The `'auto'` serving mode automatically selects the appropriate delivery mechanism
6
- * based on the MCP client's capabilities:
4
+ * Platform-aware serving mode resolution for MCP tool UI.
7
5
  *
8
- * - **OpenAI/ext-apps**: Use `'inline'` mode with `_meta['ui/html']`
9
- * - **Claude**: Use `'inline'` mode with structuredContent (raw HTML + raw output)
10
- * - **Gemini/unsupported**: Skip UI entirely (return JSON only)
11
- *
12
- * When a specific mode is forced (not 'auto'), but the client doesn't support it,
13
- * the UI is skipped to prevent broken experiences.
6
+ * @packageDocumentation
14
7
  */
15
- import type { WidgetServingMode } from '../types';
16
- import type { AIPlatformType } from './platform-meta';
17
8
  /**
18
- * Result of serving mode resolution.
9
+ * Platform types recognized by the serving mode resolver.
19
10
  */
20
- export interface ResolvedServingMode {
21
- /**
22
- * The effective serving mode to use.
23
- * `null` means UI should be skipped entirely.
24
- */
25
- effectiveMode: Exclude<WidgetServingMode, 'auto'> | null;
26
- /**
27
- * Whether the client supports widget UI.
28
- */
29
- supportsUI: boolean;
30
- /**
31
- * Whether structuredContent should be used (Claude).
32
- * When true, the response includes raw tool output in structuredContent
33
- * and raw HTML in a single content block.
34
- */
35
- useStructuredContent: boolean;
36
- /**
37
- * Reason for the decision (useful for logging/debugging).
38
- */
39
- reason: string;
40
- }
11
+ export type AdapterPlatformType = 'openai' | 'ext-apps' | 'claude' | 'gemini' | 'generic-mcp' | 'unknown' | string;
41
12
  /**
42
- * Options for resolving serving mode.
13
+ * Input for serving mode resolution.
43
14
  */
44
15
  export interface ResolveServingModeOptions {
45
- /**
46
- * The configured serving mode (from UITemplateConfig).
47
- * Defaults to 'auto'.
48
- */
49
- configuredMode?: WidgetServingMode;
50
- /**
51
- * The detected platform type.
52
- */
53
- platformType: AIPlatformType;
16
+ /** The configured serving mode from the tool's UI config */
17
+ configuredMode: string;
18
+ /** The detected platform type */
19
+ platformType: AdapterPlatformType;
54
20
  }
55
21
  /**
56
- * Resolve the effective serving mode based on configuration and client capabilities.
57
- *
58
- * This function implements the 'auto' serving mode logic:
59
- * 1. If `configuredMode` is 'auto', select the best mode for the platform
60
- * 2. If a specific mode is forced, check if the platform supports it
61
- * 3. If the platform doesn't support the mode, return `null` (skip UI)
62
- *
63
- * @example
64
- * ```typescript
65
- * const result = resolveServingMode({
66
- * configuredMode: 'auto',
67
- * platformType: 'openai',
68
- * });
69
- * // { effectiveMode: 'inline', useStructuredContent: true, supportsUI: true, ... }
70
- *
71
- * const claudeResult = resolveServingMode({
72
- * configuredMode: 'auto',
73
- * platformType: 'claude',
74
- * });
75
- * // { effectiveMode: 'inline', useStructuredContent: true, supportsUI: true, ... }
76
- *
77
- * const geminiResult = resolveServingMode({
78
- * configuredMode: 'auto',
79
- * platformType: 'gemini',
80
- * });
81
- * // { effectiveMode: null, useStructuredContent: false, supportsUI: false, ... }
82
- * ```
83
- */
84
- export declare function resolveServingMode(options: ResolveServingModeOptions): ResolvedServingMode;
85
- /**
86
- * Check if a platform supports a specific serving mode.
87
- */
88
- export declare function isPlatformModeSupported(platformType: AIPlatformType, mode: WidgetServingMode): boolean;
89
- /**
90
- * Get the default serving mode for a platform.
91
- */
92
- export declare function getDefaultServingMode(platformType: AIPlatformType): Exclude<WidgetServingMode, 'auto'> | null;
93
- /**
94
- * Check if a platform uses structuredContent format.
95
- * When true, responses include raw tool output in structuredContent
96
- * and raw HTML in a single content block.
22
+ * Result of serving mode resolution.
97
23
  */
98
- export declare function platformUsesStructuredContent(platformType: AIPlatformType): boolean;
24
+ export interface ServingModeResult {
25
+ /** The original configured mode */
26
+ mode: string;
27
+ /** Whether the platform supports UI rendering */
28
+ supportsUI: boolean;
29
+ /** The effective serving mode to use, or null if UI not supported */
30
+ effectiveMode: string | null;
31
+ /** Whether to include structuredContent in the tool response */
32
+ useStructuredContent: boolean;
33
+ /** Reason for the decision (for logging) */
34
+ reason?: string;
35
+ }
99
36
  /**
100
- * Check if a platform supports widget UI via _meta.
37
+ * Resolve the effective serving mode based on platform capabilities.
101
38
  *
102
- * These platforms can read HTML from _meta['ui/html'] and render it
103
- * in a sandboxed iframe. They don't need the content blocks filled with
104
- * formatted data since the widget handles display.
39
+ * - Gemini: No UI support
40
+ * - OpenAI, ext-apps, claude, generic-mcp, unknown: UI supported, inline mode
41
+ * - OpenAI/ext-apps/generic-mcp/unknown: include structuredContent
105
42
  */
106
- export declare function platformSupportsWidgets(platformType: AIPlatformType): boolean;
43
+ export declare function resolveServingMode(options: ResolveServingModeOptions): ServingModeResult;
107
44
  //# sourceMappingURL=serving-mode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serving-mode.d.ts","sourceRoot":"","sources":["../../src/adapters/serving-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMtD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,aAAa,EAAE,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAEzD;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,cAAc,CAAC,EAAE,iBAAiB,CAAC;IAEnC;;OAEG;IACH,YAAY,EAAE,cAAc,CAAC;CAC9B;AA4FD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,mBAAmB,CA2C1F;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAQtG;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,GAAG,IAAI,CAG7G;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAGnF;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAG7E"}
1
+ {"version":3,"file":"serving-mode.d.ts","sourceRoot":"","sources":["../../src/adapters/serving-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,CAAC;AAEnH;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,YAAY,EAAE,mBAAmB,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,UAAU,EAAE,OAAO,CAAC;IACpB,qEAAqE;IACrE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gEAAgE;IAChE,oBAAoB,EAAE,OAAO,CAAC;IAC9B,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,iBAAiB,CA6CxF"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Template Renderer
3
+ *
4
+ * Core rendering function that executes templates and wraps results.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { ImportResolver } from '../resolver/types';
9
+ /**
10
+ * Options for rendering a tool template.
11
+ */
12
+ export interface RenderToolTemplateOptions {
13
+ /** Tool name */
14
+ toolName: string;
15
+ /** Tool input */
16
+ input: unknown;
17
+ /** Tool output */
18
+ output: unknown;
19
+ /** The template (function, string, or React component) */
20
+ template: unknown;
21
+ /** Platform type for rendering decisions */
22
+ platformType?: string;
23
+ /** Optional import resolver with CDN overrides */
24
+ resolver?: ImportResolver;
25
+ }
26
+ /**
27
+ * Result of rendering a tool template.
28
+ */
29
+ export interface RenderToolTemplateResult {
30
+ /** The rendered HTML string */
31
+ html: string;
32
+ /** The detected UI type */
33
+ uiType: string;
34
+ /** Content hash */
35
+ hash: string;
36
+ /** Size in bytes */
37
+ size: number;
38
+ /** Platform-specific metadata */
39
+ meta: Record<string, unknown>;
40
+ }
41
+ /**
42
+ * Render a tool template into HTML.
43
+ *
44
+ * - Function templates: Calls `template(ctx)` with createTemplateHelpers()
45
+ * - React components: Delegates to renderComponent() from uipack/component
46
+ * - String templates: Wraps in buildShell()
47
+ * - Auto-detect: wraps detected content (chart, mermaid, PDF, HTML)
48
+ */
49
+ export declare function renderToolTemplate(options: RenderToolTemplateOptions): RenderToolTemplateResult;
50
+ //# sourceMappingURL=template-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-renderer.d.ts","sourceRoot":"","sources":["../../src/adapters/template-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,0DAA0D;IAC1D,QAAQ,EAAE,OAAO,CAAC;IAClB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,wBAAwB,CAwG/F"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * UI Type Detector
3
+ *
4
+ * Detects the UIType from a template value.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { UIType } from '../types/ui-runtime';
9
+ /**
10
+ * Detect the UIType from a template value.
11
+ *
12
+ * - Function with `$$typeof` or prototype with `render` → `'react'`
13
+ * - Other function → `'html'` (template builder function)
14
+ * - String → `'html'` (or `'markdown'` if it looks like markdown)
15
+ * - Otherwise → `'auto'`
16
+ */
17
+ export declare function detectUIType(template: unknown): UIType;
18
+ //# sourceMappingURL=type-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-detector.d.ts","sourceRoot":"","sources":["../../src/adapters/type-detector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CA4CtD"}
@@ -975,7 +975,7 @@ function minifyJS(code) {
975
975
  if (code.length > MAX_MINIFY_CODE_LENGTH) {
976
976
  return code;
977
977
  }
978
- return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "").replace(/\s+/g, " ").replace(/\s*([{};,:()[\]])\s*/g, "$1").replace(/;\}/g, "}").trim();
978
+ return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/\s+/g, " ").replace(/\s*([{};,:()[\]])\s*/g, "$1").replace(/;\}/g, "}").trim();
979
979
  }
980
980
  function generatePlatformBundle(platform, options = {}) {
981
981
  const platformAdapters = {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Component Module
3
+ *
4
+ * Polymorphic UI component loading — resolve npm packages,
5
+ * local files, URLs, or inline functions into renderable HTML.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export type { NpmSource, FileSource, ImportSource, FunctionSource, UISource, UIConfig, ComponentMeta, ResolvedComponent, } from './types';
10
+ export { isNpmSource, isFileSource, isImportSource, isFunctionSource, FRONTMCP_META_KEY } from './types';
11
+ export { resolveUISource, generateMountScript } from './loader';
12
+ export { transpileReactSource, bundleFileSource, extractDefaultExportName } from './transpiler';
13
+ export { renderComponent } from './renderer';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGzG,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGhE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGhG,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}