@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,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Bridge Runtime
|
|
3
|
+
*
|
|
4
|
+
* Universal JavaScript runtime injected into UI templates that adapts
|
|
5
|
+
* to the host environment (OpenAI Apps SDK, ext-apps, Claude, etc.).
|
|
6
|
+
*
|
|
7
|
+
* This script is designed to be embedded directly into HTML templates
|
|
8
|
+
* via the MCP_BRIDGE_RUNTIME constant.
|
|
9
|
+
*
|
|
10
|
+
* Architecture:
|
|
11
|
+
* - On OpenAI: Proxy directly to native window.openai API
|
|
12
|
+
* - On Claude: Polyfill with limited functionality (network-blocked)
|
|
13
|
+
* - On ext-apps: JSON-RPC postMessage bridge (SEP-1865 compliant)
|
|
14
|
+
* - On Gemini: Gemini SDK integration
|
|
15
|
+
* - On Unknown: LocalStorage-based state, basic functionality
|
|
16
|
+
*
|
|
17
|
+
* @see https://developers.openai.com/apps-sdk/build/chatgpt-ui
|
|
18
|
+
* @see https://github.com/modelcontextprotocol/ext-apps (SEP-1865)
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* The MCP Bridge runtime script.
|
|
22
|
+
* This is injected into UI templates to provide a unified API across providers.
|
|
23
|
+
*
|
|
24
|
+
* Uses the new FrontMcpBridge adapter system which supports:
|
|
25
|
+
* - OpenAI ChatGPT Apps SDK
|
|
26
|
+
* - ext-apps (SEP-1865 protocol)
|
|
27
|
+
* - Claude (Anthropic)
|
|
28
|
+
* - Gemini (Google)
|
|
29
|
+
* - Generic fallback
|
|
30
|
+
*
|
|
31
|
+
* The bridge exposes:
|
|
32
|
+
* - window.FrontMcpBridge - New unified bridge API
|
|
33
|
+
* - window.mcpBridge - Legacy compatibility bridge
|
|
34
|
+
* - window.openai - OpenAI polyfill for non-OpenAI platforms
|
|
35
|
+
*
|
|
36
|
+
* Provides full OpenAI window.openai API compatibility:
|
|
37
|
+
* - Properties: theme, userAgent, locale, maxHeight, displayMode, safeArea,
|
|
38
|
+
* toolInput, toolOutput, toolResponseMetadata, widgetState
|
|
39
|
+
* - Methods: callTool, requestDisplayMode, requestClose, openExternal,
|
|
40
|
+
* sendFollowUpMessage, setWidgetState
|
|
41
|
+
*/
|
|
42
|
+
export declare const MCP_BRIDGE_RUNTIME = "\n<script>\n(function() {\n 'use strict';\n\n // ==================== Environment Detection ====================\n\n var isOpenAI = typeof window.openai !== 'undefined';\n var isExtApps = window.parent !== window && !isOpenAI;\n var isClaude = typeof window.claude !== 'undefined' ||\n (window.__mcpPlatform === 'claude');\n var isGemini = window.__mcpPlatform === 'gemini';\n\n // ==================== Internal State ====================\n\n var messageId = 0;\n var pendingRequests = new Map();\n var contextChangeListeners = [];\n var toolResultListeners = [];\n\n // Default values for polyfilled properties\n var defaultSafeArea = { top: 0, bottom: 0, left: 0, right: 0 };\n var defaultUserAgent = { type: 'web', hover: true, touch: false };\n\n // Host context (for ext-apps and polyfill mode)\n var hostContext = window.__mcpHostContext || {\n theme: 'light',\n displayMode: 'inline'\n };\n\n // Trusted origin for postMessage validation (set during ext-apps initialization)\n var trustedOrigin = null;\n\n // Detect device capabilities\n var detectUserAgent = function() {\n var ua = navigator.userAgent || '';\n var isMobile = /iPhone|iPad|iPod|Android/i.test(ua);\n var hasTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n var hasHover = window.matchMedia && window.matchMedia('(hover: hover)').matches;\n return {\n type: isMobile ? 'mobile' : 'web',\n hover: hasHover !== false,\n touch: hasTouch\n };\n };\n\n // Detect theme from system preference\n var detectTheme = function() {\n if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {\n return 'dark';\n }\n return 'light';\n };\n\n // ==================== Bridge Implementation ====================\n\n /**\n * MCP Bridge provides full OpenAI API compatibility.\n * On OpenAI, it proxies directly to window.openai.\n * On other platforms, it provides polyfills.\n */\n var bridge = {\n // ==================== Environment Info ====================\n\n get provider() {\n if (isOpenAI) return 'openai';\n if (isClaude) return 'claude';\n if (isGemini) return 'gemini';\n if (isExtApps) return 'ext-apps';\n return 'unknown';\n },\n\n // ==================== OpenAI-Compatible Properties ====================\n\n get theme() {\n if (isOpenAI && window.openai) {\n return window.openai.theme || 'light';\n }\n return hostContext.theme || detectTheme();\n },\n\n get userAgent() {\n if (isOpenAI && window.openai && window.openai.userAgent) {\n return window.openai.userAgent;\n }\n return hostContext.userAgent || detectUserAgent();\n },\n\n get locale() {\n if (isOpenAI && window.openai && window.openai.locale) {\n return window.openai.locale;\n }\n return navigator.language || 'en-US';\n },\n\n get maxHeight() {\n if (isOpenAI && window.openai) {\n return window.openai.maxHeight;\n }\n return hostContext.viewport ? hostContext.viewport.maxHeight : undefined;\n },\n\n get displayMode() {\n if (isOpenAI && window.openai) {\n return window.openai.displayMode || 'inline';\n }\n return hostContext.displayMode || 'inline';\n },\n\n get safeArea() {\n if (isOpenAI && window.openai && window.openai.safeArea) {\n return window.openai.safeArea;\n }\n return hostContext.safeArea || defaultSafeArea;\n },\n\n get toolInput() {\n if (isOpenAI && window.openai && window.openai.toolInput) {\n return window.openai.toolInput;\n }\n return window.__mcpToolInput || {};\n },\n\n get toolOutput() {\n if (isOpenAI && window.openai) {\n return window.openai.toolOutput;\n }\n return window.__mcpToolOutput;\n },\n\n get structuredContent() {\n // Alias for toolOutput to maintain compatibility\n if (isOpenAI && window.openai) {\n return window.openai.toolOutput;\n }\n return window.__mcpStructuredContent;\n },\n\n get toolResponseMetadata() {\n if (isOpenAI && window.openai && window.openai.toolResponseMetadata) {\n return window.openai.toolResponseMetadata;\n }\n return window.__mcpToolResponseMetadata || {};\n },\n\n get widgetState() {\n if (isOpenAI && window.openai) {\n return window.openai.widgetState || {};\n }\n // Polyfill: use localStorage\n try {\n var stored = localStorage.getItem('__mcpWidgetState');\n return stored ? JSON.parse(stored) : {};\n } catch (e) {\n return {};\n }\n },\n\n // ==================== OpenAI-Compatible Methods ====================\n\n callTool: function(name, params) {\n if (isOpenAI && window.openai && window.openai.callTool) {\n return window.openai.callTool(name, params);\n }\n if (isClaude) {\n return Promise.reject(new Error(\n 'Tool calls are not supported in Claude widgets (network-blocked sandbox)'\n ));\n }\n if (isGemini) {\n return Promise.reject(new Error(\n 'Tool calls are not supported in Gemini widgets'\n ));\n }\n if (isExtApps) {\n return this._sendRequest('tools/call', { name: name, arguments: params });\n }\n return Promise.reject(new Error('Tool calls not supported in this environment'));\n },\n\n requestDisplayMode: function(options) {\n if (isOpenAI && window.openai && window.openai.requestDisplayMode) {\n return window.openai.requestDisplayMode(options);\n }\n if (isExtApps) {\n return this._sendRequest('ui/request-display-mode', options);\n }\n // Polyfill: just update local state\n if (options && options.mode) {\n hostContext.displayMode = options.mode;\n contextChangeListeners.forEach(function(cb) {\n try { cb({ displayMode: options.mode }); } catch (e) {}\n });\n }\n return Promise.resolve();\n },\n\n requestClose: function() {\n if (isOpenAI && window.openai && window.openai.requestClose) {\n return window.openai.requestClose();\n }\n if (isExtApps) {\n return this._sendRequest('ui/request-close', {});\n }\n // Polyfill: dispatch event for parent to handle\n window.dispatchEvent(new CustomEvent('mcp:request-close'));\n return Promise.resolve();\n },\n\n openExternal: function(options) {\n var href = typeof options === 'string' ? options : (options && options.href);\n if (!href) {\n return Promise.reject(new Error('URL required'));\n }\n if (isOpenAI && window.openai && window.openai.openExternal) {\n return window.openai.openExternal({ href: href });\n }\n if (isExtApps) {\n return this._sendRequest('ui/open-link', { url: href });\n }\n // Fallback: open in new window\n window.open(href, '_blank', 'noopener,noreferrer');\n return Promise.resolve();\n },\n\n // Alias for openExternal (backwards compatibility)\n openLink: function(url) {\n return this.openExternal({ href: url });\n },\n\n sendFollowUpMessage: function(options) {\n var prompt = typeof options === 'string' ? options : (options && options.prompt);\n if (!prompt) {\n return Promise.reject(new Error('Prompt required'));\n }\n if (isOpenAI && window.openai && window.openai.sendFollowUpMessage) {\n return window.openai.sendFollowUpMessage({ prompt: prompt });\n }\n if (isClaude) {\n return Promise.reject(new Error(\n 'Follow-up messages are not supported in Claude widgets (network-blocked sandbox)'\n ));\n }\n if (isGemini) {\n return Promise.reject(new Error(\n 'Follow-up messages are not supported in Gemini widgets'\n ));\n }\n if (isExtApps) {\n return this._sendRequest('ui/message', {\n role: 'user',\n content: { type: 'text', text: prompt }\n });\n }\n return Promise.reject(new Error('Messages not supported in this environment'));\n },\n\n // Alias for sendFollowUpMessage (backwards compatibility)\n sendMessage: function(content) {\n return this.sendFollowUpMessage({ prompt: content });\n },\n\n setWidgetState: function(state) {\n if (isOpenAI && window.openai && window.openai.setWidgetState) {\n window.openai.setWidgetState(state);\n return;\n }\n // Polyfill: persist to localStorage\n try {\n localStorage.setItem('__mcpWidgetState', JSON.stringify(state));\n } catch (e) {\n console.warn('Failed to persist widget state:', e);\n }\n },\n\n // ==================== Context API (MCP-specific) ====================\n\n get context() {\n return {\n theme: this.theme,\n displayMode: this.displayMode,\n viewport: this.maxHeight ? { maxHeight: this.maxHeight } : undefined,\n userAgent: this.userAgent,\n locale: this.locale,\n safeArea: this.safeArea\n };\n },\n\n onContextChange: function(callback) {\n contextChangeListeners.push(callback);\n return function() {\n var index = contextChangeListeners.indexOf(callback);\n if (index > -1) contextChangeListeners.splice(index, 1);\n };\n },\n\n onToolResult: function(callback) {\n toolResultListeners.push(callback);\n return function() {\n var index = toolResultListeners.indexOf(callback);\n if (index > -1) toolResultListeners.splice(index, 1);\n };\n },\n\n // ==================== Internal Methods ====================\n\n _sendRequest: function(method, params) {\n return new Promise(function(resolve, reject) {\n var id = ++messageId;\n pendingRequests.set(id, { resolve: resolve, reject: reject });\n\n window.parent.postMessage({\n jsonrpc: '2.0',\n id: id,\n method: method,\n params: params\n }, '*');\n\n // Timeout after 30s\n setTimeout(function() {\n if (pendingRequests.has(id)) {\n pendingRequests.delete(id);\n reject(new Error('Request timeout'));\n }\n }, 30000);\n });\n },\n\n _initExtApps: function() {\n var self = this;\n return this._sendRequest('ui/initialize', {}).then(function(result) {\n if (result && result.hostContext) {\n hostContext = Object.assign(hostContext, result.hostContext);\n }\n // Note: trustedOrigin is now set from first message event origin (trust-on-first-use)\n // Send initialized notification\n window.parent.postMessage({\n jsonrpc: '2.0',\n method: 'ui/notifications/initialized',\n params: {}\n }, '*');\n return result;\n });\n }\n };\n\n // ==================== Event Handling ====================\n\n window.addEventListener('message', function(event) {\n var data = event.data;\n if (!data || data.jsonrpc !== '2.0') return;\n\n // Trust-on-first-use: Establish trusted origin from the first valid message\n if (isExtApps && !trustedOrigin && event.origin) {\n trustedOrigin = event.origin;\n }\n\n // Validate origin for ext-apps environment to prevent spoofed messages\n if (isExtApps && trustedOrigin && event.origin !== trustedOrigin) {\n console.warn('MCP Bridge: Ignoring message from untrusted origin:', event.origin);\n return;\n }\n\n // Handle responses\n if (data.id && pendingRequests.has(data.id)) {\n var pending = pendingRequests.get(data.id);\n pendingRequests.delete(data.id);\n\n if (data.error) {\n var err = new Error(data.error.message || 'Unknown error');\n err.code = data.error.code;\n err.data = data.error.data;\n pending.reject(err);\n } else {\n pending.resolve(data.result);\n }\n return;\n }\n\n // Handle notifications\n switch (data.method) {\n case 'ui/notifications/tool-input':\n window.__mcpToolInput = data.params && data.params.arguments;\n window.dispatchEvent(new CustomEvent('mcp:tool-input', { detail: data.params }));\n break;\n\n case 'ui/notifications/tool-input-partial':\n if (data.params && data.params.arguments) {\n window.__mcpToolInput = Object.assign(window.__mcpToolInput || {}, data.params.arguments);\n }\n break;\n\n case 'ui/notifications/tool-result':\n window.__mcpToolOutput = data.params && data.params.content;\n window.__mcpStructuredContent = data.params && data.params.structuredContent;\n toolResultListeners.forEach(function(cb) {\n try { cb(data.params); } catch (e) { console.error('Tool result listener error:', e); }\n });\n window.dispatchEvent(new CustomEvent('mcp:tool-result', { detail: data.params }));\n break;\n\n case 'ui/notifications/tool-cancelled':\n window.dispatchEvent(new CustomEvent('mcp:tool-cancelled', { detail: data.params }));\n break;\n\n case 'ui/host-context-change':\n hostContext = Object.assign(hostContext, data.params);\n contextChangeListeners.forEach(function(cb) {\n try { cb(data.params); } catch (e) { console.error('Context change listener error:', e); }\n });\n window.dispatchEvent(new CustomEvent('mcp:context-change', { detail: data.params }));\n break;\n\n case 'ui/size-change':\n if (hostContext.viewport) {\n hostContext.viewport = Object.assign(hostContext.viewport, data.params);\n } else {\n hostContext.viewport = data.params;\n }\n break;\n }\n });\n\n // ==================== Initialize ====================\n\n // Export bridge\n window.mcpBridge = bridge;\n\n // Also create window.openai polyfill for non-OpenAI platforms\n // This allows code written for OpenAI to work on other platforms\n if (!isOpenAI) {\n window.openai = {\n get theme() { return bridge.theme; },\n get userAgent() { return bridge.userAgent; },\n get locale() { return bridge.locale; },\n get maxHeight() { return bridge.maxHeight; },\n get displayMode() { return bridge.displayMode; },\n get safeArea() { return bridge.safeArea; },\n get toolInput() { return bridge.toolInput; },\n get toolOutput() { return bridge.toolOutput; },\n get toolResponseMetadata() { return bridge.toolResponseMetadata; },\n get widgetState() { return bridge.widgetState; },\n callTool: function(n, a) { return bridge.callTool(n, a); },\n requestDisplayMode: function(o) { return bridge.requestDisplayMode(o); },\n requestClose: function() { return bridge.requestClose(); },\n openExternal: function(o) { return bridge.openExternal(o); },\n sendFollowUpMessage: function(o) { return bridge.sendFollowUpMessage(o); },\n setWidgetState: function(s) { return bridge.setWidgetState(s); }\n };\n }\n\n // Auto-initialize for ext-apps\n if (isExtApps) {\n bridge._initExtApps().catch(function(err) {\n console.warn('Failed to initialize MCP bridge:', err);\n });\n }\n\n // Dispatch ready event\n window.dispatchEvent(new CustomEvent('mcp:bridge-ready'));\n})();\n</script>\n";
|
|
43
|
+
/**
|
|
44
|
+
* Get the MCP Bridge runtime script as a string (without script tags)
|
|
45
|
+
* Useful for inline embedding in specific scenarios.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getMCPBridgeScript(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Check if the current environment supports the MCP bridge
|
|
50
|
+
*/
|
|
51
|
+
export declare function isMCPBridgeSupported(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The new FrontMcpBridge runtime script (universal - includes all adapters).
|
|
54
|
+
* This is the recommended bridge for new integrations.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { FRONTMCP_BRIDGE_RUNTIME } from '@frontmcp/uipack/runtime';
|
|
59
|
+
* const html = `<!DOCTYPE html><html><head>${FRONTMCP_BRIDGE_RUNTIME}</head>...</html>`;
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare const FRONTMCP_BRIDGE_RUNTIME: string;
|
|
63
|
+
/**
|
|
64
|
+
* Platform-specific bridge scripts.
|
|
65
|
+
*
|
|
66
|
+
* Use these for smaller bundle sizes when targeting a specific platform.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* import { PLATFORM_BRIDGE_SCRIPTS } from '@frontmcp/uipack/runtime';
|
|
71
|
+
*
|
|
72
|
+
* // For ChatGPT only
|
|
73
|
+
* const chatgptHtml = `<html><head>${PLATFORM_BRIDGE_SCRIPTS.chatgpt}</head>...</html>`;
|
|
74
|
+
*
|
|
75
|
+
* // For Claude only
|
|
76
|
+
* const claudeHtml = `<html><head>${PLATFORM_BRIDGE_SCRIPTS.claude}</head>...</html>`;
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare const PLATFORM_BRIDGE_SCRIPTS: {
|
|
80
|
+
universal: string;
|
|
81
|
+
chatgpt: string;
|
|
82
|
+
claude: string;
|
|
83
|
+
gemini: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Generate a custom bridge script with specific options.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* import { generateCustomBridge } from '@frontmcp/uipack/runtime';
|
|
91
|
+
*
|
|
92
|
+
* const script = generateCustomBridge({
|
|
93
|
+
* adapters: ['openai', 'ext-apps'],
|
|
94
|
+
* debug: true,
|
|
95
|
+
* trustedOrigins: ['https://my-host.com']
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export { generateBridgeIIFE as generateCustomBridge } from '../bridge-runtime';
|
|
100
|
+
export type { IIFEGeneratorOptions } from '../bridge-runtime';
|
|
101
|
+
//# sourceMappingURL=mcp-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-bridge.d.ts","sourceRoot":"","sources":["../../src/runtime/mcp-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,kBAAkB,koeA8c9B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAI3C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAW9C;AAMD;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,QAA+B,CAAC;AAEpE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,uBAAuB;;;;;CAAqB,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,kBAAkB,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG/E,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renderer Runtime
|
|
3
|
+
*
|
|
4
|
+
* Client-side runtime that manages renderer adapters and handles
|
|
5
|
+
* communication with the FrontMCP Bridge.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { UIType, WidgetManifest } from '../types/ui-runtime';
|
|
10
|
+
import type { RenderContext, RenderResult } from './adapters/types';
|
|
11
|
+
/**
|
|
12
|
+
* Runtime configuration.
|
|
13
|
+
*/
|
|
14
|
+
export interface RendererRuntimeConfig {
|
|
15
|
+
/** The manifest embedded in the page */
|
|
16
|
+
manifest?: Partial<WidgetManifest>;
|
|
17
|
+
/** Initial tool input */
|
|
18
|
+
input?: Record<string, unknown>;
|
|
19
|
+
/** Initial tool output */
|
|
20
|
+
output?: unknown;
|
|
21
|
+
/** Initial structured content */
|
|
22
|
+
structuredContent?: unknown;
|
|
23
|
+
/** Tool name */
|
|
24
|
+
toolName?: string;
|
|
25
|
+
/** Enable debug logging */
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Renderer Runtime.
|
|
30
|
+
*
|
|
31
|
+
* Client-side runtime that:
|
|
32
|
+
* - Reads manifest from the page
|
|
33
|
+
* - Lazy-loads the appropriate renderer adapter
|
|
34
|
+
* - Handles tool output updates from the Bridge
|
|
35
|
+
* - Re-renders when data changes
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Bootstrap from manifest in page
|
|
40
|
+
* const runtime = new RendererRuntime();
|
|
41
|
+
* await runtime.init();
|
|
42
|
+
*
|
|
43
|
+
* // Listen for updates
|
|
44
|
+
* runtime.onUpdate((context) => {
|
|
45
|
+
* console.log('Tool output updated:', context.output);
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class RendererRuntime {
|
|
50
|
+
private config;
|
|
51
|
+
private adapters;
|
|
52
|
+
private state;
|
|
53
|
+
private updateCallbacks;
|
|
54
|
+
private bridgeUnsubscribe;
|
|
55
|
+
constructor(config?: RendererRuntimeConfig);
|
|
56
|
+
/**
|
|
57
|
+
* Initialize the runtime.
|
|
58
|
+
* Reads manifest, sets up Bridge listeners, and prepares adapters.
|
|
59
|
+
*/
|
|
60
|
+
init(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Get the current render context.
|
|
63
|
+
*/
|
|
64
|
+
get context(): RenderContext;
|
|
65
|
+
/**
|
|
66
|
+
* Get the manifest.
|
|
67
|
+
*/
|
|
68
|
+
get manifest(): Partial<WidgetManifest> | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Get the resolved UI type.
|
|
71
|
+
*/
|
|
72
|
+
get uiType(): UIType;
|
|
73
|
+
/**
|
|
74
|
+
* Render content to a target element.
|
|
75
|
+
*
|
|
76
|
+
* @param target - Element to render into
|
|
77
|
+
* @param content - Content to render (optional, uses existing innerHTML)
|
|
78
|
+
* @param options - Render options
|
|
79
|
+
*/
|
|
80
|
+
render(target: HTMLElement, content?: string, options?: {
|
|
81
|
+
hydrate?: boolean;
|
|
82
|
+
}): Promise<RenderResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Update the render context and re-render if needed.
|
|
85
|
+
*/
|
|
86
|
+
updateContext(updates: Partial<RenderContext>): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Subscribe to context updates.
|
|
89
|
+
*/
|
|
90
|
+
onUpdate(callback: (context: RenderContext) => void): () => void;
|
|
91
|
+
/**
|
|
92
|
+
* Clean up resources.
|
|
93
|
+
*/
|
|
94
|
+
destroy(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Read manifest from page.
|
|
97
|
+
*/
|
|
98
|
+
private readManifest;
|
|
99
|
+
/**
|
|
100
|
+
* Read initial data from page globals.
|
|
101
|
+
*/
|
|
102
|
+
private readPageGlobals;
|
|
103
|
+
/**
|
|
104
|
+
* Set up Bridge event listeners.
|
|
105
|
+
*/
|
|
106
|
+
private setupBridgeListeners;
|
|
107
|
+
/**
|
|
108
|
+
* Get or load an adapter for a UI type.
|
|
109
|
+
*/
|
|
110
|
+
private getAdapter;
|
|
111
|
+
/**
|
|
112
|
+
* Auto-detect UI type from content.
|
|
113
|
+
*/
|
|
114
|
+
private detectType;
|
|
115
|
+
/**
|
|
116
|
+
* Log message if debug enabled.
|
|
117
|
+
*/
|
|
118
|
+
private log;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create and initialize a renderer runtime.
|
|
122
|
+
*/
|
|
123
|
+
export declare function createRendererRuntime(config?: RendererRuntimeConfig): Promise<RendererRuntime>;
|
|
124
|
+
/**
|
|
125
|
+
* Bootstrap the renderer runtime from page manifest.
|
|
126
|
+
* This is the main entry point for the IIFE bootstrap script.
|
|
127
|
+
*/
|
|
128
|
+
export declare function bootstrapRendererRuntime(): Promise<RendererRuntime | null>;
|
|
129
|
+
/**
|
|
130
|
+
* Generate the bootstrap IIFE script for embedding in HTML.
|
|
131
|
+
*/
|
|
132
|
+
export declare function generateBootstrapScript(): string;
|
|
133
|
+
//# sourceMappingURL=renderer-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/renderer-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAmB,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACnC,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,0BAA0B;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAYD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,eAAe,CAA+C;IACtE,OAAO,CAAC,iBAAiB,CAA6B;gBAE1C,MAAM,GAAE,qBAA0B;IAe9C;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3B;;OAEG;IACH,IAAI,OAAO,IAAI,aAAa,CAE3B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,CAElD;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;OAMG;IACG,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAkC3G;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBnE;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI;IAUhE;;OAEG;IACH,OAAO,IAAI,IAAI;IAmBf;;OAEG;IACH,OAAO,CAAC,YAAY;IAiCpB;;OAEG;IACH,OAAO,CAAC,eAAe;IAuCvB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAoB5B;;OAEG;YACW,UAAU;IA8BxB;;OAEG;IACH,OAAO,CAAC,UAAU;IAwBlB;;OAEG;IACH,OAAO,CAAC,GAAG;CAKZ;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAIpG;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAiChF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAwBhD"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input Sanitizer
|
|
3
|
+
*
|
|
4
|
+
* Provides PII detection and redaction for tool inputs before they are
|
|
5
|
+
* exposed to widget code. This protects sensitive data from being
|
|
6
|
+
* accidentally exposed in client-side widgets.
|
|
7
|
+
*
|
|
8
|
+
* Built-in patterns:
|
|
9
|
+
* - Email addresses → [EMAIL]
|
|
10
|
+
* - Phone numbers → [PHONE]
|
|
11
|
+
* - Credit card numbers → [CARD]
|
|
12
|
+
* - SSN / National IDs → [ID]
|
|
13
|
+
* - IP addresses → [IP]
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { sanitizeInput, createSanitizer } from './sanitizer';
|
|
18
|
+
*
|
|
19
|
+
* // Auto-detect and redact PII
|
|
20
|
+
* const sanitized = sanitizeInput({
|
|
21
|
+
* user: 'john@example.com',
|
|
22
|
+
* phone: '555-123-4567',
|
|
23
|
+
* message: 'Hello world',
|
|
24
|
+
* });
|
|
25
|
+
* // Result: { user: '[EMAIL]', phone: '[PHONE]', message: 'Hello world' }
|
|
26
|
+
*
|
|
27
|
+
* // Redact specific fields
|
|
28
|
+
* const sanitized2 = sanitizeInput(data, ['email', 'ssn']);
|
|
29
|
+
*
|
|
30
|
+
* // Custom sanitizer
|
|
31
|
+
* const sanitized3 = sanitizeInput(data, (key, value) => {
|
|
32
|
+
* if (key === 'secret') return '[REDACTED]';
|
|
33
|
+
* return value;
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Redaction placeholder tokens
|
|
39
|
+
*/
|
|
40
|
+
export declare const REDACTION_TOKENS: {
|
|
41
|
+
readonly EMAIL: "[EMAIL]";
|
|
42
|
+
readonly PHONE: "[PHONE]";
|
|
43
|
+
readonly CARD: "[CARD]";
|
|
44
|
+
readonly ID: "[ID]";
|
|
45
|
+
readonly IP: "[IP]";
|
|
46
|
+
readonly REDACTED: "[REDACTED]";
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* PII detection patterns
|
|
50
|
+
*/
|
|
51
|
+
export declare const PII_PATTERNS: {
|
|
52
|
+
email: RegExp;
|
|
53
|
+
emailInText: RegExp;
|
|
54
|
+
phone: RegExp;
|
|
55
|
+
phoneInText: RegExp;
|
|
56
|
+
creditCard: RegExp;
|
|
57
|
+
creditCardInText: RegExp;
|
|
58
|
+
ssn: RegExp;
|
|
59
|
+
ssnInText: RegExp;
|
|
60
|
+
ipv4: RegExp;
|
|
61
|
+
ipv4InText: RegExp;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Custom sanitizer function type
|
|
65
|
+
*/
|
|
66
|
+
export type SanitizerFn = (key: string, value: unknown, path: string[]) => unknown;
|
|
67
|
+
/**
|
|
68
|
+
* Sanitizer options
|
|
69
|
+
*/
|
|
70
|
+
export interface SanitizeOptions {
|
|
71
|
+
/**
|
|
72
|
+
* How to handle PII detection:
|
|
73
|
+
* - true: Auto-detect and redact common PII patterns
|
|
74
|
+
* - string[]: Only redact values in fields with these names
|
|
75
|
+
* - SanitizerFn: Custom sanitizer function
|
|
76
|
+
*/
|
|
77
|
+
mode: true | string[] | SanitizerFn;
|
|
78
|
+
/**
|
|
79
|
+
* Maximum depth for recursive sanitization
|
|
80
|
+
* @default 10
|
|
81
|
+
*/
|
|
82
|
+
maxDepth?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Whether to sanitize PII patterns within string values
|
|
85
|
+
* @default true
|
|
86
|
+
*/
|
|
87
|
+
sanitizeInText?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if a string matches an email pattern
|
|
91
|
+
*/
|
|
92
|
+
export declare function isEmail(value: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Check if a string matches a phone pattern
|
|
95
|
+
*/
|
|
96
|
+
export declare function isPhone(value: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Check if a string matches a credit card pattern
|
|
99
|
+
*/
|
|
100
|
+
export declare function isCreditCard(value: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Check if a string matches an SSN pattern
|
|
103
|
+
*/
|
|
104
|
+
export declare function isSSN(value: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Check if a string matches an IPv4 pattern
|
|
107
|
+
*/
|
|
108
|
+
export declare function isIPv4(value: string): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Detect PII type in a string value
|
|
111
|
+
*/
|
|
112
|
+
export declare function detectPIIType(value: string): keyof typeof REDACTION_TOKENS | null;
|
|
113
|
+
/**
|
|
114
|
+
* Redact PII patterns from text
|
|
115
|
+
*/
|
|
116
|
+
export declare function redactPIIFromText(text: string): string;
|
|
117
|
+
/**
|
|
118
|
+
* Sanitize input data by redacting PII.
|
|
119
|
+
*
|
|
120
|
+
* @param input - The input data to sanitize
|
|
121
|
+
* @param mode - Sanitization mode:
|
|
122
|
+
* - `true`: Auto-detect and redact common PII patterns
|
|
123
|
+
* - `string[]`: Redact values in fields with these names
|
|
124
|
+
* - `SanitizerFn`: Custom sanitizer function
|
|
125
|
+
* @returns Sanitized copy of the input
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* // Auto-detect PII
|
|
130
|
+
* sanitizeInput({ email: 'test@example.com' });
|
|
131
|
+
* // { email: '[EMAIL]' }
|
|
132
|
+
*
|
|
133
|
+
* // Redact specific fields
|
|
134
|
+
* sanitizeInput({ password: 'secret', name: 'John' }, ['password']);
|
|
135
|
+
* // { password: '[REDACTED]', name: 'John' }
|
|
136
|
+
*
|
|
137
|
+
* // Custom sanitizer
|
|
138
|
+
* sanitizeInput(data, (key, value) => key === 'token' ? '[TOKEN]' : value);
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare function sanitizeInput(input: Record<string, unknown>, mode?: true | string[] | SanitizerFn): Record<string, unknown>;
|
|
142
|
+
/**
|
|
143
|
+
* Create a reusable sanitizer function with preset options.
|
|
144
|
+
*
|
|
145
|
+
* @param mode - Sanitization mode
|
|
146
|
+
* @returns Sanitizer function
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const sanitizer = createSanitizer(['email', 'phone', 'ssn']);
|
|
151
|
+
*
|
|
152
|
+
* const clean1 = sanitizer(userData1);
|
|
153
|
+
* const clean2 = sanitizer(userData2);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare function createSanitizer(mode?: true | string[] | SanitizerFn): (input: Record<string, unknown>) => Record<string, unknown>;
|
|
157
|
+
/**
|
|
158
|
+
* Check if an object contains any detected PII.
|
|
159
|
+
* Does not modify the input.
|
|
160
|
+
*
|
|
161
|
+
* @param input - The input to check
|
|
162
|
+
* @param options - Optional configuration
|
|
163
|
+
* @param options.maxDepth - Maximum recursion depth (default: 10)
|
|
164
|
+
* @returns Object with boolean `hasPII` and `fields` array of field paths
|
|
165
|
+
*/
|
|
166
|
+
export declare function detectPII(input: Record<string, unknown>, options?: {
|
|
167
|
+
maxDepth?: number;
|
|
168
|
+
}): {
|
|
169
|
+
hasPII: boolean;
|
|
170
|
+
fields: string[];
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=sanitizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../../src/runtime/sanitizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;CA8BxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,GAAG,WAAW,CAAC;IAEpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAInD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,OAAO,gBAAgB,GAAG,IAAI,CAOjF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWtD;AA0FD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,IAAI,GAAE,IAAI,GAAG,MAAM,EAAE,GAAG,WAAkB,GACzC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAczB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,IAAI,GAAE,IAAI,GAAG,MAAM,EAAE,GAAG,WAAkB,GACzC,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9B;IACD,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CA0CA"}
|