@frontmcp/ui 0.7.2 → 0.8.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.
@@ -35,7 +35,10 @@ export declare class ClaudeAdapter extends BaseAdapter {
35
35
  readonly priority = 60;
36
36
  constructor();
37
37
  /**
38
- * Check if we're running in a Claude artifact/widget context.
38
+ * Check if we're running in a Claude legacy artifact/widget context.
39
+ *
40
+ * Claude MCP Apps (2026+) uses the ext-apps adapter instead.
41
+ * This adapter only handles legacy Claude artifacts without MCP Apps support.
39
42
  */
40
43
  canHandle(): boolean;
41
44
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"claude.adapter.d.ts","sourceRoot":"","sources":["../../../src/bridge/adapters/claude.adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAwB,MAAM,gBAAgB,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,QAAQ,CAAC,EAAE,YAAY;IACvB,QAAQ,CAAC,IAAI,wBAAwB;IACrC,QAAQ,CAAC,QAAQ,MAAM;;IAgBvB;;OAEG;IACH,SAAS,IAAI,OAAO;IA0BpB;;OAEG;IACY,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAU1C;;;OAGG;IACY,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnD;;OAEG;IACY,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpE;;OAEG;IACY,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5C;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAoB5B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAEnD"}
1
+ {"version":3,"file":"claude.adapter.d.ts","sourceRoot":"","sources":["../../../src/bridge/adapters/claude.adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAwB,MAAM,gBAAgB,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,QAAQ,CAAC,EAAE,YAAY;IACvB,QAAQ,CAAC,IAAI,wBAAwB;IACrC,QAAQ,CAAC,QAAQ,MAAM;;IAgBvB;;;;;OAKG;IACH,SAAS,IAAI,OAAO;IAgCpB;;OAEG;IACY,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAU1C;;;OAGG;IACY,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnD;;OAEG;IACY,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpE;;OAEG;IACY,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5C;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAoB5B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAEnD"}
@@ -55,10 +55,17 @@ export declare class ExtAppsAdapter extends BaseAdapter {
55
55
  private _pendingRequests;
56
56
  private _requestId;
57
57
  private _trustedOrigin;
58
+ private _originTrustPending;
58
59
  private _hostCapabilities;
59
60
  constructor(config?: ExtAppsAdapterConfig);
60
61
  /**
61
- * Check if we're in an iframe (potential ext-apps context).
62
+ * Check if we're in an iframe with explicit ext-apps context.
63
+ *
64
+ * This adapter requires explicit ext-apps markers to avoid incorrectly
65
+ * matching other iframe-based platforms (e.g., Claude legacy artifacts).
66
+ *
67
+ * Claude MCP Apps (2026+) uses the ext-apps protocol - detected via
68
+ * __mcpAppsEnabled flag, which takes precedence over legacy Claude markers.
62
69
  */
63
70
  canHandle(): boolean;
64
71
  /**
@@ -74,6 +81,46 @@ export declare class ExtAppsAdapter extends BaseAdapter {
74
81
  openLink(url: string): Promise<void>;
75
82
  requestDisplayMode(mode: DisplayMode): Promise<void>;
76
83
  requestClose(): Promise<void>;
84
+ /**
85
+ * Update the model context with widget state.
86
+ *
87
+ * This allows the widget to pass contextual information to the model,
88
+ * which can be used to inform subsequent interactions.
89
+ *
90
+ * @param context - The context data to update
91
+ * @param merge - Whether to merge with existing context (default: true)
92
+ */
93
+ updateModelContext(context: unknown, merge?: boolean): Promise<void>;
94
+ /**
95
+ * Send a log message to the host.
96
+ *
97
+ * Allows the widget to forward log messages to the host for debugging
98
+ * or monitoring purposes.
99
+ *
100
+ * @param level - Log level (debug, info, warn, error)
101
+ * @param message - Log message
102
+ * @param data - Optional additional data
103
+ */
104
+ log(level: 'debug' | 'info' | 'warn' | 'error', message: string, data?: unknown): Promise<void>;
105
+ /**
106
+ * Register a widget-defined tool.
107
+ *
108
+ * Allows the widget to dynamically register tools that can be
109
+ * invoked by the model or user.
110
+ *
111
+ * @param name - Tool name
112
+ * @param description - Tool description
113
+ * @param inputSchema - Tool input schema (JSON Schema format)
114
+ */
115
+ registerTool(name: string, description: string, inputSchema: Record<string, unknown>): Promise<void>;
116
+ /**
117
+ * Unregister a widget-defined tool.
118
+ *
119
+ * Removes a previously registered tool.
120
+ *
121
+ * @param name - Tool name to unregister
122
+ */
123
+ unregisterTool(name: string): Promise<void>;
77
124
  /**
78
125
  * Setup postMessage listener for incoming messages.
79
126
  */
@@ -122,6 +169,10 @@ export declare class ExtAppsAdapter extends BaseAdapter {
122
169
  * Post a message to the parent window.
123
170
  */
124
171
  private _postMessage;
172
+ /**
173
+ * Validate that the handshake response has the expected structure.
174
+ */
175
+ private _isValidInitializeResult;
125
176
  /**
126
177
  * Perform the ui/initialize handshake with the host.
127
178
  */
@@ -129,6 +180,9 @@ export declare class ExtAppsAdapter extends BaseAdapter {
129
180
  /**
130
181
  * Check if an origin is trusted.
131
182
  * Uses trust-on-first-use if no explicit origins configured.
183
+ *
184
+ * Security note: Trust-on-first-use has inherent risks. For production,
185
+ * always configure explicit trustedOrigins in adapter config.
132
186
  */
133
187
  private _isOriginTrusted;
134
188
  /**
@@ -140,4 +194,10 @@ export declare class ExtAppsAdapter extends BaseAdapter {
140
194
  * Factory function for creating ext-apps adapter instances.
141
195
  */
142
196
  export declare function createExtAppsAdapter(config?: ExtAppsAdapterConfig): ExtAppsAdapter;
197
+ /**
198
+ * Error thrown when a feature is not supported by the host.
199
+ */
200
+ export declare class ExtAppsNotSupportedError extends Error {
201
+ constructor(message: string);
202
+ }
143
203
  //# sourceMappingURL=ext-apps.adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ext-apps.adapter.d.ts","sourceRoot":"","sources":["../../../src/bridge/adapters/ext-apps.adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,WAAW,EAUX,aAAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAwB,MAAM,gBAAgB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,OAAO,CAAC,EAAE;QACR,qFAAqF;QACrF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,qCAAqC;QACrC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,wCAAwC;QACxC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kDAAkD;QAClD,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gDAAgD;QAChD,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,CAAC,EAAE,cAAc;IACzB,QAAQ,CAAC,IAAI,yBAAyB;IACtC,QAAQ,CAAC,QAAQ,MAAM;IAEvB,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,gBAAgB,CAA8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C,wBAAwB;IAsBhC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,YAAY;IA2BpB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IASzB;;OAEG;IACH,OAAO,CAAC,YAAY;IAWpB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA0BhC;;OAEG;YACW,iBAAiB;IA0D/B;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAUzB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,cAAc,CAElF;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAI5B"}
package/bridge/index.js CHANGED
@@ -1049,6 +1049,8 @@ var ExtAppsAdapter = class extends BaseAdapter {
1049
1049
  _pendingRequests = /* @__PURE__ */ new Map();
1050
1050
  _requestId = 0;
1051
1051
  _trustedOrigin;
1052
+ _originTrustPending = false;
1053
+ // Guard against race condition in trust-on-first-use
1052
1054
  _hostCapabilities = {};
1053
1055
  constructor(config) {
1054
1056
  super();
@@ -1062,7 +1064,13 @@ var ExtAppsAdapter = class extends BaseAdapter {
1062
1064
  };
1063
1065
  }
1064
1066
  /**
1065
- * Check if we're in an iframe (potential ext-apps context).
1067
+ * Check if we're in an iframe with explicit ext-apps context.
1068
+ *
1069
+ * This adapter requires explicit ext-apps markers to avoid incorrectly
1070
+ * matching other iframe-based platforms (e.g., Claude legacy artifacts).
1071
+ *
1072
+ * Claude MCP Apps (2026+) uses the ext-apps protocol - detected via
1073
+ * __mcpAppsEnabled flag, which takes precedence over legacy Claude markers.
1066
1074
  */
1067
1075
  canHandle() {
1068
1076
  if (typeof window === "undefined") return false;
@@ -1070,8 +1078,24 @@ var ExtAppsAdapter = class extends BaseAdapter {
1070
1078
  if (!inIframe) return false;
1071
1079
  const win = window;
1072
1080
  if (win.openai?.canvas) return false;
1081
+ if (win.openai && typeof win.openai.callTool === "function") return false;
1073
1082
  if (win.__mcpPlatform === "ext-apps") return true;
1074
- return true;
1083
+ if (win.__extAppsInitialized) return true;
1084
+ if (win.__mcpAppsEnabled) return true;
1085
+ if (win.claude) return false;
1086
+ if (win.__claudeArtifact) return false;
1087
+ if (win.__mcpPlatform === "claude") return false;
1088
+ if (typeof location !== "undefined") {
1089
+ try {
1090
+ const url = new URL(location.href);
1091
+ const hostname = url.hostname.toLowerCase();
1092
+ const isClaudeHost = hostname === "claude.ai" || hostname.endsWith(".claude.ai");
1093
+ const isAnthropicHost = hostname === "anthropic.com" || hostname.endsWith(".anthropic.com");
1094
+ if (isClaudeHost || isAnthropicHost) return false;
1095
+ } catch {
1096
+ }
1097
+ }
1098
+ return false;
1075
1099
  }
1076
1100
  /**
1077
1101
  * Initialize the ext-apps adapter with protocol handshake.
@@ -1079,9 +1103,17 @@ var ExtAppsAdapter = class extends BaseAdapter {
1079
1103
  async initialize() {
1080
1104
  if (this._initialized) return;
1081
1105
  this._setupMessageListener();
1082
- await super.initialize();
1083
- await this._performHandshake();
1084
- this._initialized = true;
1106
+ try {
1107
+ await super.initialize();
1108
+ await this._performHandshake();
1109
+ this._initialized = true;
1110
+ } catch (error) {
1111
+ if (this._messageListener && typeof window !== "undefined") {
1112
+ window.removeEventListener("message", this._messageListener);
1113
+ this._messageListener = void 0;
1114
+ }
1115
+ throw error;
1116
+ }
1085
1117
  }
1086
1118
  /**
1087
1119
  * Dispose adapter resources.
@@ -1103,7 +1135,7 @@ var ExtAppsAdapter = class extends BaseAdapter {
1103
1135
  // ============================================
1104
1136
  async callTool(name, args) {
1105
1137
  if (!this._hostCapabilities.serverToolProxy) {
1106
- throw new Error("Server tool proxy not supported by host");
1138
+ throw new ExtAppsNotSupportedError("Server tool proxy not supported by host");
1107
1139
  }
1108
1140
  return this._sendRequest("ui/callServerTool", {
1109
1141
  name,
@@ -1127,6 +1159,71 @@ var ExtAppsAdapter = class extends BaseAdapter {
1127
1159
  await this._sendRequest("ui/close", {});
1128
1160
  }
1129
1161
  // ============================================
1162
+ // Extended ext-apps Methods (Full Specification)
1163
+ // ============================================
1164
+ /**
1165
+ * Update the model context with widget state.
1166
+ *
1167
+ * This allows the widget to pass contextual information to the model,
1168
+ * which can be used to inform subsequent interactions.
1169
+ *
1170
+ * @param context - The context data to update
1171
+ * @param merge - Whether to merge with existing context (default: true)
1172
+ */
1173
+ async updateModelContext(context, merge = true) {
1174
+ if (!this._hostCapabilities.modelContextUpdate) {
1175
+ throw new ExtAppsNotSupportedError("Model context update not supported by host");
1176
+ }
1177
+ await this._sendRequest("ui/updateModelContext", { context, merge });
1178
+ }
1179
+ /**
1180
+ * Send a log message to the host.
1181
+ *
1182
+ * Allows the widget to forward log messages to the host for debugging
1183
+ * or monitoring purposes.
1184
+ *
1185
+ * @param level - Log level (debug, info, warn, error)
1186
+ * @param message - Log message
1187
+ * @param data - Optional additional data
1188
+ */
1189
+ async log(level, message, data) {
1190
+ if (!this._hostCapabilities.logging) {
1191
+ const logFn = console[level] || console.log;
1192
+ logFn(`[Widget] ${message}`, data);
1193
+ return;
1194
+ }
1195
+ await this._sendRequest("ui/log", { level, message, data });
1196
+ }
1197
+ /**
1198
+ * Register a widget-defined tool.
1199
+ *
1200
+ * Allows the widget to dynamically register tools that can be
1201
+ * invoked by the model or user.
1202
+ *
1203
+ * @param name - Tool name
1204
+ * @param description - Tool description
1205
+ * @param inputSchema - Tool input schema (JSON Schema format)
1206
+ */
1207
+ async registerTool(name, description, inputSchema) {
1208
+ if (!this._hostCapabilities.widgetTools) {
1209
+ throw new ExtAppsNotSupportedError("Widget tool registration not supported by host");
1210
+ }
1211
+ await this._sendRequest("ui/registerTool", { name, description, inputSchema });
1212
+ }
1213
+ /**
1214
+ * Unregister a widget-defined tool.
1215
+ *
1216
+ * Removes a previously registered tool.
1217
+ *
1218
+ * @param name - Tool name to unregister
1219
+ */
1220
+ async unregisterTool(name) {
1221
+ if (!this._hostCapabilities.widgetTools) {
1222
+ throw new ExtAppsNotSupportedError("Widget tool unregistration not supported by host");
1223
+ }
1224
+ await this._sendRequest("ui/unregisterTool", { name });
1225
+ }
1226
+ // ============================================
1130
1227
  // Private: Message Handling
1131
1228
  // ============================================
1132
1229
  /**
@@ -1207,7 +1304,7 @@ var ExtAppsAdapter = class extends BaseAdapter {
1207
1304
  * Handle partial tool input (streaming).
1208
1305
  */
1209
1306
  _handleToolInputPartial(params) {
1210
- this._toolInput = { ...this._toolInput, ...params.arguments };
1307
+ this._toolInput = { ...this._toolInput, ...params.arguments || {} };
1211
1308
  this._emitBridgeEvent("tool:input-partial", { arguments: this._toolInput });
1212
1309
  }
1213
1310
  /**
@@ -1301,6 +1398,20 @@ var ExtAppsAdapter = class extends BaseAdapter {
1301
1398
  // ============================================
1302
1399
  // Private: Handshake
1303
1400
  // ============================================
1401
+ /**
1402
+ * Validate that the handshake response has the expected structure.
1403
+ */
1404
+ _isValidInitializeResult(result) {
1405
+ if (!result || typeof result !== "object") return false;
1406
+ const r = result;
1407
+ if (r["hostCapabilities"] !== void 0 && (typeof r["hostCapabilities"] !== "object" || r["hostCapabilities"] === null || Array.isArray(r["hostCapabilities"]))) {
1408
+ return false;
1409
+ }
1410
+ if (r["hostContext"] !== void 0 && (typeof r["hostContext"] !== "object" || r["hostContext"] === null || Array.isArray(r["hostContext"]))) {
1411
+ return false;
1412
+ }
1413
+ return true;
1414
+ }
1304
1415
  /**
1305
1416
  * Perform the ui/initialize handshake with the host.
1306
1417
  */
@@ -1318,7 +1429,11 @@ var ExtAppsAdapter = class extends BaseAdapter {
1318
1429
  protocolVersion: this._config.options?.protocolVersion || "2024-11-05"
1319
1430
  };
1320
1431
  try {
1321
- const result = await this._sendRequest("ui/initialize", params);
1432
+ const rawResult = await this._sendRequest("ui/initialize", params);
1433
+ if (!this._isValidInitializeResult(rawResult)) {
1434
+ throw new Error("Invalid ui/initialize response structure");
1435
+ }
1436
+ const result = rawResult;
1322
1437
  this._hostCapabilities = result.hostCapabilities || {};
1323
1438
  this._capabilities = {
1324
1439
  ...this._capabilities,
@@ -1345,6 +1460,9 @@ var ExtAppsAdapter = class extends BaseAdapter {
1345
1460
  /**
1346
1461
  * Check if an origin is trusted.
1347
1462
  * Uses trust-on-first-use if no explicit origins configured.
1463
+ *
1464
+ * Security note: Trust-on-first-use has inherent risks. For production,
1465
+ * always configure explicit trustedOrigins in adapter config.
1348
1466
  */
1349
1467
  _isOriginTrusted(origin) {
1350
1468
  const trustedOrigins = this._config.options?.trustedOrigins;
@@ -1352,7 +1470,12 @@ var ExtAppsAdapter = class extends BaseAdapter {
1352
1470
  return trustedOrigins.includes(origin);
1353
1471
  }
1354
1472
  if (!this._trustedOrigin) {
1473
+ if (this._originTrustPending) {
1474
+ return false;
1475
+ }
1476
+ this._originTrustPending = true;
1355
1477
  this._trustedOrigin = origin;
1478
+ this._originTrustPending = false;
1356
1479
  return true;
1357
1480
  }
1358
1481
  return this._trustedOrigin === origin;
@@ -1376,6 +1499,12 @@ var ExtAppsAdapter = class extends BaseAdapter {
1376
1499
  function createExtAppsAdapter(config) {
1377
1500
  return new ExtAppsAdapter(config);
1378
1501
  }
1502
+ var ExtAppsNotSupportedError = class extends Error {
1503
+ constructor(message) {
1504
+ super(message);
1505
+ this.name = "ExtAppsNotSupportedError";
1506
+ }
1507
+ };
1379
1508
 
1380
1509
  // libs/ui/src/bridge/adapters/claude.adapter.ts
1381
1510
  var ClaudeAdapter = class extends BaseAdapter {
@@ -1403,11 +1532,17 @@ var ClaudeAdapter = class extends BaseAdapter {
1403
1532
  };
1404
1533
  }
1405
1534
  /**
1406
- * Check if we're running in a Claude artifact/widget context.
1535
+ * Check if we're running in a Claude legacy artifact/widget context.
1536
+ *
1537
+ * Claude MCP Apps (2026+) uses the ext-apps adapter instead.
1538
+ * This adapter only handles legacy Claude artifacts without MCP Apps support.
1407
1539
  */
1408
1540
  canHandle() {
1409
1541
  if (typeof window === "undefined") return false;
1410
1542
  const win = window;
1543
+ if (win.__mcpAppsEnabled) return false;
1544
+ if (win.__mcpPlatform === "ext-apps") return false;
1545
+ if (win.__extAppsInitialized) return false;
1411
1546
  if (win.__mcpPlatform === "claude") return true;
1412
1547
  if (win.claude) return true;
1413
1548
  if (win.__claudeArtifact) return true;
package/bridge/types.d.ts CHANGED
@@ -267,10 +267,20 @@ export interface ExtAppsInitializeResult {
267
267
  version: string;
268
268
  };
269
269
  hostCapabilities: {
270
+ /** Host supports opening links */
270
271
  openLink?: boolean;
272
+ /** Host supports proxying tool calls to the MCP server */
271
273
  serverToolProxy?: boolean;
274
+ /** Host supports reading resources */
272
275
  resourceRead?: boolean;
276
+ /** Host supports logging */
273
277
  logging?: boolean;
278
+ /** Host supports model context updates */
279
+ modelContextUpdate?: boolean;
280
+ /** Host supports widget-defined tools */
281
+ widgetTools?: boolean;
282
+ /** Supported display modes */
283
+ displayModes?: ('inline' | 'fullscreen' | 'pip')[];
274
284
  };
275
285
  hostContext: HostContext;
276
286
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bridge/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,KAAK,GAAG,UAAU,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kBAAkB;IAClB,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACnC,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;IACf,2BAA2B;IAC3B,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAA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,WAAW,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC/E,YAAY,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC/D"}
@@ -997,6 +997,8 @@ var ExtAppsAdapter = class extends BaseAdapter {
997
997
  _pendingRequests = /* @__PURE__ */ new Map();
998
998
  _requestId = 0;
999
999
  _trustedOrigin;
1000
+ _originTrustPending = false;
1001
+ // Guard against race condition in trust-on-first-use
1000
1002
  _hostCapabilities = {};
1001
1003
  constructor(config) {
1002
1004
  super();
@@ -1010,7 +1012,13 @@ var ExtAppsAdapter = class extends BaseAdapter {
1010
1012
  };
1011
1013
  }
1012
1014
  /**
1013
- * Check if we're in an iframe (potential ext-apps context).
1015
+ * Check if we're in an iframe with explicit ext-apps context.
1016
+ *
1017
+ * This adapter requires explicit ext-apps markers to avoid incorrectly
1018
+ * matching other iframe-based platforms (e.g., Claude legacy artifacts).
1019
+ *
1020
+ * Claude MCP Apps (2026+) uses the ext-apps protocol - detected via
1021
+ * __mcpAppsEnabled flag, which takes precedence over legacy Claude markers.
1014
1022
  */
1015
1023
  canHandle() {
1016
1024
  if (typeof window === "undefined") return false;
@@ -1018,8 +1026,24 @@ var ExtAppsAdapter = class extends BaseAdapter {
1018
1026
  if (!inIframe) return false;
1019
1027
  const win = window;
1020
1028
  if (win.openai?.canvas) return false;
1029
+ if (win.openai && typeof win.openai.callTool === "function") return false;
1021
1030
  if (win.__mcpPlatform === "ext-apps") return true;
1022
- return true;
1031
+ if (win.__extAppsInitialized) return true;
1032
+ if (win.__mcpAppsEnabled) return true;
1033
+ if (win.claude) return false;
1034
+ if (win.__claudeArtifact) return false;
1035
+ if (win.__mcpPlatform === "claude") return false;
1036
+ if (typeof location !== "undefined") {
1037
+ try {
1038
+ const url = new URL(location.href);
1039
+ const hostname = url.hostname.toLowerCase();
1040
+ const isClaudeHost = hostname === "claude.ai" || hostname.endsWith(".claude.ai");
1041
+ const isAnthropicHost = hostname === "anthropic.com" || hostname.endsWith(".anthropic.com");
1042
+ if (isClaudeHost || isAnthropicHost) return false;
1043
+ } catch {
1044
+ }
1045
+ }
1046
+ return false;
1023
1047
  }
1024
1048
  /**
1025
1049
  * Initialize the ext-apps adapter with protocol handshake.
@@ -1027,9 +1051,17 @@ var ExtAppsAdapter = class extends BaseAdapter {
1027
1051
  async initialize() {
1028
1052
  if (this._initialized) return;
1029
1053
  this._setupMessageListener();
1030
- await super.initialize();
1031
- await this._performHandshake();
1032
- this._initialized = true;
1054
+ try {
1055
+ await super.initialize();
1056
+ await this._performHandshake();
1057
+ this._initialized = true;
1058
+ } catch (error) {
1059
+ if (this._messageListener && typeof window !== "undefined") {
1060
+ window.removeEventListener("message", this._messageListener);
1061
+ this._messageListener = void 0;
1062
+ }
1063
+ throw error;
1064
+ }
1033
1065
  }
1034
1066
  /**
1035
1067
  * Dispose adapter resources.
@@ -1051,7 +1083,7 @@ var ExtAppsAdapter = class extends BaseAdapter {
1051
1083
  // ============================================
1052
1084
  async callTool(name, args) {
1053
1085
  if (!this._hostCapabilities.serverToolProxy) {
1054
- throw new Error("Server tool proxy not supported by host");
1086
+ throw new ExtAppsNotSupportedError("Server tool proxy not supported by host");
1055
1087
  }
1056
1088
  return this._sendRequest("ui/callServerTool", {
1057
1089
  name,
@@ -1075,6 +1107,71 @@ var ExtAppsAdapter = class extends BaseAdapter {
1075
1107
  await this._sendRequest("ui/close", {});
1076
1108
  }
1077
1109
  // ============================================
1110
+ // Extended ext-apps Methods (Full Specification)
1111
+ // ============================================
1112
+ /**
1113
+ * Update the model context with widget state.
1114
+ *
1115
+ * This allows the widget to pass contextual information to the model,
1116
+ * which can be used to inform subsequent interactions.
1117
+ *
1118
+ * @param context - The context data to update
1119
+ * @param merge - Whether to merge with existing context (default: true)
1120
+ */
1121
+ async updateModelContext(context, merge = true) {
1122
+ if (!this._hostCapabilities.modelContextUpdate) {
1123
+ throw new ExtAppsNotSupportedError("Model context update not supported by host");
1124
+ }
1125
+ await this._sendRequest("ui/updateModelContext", { context, merge });
1126
+ }
1127
+ /**
1128
+ * Send a log message to the host.
1129
+ *
1130
+ * Allows the widget to forward log messages to the host for debugging
1131
+ * or monitoring purposes.
1132
+ *
1133
+ * @param level - Log level (debug, info, warn, error)
1134
+ * @param message - Log message
1135
+ * @param data - Optional additional data
1136
+ */
1137
+ async log(level, message, data) {
1138
+ if (!this._hostCapabilities.logging) {
1139
+ const logFn = console[level] || console.log;
1140
+ logFn(`[Widget] ${message}`, data);
1141
+ return;
1142
+ }
1143
+ await this._sendRequest("ui/log", { level, message, data });
1144
+ }
1145
+ /**
1146
+ * Register a widget-defined tool.
1147
+ *
1148
+ * Allows the widget to dynamically register tools that can be
1149
+ * invoked by the model or user.
1150
+ *
1151
+ * @param name - Tool name
1152
+ * @param description - Tool description
1153
+ * @param inputSchema - Tool input schema (JSON Schema format)
1154
+ */
1155
+ async registerTool(name, description, inputSchema) {
1156
+ if (!this._hostCapabilities.widgetTools) {
1157
+ throw new ExtAppsNotSupportedError("Widget tool registration not supported by host");
1158
+ }
1159
+ await this._sendRequest("ui/registerTool", { name, description, inputSchema });
1160
+ }
1161
+ /**
1162
+ * Unregister a widget-defined tool.
1163
+ *
1164
+ * Removes a previously registered tool.
1165
+ *
1166
+ * @param name - Tool name to unregister
1167
+ */
1168
+ async unregisterTool(name) {
1169
+ if (!this._hostCapabilities.widgetTools) {
1170
+ throw new ExtAppsNotSupportedError("Widget tool unregistration not supported by host");
1171
+ }
1172
+ await this._sendRequest("ui/unregisterTool", { name });
1173
+ }
1174
+ // ============================================
1078
1175
  // Private: Message Handling
1079
1176
  // ============================================
1080
1177
  /**
@@ -1155,7 +1252,7 @@ var ExtAppsAdapter = class extends BaseAdapter {
1155
1252
  * Handle partial tool input (streaming).
1156
1253
  */
1157
1254
  _handleToolInputPartial(params) {
1158
- this._toolInput = { ...this._toolInput, ...params.arguments };
1255
+ this._toolInput = { ...this._toolInput, ...params.arguments || {} };
1159
1256
  this._emitBridgeEvent("tool:input-partial", { arguments: this._toolInput });
1160
1257
  }
1161
1258
  /**
@@ -1249,6 +1346,20 @@ var ExtAppsAdapter = class extends BaseAdapter {
1249
1346
  // ============================================
1250
1347
  // Private: Handshake
1251
1348
  // ============================================
1349
+ /**
1350
+ * Validate that the handshake response has the expected structure.
1351
+ */
1352
+ _isValidInitializeResult(result) {
1353
+ if (!result || typeof result !== "object") return false;
1354
+ const r = result;
1355
+ if (r["hostCapabilities"] !== void 0 && (typeof r["hostCapabilities"] !== "object" || r["hostCapabilities"] === null || Array.isArray(r["hostCapabilities"]))) {
1356
+ return false;
1357
+ }
1358
+ if (r["hostContext"] !== void 0 && (typeof r["hostContext"] !== "object" || r["hostContext"] === null || Array.isArray(r["hostContext"]))) {
1359
+ return false;
1360
+ }
1361
+ return true;
1362
+ }
1252
1363
  /**
1253
1364
  * Perform the ui/initialize handshake with the host.
1254
1365
  */
@@ -1266,7 +1377,11 @@ var ExtAppsAdapter = class extends BaseAdapter {
1266
1377
  protocolVersion: this._config.options?.protocolVersion || "2024-11-05"
1267
1378
  };
1268
1379
  try {
1269
- const result = await this._sendRequest("ui/initialize", params);
1380
+ const rawResult = await this._sendRequest("ui/initialize", params);
1381
+ if (!this._isValidInitializeResult(rawResult)) {
1382
+ throw new Error("Invalid ui/initialize response structure");
1383
+ }
1384
+ const result = rawResult;
1270
1385
  this._hostCapabilities = result.hostCapabilities || {};
1271
1386
  this._capabilities = {
1272
1387
  ...this._capabilities,
@@ -1293,6 +1408,9 @@ var ExtAppsAdapter = class extends BaseAdapter {
1293
1408
  /**
1294
1409
  * Check if an origin is trusted.
1295
1410
  * Uses trust-on-first-use if no explicit origins configured.
1411
+ *
1412
+ * Security note: Trust-on-first-use has inherent risks. For production,
1413
+ * always configure explicit trustedOrigins in adapter config.
1296
1414
  */
1297
1415
  _isOriginTrusted(origin) {
1298
1416
  const trustedOrigins = this._config.options?.trustedOrigins;
@@ -1300,7 +1418,12 @@ var ExtAppsAdapter = class extends BaseAdapter {
1300
1418
  return trustedOrigins.includes(origin);
1301
1419
  }
1302
1420
  if (!this._trustedOrigin) {
1421
+ if (this._originTrustPending) {
1422
+ return false;
1423
+ }
1424
+ this._originTrustPending = true;
1303
1425
  this._trustedOrigin = origin;
1426
+ this._originTrustPending = false;
1304
1427
  return true;
1305
1428
  }
1306
1429
  return this._trustedOrigin === origin;
@@ -1324,6 +1447,12 @@ var ExtAppsAdapter = class extends BaseAdapter {
1324
1447
  function createExtAppsAdapter(config) {
1325
1448
  return new ExtAppsAdapter(config);
1326
1449
  }
1450
+ var ExtAppsNotSupportedError = class extends Error {
1451
+ constructor(message) {
1452
+ super(message);
1453
+ this.name = "ExtAppsNotSupportedError";
1454
+ }
1455
+ };
1327
1456
 
1328
1457
  // libs/ui/src/bridge/adapters/claude.adapter.ts
1329
1458
  var ClaudeAdapter = class extends BaseAdapter {
@@ -1351,11 +1480,17 @@ var ClaudeAdapter = class extends BaseAdapter {
1351
1480
  };
1352
1481
  }
1353
1482
  /**
1354
- * Check if we're running in a Claude artifact/widget context.
1483
+ * Check if we're running in a Claude legacy artifact/widget context.
1484
+ *
1485
+ * Claude MCP Apps (2026+) uses the ext-apps adapter instead.
1486
+ * This adapter only handles legacy Claude artifacts without MCP Apps support.
1355
1487
  */
1356
1488
  canHandle() {
1357
1489
  if (typeof window === "undefined") return false;
1358
1490
  const win = window;
1491
+ if (win.__mcpAppsEnabled) return false;
1492
+ if (win.__mcpPlatform === "ext-apps") return false;
1493
+ if (win.__extAppsInitialized) return false;
1359
1494
  if (win.__mcpPlatform === "claude") return true;
1360
1495
  if (win.claude) return true;
1361
1496
  if (win.__claudeArtifact) return true;
package/esm/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/ui",
3
- "version": "0.7.2",
3
+ "version": "0.8.1",
4
4
  "description": "FrontMCP UI - React components and hooks for MCP applications",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "homepage": "https://docs.agentfront.dev",
@@ -52,6 +52,9 @@
52
52
  },
53
53
  "./esm": null
54
54
  },
55
+ "engines": {
56
+ "node": ">=22.0.0"
57
+ },
55
58
  "dependencies": {
56
59
  "@mdx-js/mdx": "^3.1.1",
57
60
  "@swc/core": "^1.5.0",
@@ -61,7 +64,7 @@
61
64
  "peerDependencies": {
62
65
  "react": "^18.0.0 || ^19.0.0",
63
66
  "react-dom": "^18.0.0 || ^19.0.0",
64
- "@frontmcp/uipack": "0.7.2"
67
+ "@frontmcp/uipack": "0.8.1"
65
68
  },
66
69
  "devDependencies": {
67
70
  "@types/react": "^19.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/ui",
3
- "version": "0.7.2",
3
+ "version": "0.8.1",
4
4
  "description": "FrontMCP UI - React components and hooks for MCP applications",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "homepage": "https://docs.agentfront.dev",
@@ -52,6 +52,9 @@
52
52
  },
53
53
  "./esm": null
54
54
  },
55
+ "engines": {
56
+ "node": ">=22.0.0"
57
+ },
55
58
  "dependencies": {
56
59
  "@mdx-js/mdx": "^3.1.1",
57
60
  "@swc/core": "^1.5.0",
@@ -61,7 +64,7 @@
61
64
  "peerDependencies": {
62
65
  "react": "^18.0.0 || ^19.0.0",
63
66
  "react-dom": "^18.0.0 || ^19.0.0",
64
- "@frontmcp/uipack": "0.7.2"
67
+ "@frontmcp/uipack": "0.8.1"
65
68
  },
66
69
  "devDependencies": {
67
70
  "@types/react": "^19.0.0",