@frontmcp/uipack 1.9.1 → 1.9.3
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/adapters/index.d.ts +1 -1
- package/adapters/index.d.ts.map +1 -1
- package/adapters/index.js +84 -23
- package/adapters/template-renderer.d.ts +15 -3
- package/adapters/template-renderer.d.ts.map +1 -1
- package/bridge-runtime/iife-generator.d.ts +7 -0
- package/bridge-runtime/iife-generator.d.ts.map +1 -1
- package/bridge-runtime/index.d.ts +1 -1
- package/bridge-runtime/index.d.ts.map +1 -1
- package/bridge-runtime/index.js +52 -11
- package/component/index.js +61 -16
- package/esm/adapters/index.mjs +83 -23
- package/esm/bridge-runtime/index.mjs +50 -11
- package/esm/component/index.mjs +61 -16
- package/esm/index.mjs +83 -23
- package/esm/package.json +2 -2
- package/esm/shell/index.mjs +61 -16
- package/index.js +84 -23
- package/package.json +2 -2
- package/shell/builder.d.ts.map +1 -1
- package/shell/data-injector.d.ts +3 -1
- package/shell/data-injector.d.ts.map +1 -1
- package/shell/index.js +61 -16
- package/shell/trusted-html.d.ts +2 -2
- package/shell/types.d.ts +2 -0
- package/shell/types.d.ts.map +1 -1
- package/types/ui-config.d.ts +23 -20
- package/types/ui-config.d.ts.map +1 -1
- package/types/ui-runtime.d.ts +1 -1
package/shell/index.js
CHANGED
|
@@ -51,6 +51,8 @@ __export(shell_exports, {
|
|
|
51
51
|
module.exports = __toCommonJS(shell_exports);
|
|
52
52
|
|
|
53
53
|
// libs/uipack/src/bridge-runtime/iife-generator.ts
|
|
54
|
+
var WIDGET_CALL_META_KEY = "frontmcp/widgetCall";
|
|
55
|
+
var MCP_APPS_DISPLAY_MODES = ["inline", "fullscreen", "pip"];
|
|
54
56
|
function generateBridgeIIFE(options = {}) {
|
|
55
57
|
const { debug = false, trustedOrigins = [], minify = false } = options;
|
|
56
58
|
const adapters = options.adapters || ["openai", "ext-apps", "claude", "gemini", "generic"];
|
|
@@ -98,6 +100,7 @@ function generateBridgeIIFE(options = {}) {
|
|
|
98
100
|
parts.push("bridge.initialize().then(function() {");
|
|
99
101
|
parts.push(' log("Bridge initialized with adapter: " + bridge.adapterId);');
|
|
100
102
|
parts.push(' window.dispatchEvent(new CustomEvent("bridge:ready", { detail: { adapter: bridge.adapterId } }));');
|
|
103
|
+
parts.push(" if (window.__mcpDisplayMode) bridge.requestDisplayMode(window.__mcpDisplayMode).catch(function() {});");
|
|
101
104
|
parts.push("}).catch(function(err) {");
|
|
102
105
|
parts.push(' console.error("[FrontMcpBridge] Init failed:", err);');
|
|
103
106
|
parts.push(' window.dispatchEvent(new CustomEvent("bridge:error", { detail: { error: err } }));');
|
|
@@ -431,6 +434,9 @@ var OpenAIAdapter = {
|
|
|
431
434
|
return Promise.resolve();
|
|
432
435
|
},
|
|
433
436
|
requestDisplayMode: function(context, mode) {
|
|
437
|
+
if (window.openai && typeof window.openai.requestDisplayMode === 'function') {
|
|
438
|
+
return Promise.resolve(window.openai.requestDisplayMode({ mode: mode }));
|
|
439
|
+
}
|
|
434
440
|
return Promise.resolve();
|
|
435
441
|
},
|
|
436
442
|
setSize: function(context, size) {
|
|
@@ -468,6 +474,7 @@ var ExtAppsAdapter = {
|
|
|
468
474
|
hostCapabilities: {},
|
|
469
475
|
handshakeSettled: false,
|
|
470
476
|
pendingSize: null,
|
|
477
|
+
modelContext: null,
|
|
471
478
|
canHandle: function() {
|
|
472
479
|
if (typeof window === 'undefined') return false;
|
|
473
480
|
if (window.parent === window) return false;
|
|
@@ -546,8 +553,19 @@ var ExtAppsAdapter = {
|
|
|
546
553
|
|
|
547
554
|
if ('method' in data && !('id' in data)) {
|
|
548
555
|
this.handleNotification(context, data);
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
if ('method' in data && 'id' in data) {
|
|
560
|
+
this.handleRequest(context, data, event.origin);
|
|
549
561
|
}
|
|
550
562
|
},
|
|
563
|
+
handleRequest: function(context, request, origin) {
|
|
564
|
+
// ui/resource-teardown: the host is about to unmount the view; reply once listeners have cleaned up.
|
|
565
|
+
if (request.method !== 'ui/resource-teardown') return;
|
|
566
|
+
window.dispatchEvent(new CustomEvent('bridge:teardown', { detail: {} }));
|
|
567
|
+
window.parent.postMessage({ jsonrpc: '2.0', id: request.id, result: {} }, origin);
|
|
568
|
+
},
|
|
551
569
|
handleNotification: function(context, notification) {
|
|
552
570
|
var params = notification.params || {};
|
|
553
571
|
switch (notification.method) {
|
|
@@ -571,6 +589,7 @@ var ExtAppsAdapter = {
|
|
|
571
589
|
Object.assign(context.hostContext, params);
|
|
572
590
|
context.notifyContextChange(params);
|
|
573
591
|
break;
|
|
592
|
+
case 'ui/notifications/tool-cancelled':
|
|
574
593
|
case 'ui/notifications/cancelled':
|
|
575
594
|
window.dispatchEvent(new CustomEvent('tool:cancelled', { detail: { reason: params.reason } }));
|
|
576
595
|
break;
|
|
@@ -635,7 +654,7 @@ var ExtAppsAdapter = {
|
|
|
635
654
|
var id = ++this.requestId;
|
|
636
655
|
var params = {
|
|
637
656
|
appInfo: { name: 'FrontMCP Widget', version: '1.0.0' },
|
|
638
|
-
appCapabilities: { tools: { listChanged: false } },
|
|
657
|
+
appCapabilities: { tools: { listChanged: false }, availableDisplayModes: ${JSON.stringify(MCP_APPS_DISPLAY_MODES)} },
|
|
639
658
|
protocolVersion: '2024-11-05'
|
|
640
659
|
};
|
|
641
660
|
|
|
@@ -703,20 +722,25 @@ var ExtAppsAdapter = {
|
|
|
703
722
|
return Promise.reject(new Error('Server tool proxy not supported'));
|
|
704
723
|
}
|
|
705
724
|
// Per ext-apps spec: use standard MCP method 'tools/call' (not 'ui/callServerTool')
|
|
706
|
-
return this.sendRequest('tools/call', { name: name, arguments: args || {} });
|
|
725
|
+
return this.sendRequest('tools/call', { name: name, arguments: args || {}, _meta: { '${WIDGET_CALL_META_KEY}': true } });
|
|
707
726
|
},
|
|
708
727
|
sendMessage: function(context, content) {
|
|
709
728
|
return this.sendRequest('ui/message', { content: content });
|
|
710
729
|
},
|
|
711
730
|
openLink: function(context, url) {
|
|
712
|
-
if (!this.hostCapabilities.openLink) {
|
|
731
|
+
if (!this.hostCapabilities.openLinks && !this.hostCapabilities.openLink) {
|
|
713
732
|
window.open(url, '_blank', 'noopener,noreferrer');
|
|
714
733
|
return Promise.resolve();
|
|
715
734
|
}
|
|
716
|
-
return this.sendRequest('ui/
|
|
735
|
+
return this.sendRequest('ui/open-link', { url: url });
|
|
717
736
|
},
|
|
718
737
|
requestDisplayMode: function(context, mode) {
|
|
719
|
-
|
|
738
|
+
// Ask only for a mode the host offers; it answers with the mode it actually set.
|
|
739
|
+
var offered = context.hostContext.availableDisplayModes;
|
|
740
|
+
if (!Array.isArray(offered) || offered.indexOf(mode) === -1) {
|
|
741
|
+
return Promise.reject(new Error('Display mode "' + mode + '" is not available on this host'));
|
|
742
|
+
}
|
|
743
|
+
return this.sendRequest('ui/request-display-mode', { mode: mode });
|
|
720
744
|
},
|
|
721
745
|
setSize: function(context, size) {
|
|
722
746
|
// Standard ext-apps sizing: the view tells the host its dimensions with the
|
|
@@ -737,14 +761,22 @@ var ExtAppsAdapter = {
|
|
|
737
761
|
return this.sendNotification('ui/notifications/size-changed', params);
|
|
738
762
|
},
|
|
739
763
|
requestClose: function(context) {
|
|
740
|
-
|
|
764
|
+
// The host decides whether to tear the view down; it answers with ui/resource-teardown if it does.
|
|
765
|
+
return this.sendNotification('ui/notifications/request-teardown', {});
|
|
741
766
|
},
|
|
742
767
|
// Extended ext-apps methods (full specification)
|
|
743
768
|
updateModelContext: function(context, data, merge) {
|
|
744
|
-
if (!this.hostCapabilities.modelContextUpdate) {
|
|
769
|
+
if (!this.hostCapabilities.updateModelContext && !this.hostCapabilities.modelContextUpdate) {
|
|
745
770
|
return Promise.reject(new Error('Model context update not supported'));
|
|
746
771
|
}
|
|
747
|
-
|
|
772
|
+
// The host keeps only the latest update, so an object merges into the last one here.
|
|
773
|
+
var isObject = data !== null && typeof data === 'object' && !Array.isArray(data);
|
|
774
|
+
var modelContext = isObject && merge !== false ? Object.assign({}, this.modelContext, data) : data;
|
|
775
|
+
this.modelContext = isObject ? modelContext : null;
|
|
776
|
+
var text = typeof modelContext === 'string' ? modelContext : JSON.stringify(modelContext);
|
|
777
|
+
var params = { content: [{ type: 'text', text: text }] };
|
|
778
|
+
if (isObject) params.structuredContent = modelContext;
|
|
779
|
+
return this.sendRequest('ui/update-model-context', params);
|
|
748
780
|
},
|
|
749
781
|
log: function(context, level, message, data) {
|
|
750
782
|
if (!this.hostCapabilities.logging) {
|
|
@@ -753,7 +785,10 @@ var ExtAppsAdapter = {
|
|
|
753
785
|
logFn('[Widget] ' + message, data);
|
|
754
786
|
return Promise.resolve();
|
|
755
787
|
}
|
|
756
|
-
return this.
|
|
788
|
+
return this.sendNotification('notifications/message', {
|
|
789
|
+
level: level === 'warn' ? 'warning' : level,
|
|
790
|
+
data: data === undefined ? message : { message: message, data: data }
|
|
791
|
+
});
|
|
757
792
|
},
|
|
758
793
|
registerTool: function(context, name, description, inputSchema) {
|
|
759
794
|
if (!this.hostCapabilities.widgetTools) {
|
|
@@ -1150,8 +1185,10 @@ FrontMcpBridge.prototype.openLink = function(url) {
|
|
|
1150
1185
|
FrontMcpBridge.prototype.requestDisplayMode = function(mode) {
|
|
1151
1186
|
if (!this._adapter) return Promise.reject(new Error('Not initialized'));
|
|
1152
1187
|
var self = this;
|
|
1153
|
-
return this._adapter.requestDisplayMode(this._context, mode).then(function() {
|
|
1154
|
-
|
|
1188
|
+
return this._adapter.requestDisplayMode(this._context, mode).then(function(result) {
|
|
1189
|
+
// The host may set another mode than the one asked for, e.g. when it refuses the change.
|
|
1190
|
+
var setMode = result && result.mode;
|
|
1191
|
+
if (${JSON.stringify(MCP_APPS_DISPLAY_MODES)}.indexOf(setMode) !== -1) self._context.hostContext.displayMode = setMode;
|
|
1155
1192
|
});
|
|
1156
1193
|
};
|
|
1157
1194
|
|
|
@@ -1576,7 +1613,7 @@ function hasSizing(sizing) {
|
|
|
1576
1613
|
return sizing.preferredHeight !== void 0 || sizing.minHeight !== void 0 || sizing.maxHeight !== void 0 || sizing.aspectRatio !== void 0 || sizing.autoResize !== void 0;
|
|
1577
1614
|
}
|
|
1578
1615
|
function buildDataInjectionScript(options) {
|
|
1579
|
-
const { toolName, input, output, structuredContent, sizing } = options;
|
|
1616
|
+
const { toolName, input, output, structuredContent, sizing, displayMode } = options;
|
|
1580
1617
|
const lines = [
|
|
1581
1618
|
`window.__mcpAppsEnabled = true;`,
|
|
1582
1619
|
`window.__mcpToolName = ${safeJsonForScript(toolName)};`,
|
|
@@ -1587,6 +1624,9 @@ function buildDataInjectionScript(options) {
|
|
|
1587
1624
|
if (hasSizing(sizing)) {
|
|
1588
1625
|
lines.push(`window.__mcpWidgetSizing = ${safeJsonForScript(sizing)};`);
|
|
1589
1626
|
}
|
|
1627
|
+
if (displayMode && displayMode !== "inline") {
|
|
1628
|
+
lines.push(`window.__mcpDisplayMode = ${safeJsonForScript(displayMode)};`);
|
|
1629
|
+
}
|
|
1590
1630
|
return `<script>
|
|
1591
1631
|
${lines.join("\n")}
|
|
1592
1632
|
</script>`;
|
|
@@ -1678,7 +1718,8 @@ function resolveDataInjectionScript(args) {
|
|
|
1678
1718
|
input: args.input,
|
|
1679
1719
|
output: args.output,
|
|
1680
1720
|
structuredContent: args.structuredContent,
|
|
1681
|
-
sizing: args.sizing
|
|
1721
|
+
sizing: args.sizing,
|
|
1722
|
+
displayMode: args.displayMode
|
|
1682
1723
|
});
|
|
1683
1724
|
}
|
|
1684
1725
|
function buildShell(content, config) {
|
|
@@ -1691,7 +1732,8 @@ function buildShell(content, config) {
|
|
|
1691
1732
|
structuredContent,
|
|
1692
1733
|
includeBridge = true,
|
|
1693
1734
|
title,
|
|
1694
|
-
sizing
|
|
1735
|
+
sizing,
|
|
1736
|
+
displayMode
|
|
1695
1737
|
} = config;
|
|
1696
1738
|
const { customShell, dataInjection } = config;
|
|
1697
1739
|
const dataScript = resolveDataInjectionScript({
|
|
@@ -1700,7 +1742,8 @@ function buildShell(content, config) {
|
|
|
1700
1742
|
input,
|
|
1701
1743
|
output,
|
|
1702
1744
|
structuredContent,
|
|
1703
|
-
sizing
|
|
1745
|
+
sizing,
|
|
1746
|
+
displayMode
|
|
1704
1747
|
});
|
|
1705
1748
|
if (!withShell) {
|
|
1706
1749
|
const html3 = `${dataScript}
|
|
@@ -1721,6 +1764,7 @@ ${content}`;
|
|
|
1721
1764
|
includeBridge,
|
|
1722
1765
|
title,
|
|
1723
1766
|
sizing,
|
|
1767
|
+
displayMode,
|
|
1724
1768
|
dataInjection
|
|
1725
1769
|
});
|
|
1726
1770
|
}
|
|
@@ -1776,7 +1820,8 @@ function buildCustomShell(content, customShell, ctx) {
|
|
|
1776
1820
|
input: ctx.input,
|
|
1777
1821
|
output: ctx.output,
|
|
1778
1822
|
structuredContent: ctx.structuredContent,
|
|
1779
|
-
sizing: ctx.sizing
|
|
1823
|
+
sizing: ctx.sizing,
|
|
1824
|
+
displayMode: ctx.displayMode
|
|
1780
1825
|
});
|
|
1781
1826
|
const sizingStyle = buildSizingStyleTag(ctx.sizing);
|
|
1782
1827
|
const dataWithSizing = sizingStyle ? `${dataScript}
|
package/shell/trusted-html.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Trusted Markup
|
|
3
3
|
*
|
|
4
4
|
* Explicit markup values for UI template functions. A template result built with {@link html}
|
|
5
|
-
* or wrapped with {@link trustedHtml} is rendered as HTML;
|
|
6
|
-
*
|
|
5
|
+
* or wrapped with {@link trustedHtml} is rendered as HTML; a plain string result is escaped instead
|
|
6
|
+
* (unless `escapeStringResults: false`).
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
package/shell/types.d.ts
CHANGED
|
@@ -113,6 +113,8 @@ export interface ShellConfig {
|
|
|
113
113
|
customShell?: ResolvedShellTemplate | string;
|
|
114
114
|
/** Widget sizing configuration (height/aspect-ratio/auto-resize). */
|
|
115
115
|
sizing?: WidgetSizing;
|
|
116
|
+
/** Display mode the widget asks the host for once the bridge connects; `'inline'` asks for none. */
|
|
117
|
+
displayMode?: 'inline' | 'fullscreen' | 'pip';
|
|
116
118
|
/**
|
|
117
119
|
* Pluggable inline-module mount tail. Default = the widget `McpBridgeProvider`
|
|
118
120
|
* mount from `@frontmcp/ui/react`. See {@link ShellMountDescriptor}.
|
package/shell/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shell/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,4BAA4B;IAC3C,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAA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,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,6CAA6C;IAC7C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,WAAW,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC;IAC7C,qEAAqE;IACrE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,oGAAoG;IACpG,WAAW,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,KAAK,CAAC;IAC9C;;;OAGG;IACH,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,4BAA4B,CAAC;CAC9C;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,uEAAuE;IACvE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,iFAAiF;IACjF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/types/ui-config.d.ts
CHANGED
|
@@ -37,8 +37,10 @@ export interface FileBundleOptions {
|
|
|
37
37
|
* **Where this is emitted (issue #455 fix):** FrontMCP attaches this
|
|
38
38
|
* configuration to the **resource** content item returned by
|
|
39
39
|
* `resources/read` for `ui://widget/{toolName}.html`, as both
|
|
40
|
-
* `_meta.ui.csp` (nested) and `_meta['ui/csp']` (slash) with
|
|
41
|
-
* `
|
|
40
|
+
* `_meta.ui.csp` (nested) and `_meta['ui/csp']` (slash) with the MCP Apps
|
|
41
|
+
* `connectDomains` / `resourceDomains` keys (the snake_case keys sent up to
|
|
42
|
+
* 1.9.2 stay alongside), and as `_meta['openai/widgetCSP']` with the OpenAI
|
|
43
|
+
* Apps SDK's `connect_domains` / `resource_domains`. MCP Apps hosts (notably
|
|
42
44
|
* Claude) only honor CSP declared on the resource — declarations on the
|
|
43
45
|
* tool's `_meta.ui.csp` are ignored.
|
|
44
46
|
*/
|
|
@@ -182,8 +184,8 @@ export interface TemplateHelpers {
|
|
|
182
184
|
*/
|
|
183
185
|
html: (strings: TemplateStringsArray, ...values: unknown[]) => TrustedHtml;
|
|
184
186
|
/**
|
|
185
|
-
* Mark markup you produced or sanitized yourself as trusted, so it renders as HTML
|
|
186
|
-
*
|
|
187
|
+
* Mark markup you produced or sanitized yourself as trusted, so it renders as HTML although plain
|
|
188
|
+
* string results are escaped. Never pass raw tool output or user input.
|
|
187
189
|
*/
|
|
188
190
|
trustedHtml: (markup: string) => TrustedHtml;
|
|
189
191
|
}
|
|
@@ -349,27 +351,26 @@ export interface UITemplateConfig<In = unknown, Out = unknown> {
|
|
|
349
351
|
/**
|
|
350
352
|
* HTML-escape a plain string returned by a template function.
|
|
351
353
|
*
|
|
352
|
-
* -
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* - `false`:
|
|
354
|
+
* - unset (the default since 1.9.2): plain strings are escaped and shown as text, and a one-time notice per
|
|
355
|
+
* tool is logged when one looked like markup; markup built with `ctx.helpers.html` or wrapped
|
|
356
|
+
* with `ctx.helpers.trustedHtml` still renders as HTML.
|
|
357
|
+
* - `true`: the same, without the notice.
|
|
358
|
+
* - `false`: strings that look like HTML render as markup (the behaviour before 1.9.2).
|
|
357
359
|
*
|
|
358
360
|
* Overrides the server-wide `@FrontMcp({ ui: { escapeStringResults } })` default.
|
|
359
361
|
* Static string templates (`template: '<div>…</div>'`) are author markup and never escaped.
|
|
360
362
|
*/
|
|
361
363
|
escapeStringResults?: boolean;
|
|
362
364
|
/**
|
|
363
|
-
* Whether the widget
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
* Default: false
|
|
365
|
+
* Whether the widget may call tools itself. Sent in `tools/list` as
|
|
366
|
+
* `_meta['openai/widgetAccessible']`, which the OpenAI Apps SDK requires for
|
|
367
|
+
* `window.openai.callTool()`; MCP Apps hosts let widgets call tools by default.
|
|
368
368
|
*/
|
|
369
369
|
widgetAccessible?: boolean;
|
|
370
370
|
/**
|
|
371
|
-
* Preferred display mode for the widget
|
|
372
|
-
*
|
|
371
|
+
* Preferred display mode for the widget, which the page asks the host for once its
|
|
372
|
+
* bridge connects (`ui/request-display-mode`, or `window.openai.requestDisplayMode()`).
|
|
373
|
+
* - 'inline': Rendered inline in the conversation (default; nothing is asked)
|
|
373
374
|
* - 'fullscreen': Request fullscreen display
|
|
374
375
|
* - 'pip': Picture-in-picture mode
|
|
375
376
|
*
|
|
@@ -424,8 +425,8 @@ export interface UITemplateConfig<In = unknown, Out = unknown> {
|
|
|
424
425
|
*/
|
|
425
426
|
autoResize?: boolean;
|
|
426
427
|
/**
|
|
427
|
-
*
|
|
428
|
-
*
|
|
428
|
+
* What the widget shows, for the model. Sent on the widget resource as
|
|
429
|
+
* `_meta['openai/widgetDescription']` (OpenAI Apps SDK).
|
|
429
430
|
*/
|
|
430
431
|
widgetDescription?: string;
|
|
431
432
|
/**
|
|
@@ -536,7 +537,8 @@ export interface UITemplateConfig<In = unknown, Out = unknown> {
|
|
|
536
537
|
};
|
|
537
538
|
/**
|
|
538
539
|
* Whether to show a border around the UI widget.
|
|
539
|
-
*
|
|
540
|
+
* Sent on the widget resource as `_meta.ui.prefersBorder` (MCP Apps) and
|
|
541
|
+
* `_meta['openai/widgetPrefersBorder']` (OpenAI Apps SDK).
|
|
540
542
|
*
|
|
541
543
|
* When true, hosts should render a visible border around the sandbox iframe.
|
|
542
544
|
* Useful for visual clarity when the widget content doesn't have its own borders.
|
|
@@ -546,7 +548,8 @@ export interface UITemplateConfig<In = unknown, Out = unknown> {
|
|
|
546
548
|
prefersBorder?: boolean;
|
|
547
549
|
/**
|
|
548
550
|
* Dedicated sandbox domain for the widget.
|
|
549
|
-
*
|
|
551
|
+
* Sent on the widget resource as `_meta.ui.domain` (MCP Apps) and
|
|
552
|
+
* `_meta['openai/widgetDomain']` (OpenAI Apps SDK).
|
|
550
553
|
*
|
|
551
554
|
* When specified, the host should load the widget in an iframe with this
|
|
552
555
|
* domain as the origin, providing additional isolation.
|
package/types/ui-config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-config.d.ts","sourceRoot":"","sources":["../../src/types/ui-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gCAAgC;IAChC,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACzE,0BAA0B;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1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