@frontmcp/uipack 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +246 -0
- package/LICENSE +201 -0
- package/README.md +150 -0
- package/adapters/index.d.ts +13 -0
- package/adapters/index.d.ts.map +1 -0
- package/adapters/index.js +462 -0
- package/adapters/platform-meta.d.ts +166 -0
- package/adapters/platform-meta.d.ts.map +1 -0
- package/adapters/response-builder.d.ts +108 -0
- package/adapters/response-builder.d.ts.map +1 -0
- package/adapters/serving-mode.d.ts +107 -0
- package/adapters/serving-mode.d.ts.map +1 -0
- package/base-template/bridge.d.ts +90 -0
- package/base-template/bridge.d.ts.map +1 -0
- package/base-template/default-base-template.d.ts +92 -0
- package/base-template/default-base-template.d.ts.map +1 -0
- package/base-template/index.d.ts +15 -0
- package/base-template/index.d.ts.map +1 -0
- package/base-template/index.js +1398 -0
- package/base-template/polyfills.d.ts +31 -0
- package/base-template/polyfills.d.ts.map +1 -0
- package/base-template/theme-styles.d.ts +74 -0
- package/base-template/theme-styles.d.ts.map +1 -0
- package/bridge-runtime/iife-generator.d.ts +62 -0
- package/bridge-runtime/iife-generator.d.ts.map +1 -0
- package/bridge-runtime/index.d.ts +10 -0
- package/bridge-runtime/index.d.ts.map +1 -0
- package/bridge-runtime/index.js +883 -0
- package/build/cdn-resources.d.ts +243 -0
- package/build/cdn-resources.d.ts.map +1 -0
- package/build/index.d.ts +295 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +6861 -0
- package/build/widget-manifest.d.ts +362 -0
- package/build/widget-manifest.d.ts.map +1 -0
- package/bundler/cache.d.ts +173 -0
- package/bundler/cache.d.ts.map +1 -0
- package/bundler/file-cache/component-builder.d.ts +167 -0
- package/bundler/file-cache/component-builder.d.ts.map +1 -0
- package/bundler/file-cache/hash-calculator.d.ts +155 -0
- package/bundler/file-cache/hash-calculator.d.ts.map +1 -0
- package/bundler/file-cache/index.d.ts +12 -0
- package/bundler/file-cache/index.d.ts.map +1 -0
- package/bundler/file-cache/storage/filesystem.d.ts +149 -0
- package/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
- package/bundler/file-cache/storage/index.d.ts +11 -0
- package/bundler/file-cache/storage/index.d.ts.map +1 -0
- package/bundler/file-cache/storage/interface.d.ts +152 -0
- package/bundler/file-cache/storage/interface.d.ts.map +1 -0
- package/bundler/file-cache/storage/redis.d.ts +139 -0
- package/bundler/file-cache/storage/redis.d.ts.map +1 -0
- package/bundler/index.d.ts +35 -0
- package/bundler/index.d.ts.map +1 -0
- package/bundler/index.js +2947 -0
- package/bundler/sandbox/enclave-adapter.d.ts +121 -0
- package/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
- package/bundler/sandbox/executor.d.ts +14 -0
- package/bundler/sandbox/executor.d.ts.map +1 -0
- package/bundler/sandbox/policy.d.ts +62 -0
- package/bundler/sandbox/policy.d.ts.map +1 -0
- package/bundler/types.d.ts +702 -0
- package/bundler/types.d.ts.map +1 -0
- package/dependency/cdn-registry.d.ts +98 -0
- package/dependency/cdn-registry.d.ts.map +1 -0
- package/dependency/import-map.d.ts +186 -0
- package/dependency/import-map.d.ts.map +1 -0
- package/dependency/import-parser.d.ts +82 -0
- package/dependency/import-parser.d.ts.map +1 -0
- package/dependency/index.d.ts +17 -0
- package/dependency/index.d.ts.map +1 -0
- package/dependency/index.js +3215 -0
- package/dependency/resolver.d.ts +164 -0
- package/dependency/resolver.d.ts.map +1 -0
- package/dependency/schemas.d.ts +486 -0
- package/dependency/schemas.d.ts.map +1 -0
- package/dependency/template-loader.d.ts +204 -0
- package/dependency/template-loader.d.ts.map +1 -0
- package/dependency/template-processor.d.ts +118 -0
- package/dependency/template-processor.d.ts.map +1 -0
- package/dependency/types.d.ts +739 -0
- package/dependency/types.d.ts.map +1 -0
- package/esm/adapters/index.d.ts +13 -0
- package/esm/adapters/index.d.ts.map +1 -0
- package/esm/adapters/index.js +427 -0
- package/esm/adapters/platform-meta.d.ts +166 -0
- package/esm/adapters/platform-meta.d.ts.map +1 -0
- package/esm/adapters/response-builder.d.ts +108 -0
- package/esm/adapters/response-builder.d.ts.map +1 -0
- package/esm/adapters/serving-mode.d.ts +107 -0
- package/esm/adapters/serving-mode.d.ts.map +1 -0
- package/esm/base-template/bridge.d.ts +90 -0
- package/esm/base-template/bridge.d.ts.map +1 -0
- package/esm/base-template/default-base-template.d.ts +92 -0
- package/esm/base-template/default-base-template.d.ts.map +1 -0
- package/esm/base-template/index.d.ts +15 -0
- package/esm/base-template/index.d.ts.map +1 -0
- package/esm/base-template/index.js +1364 -0
- package/esm/base-template/polyfills.d.ts +31 -0
- package/esm/base-template/polyfills.d.ts.map +1 -0
- package/esm/base-template/theme-styles.d.ts +74 -0
- package/esm/base-template/theme-styles.d.ts.map +1 -0
- package/esm/bridge-runtime/iife-generator.d.ts +62 -0
- package/esm/bridge-runtime/iife-generator.d.ts.map +1 -0
- package/esm/bridge-runtime/index.d.ts +10 -0
- package/esm/bridge-runtime/index.d.ts.map +1 -0
- package/esm/bridge-runtime/index.js +853 -0
- package/esm/build/cdn-resources.d.ts +243 -0
- package/esm/build/cdn-resources.d.ts.map +1 -0
- package/esm/build/index.d.ts +295 -0
- package/esm/build/index.d.ts.map +1 -0
- package/esm/build/index.js +6786 -0
- package/esm/build/widget-manifest.d.ts +362 -0
- package/esm/build/widget-manifest.d.ts.map +1 -0
- package/esm/bundler/cache.d.ts +173 -0
- package/esm/bundler/cache.d.ts.map +1 -0
- package/esm/bundler/file-cache/component-builder.d.ts +167 -0
- package/esm/bundler/file-cache/component-builder.d.ts.map +1 -0
- package/esm/bundler/file-cache/hash-calculator.d.ts +155 -0
- package/esm/bundler/file-cache/hash-calculator.d.ts.map +1 -0
- package/esm/bundler/file-cache/index.d.ts +12 -0
- package/esm/bundler/file-cache/index.d.ts.map +1 -0
- package/esm/bundler/file-cache/storage/filesystem.d.ts +149 -0
- package/esm/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
- package/esm/bundler/file-cache/storage/index.d.ts +11 -0
- package/esm/bundler/file-cache/storage/index.d.ts.map +1 -0
- package/esm/bundler/file-cache/storage/interface.d.ts +152 -0
- package/esm/bundler/file-cache/storage/interface.d.ts.map +1 -0
- package/esm/bundler/file-cache/storage/redis.d.ts +139 -0
- package/esm/bundler/file-cache/storage/redis.d.ts.map +1 -0
- package/esm/bundler/index.d.ts +35 -0
- package/esm/bundler/index.d.ts.map +1 -0
- package/esm/bundler/index.js +2882 -0
- package/esm/bundler/sandbox/enclave-adapter.d.ts +121 -0
- package/esm/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
- package/esm/bundler/sandbox/executor.d.ts +14 -0
- package/esm/bundler/sandbox/executor.d.ts.map +1 -0
- package/esm/bundler/sandbox/policy.d.ts +62 -0
- package/esm/bundler/sandbox/policy.d.ts.map +1 -0
- package/esm/bundler/types.d.ts +702 -0
- package/esm/bundler/types.d.ts.map +1 -0
- package/esm/dependency/cdn-registry.d.ts +98 -0
- package/esm/dependency/cdn-registry.d.ts.map +1 -0
- package/esm/dependency/import-map.d.ts +186 -0
- package/esm/dependency/import-map.d.ts.map +1 -0
- package/esm/dependency/import-parser.d.ts +82 -0
- package/esm/dependency/import-parser.d.ts.map +1 -0
- package/esm/dependency/index.d.ts +17 -0
- package/esm/dependency/index.d.ts.map +1 -0
- package/esm/dependency/index.js +3096 -0
- package/esm/dependency/resolver.d.ts +164 -0
- package/esm/dependency/resolver.d.ts.map +1 -0
- package/esm/dependency/schemas.d.ts +486 -0
- package/esm/dependency/schemas.d.ts.map +1 -0
- package/esm/dependency/template-loader.d.ts +204 -0
- package/esm/dependency/template-loader.d.ts.map +1 -0
- package/esm/dependency/template-processor.d.ts +118 -0
- package/esm/dependency/template-processor.d.ts.map +1 -0
- package/esm/dependency/types.d.ts +739 -0
- package/esm/dependency/types.d.ts.map +1 -0
- package/esm/handlebars/expression-extractor.d.ts +147 -0
- package/esm/handlebars/expression-extractor.d.ts.map +1 -0
- package/esm/handlebars/helpers.d.ts +339 -0
- package/esm/handlebars/helpers.d.ts.map +1 -0
- package/esm/handlebars/index.d.ts +195 -0
- package/esm/handlebars/index.d.ts.map +1 -0
- package/esm/handlebars/index.js +587 -0
- package/esm/index.d.ts +50 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +12434 -0
- package/esm/package.json +68 -0
- package/esm/registry/index.d.ts +46 -0
- package/esm/registry/index.d.ts.map +1 -0
- package/esm/registry/index.js +6237 -0
- package/esm/registry/render-template.d.ts +91 -0
- package/esm/registry/render-template.d.ts.map +1 -0
- package/esm/registry/tool-ui.registry.d.ts +294 -0
- package/esm/registry/tool-ui.registry.d.ts.map +1 -0
- package/esm/registry/uri-utils.d.ts +56 -0
- package/esm/registry/uri-utils.d.ts.map +1 -0
- package/esm/renderers/cache.d.ts +145 -0
- package/esm/renderers/cache.d.ts.map +1 -0
- package/esm/renderers/html.renderer.d.ts +123 -0
- package/esm/renderers/html.renderer.d.ts.map +1 -0
- package/esm/renderers/index.d.ts +36 -0
- package/esm/renderers/index.d.ts.map +1 -0
- package/esm/renderers/index.js +1654 -0
- package/esm/renderers/mdx.renderer.d.ts +120 -0
- package/esm/renderers/mdx.renderer.d.ts.map +1 -0
- package/esm/renderers/registry.d.ts +133 -0
- package/esm/renderers/registry.d.ts.map +1 -0
- package/esm/renderers/types.d.ts +342 -0
- package/esm/renderers/types.d.ts.map +1 -0
- package/esm/renderers/utils/detect.d.ts +107 -0
- package/esm/renderers/utils/detect.d.ts.map +1 -0
- package/esm/renderers/utils/hash.d.ts +40 -0
- package/esm/renderers/utils/hash.d.ts.map +1 -0
- package/esm/renderers/utils/index.d.ts +9 -0
- package/esm/renderers/utils/index.d.ts.map +1 -0
- package/esm/renderers/utils/transpiler.d.ts +89 -0
- package/esm/renderers/utils/transpiler.d.ts.map +1 -0
- package/esm/runtime/adapters/html.adapter.d.ts +59 -0
- package/esm/runtime/adapters/html.adapter.d.ts.map +1 -0
- package/esm/runtime/adapters/index.d.ts +26 -0
- package/esm/runtime/adapters/index.d.ts.map +1 -0
- package/esm/runtime/adapters/mdx.adapter.d.ts +73 -0
- package/esm/runtime/adapters/mdx.adapter.d.ts.map +1 -0
- package/esm/runtime/adapters/types.d.ts +95 -0
- package/esm/runtime/adapters/types.d.ts.map +1 -0
- package/esm/runtime/csp.d.ts +48 -0
- package/esm/runtime/csp.d.ts.map +1 -0
- package/esm/runtime/index.d.ts +17 -0
- package/esm/runtime/index.d.ts.map +1 -0
- package/esm/runtime/index.js +4976 -0
- package/esm/runtime/mcp-bridge.d.ts +101 -0
- package/esm/runtime/mcp-bridge.d.ts.map +1 -0
- package/esm/runtime/renderer-runtime.d.ts +133 -0
- package/esm/runtime/renderer-runtime.d.ts.map +1 -0
- package/esm/runtime/sanitizer.d.ts +172 -0
- package/esm/runtime/sanitizer.d.ts.map +1 -0
- package/esm/runtime/types.d.ts +415 -0
- package/esm/runtime/types.d.ts.map +1 -0
- package/esm/runtime/wrapper.d.ts +421 -0
- package/esm/runtime/wrapper.d.ts.map +1 -0
- package/esm/styles/index.d.ts +8 -0
- package/esm/styles/index.d.ts.map +1 -0
- package/esm/styles/index.js +171 -0
- package/esm/styles/variants.d.ts +51 -0
- package/esm/styles/variants.d.ts.map +1 -0
- package/esm/theme/cdn.d.ts +195 -0
- package/esm/theme/cdn.d.ts.map +1 -0
- package/esm/theme/index.d.ts +18 -0
- package/esm/theme/index.d.ts.map +1 -0
- package/esm/theme/index.js +700 -0
- package/esm/theme/platforms.d.ts +107 -0
- package/esm/theme/platforms.d.ts.map +1 -0
- package/esm/theme/presets/github-openai.d.ts +50 -0
- package/esm/theme/presets/github-openai.d.ts.map +1 -0
- package/esm/theme/presets/index.d.ts +11 -0
- package/esm/theme/presets/index.d.ts.map +1 -0
- package/esm/theme/theme.d.ts +396 -0
- package/esm/theme/theme.d.ts.map +1 -0
- package/esm/tool-template/builder.d.ts +213 -0
- package/esm/tool-template/builder.d.ts.map +1 -0
- package/esm/tool-template/index.d.ts +16 -0
- package/esm/tool-template/index.d.ts.map +1 -0
- package/esm/tool-template/index.js +3518 -0
- package/esm/types/index.d.ts +14 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/index.js +75 -0
- package/esm/types/ui-config.d.ts +641 -0
- package/esm/types/ui-config.d.ts.map +1 -0
- package/esm/types/ui-runtime.d.ts +1008 -0
- package/esm/types/ui-runtime.d.ts.map +1 -0
- package/esm/typings/cache/cache-adapter.d.ts +125 -0
- package/esm/typings/cache/cache-adapter.d.ts.map +1 -0
- package/esm/typings/cache/index.d.ts +10 -0
- package/esm/typings/cache/index.d.ts.map +1 -0
- package/esm/typings/cache/memory-cache.d.ts +92 -0
- package/esm/typings/cache/memory-cache.d.ts.map +1 -0
- package/esm/typings/dts-parser.d.ts +90 -0
- package/esm/typings/dts-parser.d.ts.map +1 -0
- package/esm/typings/index.d.ts +48 -0
- package/esm/typings/index.d.ts.map +1 -0
- package/esm/typings/index.js +812 -0
- package/esm/typings/schemas.d.ts +232 -0
- package/esm/typings/schemas.d.ts.map +1 -0
- package/esm/typings/type-fetcher.d.ts +89 -0
- package/esm/typings/type-fetcher.d.ts.map +1 -0
- package/esm/typings/types.d.ts +320 -0
- package/esm/typings/types.d.ts.map +1 -0
- package/esm/utils/escape-html.d.ts +58 -0
- package/esm/utils/escape-html.d.ts.map +1 -0
- package/esm/utils/index.d.ts +10 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +40 -0
- package/esm/utils/safe-stringify.d.ts +30 -0
- package/esm/utils/safe-stringify.d.ts.map +1 -0
- package/esm/validation/error-box.d.ts +56 -0
- package/esm/validation/error-box.d.ts.map +1 -0
- package/esm/validation/index.d.ts +13 -0
- package/esm/validation/index.d.ts.map +1 -0
- package/esm/validation/index.js +542 -0
- package/esm/validation/schema-paths.d.ts +118 -0
- package/esm/validation/schema-paths.d.ts.map +1 -0
- package/esm/validation/template-validator.d.ts +143 -0
- package/esm/validation/template-validator.d.ts.map +1 -0
- package/esm/validation/wrapper.d.ts +97 -0
- package/esm/validation/wrapper.d.ts.map +1 -0
- package/handlebars/expression-extractor.d.ts +147 -0
- package/handlebars/expression-extractor.d.ts.map +1 -0
- package/handlebars/helpers.d.ts +339 -0
- package/handlebars/helpers.d.ts.map +1 -0
- package/handlebars/index.d.ts +195 -0
- package/handlebars/index.d.ts.map +1 -0
- package/handlebars/index.js +666 -0
- package/index.d.ts +50 -0
- package/index.d.ts.map +1 -0
- package/index.js +12683 -0
- package/package.json +66 -0
- package/registry/index.d.ts +46 -0
- package/registry/index.d.ts.map +1 -0
- package/registry/index.js +6280 -0
- package/registry/render-template.d.ts +91 -0
- package/registry/render-template.d.ts.map +1 -0
- package/registry/tool-ui.registry.d.ts +294 -0
- package/registry/tool-ui.registry.d.ts.map +1 -0
- package/registry/uri-utils.d.ts +56 -0
- package/registry/uri-utils.d.ts.map +1 -0
- package/renderers/cache.d.ts +145 -0
- package/renderers/cache.d.ts.map +1 -0
- package/renderers/html.renderer.d.ts +123 -0
- package/renderers/html.renderer.d.ts.map +1 -0
- package/renderers/index.d.ts +36 -0
- package/renderers/index.d.ts.map +1 -0
- package/renderers/index.js +1706 -0
- package/renderers/mdx.renderer.d.ts +120 -0
- package/renderers/mdx.renderer.d.ts.map +1 -0
- package/renderers/registry.d.ts +133 -0
- package/renderers/registry.d.ts.map +1 -0
- package/renderers/types.d.ts +342 -0
- package/renderers/types.d.ts.map +1 -0
- package/renderers/utils/detect.d.ts +107 -0
- package/renderers/utils/detect.d.ts.map +1 -0
- package/renderers/utils/hash.d.ts +40 -0
- package/renderers/utils/hash.d.ts.map +1 -0
- package/renderers/utils/index.d.ts +9 -0
- package/renderers/utils/index.d.ts.map +1 -0
- package/renderers/utils/transpiler.d.ts +89 -0
- package/renderers/utils/transpiler.d.ts.map +1 -0
- package/runtime/adapters/html.adapter.d.ts +59 -0
- package/runtime/adapters/html.adapter.d.ts.map +1 -0
- package/runtime/adapters/index.d.ts +26 -0
- package/runtime/adapters/index.d.ts.map +1 -0
- package/runtime/adapters/mdx.adapter.d.ts +73 -0
- package/runtime/adapters/mdx.adapter.d.ts.map +1 -0
- package/runtime/adapters/types.d.ts +95 -0
- package/runtime/adapters/types.d.ts.map +1 -0
- package/runtime/csp.d.ts +48 -0
- package/runtime/csp.d.ts.map +1 -0
- package/runtime/index.d.ts +17 -0
- package/runtime/index.d.ts.map +1 -0
- package/runtime/index.js +5052 -0
- package/runtime/mcp-bridge.d.ts +101 -0
- package/runtime/mcp-bridge.d.ts.map +1 -0
- package/runtime/renderer-runtime.d.ts +133 -0
- package/runtime/renderer-runtime.d.ts.map +1 -0
- package/runtime/sanitizer.d.ts +172 -0
- package/runtime/sanitizer.d.ts.map +1 -0
- package/runtime/types.d.ts +415 -0
- package/runtime/types.d.ts.map +1 -0
- package/runtime/wrapper.d.ts +421 -0
- package/runtime/wrapper.d.ts.map +1 -0
- package/styles/index.d.ts +8 -0
- package/styles/index.d.ts.map +1 -0
- package/styles/index.js +222 -0
- package/styles/variants.d.ts +51 -0
- package/styles/variants.d.ts.map +1 -0
- package/theme/cdn.d.ts +195 -0
- package/theme/cdn.d.ts.map +1 -0
- package/theme/index.d.ts +18 -0
- package/theme/index.d.ts.map +1 -0
- package/theme/index.js +757 -0
- package/theme/platforms.d.ts +107 -0
- package/theme/platforms.d.ts.map +1 -0
- package/theme/presets/github-openai.d.ts +50 -0
- package/theme/presets/github-openai.d.ts.map +1 -0
- package/theme/presets/index.d.ts +11 -0
- package/theme/presets/index.d.ts.map +1 -0
- package/theme/theme.d.ts +396 -0
- package/theme/theme.d.ts.map +1 -0
- package/tool-template/builder.d.ts +213 -0
- package/tool-template/builder.d.ts.map +1 -0
- package/tool-template/index.d.ts +16 -0
- package/tool-template/index.d.ts.map +1 -0
- package/tool-template/index.js +3562 -0
- package/types/index.d.ts +14 -0
- package/types/index.d.ts.map +1 -0
- package/types/index.js +108 -0
- package/types/ui-config.d.ts +641 -0
- package/types/ui-config.d.ts.map +1 -0
- package/types/ui-runtime.d.ts +1008 -0
- package/types/ui-runtime.d.ts.map +1 -0
- package/typings/cache/cache-adapter.d.ts +125 -0
- package/typings/cache/cache-adapter.d.ts.map +1 -0
- package/typings/cache/index.d.ts +10 -0
- package/typings/cache/index.d.ts.map +1 -0
- package/typings/cache/memory-cache.d.ts +92 -0
- package/typings/cache/memory-cache.d.ts.map +1 -0
- package/typings/dts-parser.d.ts +90 -0
- package/typings/dts-parser.d.ts.map +1 -0
- package/typings/index.d.ts +48 -0
- package/typings/index.d.ts.map +1 -0
- package/typings/index.js +868 -0
- package/typings/schemas.d.ts +232 -0
- package/typings/schemas.d.ts.map +1 -0
- package/typings/type-fetcher.d.ts +89 -0
- package/typings/type-fetcher.d.ts.map +1 -0
- package/typings/types.d.ts +320 -0
- package/typings/types.d.ts.map +1 -0
- package/utils/escape-html.d.ts +58 -0
- package/utils/escape-html.d.ts.map +1 -0
- package/utils/index.d.ts +10 -0
- package/utils/index.d.ts.map +1 -0
- package/utils/index.js +70 -0
- package/utils/safe-stringify.d.ts +30 -0
- package/utils/safe-stringify.d.ts.map +1 -0
- package/validation/error-box.d.ts +56 -0
- package/validation/error-box.d.ts.map +1 -0
- package/validation/index.d.ts +13 -0
- package/validation/index.d.ts.map +1 -0
- package/validation/index.js +583 -0
- package/validation/schema-paths.d.ts +118 -0
- package/validation/schema-paths.d.ts.map +1 -0
- package/validation/template-validator.d.ts +143 -0
- package/validation/template-validator.d.ts.map +1 -0
- package/validation/wrapper.d.ts +97 -0
- package/validation/wrapper.d.ts.map +1 -0
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone UI Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* SDK-independent types for configuring UI templates.
|
|
5
|
+
* These types can be used by external consumers (like AgentLink)
|
|
6
|
+
* without requiring @frontmcp/sdk as a dependency.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import type { CDNDependency, FileBundleOptions } from '../dependency/types';
|
|
11
|
+
/**
|
|
12
|
+
* Content Security Policy for UI templates rendered in sandboxed iframes.
|
|
13
|
+
* Based on OpenAI Apps SDK and MCP Apps (SEP-1865) specifications.
|
|
14
|
+
*/
|
|
15
|
+
export interface UIContentSecurityPolicy {
|
|
16
|
+
/**
|
|
17
|
+
* Origins allowed for fetch/XHR/WebSocket connections.
|
|
18
|
+
* Maps to CSP `connect-src` directive.
|
|
19
|
+
* @example ['https://api.example.com', 'https://*.myservice.com']
|
|
20
|
+
*/
|
|
21
|
+
connectDomains?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Origins allowed for images, scripts, fonts, and styles.
|
|
24
|
+
* Maps to CSP `img-src`, `script-src`, `style-src`, `font-src` directives.
|
|
25
|
+
* @example ['https://cdn.example.com']
|
|
26
|
+
*/
|
|
27
|
+
resourceDomains?: string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* XSS protection and content security settings.
|
|
31
|
+
*
|
|
32
|
+
* Controls sanitization of HTML content rendered in widgets.
|
|
33
|
+
* By default, strict sanitization is applied to prevent XSS attacks.
|
|
34
|
+
*
|
|
35
|
+
* ## Platform Isolation Context
|
|
36
|
+
*
|
|
37
|
+
* Both OpenAI and Claude render widgets in **double-iframe isolation**:
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
* ┌─────────────────────────────────────────────────┐
|
|
41
|
+
* │ ChatGPT / Claude Desktop │
|
|
42
|
+
* │ ┌─────────────────────────────────────────────┐│
|
|
43
|
+
* │ │ Outer Sandbox Iframe ││
|
|
44
|
+
* │ │ - sandbox="allow-scripts allow-same-origin"││
|
|
45
|
+
* │ │ - No access to parent cookies ││
|
|
46
|
+
* │ │ ┌─────────────────────────────────────────┐││
|
|
47
|
+
* │ │ │ Inner Widget Iframe │││
|
|
48
|
+
* │ │ │ - CSP: script-src 'self' 'unsafe-inline'│││
|
|
49
|
+
* │ │ │ - CSP: connect-src based on config │││
|
|
50
|
+
* │ │ │ - Your widget HTML renders here │││
|
|
51
|
+
* │ │ └─────────────────────────────────────────┘││
|
|
52
|
+
* │ └─────────────────────────────────────────────┘│
|
|
53
|
+
* └─────────────────────────────────────────────────┘
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* This isolation means XSS attacks are **contained** but can still:
|
|
57
|
+
* - Access widget data (input/output)
|
|
58
|
+
* - Make API calls within CSP-allowed domains
|
|
59
|
+
* - Display fake/phishing UI to users
|
|
60
|
+
*
|
|
61
|
+
* **Recommendation:** Only disable protection for fully trusted content.
|
|
62
|
+
*/
|
|
63
|
+
export interface UIContentSecurity {
|
|
64
|
+
/**
|
|
65
|
+
* Allow `javascript:` and other potentially dangerous URL schemes in links.
|
|
66
|
+
*
|
|
67
|
+
* When `false` (default), URLs are validated to only allow:
|
|
68
|
+
* - `http://`, `https://` (web URLs)
|
|
69
|
+
* - `/`, `#` (relative paths, anchors)
|
|
70
|
+
* - `mailto:` (email links)
|
|
71
|
+
*
|
|
72
|
+
* When `true`, allows any URL scheme including:
|
|
73
|
+
* - `javascript:` (inline script execution)
|
|
74
|
+
* - `data:` (data URIs)
|
|
75
|
+
* - `vbscript:` (legacy script)
|
|
76
|
+
*
|
|
77
|
+
* @default false
|
|
78
|
+
*/
|
|
79
|
+
allowUnsafeLinks?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Allow inline `<script>` tags and event handlers (onclick, onerror, etc).
|
|
82
|
+
*
|
|
83
|
+
* When `false` (default), HTML content is sanitized to remove:
|
|
84
|
+
* - `<script>...</script>` tags
|
|
85
|
+
* - Event handler attributes (`onclick`, `onerror`, `onload`, etc.)
|
|
86
|
+
*
|
|
87
|
+
* When `true`, these elements are preserved in the output.
|
|
88
|
+
*
|
|
89
|
+
* **Note:** Even with this enabled, CSP may still block script execution
|
|
90
|
+
* depending on the platform's iframe sandbox settings.
|
|
91
|
+
*
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
allowInlineScripts?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Completely bypass all HTML sanitization.
|
|
97
|
+
*
|
|
98
|
+
* **⚠️ DANGEROUS:** Only use with fully trusted, server-generated content.
|
|
99
|
+
*
|
|
100
|
+
* When `true`, no sanitization is applied:
|
|
101
|
+
* - Script tags are preserved
|
|
102
|
+
* - Event handlers are preserved
|
|
103
|
+
* - All URL schemes are allowed
|
|
104
|
+
* - No HTML escaping is performed
|
|
105
|
+
*
|
|
106
|
+
* This is useful for:
|
|
107
|
+
* - Embedding trusted third-party widgets
|
|
108
|
+
* - Complex interactive dashboards from trusted sources
|
|
109
|
+
* - Content that was pre-sanitized server-side
|
|
110
|
+
*
|
|
111
|
+
* @default false
|
|
112
|
+
*/
|
|
113
|
+
bypassSanitization?: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Helper functions available in template context.
|
|
117
|
+
*/
|
|
118
|
+
export interface TemplateHelpers {
|
|
119
|
+
/**
|
|
120
|
+
* Escape HTML special characters to prevent XSS.
|
|
121
|
+
* Handles null/undefined by returning empty string.
|
|
122
|
+
* Non-string values are converted to string before escaping.
|
|
123
|
+
*/
|
|
124
|
+
escapeHtml: (str: unknown) => string;
|
|
125
|
+
/**
|
|
126
|
+
* Format a date for display.
|
|
127
|
+
* @param date - Date object or ISO string
|
|
128
|
+
* @param format - Optional format (default: localized date)
|
|
129
|
+
*/
|
|
130
|
+
formatDate: (date: Date | string, format?: string) => string;
|
|
131
|
+
/**
|
|
132
|
+
* Format a number as currency.
|
|
133
|
+
* @param amount - The numeric amount
|
|
134
|
+
* @param currency - ISO 4217 currency code (default: 'USD')
|
|
135
|
+
*/
|
|
136
|
+
formatCurrency: (amount: number, currency?: string) => string;
|
|
137
|
+
/**
|
|
138
|
+
* Generate a unique ID for DOM elements.
|
|
139
|
+
* @param prefix - Optional prefix for the ID
|
|
140
|
+
*/
|
|
141
|
+
uniqueId: (prefix?: string) => string;
|
|
142
|
+
/**
|
|
143
|
+
* Safely embed JSON data in HTML (escapes script-breaking characters).
|
|
144
|
+
*/
|
|
145
|
+
jsonEmbed: (data: unknown) => string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Context passed to template builder functions.
|
|
149
|
+
* Contains all data needed to render a tool's UI template.
|
|
150
|
+
*/
|
|
151
|
+
export interface TemplateContext<In = unknown, Out = unknown> {
|
|
152
|
+
/**
|
|
153
|
+
* The input arguments passed to the tool.
|
|
154
|
+
*/
|
|
155
|
+
input: In;
|
|
156
|
+
/**
|
|
157
|
+
* The raw output returned by the tool's execute method.
|
|
158
|
+
*/
|
|
159
|
+
output: Out;
|
|
160
|
+
/**
|
|
161
|
+
* The structured content parsed from the output (if outputSchema was provided).
|
|
162
|
+
* This is the JSON-serializable form suitable for widget consumption.
|
|
163
|
+
*/
|
|
164
|
+
structuredContent?: unknown;
|
|
165
|
+
/**
|
|
166
|
+
* Helper functions for template rendering.
|
|
167
|
+
*/
|
|
168
|
+
helpers: TemplateHelpers;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Template builder function type.
|
|
172
|
+
* Receives context with input/output and returns HTML string.
|
|
173
|
+
*/
|
|
174
|
+
export type TemplateBuilderFn<In = unknown, Out = unknown> = (ctx: TemplateContext<In, Out>) => string;
|
|
175
|
+
/**
|
|
176
|
+
* Widget serving mode determines how the widget HTML is delivered to the client.
|
|
177
|
+
*
|
|
178
|
+
* - `'auto'` (default): Automatically select mode based on client capabilities.
|
|
179
|
+
* For OpenAI/ext-apps: uses 'inline'. For Claude: uses 'inline' with dual-payload.
|
|
180
|
+
* For unsupported clients (e.g., Gemini): skips UI entirely (returns JSON only).
|
|
181
|
+
*
|
|
182
|
+
* - `'inline'`: HTML embedded directly in tool response `_meta['ui/html']`.
|
|
183
|
+
* Works on all platforms including network-blocked ones.
|
|
184
|
+
*
|
|
185
|
+
* - `'static'`: Pre-compiled at startup, resolved via `tools/list` (ui:// resource URI).
|
|
186
|
+
* Widget is fetched via MCP `resources/read`.
|
|
187
|
+
*
|
|
188
|
+
* - `'hybrid'`: Shell (React runtime + bridge) pre-compiled at startup.
|
|
189
|
+
* Component code transpiled per-request and delivered in `_meta['ui/component']`.
|
|
190
|
+
*
|
|
191
|
+
* - `'direct-url'`: HTTP endpoint on MCP server.
|
|
192
|
+
*
|
|
193
|
+
* - `'custom-url'`: Custom URL (CDN or external hosting).
|
|
194
|
+
*/
|
|
195
|
+
export type WidgetServingMode = 'auto' | 'inline' | 'static' | 'hybrid' | 'direct-url' | 'custom-url';
|
|
196
|
+
/**
|
|
197
|
+
* @deprecated Use 'static' instead of 'mcp-resource'. Will be removed in v2.0.
|
|
198
|
+
* Alias maintained for backwards compatibility.
|
|
199
|
+
*/
|
|
200
|
+
export type WidgetServingModeLegacy = 'mcp-resource';
|
|
201
|
+
/**
|
|
202
|
+
* Widget display mode preference.
|
|
203
|
+
*/
|
|
204
|
+
export type WidgetDisplayMode = 'inline' | 'fullscreen' | 'pip';
|
|
205
|
+
/**
|
|
206
|
+
* UI template configuration for tools.
|
|
207
|
+
* Enables rendering interactive widgets for tool responses in supported hosts
|
|
208
|
+
* (OpenAI Apps SDK, Claude/MCP-UI, etc.).
|
|
209
|
+
*
|
|
210
|
+
* This is a standalone type that doesn't depend on @frontmcp/sdk.
|
|
211
|
+
* Use this type in external systems (like AgentLink) that consume @frontmcp/ui.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* const uiConfig: UITemplateConfig = {
|
|
216
|
+
* template: (ctx) => `
|
|
217
|
+
* <div class="p-4">
|
|
218
|
+
* <h2>${ctx.helpers.escapeHtml(ctx.input.location)}</h2>
|
|
219
|
+
* <p>${ctx.output.temperature}°F</p>
|
|
220
|
+
* </div>
|
|
221
|
+
* `,
|
|
222
|
+
* csp: { connectDomains: ['https://api.weather.com'] },
|
|
223
|
+
* widgetAccessible: true,
|
|
224
|
+
* widgetDescription: 'Displays current weather conditions',
|
|
225
|
+
* };
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export interface UITemplateConfig<In = unknown, Out = unknown> {
|
|
229
|
+
/**
|
|
230
|
+
* Template for rendering tool UI.
|
|
231
|
+
*
|
|
232
|
+
* Supports multiple formats (auto-detected by renderer):
|
|
233
|
+
* - Template builder function: `(ctx) => string` - receives input/output/helpers, returns HTML
|
|
234
|
+
* - Static HTML/MDX string: `"<div>...</div>"` or `"# Title\n<Card />"`
|
|
235
|
+
* - React component: `MyWidget` - receives props with input/output/helpers
|
|
236
|
+
*/
|
|
237
|
+
template: TemplateBuilderFn<In, Out> | string | ((props: any) => any);
|
|
238
|
+
/**
|
|
239
|
+
* Content Security Policy for the sandboxed widget.
|
|
240
|
+
* Controls which external resources the widget can access.
|
|
241
|
+
*/
|
|
242
|
+
csp?: UIContentSecurityPolicy;
|
|
243
|
+
/**
|
|
244
|
+
* Content security and XSS protection settings.
|
|
245
|
+
*
|
|
246
|
+
* By default, FrontMCP sanitizes HTML content to prevent XSS attacks:
|
|
247
|
+
* - Removes `<script>` tags and event handlers (onclick, onerror, etc.)
|
|
248
|
+
* - Validates URL schemes in links (blocks `javascript:`, `data:`, `vbscript:`)
|
|
249
|
+
*
|
|
250
|
+
* These protections can be disabled for trusted content that requires
|
|
251
|
+
* inline scripts, custom event handlers, or special URL schemes.
|
|
252
|
+
*
|
|
253
|
+
* ## Security Context
|
|
254
|
+
*
|
|
255
|
+
* **OpenAI/Claude run widgets in double-iframe isolation:**
|
|
256
|
+
* - Outer sandbox iframe with restricted permissions
|
|
257
|
+
* - Inner content iframe with CSP headers
|
|
258
|
+
* - No access to parent window or cookies
|
|
259
|
+
* - Network requests restricted by CSP
|
|
260
|
+
*
|
|
261
|
+
* This isolation provides defense-in-depth, making XSS less impactful.
|
|
262
|
+
* However, XSS can still:
|
|
263
|
+
* - Steal widget state/data
|
|
264
|
+
* - Make unauthorized API calls (within CSP limits)
|
|
265
|
+
* - Phish users with fake UI
|
|
266
|
+
*
|
|
267
|
+
* **Best Practice:** Keep XSS protection enabled unless you have a specific
|
|
268
|
+
* need for inline scripts/handlers AND trust your content source completely.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* // Default: Full XSS protection
|
|
273
|
+
* ui: { template: MyWidget }
|
|
274
|
+
*
|
|
275
|
+
* // Allow inline scripts for trusted dashboard
|
|
276
|
+
* ui: {
|
|
277
|
+
* template: TrustedDashboard,
|
|
278
|
+
* contentSecurity: { allowInlineScripts: true }
|
|
279
|
+
* }
|
|
280
|
+
*
|
|
281
|
+
* // Bypass all sanitization for fully trusted HTML
|
|
282
|
+
* ui: {
|
|
283
|
+
* template: FullyTrustedContent,
|
|
284
|
+
* contentSecurity: { bypassSanitization: true }
|
|
285
|
+
* }
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
contentSecurity?: UIContentSecurity;
|
|
289
|
+
/**
|
|
290
|
+
* Whether the widget can invoke tools via the MCP bridge.
|
|
291
|
+
* When true, the widget gains access to `window.mcpBridge.callTool()`.
|
|
292
|
+
* Maps to OpenAI's `openai/widgetAccessible` annotation.
|
|
293
|
+
*
|
|
294
|
+
* Default: false
|
|
295
|
+
*/
|
|
296
|
+
widgetAccessible?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Preferred display mode for the widget.
|
|
299
|
+
* - 'inline': Rendered inline in the conversation (default)
|
|
300
|
+
* - 'fullscreen': Request fullscreen display
|
|
301
|
+
* - 'pip': Picture-in-picture mode
|
|
302
|
+
*
|
|
303
|
+
* Note: Host may not support all modes; this is a preference hint.
|
|
304
|
+
*/
|
|
305
|
+
displayMode?: WidgetDisplayMode;
|
|
306
|
+
/**
|
|
307
|
+
* Human-readable description shown to users about what the widget does.
|
|
308
|
+
* Maps to OpenAI's `openai/widgetDescription` annotation.
|
|
309
|
+
*/
|
|
310
|
+
widgetDescription?: string;
|
|
311
|
+
/**
|
|
312
|
+
* Status messages shown during tool invocation (OpenAI ChatGPT specific).
|
|
313
|
+
* Maps to OpenAI's `openai/toolInvocation/invoking` and `openai/toolInvocation/invoked`.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* invocationStatus: {
|
|
318
|
+
* invoking: 'Fetching weather data...',
|
|
319
|
+
* invoked: 'Weather data loaded'
|
|
320
|
+
* }
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
invocationStatus?: {
|
|
324
|
+
/** Status text shown while tool is executing */
|
|
325
|
+
invoking?: string;
|
|
326
|
+
/** Status text shown after tool execution completes */
|
|
327
|
+
invoked?: string;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* How the widget HTML should be served to the client.
|
|
331
|
+
*
|
|
332
|
+
* - `'auto'` (default): Automatically select mode based on client capabilities.
|
|
333
|
+
* For OpenAI/ext-apps clients: uses `'inline'` with `_meta`.
|
|
334
|
+
* For Claude clients: uses `'inline'` with dual-payload format.
|
|
335
|
+
* For unsupported clients (Gemini, unknown): skips UI (returns JSON only).
|
|
336
|
+
*
|
|
337
|
+
* - `'inline'`: HTML embedded directly in tool response `_meta['ui/html']`.
|
|
338
|
+
* Best for small widgets, works on all platforms including network-blocked ones.
|
|
339
|
+
*
|
|
340
|
+
* - `'static'`: Widget pre-compiled at server startup, registered as MCP resource with `ui://` URI.
|
|
341
|
+
* Client fetches via `resources/read`. Good for OpenAI's template system.
|
|
342
|
+
* Widget is resolved during `tools/list`, not dependent on tool call.
|
|
343
|
+
*
|
|
344
|
+
* - `'hybrid'`: Shell (React runtime + bridge) pre-compiled at startup.
|
|
345
|
+
* Component code transpiled per-request and delivered in `_meta['ui/component']`.
|
|
346
|
+
*
|
|
347
|
+
* - `'direct-url'`: Served from MCP server's HTTP endpoint.
|
|
348
|
+
* Avoids third-party cookie issues since widget loads from same domain.
|
|
349
|
+
*
|
|
350
|
+
* - `'custom-url'`: Served from a custom URL (CDN, external hosting).
|
|
351
|
+
* Requires `customWidgetUrl` to be set.
|
|
352
|
+
*
|
|
353
|
+
* @default 'auto'
|
|
354
|
+
*/
|
|
355
|
+
servingMode?: WidgetServingMode;
|
|
356
|
+
/**
|
|
357
|
+
* Custom URL for widget serving when `servingMode: 'custom-url'`.
|
|
358
|
+
* The URL can include `{token}` placeholder which will be replaced with
|
|
359
|
+
* the widget access token.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* customWidgetUrl: 'https://cdn.example.com/widgets/weather.html?token={token}'
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
customWidgetUrl?: string;
|
|
367
|
+
/**
|
|
368
|
+
* Path for direct URL serving when `servingMode: 'direct-url'`.
|
|
369
|
+
* This path is appended to the MCP server's base URL.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* directPath: '/widgets/weather'
|
|
374
|
+
* // Results in: https://mcp-server.example.com/widgets/weather?token=...
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
directPath?: string;
|
|
378
|
+
/**
|
|
379
|
+
* Custom React components available in MDX templates.
|
|
380
|
+
* These components can be used directly in MDX content without importing.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* ui: {
|
|
385
|
+
* template: `# Weather\n<Alert type="info">Data loaded</Alert>`,
|
|
386
|
+
* mdxComponents: {
|
|
387
|
+
* Alert: ({ type, children }) => <div className={type}>{children}</div>,
|
|
388
|
+
* Card: MyCardComponent,
|
|
389
|
+
* }
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
mdxComponents?: Record<string, any>;
|
|
394
|
+
/**
|
|
395
|
+
* Whether to show a border around the UI widget.
|
|
396
|
+
* MCP Apps spec: `_meta.ui.prefersBorder`
|
|
397
|
+
*
|
|
398
|
+
* When true, hosts should render a visible border around the sandbox iframe.
|
|
399
|
+
* Useful for visual clarity when the widget content doesn't have its own borders.
|
|
400
|
+
*
|
|
401
|
+
* Default: undefined (host decides)
|
|
402
|
+
*/
|
|
403
|
+
prefersBorder?: boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Dedicated sandbox domain for the widget.
|
|
406
|
+
* MCP Apps spec: `_meta.ui.domain`
|
|
407
|
+
*
|
|
408
|
+
* When specified, the host should load the widget in an iframe with this
|
|
409
|
+
* domain as the origin, providing additional isolation.
|
|
410
|
+
*
|
|
411
|
+
* @example 'sandbox.example.com'
|
|
412
|
+
*/
|
|
413
|
+
sandboxDomain?: string;
|
|
414
|
+
/**
|
|
415
|
+
* Enable client-side React hydration after server-side rendering (SSR).
|
|
416
|
+
*
|
|
417
|
+
* **Default: `false`**
|
|
418
|
+
*
|
|
419
|
+
* When `false` (default):
|
|
420
|
+
* - SSR output is static HTML
|
|
421
|
+
* - No React runtime is loaded on the client
|
|
422
|
+
* - All interactivity is handled by the FrontMCP Bridge IIFE
|
|
423
|
+
* - This prevents React Hydration Error #418 in MCP clients
|
|
424
|
+
*
|
|
425
|
+
* When `true`:
|
|
426
|
+
* - React/ReactDOM CDN scripts are included
|
|
427
|
+
* - Client attempts to hydrate React components
|
|
428
|
+
* - May cause hydration mismatch errors in some MCP clients (Claude, ChatGPT)
|
|
429
|
+
*
|
|
430
|
+
* **Why disabled by default?**
|
|
431
|
+
* MCP clients like Claude and ChatGPT render HTML in sandboxed iframes.
|
|
432
|
+
* React hydration expects the client-rendered HTML to exactly match the
|
|
433
|
+
* server-rendered HTML. Due to timing differences, random data, and
|
|
434
|
+
* different execution contexts, mismatches frequently occur causing
|
|
435
|
+
* React Error #418 ("Hydration failed...").
|
|
436
|
+
*
|
|
437
|
+
* The FrontMCP Bridge IIFE already provides all necessary interactivity
|
|
438
|
+
* (tool calls via `data-tool-call`, state updates, loading states) without
|
|
439
|
+
* requiring React hydration.
|
|
440
|
+
*
|
|
441
|
+
* **Only enable if:**
|
|
442
|
+
* - You need React state management on the client
|
|
443
|
+
* - You're sure your template produces deterministic HTML
|
|
444
|
+
* - You've tested hydration works in your target MCP client
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* // Disable hydration (default behavior - recommended)
|
|
449
|
+
* ui: {
|
|
450
|
+
* template: MyReactComponent,
|
|
451
|
+
* hydrate: false
|
|
452
|
+
* }
|
|
453
|
+
*
|
|
454
|
+
* // Enable hydration (use with caution)
|
|
455
|
+
* ui: {
|
|
456
|
+
* template: MyStatefulComponent,
|
|
457
|
+
* hydrate: true
|
|
458
|
+
* }
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
hydrate?: boolean;
|
|
462
|
+
/**
|
|
463
|
+
* UI renderer type.
|
|
464
|
+
*
|
|
465
|
+
* - `'html'`: HTML with optional Handlebars
|
|
466
|
+
* - `'react'`: React component (SSR)
|
|
467
|
+
* - `'mdx'`: MDX template
|
|
468
|
+
* - `'markdown'`: Pure Markdown
|
|
469
|
+
* - `'auto'`: Auto-detect from template (default)
|
|
470
|
+
*
|
|
471
|
+
* @default 'auto'
|
|
472
|
+
*/
|
|
473
|
+
uiType?: 'html' | 'react' | 'mdx' | 'markdown' | 'auto';
|
|
474
|
+
/**
|
|
475
|
+
* Bundling mode.
|
|
476
|
+
*
|
|
477
|
+
* - `'static'`: Pre-compile widget shell, inject data at runtime (default)
|
|
478
|
+
* - `'dynamic'`: Generate fresh HTML per tool invocation
|
|
479
|
+
*
|
|
480
|
+
* @default 'static'
|
|
481
|
+
*/
|
|
482
|
+
bundlingMode?: 'static' | 'dynamic';
|
|
483
|
+
/**
|
|
484
|
+
* Resource loading mode.
|
|
485
|
+
*
|
|
486
|
+
* - `'cdn'`: Load React/MDX/Handlebars from CDN URLs (lightweight)
|
|
487
|
+
* - `'inline'`: Embed all scripts in HTML (self-contained)
|
|
488
|
+
*
|
|
489
|
+
* Use 'cdn' for most platforms (OpenAI, ChatGPT, Cursor).
|
|
490
|
+
* Use 'inline' for network-blocked environments (Claude Artifacts).
|
|
491
|
+
*
|
|
492
|
+
* @default 'cdn'
|
|
493
|
+
*/
|
|
494
|
+
resourceMode?: 'cdn' | 'inline';
|
|
495
|
+
/**
|
|
496
|
+
* Runtime options for specific renderers.
|
|
497
|
+
*/
|
|
498
|
+
runtimeOptions?: {
|
|
499
|
+
/** Enable React hydration after SSR */
|
|
500
|
+
hydrate?: boolean;
|
|
501
|
+
/** Markdown rendering options */
|
|
502
|
+
markdown?: {
|
|
503
|
+
/** Enable GitHub-flavored markdown */
|
|
504
|
+
gfm?: boolean;
|
|
505
|
+
/** Syntax highlighting theme */
|
|
506
|
+
highlightTheme?: string;
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* Prefix text shown before HTML in dual-payload responses (Claude).
|
|
511
|
+
*
|
|
512
|
+
* When the output mode is `'dual-payload'` (auto-detected for Claude clients),
|
|
513
|
+
* the tool response contains two TextContent blocks:
|
|
514
|
+
* 1. Pure JSON data: `{"temperature": 72, ...}`
|
|
515
|
+
* 2. Markdown-wrapped HTML: `{prefix}:\n\n```html\n<!DOCTYPE html>...\n```
|
|
516
|
+
*
|
|
517
|
+
* This field controls the prefix text in block 2.
|
|
518
|
+
*
|
|
519
|
+
* @default 'Here is the visual result'
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```typescript
|
|
523
|
+
* // Weather tool
|
|
524
|
+
* ui: {
|
|
525
|
+
* template: WeatherWidget,
|
|
526
|
+
* htmlResponsePrefix: 'Here is the weather dashboard',
|
|
527
|
+
* }
|
|
528
|
+
* // Output block 2: "Here is the weather dashboard:\n\n```html\n..."
|
|
529
|
+
*
|
|
530
|
+
* // Stock tool
|
|
531
|
+
* ui: {
|
|
532
|
+
* template: StockWidget,
|
|
533
|
+
* htmlResponsePrefix: 'Here is the stock information',
|
|
534
|
+
* }
|
|
535
|
+
* // Output block 2: "Here is the stock information:\n\n```html\n..."
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
538
|
+
htmlResponsePrefix?: string;
|
|
539
|
+
/**
|
|
540
|
+
* Packages to load from CDN instead of bundling.
|
|
541
|
+
*
|
|
542
|
+
* When `template` is a file path (e.g., `'./chart-widget.tsx'`), imports
|
|
543
|
+
* of these packages will be excluded from the bundle and loaded at runtime
|
|
544
|
+
* via CDN import maps.
|
|
545
|
+
*
|
|
546
|
+
* Package names should match npm package names. The CDN URL is resolved
|
|
547
|
+
* from the built-in CDN registry or from explicit `dependencies` overrides.
|
|
548
|
+
*
|
|
549
|
+
* **Platform considerations:**
|
|
550
|
+
* - Claude only allows `cdnjs.cloudflare.com` (blocked network)
|
|
551
|
+
* - OpenAI/Cursor/other platforms can use any CDN
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* // Auto-resolved from CDN registry
|
|
556
|
+
* ui: {
|
|
557
|
+
* template: './chart-widget.tsx',
|
|
558
|
+
* externals: ['chart.js', 'react-chartjs-2'],
|
|
559
|
+
* }
|
|
560
|
+
*
|
|
561
|
+
* // With explicit override
|
|
562
|
+
* ui: {
|
|
563
|
+
* template: './chart-widget.tsx',
|
|
564
|
+
* externals: ['chart.js'],
|
|
565
|
+
* dependencies: {
|
|
566
|
+
* 'chart.js': {
|
|
567
|
+
* url: 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js',
|
|
568
|
+
* integrity: 'sha512-...',
|
|
569
|
+
* global: 'Chart',
|
|
570
|
+
* },
|
|
571
|
+
* },
|
|
572
|
+
* }
|
|
573
|
+
* ```
|
|
574
|
+
*/
|
|
575
|
+
externals?: string[];
|
|
576
|
+
/**
|
|
577
|
+
* Explicit CDN dependency overrides for external packages.
|
|
578
|
+
*
|
|
579
|
+
* Use this to specify custom CDN URLs or override the default CDN registry
|
|
580
|
+
* entries for packages listed in `externals`.
|
|
581
|
+
*
|
|
582
|
+
* Keys are npm package names. Values specify the CDN URL, integrity hash,
|
|
583
|
+
* and other loading options.
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```typescript
|
|
587
|
+
* ui: {
|
|
588
|
+
* template: './dashboard.tsx',
|
|
589
|
+
* externals: ['d3', 'lodash'],
|
|
590
|
+
* dependencies: {
|
|
591
|
+
* 'd3': {
|
|
592
|
+
* url: 'https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js',
|
|
593
|
+
* integrity: 'sha512-...',
|
|
594
|
+
* global: 'd3',
|
|
595
|
+
* },
|
|
596
|
+
* 'lodash': {
|
|
597
|
+
* url: 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js',
|
|
598
|
+
* global: '_',
|
|
599
|
+
* },
|
|
600
|
+
* },
|
|
601
|
+
* }
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
dependencies?: Record<string, CDNDependency>;
|
|
605
|
+
/**
|
|
606
|
+
* Bundle options for file-based templates.
|
|
607
|
+
*
|
|
608
|
+
* Controls how the file-based template is compiled and bundled.
|
|
609
|
+
* These options are only used when `template` is a file path.
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* // Development mode
|
|
614
|
+
* ui: {
|
|
615
|
+
* template: './debug-widget.tsx',
|
|
616
|
+
* bundleOptions: {
|
|
617
|
+
* minify: false,
|
|
618
|
+
* sourceMaps: true,
|
|
619
|
+
* target: 'esnext',
|
|
620
|
+
* },
|
|
621
|
+
* }
|
|
622
|
+
*
|
|
623
|
+
* // Production mode (defaults)
|
|
624
|
+
* ui: {
|
|
625
|
+
* template: './widget.tsx',
|
|
626
|
+
* bundleOptions: {
|
|
627
|
+
* minify: true,
|
|
628
|
+
* treeShake: true,
|
|
629
|
+
* target: 'es2020',
|
|
630
|
+
* },
|
|
631
|
+
* }
|
|
632
|
+
* ```
|
|
633
|
+
*/
|
|
634
|
+
fileBundleOptions?: FileBundleOptions;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Type alias for backwards compatibility.
|
|
638
|
+
* Prefer using UITemplateConfig directly.
|
|
639
|
+
*/
|
|
640
|
+
export type UITemplate<In = unknown, Out = unknown> = UITemplateConfig<In, Out>;
|
|
641
|
+
//# sourceMappingURL=ui-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-config.d.ts","sourceRoot":"","sources":["../../../src/types/ui-config.ts"],"names":[],"mappings":"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"}
|