@frontmcp/ui 0.5.1 → 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/README.md +140 -362
- package/bridge/adapters/base-adapter.d.ts +104 -0
- package/bridge/adapters/base-adapter.d.ts.map +1 -0
- package/bridge/adapters/claude.adapter.d.ts +67 -0
- package/bridge/adapters/claude.adapter.d.ts.map +1 -0
- package/bridge/adapters/ext-apps.adapter.d.ts +143 -0
- package/bridge/adapters/ext-apps.adapter.d.ts.map +1 -0
- package/bridge/adapters/gemini.adapter.d.ts +64 -0
- package/bridge/adapters/gemini.adapter.d.ts.map +1 -0
- package/bridge/adapters/generic.adapter.d.ts +56 -0
- package/bridge/adapters/generic.adapter.d.ts.map +1 -0
- package/bridge/adapters/index.d.ts +26 -0
- package/bridge/adapters/index.d.ts.map +1 -0
- package/bridge/adapters/openai.adapter.d.ts +65 -0
- package/bridge/adapters/openai.adapter.d.ts.map +1 -0
- package/bridge/core/adapter-registry.d.ts +122 -0
- package/bridge/core/adapter-registry.d.ts.map +1 -0
- package/bridge/core/bridge-factory.d.ts +199 -0
- package/bridge/core/bridge-factory.d.ts.map +1 -0
- package/bridge/core/index.d.ts +10 -0
- package/bridge/core/index.d.ts.map +1 -0
- package/bridge/index.d.ts +62 -0
- package/bridge/index.d.ts.map +1 -0
- package/bridge/index.js +2540 -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/types.d.ts +386 -0
- package/bridge/types.d.ts.map +1 -0
- package/bundler/bundler.d.ts +208 -0
- package/bundler/bundler.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 +43 -0
- package/bundler/index.d.ts.map +1 -0
- package/bundler/index.js +3707 -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/components/alert.d.ts +66 -0
- package/components/alert.d.ts.map +1 -0
- package/components/alert.schema.d.ts +98 -0
- package/components/alert.schema.d.ts.map +1 -0
- package/components/avatar.d.ts +77 -0
- package/components/avatar.d.ts.map +1 -0
- package/components/avatar.schema.d.ts +170 -0
- package/components/avatar.schema.d.ts.map +1 -0
- package/components/badge.d.ts +64 -0
- package/components/badge.d.ts.map +1 -0
- package/components/badge.schema.d.ts +91 -0
- package/components/badge.schema.d.ts.map +1 -0
- package/components/button.d.ts +100 -0
- package/components/button.d.ts.map +1 -0
- package/components/button.schema.d.ts +120 -0
- package/components/button.schema.d.ts.map +1 -0
- package/components/card.d.ts +53 -0
- package/components/card.d.ts.map +1 -0
- package/components/card.schema.d.ts +93 -0
- package/components/card.schema.d.ts.map +1 -0
- package/components/form.d.ts +212 -0
- package/components/form.d.ts.map +1 -0
- package/components/form.schema.d.ts +365 -0
- package/components/form.schema.d.ts.map +1 -0
- package/components/index.d.ts +29 -0
- package/components/index.d.ts.map +1 -0
- package/components/index.js +2525 -0
- package/components/list.d.ts +121 -0
- package/components/list.d.ts.map +1 -0
- package/components/list.schema.d.ts +129 -0
- package/components/list.schema.d.ts.map +1 -0
- package/components/modal.d.ts +100 -0
- package/components/modal.d.ts.map +1 -0
- package/components/modal.schema.d.ts +151 -0
- package/components/modal.schema.d.ts.map +1 -0
- package/components/table.d.ts +91 -0
- package/components/table.d.ts.map +1 -0
- package/components/table.schema.d.ts +123 -0
- package/components/table.schema.d.ts.map +1 -0
- package/esm/bridge/adapters/base-adapter.d.ts +104 -0
- package/esm/bridge/adapters/base-adapter.d.ts.map +1 -0
- package/esm/bridge/adapters/claude.adapter.d.ts +67 -0
- package/esm/bridge/adapters/claude.adapter.d.ts.map +1 -0
- package/esm/bridge/adapters/ext-apps.adapter.d.ts +143 -0
- package/esm/bridge/adapters/ext-apps.adapter.d.ts.map +1 -0
- package/esm/bridge/adapters/gemini.adapter.d.ts +64 -0
- package/esm/bridge/adapters/gemini.adapter.d.ts.map +1 -0
- package/esm/bridge/adapters/generic.adapter.d.ts +56 -0
- package/esm/bridge/adapters/generic.adapter.d.ts.map +1 -0
- package/esm/bridge/adapters/index.d.ts +26 -0
- package/esm/bridge/adapters/index.d.ts.map +1 -0
- package/esm/bridge/adapters/openai.adapter.d.ts +65 -0
- package/esm/bridge/adapters/openai.adapter.d.ts.map +1 -0
- package/esm/bridge/core/adapter-registry.d.ts +122 -0
- package/esm/bridge/core/adapter-registry.d.ts.map +1 -0
- package/esm/bridge/core/bridge-factory.d.ts +199 -0
- package/esm/bridge/core/bridge-factory.d.ts.map +1 -0
- package/esm/bridge/core/index.d.ts +10 -0
- package/esm/bridge/core/index.d.ts.map +1 -0
- package/esm/bridge/index.d.ts +62 -0
- package/esm/bridge/index.d.ts.map +1 -0
- package/esm/bridge/index.js +2487 -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/types.d.ts +386 -0
- package/esm/bridge/types.d.ts.map +1 -0
- package/esm/bundler/bundler.d.ts +208 -0
- package/esm/bundler/bundler.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 +43 -0
- package/esm/bundler/index.d.ts.map +1 -0
- package/esm/bundler/index.js +3640 -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/components/alert.d.ts +66 -0
- package/esm/components/alert.d.ts.map +1 -0
- package/esm/components/alert.schema.d.ts +98 -0
- package/esm/components/alert.schema.d.ts.map +1 -0
- package/esm/components/avatar.d.ts +77 -0
- package/esm/components/avatar.d.ts.map +1 -0
- package/esm/components/avatar.schema.d.ts +170 -0
- package/esm/components/avatar.schema.d.ts.map +1 -0
- package/esm/components/badge.d.ts +64 -0
- package/esm/components/badge.d.ts.map +1 -0
- package/esm/components/badge.schema.d.ts +91 -0
- package/esm/components/badge.schema.d.ts.map +1 -0
- package/esm/components/button.d.ts +100 -0
- package/esm/components/button.d.ts.map +1 -0
- package/esm/components/button.schema.d.ts +120 -0
- package/esm/components/button.schema.d.ts.map +1 -0
- package/esm/components/card.d.ts +53 -0
- package/esm/components/card.d.ts.map +1 -0
- package/esm/components/card.schema.d.ts +93 -0
- package/esm/components/card.schema.d.ts.map +1 -0
- package/esm/components/form.d.ts +212 -0
- package/esm/components/form.d.ts.map +1 -0
- package/esm/components/form.schema.d.ts +365 -0
- package/esm/components/form.schema.d.ts.map +1 -0
- package/esm/components/index.d.ts +29 -0
- package/esm/components/index.d.ts.map +1 -0
- package/esm/components/index.js +2396 -0
- package/esm/components/list.d.ts +121 -0
- package/esm/components/list.d.ts.map +1 -0
- package/esm/components/list.schema.d.ts +129 -0
- package/esm/components/list.schema.d.ts.map +1 -0
- package/esm/components/modal.d.ts +100 -0
- package/esm/components/modal.d.ts.map +1 -0
- package/esm/components/modal.schema.d.ts +151 -0
- package/esm/components/modal.schema.d.ts.map +1 -0
- package/esm/components/table.d.ts +91 -0
- package/esm/components/table.d.ts.map +1 -0
- package/esm/components/table.schema.d.ts +123 -0
- package/esm/components/table.schema.d.ts.map +1 -0
- package/esm/index.d.ts +40 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +8326 -0
- package/esm/layouts/base.d.ts +86 -0
- package/esm/layouts/base.d.ts.map +1 -0
- package/esm/layouts/index.d.ts +8 -0
- package/esm/layouts/index.d.ts.map +1 -0
- package/esm/layouts/index.js +409 -0
- package/esm/layouts/presets.d.ts +134 -0
- package/esm/layouts/presets.d.ts.map +1 -0
- package/esm/package.json +72 -0
- package/esm/pages/consent.d.ts +117 -0
- package/esm/pages/consent.d.ts.map +1 -0
- package/esm/pages/error.d.ts +101 -0
- package/esm/pages/error.d.ts.map +1 -0
- package/esm/pages/index.d.ts +9 -0
- package/esm/pages/index.d.ts.map +1 -0
- package/esm/pages/index.js +1036 -0
- package/esm/react/Alert.d.ts +101 -0
- package/esm/react/Alert.d.ts.map +1 -0
- package/esm/react/Badge.d.ts +100 -0
- package/esm/react/Badge.d.ts.map +1 -0
- package/esm/react/Button.d.ts +108 -0
- package/esm/react/Button.d.ts.map +1 -0
- package/esm/react/Card.d.ts +103 -0
- package/esm/react/Card.d.ts.map +1 -0
- package/esm/react/hooks/context.d.ts +179 -0
- package/esm/react/hooks/context.d.ts.map +1 -0
- package/esm/react/hooks/index.d.ts +42 -0
- package/esm/react/hooks/index.d.ts.map +1 -0
- package/esm/react/hooks/tools.d.ts +284 -0
- package/esm/react/hooks/tools.d.ts.map +1 -0
- package/esm/react/index.d.ts +80 -0
- package/esm/react/index.d.ts.map +1 -0
- package/esm/react/index.js +3124 -0
- package/esm/react/types.d.ts +105 -0
- package/esm/react/types.d.ts.map +1 -0
- package/esm/react/utils.d.ts +43 -0
- package/esm/react/utils.d.ts.map +1 -0
- package/esm/render/index.d.ts +8 -0
- package/esm/render/index.d.ts.map +1 -0
- package/esm/render/index.js +45 -0
- package/esm/render/prerender.d.ts +57 -0
- package/esm/render/prerender.d.ts.map +1 -0
- package/esm/renderers/index.d.ts +21 -0
- package/esm/renderers/index.d.ts.map +1 -0
- package/esm/renderers/index.js +381 -0
- package/esm/renderers/react.adapter.d.ts +70 -0
- package/esm/renderers/react.adapter.d.ts.map +1 -0
- package/esm/renderers/react.renderer.d.ts +96 -0
- package/esm/renderers/react.renderer.d.ts.map +1 -0
- package/esm/universal/UniversalApp.d.ts +108 -0
- package/esm/universal/UniversalApp.d.ts.map +1 -0
- package/esm/universal/cached-runtime.d.ts +115 -0
- package/esm/universal/cached-runtime.d.ts.map +1 -0
- package/esm/universal/context.d.ts +122 -0
- package/esm/universal/context.d.ts.map +1 -0
- package/esm/universal/index.d.ts +57 -0
- package/esm/universal/index.d.ts.map +1 -0
- package/esm/universal/index.js +1755 -0
- package/esm/universal/renderers/html.renderer.d.ts +37 -0
- package/esm/universal/renderers/html.renderer.d.ts.map +1 -0
- package/esm/universal/renderers/index.d.ts +112 -0
- package/esm/universal/renderers/index.d.ts.map +1 -0
- package/esm/universal/renderers/markdown.renderer.d.ts +33 -0
- package/esm/universal/renderers/markdown.renderer.d.ts.map +1 -0
- package/esm/universal/renderers/mdx.renderer.d.ts +38 -0
- package/esm/universal/renderers/mdx.renderer.d.ts.map +1 -0
- package/esm/universal/renderers/react.renderer.d.ts +46 -0
- package/esm/universal/renderers/react.renderer.d.ts.map +1 -0
- package/esm/universal/runtime-builder.d.ts +33 -0
- package/esm/universal/runtime-builder.d.ts.map +1 -0
- package/esm/universal/store.d.ts +135 -0
- package/esm/universal/store.d.ts.map +1 -0
- package/esm/universal/types.d.ts +199 -0
- package/esm/universal/types.d.ts.map +1 -0
- package/esm/web-components/core/attribute-parser.d.ts +82 -0
- package/esm/web-components/core/attribute-parser.d.ts.map +1 -0
- package/esm/web-components/core/base-element.d.ts +197 -0
- package/esm/web-components/core/base-element.d.ts.map +1 -0
- package/esm/web-components/core/index.d.ts +9 -0
- package/esm/web-components/core/index.d.ts.map +1 -0
- package/esm/web-components/elements/fmcp-alert.d.ts +46 -0
- package/esm/web-components/elements/fmcp-alert.d.ts.map +1 -0
- package/esm/web-components/elements/fmcp-badge.d.ts +47 -0
- package/esm/web-components/elements/fmcp-badge.d.ts.map +1 -0
- package/esm/web-components/elements/fmcp-button.d.ts +117 -0
- package/esm/web-components/elements/fmcp-button.d.ts.map +1 -0
- package/esm/web-components/elements/fmcp-card.d.ts +53 -0
- package/esm/web-components/elements/fmcp-card.d.ts.map +1 -0
- package/esm/web-components/elements/fmcp-input.d.ts +96 -0
- package/esm/web-components/elements/fmcp-input.d.ts.map +1 -0
- package/esm/web-components/elements/fmcp-select.d.ts +100 -0
- package/esm/web-components/elements/fmcp-select.d.ts.map +1 -0
- package/esm/web-components/elements/index.d.ts +13 -0
- package/esm/web-components/elements/index.d.ts.map +1 -0
- package/esm/web-components/index.d.ts +50 -0
- package/esm/web-components/index.d.ts.map +1 -0
- package/esm/web-components/index.js +1993 -0
- package/esm/web-components/register.d.ts +57 -0
- package/esm/web-components/register.d.ts.map +1 -0
- package/esm/web-components/types.d.ts +122 -0
- package/esm/web-components/types.d.ts.map +1 -0
- package/esm/widgets/index.d.ts +8 -0
- package/esm/widgets/index.d.ts.map +1 -0
- package/esm/widgets/index.js +883 -0
- package/esm/widgets/progress.d.ts +133 -0
- package/esm/widgets/progress.d.ts.map +1 -0
- package/esm/widgets/resource.d.ts +163 -0
- package/esm/widgets/resource.d.ts.map +1 -0
- package/index.d.ts +40 -0
- package/index.d.ts.map +1 -0
- package/index.js +8526 -0
- package/layouts/base.d.ts +86 -0
- package/layouts/base.d.ts.map +1 -0
- package/layouts/index.d.ts +8 -0
- package/layouts/index.d.ts.map +1 -0
- package/layouts/index.js +437 -0
- package/layouts/presets.d.ts +134 -0
- package/layouts/presets.d.ts.map +1 -0
- package/package.json +33 -110
- package/pages/consent.d.ts +117 -0
- package/pages/consent.d.ts.map +1 -0
- package/pages/error.d.ts +101 -0
- package/pages/error.d.ts.map +1 -0
- package/pages/index.d.ts +9 -0
- package/pages/index.d.ts.map +1 -0
- package/pages/index.js +1065 -0
- package/react/Alert.d.ts +101 -0
- package/react/Alert.d.ts.map +1 -0
- package/react/Badge.d.ts +100 -0
- package/react/Badge.d.ts.map +1 -0
- package/react/Button.d.ts +108 -0
- package/react/Button.d.ts.map +1 -0
- package/react/Card.d.ts +103 -0
- package/react/Card.d.ts.map +1 -0
- package/react/hooks/context.d.ts +179 -0
- package/react/hooks/context.d.ts.map +1 -0
- package/react/hooks/index.d.ts +42 -0
- package/react/hooks/index.d.ts.map +1 -0
- package/react/hooks/tools.d.ts +284 -0
- package/react/hooks/tools.d.ts.map +1 -0
- package/react/index.d.ts +80 -0
- package/react/index.d.ts.map +1 -0
- package/react/index.js +3160 -0
- package/react/types.d.ts +105 -0
- package/react/types.d.ts.map +1 -0
- package/react/utils.d.ts +43 -0
- package/react/utils.d.ts.map +1 -0
- package/render/index.d.ts +8 -0
- package/render/index.d.ts.map +1 -0
- package/render/index.js +77 -0
- package/render/prerender.d.ts +57 -0
- package/render/prerender.d.ts.map +1 -0
- package/renderers/index.d.ts +21 -0
- package/renderers/index.d.ts.map +1 -0
- package/renderers/index.js +416 -0
- package/renderers/react.adapter.d.ts +70 -0
- package/renderers/react.adapter.d.ts.map +1 -0
- package/renderers/react.renderer.d.ts +96 -0
- package/renderers/react.renderer.d.ts.map +1 -0
- package/universal/UniversalApp.d.ts +108 -0
- package/universal/UniversalApp.d.ts.map +1 -0
- package/universal/cached-runtime.d.ts +115 -0
- package/universal/cached-runtime.d.ts.map +1 -0
- package/universal/context.d.ts +122 -0
- package/universal/context.d.ts.map +1 -0
- package/universal/index.d.ts +57 -0
- package/universal/index.d.ts.map +1 -0
- package/universal/index.js +1841 -0
- package/universal/renderers/html.renderer.d.ts +37 -0
- package/universal/renderers/html.renderer.d.ts.map +1 -0
- package/universal/renderers/index.d.ts +112 -0
- package/universal/renderers/index.d.ts.map +1 -0
- package/universal/renderers/markdown.renderer.d.ts +33 -0
- package/universal/renderers/markdown.renderer.d.ts.map +1 -0
- package/universal/renderers/mdx.renderer.d.ts +38 -0
- package/universal/renderers/mdx.renderer.d.ts.map +1 -0
- package/universal/renderers/react.renderer.d.ts +46 -0
- package/universal/renderers/react.renderer.d.ts.map +1 -0
- package/universal/runtime-builder.d.ts +33 -0
- package/universal/runtime-builder.d.ts.map +1 -0
- package/universal/store.d.ts +135 -0
- package/universal/store.d.ts.map +1 -0
- package/universal/types.d.ts +199 -0
- package/universal/types.d.ts.map +1 -0
- package/web-components/core/attribute-parser.d.ts +82 -0
- package/web-components/core/attribute-parser.d.ts.map +1 -0
- package/web-components/core/base-element.d.ts +197 -0
- package/web-components/core/base-element.d.ts.map +1 -0
- package/web-components/core/index.d.ts +9 -0
- package/web-components/core/index.d.ts.map +1 -0
- package/web-components/elements/fmcp-alert.d.ts +46 -0
- package/web-components/elements/fmcp-alert.d.ts.map +1 -0
- package/web-components/elements/fmcp-badge.d.ts +47 -0
- package/web-components/elements/fmcp-badge.d.ts.map +1 -0
- package/web-components/elements/fmcp-button.d.ts +117 -0
- package/web-components/elements/fmcp-button.d.ts.map +1 -0
- package/web-components/elements/fmcp-card.d.ts +53 -0
- package/web-components/elements/fmcp-card.d.ts.map +1 -0
- package/web-components/elements/fmcp-input.d.ts +96 -0
- package/web-components/elements/fmcp-input.d.ts.map +1 -0
- package/web-components/elements/fmcp-select.d.ts +100 -0
- package/web-components/elements/fmcp-select.d.ts.map +1 -0
- package/web-components/elements/index.d.ts +13 -0
- package/web-components/elements/index.d.ts.map +1 -0
- package/web-components/index.d.ts +50 -0
- package/web-components/index.d.ts.map +1 -0
- package/web-components/index.js +2028 -0
- package/web-components/register.d.ts +57 -0
- package/web-components/register.d.ts.map +1 -0
- package/web-components/types.d.ts +122 -0
- package/web-components/types.d.ts.map +1 -0
- package/widgets/index.d.ts +8 -0
- package/widgets/index.d.ts.map +1 -0
- package/widgets/index.js +910 -0
- package/widgets/progress.d.ts +133 -0
- package/widgets/progress.d.ts.map +1 -0
- package/widgets/resource.d.ts +163 -0
- package/widgets/resource.d.ts.map +1 -0
- package/src/adapters/index.d.ts +0 -10
- package/src/adapters/index.js +0 -18
- package/src/adapters/index.js.map +0 -1
- package/src/adapters/platform-meta.d.ts +0 -165
- package/src/adapters/platform-meta.js +0 -310
- package/src/adapters/platform-meta.js.map +0 -1
- package/src/base-template/bridge.d.ts +0 -89
- package/src/base-template/bridge.js +0 -452
- package/src/base-template/bridge.js.map +0 -1
- package/src/base-template/default-base-template.d.ts +0 -91
- package/src/base-template/default-base-template.js +0 -435
- package/src/base-template/default-base-template.js.map +0 -1
- package/src/base-template/index.d.ts +0 -14
- package/src/base-template/index.js +0 -30
- package/src/base-template/index.js.map +0 -1
- package/src/base-template/polyfills.d.ts +0 -30
- package/src/base-template/polyfills.js +0 -190
- package/src/base-template/polyfills.js.map +0 -1
- package/src/base-template/theme-styles.d.ts +0 -73
- package/src/base-template/theme-styles.js +0 -95
- package/src/base-template/theme-styles.js.map +0 -1
- package/src/bridge/adapters/base-adapter.d.ts +0 -103
- package/src/bridge/adapters/base-adapter.js +0 -314
- package/src/bridge/adapters/base-adapter.js.map +0 -1
- package/src/bridge/adapters/claude.adapter.d.ts +0 -66
- package/src/bridge/adapters/claude.adapter.js +0 -145
- package/src/bridge/adapters/claude.adapter.js.map +0 -1
- package/src/bridge/adapters/ext-apps.adapter.d.ts +0 -142
- package/src/bridge/adapters/ext-apps.adapter.js +0 -416
- package/src/bridge/adapters/ext-apps.adapter.js.map +0 -1
- package/src/bridge/adapters/gemini.adapter.d.ts +0 -63
- package/src/bridge/adapters/gemini.adapter.js +0 -160
- package/src/bridge/adapters/gemini.adapter.js.map +0 -1
- package/src/bridge/adapters/generic.adapter.d.ts +0 -55
- package/src/bridge/adapters/generic.adapter.js +0 -108
- package/src/bridge/adapters/generic.adapter.js.map +0 -1
- package/src/bridge/adapters/index.d.ts +0 -25
- package/src/bridge/adapters/index.js +0 -65
- package/src/bridge/adapters/index.js.map +0 -1
- package/src/bridge/adapters/openai.adapter.d.ts +0 -64
- package/src/bridge/adapters/openai.adapter.js +0 -194
- package/src/bridge/adapters/openai.adapter.js.map +0 -1
- package/src/bridge/core/adapter-registry.d.ts +0 -121
- package/src/bridge/core/adapter-registry.js +0 -271
- package/src/bridge/core/adapter-registry.js.map +0 -1
- package/src/bridge/core/bridge-factory.d.ts +0 -198
- package/src/bridge/core/bridge-factory.js +0 -428
- package/src/bridge/core/bridge-factory.js.map +0 -1
- package/src/bridge/core/index.d.ts +0 -9
- package/src/bridge/core/index.js +0 -22
- package/src/bridge/core/index.js.map +0 -1
- package/src/bridge/index.d.ts +0 -61
- package/src/bridge/index.js +0 -94
- package/src/bridge/index.js.map +0 -1
- package/src/bridge/runtime/iife-generator.d.ts +0 -61
- package/src/bridge/runtime/iife-generator.js +0 -940
- package/src/bridge/runtime/iife-generator.js.map +0 -1
- package/src/bridge/runtime/index.d.ts +0 -8
- package/src/bridge/runtime/index.js +0 -16
- package/src/bridge/runtime/index.js.map +0 -1
- package/src/bridge/types.d.ts +0 -385
- package/src/bridge/types.js +0 -11
- package/src/bridge/types.js.map +0 -1
- package/src/build/cdn-resources.d.ts +0 -140
- package/src/build/cdn-resources.js +0 -314
- package/src/build/cdn-resources.js.map +0 -1
- package/src/build/index.d.ts +0 -294
- package/src/build/index.js +0 -325
- package/src/build/index.js.map +0 -1
- package/src/build/widget-manifest.d.ts +0 -212
- package/src/build/widget-manifest.js +0 -652
- package/src/build/widget-manifest.js.map +0 -1
- package/src/bundler/bundler.d.ts +0 -110
- package/src/bundler/bundler.js +0 -432
- package/src/bundler/bundler.js.map +0 -1
- package/src/bundler/cache.d.ts +0 -172
- package/src/bundler/cache.js +0 -250
- package/src/bundler/cache.js.map +0 -1
- package/src/bundler/index.d.ts +0 -41
- package/src/bundler/index.js +0 -73
- package/src/bundler/index.js.map +0 -1
- package/src/bundler/sandbox/enclave-adapter.d.ts +0 -120
- package/src/bundler/sandbox/enclave-adapter.js +0 -339
- package/src/bundler/sandbox/enclave-adapter.js.map +0 -1
- package/src/bundler/sandbox/executor.d.ts +0 -13
- package/src/bundler/sandbox/executor.js +0 -22
- package/src/bundler/sandbox/executor.js.map +0 -1
- package/src/bundler/sandbox/policy.d.ts +0 -61
- package/src/bundler/sandbox/policy.js +0 -238
- package/src/bundler/sandbox/policy.js.map +0 -1
- package/src/bundler/types.d.ts +0 -347
- package/src/bundler/types.js +0 -132
- package/src/bundler/types.js.map +0 -1
- package/src/components/alert.d.ts +0 -71
- package/src/components/alert.js +0 -189
- package/src/components/alert.js.map +0 -1
- package/src/components/alert.schema.d.ts +0 -114
- package/src/components/alert.schema.js +0 -105
- package/src/components/alert.schema.js.map +0 -1
- package/src/components/avatar.d.ts +0 -76
- package/src/components/avatar.js +0 -176
- package/src/components/avatar.js.map +0 -1
- package/src/components/avatar.schema.d.ts +0 -169
- package/src/components/avatar.schema.js +0 -103
- package/src/components/avatar.schema.js.map +0 -1
- package/src/components/badge.d.ts +0 -70
- package/src/components/badge.js +0 -149
- package/src/components/badge.js.map +0 -1
- package/src/components/badge.schema.d.ts +0 -109
- package/src/components/badge.schema.js +0 -96
- package/src/components/badge.schema.js.map +0 -1
- package/src/components/button.d.ts +0 -111
- package/src/components/button.js +0 -336
- package/src/components/button.js.map +0 -1
- package/src/components/button.schema.d.ts +0 -148
- package/src/components/button.schema.js +0 -121
- package/src/components/button.schema.js.map +0 -1
- package/src/components/card.d.ts +0 -60
- package/src/components/card.js +0 -117
- package/src/components/card.js.map +0 -1
- package/src/components/card.schema.d.ts +0 -113
- package/src/components/card.schema.js +0 -98
- package/src/components/card.schema.js.map +0 -1
- package/src/components/form.d.ts +0 -239
- package/src/components/form.js +0 -420
- package/src/components/form.js.map +0 -1
- package/src/components/form.schema.d.ts +0 -441
- package/src/components/form.schema.js +0 -406
- package/src/components/form.schema.js.map +0 -1
- package/src/components/index.d.ts +0 -29
- package/src/components/index.js +0 -98
- package/src/components/index.js.map +0 -1
- package/src/components/list.d.ts +0 -127
- package/src/components/list.js +0 -279
- package/src/components/list.js.map +0 -1
- package/src/components/list.schema.d.ts +0 -134
- package/src/components/list.schema.js +0 -168
- package/src/components/list.schema.js.map +0 -1
- package/src/components/modal.d.ts +0 -111
- package/src/components/modal.js +0 -260
- package/src/components/modal.js.map +0 -1
- package/src/components/modal.schema.d.ts +0 -186
- package/src/components/modal.schema.js +0 -167
- package/src/components/modal.schema.js.map +0 -1
- package/src/components/table.d.ts +0 -105
- package/src/components/table.js +0 -283
- package/src/components/table.js.map +0 -1
- package/src/components/table.schema.d.ts +0 -159
- package/src/components/table.schema.js +0 -173
- package/src/components/table.schema.js.map +0 -1
- package/src/handlebars/helpers.d.ts +0 -348
- package/src/handlebars/helpers.js +0 -605
- package/src/handlebars/helpers.js.map +0 -1
- package/src/handlebars/index.d.ts +0 -193
- package/src/handlebars/index.js +0 -350
- package/src/handlebars/index.js.map +0 -1
- package/src/index.d.ts +0 -50
- package/src/index.js +0 -192
- package/src/index.js.map +0 -1
- package/src/layouts/base.d.ts +0 -88
- package/src/layouts/base.js +0 -227
- package/src/layouts/base.js.map +0 -1
- package/src/layouts/index.d.ts +0 -7
- package/src/layouts/index.js +0 -25
- package/src/layouts/index.js.map +0 -1
- package/src/layouts/presets.d.ts +0 -133
- package/src/layouts/presets.js +0 -277
- package/src/layouts/presets.js.map +0 -1
- package/src/pages/consent.d.ts +0 -116
- package/src/pages/consent.js +0 -218
- package/src/pages/consent.js.map +0 -1
- package/src/pages/error.d.ts +0 -100
- package/src/pages/error.js +0 -263
- package/src/pages/error.js.map +0 -1
- package/src/pages/index.d.ts +0 -8
- package/src/pages/index.js +0 -27
- package/src/pages/index.js.map +0 -1
- package/src/react/Alert.d.ts +0 -101
- package/src/react/Alert.js +0 -51
- package/src/react/Alert.js.map +0 -1
- package/src/react/Badge.d.ts +0 -100
- package/src/react/Badge.js +0 -55
- package/src/react/Badge.js.map +0 -1
- package/src/react/Button.d.ts +0 -108
- package/src/react/Button.js +0 -52
- package/src/react/Button.js.map +0 -1
- package/src/react/Card.d.ts +0 -103
- package/src/react/Card.js +0 -55
- package/src/react/Card.js.map +0 -1
- package/src/react/hooks/context.d.ts +0 -178
- package/src/react/hooks/context.js +0 -287
- package/src/react/hooks/context.js.map +0 -1
- package/src/react/hooks/index.d.ts +0 -41
- package/src/react/hooks/index.js +0 -61
- package/src/react/hooks/index.js.map +0 -1
- package/src/react/hooks/tools.d.ts +0 -283
- package/src/react/hooks/tools.js +0 -465
- package/src/react/hooks/tools.js.map +0 -1
- package/src/react/index.d.ts +0 -80
- package/src/react/index.js +0 -113
- package/src/react/index.js.map +0 -1
- package/src/react/types.d.ts +0 -105
- package/src/react/types.js +0 -12
- package/src/react/types.js.map +0 -1
- package/src/react/utils.d.ts +0 -42
- package/src/react/utils.js +0 -99
- package/src/react/utils.js.map +0 -1
- package/src/registry/index.d.ts +0 -45
- package/src/registry/index.js +0 -67
- package/src/registry/index.js.map +0 -1
- package/src/registry/render-template.d.ts +0 -86
- package/src/registry/render-template.js +0 -239
- package/src/registry/render-template.js.map +0 -1
- package/src/registry/tool-ui.registry.d.ts +0 -260
- package/src/registry/tool-ui.registry.js +0 -438
- package/src/registry/tool-ui.registry.js.map +0 -1
- package/src/registry/uri-utils.d.ts +0 -55
- package/src/registry/uri-utils.js +0 -97
- package/src/registry/uri-utils.js.map +0 -1
- package/src/render/index.d.ts +0 -7
- package/src/render/index.js +0 -14
- package/src/render/index.js.map +0 -1
- package/src/render/prerender.d.ts +0 -56
- package/src/render/prerender.js +0 -98
- package/src/render/prerender.js.map +0 -1
- package/src/renderers/cache.d.ts +0 -144
- package/src/renderers/cache.js +0 -240
- package/src/renderers/cache.js.map +0 -1
- package/src/renderers/html.renderer.d.ts +0 -122
- package/src/renderers/html.renderer.js +0 -204
- package/src/renderers/html.renderer.js.map +0 -1
- package/src/renderers/index.d.ts +0 -35
- package/src/renderers/index.js +0 -70
- package/src/renderers/index.js.map +0 -1
- package/src/renderers/mdx.renderer.d.ts +0 -119
- package/src/renderers/mdx.renderer.js +0 -305
- package/src/renderers/mdx.renderer.js.map +0 -1
- package/src/renderers/react.renderer.d.ts +0 -95
- package/src/renderers/react.renderer.js +0 -260
- package/src/renderers/react.renderer.js.map +0 -1
- package/src/renderers/registry.d.ts +0 -133
- package/src/renderers/registry.js +0 -232
- package/src/renderers/registry.js.map +0 -1
- package/src/renderers/types.d.ts +0 -341
- package/src/renderers/types.js +0 -9
- package/src/renderers/types.js.map +0 -1
- package/src/renderers/utils/detect.d.ts +0 -106
- package/src/renderers/utils/detect.js +0 -267
- package/src/renderers/utils/detect.js.map +0 -1
- package/src/renderers/utils/hash.d.ts +0 -39
- package/src/renderers/utils/hash.js +0 -75
- package/src/renderers/utils/hash.js.map +0 -1
- package/src/renderers/utils/index.d.ts +0 -8
- package/src/renderers/utils/index.js +0 -28
- package/src/renderers/utils/index.js.map +0 -1
- package/src/renderers/utils/transpiler.d.ts +0 -88
- package/src/renderers/utils/transpiler.js +0 -215
- package/src/renderers/utils/transpiler.js.map +0 -1
- package/src/runtime/adapters/html.adapter.d.ts +0 -58
- package/src/runtime/adapters/html.adapter.js +0 -131
- package/src/runtime/adapters/html.adapter.js.map +0 -1
- package/src/runtime/adapters/index.d.ts +0 -25
- package/src/runtime/adapters/index.js +0 -54
- package/src/runtime/adapters/index.js.map +0 -1
- package/src/runtime/adapters/mdx.adapter.d.ts +0 -72
- package/src/runtime/adapters/mdx.adapter.js +0 -241
- package/src/runtime/adapters/mdx.adapter.js.map +0 -1
- package/src/runtime/adapters/react.adapter.d.ts +0 -69
- package/src/runtime/adapters/react.adapter.js +0 -245
- package/src/runtime/adapters/react.adapter.js.map +0 -1
- package/src/runtime/adapters/types.d.ts +0 -94
- package/src/runtime/adapters/types.js +0 -11
- package/src/runtime/adapters/types.js.map +0 -1
- package/src/runtime/csp.d.ts +0 -37
- package/src/runtime/csp.js +0 -140
- package/src/runtime/csp.js.map +0 -1
- package/src/runtime/index.d.ts +0 -16
- package/src/runtime/index.js +0 -72
- package/src/runtime/index.js.map +0 -1
- package/src/runtime/mcp-bridge.d.ts +0 -100
- package/src/runtime/mcp-bridge.js +0 -581
- package/src/runtime/mcp-bridge.js.map +0 -1
- package/src/runtime/renderer-runtime.d.ts +0 -132
- package/src/runtime/renderer-runtime.js +0 -389
- package/src/runtime/renderer-runtime.js.map +0 -1
- package/src/runtime/sanitizer.d.ts +0 -171
- package/src/runtime/sanitizer.js +0 -318
- package/src/runtime/sanitizer.js.map +0 -1
- package/src/runtime/types.d.ts +0 -414
- package/src/runtime/types.js +0 -12
- package/src/runtime/types.js.map +0 -1
- package/src/runtime/wrapper.d.ts +0 -375
- package/src/runtime/wrapper.js +0 -1793
- package/src/runtime/wrapper.js.map +0 -1
- package/src/styles/index.d.ts +0 -7
- package/src/styles/index.js +0 -11
- package/src/styles/index.js.map +0 -1
- package/src/styles/variants.d.ts +0 -50
- package/src/styles/variants.js +0 -175
- package/src/styles/variants.js.map +0 -1
- package/src/theme/cdn.d.ts +0 -194
- package/src/theme/cdn.js +0 -375
- package/src/theme/cdn.js.map +0 -1
- package/src/theme/index.d.ts +0 -17
- package/src/theme/index.js +0 -57
- package/src/theme/index.js.map +0 -1
- package/src/theme/platforms.d.ts +0 -106
- package/src/theme/platforms.js +0 -161
- package/src/theme/platforms.js.map +0 -1
- package/src/theme/presets/github-openai.d.ts +0 -49
- package/src/theme/presets/github-openai.js +0 -189
- package/src/theme/presets/github-openai.js.map +0 -1
- package/src/theme/presets/index.d.ts +0 -10
- package/src/theme/presets/index.js +0 -17
- package/src/theme/presets/index.js.map +0 -1
- package/src/theme/theme.d.ts +0 -395
- package/src/theme/theme.js +0 -332
- package/src/theme/theme.js.map +0 -1
- package/src/tool-template/builder.d.ts +0 -212
- package/src/tool-template/builder.js +0 -397
- package/src/tool-template/builder.js.map +0 -1
- package/src/tool-template/index.d.ts +0 -15
- package/src/tool-template/index.js +0 -38
- package/src/tool-template/index.js.map +0 -1
- package/src/types/index.d.ts +0 -13
- package/src/types/index.js +0 -26
- package/src/types/index.js.map +0 -1
- package/src/types/ui-config.d.ts +0 -357
- package/src/types/ui-config.js +0 -12
- package/src/types/ui-config.js.map +0 -1
- package/src/types/ui-runtime.d.ts +0 -965
- package/src/types/ui-runtime.js +0 -117
- package/src/types/ui-runtime.js.map +0 -1
- package/src/validation/error-box.d.ts +0 -55
- package/src/validation/error-box.js +0 -75
- package/src/validation/error-box.js.map +0 -1
- package/src/validation/index.d.ts +0 -12
- package/src/validation/index.js +0 -21
- package/src/validation/index.js.map +0 -1
- package/src/validation/wrapper.d.ts +0 -96
- package/src/validation/wrapper.js +0 -117
- package/src/validation/wrapper.js.map +0 -1
- package/src/web-components/core/attribute-parser.d.ts +0 -85
- package/src/web-components/core/attribute-parser.js +0 -189
- package/src/web-components/core/attribute-parser.js.map +0 -1
- package/src/web-components/core/base-element.d.ts +0 -197
- package/src/web-components/core/base-element.js +0 -289
- package/src/web-components/core/base-element.js.map +0 -1
- package/src/web-components/core/index.d.ts +0 -8
- package/src/web-components/core/index.js +0 -18
- package/src/web-components/core/index.js.map +0 -1
- package/src/web-components/elements/fmcp-alert.d.ts +0 -45
- package/src/web-components/elements/fmcp-alert.js +0 -93
- package/src/web-components/elements/fmcp-alert.js.map +0 -1
- package/src/web-components/elements/fmcp-badge.d.ts +0 -46
- package/src/web-components/elements/fmcp-badge.js +0 -99
- package/src/web-components/elements/fmcp-badge.js.map +0 -1
- package/src/web-components/elements/fmcp-button.d.ts +0 -124
- package/src/web-components/elements/fmcp-button.js +0 -233
- package/src/web-components/elements/fmcp-button.js.map +0 -1
- package/src/web-components/elements/fmcp-card.d.ts +0 -52
- package/src/web-components/elements/fmcp-card.js +0 -115
- package/src/web-components/elements/fmcp-card.js.map +0 -1
- package/src/web-components/elements/fmcp-input.d.ts +0 -95
- package/src/web-components/elements/fmcp-input.js +0 -248
- package/src/web-components/elements/fmcp-input.js.map +0 -1
- package/src/web-components/elements/fmcp-select.d.ts +0 -99
- package/src/web-components/elements/fmcp-select.js +0 -243
- package/src/web-components/elements/fmcp-select.js.map +0 -1
- package/src/web-components/elements/index.d.ts +0 -12
- package/src/web-components/elements/index.js +0 -34
- package/src/web-components/elements/index.js.map +0 -1
- package/src/web-components/index.d.ts +0 -49
- package/src/web-components/index.js +0 -75
- package/src/web-components/index.js.map +0 -1
- package/src/web-components/register.d.ts +0 -56
- package/src/web-components/register.js +0 -80
- package/src/web-components/register.js.map +0 -1
- package/src/web-components/types.d.ts +0 -121
- package/src/web-components/types.js +0 -25
- package/src/web-components/types.js.map +0 -1
- package/src/widgets/index.d.ts +0 -7
- package/src/widgets/index.js +0 -24
- package/src/widgets/index.js.map +0 -1
- package/src/widgets/progress.d.ts +0 -132
- package/src/widgets/progress.js +0 -303
- package/src/widgets/progress.js.map +0 -1
- package/src/widgets/resource.d.ts +0 -162
- package/src/widgets/resource.js +0 -340
- package/src/widgets/resource.js.map +0 -1
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Tool UI Registry
|
|
4
|
-
*
|
|
5
|
-
* Manages UI template rendering for tool responses.
|
|
6
|
-
* Provides platform-specific metadata generation for MCP clients.
|
|
7
|
-
*
|
|
8
|
-
* Three serving modes:
|
|
9
|
-
* - **inline**: HTML is rendered per-request and embedded in _meta['ui/html']
|
|
10
|
-
* - **static**: Static widget is pre-compiled at startup, client fetches via resources/read
|
|
11
|
-
* - **hybrid**: Shell (React + renderer) cached at startup, component + data in response
|
|
12
|
-
*
|
|
13
|
-
* @packageDocumentation
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ToolUIRegistry = void 0;
|
|
17
|
-
const crypto_1 = require("crypto");
|
|
18
|
-
const render_template_1 = require("./render-template");
|
|
19
|
-
const adapters_1 = require("../adapters");
|
|
20
|
-
const wrapper_1 = require("../runtime/wrapper");
|
|
21
|
-
const build_1 = require("../build");
|
|
22
|
-
class ToolUIRegistry {
|
|
23
|
-
/**
|
|
24
|
-
* Cache for static widgets (keyed by tool name).
|
|
25
|
-
* Static widgets are pre-compiled at server startup for tools with servingMode: 'static'.
|
|
26
|
-
* These widgets read data from the FrontMCP Bridge at runtime (window.openai.toolOutput).
|
|
27
|
-
*/
|
|
28
|
-
staticWidgetCache = new Map();
|
|
29
|
-
/**
|
|
30
|
-
* Cache for widget manifests (keyed by tool name).
|
|
31
|
-
* Manifests describe the widget's renderer type, CSP, and other metadata.
|
|
32
|
-
*/
|
|
33
|
-
manifestCache = new Map();
|
|
34
|
-
/**
|
|
35
|
-
* Cache for build results (keyed by tool name).
|
|
36
|
-
* Includes HTML, manifest, and hash for cache validation.
|
|
37
|
-
*/
|
|
38
|
-
buildResultCache = new Map();
|
|
39
|
-
/**
|
|
40
|
-
* Compile a static widget template for a tool at server startup.
|
|
41
|
-
*
|
|
42
|
-
* For tools with `servingMode: 'static'`, the widget HTML is pre-compiled
|
|
43
|
-
* WITHOUT embedded data. The widget reads data from the FrontMCP Bridge at runtime
|
|
44
|
-
* (via window.openai.toolOutput or window.__frontmcp.toolOutput).
|
|
45
|
-
*
|
|
46
|
-
* This is called during tool registration, not during tool calls.
|
|
47
|
-
*
|
|
48
|
-
* @param options - Static widget compilation options
|
|
49
|
-
*/
|
|
50
|
-
async compileStaticWidgetAsync(options) {
|
|
51
|
-
const { toolName, template, uiConfig } = options;
|
|
52
|
-
// Try to use the new manifest builder first
|
|
53
|
-
try {
|
|
54
|
-
// Detect uiType if not provided (using type assertion for extended config)
|
|
55
|
-
const extendedConfig = uiConfig;
|
|
56
|
-
const detectedType = (0, build_1.detectUIType)(template);
|
|
57
|
-
// Convert UITemplateConfig to WidgetConfig format for the manifest builder
|
|
58
|
-
const widgetConfig = {
|
|
59
|
-
template: template,
|
|
60
|
-
uiType: (extendedConfig.uiType ?? detectedType),
|
|
61
|
-
displayMode: (uiConfig.displayMode ?? 'inline'),
|
|
62
|
-
bundlingMode: (extendedConfig.bundlingMode ?? 'static'),
|
|
63
|
-
resourceMode: (extendedConfig.resourceMode ?? 'cdn'),
|
|
64
|
-
widgetAccessible: uiConfig.widgetAccessible,
|
|
65
|
-
widgetDescription: uiConfig.widgetDescription,
|
|
66
|
-
csp: uiConfig.csp
|
|
67
|
-
? {
|
|
68
|
-
scriptSrc: uiConfig.csp.resourceDomains ?? [],
|
|
69
|
-
styleSrc: uiConfig.csp.resourceDomains ?? [],
|
|
70
|
-
connectSrc: uiConfig.csp.connectDomains ?? [],
|
|
71
|
-
imgSrc: uiConfig.csp.resourceDomains ?? [],
|
|
72
|
-
}
|
|
73
|
-
: undefined,
|
|
74
|
-
mdxComponents: uiConfig.mdxComponents,
|
|
75
|
-
runtimeOptions: extendedConfig.runtimeOptions,
|
|
76
|
-
};
|
|
77
|
-
const result = await (0, build_1.buildToolWidgetManifest)({
|
|
78
|
-
toolName,
|
|
79
|
-
uiConfig: widgetConfig,
|
|
80
|
-
schema: {},
|
|
81
|
-
});
|
|
82
|
-
// For React/MDX components, we need to use wrapStaticWidgetUniversal
|
|
83
|
-
// to include the React runtime and rendering script
|
|
84
|
-
if (result.componentCode && (result.rendererType === 'react' || result.rendererType === 'mdx')) {
|
|
85
|
-
// Re-wrap with wrapStaticWidgetUniversal to include React runtime + rendering
|
|
86
|
-
const widgetHtml = (0, wrapper_1.wrapStaticWidgetUniversal)({
|
|
87
|
-
toolName,
|
|
88
|
-
ssrContent: result.content,
|
|
89
|
-
uiConfig,
|
|
90
|
-
rendererType: result.rendererType,
|
|
91
|
-
componentCode: result.componentCode,
|
|
92
|
-
});
|
|
93
|
-
this.staticWidgetCache.set(toolName, widgetHtml);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// Use the pre-built HTML for non-React templates
|
|
97
|
-
this.staticWidgetCache.set(toolName, result.html);
|
|
98
|
-
}
|
|
99
|
-
this.manifestCache.set(toolName, result.manifest);
|
|
100
|
-
this.buildResultCache.set(toolName, result);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
// Fall back to legacy compilation
|
|
105
|
-
console.warn(`[ToolUIRegistry] Manifest build failed for ${toolName}, using legacy method:`, error);
|
|
106
|
-
}
|
|
107
|
-
// Legacy fallback: Render the template SSR'd WITHOUT data
|
|
108
|
-
// The widget will read data from Bridge at runtime
|
|
109
|
-
const ssrContent = await (0, render_template_1.renderToolTemplateAsync)({
|
|
110
|
-
template,
|
|
111
|
-
input: {}, // Empty - data comes from Bridge at runtime
|
|
112
|
-
output: undefined,
|
|
113
|
-
structuredContent: undefined,
|
|
114
|
-
mdxComponents: uiConfig.mdxComponents,
|
|
115
|
-
});
|
|
116
|
-
// Wrap in a complete HTML document with FrontMCP Bridge
|
|
117
|
-
// The Bridge will read data from window.openai.toolOutput at runtime
|
|
118
|
-
const widgetHtml = (0, wrapper_1.wrapStaticWidgetUniversal)({
|
|
119
|
-
toolName,
|
|
120
|
-
ssrContent,
|
|
121
|
-
uiConfig,
|
|
122
|
-
});
|
|
123
|
-
// Cache the static widget HTML
|
|
124
|
-
this.staticWidgetCache.set(toolName, widgetHtml);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Compile a lean widget shell for inline mode tools at server startup.
|
|
128
|
-
*
|
|
129
|
-
* For tools with `servingMode: 'inline'`, we create a minimal HTML shell that:
|
|
130
|
-
* - Contains only HTML structure, theme CSS, and fonts
|
|
131
|
-
* - NO React runtime, NO component code, NO bridge
|
|
132
|
-
* - OpenAI caches this at discovery time
|
|
133
|
-
* - The actual React widget comes in each tool response with embedded data
|
|
134
|
-
*
|
|
135
|
-
* @param options - Options for lean widget compilation
|
|
136
|
-
*/
|
|
137
|
-
compileLeanWidgetAsync(options) {
|
|
138
|
-
const { toolName, uiConfig } = options;
|
|
139
|
-
// Create a lean HTML shell with just theme and structure
|
|
140
|
-
const leanHtml = (0, wrapper_1.wrapLeanWidgetShell)({
|
|
141
|
-
toolName,
|
|
142
|
-
uiConfig: {
|
|
143
|
-
widgetAccessible: uiConfig.widgetAccessible,
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
// Cache the lean widget HTML
|
|
147
|
-
this.staticWidgetCache.set(toolName, leanHtml);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Compile a hybrid widget shell at server startup.
|
|
151
|
-
*
|
|
152
|
-
* For tools with `servingMode: 'hybrid'`, we create a shell that:
|
|
153
|
-
* - Contains React 19 runtime from esm.sh CDN
|
|
154
|
-
* - Contains FrontMCP Bridge (universal)
|
|
155
|
-
* - Contains all FrontMCP hooks (useMcpBridgeContext, useToolOutput, etc.)
|
|
156
|
-
* - Contains all FrontMCP UI components (Card, Badge, Button)
|
|
157
|
-
* - Contains dynamic renderer script that imports components via blob URL
|
|
158
|
-
* - NO component code (comes at tool call time via `_meta['ui/component']`)
|
|
159
|
-
*
|
|
160
|
-
* The shell listens for `ui/component` in tool response metadata and dynamically
|
|
161
|
-
* imports the transpiled component code, then renders it with tool output data.
|
|
162
|
-
*
|
|
163
|
-
* @param options - Options for hybrid widget compilation
|
|
164
|
-
*/
|
|
165
|
-
compileHybridWidgetAsync(options) {
|
|
166
|
-
const { toolName, uiConfig } = options;
|
|
167
|
-
// Create a hybrid shell with React runtime and dynamic renderer
|
|
168
|
-
const hybridHtml = (0, wrapper_1.wrapHybridWidgetShell)({
|
|
169
|
-
toolName,
|
|
170
|
-
uiConfig: {
|
|
171
|
-
widgetAccessible: uiConfig.widgetAccessible,
|
|
172
|
-
csp: uiConfig.csp,
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
// Cache the hybrid widget HTML
|
|
176
|
-
this.staticWidgetCache.set(toolName, hybridHtml);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Build a component payload for hybrid mode tool responses.
|
|
180
|
-
*
|
|
181
|
-
* For tools with `servingMode: 'hybrid'`, this method is called at tool call time
|
|
182
|
-
* to build the transpiled component code that gets delivered in `_meta['ui/component']`.
|
|
183
|
-
*
|
|
184
|
-
* The component code is in ES module format so it can be dynamically imported
|
|
185
|
-
* via blob URL in the hybrid shell's renderer.
|
|
186
|
-
*
|
|
187
|
-
* @param options - Options for building the component payload
|
|
188
|
-
* @returns The hybrid component payload, or undefined if template is not a function
|
|
189
|
-
*/
|
|
190
|
-
buildHybridComponentPayload(options) {
|
|
191
|
-
const { toolName, template } = options;
|
|
192
|
-
// Detect the UI type
|
|
193
|
-
const detectedType = this.detectUIType(template);
|
|
194
|
-
// Only support function templates (React components) for hybrid mode
|
|
195
|
-
if (typeof template !== 'function') {
|
|
196
|
-
// For HTML strings, return undefined - hybrid mode is designed for React components
|
|
197
|
-
// HTML templates should use inline mode instead
|
|
198
|
-
return undefined;
|
|
199
|
-
}
|
|
200
|
-
// Get the component function as a string
|
|
201
|
-
const componentSource = template.toString();
|
|
202
|
-
// Sanitize tool name for JavaScript variable name
|
|
203
|
-
const safeName = toolName.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
204
|
-
// Build ES module compatible component code
|
|
205
|
-
// The component is exported as default and also registered globally
|
|
206
|
-
// for the hybrid shell's dynamic renderer
|
|
207
|
-
const code = `
|
|
208
|
-
// FrontMCP Hybrid Widget Component: ${toolName}
|
|
209
|
-
// Type: ${detectedType}
|
|
210
|
-
|
|
211
|
-
// The component function
|
|
212
|
-
const ${safeName} = ${componentSource};
|
|
213
|
-
|
|
214
|
-
// Register component globally for dynamic rendering
|
|
215
|
-
window.__frontmcp_component = ${safeName};
|
|
216
|
-
|
|
217
|
-
// Also register in __frontmcp_components for multiple components
|
|
218
|
-
window.__frontmcp_components = window.__frontmcp_components || {};
|
|
219
|
-
window.__frontmcp_components['${toolName}'] = ${safeName};
|
|
220
|
-
|
|
221
|
-
// Export as default for ES module import
|
|
222
|
-
export default ${safeName};
|
|
223
|
-
`.trim();
|
|
224
|
-
// Generate hash for cache validation
|
|
225
|
-
const hash = (0, crypto_1.createHash)('sha256').update(code).digest('hex').substring(0, 16);
|
|
226
|
-
// Determine renderer type
|
|
227
|
-
const type = detectedType === 'react' || detectedType === 'mdx' ? detectedType : 'react'; // Default to react for function templates
|
|
228
|
-
return {
|
|
229
|
-
code,
|
|
230
|
-
type,
|
|
231
|
-
toolName,
|
|
232
|
-
hash,
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Get the pre-compiled static widget HTML for a tool.
|
|
237
|
-
*
|
|
238
|
-
* @param toolName - The tool name to look up
|
|
239
|
-
* @returns Pre-compiled widget HTML, or undefined if not cached
|
|
240
|
-
*/
|
|
241
|
-
getStaticWidget(toolName) {
|
|
242
|
-
return this.staticWidgetCache.get(toolName);
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Check if a tool has a pre-compiled static widget.
|
|
246
|
-
*
|
|
247
|
-
* @param toolName - The tool name to check
|
|
248
|
-
* @returns true if the tool has a cached static widget
|
|
249
|
-
*/
|
|
250
|
-
hasStaticWidget(toolName) {
|
|
251
|
-
return this.staticWidgetCache.has(toolName);
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Get the widget manifest for a tool.
|
|
255
|
-
*
|
|
256
|
-
* @param toolName - The tool name to look up
|
|
257
|
-
* @returns Widget manifest, or undefined if not cached
|
|
258
|
-
*/
|
|
259
|
-
getManifest(toolName) {
|
|
260
|
-
return this.manifestCache.get(toolName);
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Check if a tool has a cached manifest.
|
|
264
|
-
*
|
|
265
|
-
* @param toolName - The tool name to check
|
|
266
|
-
* @returns true if the tool has a cached manifest
|
|
267
|
-
*/
|
|
268
|
-
hasManifest(toolName) {
|
|
269
|
-
return this.manifestCache.has(toolName);
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Get the full build result for a tool.
|
|
273
|
-
*
|
|
274
|
-
* @param toolName - The tool name to look up
|
|
275
|
-
* @returns Build result, or undefined if not cached
|
|
276
|
-
*/
|
|
277
|
-
getBuildResult(toolName) {
|
|
278
|
-
return this.buildResultCache.get(toolName);
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Detect the UI type for a template.
|
|
282
|
-
*
|
|
283
|
-
* @param template - The template to analyze
|
|
284
|
-
* @returns Detected UI type
|
|
285
|
-
*/
|
|
286
|
-
detectUIType(template) {
|
|
287
|
-
// Use the imported detectUIType function from build module
|
|
288
|
-
return (0, build_1.detectUIType)(template);
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Render a tool's UI template for inline mode.
|
|
292
|
-
*
|
|
293
|
-
* This version supports all template types including React components.
|
|
294
|
-
* The rendered HTML is embedded directly in _meta['ui/html'] for the client.
|
|
295
|
-
*
|
|
296
|
-
* For React/MDX components, the output is wrapped using wrapStaticWidgetUniversal
|
|
297
|
-
* which includes the React 19 CDN, client-side rendering script, and all the
|
|
298
|
-
* FrontMCP hooks/components. This provides the same rendering capability as
|
|
299
|
-
* static mode, but with data embedded in each response.
|
|
300
|
-
*
|
|
301
|
-
* @param options - Rendering options
|
|
302
|
-
* @returns Promise resolving to render result with HTML and metadata
|
|
303
|
-
*/
|
|
304
|
-
async renderAndRegisterAsync(options) {
|
|
305
|
-
const { toolName, input, output, structuredContent, uiConfig, platformType, token, directUrl } = options;
|
|
306
|
-
// Detect if this is a React component
|
|
307
|
-
const detectedType = this.detectUIType(uiConfig.template);
|
|
308
|
-
const isReactBased = detectedType === 'react' || detectedType === 'mdx';
|
|
309
|
-
let html;
|
|
310
|
-
if (isReactBased && typeof uiConfig.template === 'function') {
|
|
311
|
-
// For React/MDX components: Use wrapStaticWidgetUniversal with component code
|
|
312
|
-
// This includes the React 19 CDN, client-side renderer, and all FrontMCP hooks
|
|
313
|
-
// Same approach as static mode, but with data embedded
|
|
314
|
-
// 1. Build the component code that will be embedded in the HTML
|
|
315
|
-
const componentCode = this.buildComponentCode(uiConfig.template, toolName);
|
|
316
|
-
// 2. Render SSR content (optional, for initial display)
|
|
317
|
-
const ssrContent = await (0, render_template_1.renderToolTemplateAsync)({
|
|
318
|
-
template: uiConfig.template,
|
|
319
|
-
input,
|
|
320
|
-
output,
|
|
321
|
-
structuredContent,
|
|
322
|
-
mdxComponents: uiConfig.mdxComponents,
|
|
323
|
-
});
|
|
324
|
-
// 3. Wrap with React runtime + component code
|
|
325
|
-
// This creates a complete HTML document with:
|
|
326
|
-
// - React 19 CDN imports
|
|
327
|
-
// - FrontMCP hooks (useMcpBridgeContext, useToolOutput, etc.)
|
|
328
|
-
// - FrontMCP UI components (Card, Badge, Button)
|
|
329
|
-
// - The component code registered as window.__frontmcp_component
|
|
330
|
-
// - Client-side rendering script that hydrates with the embedded data
|
|
331
|
-
html = (0, wrapper_1.wrapStaticWidgetUniversal)({
|
|
332
|
-
toolName,
|
|
333
|
-
ssrContent,
|
|
334
|
-
uiConfig,
|
|
335
|
-
rendererType: detectedType,
|
|
336
|
-
componentCode,
|
|
337
|
-
// For inline mode, we embed the data in the HTML so the component
|
|
338
|
-
// can render immediately without waiting for window.openai.toolOutput
|
|
339
|
-
embeddedData: {
|
|
340
|
-
input: input,
|
|
341
|
-
output,
|
|
342
|
-
structuredContent,
|
|
343
|
-
},
|
|
344
|
-
// Self-contained mode: no bridge, React manages state internally
|
|
345
|
-
// This prevents OpenAI's wrapper from interfering with React re-renders
|
|
346
|
-
selfContained: true,
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
// For HTML templates: Use the original wrapToolUIUniversal approach
|
|
351
|
-
// which embeds the pre-rendered content with the Bridge runtime
|
|
352
|
-
// 1. Render the template
|
|
353
|
-
const renderedContent = await (0, render_template_1.renderToolTemplateAsync)({
|
|
354
|
-
template: uiConfig.template,
|
|
355
|
-
input,
|
|
356
|
-
output,
|
|
357
|
-
structuredContent,
|
|
358
|
-
mdxComponents: uiConfig.mdxComponents,
|
|
359
|
-
});
|
|
360
|
-
// 2. Wrap in a complete HTML document with FrontMCP Bridge runtime.
|
|
361
|
-
// For OpenAI platform, we skip the CSP meta tag because OpenAI handles CSP
|
|
362
|
-
// through `_meta['openai/widgetCSP']` in the MCP response, not HTML meta tags.
|
|
363
|
-
const isOpenAIPlatform = platformType === 'openai';
|
|
364
|
-
html = (0, wrapper_1.wrapToolUIUniversal)({
|
|
365
|
-
content: renderedContent,
|
|
366
|
-
toolName,
|
|
367
|
-
input: input,
|
|
368
|
-
output,
|
|
369
|
-
structuredContent,
|
|
370
|
-
csp: uiConfig.csp,
|
|
371
|
-
widgetAccessible: uiConfig.widgetAccessible,
|
|
372
|
-
includeBridge: true,
|
|
373
|
-
skipCspMeta: isOpenAIPlatform,
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
// Get manifest info if available (from static widget compilation)
|
|
377
|
-
const manifest = this.manifestCache.get(toolName);
|
|
378
|
-
const buildResult = this.buildResultCache.get(toolName);
|
|
379
|
-
// Determine renderer type
|
|
380
|
-
const rendererType = manifest?.uiType ?? detectedType ?? 'auto';
|
|
381
|
-
// Build platform-specific metadata
|
|
382
|
-
// For inline mode, HTML is embedded in _meta['ui/html']
|
|
383
|
-
const meta = (0, adapters_1.buildUIMeta)({
|
|
384
|
-
uiConfig,
|
|
385
|
-
platformType,
|
|
386
|
-
html,
|
|
387
|
-
token,
|
|
388
|
-
directUrl,
|
|
389
|
-
rendererType,
|
|
390
|
-
contentHash: buildResult?.hash,
|
|
391
|
-
manifestUri: manifest?.uri,
|
|
392
|
-
});
|
|
393
|
-
return { html, meta };
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Build component code string for embedding in widget HTML.
|
|
397
|
-
*
|
|
398
|
-
* @param template - The React component
|
|
399
|
-
* @param toolName - Tool name for naming the component
|
|
400
|
-
* @returns JavaScript code string that defines and registers the component
|
|
401
|
-
*/
|
|
402
|
-
buildComponentCode(template, toolName) {
|
|
403
|
-
if (typeof template !== 'function') {
|
|
404
|
-
return undefined;
|
|
405
|
-
}
|
|
406
|
-
// Get the component function as a string
|
|
407
|
-
const componentSource = template.toString();
|
|
408
|
-
// Sanitize tool name for JavaScript variable name
|
|
409
|
-
const safeName = toolName.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
410
|
-
// Build the component code that will be embedded in the HTML
|
|
411
|
-
// The component is registered on window.__frontmcp_component for the render script
|
|
412
|
-
return `
|
|
413
|
-
// FrontMCP Widget Component: ${toolName}
|
|
414
|
-
(function() {
|
|
415
|
-
// The component function
|
|
416
|
-
var ${safeName} = ${componentSource};
|
|
417
|
-
|
|
418
|
-
// Register component globally for client-side rendering
|
|
419
|
-
window.__frontmcp_component = ${safeName};
|
|
420
|
-
|
|
421
|
-
// Also register in __frontmcp_components for multiple components
|
|
422
|
-
window.__frontmcp_components = window.__frontmcp_components || {};
|
|
423
|
-
window.__frontmcp_components['${toolName}'] = ${safeName};
|
|
424
|
-
})();
|
|
425
|
-
`.trim();
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Check if a template requires async rendering (e.g., React components).
|
|
429
|
-
*
|
|
430
|
-
* @param template - The template to check
|
|
431
|
-
* @returns true if the template requires async rendering
|
|
432
|
-
*/
|
|
433
|
-
requiresAsyncRendering(template) {
|
|
434
|
-
return (0, render_template_1.isReactComponent)(template);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
exports.ToolUIRegistry = ToolUIRegistry;
|
|
438
|
-
//# sourceMappingURL=tool-ui.registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-ui.registry.js","sourceRoot":"","sources":["../../../src/registry/tool-ui.registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,mCAAoC;AAGpC,uDAA8E;AAC9E,0CAA0C;AAC1C,gDAK4B;AAC5B,oCAAiE;AAuGjE,MAAa,cAAc;IACzB;;;;OAIG;IACc,iBAAiB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE/D;;;OAGG;IACc,aAAa,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEnE;;;OAGG;IACc,gBAAgB,GAAG,IAAI,GAAG,EAA+B,CAAC;IAE3E;;;;;;;;;;OAUG;IACH,KAAK,CAAC,wBAAwB,CAAC,OAAmC;QAChE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAEjD,4CAA4C;QAC5C,IAAI,CAAC;YACH,2EAA2E;YAC3E,MAAM,cAAc,GAAG,QAKtB,CAAC;YACF,MAAM,YAAY,GAAG,IAAA,oBAAY,EAAC,QAA8C,CAAC,CAAC;YAElF,2EAA2E;YAC3E,MAAM,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O,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,CAAC;IAED;;;;;;OAMG;IACK,kBAAkB,CAAC,QAAiB,EAAE,QAAgB;QAC5D,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACnC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,yCAAyC;QACzC,MAAM,eAAe,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAE5C,kDAAkD;QAClD,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;QAEzD,6DAA6D;QAC7D,mFAAmF;QACnF,OAAO;gCACqB,QAAQ;;;QAGhC,QAAQ,MAAM,eAAe;;;kCAGH,QAAQ;;;;kCAIR,QAAQ,QAAQ,QAAQ;;CAEzD,CAAC,IAAI,EAAE,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACH,sBAAsB,CAAC,QAAsC;QAC3D,OAAO,IAAA,kCAAgB,EAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;CACF;AAldD,wCAkdC","sourcesContent":["/**\n * Tool UI Registry\n *\n * Manages UI template rendering for tool responses.\n * Provides platform-specific metadata generation for MCP clients.\n *\n * Three serving modes:\n * - **inline**: HTML is rendered per-request and embedded in _meta['ui/html']\n * - **static**: Static widget is pre-compiled at startup, client fetches via resources/read\n * - **hybrid**: Shell (React + renderer) cached at startup, component + data in response\n *\n * @packageDocumentation\n */\n\nimport { createHash } from 'crypto';\nimport type { UITemplateConfig, WidgetManifest, BuildManifestResult } from '../types';\nimport type { AIPlatformType, UIMetadata } from '../adapters';\nimport { renderToolTemplateAsync, isReactComponent } from './render-template';\nimport { buildUIMeta } from '../adapters';\nimport {\n wrapToolUIUniversal,\n wrapStaticWidgetUniversal,\n wrapLeanWidgetShell,\n wrapHybridWidgetShell,\n} from '../runtime/wrapper';\nimport { buildToolWidgetManifest, detectUIType } from '../build';\n\n/**\n * Options for renderAndRegisterAsync (inline mode).\n */\nexport interface RenderOptions {\n /** Tool name */\n toolName: string;\n /** Unique request identifier */\n requestId: string;\n /** Tool input arguments */\n input: Record<string, unknown>;\n /** Raw tool output */\n output: unknown;\n /** Structured content (parsed from output) */\n structuredContent?: unknown;\n /** Tool UI configuration */\n uiConfig: UITemplateConfig;\n /** Detected platform type */\n platformType: AIPlatformType;\n /** Widget access token (optional) */\n token?: string;\n /** Direct URL for widget serving (optional) */\n directUrl?: string;\n}\n\n/**\n * Result of rendering UI for inline mode.\n */\nexport interface UIRenderResult {\n /** Rendered HTML content */\n html: string;\n /** Platform-specific metadata for _meta field */\n meta: UIMetadata;\n}\n\n/**\n * ToolUIRegistry manages UI template rendering for tool responses.\n *\n * It provides:\n * - Static widget compilation for static mode (pre-compiled at startup)\n * - Per-request HTML rendering for inline mode (embedded in _meta)\n * - Platform-specific _meta generation\n * - Widget manifest management\n *\n * @example\n * ```typescript\n * const registry = new ToolUIRegistry();\n *\n * // For inline mode: render HTML per-request\n * const result = await registry.renderAndRegisterAsync({\n * toolName: 'get_weather',\n * requestId: 'abc123',\n * input: { location: 'London' },\n * output: { temp: 72, conditions: 'Sunny' },\n * uiConfig: tool.metadata.ui,\n * platformType: 'openai',\n * });\n *\n * // result.meta can be spread into tool result _meta\n * return { content: [...], _meta: { ...result.meta } };\n * ```\n */\n\n/**\n * Options for compiling a static widget.\n */\nexport interface CompileStaticWidgetOptions {\n /** Tool name (used for cache key and URI) */\n toolName: string;\n /** The template to compile (React component, HTML string, or builder function) */\n template: UITemplateConfig['template'];\n /** Tool UI configuration */\n uiConfig: UITemplateConfig;\n}\n\n/**\n * Payload for hybrid mode component delivery.\n * Sent in `_meta['ui/component']` at tool call time.\n */\nexport interface HybridComponentPayload {\n /** Transpiled component JavaScript code (ES module format) */\n code: string;\n /** Renderer type for the component */\n type: 'react' | 'mdx' | 'html';\n /** Tool name for identification */\n toolName: string;\n /** Content hash for cache validation */\n hash: string;\n}\n\n/**\n * Options for building a hybrid component payload.\n */\nexport interface BuildHybridComponentPayloadOptions {\n /** Tool name */\n toolName: string;\n /** The template to transpile */\n template: UITemplateConfig['template'];\n /** Tool UI configuration */\n uiConfig: UITemplateConfig;\n}\n\nexport class ToolUIRegistry {\n /**\n * Cache for static widgets (keyed by tool name).\n * Static widgets are pre-compiled at server startup for tools with servingMode: 'static'.\n * These widgets read data from the FrontMCP Bridge at runtime (window.openai.toolOutput).\n */\n private readonly staticWidgetCache = new Map<string, string>();\n\n /**\n * Cache for widget manifests (keyed by tool name).\n * Manifests describe the widget's renderer type, CSP, and other metadata.\n */\n private readonly manifestCache = new Map<string, WidgetManifest>();\n\n /**\n * Cache for build results (keyed by tool name).\n * Includes HTML, manifest, and hash for cache validation.\n */\n private readonly buildResultCache = new Map<string, BuildManifestResult>();\n\n /**\n * Compile a static widget template for a tool at server startup.\n *\n * For tools with `servingMode: 'static'`, the widget HTML is pre-compiled\n * WITHOUT embedded data. The widget reads data from the FrontMCP Bridge at runtime\n * (via window.openai.toolOutput or window.__frontmcp.toolOutput).\n *\n * This is called during tool registration, not during tool calls.\n *\n * @param options - Static widget compilation options\n */\n async compileStaticWidgetAsync(options: CompileStaticWidgetOptions): Promise<void> {\n const { toolName, template, uiConfig } = options;\n\n // Try to use the new manifest builder first\n try {\n // Detect uiType if not provided (using type assertion for extended config)\n const extendedConfig = uiConfig as UITemplateConfig & {\n uiType?: string;\n bundlingMode?: string;\n resourceMode?: 'cdn' | 'inline';\n runtimeOptions?: { hydrate?: boolean };\n };\n const detectedType = detectUIType(template as Parameters<typeof detectUIType>[0]);\n\n // Convert UITemplateConfig to WidgetConfig format for the manifest builder\n const widgetConfig = {\n template: template as Parameters<typeof buildToolWidgetManifest>[0]['uiConfig']['template'],\n uiType: (extendedConfig.uiType ?? detectedType) as 'html' | 'react' | 'mdx' | 'markdown' | 'auto',\n displayMode: (uiConfig.displayMode ?? 'inline') as 'inline' | 'fullscreen' | 'pip',\n bundlingMode: (extendedConfig.bundlingMode ?? 'static') as 'static' | 'dynamic',\n resourceMode: (extendedConfig.resourceMode ?? 'cdn') as 'cdn' | 'inline',\n widgetAccessible: uiConfig.widgetAccessible,\n widgetDescription: uiConfig.widgetDescription,\n csp: uiConfig.csp\n ? {\n scriptSrc: uiConfig.csp.resourceDomains ?? [],\n styleSrc: uiConfig.csp.resourceDomains ?? [],\n connectSrc: uiConfig.csp.connectDomains ?? [],\n imgSrc: uiConfig.csp.resourceDomains ?? [],\n }\n : undefined,\n mdxComponents: uiConfig.mdxComponents,\n runtimeOptions: extendedConfig.runtimeOptions,\n };\n\n const result = await buildToolWidgetManifest({\n toolName,\n uiConfig: widgetConfig,\n schema: {},\n });\n\n // For React/MDX components, we need to use wrapStaticWidgetUniversal\n // to include the React runtime and rendering script\n if (result.componentCode && (result.rendererType === 'react' || result.rendererType === 'mdx')) {\n // Re-wrap with wrapStaticWidgetUniversal to include React runtime + rendering\n const widgetHtml = wrapStaticWidgetUniversal({\n toolName,\n ssrContent: result.content,\n uiConfig,\n rendererType: result.rendererType,\n componentCode: result.componentCode,\n });\n this.staticWidgetCache.set(toolName, widgetHtml);\n } else {\n // Use the pre-built HTML for non-React templates\n this.staticWidgetCache.set(toolName, result.html);\n }\n\n this.manifestCache.set(toolName, result.manifest);\n this.buildResultCache.set(toolName, result);\n return;\n } catch (error) {\n // Fall back to legacy compilation\n console.warn(`[ToolUIRegistry] Manifest build failed for ${toolName}, using legacy method:`, error);\n }\n\n // Legacy fallback: Render the template SSR'd WITHOUT data\n // The widget will read data from Bridge at runtime\n const ssrContent = await renderToolTemplateAsync({\n template,\n input: {}, // Empty - data comes from Bridge at runtime\n output: undefined,\n structuredContent: undefined,\n mdxComponents: uiConfig.mdxComponents,\n });\n\n // Wrap in a complete HTML document with FrontMCP Bridge\n // The Bridge will read data from window.openai.toolOutput at runtime\n const widgetHtml = wrapStaticWidgetUniversal({\n toolName,\n ssrContent,\n uiConfig,\n });\n\n // Cache the static widget HTML\n this.staticWidgetCache.set(toolName, widgetHtml);\n }\n\n /**\n * Compile a lean widget shell for inline mode tools at server startup.\n *\n * For tools with `servingMode: 'inline'`, we create a minimal HTML shell that:\n * - Contains only HTML structure, theme CSS, and fonts\n * - NO React runtime, NO component code, NO bridge\n * - OpenAI caches this at discovery time\n * - The actual React widget comes in each tool response with embedded data\n *\n * @param options - Options for lean widget compilation\n */\n compileLeanWidgetAsync(options: { toolName: string; uiConfig: UITemplateConfig }): void {\n const { toolName, uiConfig } = options;\n\n // Create a lean HTML shell with just theme and structure\n const leanHtml = wrapLeanWidgetShell({\n toolName,\n uiConfig: {\n widgetAccessible: uiConfig.widgetAccessible,\n },\n });\n\n // Cache the lean widget HTML\n this.staticWidgetCache.set(toolName, leanHtml);\n }\n\n /**\n * Compile a hybrid widget shell at server startup.\n *\n * For tools with `servingMode: 'hybrid'`, we create a shell that:\n * - Contains React 19 runtime from esm.sh CDN\n * - Contains FrontMCP Bridge (universal)\n * - Contains all FrontMCP hooks (useMcpBridgeContext, useToolOutput, etc.)\n * - Contains all FrontMCP UI components (Card, Badge, Button)\n * - Contains dynamic renderer script that imports components via blob URL\n * - NO component code (comes at tool call time via `_meta['ui/component']`)\n *\n * The shell listens for `ui/component` in tool response metadata and dynamically\n * imports the transpiled component code, then renders it with tool output data.\n *\n * @param options - Options for hybrid widget compilation\n */\n compileHybridWidgetAsync(options: { toolName: string; uiConfig: UITemplateConfig }): void {\n const { toolName, uiConfig } = options;\n\n // Create a hybrid shell with React runtime and dynamic renderer\n const hybridHtml = wrapHybridWidgetShell({\n toolName,\n uiConfig: {\n widgetAccessible: uiConfig.widgetAccessible,\n csp: uiConfig.csp,\n },\n });\n\n // Cache the hybrid widget HTML\n this.staticWidgetCache.set(toolName, hybridHtml);\n }\n\n /**\n * Build a component payload for hybrid mode tool responses.\n *\n * For tools with `servingMode: 'hybrid'`, this method is called at tool call time\n * to build the transpiled component code that gets delivered in `_meta['ui/component']`.\n *\n * The component code is in ES module format so it can be dynamically imported\n * via blob URL in the hybrid shell's renderer.\n *\n * @param options - Options for building the component payload\n * @returns The hybrid component payload, or undefined if template is not a function\n */\n buildHybridComponentPayload(options: BuildHybridComponentPayloadOptions): HybridComponentPayload | undefined {\n const { toolName, template } = options;\n\n // Detect the UI type\n const detectedType = this.detectUIType(template);\n\n // Only support function templates (React components) for hybrid mode\n if (typeof template !== 'function') {\n // For HTML strings, return undefined - hybrid mode is designed for React components\n // HTML templates should use inline mode instead\n return undefined;\n }\n\n // Get the component function as a string\n const componentSource = template.toString();\n\n // Sanitize tool name for JavaScript variable name\n const safeName = toolName.replace(/[^a-zA-Z0-9_]/g, '_');\n\n // Build ES module compatible component code\n // The component is exported as default and also registered globally\n // for the hybrid shell's dynamic renderer\n const code = `\n// FrontMCP Hybrid Widget Component: ${toolName}\n// Type: ${detectedType}\n\n// The component function\nconst ${safeName} = ${componentSource};\n\n// Register component globally for dynamic rendering\nwindow.__frontmcp_component = ${safeName};\n\n// Also register in __frontmcp_components for multiple components\nwindow.__frontmcp_components = window.__frontmcp_components || {};\nwindow.__frontmcp_components['${toolName}'] = ${safeName};\n\n// Export as default for ES module import\nexport default ${safeName};\n`.trim();\n\n // Generate hash for cache validation\n const hash = createHash('sha256').update(code).digest('hex').substring(0, 16);\n\n // Determine renderer type\n const type = detectedType === 'react' || detectedType === 'mdx' ? (detectedType as 'react' | 'mdx') : 'react'; // Default to react for function templates\n\n return {\n code,\n type,\n toolName,\n hash,\n };\n }\n\n /**\n * Get the pre-compiled static widget HTML for a tool.\n *\n * @param toolName - The tool name to look up\n * @returns Pre-compiled widget HTML, or undefined if not cached\n */\n getStaticWidget(toolName: string): string | undefined {\n return this.staticWidgetCache.get(toolName);\n }\n\n /**\n * Check if a tool has a pre-compiled static widget.\n *\n * @param toolName - The tool name to check\n * @returns true if the tool has a cached static widget\n */\n hasStaticWidget(toolName: string): boolean {\n return this.staticWidgetCache.has(toolName);\n }\n\n /**\n * Get the widget manifest for a tool.\n *\n * @param toolName - The tool name to look up\n * @returns Widget manifest, or undefined if not cached\n */\n getManifest(toolName: string): WidgetManifest | undefined {\n return this.manifestCache.get(toolName);\n }\n\n /**\n * Check if a tool has a cached manifest.\n *\n * @param toolName - The tool name to check\n * @returns true if the tool has a cached manifest\n */\n hasManifest(toolName: string): boolean {\n return this.manifestCache.has(toolName);\n }\n\n /**\n * Get the full build result for a tool.\n *\n * @param toolName - The tool name to look up\n * @returns Build result, or undefined if not cached\n */\n getBuildResult(toolName: string): BuildManifestResult | undefined {\n return this.buildResultCache.get(toolName);\n }\n\n /**\n * Detect the UI type for a template.\n *\n * @param template - The template to analyze\n * @returns Detected UI type\n */\n detectUIType(template: UITemplateConfig['template']): string {\n // Use the imported detectUIType function from build module\n return detectUIType(template as Parameters<typeof detectUIType>[0]);\n }\n\n /**\n * Render a tool's UI template for inline mode.\n *\n * This version supports all template types including React components.\n * The rendered HTML is embedded directly in _meta['ui/html'] for the client.\n *\n * For React/MDX components, the output is wrapped using wrapStaticWidgetUniversal\n * which includes the React 19 CDN, client-side rendering script, and all the\n * FrontMCP hooks/components. This provides the same rendering capability as\n * static mode, but with data embedded in each response.\n *\n * @param options - Rendering options\n * @returns Promise resolving to render result with HTML and metadata\n */\n async renderAndRegisterAsync(options: RenderOptions): Promise<UIRenderResult> {\n const { toolName, input, output, structuredContent, uiConfig, platformType, token, directUrl } = options;\n\n // Detect if this is a React component\n const detectedType = this.detectUIType(uiConfig.template);\n const isReactBased = detectedType === 'react' || detectedType === 'mdx';\n\n let html: string;\n\n if (isReactBased && typeof uiConfig.template === 'function') {\n // For React/MDX components: Use wrapStaticWidgetUniversal with component code\n // This includes the React 19 CDN, client-side renderer, and all FrontMCP hooks\n // Same approach as static mode, but with data embedded\n\n // 1. Build the component code that will be embedded in the HTML\n const componentCode = this.buildComponentCode(uiConfig.template, toolName);\n\n // 2. Render SSR content (optional, for initial display)\n const ssrContent = await renderToolTemplateAsync({\n template: uiConfig.template,\n input,\n output,\n structuredContent,\n mdxComponents: uiConfig.mdxComponents,\n });\n\n // 3. Wrap with React runtime + component code\n // This creates a complete HTML document with:\n // - React 19 CDN imports\n // - FrontMCP hooks (useMcpBridgeContext, useToolOutput, etc.)\n // - FrontMCP UI components (Card, Badge, Button)\n // - The component code registered as window.__frontmcp_component\n // - Client-side rendering script that hydrates with the embedded data\n html = wrapStaticWidgetUniversal({\n toolName,\n ssrContent,\n uiConfig,\n rendererType: detectedType,\n componentCode,\n // For inline mode, we embed the data in the HTML so the component\n // can render immediately without waiting for window.openai.toolOutput\n embeddedData: {\n input: input as Record<string, unknown>,\n output,\n structuredContent,\n },\n // Self-contained mode: no bridge, React manages state internally\n // This prevents OpenAI's wrapper from interfering with React re-renders\n selfContained: true,\n });\n } else {\n // For HTML templates: Use the original wrapToolUIUniversal approach\n // which embeds the pre-rendered content with the Bridge runtime\n\n // 1. Render the template\n const renderedContent = await renderToolTemplateAsync({\n template: uiConfig.template,\n input,\n output,\n structuredContent,\n mdxComponents: uiConfig.mdxComponents,\n });\n\n // 2. Wrap in a complete HTML document with FrontMCP Bridge runtime.\n // For OpenAI platform, we skip the CSP meta tag because OpenAI handles CSP\n // through `_meta['openai/widgetCSP']` in the MCP response, not HTML meta tags.\n const isOpenAIPlatform = platformType === 'openai';\n html = wrapToolUIUniversal({\n content: renderedContent,\n toolName,\n input: input as Record<string, unknown>,\n output,\n structuredContent,\n csp: uiConfig.csp,\n widgetAccessible: uiConfig.widgetAccessible,\n includeBridge: true,\n skipCspMeta: isOpenAIPlatform,\n });\n }\n\n // Get manifest info if available (from static widget compilation)\n const manifest = this.manifestCache.get(toolName);\n const buildResult = this.buildResultCache.get(toolName);\n\n // Determine renderer type\n const rendererType = manifest?.uiType ?? detectedType ?? 'auto';\n\n // Build platform-specific metadata\n // For inline mode, HTML is embedded in _meta['ui/html']\n const meta = buildUIMeta({\n uiConfig,\n platformType,\n html,\n token,\n directUrl,\n rendererType,\n contentHash: buildResult?.hash,\n manifestUri: manifest?.uri,\n });\n\n return { html, meta };\n }\n\n /**\n * Build component code string for embedding in widget HTML.\n *\n * @param template - The React component\n * @param toolName - Tool name for naming the component\n * @returns JavaScript code string that defines and registers the component\n */\n private buildComponentCode(template: unknown, toolName: string): string | undefined {\n if (typeof template !== 'function') {\n return undefined;\n }\n\n // Get the component function as a string\n const componentSource = template.toString();\n\n // Sanitize tool name for JavaScript variable name\n const safeName = toolName.replace(/[^a-zA-Z0-9_]/g, '_');\n\n // Build the component code that will be embedded in the HTML\n // The component is registered on window.__frontmcp_component for the render script\n return `\n// FrontMCP Widget Component: ${toolName}\n(function() {\n // The component function\n var ${safeName} = ${componentSource};\n\n // Register component globally for client-side rendering\n window.__frontmcp_component = ${safeName};\n\n // Also register in __frontmcp_components for multiple components\n window.__frontmcp_components = window.__frontmcp_components || {};\n window.__frontmcp_components['${toolName}'] = ${safeName};\n})();\n`.trim();\n }\n\n /**\n * Check if a template requires async rendering (e.g., React components).\n *\n * @param template - The template to check\n * @returns true if the template requires async rendering\n */\n requiresAsyncRendering(template: UITemplateConfig['template']): boolean {\n return isReactComponent(template);\n }\n}\n"]}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UI Resource URI Utilities
|
|
3
|
-
*
|
|
4
|
-
* Standalone utilities for parsing and building ui:// resource URIs.
|
|
5
|
-
* Used for static widget serving mode where widgets are pre-compiled
|
|
6
|
-
* at startup and fetched via resources/read.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
|
-
import type { AIPlatformType } from '../adapters';
|
|
11
|
-
/**
|
|
12
|
-
* UI resource URI scheme
|
|
13
|
-
*/
|
|
14
|
-
export declare const UI_RESOURCE_SCHEME = "ui://";
|
|
15
|
-
/**
|
|
16
|
-
* Parsed static widget URI
|
|
17
|
-
*/
|
|
18
|
-
export interface ParsedWidgetUri {
|
|
19
|
-
toolName: string;
|
|
20
|
-
fullUri: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Check if a URI is a UI resource URI
|
|
24
|
-
*
|
|
25
|
-
* @param uri - URI to check
|
|
26
|
-
* @returns True if the URI starts with ui://
|
|
27
|
-
*/
|
|
28
|
-
export declare function isUIResourceUri(uri: string): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Parse a static widget URI into its components
|
|
31
|
-
*
|
|
32
|
-
* @param uri - URI to parse (format: ui://widget/{toolName}.html)
|
|
33
|
-
* @returns Parsed components or undefined if invalid
|
|
34
|
-
*/
|
|
35
|
-
export declare function parseWidgetUri(uri: string): ParsedWidgetUri | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Check if URI is a static widget URI (ui://widget/{toolName}.html)
|
|
38
|
-
*/
|
|
39
|
-
export declare function isStaticWidgetUri(uri: string): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Build a static widget URI from tool name
|
|
42
|
-
*
|
|
43
|
-
* @param toolName - Name of the tool
|
|
44
|
-
* @returns Static widget URI (ui://widget/{toolName}.html)
|
|
45
|
-
*/
|
|
46
|
-
export declare function buildStaticWidgetUri(toolName: string): string;
|
|
47
|
-
/**
|
|
48
|
-
* Get the MIME type for UI resources based on platform.
|
|
49
|
-
*
|
|
50
|
-
* Per user requirement: OpenAI or default uses 'text/html+skybridge'
|
|
51
|
-
*
|
|
52
|
-
* @param platformType - The detected platform type
|
|
53
|
-
* @returns The appropriate MIME type
|
|
54
|
-
*/
|
|
55
|
-
export declare function getUIResourceMimeType(platformType?: AIPlatformType): string;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* UI Resource URI Utilities
|
|
4
|
-
*
|
|
5
|
-
* Standalone utilities for parsing and building ui:// resource URIs.
|
|
6
|
-
* Used for static widget serving mode where widgets are pre-compiled
|
|
7
|
-
* at startup and fetched via resources/read.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.UI_RESOURCE_SCHEME = void 0;
|
|
13
|
-
exports.isUIResourceUri = isUIResourceUri;
|
|
14
|
-
exports.parseWidgetUri = parseWidgetUri;
|
|
15
|
-
exports.isStaticWidgetUri = isStaticWidgetUri;
|
|
16
|
-
exports.buildStaticWidgetUri = buildStaticWidgetUri;
|
|
17
|
-
exports.getUIResourceMimeType = getUIResourceMimeType;
|
|
18
|
-
/**
|
|
19
|
-
* UI resource URI scheme
|
|
20
|
-
*/
|
|
21
|
-
exports.UI_RESOURCE_SCHEME = 'ui://';
|
|
22
|
-
/**
|
|
23
|
-
* Pattern for static widget URIs: ui://widget/{toolName}.html
|
|
24
|
-
* This format is used by OpenAI at discovery time (tools/list)
|
|
25
|
-
*/
|
|
26
|
-
const UI_WIDGET_PATTERN = /^ui:\/\/widget\/([^/]+)\.html$/;
|
|
27
|
-
/**
|
|
28
|
-
* Check if a URI is a UI resource URI
|
|
29
|
-
*
|
|
30
|
-
* @param uri - URI to check
|
|
31
|
-
* @returns True if the URI starts with ui://
|
|
32
|
-
*/
|
|
33
|
-
function isUIResourceUri(uri) {
|
|
34
|
-
return uri.startsWith(exports.UI_RESOURCE_SCHEME);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Parse a static widget URI into its components
|
|
38
|
-
*
|
|
39
|
-
* @param uri - URI to parse (format: ui://widget/{toolName}.html)
|
|
40
|
-
* @returns Parsed components or undefined if invalid
|
|
41
|
-
*/
|
|
42
|
-
function parseWidgetUri(uri) {
|
|
43
|
-
const match = uri.match(UI_WIDGET_PATTERN);
|
|
44
|
-
if (!match) {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
toolName: decodeURIComponent(match[1]),
|
|
49
|
-
fullUri: uri,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Check if URI is a static widget URI (ui://widget/{toolName}.html)
|
|
54
|
-
*/
|
|
55
|
-
function isStaticWidgetUri(uri) {
|
|
56
|
-
return UI_WIDGET_PATTERN.test(uri);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Build a static widget URI from tool name
|
|
60
|
-
*
|
|
61
|
-
* @param toolName - Name of the tool
|
|
62
|
-
* @returns Static widget URI (ui://widget/{toolName}.html)
|
|
63
|
-
*/
|
|
64
|
-
function buildStaticWidgetUri(toolName) {
|
|
65
|
-
return `ui://widget/${encodeURIComponent(toolName)}.html`;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Get the MIME type for UI resources based on platform.
|
|
69
|
-
*
|
|
70
|
-
* Per user requirement: OpenAI or default uses 'text/html+skybridge'
|
|
71
|
-
*
|
|
72
|
-
* @param platformType - The detected platform type
|
|
73
|
-
* @returns The appropriate MIME type
|
|
74
|
-
*/
|
|
75
|
-
function getUIResourceMimeType(platformType) {
|
|
76
|
-
// Per requirement: "for openai or default text/html+skybridge"
|
|
77
|
-
// This aligns with OpenAI's skybridge widget protocol
|
|
78
|
-
switch (platformType) {
|
|
79
|
-
case 'claude':
|
|
80
|
-
// Claude uses standard text/html (network-blocked environment)
|
|
81
|
-
return 'text/html';
|
|
82
|
-
case 'gemini':
|
|
83
|
-
// Gemini uses standard text/html
|
|
84
|
-
return 'text/html';
|
|
85
|
-
case 'openai':
|
|
86
|
-
case 'cursor':
|
|
87
|
-
case 'continue':
|
|
88
|
-
case 'cody':
|
|
89
|
-
case 'generic-mcp':
|
|
90
|
-
case 'ext-apps':
|
|
91
|
-
case 'unknown':
|
|
92
|
-
default:
|
|
93
|
-
// OpenAI and default use skybridge MIME type
|
|
94
|
-
return 'text/html+skybridge';
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=uri-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uri-utils.js","sourceRoot":"","sources":["../../../src/registry/uri-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA6BH,0CAEC;AAQD,wCAUC;AAKD,8CAEC;AAQD,oDAEC;AAUD,sDAqBC;AA7FD;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["/**\n * UI Resource URI Utilities\n *\n * Standalone utilities for parsing and building ui:// resource URIs.\n * Used for static widget serving mode where widgets are pre-compiled\n * at startup and fetched via resources/read.\n *\n * @packageDocumentation\n */\n\nimport type { AIPlatformType } from '../adapters';\n\n/**\n * UI resource URI scheme\n */\nexport const UI_RESOURCE_SCHEME = 'ui://';\n\n/**\n * Pattern for static widget URIs: ui://widget/{toolName}.html\n * This format is used by OpenAI at discovery time (tools/list)\n */\nconst UI_WIDGET_PATTERN = /^ui:\\/\\/widget\\/([^/]+)\\.html$/;\n\n/**\n * Parsed static widget URI\n */\nexport interface ParsedWidgetUri {\n toolName: string;\n fullUri: string;\n}\n\n/**\n * Check if a URI is a UI resource URI\n *\n * @param uri - URI to check\n * @returns True if the URI starts with ui://\n */\nexport function isUIResourceUri(uri: string): boolean {\n return uri.startsWith(UI_RESOURCE_SCHEME);\n}\n\n/**\n * Parse a static widget URI into its components\n *\n * @param uri - URI to parse (format: ui://widget/{toolName}.html)\n * @returns Parsed components or undefined if invalid\n */\nexport function parseWidgetUri(uri: string): ParsedWidgetUri | undefined {\n const match = uri.match(UI_WIDGET_PATTERN);\n if (!match) {\n return undefined;\n }\n\n return {\n toolName: decodeURIComponent(match[1]),\n fullUri: uri,\n };\n}\n\n/**\n * Check if URI is a static widget URI (ui://widget/{toolName}.html)\n */\nexport function isStaticWidgetUri(uri: string): boolean {\n return UI_WIDGET_PATTERN.test(uri);\n}\n\n/**\n * Build a static widget URI from tool name\n *\n * @param toolName - Name of the tool\n * @returns Static widget URI (ui://widget/{toolName}.html)\n */\nexport function buildStaticWidgetUri(toolName: string): string {\n return `ui://widget/${encodeURIComponent(toolName)}.html`;\n}\n\n/**\n * Get the MIME type for UI resources based on platform.\n *\n * Per user requirement: OpenAI or default uses 'text/html+skybridge'\n *\n * @param platformType - The detected platform type\n * @returns The appropriate MIME type\n */\nexport function getUIResourceMimeType(platformType?: AIPlatformType): string {\n // Per requirement: \"for openai or default text/html+skybridge\"\n // This aligns with OpenAI's skybridge widget protocol\n switch (platformType) {\n case 'claude':\n // Claude uses standard text/html (network-blocked environment)\n return 'text/html';\n case 'gemini':\n // Gemini uses standard text/html\n return 'text/html';\n case 'openai':\n case 'cursor':\n case 'continue':\n case 'cody':\n case 'generic-mcp':\n case 'ext-apps':\n case 'unknown':\n default:\n // OpenAI and default use skybridge MIME type\n return 'text/html+skybridge';\n }\n}\n"]}
|