@frontmcp/uipack 0.7.2 → 0.8.0
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 +71 -24
- package/adapters/platform-meta.constants.d.ts +26 -0
- package/adapters/platform-meta.constants.d.ts.map +1 -0
- package/adapters/platform-meta.d.ts +39 -0
- package/adapters/platform-meta.d.ts.map +1 -1
- package/bridge-runtime/iife-generator.d.ts.map +1 -1
- package/bridge-runtime/index.js +125 -7
- package/build/index.js +125 -7
- package/esm/adapters/index.mjs +69 -24
- package/esm/bridge-runtime/index.mjs +125 -7
- package/esm/build/index.mjs +125 -7
- package/esm/index.mjs +180 -31
- package/esm/package.json +5 -2
- package/esm/registry/index.mjs +153 -24
- package/esm/runtime/index.mjs +125 -7
- package/esm/tool-template/index.mjs +125 -7
- package/index.js +180 -31
- package/package.json +5 -2
- package/registry/index.js +153 -24
- package/runtime/index.js +125 -7
- package/tool-template/index.js +125 -7
- package/types/ui-config.d.ts +23 -0
- package/types/ui-config.d.ts.map +1 -1
package/runtime/index.js
CHANGED
|
@@ -1177,16 +1177,43 @@ var ExtAppsAdapter = {
|
|
|
1177
1177
|
capabilities: Object.assign({}, DEFAULT_CAPABILITIES, { canPersistState: true, hasNetworkAccess: true }),
|
|
1178
1178
|
trustedOrigins: ${originsArray},
|
|
1179
1179
|
trustedOrigin: null,
|
|
1180
|
+
originTrustPending: false,
|
|
1180
1181
|
pendingRequests: {},
|
|
1181
1182
|
requestId: 0,
|
|
1182
1183
|
hostCapabilities: {},
|
|
1183
1184
|
canHandle: function() {
|
|
1184
1185
|
if (typeof window === 'undefined') return false;
|
|
1185
1186
|
if (window.parent === window) return false;
|
|
1186
|
-
|
|
1187
|
+
|
|
1188
|
+
// Check for OpenAI SDK - defer to OpenAIAdapter
|
|
1189
|
+
if (window.openai && window.openai.canvas) return false;
|
|
1187
1190
|
if (window.openai && typeof window.openai.callTool === 'function') return false;
|
|
1191
|
+
|
|
1192
|
+
// Explicit ext-apps marker
|
|
1188
1193
|
if (window.__mcpPlatform === 'ext-apps') return true;
|
|
1189
|
-
return true;
|
|
1194
|
+
if (window.__extAppsInitialized) return true;
|
|
1195
|
+
|
|
1196
|
+
// Claude MCP Apps mode (2026+) - uses ext-apps protocol
|
|
1197
|
+
if (window.__mcpAppsEnabled) return true;
|
|
1198
|
+
|
|
1199
|
+
// Legacy Claude detection - defer to ClaudeAdapter
|
|
1200
|
+
if (window.claude) return false;
|
|
1201
|
+
if (window.__claudeArtifact) return false;
|
|
1202
|
+
if (window.__mcpPlatform === 'claude') return false;
|
|
1203
|
+
if (typeof location !== 'undefined') {
|
|
1204
|
+
try {
|
|
1205
|
+
var url = new URL(location.href);
|
|
1206
|
+
var hostname = url.hostname.toLowerCase();
|
|
1207
|
+
var isClaudeHost = hostname === 'claude.ai' || (hostname.length > 10 && hostname.slice(-10) === '.claude.ai');
|
|
1208
|
+
var isAnthropicHost = hostname === 'anthropic.com' || (hostname.length > 14 && hostname.slice(-14) === '.anthropic.com');
|
|
1209
|
+
if (isClaudeHost || isAnthropicHost) return false;
|
|
1210
|
+
} catch (e) {
|
|
1211
|
+
// If URL parsing fails, fall through to other checks
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// Do NOT default to true for any iframe
|
|
1216
|
+
return false;
|
|
1190
1217
|
},
|
|
1191
1218
|
initialize: function(context) {
|
|
1192
1219
|
var self = this;
|
|
@@ -1228,6 +1255,11 @@ var ExtAppsAdapter = {
|
|
|
1228
1255
|
context.toolInput = params.arguments || {};
|
|
1229
1256
|
window.dispatchEvent(new CustomEvent('tool:input', { detail: { arguments: context.toolInput } }));
|
|
1230
1257
|
break;
|
|
1258
|
+
case 'ui/notifications/tool-input-partial':
|
|
1259
|
+
// Streaming: merge partial input with existing
|
|
1260
|
+
context.toolInput = Object.assign({}, context.toolInput, params.arguments || {});
|
|
1261
|
+
window.dispatchEvent(new CustomEvent('tool:input-partial', { detail: { arguments: context.toolInput } }));
|
|
1262
|
+
break;
|
|
1231
1263
|
case 'ui/notifications/tool-result':
|
|
1232
1264
|
context.toolOutput = params.content;
|
|
1233
1265
|
context.structuredContent = params.structuredContent;
|
|
@@ -1238,18 +1270,26 @@ var ExtAppsAdapter = {
|
|
|
1238
1270
|
Object.assign(context.hostContext, params);
|
|
1239
1271
|
context.notifyContextChange(params);
|
|
1240
1272
|
break;
|
|
1273
|
+
case 'ui/notifications/cancelled':
|
|
1274
|
+
window.dispatchEvent(new CustomEvent('tool:cancelled', { detail: { reason: params.reason } }));
|
|
1275
|
+
break;
|
|
1241
1276
|
}
|
|
1242
1277
|
},
|
|
1243
1278
|
isOriginTrusted: function(origin) {
|
|
1244
1279
|
if (this.trustedOrigins.length > 0) {
|
|
1245
1280
|
return this.trustedOrigins.indexOf(origin) !== -1;
|
|
1246
1281
|
}
|
|
1247
|
-
//
|
|
1248
|
-
// SECURITY WARNING:
|
|
1249
|
-
// message establishes permanent trust. For production, always configure trustedOrigins.
|
|
1282
|
+
// Trust-on-first-use: trust first message origin.
|
|
1283
|
+
// SECURITY WARNING: For production, always configure trustedOrigins.
|
|
1250
1284
|
if (!this.trustedOrigin) {
|
|
1285
|
+
// Guard against race condition where multiple messages arrive simultaneously
|
|
1286
|
+
if (this.originTrustPending) {
|
|
1287
|
+
return false;
|
|
1288
|
+
}
|
|
1251
1289
|
if (window.parent !== window && origin) {
|
|
1290
|
+
this.originTrustPending = true;
|
|
1252
1291
|
this.trustedOrigin = origin;
|
|
1292
|
+
this.originTrustPending = false; // Reset after successful trust establishment
|
|
1253
1293
|
return true;
|
|
1254
1294
|
}
|
|
1255
1295
|
return false;
|
|
@@ -1319,6 +1359,34 @@ var ExtAppsAdapter = {
|
|
|
1319
1359
|
},
|
|
1320
1360
|
requestClose: function(context) {
|
|
1321
1361
|
return this.sendRequest('ui/close', {});
|
|
1362
|
+
},
|
|
1363
|
+
// Extended ext-apps methods (full specification)
|
|
1364
|
+
updateModelContext: function(context, data, merge) {
|
|
1365
|
+
if (!this.hostCapabilities.modelContextUpdate) {
|
|
1366
|
+
return Promise.reject(new Error('Model context update not supported'));
|
|
1367
|
+
}
|
|
1368
|
+
return this.sendRequest('ui/updateModelContext', { context: data, merge: merge !== false });
|
|
1369
|
+
},
|
|
1370
|
+
log: function(context, level, message, data) {
|
|
1371
|
+
if (!this.hostCapabilities.logging) {
|
|
1372
|
+
// Fallback to console logging if host doesn't support it
|
|
1373
|
+
var logFn = console[level] || console.log;
|
|
1374
|
+
logFn('[Widget] ' + message, data);
|
|
1375
|
+
return Promise.resolve();
|
|
1376
|
+
}
|
|
1377
|
+
return this.sendRequest('ui/log', { level: level, message: message, data: data });
|
|
1378
|
+
},
|
|
1379
|
+
registerTool: function(context, name, description, inputSchema) {
|
|
1380
|
+
if (!this.hostCapabilities.widgetTools) {
|
|
1381
|
+
return Promise.reject(new Error('Widget tool registration not supported'));
|
|
1382
|
+
}
|
|
1383
|
+
return this.sendRequest('ui/registerTool', { name: name, description: description, inputSchema: inputSchema });
|
|
1384
|
+
},
|
|
1385
|
+
unregisterTool: function(context, name) {
|
|
1386
|
+
if (!this.hostCapabilities.widgetTools) {
|
|
1387
|
+
return Promise.reject(new Error('Widget tool unregistration not supported'));
|
|
1388
|
+
}
|
|
1389
|
+
return this.sendRequest('ui/unregisterTool', { name: name });
|
|
1322
1390
|
}
|
|
1323
1391
|
};
|
|
1324
1392
|
`.trim();
|
|
@@ -1338,12 +1406,26 @@ var ClaudeAdapter = {
|
|
|
1338
1406
|
}),
|
|
1339
1407
|
canHandle: function() {
|
|
1340
1408
|
if (typeof window === 'undefined') return false;
|
|
1409
|
+
|
|
1410
|
+
// If MCP Apps is enabled, let ext-apps adapter handle it
|
|
1411
|
+
if (window.__mcpAppsEnabled) return false;
|
|
1412
|
+
if (window.__mcpPlatform === 'ext-apps') return false;
|
|
1413
|
+
if (window.__extAppsInitialized) return false;
|
|
1414
|
+
|
|
1415
|
+
// Legacy Claude detection
|
|
1341
1416
|
if (window.__mcpPlatform === 'claude') return true;
|
|
1342
1417
|
if (window.claude) return true;
|
|
1343
1418
|
if (window.__claudeArtifact) return true;
|
|
1344
1419
|
if (typeof location !== 'undefined') {
|
|
1345
|
-
|
|
1346
|
-
|
|
1420
|
+
try {
|
|
1421
|
+
var url = new URL(location.href);
|
|
1422
|
+
var hostname = url.hostname.toLowerCase();
|
|
1423
|
+
var isClaudeHost = hostname === 'claude.ai' || (hostname.length > 10 && hostname.slice(-10) === '.claude.ai');
|
|
1424
|
+
var isAnthropicHost = hostname === 'anthropic.com' || (hostname.length > 14 && hostname.slice(-14) === '.anthropic.com');
|
|
1425
|
+
if (isClaudeHost || isAnthropicHost) return true;
|
|
1426
|
+
} catch (e) {
|
|
1427
|
+
// If URL parsing fails, fall through
|
|
1428
|
+
}
|
|
1347
1429
|
}
|
|
1348
1430
|
return false;
|
|
1349
1431
|
},
|
|
@@ -1688,6 +1770,42 @@ FrontMcpBridge.prototype.requestClose = function() {
|
|
|
1688
1770
|
return this._adapter.requestClose(this._context);
|
|
1689
1771
|
};
|
|
1690
1772
|
|
|
1773
|
+
// Extended ext-apps methods (full specification)
|
|
1774
|
+
FrontMcpBridge.prototype.updateModelContext = function(context, merge) {
|
|
1775
|
+
if (!this._adapter) return Promise.reject(new Error('Not initialized'));
|
|
1776
|
+
if (!this._adapter.updateModelContext) {
|
|
1777
|
+
return Promise.reject(new Error('updateModelContext not supported on this platform'));
|
|
1778
|
+
}
|
|
1779
|
+
return this._adapter.updateModelContext(this._context, context, merge);
|
|
1780
|
+
};
|
|
1781
|
+
|
|
1782
|
+
FrontMcpBridge.prototype.log = function(level, message, data) {
|
|
1783
|
+
if (!this._adapter) return Promise.reject(new Error('Not initialized'));
|
|
1784
|
+
if (!this._adapter.log) {
|
|
1785
|
+
// Fallback to console
|
|
1786
|
+
var logFn = console[level] || console.log;
|
|
1787
|
+
logFn('[Widget] ' + message, data);
|
|
1788
|
+
return Promise.resolve();
|
|
1789
|
+
}
|
|
1790
|
+
return this._adapter.log(this._context, level, message, data);
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1793
|
+
FrontMcpBridge.prototype.registerTool = function(name, description, inputSchema) {
|
|
1794
|
+
if (!this._adapter) return Promise.reject(new Error('Not initialized'));
|
|
1795
|
+
if (!this._adapter.registerTool) {
|
|
1796
|
+
return Promise.reject(new Error('registerTool not supported on this platform'));
|
|
1797
|
+
}
|
|
1798
|
+
return this._adapter.registerTool(this._context, name, description, inputSchema);
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1801
|
+
FrontMcpBridge.prototype.unregisterTool = function(name) {
|
|
1802
|
+
if (!this._adapter) return Promise.reject(new Error('Not initialized'));
|
|
1803
|
+
if (!this._adapter.unregisterTool) {
|
|
1804
|
+
return Promise.reject(new Error('unregisterTool not supported on this platform'));
|
|
1805
|
+
}
|
|
1806
|
+
return this._adapter.unregisterTool(this._context, name);
|
|
1807
|
+
};
|
|
1808
|
+
|
|
1691
1809
|
FrontMcpBridge.prototype.setWidgetState = function(state) {
|
|
1692
1810
|
Object.assign(this._context.widgetState, state);
|
|
1693
1811
|
this._saveWidgetState();
|
package/tool-template/index.js
CHANGED
|
@@ -845,16 +845,43 @@ var ExtAppsAdapter = {
|
|
|
845
845
|
capabilities: Object.assign({}, DEFAULT_CAPABILITIES, { canPersistState: true, hasNetworkAccess: true }),
|
|
846
846
|
trustedOrigins: ${originsArray},
|
|
847
847
|
trustedOrigin: null,
|
|
848
|
+
originTrustPending: false,
|
|
848
849
|
pendingRequests: {},
|
|
849
850
|
requestId: 0,
|
|
850
851
|
hostCapabilities: {},
|
|
851
852
|
canHandle: function() {
|
|
852
853
|
if (typeof window === 'undefined') return false;
|
|
853
854
|
if (window.parent === window) return false;
|
|
854
|
-
|
|
855
|
+
|
|
856
|
+
// Check for OpenAI SDK - defer to OpenAIAdapter
|
|
857
|
+
if (window.openai && window.openai.canvas) return false;
|
|
855
858
|
if (window.openai && typeof window.openai.callTool === 'function') return false;
|
|
859
|
+
|
|
860
|
+
// Explicit ext-apps marker
|
|
856
861
|
if (window.__mcpPlatform === 'ext-apps') return true;
|
|
857
|
-
return true;
|
|
862
|
+
if (window.__extAppsInitialized) return true;
|
|
863
|
+
|
|
864
|
+
// Claude MCP Apps mode (2026+) - uses ext-apps protocol
|
|
865
|
+
if (window.__mcpAppsEnabled) return true;
|
|
866
|
+
|
|
867
|
+
// Legacy Claude detection - defer to ClaudeAdapter
|
|
868
|
+
if (window.claude) return false;
|
|
869
|
+
if (window.__claudeArtifact) return false;
|
|
870
|
+
if (window.__mcpPlatform === 'claude') return false;
|
|
871
|
+
if (typeof location !== 'undefined') {
|
|
872
|
+
try {
|
|
873
|
+
var url = new URL(location.href);
|
|
874
|
+
var hostname = url.hostname.toLowerCase();
|
|
875
|
+
var isClaudeHost = hostname === 'claude.ai' || (hostname.length > 10 && hostname.slice(-10) === '.claude.ai');
|
|
876
|
+
var isAnthropicHost = hostname === 'anthropic.com' || (hostname.length > 14 && hostname.slice(-14) === '.anthropic.com');
|
|
877
|
+
if (isClaudeHost || isAnthropicHost) return false;
|
|
878
|
+
} catch (e) {
|
|
879
|
+
// If URL parsing fails, fall through to other checks
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// Do NOT default to true for any iframe
|
|
884
|
+
return false;
|
|
858
885
|
},
|
|
859
886
|
initialize: function(context) {
|
|
860
887
|
var self = this;
|
|
@@ -896,6 +923,11 @@ var ExtAppsAdapter = {
|
|
|
896
923
|
context.toolInput = params.arguments || {};
|
|
897
924
|
window.dispatchEvent(new CustomEvent('tool:input', { detail: { arguments: context.toolInput } }));
|
|
898
925
|
break;
|
|
926
|
+
case 'ui/notifications/tool-input-partial':
|
|
927
|
+
// Streaming: merge partial input with existing
|
|
928
|
+
context.toolInput = Object.assign({}, context.toolInput, params.arguments || {});
|
|
929
|
+
window.dispatchEvent(new CustomEvent('tool:input-partial', { detail: { arguments: context.toolInput } }));
|
|
930
|
+
break;
|
|
899
931
|
case 'ui/notifications/tool-result':
|
|
900
932
|
context.toolOutput = params.content;
|
|
901
933
|
context.structuredContent = params.structuredContent;
|
|
@@ -906,18 +938,26 @@ var ExtAppsAdapter = {
|
|
|
906
938
|
Object.assign(context.hostContext, params);
|
|
907
939
|
context.notifyContextChange(params);
|
|
908
940
|
break;
|
|
941
|
+
case 'ui/notifications/cancelled':
|
|
942
|
+
window.dispatchEvent(new CustomEvent('tool:cancelled', { detail: { reason: params.reason } }));
|
|
943
|
+
break;
|
|
909
944
|
}
|
|
910
945
|
},
|
|
911
946
|
isOriginTrusted: function(origin) {
|
|
912
947
|
if (this.trustedOrigins.length > 0) {
|
|
913
948
|
return this.trustedOrigins.indexOf(origin) !== -1;
|
|
914
949
|
}
|
|
915
|
-
//
|
|
916
|
-
// SECURITY WARNING:
|
|
917
|
-
// message establishes permanent trust. For production, always configure trustedOrigins.
|
|
950
|
+
// Trust-on-first-use: trust first message origin.
|
|
951
|
+
// SECURITY WARNING: For production, always configure trustedOrigins.
|
|
918
952
|
if (!this.trustedOrigin) {
|
|
953
|
+
// Guard against race condition where multiple messages arrive simultaneously
|
|
954
|
+
if (this.originTrustPending) {
|
|
955
|
+
return false;
|
|
956
|
+
}
|
|
919
957
|
if (window.parent !== window && origin) {
|
|
958
|
+
this.originTrustPending = true;
|
|
920
959
|
this.trustedOrigin = origin;
|
|
960
|
+
this.originTrustPending = false; // Reset after successful trust establishment
|
|
921
961
|
return true;
|
|
922
962
|
}
|
|
923
963
|
return false;
|
|
@@ -987,6 +1027,34 @@ var ExtAppsAdapter = {
|
|
|
987
1027
|
},
|
|
988
1028
|
requestClose: function(context) {
|
|
989
1029
|
return this.sendRequest('ui/close', {});
|
|
1030
|
+
},
|
|
1031
|
+
// Extended ext-apps methods (full specification)
|
|
1032
|
+
updateModelContext: function(context, data, merge) {
|
|
1033
|
+
if (!this.hostCapabilities.modelContextUpdate) {
|
|
1034
|
+
return Promise.reject(new Error('Model context update not supported'));
|
|
1035
|
+
}
|
|
1036
|
+
return this.sendRequest('ui/updateModelContext', { context: data, merge: merge !== false });
|
|
1037
|
+
},
|
|
1038
|
+
log: function(context, level, message, data) {
|
|
1039
|
+
if (!this.hostCapabilities.logging) {
|
|
1040
|
+
// Fallback to console logging if host doesn't support it
|
|
1041
|
+
var logFn = console[level] || console.log;
|
|
1042
|
+
logFn('[Widget] ' + message, data);
|
|
1043
|
+
return Promise.resolve();
|
|
1044
|
+
}
|
|
1045
|
+
return this.sendRequest('ui/log', { level: level, message: message, data: data });
|
|
1046
|
+
},
|
|
1047
|
+
registerTool: function(context, name, description, inputSchema) {
|
|
1048
|
+
if (!this.hostCapabilities.widgetTools) {
|
|
1049
|
+
return Promise.reject(new Error('Widget tool registration not supported'));
|
|
1050
|
+
}
|
|
1051
|
+
return this.sendRequest('ui/registerTool', { name: name, description: description, inputSchema: inputSchema });
|
|
1052
|
+
},
|
|
1053
|
+
unregisterTool: function(context, name) {
|
|
1054
|
+
if (!this.hostCapabilities.widgetTools) {
|
|
1055
|
+
return Promise.reject(new Error('Widget tool unregistration not supported'));
|
|
1056
|
+
}
|
|
1057
|
+
return this.sendRequest('ui/unregisterTool', { name: name });
|
|
990
1058
|
}
|
|
991
1059
|
};
|
|
992
1060
|
`.trim();
|
|
@@ -1006,12 +1074,26 @@ var ClaudeAdapter = {
|
|
|
1006
1074
|
}),
|
|
1007
1075
|
canHandle: function() {
|
|
1008
1076
|
if (typeof window === 'undefined') return false;
|
|
1077
|
+
|
|
1078
|
+
// If MCP Apps is enabled, let ext-apps adapter handle it
|
|
1079
|
+
if (window.__mcpAppsEnabled) return false;
|
|
1080
|
+
if (window.__mcpPlatform === 'ext-apps') return false;
|
|
1081
|
+
if (window.__extAppsInitialized) return false;
|
|
1082
|
+
|
|
1083
|
+
// Legacy Claude detection
|
|
1009
1084
|
if (window.__mcpPlatform === 'claude') return true;
|
|
1010
1085
|
if (window.claude) return true;
|
|
1011
1086
|
if (window.__claudeArtifact) return true;
|
|
1012
1087
|
if (typeof location !== 'undefined') {
|
|
1013
|
-
|
|
1014
|
-
|
|
1088
|
+
try {
|
|
1089
|
+
var url = new URL(location.href);
|
|
1090
|
+
var hostname = url.hostname.toLowerCase();
|
|
1091
|
+
var isClaudeHost = hostname === 'claude.ai' || (hostname.length > 10 && hostname.slice(-10) === '.claude.ai');
|
|
1092
|
+
var isAnthropicHost = hostname === 'anthropic.com' || (hostname.length > 14 && hostname.slice(-14) === '.anthropic.com');
|
|
1093
|
+
if (isClaudeHost || isAnthropicHost) return true;
|
|
1094
|
+
} catch (e) {
|
|
1095
|
+
// If URL parsing fails, fall through
|
|
1096
|
+
}
|
|
1015
1097
|
}
|
|
1016
1098
|
return false;
|
|
1017
1099
|
},
|
|
@@ -1356,6 +1438,42 @@ FrontMcpBridge.prototype.requestClose = function() {
|
|
|
1356
1438
|
return this._adapter.requestClose(this._context);
|
|
1357
1439
|
};
|
|
1358
1440
|
|
|
1441
|
+
// Extended ext-apps methods (full specification)
|
|
1442
|
+
FrontMcpBridge.prototype.updateModelContext = function(context, merge) {
|
|
1443
|
+
if (!this._adapter) return Promise.reject(new Error('Not initialized'));
|
|
1444
|
+
if (!this._adapter.updateModelContext) {
|
|
1445
|
+
return Promise.reject(new Error('updateModelContext not supported on this platform'));
|
|
1446
|
+
}
|
|
1447
|
+
return this._adapter.updateModelContext(this._context, context, merge);
|
|
1448
|
+
};
|
|
1449
|
+
|
|
1450
|
+
FrontMcpBridge.prototype.log = function(level, message, data) {
|
|
1451
|
+
if (!this._adapter) return Promise.reject(new Error('Not initialized'));
|
|
1452
|
+
if (!this._adapter.log) {
|
|
1453
|
+
// Fallback to console
|
|
1454
|
+
var logFn = console[level] || console.log;
|
|
1455
|
+
logFn('[Widget] ' + message, data);
|
|
1456
|
+
return Promise.resolve();
|
|
1457
|
+
}
|
|
1458
|
+
return this._adapter.log(this._context, level, message, data);
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
FrontMcpBridge.prototype.registerTool = function(name, description, inputSchema) {
|
|
1462
|
+
if (!this._adapter) return Promise.reject(new Error('Not initialized'));
|
|
1463
|
+
if (!this._adapter.registerTool) {
|
|
1464
|
+
return Promise.reject(new Error('registerTool not supported on this platform'));
|
|
1465
|
+
}
|
|
1466
|
+
return this._adapter.registerTool(this._context, name, description, inputSchema);
|
|
1467
|
+
};
|
|
1468
|
+
|
|
1469
|
+
FrontMcpBridge.prototype.unregisterTool = function(name) {
|
|
1470
|
+
if (!this._adapter) return Promise.reject(new Error('Not initialized'));
|
|
1471
|
+
if (!this._adapter.unregisterTool) {
|
|
1472
|
+
return Promise.reject(new Error('unregisterTool not supported on this platform'));
|
|
1473
|
+
}
|
|
1474
|
+
return this._adapter.unregisterTool(this._context, name);
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1359
1477
|
FrontMcpBridge.prototype.setWidgetState = function(state) {
|
|
1360
1478
|
Object.assign(this._context.widgetState, state);
|
|
1361
1479
|
this._saveWidgetState();
|
package/types/ui-config.d.ts
CHANGED
|
@@ -391,6 +391,29 @@ export interface UITemplateConfig<In = unknown, Out = unknown> {
|
|
|
391
391
|
* ```
|
|
392
392
|
*/
|
|
393
393
|
mdxComponents?: Record<string, any>;
|
|
394
|
+
/**
|
|
395
|
+
* MCP Apps: Explicit resource URI for the UI template.
|
|
396
|
+
* If not specified, auto-generated as `ui://widget/{toolName}.html`
|
|
397
|
+
*
|
|
398
|
+
* Use this when you need a specific URI pattern for your widget,
|
|
399
|
+
* such as when integrating with existing resource systems.
|
|
400
|
+
*
|
|
401
|
+
* @example 'ui://my-app/dashboard.html'
|
|
402
|
+
* @example 'ui://weather-service/forecast.html'
|
|
403
|
+
*/
|
|
404
|
+
resourceUri?: string;
|
|
405
|
+
/**
|
|
406
|
+
* MCP Apps: Widget capabilities for ext-apps initialization.
|
|
407
|
+
*
|
|
408
|
+
* These capabilities are communicated to the host during tool discovery,
|
|
409
|
+
* allowing the host to enable or configure specific features.
|
|
410
|
+
*/
|
|
411
|
+
widgetCapabilities?: {
|
|
412
|
+
/** Widget can emit tool list changes (dynamic tool registration) */
|
|
413
|
+
toolListChanged?: boolean;
|
|
414
|
+
/** Widget can handle partial tool input streaming */
|
|
415
|
+
supportsPartialInput?: boolean;
|
|
416
|
+
};
|
|
394
417
|
/**
|
|
395
418
|
* Whether to show a border around the UI widget.
|
|
396
419
|
* MCP Apps spec: `_meta.ui.prefersBorder`
|
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,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAM5E;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;;;;;OAcG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;;;;;;;;OAaG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;;;;;;;;;;;;OAiBG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAMD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAC;IAErC;;;;OAIG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAE7D;;;;OAIG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,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