@frontmcp/uipack 0.12.2 → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +56 -154
- package/README.md +367 -62
- package/adapters/base-template.d.ts +30 -0
- package/adapters/base-template.d.ts.map +1 -0
- package/adapters/cdn-info.d.ts +34 -0
- package/adapters/cdn-info.d.ts.map +1 -0
- package/adapters/constants.d.ts +18 -0
- package/adapters/constants.d.ts.map +1 -0
- package/adapters/content-detector.d.ts +19 -0
- package/adapters/content-detector.d.ts.map +1 -0
- package/adapters/content-renderers.d.ts +27 -0
- package/adapters/content-renderers.d.ts.map +1 -0
- package/adapters/index.d.ts +14 -7
- package/adapters/index.d.ts.map +1 -1
- package/adapters/index.js +2343 -426
- package/adapters/render-failure.d.ts +18 -0
- package/adapters/render-failure.d.ts.map +1 -0
- package/adapters/response-builder.d.ts +34 -104
- package/adapters/response-builder.d.ts.map +1 -1
- package/adapters/serving-mode.d.ts +28 -91
- package/adapters/serving-mode.d.ts.map +1 -1
- package/adapters/template-renderer.d.ts +50 -0
- package/adapters/template-renderer.d.ts.map +1 -0
- package/adapters/type-detector.d.ts +18 -0
- package/adapters/type-detector.d.ts.map +1 -0
- package/bridge-runtime/index.js +1 -1
- package/component/index.d.ts +14 -0
- package/component/index.d.ts.map +1 -0
- package/component/index.js +2043 -0
- package/component/loader.d.ts +36 -0
- package/component/loader.d.ts.map +1 -0
- package/component/renderer.d.ts +30 -0
- package/component/renderer.d.ts.map +1 -0
- package/component/transpiler.d.ts +49 -0
- package/component/transpiler.d.ts.map +1 -0
- package/component/types.d.ts +82 -0
- package/component/types.d.ts.map +1 -0
- package/esm/adapters/index.mjs +2337 -422
- package/esm/bridge-runtime/index.mjs +1 -1
- package/esm/component/index.mjs +2013 -0
- package/esm/index.mjs +3446 -13935
- package/esm/package.json +4 -13
- package/esm/resolver/index.mjs +661 -0
- package/esm/shell/index.mjs +1406 -0
- package/esm/types/index.mjs +11 -11
- package/esm/utils/index.mjs +53 -8
- package/index.d.ts +12 -40
- package/index.d.ts.map +1 -1
- package/index.js +3579 -14218
- package/package.json +4 -13
- package/resolver/cdn-registry.d.ts +39 -0
- package/resolver/cdn-registry.d.ts.map +1 -0
- package/resolver/esm-sh.resolver.d.ts +54 -0
- package/resolver/esm-sh.resolver.d.ts.map +1 -0
- package/resolver/import-map.d.ts +47 -0
- package/resolver/import-map.d.ts.map +1 -0
- package/resolver/import-parser.d.ts +28 -0
- package/resolver/import-parser.d.ts.map +1 -0
- package/resolver/import-rewriter.d.ts +29 -0
- package/resolver/import-rewriter.d.ts.map +1 -0
- package/resolver/index.d.ts +15 -0
- package/resolver/index.d.ts.map +1 -0
- package/resolver/index.js +708 -0
- package/resolver/types.d.ts +191 -0
- package/resolver/types.d.ts.map +1 -0
- package/shell/builder.d.ts +31 -0
- package/shell/builder.d.ts.map +1 -0
- package/shell/csp.d.ts +37 -0
- package/shell/csp.d.ts.map +1 -0
- package/shell/custom-shell-applier.d.ts +33 -0
- package/shell/custom-shell-applier.d.ts.map +1 -0
- package/shell/custom-shell-resolver.d.ts +47 -0
- package/shell/custom-shell-resolver.d.ts.map +1 -0
- package/shell/custom-shell-types.d.ts +75 -0
- package/shell/custom-shell-types.d.ts.map +1 -0
- package/shell/custom-shell-validator.d.ts +26 -0
- package/shell/custom-shell-validator.d.ts.map +1 -0
- package/shell/data-injector.d.ts +40 -0
- package/shell/data-injector.d.ts.map +1 -0
- package/shell/index.d.ts +19 -0
- package/shell/index.d.ts.map +1 -0
- package/shell/index.js +1453 -0
- package/shell/types.d.ts +54 -0
- package/shell/types.d.ts.map +1 -0
- package/types/index.d.ts +1 -3
- package/types/index.d.ts.map +1 -1
- package/types/index.js +11 -11
- package/types/ui-config.d.ts +50 -11
- package/types/ui-config.d.ts.map +1 -1
- package/types/ui-runtime.d.ts +8 -82
- package/types/ui-runtime.d.ts.map +1 -1
- package/utils/index.d.ts +9 -3
- package/utils/index.d.ts.map +1 -1
- package/utils/index.js +59 -7
- package/adapters/platform-meta.constants.d.ts +0 -26
- package/adapters/platform-meta.constants.d.ts.map +0 -1
- package/adapters/platform-meta.d.ts +0 -234
- package/adapters/platform-meta.d.ts.map +0 -1
- package/base-template/bridge.d.ts +0 -90
- package/base-template/bridge.d.ts.map +0 -1
- package/base-template/default-base-template.d.ts +0 -91
- package/base-template/default-base-template.d.ts.map +0 -1
- package/base-template/index.d.ts +0 -15
- package/base-template/index.d.ts.map +0 -1
- package/base-template/index.js +0 -1393
- package/base-template/polyfills.d.ts +0 -31
- package/base-template/polyfills.d.ts.map +0 -1
- package/base-template/theme-styles.d.ts +0 -74
- package/base-template/theme-styles.d.ts.map +0 -1
- package/build/builders/base-builder.d.ts +0 -124
- package/build/builders/base-builder.d.ts.map +0 -1
- package/build/builders/esbuild-config.d.ts +0 -94
- package/build/builders/esbuild-config.d.ts.map +0 -1
- package/build/builders/hybrid-builder.d.ts +0 -93
- package/build/builders/hybrid-builder.d.ts.map +0 -1
- package/build/builders/index.d.ts +0 -17
- package/build/builders/index.d.ts.map +0 -1
- package/build/builders/inline-builder.d.ts +0 -83
- package/build/builders/inline-builder.d.ts.map +0 -1
- package/build/builders/static-builder.d.ts +0 -78
- package/build/builders/static-builder.d.ts.map +0 -1
- package/build/builders/types.d.ts +0 -341
- package/build/builders/types.d.ts.map +0 -1
- package/build/cdn-resources.d.ts +0 -244
- package/build/cdn-resources.d.ts.map +0 -1
- package/build/hybrid-data.d.ts +0 -127
- package/build/hybrid-data.d.ts.map +0 -1
- package/build/index.d.ts +0 -299
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -8699
- package/build/ui-components-browser.d.ts +0 -64
- package/build/ui-components-browser.d.ts.map +0 -1
- package/build/widget-manifest.d.ts +0 -362
- package/build/widget-manifest.d.ts.map +0 -1
- package/bundler/cache.d.ts +0 -173
- package/bundler/cache.d.ts.map +0 -1
- package/bundler/file-cache/component-builder.d.ts +0 -167
- package/bundler/file-cache/component-builder.d.ts.map +0 -1
- package/bundler/file-cache/hash-calculator.d.ts +0 -155
- package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
- package/bundler/file-cache/index.d.ts +0 -12
- package/bundler/file-cache/index.d.ts.map +0 -1
- package/bundler/file-cache/storage/filesystem.d.ts +0 -149
- package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
- package/bundler/file-cache/storage/index.d.ts +0 -11
- package/bundler/file-cache/storage/index.d.ts.map +0 -1
- package/bundler/file-cache/storage/interface.d.ts +0 -152
- package/bundler/file-cache/storage/interface.d.ts.map +0 -1
- package/bundler/file-cache/storage/redis.d.ts +0 -139
- package/bundler/file-cache/storage/redis.d.ts.map +0 -1
- package/bundler/index.d.ts +0 -35
- package/bundler/index.d.ts.map +0 -1
- package/bundler/index.js +0 -2953
- package/bundler/sandbox/enclave-adapter.d.ts +0 -121
- package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
- package/bundler/sandbox/executor.d.ts +0 -14
- package/bundler/sandbox/executor.d.ts.map +0 -1
- package/bundler/sandbox/policy.d.ts +0 -62
- package/bundler/sandbox/policy.d.ts.map +0 -1
- package/bundler/types.d.ts +0 -702
- package/bundler/types.d.ts.map +0 -1
- package/dependency/cdn-registry.d.ts +0 -98
- package/dependency/cdn-registry.d.ts.map +0 -1
- package/dependency/import-map.d.ts +0 -186
- package/dependency/import-map.d.ts.map +0 -1
- package/dependency/import-parser.d.ts +0 -82
- package/dependency/import-parser.d.ts.map +0 -1
- package/dependency/index.d.ts +0 -17
- package/dependency/index.d.ts.map +0 -1
- package/dependency/index.js +0 -3180
- package/dependency/resolver.d.ts +0 -164
- package/dependency/resolver.d.ts.map +0 -1
- package/dependency/schemas.d.ts +0 -486
- package/dependency/schemas.d.ts.map +0 -1
- package/dependency/template-loader.d.ts +0 -204
- package/dependency/template-loader.d.ts.map +0 -1
- package/dependency/template-processor.d.ts +0 -118
- package/dependency/template-processor.d.ts.map +0 -1
- package/dependency/types.d.ts +0 -739
- package/dependency/types.d.ts.map +0 -1
- package/esm/base-template/index.mjs +0 -1359
- package/esm/build/index.mjs +0 -8601
- package/esm/bundler/index.mjs +0 -2895
- package/esm/dependency/index.mjs +0 -3068
- package/esm/handlebars/index.mjs +0 -587
- package/esm/registry/index.mjs +0 -6305
- package/esm/renderers/index.mjs +0 -1557
- package/esm/runtime/index.mjs +0 -5361
- package/esm/styles/index.mjs +0 -171
- package/esm/theme/index.mjs +0 -756
- package/esm/tool-template/index.mjs +0 -3652
- package/esm/validation/index.mjs +0 -542
- package/handlebars/expression-extractor.d.ts +0 -147
- package/handlebars/expression-extractor.d.ts.map +0 -1
- package/handlebars/helpers.d.ts +0 -339
- package/handlebars/helpers.d.ts.map +0 -1
- package/handlebars/index.d.ts +0 -195
- package/handlebars/index.d.ts.map +0 -1
- package/handlebars/index.js +0 -659
- package/preview/claude-preview.d.ts +0 -67
- package/preview/claude-preview.d.ts.map +0 -1
- package/preview/generic-preview.d.ts +0 -66
- package/preview/generic-preview.d.ts.map +0 -1
- package/preview/index.d.ts +0 -36
- package/preview/index.d.ts.map +0 -1
- package/preview/openai-preview.d.ts +0 -70
- package/preview/openai-preview.d.ts.map +0 -1
- package/preview/types.d.ts +0 -199
- package/preview/types.d.ts.map +0 -1
- package/registry/index.d.ts +0 -46
- package/registry/index.d.ts.map +0 -1
- package/registry/index.js +0 -6342
- package/registry/render-template.d.ts +0 -91
- package/registry/render-template.d.ts.map +0 -1
- package/registry/tool-ui.registry.d.ts +0 -294
- package/registry/tool-ui.registry.d.ts.map +0 -1
- package/registry/uri-utils.d.ts +0 -56
- package/registry/uri-utils.d.ts.map +0 -1
- package/renderers/cache.d.ts +0 -145
- package/renderers/cache.d.ts.map +0 -1
- package/renderers/html.renderer.d.ts +0 -123
- package/renderers/html.renderer.d.ts.map +0 -1
- package/renderers/index.d.ts +0 -36
- package/renderers/index.d.ts.map +0 -1
- package/renderers/index.js +0 -1603
- package/renderers/mdx-client.renderer.d.ts +0 -124
- package/renderers/mdx-client.renderer.d.ts.map +0 -1
- package/renderers/registry.d.ts +0 -133
- package/renderers/registry.d.ts.map +0 -1
- package/renderers/types.d.ts +0 -343
- package/renderers/types.d.ts.map +0 -1
- package/renderers/utils/detect.d.ts +0 -107
- package/renderers/utils/detect.d.ts.map +0 -1
- package/renderers/utils/hash.d.ts +0 -40
- package/renderers/utils/hash.d.ts.map +0 -1
- package/renderers/utils/index.d.ts +0 -9
- package/renderers/utils/index.d.ts.map +0 -1
- package/renderers/utils/transpiler.d.ts +0 -70
- package/renderers/utils/transpiler.d.ts.map +0 -1
- package/runtime/adapters/html.adapter.d.ts +0 -59
- package/runtime/adapters/html.adapter.d.ts.map +0 -1
- package/runtime/adapters/index.d.ts +0 -26
- package/runtime/adapters/index.d.ts.map +0 -1
- package/runtime/adapters/mdx.adapter.d.ts +0 -73
- package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
- package/runtime/adapters/types.d.ts +0 -95
- package/runtime/adapters/types.d.ts.map +0 -1
- package/runtime/csp.d.ts +0 -48
- package/runtime/csp.d.ts.map +0 -1
- package/runtime/index.d.ts +0 -17
- package/runtime/index.d.ts.map +0 -1
- package/runtime/index.js +0 -5432
- package/runtime/mcp-bridge.d.ts +0 -101
- package/runtime/mcp-bridge.d.ts.map +0 -1
- package/runtime/renderer-runtime.d.ts +0 -133
- package/runtime/renderer-runtime.d.ts.map +0 -1
- package/runtime/sanitizer.d.ts +0 -180
- package/runtime/sanitizer.d.ts.map +0 -1
- package/runtime/types.d.ts +0 -415
- package/runtime/types.d.ts.map +0 -1
- package/runtime/wrapper.d.ts +0 -421
- package/runtime/wrapper.d.ts.map +0 -1
- package/styles/index.d.ts +0 -8
- package/styles/index.d.ts.map +0 -1
- package/styles/index.js +0 -222
- package/styles/variants.d.ts +0 -51
- package/styles/variants.d.ts.map +0 -1
- package/theme/cdn.d.ts +0 -195
- package/theme/cdn.d.ts.map +0 -1
- package/theme/css-to-theme.d.ts +0 -64
- package/theme/css-to-theme.d.ts.map +0 -1
- package/theme/index.d.ts +0 -19
- package/theme/index.d.ts.map +0 -1
- package/theme/index.js +0 -814
- package/theme/platforms.d.ts +0 -102
- package/theme/platforms.d.ts.map +0 -1
- package/theme/presets/github-openai.d.ts +0 -50
- package/theme/presets/github-openai.d.ts.map +0 -1
- package/theme/presets/index.d.ts +0 -11
- package/theme/presets/index.d.ts.map +0 -1
- package/theme/theme.d.ts +0 -396
- package/theme/theme.d.ts.map +0 -1
- package/tool-template/builder.d.ts +0 -213
- package/tool-template/builder.d.ts.map +0 -1
- package/tool-template/index.d.ts +0 -16
- package/tool-template/index.d.ts.map +0 -1
- package/tool-template/index.js +0 -3690
- package/validation/error-box.d.ts +0 -56
- package/validation/error-box.d.ts.map +0 -1
- package/validation/index.d.ts +0 -13
- package/validation/index.d.ts.map +0 -1
- package/validation/index.js +0 -576
- package/validation/schema-paths.d.ts +0 -118
- package/validation/schema-paths.d.ts.map +0 -1
- package/validation/template-validator.d.ts +0 -143
- package/validation/template-validator.d.ts.map +0 -1
- package/validation/wrapper.d.ts +0 -97
- package/validation/wrapper.d.ts.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render Failure Type Guard
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Shape of a UI render failure result.
|
|
8
|
+
*/
|
|
9
|
+
export interface UIRenderFailure {
|
|
10
|
+
reason: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Type guard for UI render failure objects.
|
|
14
|
+
*
|
|
15
|
+
* A render failure is an object with a `reason` string and no `meta` property.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isUIRenderFailure(result: unknown): result is UIRenderFailure;
|
|
18
|
+
//# sourceMappingURL=render-failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-failure.d.ts","sourceRoot":"","sources":["../../src/adapters/render-failure.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,eAAe,CAM5E"}
|
|
@@ -1,121 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @description Tool response content builder for different serving modes and platforms.
|
|
2
|
+
* Response Builder
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
* handling the various output formats based on serving mode and platform capabilities.
|
|
4
|
+
* Formats MCP tool response content with UI data per the MCP Apps protocol.
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
* - content: [{ type: 'text', text: '<!DOCTYPE html>...' }] (single block with raw HTML)
|
|
10
|
-
* - structuredContent: raw tool output (set by SDK, not this module)
|
|
6
|
+
* @packageDocumentation
|
|
11
7
|
*/
|
|
12
|
-
import type {
|
|
13
|
-
import type { AIPlatformType } from './platform-meta';
|
|
8
|
+
import type { AdapterPlatformType } from './serving-mode';
|
|
14
9
|
/**
|
|
15
|
-
*
|
|
10
|
+
* Formatted tool response with UI content.
|
|
16
11
|
*/
|
|
17
|
-
export interface
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
export interface ToolResponseContent {
|
|
13
|
+
/** Text content blocks */
|
|
14
|
+
content: Array<{
|
|
15
|
+
type: 'text';
|
|
16
|
+
text: string;
|
|
17
|
+
}>;
|
|
18
|
+
/** Structured content for clients that support it */
|
|
19
|
+
structuredContent?: Record<string, unknown>;
|
|
20
|
+
/** Response format hint */
|
|
21
|
+
format?: string;
|
|
22
|
+
/** Whether the text content was cleared in favor of structured */
|
|
23
|
+
contentCleared?: boolean;
|
|
24
|
+
/** UI metadata to merge into _meta */
|
|
25
|
+
_meta?: Record<string, unknown>;
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
|
-
* Options for building tool response content.
|
|
28
|
+
* Options for building a tool response with UI content.
|
|
23
29
|
*/
|
|
24
|
-
export interface
|
|
25
|
-
/**
|
|
26
|
-
* The raw output from the tool execution.
|
|
27
|
-
*/
|
|
30
|
+
export interface BuildToolResponseContentOptions {
|
|
31
|
+
/** Raw tool output */
|
|
28
32
|
rawOutput: unknown;
|
|
29
|
-
/**
|
|
30
|
-
* Rendered HTML content (for inline mode).
|
|
31
|
-
*/
|
|
33
|
+
/** Rendered HTML content (if available) */
|
|
32
34
|
htmlContent?: string;
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
servingMode: Exclude<WidgetServingMode, 'auto'>;
|
|
37
|
-
/**
|
|
38
|
-
* Whether to use structuredContent format.
|
|
39
|
-
* When true, raw HTML is returned in content and rawOutput goes to structuredContent.
|
|
40
|
-
*/
|
|
35
|
+
/** The effective serving mode */
|
|
36
|
+
servingMode: string;
|
|
37
|
+
/** Whether to include structuredContent */
|
|
41
38
|
useStructuredContent: boolean;
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
*/
|
|
45
|
-
platformType: AIPlatformType;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Result of building tool response content.
|
|
49
|
-
*/
|
|
50
|
-
export interface ToolResponseContent {
|
|
51
|
-
/**
|
|
52
|
-
* The content blocks to include in the response.
|
|
53
|
-
* For structuredContent format: single TextContent with raw HTML.
|
|
54
|
-
* For widget format: empty (widget reads from _meta).
|
|
55
|
-
*/
|
|
56
|
-
content: TextContentBlock[];
|
|
57
|
-
/**
|
|
58
|
-
* Structured content containing raw tool output.
|
|
59
|
-
* Set when useStructuredContent is true.
|
|
60
|
-
*/
|
|
61
|
-
structuredContent?: unknown;
|
|
62
|
-
/**
|
|
63
|
-
* Metadata to merge into result._meta.
|
|
64
|
-
*/
|
|
65
|
-
meta?: Record<string, unknown>;
|
|
66
|
-
/**
|
|
67
|
-
* Whether the content was cleared (widget platform handles display).
|
|
68
|
-
*/
|
|
69
|
-
contentCleared: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Format used for the response.
|
|
72
|
-
*/
|
|
73
|
-
format: 'structured-content' | 'widget' | 'markdown' | 'json-only';
|
|
39
|
+
/** The platform type */
|
|
40
|
+
platformType: AdapterPlatformType;
|
|
74
41
|
}
|
|
75
42
|
/**
|
|
76
|
-
* Build
|
|
77
|
-
*
|
|
78
|
-
* This function consolidates the content formatting logic that was previously
|
|
79
|
-
* spread across the call-tool.flow.ts finalize stage.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* // OpenAI/ext-apps: HTML goes directly in content
|
|
84
|
-
* const openaiResult = buildToolResponseContent({
|
|
85
|
-
* rawOutput: { temperature: 72 },
|
|
86
|
-
* htmlContent: '<!DOCTYPE html>...',
|
|
87
|
-
* servingMode: 'inline',
|
|
88
|
-
* useStructuredContent: true,
|
|
89
|
-
* platformType: 'openai',
|
|
90
|
-
* });
|
|
91
|
-
* // result.content = [{ type: 'text', text: '<!DOCTYPE html>...' }]
|
|
92
|
-
* // result.structuredContent = { temperature: 72 }
|
|
93
|
-
* // result.format = 'structured-content'
|
|
94
|
-
*
|
|
95
|
-
* // Claude/generic platforms: JSON in content, HTML via _meta['ui/html']
|
|
96
|
-
* const claudeResult = buildToolResponseContent({
|
|
97
|
-
* rawOutput: { temperature: 72 },
|
|
98
|
-
* htmlContent: '<!DOCTYPE html>...',
|
|
99
|
-
* servingMode: 'inline',
|
|
100
|
-
* useStructuredContent: true,
|
|
101
|
-
* platformType: 'claude',
|
|
102
|
-
* });
|
|
103
|
-
* // result.content = [{ type: 'text', text: '{"temperature":72}' }]
|
|
104
|
-
* // result.structuredContent = { temperature: 72 }
|
|
105
|
-
* // Note: HTML is set in _meta['ui/html'] by the call-tool flow, not this function
|
|
106
|
-
* // result.format = 'structured-content'
|
|
43
|
+
* Build a formatted tool response with UI content.
|
|
107
44
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* servingMode: 'inline',
|
|
113
|
-
* useStructuredContent: false,
|
|
114
|
-
* platformType: 'gemini',
|
|
115
|
-
* });
|
|
116
|
-
* // result.content = [{ type: 'text', text: '{"temperature":72}' }]
|
|
117
|
-
* // result.format = 'json-only'
|
|
118
|
-
* ```
|
|
45
|
+
* Includes:
|
|
46
|
+
* - `content`: Text summary of the output
|
|
47
|
+
* - `structuredContent`: Raw output as structured data (when supported)
|
|
48
|
+
* - `_meta`: Platform-specific HTML key with rendered content
|
|
119
49
|
*/
|
|
120
|
-
export declare function buildToolResponseContent(options:
|
|
50
|
+
export declare function buildToolResponseContent(options: BuildToolResponseContentOptions): ToolResponseContent;
|
|
121
51
|
//# sourceMappingURL=response-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-builder.d.ts","sourceRoot":"","sources":["../../src/adapters/response-builder.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"response-builder.d.ts","sourceRoot":"","sources":["../../src/adapters/response-builder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0BAA0B;IAC1B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,sBAAsB;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,oBAAoB,EAAE,OAAO,CAAC;IAC9B,wBAAwB;IACxB,YAAY,EAAE,mBAAmB,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,mBAAmB,CAkCtG"}
|
|
@@ -1,107 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @description Serving mode resolution for auto-detection based on client capabilities.
|
|
2
|
+
* Serving Mode Resolution
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
* based on the MCP client's capabilities:
|
|
4
|
+
* Platform-aware serving mode resolution for MCP tool UI.
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
* - **Claude**: Use `'inline'` mode with structuredContent (raw HTML + raw output)
|
|
10
|
-
* - **Gemini/unsupported**: Skip UI entirely (return JSON only)
|
|
11
|
-
*
|
|
12
|
-
* When a specific mode is forced (not 'auto'), but the client doesn't support it,
|
|
13
|
-
* the UI is skipped to prevent broken experiences.
|
|
6
|
+
* @packageDocumentation
|
|
14
7
|
*/
|
|
15
|
-
import type { WidgetServingMode } from '../types';
|
|
16
|
-
import type { AIPlatformType } from './platform-meta';
|
|
17
8
|
/**
|
|
18
|
-
*
|
|
9
|
+
* Platform types recognized by the serving mode resolver.
|
|
19
10
|
*/
|
|
20
|
-
export
|
|
21
|
-
/**
|
|
22
|
-
* The effective serving mode to use.
|
|
23
|
-
* `null` means UI should be skipped entirely.
|
|
24
|
-
*/
|
|
25
|
-
effectiveMode: Exclude<WidgetServingMode, 'auto'> | null;
|
|
26
|
-
/**
|
|
27
|
-
* Whether the client supports widget UI.
|
|
28
|
-
*/
|
|
29
|
-
supportsUI: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Whether structuredContent should be used (Claude).
|
|
32
|
-
* When true, the response includes raw tool output in structuredContent
|
|
33
|
-
* and raw HTML in a single content block.
|
|
34
|
-
*/
|
|
35
|
-
useStructuredContent: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Reason for the decision (useful for logging/debugging).
|
|
38
|
-
*/
|
|
39
|
-
reason: string;
|
|
40
|
-
}
|
|
11
|
+
export type AdapterPlatformType = 'openai' | 'ext-apps' | 'claude' | 'gemini' | 'generic-mcp' | 'unknown' | string;
|
|
41
12
|
/**
|
|
42
|
-
*
|
|
13
|
+
* Input for serving mode resolution.
|
|
43
14
|
*/
|
|
44
15
|
export interface ResolveServingModeOptions {
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
configuredMode?: WidgetServingMode;
|
|
50
|
-
/**
|
|
51
|
-
* The detected platform type.
|
|
52
|
-
*/
|
|
53
|
-
platformType: AIPlatformType;
|
|
16
|
+
/** The configured serving mode from the tool's UI config */
|
|
17
|
+
configuredMode: string;
|
|
18
|
+
/** The detected platform type */
|
|
19
|
+
platformType: AdapterPlatformType;
|
|
54
20
|
}
|
|
55
21
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* This function implements the 'auto' serving mode logic:
|
|
59
|
-
* 1. If `configuredMode` is 'auto', select the best mode for the platform
|
|
60
|
-
* 2. If a specific mode is forced, check if the platform supports it
|
|
61
|
-
* 3. If the platform doesn't support the mode, return `null` (skip UI)
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const result = resolveServingMode({
|
|
66
|
-
* configuredMode: 'auto',
|
|
67
|
-
* platformType: 'openai',
|
|
68
|
-
* });
|
|
69
|
-
* // { effectiveMode: 'inline', useStructuredContent: true, supportsUI: true, ... }
|
|
70
|
-
*
|
|
71
|
-
* const claudeResult = resolveServingMode({
|
|
72
|
-
* configuredMode: 'auto',
|
|
73
|
-
* platformType: 'claude',
|
|
74
|
-
* });
|
|
75
|
-
* // { effectiveMode: 'inline', useStructuredContent: true, supportsUI: true, ... }
|
|
76
|
-
*
|
|
77
|
-
* const geminiResult = resolveServingMode({
|
|
78
|
-
* configuredMode: 'auto',
|
|
79
|
-
* platformType: 'gemini',
|
|
80
|
-
* });
|
|
81
|
-
* // { effectiveMode: null, useStructuredContent: false, supportsUI: false, ... }
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
export declare function resolveServingMode(options: ResolveServingModeOptions): ResolvedServingMode;
|
|
85
|
-
/**
|
|
86
|
-
* Check if a platform supports a specific serving mode.
|
|
87
|
-
*/
|
|
88
|
-
export declare function isPlatformModeSupported(platformType: AIPlatformType, mode: WidgetServingMode): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Get the default serving mode for a platform.
|
|
91
|
-
*/
|
|
92
|
-
export declare function getDefaultServingMode(platformType: AIPlatformType): Exclude<WidgetServingMode, 'auto'> | null;
|
|
93
|
-
/**
|
|
94
|
-
* Check if a platform uses structuredContent format.
|
|
95
|
-
* When true, responses include raw tool output in structuredContent
|
|
96
|
-
* and raw HTML in a single content block.
|
|
22
|
+
* Result of serving mode resolution.
|
|
97
23
|
*/
|
|
98
|
-
export
|
|
24
|
+
export interface ServingModeResult {
|
|
25
|
+
/** The original configured mode */
|
|
26
|
+
mode: string;
|
|
27
|
+
/** Whether the platform supports UI rendering */
|
|
28
|
+
supportsUI: boolean;
|
|
29
|
+
/** The effective serving mode to use, or null if UI not supported */
|
|
30
|
+
effectiveMode: string | null;
|
|
31
|
+
/** Whether to include structuredContent in the tool response */
|
|
32
|
+
useStructuredContent: boolean;
|
|
33
|
+
/** Reason for the decision (for logging) */
|
|
34
|
+
reason?: string;
|
|
35
|
+
}
|
|
99
36
|
/**
|
|
100
|
-
*
|
|
37
|
+
* Resolve the effective serving mode based on platform capabilities.
|
|
101
38
|
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
39
|
+
* - Gemini: No UI support
|
|
40
|
+
* - OpenAI, ext-apps, claude, generic-mcp, unknown: UI supported, inline mode
|
|
41
|
+
* - OpenAI/ext-apps/generic-mcp/unknown: include structuredContent
|
|
105
42
|
*/
|
|
106
|
-
export declare function
|
|
43
|
+
export declare function resolveServingMode(options: ResolveServingModeOptions): ServingModeResult;
|
|
107
44
|
//# sourceMappingURL=serving-mode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serving-mode.d.ts","sourceRoot":"","sources":["../../src/adapters/serving-mode.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"serving-mode.d.ts","sourceRoot":"","sources":["../../src/adapters/serving-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,CAAC;AAEnH;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,YAAY,EAAE,mBAAmB,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,UAAU,EAAE,OAAO,CAAC;IACpB,qEAAqE;IACrE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gEAAgE;IAChE,oBAAoB,EAAE,OAAO,CAAC;IAC9B,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,iBAAiB,CA6CxF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Renderer
|
|
3
|
+
*
|
|
4
|
+
* Core rendering function that executes templates and wraps results.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { ImportResolver } from '../resolver/types';
|
|
9
|
+
/**
|
|
10
|
+
* Options for rendering a tool template.
|
|
11
|
+
*/
|
|
12
|
+
export interface RenderToolTemplateOptions {
|
|
13
|
+
/** Tool name */
|
|
14
|
+
toolName: string;
|
|
15
|
+
/** Tool input */
|
|
16
|
+
input: unknown;
|
|
17
|
+
/** Tool output */
|
|
18
|
+
output: unknown;
|
|
19
|
+
/** The template (function, string, or React component) */
|
|
20
|
+
template: unknown;
|
|
21
|
+
/** Platform type for rendering decisions */
|
|
22
|
+
platformType?: string;
|
|
23
|
+
/** Optional import resolver with CDN overrides */
|
|
24
|
+
resolver?: ImportResolver;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of rendering a tool template.
|
|
28
|
+
*/
|
|
29
|
+
export interface RenderToolTemplateResult {
|
|
30
|
+
/** The rendered HTML string */
|
|
31
|
+
html: string;
|
|
32
|
+
/** The detected UI type */
|
|
33
|
+
uiType: string;
|
|
34
|
+
/** Content hash */
|
|
35
|
+
hash: string;
|
|
36
|
+
/** Size in bytes */
|
|
37
|
+
size: number;
|
|
38
|
+
/** Platform-specific metadata */
|
|
39
|
+
meta: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Render a tool template into HTML.
|
|
43
|
+
*
|
|
44
|
+
* - Function templates: Calls `template(ctx)` with createTemplateHelpers()
|
|
45
|
+
* - React components: Delegates to renderComponent() from uipack/component
|
|
46
|
+
* - String templates: Wraps in buildShell()
|
|
47
|
+
* - Auto-detect: wraps detected content (chart, mermaid, PDF, HTML)
|
|
48
|
+
*/
|
|
49
|
+
export declare function renderToolTemplate(options: RenderToolTemplateOptions): RenderToolTemplateResult;
|
|
50
|
+
//# sourceMappingURL=template-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-renderer.d.ts","sourceRoot":"","sources":["../../src/adapters/template-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,0DAA0D;IAC1D,QAAQ,EAAE,OAAO,CAAC;IAClB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,wBAAwB,CAwG/F"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI Type Detector
|
|
3
|
+
*
|
|
4
|
+
* Detects the UIType from a template value.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { UIType } from '../types/ui-runtime';
|
|
9
|
+
/**
|
|
10
|
+
* Detect the UIType from a template value.
|
|
11
|
+
*
|
|
12
|
+
* - Function with `$$typeof` or prototype with `render` → `'react'`
|
|
13
|
+
* - Other function → `'html'` (template builder function)
|
|
14
|
+
* - String → `'html'` (or `'markdown'` if it looks like markdown)
|
|
15
|
+
* - Otherwise → `'auto'`
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectUIType(template: unknown): UIType;
|
|
18
|
+
//# sourceMappingURL=type-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-detector.d.ts","sourceRoot":"","sources":["../../src/adapters/type-detector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CA4CtD"}
|
package/bridge-runtime/index.js
CHANGED
|
@@ -975,7 +975,7 @@ function minifyJS(code) {
|
|
|
975
975
|
if (code.length > MAX_MINIFY_CODE_LENGTH) {
|
|
976
976
|
return code;
|
|
977
977
|
}
|
|
978
|
-
return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(
|
|
978
|
+
return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/\s+/g, " ").replace(/\s*([{};,:()[\]])\s*/g, "$1").replace(/;\}/g, "}").trim();
|
|
979
979
|
}
|
|
980
980
|
function generatePlatformBundle(platform, options = {}) {
|
|
981
981
|
const platformAdapters = {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Module
|
|
3
|
+
*
|
|
4
|
+
* Polymorphic UI component loading — resolve npm packages,
|
|
5
|
+
* local files, URLs, or inline functions into renderable HTML.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export type { NpmSource, FileSource, ImportSource, FunctionSource, UISource, UIConfig, ComponentMeta, ResolvedComponent, } from './types';
|
|
10
|
+
export { isNpmSource, isFileSource, isImportSource, isFunctionSource, FRONTMCP_META_KEY } from './types';
|
|
11
|
+
export { resolveUISource, generateMountScript } from './loader';
|
|
12
|
+
export { transpileReactSource, bundleFileSource, extractDefaultExportName } from './transpiler';
|
|
13
|
+
export { renderComponent } from './renderer';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGzG,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGhE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGhG,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|