skybridge 0.0.0-dev.7d427ae → 0.0.0-dev.7d5a640

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.
Files changed (219) hide show
  1. package/README.md +145 -0
  2. package/bin/run.js +0 -4
  3. package/dist/cli/detect-port.d.ts +18 -0
  4. package/dist/cli/detect-port.js +61 -0
  5. package/dist/cli/detect-port.js.map +1 -0
  6. package/dist/cli/header.d.ts +4 -0
  7. package/dist/cli/header.js +6 -0
  8. package/dist/cli/header.js.map +1 -0
  9. package/dist/cli/run-command.d.ts +2 -0
  10. package/dist/cli/run-command.js +43 -0
  11. package/dist/cli/run-command.js.map +1 -0
  12. package/dist/cli/telemetry.d.ts +7 -0
  13. package/dist/cli/telemetry.js +123 -0
  14. package/dist/cli/telemetry.js.map +1 -0
  15. package/dist/cli/use-execute-steps.d.ts +11 -0
  16. package/dist/cli/use-execute-steps.js +36 -0
  17. package/dist/cli/use-execute-steps.js.map +1 -0
  18. package/dist/cli/use-nodemon.d.ts +6 -0
  19. package/dist/cli/use-nodemon.js +69 -0
  20. package/dist/cli/use-nodemon.js.map +1 -0
  21. package/dist/cli/use-typescript-check.d.ts +8 -0
  22. package/dist/cli/use-typescript-check.js +59 -0
  23. package/dist/cli/use-typescript-check.js.map +1 -0
  24. package/dist/commands/build.d.ts +9 -0
  25. package/dist/commands/build.js +46 -0
  26. package/dist/commands/build.js.map +1 -0
  27. package/dist/commands/dev.d.ts +4 -1
  28. package/dist/commands/dev.js +33 -21
  29. package/dist/commands/dev.js.map +1 -1
  30. package/dist/commands/start.d.ts +9 -0
  31. package/dist/commands/start.js +52 -0
  32. package/dist/commands/start.js.map +1 -0
  33. package/dist/commands/telemetry/disable.d.ts +5 -0
  34. package/dist/commands/telemetry/disable.js +14 -0
  35. package/dist/commands/telemetry/disable.js.map +1 -0
  36. package/dist/commands/telemetry/enable.d.ts +5 -0
  37. package/dist/commands/telemetry/enable.js +14 -0
  38. package/dist/commands/telemetry/enable.js.map +1 -0
  39. package/dist/commands/telemetry/status.d.ts +5 -0
  40. package/dist/commands/telemetry/status.js +14 -0
  41. package/dist/commands/telemetry/status.js.map +1 -0
  42. package/dist/server/asset-base-url-transform-plugin.d.ts +11 -0
  43. package/dist/server/asset-base-url-transform-plugin.js +34 -0
  44. package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
  45. package/dist/server/asset-base-url-transform-plugin.test.js +56 -0
  46. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
  47. package/dist/server/const.d.ts +1 -0
  48. package/dist/server/const.js +2 -0
  49. package/dist/server/const.js.map +1 -0
  50. package/dist/server/express.d.ts +9 -0
  51. package/dist/server/express.js +72 -0
  52. package/dist/server/express.js.map +1 -0
  53. package/dist/server/express.test.d.ts +1 -0
  54. package/dist/server/express.test.js +74 -0
  55. package/dist/server/express.test.js.map +1 -0
  56. package/dist/server/server.d.ts +8 -4
  57. package/dist/server/server.js +131 -59
  58. package/dist/server/server.js.map +1 -1
  59. package/dist/server/templateHelper.d.ts +1 -0
  60. package/dist/server/templateHelper.js.map +1 -1
  61. package/dist/server/templates/development.hbs +3 -2
  62. package/dist/server/templates/production.hbs +1 -2
  63. package/dist/server/widgetsDevServer.js +17 -1
  64. package/dist/server/widgetsDevServer.js.map +1 -1
  65. package/dist/test/widget.test.js +43 -16
  66. package/dist/test/widget.test.js.map +1 -1
  67. package/dist/web/bridges/apps-sdk/adaptor.d.ts +22 -0
  68. package/dist/web/bridges/apps-sdk/adaptor.js +71 -0
  69. package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
  70. package/dist/web/bridges/apps-sdk/bridge.d.ts +10 -0
  71. package/dist/web/bridges/{apps-sdk-bridge.js → apps-sdk/bridge.js} +2 -2
  72. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
  73. package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
  74. package/dist/web/bridges/apps-sdk/index.js +5 -0
  75. package/dist/web/bridges/apps-sdk/index.js.map +1 -0
  76. package/dist/web/bridges/apps-sdk/types.d.ts +118 -0
  77. package/dist/web/bridges/apps-sdk/types.js +10 -0
  78. package/dist/web/bridges/apps-sdk/types.js.map +1 -0
  79. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +2 -0
  80. package/dist/web/bridges/{hooks/use-apps-sdk-bridge.js → apps-sdk/use-apps-sdk-context.js} +3 -3
  81. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
  82. package/dist/web/bridges/get-adaptor.d.ts +2 -0
  83. package/dist/web/bridges/get-adaptor.js +8 -0
  84. package/dist/web/bridges/get-adaptor.js.map +1 -0
  85. package/dist/web/bridges/index.d.ts +5 -4
  86. package/dist/web/bridges/index.js +5 -4
  87. package/dist/web/bridges/index.js.map +1 -1
  88. package/dist/web/bridges/mcp-app/adaptor.d.ts +36 -0
  89. package/dist/web/bridges/mcp-app/adaptor.js +190 -0
  90. package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
  91. package/dist/web/bridges/{mcp-app-bridge.d.ts → mcp-app/bridge.d.ts} +10 -13
  92. package/dist/web/bridges/{mcp-app-bridge.js → mcp-app/bridge.js} +76 -33
  93. package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
  94. package/dist/web/bridges/mcp-app/index.d.ts +4 -0
  95. package/dist/web/bridges/mcp-app/index.js +4 -0
  96. package/dist/web/bridges/mcp-app/index.js.map +1 -0
  97. package/dist/web/bridges/mcp-app/types.d.ts +8 -0
  98. package/dist/web/bridges/mcp-app/types.js +2 -0
  99. package/dist/web/bridges/mcp-app/types.js.map +1 -0
  100. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -0
  101. package/dist/web/bridges/{hooks/use-mcp-app-bridge.js → mcp-app/use-mcp-app-context.js} +3 -3
  102. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
  103. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.d.ts +1 -0
  104. package/dist/web/bridges/{hooks/use-mcp-app-bridge.test.js → mcp-app/use-mcp-app-context.test.js} +17 -13
  105. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
  106. package/dist/web/bridges/types.d.ts +65 -24
  107. package/dist/web/bridges/use-host-context.d.ts +2 -0
  108. package/dist/web/bridges/use-host-context.js +8 -0
  109. package/dist/web/bridges/use-host-context.js.map +1 -0
  110. package/dist/web/components/modal-provider.d.ts +4 -0
  111. package/dist/web/components/modal-provider.js +47 -0
  112. package/dist/web/components/modal-provider.js.map +1 -0
  113. package/dist/web/create-store.js +6 -7
  114. package/dist/web/create-store.js.map +1 -1
  115. package/dist/web/create-store.test.js +108 -52
  116. package/dist/web/create-store.test.js.map +1 -1
  117. package/dist/web/data-llm.js +5 -3
  118. package/dist/web/data-llm.js.map +1 -1
  119. package/dist/web/data-llm.test.js +130 -65
  120. package/dist/web/data-llm.test.js.map +1 -1
  121. package/dist/web/generate-helpers.d.ts +3 -2
  122. package/dist/web/generate-helpers.js +1 -1
  123. package/dist/web/generate-helpers.js.map +1 -1
  124. package/dist/web/helpers/state.js +13 -8
  125. package/dist/web/helpers/state.js.map +1 -1
  126. package/dist/web/hooks/index.d.ts +1 -1
  127. package/dist/web/hooks/index.js +1 -1
  128. package/dist/web/hooks/index.js.map +1 -1
  129. package/dist/web/hooks/test/utils.d.ts +8 -2
  130. package/dist/web/hooks/test/utils.js +33 -13
  131. package/dist/web/hooks/test/utils.js.map +1 -1
  132. package/dist/web/hooks/use-call-tool.d.ts +3 -2
  133. package/dist/web/hooks/use-call-tool.js +2 -2
  134. package/dist/web/hooks/use-call-tool.js.map +1 -1
  135. package/dist/web/hooks/use-call-tool.test-d.js +1 -1
  136. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
  137. package/dist/web/hooks/use-call-tool.test.js +3 -3
  138. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  139. package/dist/web/hooks/use-display-mode.js +3 -4
  140. package/dist/web/hooks/use-display-mode.js.map +1 -1
  141. package/dist/web/hooks/use-files.d.ts +2 -6
  142. package/dist/web/hooks/use-files.js +4 -2
  143. package/dist/web/hooks/use-files.js.map +1 -1
  144. package/dist/web/hooks/use-files.test.js +6 -1
  145. package/dist/web/hooks/use-files.test.js.map +1 -1
  146. package/dist/web/hooks/use-layout.d.ts +2 -2
  147. package/dist/web/hooks/use-layout.js +4 -4
  148. package/dist/web/hooks/use-layout.js.map +1 -1
  149. package/dist/web/hooks/use-layout.test.js +6 -5
  150. package/dist/web/hooks/use-layout.test.js.map +1 -1
  151. package/dist/web/hooks/use-open-external.js +2 -2
  152. package/dist/web/hooks/use-open-external.test.js +1 -1
  153. package/dist/web/hooks/use-request-modal.d.ts +2 -2
  154. package/dist/web/hooks/use-request-modal.js +9 -7
  155. package/dist/web/hooks/use-request-modal.js.map +1 -1
  156. package/dist/web/hooks/use-send-follow-up-message.js +2 -2
  157. package/dist/web/hooks/use-set-open-in-app-url.d.ts +1 -0
  158. package/dist/web/hooks/use-set-open-in-app-url.js +8 -0
  159. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
  160. package/dist/web/hooks/use-set-open-in-app-url.test.d.ts +1 -0
  161. package/dist/web/hooks/use-set-open-in-app-url.test.js +43 -0
  162. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
  163. package/dist/web/hooks/use-tool-info.js +4 -4
  164. package/dist/web/hooks/use-tool-info.js.map +1 -1
  165. package/dist/web/hooks/use-tool-info.test.js +4 -4
  166. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  167. package/dist/web/hooks/use-user.d.ts +1 -1
  168. package/dist/web/hooks/use-user.js +3 -3
  169. package/dist/web/hooks/use-user.js.map +1 -1
  170. package/dist/web/hooks/use-user.test.js +4 -3
  171. package/dist/web/hooks/use-user.test.js.map +1 -1
  172. package/dist/web/hooks/use-widget-state.js +10 -10
  173. package/dist/web/hooks/use-widget-state.js.map +1 -1
  174. package/dist/web/hooks/use-widget-state.test.js +7 -6
  175. package/dist/web/hooks/use-widget-state.test.js.map +1 -1
  176. package/dist/web/mount-widget.js +9 -1
  177. package/dist/web/mount-widget.js.map +1 -1
  178. package/dist/web/plugin/plugin.js +24 -9
  179. package/dist/web/plugin/plugin.js.map +1 -1
  180. package/dist/web/plugin/validate-widget.d.ts +5 -0
  181. package/dist/web/plugin/validate-widget.js +27 -0
  182. package/dist/web/plugin/validate-widget.js.map +1 -0
  183. package/dist/web/plugin/validate-widget.test.d.ts +1 -0
  184. package/dist/web/plugin/validate-widget.test.js +42 -0
  185. package/dist/web/plugin/validate-widget.test.js.map +1 -0
  186. package/dist/web/proxy.js +0 -1
  187. package/dist/web/proxy.js.map +1 -1
  188. package/dist/web/types.d.ts +0 -133
  189. package/dist/web/types.js +0 -9
  190. package/dist/web/types.js.map +1 -1
  191. package/package.json +33 -22
  192. package/tsconfig.base.json +28 -0
  193. package/dist/cli/use-version.d.ts +0 -1
  194. package/dist/cli/use-version.js +0 -33
  195. package/dist/cli/use-version.js.map +0 -1
  196. package/dist/web/bridges/adaptors/apps-sdk-adaptor.d.ts +0 -13
  197. package/dist/web/bridges/adaptors/apps-sdk-adaptor.js +0 -33
  198. package/dist/web/bridges/adaptors/apps-sdk-adaptor.js.map +0 -1
  199. package/dist/web/bridges/adaptors/mcp-app-adaptor.d.ts +0 -16
  200. package/dist/web/bridges/adaptors/mcp-app-adaptor.js +0 -115
  201. package/dist/web/bridges/adaptors/mcp-app-adaptor.js.map +0 -1
  202. package/dist/web/bridges/apps-sdk-bridge.d.ts +0 -10
  203. package/dist/web/bridges/apps-sdk-bridge.js.map +0 -1
  204. package/dist/web/bridges/hooks/use-adaptor.d.ts +0 -2
  205. package/dist/web/bridges/hooks/use-adaptor.js +0 -8
  206. package/dist/web/bridges/hooks/use-adaptor.js.map +0 -1
  207. package/dist/web/bridges/hooks/use-apps-sdk-bridge.d.ts +0 -2
  208. package/dist/web/bridges/hooks/use-apps-sdk-bridge.js.map +0 -1
  209. package/dist/web/bridges/hooks/use-bridge.d.ts +0 -2
  210. package/dist/web/bridges/hooks/use-bridge.js +0 -8
  211. package/dist/web/bridges/hooks/use-bridge.js.map +0 -1
  212. package/dist/web/bridges/hooks/use-mcp-app-bridge.d.ts +0 -5
  213. package/dist/web/bridges/hooks/use-mcp-app-bridge.js.map +0 -1
  214. package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js.map +0 -1
  215. package/dist/web/bridges/mcp-app-bridge.js.map +0 -1
  216. package/dist/web/hooks/use-openai-global.d.ts +0 -3
  217. package/dist/web/hooks/use-openai-global.js +0 -6
  218. package/dist/web/hooks/use-openai-global.js.map +0 -1
  219. /package/dist/{web/bridges/hooks/use-mcp-app-bridge.test.d.ts → server/asset-base-url-transform-plugin.test.d.ts} +0 -0
@@ -1,16 +1,10 @@
1
- import type { McpUiHostContext, McpUiInitializeRequest, McpUiToolCancelledNotification, McpUiToolInputNotification, McpUiToolResultNotification } from "@modelcontextprotocol/ext-apps";
2
- import type { Bridge, Subscribe } from "./types.js";
1
+ import type { McpUiHostContext, McpUiInitializeRequest } from "@modelcontextprotocol/ext-apps";
2
+ import type { Bridge, Subscribe } from "../types.js";
3
+ import type { McpAppContext, McpAppContextKey } from "./types.js";
3
4
  type McpAppInitializationOptions = Pick<McpUiInitializeRequest["params"], "appInfo">;
4
- export type McpToolState = {
5
- toolInput: NonNullable<McpUiToolInputNotification["params"]["arguments"]> | null;
6
- toolResult: McpUiToolResultNotification["params"] | null;
7
- toolCancelled: McpUiToolCancelledNotification["params"] | null;
8
- };
9
- export type McpAppBridgeContext = McpUiHostContext & McpToolState;
10
- export type McpAppBridgeKey = keyof McpAppBridgeContext;
11
5
  export declare class McpAppBridge implements Bridge<McpUiHostContext> {
12
6
  private static instance;
13
- context: McpAppBridgeContext;
7
+ context: McpAppContext;
14
8
  private listeners;
15
9
  private pendingRequests;
16
10
  private nextId;
@@ -20,9 +14,9 @@ export declare class McpAppBridge implements Bridge<McpUiHostContext> {
20
14
  private cleanupSizeObserver;
21
15
  constructor(options: McpAppInitializationOptions, requestTimeout?: number);
22
16
  static getInstance(options?: Partial<McpAppInitializationOptions>, requestTimeout?: number): McpAppBridge;
23
- subscribe(key: McpAppBridgeKey): Subscribe;
24
- subscribe(keys: readonly McpAppBridgeKey[]): Subscribe;
25
- getSnapshot<K extends keyof McpAppBridgeContext>(key: K): McpAppBridgeContext[K];
17
+ subscribe(key: McpAppContextKey): Subscribe;
18
+ subscribe(keys: readonly McpAppContextKey[]): Subscribe;
19
+ getSnapshot<K extends keyof McpAppContext>(key: K): McpAppContext[K];
26
20
  cleanup: () => void;
27
21
  static resetInstance(): void;
28
22
  request<R extends {
@@ -33,6 +27,9 @@ export declare class McpAppBridge implements Bridge<McpUiHostContext> {
33
27
  private updateContext;
34
28
  private init;
35
29
  private handleMessage;
30
+ private handleResponse;
31
+ private handleNotification;
32
+ private handleRequest;
36
33
  private connect;
37
34
  private notify;
38
35
  private sendSizeChanged;
@@ -1,4 +1,12 @@
1
1
  const LATEST_PROTOCOL_VERSION = "2025-11-21";
2
+ var JsonRpcErrorCode;
3
+ (function (JsonRpcErrorCode) {
4
+ JsonRpcErrorCode[JsonRpcErrorCode["ParseError"] = -32700] = "ParseError";
5
+ JsonRpcErrorCode[JsonRpcErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
6
+ JsonRpcErrorCode[JsonRpcErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
7
+ JsonRpcErrorCode[JsonRpcErrorCode["InvalidParams"] = -32602] = "InvalidParams";
8
+ JsonRpcErrorCode[JsonRpcErrorCode["InternalError"] = -32603] = "InternalError";
9
+ })(JsonRpcErrorCode || (JsonRpcErrorCode = {}));
2
10
  export class McpAppBridge {
3
11
  static instance = null;
4
12
  context = {
@@ -21,6 +29,7 @@ export class McpAppBridge {
21
29
  appCapabilities: {},
22
30
  protocolVersion: LATEST_PROTOCOL_VERSION,
23
31
  };
32
+ this.init();
24
33
  }
25
34
  static getInstance(options, requestTimeout) {
26
35
  if (window.skybridge.hostType !== "mcp-app") {
@@ -43,7 +52,6 @@ export class McpAppBridge {
43
52
  for (const key of keys) {
44
53
  this.listeners.set(key, new Set([...(this.listeners.get(key) || []), onChange]));
45
54
  }
46
- this.init();
47
55
  return () => {
48
56
  for (const key of keys) {
49
57
  this.listeners.get(key)?.delete(onChange);
@@ -112,39 +120,75 @@ export class McpAppBridge {
112
120
  return;
113
121
  }
114
122
  if ("id" in data) {
115
- const request = this.pendingRequests.get(data.id);
116
- if (request) {
117
- clearTimeout(request.timeout);
118
- this.pendingRequests.delete(data.id);
119
- if ("error" in data) {
120
- request.reject(new Error(data.error.message));
121
- return;
122
- }
123
- request.resolve(data.result);
123
+ if ("method" in data) {
124
+ this.handleRequest(data);
125
+ return;
124
126
  }
127
+ this.handleResponse(data);
125
128
  return;
126
129
  }
127
- switch (data.method) {
130
+ this.handleNotification(data);
131
+ };
132
+ handleResponse(response) {
133
+ const request = this.pendingRequests.get(response.id);
134
+ if (request) {
135
+ clearTimeout(request.timeout);
136
+ this.pendingRequests.delete(response.id);
137
+ if ("error" in response) {
138
+ request.reject(new Error(response.error.message));
139
+ return;
140
+ }
141
+ request.resolve(response.result);
142
+ }
143
+ }
144
+ handleNotification = (notification) => {
145
+ switch (notification.method) {
128
146
  case "ui/notifications/host-context-changed":
129
- this.updateContext(data.params);
147
+ this.updateContext(notification.params);
148
+ return;
149
+ case "ui/notifications/tool-input-partial":
150
+ this.updateContext({
151
+ toolInput: notification.params.arguments ?? {},
152
+ });
130
153
  return;
131
154
  case "ui/notifications/tool-input":
132
155
  this.updateContext({
133
- toolInput: data.params.arguments ?? {},
156
+ toolInput: notification.params.arguments ?? {},
134
157
  });
135
158
  return;
136
159
  case "ui/notifications/tool-result":
137
160
  this.updateContext({
138
- toolResult: data.params,
161
+ toolResult: notification.params,
139
162
  });
140
163
  return;
141
164
  case "ui/notifications/tool-cancelled":
142
165
  this.updateContext({
143
- toolCancelled: data.params,
166
+ toolCancelled: notification.params,
144
167
  });
145
168
  return;
146
169
  }
147
170
  };
171
+ handleRequest = (request) => {
172
+ switch (request.method) {
173
+ case "ui/resource-teardown":
174
+ this.cleanup();
175
+ window.parent.postMessage({
176
+ jsonrpc: "2.0",
177
+ id: request.id,
178
+ result: {},
179
+ }, "*");
180
+ return;
181
+ default:
182
+ window.parent.postMessage({
183
+ jsonrpc: "2.0",
184
+ id: request.id,
185
+ error: {
186
+ code: JsonRpcErrorCode.MethodNotFound,
187
+ message: "Unsupported Request",
188
+ },
189
+ }, "*");
190
+ }
191
+ };
148
192
  async connect() {
149
193
  try {
150
194
  const result = await this.request({
@@ -181,23 +225,22 @@ export class McpAppBridge {
181
225
  scheduled = true;
182
226
  requestAnimationFrame(() => {
183
227
  scheduled = false;
184
- const html = document.documentElement;
185
- // Measure actual content size by temporarily setting html to fit-content.
186
- // This shrinks html to fit body (including body margins), giving us the
187
- // true minimum size needed by the content.
188
- const originalWidth = html.style.width;
189
- const originalHeight = html.style.height;
190
- html.style.width = "fit-content";
191
- html.style.height = "fit-content";
192
- const rect = html.getBoundingClientRect();
193
- html.style.width = originalWidth;
194
- html.style.height = originalHeight;
195
- // Compensate for scrollbar width on Linux/Windows where scrollbars
196
- // consume space. On systems with overlay scrollbars (macOS), this
197
- // will be 0.
198
- const scrollbarWidth = window.innerWidth - html.clientWidth;
199
- const width = Math.ceil(rect.width + scrollbarWidth);
200
- const height = Math.ceil(rect.height);
228
+ let width;
229
+ let height;
230
+ // In fullscreen mode, use viewport size since the widget should fill
231
+ // the entire available space provided by the host.
232
+ if (this.context.displayMode === "fullscreen") {
233
+ width = window.innerWidth;
234
+ height = window.innerHeight;
235
+ }
236
+ else {
237
+ // Use scrollWidth/scrollHeight to measure actual rendered content size.
238
+ // This works better than fit-content for viewport-based layouts (vw/vh)
239
+ // and fluid elements like maps that want to fill available space.
240
+ const body = document.body;
241
+ width = Math.ceil(body.scrollWidth);
242
+ height = Math.ceil(body.scrollHeight);
243
+ }
201
244
  // Only send if size actually changed (prevents feedback loops from
202
245
  // style changes)
203
246
  if (width !== lastWidth || height !== lastHeight) {
@@ -214,4 +257,4 @@ export class McpAppBridge {
214
257
  return () => resizeObserver.disconnect();
215
258
  }
216
259
  }
217
- //# sourceMappingURL=mcp-app-bridge.js.map
260
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/bridge.ts"],"names":[],"mappings":"AA4BA,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAE7C,IAAK,gBAMJ;AAND,WAAK,gBAAgB;IACnB,wEAAmB,CAAA;IACnB,gFAAuB,CAAA;IACvB,gFAAuB,CAAA;IACvB,8EAAsB,CAAA;IACtB,8EAAsB,CAAA;AACxB,CAAC,EANI,gBAAgB,KAAhB,gBAAgB,QAMpB;AA2BD,MAAM,OAAO,YAAY;IACf,MAAM,CAAC,QAAQ,GAAwB,IAAI,CAAC;IAC7C,OAAO,GAAkB;QAC9B,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,IAAI;KACjB,CAAC;IACM,SAAS,GAAG,IAAI,GAAG,EAAqC,CAAC;IACzD,eAAe,GAAG,IAAI,GAAG,EAA4C,CAAC;IACtE,MAAM,GAAG,CAAC,CAAC;IACX,WAAW,CAAU;IACrB,wBAAwB,CAAmC;IAC3D,cAAc,CAAS;IACvB,mBAAmB,GAAwB,IAAI,CAAC;IAExD,YACE,OAAoC,EACpC,iBAAyB,MAAM;QAE/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,wBAAwB,GAAG;YAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,eAAe,EAAE,EAAE;YACnB,eAAe,EAAE,uBAAuB;SACzC,CAAC;QACF,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,WAAW,CACvB,OAA8C,EAC9C,cAAuB;QAEvB,IAAI,M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;gBACnE,iBAAiB;gBACjB,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;oBACjD,SAAS,GAAG,KAAK,CAAC;oBAClB,UAAU,GAAG,MAAM,CAAC;oBACpB,IAAI,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,mBAAmB,EAAE,CAAC;QAEtB,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,mBAAmB,CAAC,CAAC;QAC/D,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACjD,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEtC,OAAO,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;IAC3C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { McpAppAdaptor } from "./adaptor.js";
2
+ export { McpAppBridge } from "./bridge.js";
3
+ export type { McpAppContext, McpAppContextKey, McpToolState, } from "./types.js";
4
+ export { useMcpAppContext } from "./use-mcp-app-context.js";
@@ -0,0 +1,4 @@
1
+ export { McpAppAdaptor } from "./adaptor.js";
2
+ export { McpAppBridge } from "./bridge.js";
3
+ export { useMcpAppContext } from "./use-mcp-app-context.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { McpUiHostContext, McpUiToolCancelledNotification, McpUiToolInputNotification, McpUiToolResultNotification } from "@modelcontextprotocol/ext-apps";
2
+ export type McpToolState = {
3
+ toolInput: NonNullable<McpUiToolInputNotification["params"]["arguments"]> | null;
4
+ toolResult: McpUiToolResultNotification["params"] | null;
5
+ toolCancelled: McpUiToolCancelledNotification["params"] | null;
6
+ };
7
+ export type McpAppContext = McpUiHostContext & McpToolState;
8
+ export type McpAppContextKey = keyof McpAppContext;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { McpUiInitializeRequest } from "@modelcontextprotocol/ext-apps";
2
+ import type { McpAppContext } from "./types.js";
3
+ type McpAppInitializationOptions = Pick<McpUiInitializeRequest["params"], "appInfo">;
4
+ export declare function useMcpAppContext<K extends keyof McpAppContext>(key: K, options?: Partial<McpAppInitializationOptions>, requestTimeout?: number): McpAppContext[K];
5
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { useSyncExternalStore } from "react";
2
- import { McpAppBridge } from "../mcp-app-bridge.js";
3
- export function useMcpAppBridge(key, options, requestTimeout) {
2
+ import { McpAppBridge } from "./bridge.js";
3
+ export function useMcpAppContext(key, options, requestTimeout) {
4
4
  const bridge = McpAppBridge.getInstance(options, requestTimeout);
5
5
  return useSyncExternalStore(bridge.subscribe(key), () => bridge.getSnapshot(key));
6
6
  }
7
- //# sourceMappingURL=use-mcp-app-bridge.js.map
7
+ //# sourceMappingURL=use-mcp-app-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mcp-app-context.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/use-mcp-app-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQ3C,MAAM,UAAU,gBAAgB,CAC9B,GAAM,EACN,OAA8C,EAC9C,cAAuB;IAEvB,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CACtD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CACxB,CAAC;AACJ,CAAC"}
@@ -1,14 +1,9 @@
1
1
  import { act, renderHook, waitFor } from "@testing-library/react";
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
- import { getMcpAppHostPostMessageMock } from "../../hooks/test/utils.js";
4
- import { McpAppBridge } from "../mcp-app-bridge.js";
5
- import { useMcpAppBridge } from "./use-mcp-app-bridge.js";
6
- class MockResizeObserver {
7
- observe = vi.fn();
8
- unobserve = vi.fn();
9
- disconnect = vi.fn();
10
- }
11
- describe("useMcpAppBridge", () => {
3
+ import { getMcpAppHostPostMessageMock, MockResizeObserver, } from "../../hooks/test/utils.js";
4
+ import { McpAppBridge } from "./bridge.js";
5
+ import { useMcpAppContext } from "./use-mcp-app-context.js";
6
+ describe("useMcpAppContext", () => {
12
7
  beforeEach(async () => {
13
8
  vi.stubGlobal("skybridge", { hostType: "mcp-app" });
14
9
  vi.stubGlobal("ResizeObserver", MockResizeObserver);
@@ -22,7 +17,7 @@ describe("useMcpAppBridge", () => {
22
17
  vi.stubGlobal("parent", {
23
18
  postMessage: getMcpAppHostPostMessageMock({ theme: "light" }),
24
19
  });
25
- const { result } = renderHook(() => useMcpAppBridge("theme"));
20
+ const { result } = renderHook(() => useMcpAppContext("theme"));
26
21
  await waitFor(() => {
27
22
  expect(result.current).toBe("light");
28
23
  });
@@ -34,7 +29,7 @@ describe("useMcpAppBridge", () => {
34
29
  .mockImplementation(() => { });
35
30
  const nonRespondingMock = vi.fn();
36
31
  vi.stubGlobal("parent", { postMessage: nonRespondingMock });
37
- renderHook(() => useMcpAppBridge("theme", undefined, 100));
32
+ renderHook(() => useMcpAppContext("theme", undefined, 100));
38
33
  expect(nonRespondingMock).toHaveBeenCalledWith(expect.objectContaining({ method: "ui/initialize" }), "*");
39
34
  await act(async () => {
40
35
  await vi.advanceTimersByTimeAsync(100);
@@ -44,9 +39,18 @@ describe("useMcpAppBridge", () => {
44
39
  vi.useRealTimers();
45
40
  });
46
41
  it("should send size-changed notification after successful initialization", async () => {
42
+ // Mock body dimensions to non-zero (size-changed only sends when dimensions change)
43
+ Object.defineProperty(document.body, "scrollWidth", {
44
+ value: 800,
45
+ configurable: true,
46
+ });
47
+ Object.defineProperty(document.body, "scrollHeight", {
48
+ value: 600,
49
+ configurable: true,
50
+ });
47
51
  const postMessageMock = getMcpAppHostPostMessageMock({ theme: "light" });
48
52
  vi.stubGlobal("parent", { postMessage: postMessageMock });
49
- renderHook(() => useMcpAppBridge("theme"));
53
+ renderHook(() => useMcpAppContext("theme"));
50
54
  await waitFor(() => {
51
55
  expect(postMessageMock).toHaveBeenCalledWith(expect.objectContaining({
52
56
  jsonrpc: "2.0",
@@ -59,4 +63,4 @@ describe("useMcpAppBridge", () => {
59
63
  });
60
64
  });
61
65
  });
62
- //# sourceMappingURL=use-mcp-app-bridge.test.js.map
66
+ //# sourceMappingURL=use-mcp-app-context.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mcp-app-context.test.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/use-mcp-app-context.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0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,CAAC,gBAAgB,CAAC;gBACtB,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,+BAA+B;gBACvC,MAAM,EAAE,MAAM,CAAC,gBAAgB,CAAC;oBAC9B,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;oBACzB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;iBAC3B,CAAC;aACH,CAAC,EACF,GAAG,CACJ,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,40 +1,59 @@
1
1
  import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
2
  import type { useSyncExternalStore } from "react";
3
+ import type { WidgetHostType } from "../../server/index.js";
4
+ export type SkybridgeProperties = {
5
+ hostType: WidgetHostType;
6
+ serverUrl: string;
7
+ };
8
+ declare global {
9
+ interface Window {
10
+ skybridge: SkybridgeProperties;
11
+ }
12
+ }
3
13
  export type CallToolArgs = Record<string, unknown> | null;
4
14
  export type CallToolResponse = {
5
15
  content: CallToolResult["content"];
6
16
  structuredContent: NonNullable<CallToolResult["structuredContent"]>;
7
17
  isError: NonNullable<CallToolResult["isError"]>;
8
18
  result: string;
9
- _meta?: CallToolResult["_meta"];
19
+ meta?: CallToolResult["_meta"];
10
20
  };
11
21
  export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
22
+ export type Theme = "light" | "dark";
12
23
  export type DeviceType = "mobile" | "tablet" | "desktop" | "unknown";
13
- export interface BridgeInterface {
14
- theme: "light" | "dark";
15
- locale: string;
16
- displayMode: DisplayMode;
17
- safeArea: {
18
- insets: {
19
- top: number;
20
- right: number;
21
- bottom: number;
22
- left: number;
23
- };
24
+ export type SafeAreaInsets = {
25
+ top: number;
26
+ right: number;
27
+ bottom: number;
28
+ left: number;
29
+ };
30
+ export type SafeArea = {
31
+ insets: SafeAreaInsets;
32
+ };
33
+ export type UserAgent = {
34
+ device: {
35
+ type: DeviceType;
24
36
  };
25
- maxHeight: number;
26
- userAgent: {
27
- device: {
28
- type: DeviceType;
29
- };
30
- capabilities: {
31
- hover: boolean;
32
- touch: boolean;
33
- };
37
+ capabilities: {
38
+ hover: boolean;
39
+ touch: boolean;
34
40
  };
41
+ };
42
+ export interface HostContext {
43
+ theme: Theme;
44
+ locale: string;
45
+ displayMode: DisplayMode;
46
+ safeArea: SafeArea;
47
+ maxHeight: number | undefined;
48
+ userAgent: UserAgent;
35
49
  toolInput: Record<string, unknown> | null;
36
50
  toolOutput: Record<string, unknown> | null;
37
51
  toolResponseMetadata: Record<string, unknown> | null;
52
+ view: {
53
+ mode: DisplayMode;
54
+ params?: Record<string, unknown>;
55
+ };
56
+ widgetState: Record<string, unknown> | null;
38
57
  }
39
58
  export type Subscribe = Parameters<typeof useSyncExternalStore>[0];
40
59
  export interface Bridge<Context> {
@@ -42,16 +61,38 @@ export interface Bridge<Context> {
42
61
  subscribe(keys: readonly (keyof Context)[]): Subscribe;
43
62
  getSnapshot<K extends keyof Context>(key: K): Context[K] | undefined;
44
63
  }
45
- export type ExternalStore<K extends keyof BridgeInterface> = {
64
+ export type HostContextStore<K extends keyof HostContext> = {
46
65
  subscribe: Subscribe;
47
- getSnapshot: () => BridgeInterface[K];
66
+ getSnapshot: () => HostContext[K];
67
+ };
68
+ export type WidgetState = Record<string, unknown>;
69
+ export type SetWidgetStateAction = WidgetState | ((prevState: WidgetState | null) => WidgetState);
70
+ export type FileMetadata = {
71
+ fileId: string;
72
+ };
73
+ export type RequestModalOptions = {
74
+ title?: string;
75
+ params?: Record<string, unknown>;
76
+ anchor?: {
77
+ top?: number;
78
+ left?: number;
79
+ width?: number;
80
+ height?: number;
81
+ };
48
82
  };
49
83
  export interface Adaptor {
50
- getExternalStore<K extends keyof BridgeInterface>(key: K): ExternalStore<K>;
84
+ getHostContextStore<K extends keyof HostContext>(key: K): HostContextStore<K>;
51
85
  callTool<ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs): Promise<ToolResponse>;
52
86
  requestDisplayMode(mode: DisplayMode): Promise<{
53
87
  mode: DisplayMode;
54
88
  }>;
55
89
  sendFollowUpMessage(prompt: string): Promise<void>;
56
90
  openExternal(href: string): void;
91
+ setWidgetState(stateOrUpdater: SetWidgetStateAction): Promise<void>;
92
+ uploadFile(file: File): Promise<FileMetadata>;
93
+ getFileDownloadUrl(file: FileMetadata): Promise<{
94
+ downloadUrl: string;
95
+ }>;
96
+ openModal(options: RequestModalOptions): void;
97
+ setOpenInAppUrl(href: string): Promise<void>;
57
98
  }
@@ -0,0 +1,2 @@
1
+ import type { HostContext } from "./types.js";
2
+ export declare const useHostContext: <K extends keyof HostContext>(key: K) => HostContext[K];
@@ -0,0 +1,8 @@
1
+ import { useSyncExternalStore } from "react";
2
+ import { getAdaptor } from "./get-adaptor.js";
3
+ export const useHostContext = (key) => {
4
+ const adaptor = getAdaptor();
5
+ const store = adaptor.getHostContextStore(key);
6
+ return useSyncExternalStore(store.subscribe, store.getSnapshot);
7
+ };
8
+ //# sourceMappingURL=use-host-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-host-context.js","sourceRoot":"","sources":["../../../src/web/bridges/use-host-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,GAAM,EACU,EAAE;IAClB,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAE/C,OAAO,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;AAClE,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type ReactNode } from "react";
2
+ export declare function ModalProvider({ children }: {
3
+ children: ReactNode;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useSyncExternalStore } from "react";
3
+ import { McpAppAdaptor } from "../bridges";
4
+ const modalStyles = `
5
+ .sb-modal-backdrop {
6
+ position: fixed;
7
+ inset: 0;
8
+ background: rgba(0, 0, 0, 0.5);
9
+ z-index: 9998;
10
+ }
11
+ .sb-modal-container {
12
+ border-radius: 12px;
13
+ position: fixed;
14
+ inset: 0;
15
+ margin: auto;
16
+ width: fit-content;
17
+ height: fit-content;
18
+ background: white;
19
+ z-index: 9999;
20
+ }
21
+ `;
22
+ export function ModalProvider({ children }) {
23
+ const adaptor = McpAppAdaptor.getInstance();
24
+ const { mode } = useSyncExternalStore(adaptor.getHostContextStore("view").subscribe, adaptor.getHostContextStore("view").getSnapshot);
25
+ const isOpen = mode === "modal";
26
+ const handleBackdropClick = (e) => {
27
+ if (e.target === e.currentTarget) {
28
+ adaptor.closeModal();
29
+ }
30
+ };
31
+ useEffect(() => {
32
+ if (!isOpen) {
33
+ return;
34
+ }
35
+ const handler = (e) => {
36
+ if (e.key === "Escape") {
37
+ adaptor.closeModal();
38
+ }
39
+ };
40
+ document.addEventListener("keydown", handler);
41
+ return () => document.removeEventListener("keydown", handler);
42
+ }, [isOpen, adaptor]);
43
+ return (_jsxs(_Fragment, { children: [_jsx("style", { children: modalStyles }), isOpen && (
44
+ // biome-ignore lint/a11y/useKeyWithClickEvents: backdrop isn't focusable
45
+ _jsx("div", { role: "dialog", className: "sb-modal-backdrop", onClick: handleBackdropClick })), _jsx("div", { className: isOpen ? "sb-modal-container" : undefined, children: children })] }));
46
+ }
47
+ //# sourceMappingURL=modal-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-provider.js","sourceRoot":"","sources":["../../../src/web/components/modal-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,SAAS,EAAE,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S,EAAC,mBAAmB,EAC7B,OAAO,EAAE,mBAAmB,GAC5B,CACH,EACD,cAAK,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,YACtD,QAAQ,GACL,IACL,CACJ,CAAC;AACJ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { create } from "zustand";
2
+ import { getAdaptor } from "./bridges/index.js";
2
3
  import { getInitialState, injectWidgetContext, serializeState, } from "./helpers/state.js";
3
4
  export function createStore(storeCreator, defaultState) {
4
5
  const initialState = getInitialState(defaultState);
@@ -10,13 +11,11 @@ export function createStore(storeCreator, defaultState) {
10
11
  return baseStore;
11
12
  });
12
13
  store.subscribe((state) => {
13
- if (window.openai) {
14
- const serializedState = serializeState(state);
15
- if (serializedState !== null && serializedState !== undefined) {
16
- const stateToPersist = injectWidgetContext(serializedState);
17
- if (stateToPersist !== null) {
18
- window.openai.setWidgetState(stateToPersist);
19
- }
14
+ const serializedState = serializeState(state);
15
+ if (serializedState !== null && serializedState !== undefined) {
16
+ const stateToPersist = injectWidgetContext(serializedState);
17
+ if (stateToPersist !== null) {
18
+ getAdaptor().setWidgetState(stateToPersist);
20
19
  }
21
20
  }
22
21
  });
@@ -1 +1 @@
1
- {"version":3,"file":"create-store.js","sourceRoot":"","sources":["../../src/web/create-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,MAAM,UAAU,WAAW,CACzB,YAAgD,EAChD,YAAoC;IAEpC,MAAM,YAAY,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;IAEnD,MAAM,KAAK,GAAG,MAAM,EAAS,CAC3B,CAAC,GAAG,IAAoD,EAAE,EAAE;QAC1D,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;QAExC,IAAI,YAAY,KAAK,I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