skybridge 0.0.0-dev.dfcfcc3 → 0.0.0-dev.e0ed208

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 (194) hide show
  1. package/dist/src/server/devtoolsStaticServer.d.ts +15 -0
  2. package/dist/src/server/devtoolsStaticServer.js +38 -0
  3. package/dist/src/server/devtoolsStaticServer.js.map +1 -0
  4. package/dist/src/server/index.d.ts +3 -0
  5. package/dist/src/server/index.js +1 -0
  6. package/dist/src/server/index.js.map +1 -1
  7. package/dist/src/server/inferUtilityTypes.d.ts +64 -0
  8. package/dist/src/server/inferUtilityTypes.js +2 -0
  9. package/dist/src/server/inferUtilityTypes.js.map +1 -0
  10. package/dist/src/server/server.d.ts +71 -9
  11. package/dist/src/server/server.js +65 -28
  12. package/dist/src/server/server.js.map +1 -1
  13. package/dist/src/server/templateHelper.d.ts +12 -8
  14. package/dist/src/server/templateHelper.js +5 -12
  15. package/dist/src/server/templateHelper.js.map +1 -1
  16. package/dist/src/server/templates/development.hbs +3 -2
  17. package/dist/src/server/templates/production.hbs +4 -3
  18. package/dist/src/server/widgetsDevServer.js +3 -3
  19. package/dist/src/server/widgetsDevServer.js.map +1 -1
  20. package/dist/src/test/utils.d.ts +108 -1
  21. package/dist/src/test/utils.js +202 -3
  22. package/dist/src/test/utils.js.map +1 -1
  23. package/dist/src/test/widget.test.js +102 -25
  24. package/dist/src/test/widget.test.js.map +1 -1
  25. package/dist/src/web/bridges/apps-sdk-adapter.d.ts +4 -0
  26. package/dist/src/web/bridges/apps-sdk-adapter.js +10 -0
  27. package/dist/src/web/bridges/apps-sdk-adapter.js.map +1 -0
  28. package/dist/src/web/bridges/apps-sdk-bridge.d.ts +8 -0
  29. package/dist/src/web/bridges/apps-sdk-bridge.js +41 -0
  30. package/dist/src/web/bridges/apps-sdk-bridge.js.map +1 -0
  31. package/dist/src/web/bridges/get-bridge-methods.d.ts +2 -0
  32. package/dist/src/web/bridges/get-bridge-methods.js +8 -0
  33. package/dist/src/web/bridges/get-bridge-methods.js.map +1 -0
  34. package/dist/src/web/bridges/hooks/types.d.ts +6 -0
  35. package/dist/src/web/bridges/hooks/types.js +2 -0
  36. package/dist/src/web/bridges/hooks/types.js.map +1 -0
  37. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.d.ts +2 -0
  38. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js +7 -0
  39. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js.map +1 -0
  40. package/dist/src/web/bridges/hooks/use-bridge.d.ts +2 -0
  41. package/dist/src/web/bridges/hooks/use-bridge.js +19 -0
  42. package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -0
  43. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +4 -0
  44. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js +7 -0
  45. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -0
  46. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +58 -0
  47. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -0
  48. package/dist/src/web/bridges/index.d.ts +4 -0
  49. package/dist/src/web/bridges/index.js +5 -0
  50. package/dist/src/web/bridges/index.js.map +1 -0
  51. package/dist/src/web/bridges/mcp-app-adapter.d.ts +6 -0
  52. package/dist/src/web/bridges/mcp-app-adapter.js +81 -0
  53. package/dist/src/web/bridges/mcp-app-adapter.js.map +1 -0
  54. package/dist/src/web/bridges/mcp-app-bridge.d.ts +39 -0
  55. package/dist/src/web/bridges/mcp-app-bridge.js +166 -0
  56. package/dist/src/web/bridges/mcp-app-bridge.js.map +1 -0
  57. package/dist/src/web/bridges/types.d.ts +46 -0
  58. package/dist/src/web/bridges/types.js +2 -0
  59. package/dist/src/web/bridges/types.js.map +1 -0
  60. package/dist/src/web/create-store.d.ts +3 -0
  61. package/dist/src/web/create-store.js +25 -0
  62. package/dist/src/web/create-store.js.map +1 -0
  63. package/dist/src/web/create-store.test.d.ts +1 -0
  64. package/dist/src/web/create-store.test.js +70 -0
  65. package/dist/src/web/create-store.test.js.map +1 -0
  66. package/dist/src/web/data-llm.d.ts +14 -0
  67. package/dist/src/web/data-llm.js +68 -0
  68. package/dist/src/web/data-llm.js.map +1 -0
  69. package/dist/src/web/data-llm.test.d.ts +1 -0
  70. package/dist/src/web/data-llm.test.js +76 -0
  71. package/dist/src/web/data-llm.test.js.map +1 -0
  72. package/dist/src/web/generate-helpers.d.ts +115 -0
  73. package/dist/src/web/generate-helpers.js +111 -0
  74. package/dist/src/web/generate-helpers.js.map +1 -0
  75. package/dist/src/web/generate-helpers.test-d.d.ts +1 -0
  76. package/dist/src/web/generate-helpers.test-d.js +206 -0
  77. package/dist/src/web/generate-helpers.test-d.js.map +1 -0
  78. package/dist/src/web/generate-helpers.test.d.ts +1 -0
  79. package/dist/src/web/generate-helpers.test.js +17 -0
  80. package/dist/src/web/generate-helpers.test.js.map +1 -0
  81. package/dist/src/web/helpers/state.d.ts +7 -0
  82. package/dist/src/web/helpers/state.js +40 -0
  83. package/dist/src/web/helpers/state.js.map +1 -0
  84. package/dist/src/web/helpers/state.test.d.ts +1 -0
  85. package/dist/src/web/helpers/state.test.js +53 -0
  86. package/dist/src/web/helpers/state.test.js.map +1 -0
  87. package/dist/src/web/hooks/index.d.ts +11 -0
  88. package/dist/src/web/hooks/index.js +12 -0
  89. package/dist/src/web/hooks/index.js.map +1 -0
  90. package/dist/src/web/hooks/use-call-tool.d.ts +100 -0
  91. package/dist/src/web/hooks/use-call-tool.js +62 -0
  92. package/dist/src/web/hooks/use-call-tool.js.map +1 -0
  93. package/dist/src/web/hooks/use-call-tool.test-d.d.ts +1 -0
  94. package/dist/src/web/hooks/use-call-tool.test-d.js +104 -0
  95. package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -0
  96. package/dist/src/web/hooks/use-call-tool.test.d.ts +1 -0
  97. package/dist/src/web/hooks/use-call-tool.test.js +168 -0
  98. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -0
  99. package/dist/src/web/hooks/use-display-mode.d.ts +4 -0
  100. package/dist/src/web/hooks/use-display-mode.js +10 -0
  101. package/dist/src/web/hooks/use-display-mode.js.map +1 -0
  102. package/dist/src/web/hooks/use-display-mode.test.d.ts +1 -0
  103. package/dist/src/web/hooks/use-display-mode.test.js +41 -0
  104. package/dist/src/web/hooks/use-display-mode.test.js.map +1 -0
  105. package/dist/src/web/hooks/use-files.d.ts +10 -0
  106. package/dist/src/web/hooks/use-files.js +7 -0
  107. package/dist/src/web/hooks/use-files.js.map +1 -0
  108. package/dist/src/web/hooks/use-files.test.d.ts +1 -0
  109. package/dist/src/web/hooks/use-files.test.js +29 -0
  110. package/dist/src/web/hooks/use-files.test.js.map +1 -0
  111. package/dist/src/web/hooks/use-layout.d.ts +22 -0
  112. package/dist/src/web/hooks/use-layout.js +23 -0
  113. package/dist/src/web/hooks/use-layout.js.map +1 -0
  114. package/dist/src/web/hooks/use-layout.test.d.ts +1 -0
  115. package/dist/src/web/hooks/use-layout.test.js +46 -0
  116. package/dist/src/web/hooks/use-layout.test.js.map +1 -0
  117. package/dist/src/web/hooks/use-open-external.d.ts +1 -0
  118. package/dist/src/web/hooks/use-open-external.js +6 -0
  119. package/dist/src/web/hooks/use-open-external.js.map +1 -0
  120. package/dist/src/web/hooks/use-open-external.test.d.ts +1 -0
  121. package/dist/src/web/hooks/use-open-external.test.js +24 -0
  122. package/dist/src/web/hooks/use-open-external.test.js.map +1 -0
  123. package/dist/src/web/hooks/use-openai-global.d.ts +3 -0
  124. package/dist/src/web/hooks/use-openai-global.js +6 -0
  125. package/dist/src/web/hooks/use-openai-global.js.map +1 -0
  126. package/dist/src/web/hooks/use-request-modal.d.ts +9 -0
  127. package/dist/src/web/hooks/use-request-modal.js +14 -0
  128. package/dist/src/web/hooks/use-request-modal.js.map +1 -0
  129. package/dist/src/web/hooks/use-request-modal.test.d.ts +1 -0
  130. package/dist/src/web/hooks/use-request-modal.test.js +57 -0
  131. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -0
  132. package/dist/src/web/hooks/use-send-follow-up-message.d.ts +1 -0
  133. package/dist/src/web/hooks/use-send-follow-up-message.js +6 -0
  134. package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -0
  135. package/dist/src/web/hooks/use-tool-info.d.ts +25 -0
  136. package/dist/src/web/hooks/use-tool-info.js +20 -0
  137. package/dist/src/web/hooks/use-tool-info.js.map +1 -0
  138. package/dist/src/web/hooks/use-tool-info.test-d.d.ts +1 -0
  139. package/dist/src/web/hooks/use-tool-info.test-d.js +73 -0
  140. package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -0
  141. package/dist/src/web/hooks/use-tool-info.test.d.ts +1 -0
  142. package/dist/src/web/hooks/use-tool-info.test.js +162 -0
  143. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -0
  144. package/dist/src/web/hooks/use-user.d.ts +18 -0
  145. package/dist/src/web/hooks/use-user.js +19 -0
  146. package/dist/src/web/hooks/use-user.js.map +1 -0
  147. package/dist/src/web/hooks/use-user.test.d.ts +1 -0
  148. package/dist/src/web/hooks/use-user.test.js +44 -0
  149. package/dist/src/web/hooks/use-user.test.js.map +1 -0
  150. package/dist/src/web/hooks/use-widget-state.d.ts +4 -0
  151. package/dist/src/web/hooks/use-widget-state.js +32 -0
  152. package/dist/src/web/hooks/use-widget-state.js.map +1 -0
  153. package/dist/src/web/hooks/use-widget-state.test.d.ts +1 -0
  154. package/dist/src/web/hooks/use-widget-state.test.js +61 -0
  155. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -0
  156. package/dist/src/web/index.d.ts +7 -4
  157. package/dist/src/web/index.js +7 -4
  158. package/dist/src/web/index.js.map +1 -1
  159. package/dist/src/web/mount-widget.js +5 -0
  160. package/dist/src/web/mount-widget.js.map +1 -1
  161. package/dist/src/web/plugin/data-llm.test.d.ts +1 -0
  162. package/dist/src/web/plugin/data-llm.test.js +81 -0
  163. package/dist/src/web/plugin/data-llm.test.js.map +1 -0
  164. package/dist/src/web/plugin/plugin.js +39 -0
  165. package/dist/src/web/plugin/plugin.js.map +1 -0
  166. package/dist/src/web/plugin/transform-data-llm.d.ts +12 -0
  167. package/dist/src/web/plugin/transform-data-llm.js +93 -0
  168. package/dist/src/web/plugin/transform-data-llm.js.map +1 -0
  169. package/dist/src/web/plugin/transform-data-llm.test.d.ts +1 -0
  170. package/dist/src/web/plugin/transform-data-llm.test.js +81 -0
  171. package/dist/src/web/plugin/transform-data-llm.test.js.map +1 -0
  172. package/dist/src/web/proxy.d.ts +1 -0
  173. package/dist/src/web/proxy.js +53 -0
  174. package/dist/src/web/proxy.js.map +1 -0
  175. package/dist/src/web/types.d.ts +73 -19
  176. package/dist/src/web/types.js +1 -0
  177. package/dist/src/web/types.js.map +1 -1
  178. package/dist/vitest.config.js +0 -1
  179. package/dist/vitest.config.js.map +1 -1
  180. package/package.json +22 -5
  181. package/LICENSE +0 -674
  182. package/README.md +0 -126
  183. package/dist/src/test/setup.js +0 -9
  184. package/dist/src/test/setup.js.map +0 -1
  185. package/dist/src/web/plugin.js +0 -31
  186. package/dist/src/web/plugin.js.map +0 -1
  187. package/dist/src/web/use-openai-global.d.ts +0 -2
  188. package/dist/src/web/use-openai-global.js +0 -21
  189. package/dist/src/web/use-openai-global.js.map +0 -1
  190. package/dist/src/web/use-tool-output.d.ts +0 -3
  191. package/dist/src/web/use-tool-output.js +0 -5
  192. package/dist/src/web/use-tool-output.js.map +0 -1
  193. /package/dist/src/{test/setup.d.ts → web/bridges/hooks/use-mcp-app-bridge.test.d.ts} +0 -0
  194. /package/dist/src/web/{plugin.d.ts → plugin/plugin.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-files.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-files.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ;IACtB,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;QAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY;KACrC,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ import { renderHook } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { useFiles } from "./use-files.js";
4
+ describe("useLocale", () => {
5
+ const OpenaiMock = {
6
+ uploadFile: vi.fn(),
7
+ downloadFile: vi.fn(),
8
+ };
9
+ beforeEach(() => {
10
+ vi.stubGlobal("openai", OpenaiMock);
11
+ });
12
+ afterEach(() => {
13
+ vi.unstubAllGlobals();
14
+ vi.resetAllMocks();
15
+ });
16
+ const dummyFile = new File([], "test.txt");
17
+ it("should upload a file to ChatGPT", () => {
18
+ const { result } = renderHook(() => useFiles());
19
+ result.current.upload(dummyFile);
20
+ expect(OpenaiMock.uploadFile).toHaveBeenCalledWith(dummyFile);
21
+ });
22
+ it("should download a file from ChatGPT", () => {
23
+ const fileId = "123";
24
+ const { result } = renderHook(() => useFiles());
25
+ result.current.download({ fileId });
26
+ expect(OpenaiMock.downloadFile).toHaveBeenCalledWith({ fileId });
27
+ });
28
+ });
29
+ //# sourceMappingURL=use-files.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-files.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-files.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,UAAU,GAAG;QACjB,UAAU,EAAE,EAAE,CAAC,EAAE,EAAE;QACnB,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE;KACtB,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IAE3C,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEhD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACjC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,MAAM,GAAG,KAAK,CAAC;QACrB,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEhD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACpC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { SafeArea, Theme } from "../types.js";
2
+ export type LayoutState = {
3
+ theme: Theme;
4
+ maxHeight: number;
5
+ safeArea: SafeArea;
6
+ };
7
+ /**
8
+ * Hook for accessing layout and visual environment information.
9
+ * These values may change on resize or theme toggle.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * const { theme, maxHeight, safeArea } = useLayout();
14
+ *
15
+ * // Apply theme-aware styling
16
+ * const backgroundColor = theme === "dark" ? "#1a1a1a" : "#ffffff";
17
+ *
18
+ * // Respect safe area insets
19
+ * const paddingTop = safeArea.insets.top;
20
+ * ```
21
+ */
22
+ export declare function useLayout(): LayoutState;
@@ -0,0 +1,23 @@
1
+ import { useBridge } from "../bridges/index.js";
2
+ /**
3
+ * Hook for accessing layout and visual environment information.
4
+ * These values may change on resize or theme toggle.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * const { theme, maxHeight, safeArea } = useLayout();
9
+ *
10
+ * // Apply theme-aware styling
11
+ * const backgroundColor = theme === "dark" ? "#1a1a1a" : "#ffffff";
12
+ *
13
+ * // Respect safe area insets
14
+ * const paddingTop = safeArea.insets.top;
15
+ * ```
16
+ */
17
+ export function useLayout() {
18
+ const theme = useBridge("theme");
19
+ const maxHeight = useBridge("maxHeight");
20
+ const safeArea = useBridge("safeArea");
21
+ return { theme, maxHeight, safeArea };
22
+ }
23
+ //# sourceMappingURL=use-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-layout.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAShD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAEvC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ import { renderHook } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { useLayout } from "./use-layout.js";
4
+ describe("useLayout", () => {
5
+ let OpenaiMock;
6
+ beforeEach(() => {
7
+ OpenaiMock = {
8
+ theme: "light",
9
+ maxHeight: 500,
10
+ safeArea: { insets: { top: 0, bottom: 0, left: 0, right: 0 } },
11
+ };
12
+ vi.stubGlobal("openai", OpenaiMock);
13
+ vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
14
+ });
15
+ afterEach(() => {
16
+ vi.unstubAllGlobals();
17
+ vi.resetAllMocks();
18
+ });
19
+ it("should return theme, maxHeight, and safeArea from window.openai", () => {
20
+ const { result } = renderHook(() => useLayout());
21
+ expect(result.current.theme).toBe("light");
22
+ expect(result.current.maxHeight).toBe(500);
23
+ expect(result.current.safeArea).toEqual({
24
+ insets: { top: 0, bottom: 0, left: 0, right: 0 },
25
+ });
26
+ });
27
+ it("should return dark theme when set to dark", () => {
28
+ OpenaiMock.theme = "dark";
29
+ const { result } = renderHook(() => useLayout());
30
+ expect(result.current.theme).toBe("dark");
31
+ });
32
+ it("should return different maxHeight when set", () => {
33
+ OpenaiMock.maxHeight = 800;
34
+ const { result } = renderHook(() => useLayout());
35
+ expect(result.current.maxHeight).toBe(800);
36
+ });
37
+ it("should return safeArea with insets when set", () => {
38
+ OpenaiMock.safeArea = {
39
+ insets: { top: 44, bottom: 34, left: 0, right: 0 },
40
+ };
41
+ const { result } = renderHook(() => useLayout());
42
+ expect(result.current.safeArea.insets.top).toBe(44);
43
+ expect(result.current.safeArea.insets.bottom).toBe(34);
44
+ });
45
+ });
46
+ //# sourceMappingURL=use-layout.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-layout.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-layout.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEzE,OAAO,EAAE,SAAS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
3
+ window.openai.openExternal({ href });
4
+ };
5
+ }
6
+ //# sourceMappingURL=use-open-external.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-open-external.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-open-external.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,IAAY,EAAE,EAAE;QACtB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { renderHook } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { useOpenExternal } from "./use-open-external.js";
4
+ describe("useOpenExternal", () => {
5
+ let openExternalMock;
6
+ beforeEach(() => {
7
+ openExternalMock = vi.fn();
8
+ vi.stubGlobal("openai", {
9
+ openExternal: openExternalMock,
10
+ });
11
+ });
12
+ afterEach(() => {
13
+ vi.unstubAllGlobals();
14
+ vi.resetAllMocks();
15
+ });
16
+ it("should return a function that calls window.openai.openExternal with the href", () => {
17
+ const { result } = renderHook(() => useOpenExternal());
18
+ const href = "https://example.com";
19
+ result.current(href);
20
+ expect(openExternalMock).toHaveBeenCalledTimes(1);
21
+ expect(openExternalMock).toHaveBeenCalledWith({ href });
22
+ });
23
+ });
24
+ //# sourceMappingURL=use-open-external.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-open-external.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-open-external.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,gBAA0C,CAAC;IAE/C,UAAU,CAAC,GAAG,EAAE;QACd,gBAAgB,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtB,YAAY,EAAE,gBAAgB;SAC/B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8EAA8E,EAAE,GAAG,EAAE;QACtF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QAEvD,MAAM,IAAI,GAAG,qBAAqB,CAAC;QACnC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAErB,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { OpenAiProperties } from "../types.js";
2
+ /** @deprecated Use `useAppsSdkBridge` instead */
3
+ export declare function useOpenAiGlobal<K extends keyof OpenAiProperties>(key: K): OpenAiProperties[K];
@@ -0,0 +1,6 @@
1
+ import { useAppsSdkBridge } from "../bridges/index.js";
2
+ /** @deprecated Use `useAppsSdkBridge` instead */
3
+ export function useOpenAiGlobal(key) {
4
+ return useAppsSdkBridge(key);
5
+ }
6
+ //# sourceMappingURL=use-openai-global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-openai-global.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-openai-global.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,iDAAiD;AACjD,MAAM,UAAU,eAAe,CAC7B,GAAM;IAEN,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { RequestModalOptions } from "../types.js";
2
+ /**
3
+ * Triggers a modal containing the widget rendered in display mode "modal"
4
+ */
5
+ export declare function useRequestModal(): {
6
+ isOpen: boolean;
7
+ open: (options: RequestModalOptions) => void;
8
+ params: Record<string, unknown> | undefined;
9
+ };
@@ -0,0 +1,14 @@
1
+ import { useAppsSdkBridge } from "../bridges/hooks/use-apps-sdk-bridge.js";
2
+ /**
3
+ * Triggers a modal containing the widget rendered in display mode "modal"
4
+ */
5
+ export function useRequestModal() {
6
+ const view = useAppsSdkBridge("view");
7
+ const isOpen = view?.mode === "modal";
8
+ const params = view?.params;
9
+ const open = (options) => {
10
+ window.openai.requestModal(options);
11
+ };
12
+ return { isOpen, open, params };
13
+ }
14
+ //# sourceMappingURL=use-request-modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-request-modal.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-request-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACtC,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC;IAE5B,MAAM,IAAI,GAAG,CAAC,OAA4B,EAAE,EAAE;QAC5C,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,57 @@
1
+ import { renderHook } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { useRequestModal } from "./use-request-modal.js";
4
+ describe("useRequestModal", () => {
5
+ let requestModalMock;
6
+ beforeEach(() => {
7
+ requestModalMock = vi.fn();
8
+ vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
9
+ vi.stubGlobal("openai", {
10
+ requestModal: requestModalMock,
11
+ view: { mode: "inline" },
12
+ });
13
+ });
14
+ afterEach(() => {
15
+ vi.unstubAllGlobals();
16
+ vi.resetAllMocks();
17
+ });
18
+ it("should return an object with open, isOpen, and params properties where isOpen is false when mode is not modal", () => {
19
+ const { result } = renderHook(() => useRequestModal());
20
+ expect(typeof result.current).toBe("object");
21
+ expect(result.current).toHaveProperty("open");
22
+ expect(result.current).toHaveProperty("isOpen");
23
+ expect(result.current).toHaveProperty("params");
24
+ const { open, isOpen, params } = result.current;
25
+ expect(typeof open).toBe("function");
26
+ expect(isOpen).toBe(false);
27
+ expect(params).toBeUndefined();
28
+ });
29
+ it("should return isOpen as true when mode is modal", () => {
30
+ vi.stubGlobal("openai", {
31
+ requestModal: requestModalMock,
32
+ view: { mode: "modal" },
33
+ });
34
+ const { result } = renderHook(() => useRequestModal());
35
+ const { isOpen } = result.current;
36
+ expect(isOpen).toBe(true);
37
+ });
38
+ it("should return params from view when available", () => {
39
+ const testParams = { foo: "bar", baz: 42 };
40
+ vi.stubGlobal("openai", {
41
+ requestModal: requestModalMock,
42
+ view: { mode: "modal", params: testParams },
43
+ });
44
+ const { result } = renderHook(() => useRequestModal());
45
+ const { params } = result.current;
46
+ expect(params).toEqual(testParams);
47
+ });
48
+ it("should call window.openai.requestModal with the options when open is called", () => {
49
+ const { result } = renderHook(() => useRequestModal());
50
+ const { open } = result.current;
51
+ const options = { title: "Test Modal" };
52
+ open(options);
53
+ expect(requestModalMock).toHaveBeenCalledTimes(1);
54
+ expect(requestModalMock).toHaveBeenCalledWith(options);
55
+ });
56
+ });
57
+ //# sourceMappingURL=use-request-modal.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-request-modal.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-request-modal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,gBAA0C,CAAC;IAE/C,UAAU,CAAC,GAAG,EAAE;QACd,gBAAgB,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;QACrD,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtB,YAAY,EAAE,gBAAgB;YAC9B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+GAA+G,EAAE,GAAG,EAAE;QACvH,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QAEvD,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,CAA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e,EAAE,CAAC,CAAC;QACvD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;QAElC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACrF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QACvD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;QAEhC,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEd,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useSendFollowUpMessage(): (prompt: string) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ import { getBridgeMethods } from "../bridges/index.js";
2
+ export function useSendFollowUpMessage() {
3
+ const { sendFollowUpMessage } = getBridgeMethods();
4
+ return sendFollowUpMessage;
5
+ }
6
+ //# sourceMappingURL=use-send-follow-up-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-send-follow-up-message.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-send-follow-up-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,UAAU,sBAAsB;IACpC,MAAM,EAAE,mBAAmB,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEnD,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { UnknownObject } from "../types.js";
2
+ export type ToolPendingState<ToolInput extends UnknownObject> = {
3
+ status: "pending";
4
+ isPending: true;
5
+ isSuccess: false;
6
+ input: ToolInput;
7
+ output: undefined;
8
+ responseMetadata: undefined;
9
+ };
10
+ export type ToolSuccessState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = {
11
+ status: "success";
12
+ isPending: false;
13
+ isSuccess: true;
14
+ input: ToolInput;
15
+ output: ToolOutput;
16
+ responseMetadata: ToolResponseMetadata;
17
+ };
18
+ export type ToolState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = ToolPendingState<ToolInput> | ToolSuccessState<ToolInput, ToolOutput, ToolResponseMetadata>;
19
+ type ToolSignature = {
20
+ input: UnknownObject;
21
+ output: UnknownObject;
22
+ responseMetadata: UnknownObject;
23
+ };
24
+ export declare function useToolInfo<TS extends Partial<ToolSignature> = Record<string, never>>(): ToolState<UnknownObject & TS["input"], UnknownObject & TS["output"], UnknownObject & TS["responseMetadata"]>;
25
+ export {};
@@ -0,0 +1,20 @@
1
+ import { useEffect, useState } from "react";
2
+ import { useBridge } from "../bridges/index.js";
3
+ export function useToolInfo() {
4
+ const [status, setStatus] = useState("pending");
5
+ const input = useBridge("toolInput");
6
+ const output = useBridge("toolOutput");
7
+ const responseMetadata = useBridge("toolResponseMetadata");
8
+ useEffect(() => {
9
+ setStatus(output === null && responseMetadata === null ? "pending" : "success");
10
+ }, [output, responseMetadata]);
11
+ return {
12
+ input,
13
+ status,
14
+ isPending: status === "pending",
15
+ isSuccess: status === "success",
16
+ output,
17
+ responseMetadata,
18
+ };
19
+ }
20
+ //# sourceMappingURL=use-tool-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tool-info.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-tool-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAuChD,MAAM,UAAU,WAAW;IAGzB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAwB,SAAS,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;IACvC,MAAM,gBAAgB,GAAG,SAAS,CAAC,sBAAsB,CAAC,CAAC;IAE3D,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CACP,MAAM,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CACrE,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAM/B,OAAO;QACL,KAAK;QACL,MAAM;QACN,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,MAAM;QACN,gBAAgB;KACqB,CAAC;AAC1C,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,73 @@
1
+ import { expectTypeOf, test } from "vitest";
2
+ import { useToolInfo } from "./use-tool-info.js";
3
+ test("useToolInfo - TypeScript typing", () => {
4
+ test("should have correct types when no generic parameter is provided", () => {
5
+ const result = useToolInfo();
6
+ expectTypeOf(result.status);
7
+ expectTypeOf(result.isPending);
8
+ expectTypeOf(result.isSuccess);
9
+ expectTypeOf(result.input);
10
+ });
11
+ test("should correctly type input, output, and responseMetadata with explicit ToolSignature", () => {
12
+ const result = useToolInfo();
13
+ expectTypeOf(result.input);
14
+ // When pending, output and responseMetadata should be undefined
15
+ if (result.status === "pending") {
16
+ expectTypeOf(result.output);
17
+ expectTypeOf(result.responseMetadata);
18
+ }
19
+ // When success, output and responseMetadata should be defined
20
+ if (result.status === "success") {
21
+ expectTypeOf(result.output);
22
+ expectTypeOf(result.responseMetadata);
23
+ }
24
+ });
25
+ test("should correctly narrow types based on status discriminated union", () => {
26
+ const result = useToolInfo();
27
+ // Test type narrowing
28
+ if (result.isPending) {
29
+ expectTypeOf(result.status);
30
+ expectTypeOf(result.isPending);
31
+ expectTypeOf(result.isSuccess);
32
+ expectTypeOf(result.output);
33
+ expectTypeOf(result.responseMetadata);
34
+ }
35
+ if (result.isSuccess) {
36
+ expectTypeOf(result.status);
37
+ expectTypeOf(result.isPending);
38
+ expectTypeOf(result.isSuccess);
39
+ expectTypeOf(result.output);
40
+ expectTypeOf(result.responseMetadata);
41
+ }
42
+ if (result.status === "pending") {
43
+ expectTypeOf(result.input);
44
+ expectTypeOf(result.isPending);
45
+ expectTypeOf(result.isSuccess);
46
+ expectTypeOf(result.output);
47
+ expectTypeOf(result.responseMetadata);
48
+ }
49
+ if (result.status === "success") {
50
+ expectTypeOf(result.input);
51
+ expectTypeOf(result.isPending);
52
+ expectTypeOf(result.isSuccess);
53
+ expectTypeOf(result.output);
54
+ expectTypeOf(result.responseMetadata);
55
+ }
56
+ });
57
+ test("should handle partial ToolSignature with only input specified", () => {
58
+ const result = useToolInfo();
59
+ expectTypeOf(result.input);
60
+ if (result.status === "success") {
61
+ expectTypeOf(result.output);
62
+ expectTypeOf(result.responseMetadata);
63
+ }
64
+ });
65
+ test("should handle ToolSignature with only output specified", () => {
66
+ const result = useToolInfo();
67
+ expectTypeOf(result.input);
68
+ if (result.status === "success") {
69
+ expectTypeOf(result.output);
70
+ }
71
+ });
72
+ });
73
+ //# sourceMappingURL=use-tool-info.test-d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tool-info.test-d.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-tool-info.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,IAAI,CAAC,iCAAiC,EAAE,G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,CAAC;QACjE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAGlE,MAAM,MAAM,GAAG,WAAW,EAEtB,CAAC;QAEL,YAAY,CAA0B,MAAM,CAAC,KAAK,CAAC,CAAC;QAEpD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAAa,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,162 @@
1
+ import { act, fireEvent, renderHook, waitFor } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { McpAppBridge } from "../bridges/mcp-app-bridge.js";
4
+ import { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, } from "../types.js";
5
+ import { useToolInfo } from "./use-tool-info.js";
6
+ describe("useToolInfo", () => {
7
+ describe("apps-sdk host", () => {
8
+ let OpenaiMock;
9
+ beforeEach(() => {
10
+ OpenaiMock = {
11
+ toolInput: { name: "pokemon", args: { name: "pikachu" } },
12
+ toolOutput: null,
13
+ toolResponseMetadata: null,
14
+ };
15
+ vi.stubGlobal("openai", OpenaiMock);
16
+ vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
17
+ });
18
+ afterEach(() => {
19
+ vi.unstubAllGlobals();
20
+ vi.resetAllMocks();
21
+ });
22
+ it("should return toolInput on initial mount window.openai", () => {
23
+ const { result } = renderHook(() => useToolInfo());
24
+ expect(result.current).toMatchObject({
25
+ input: { name: "pokemon", args: { name: "pikachu" } },
26
+ status: "pending",
27
+ isPending: true,
28
+ isSuccess: false,
29
+ });
30
+ });
31
+ it("should eventually return tool output and response metadata once tool call completes", async () => {
32
+ const toolOutput = {
33
+ name: "pikachu",
34
+ color: "yellow",
35
+ description: "When several of these POKéMON gather, their\felectricity could build and cause lightning storms.",
36
+ };
37
+ const toolResponseMetadata = { id: 12 };
38
+ const { result } = renderHook(() => useToolInfo());
39
+ act(() => {
40
+ OpenaiMock.toolOutput = toolOutput;
41
+ OpenaiMock.toolResponseMetadata = toolResponseMetadata;
42
+ fireEvent(window, new SetGlobalsEvent(SET_GLOBALS_EVENT_TYPE, {
43
+ detail: {
44
+ globals: {
45
+ toolOutput,
46
+ toolResponseMetadata,
47
+ },
48
+ },
49
+ }));
50
+ });
51
+ await waitFor(() => {
52
+ expect(result.current).toMatchObject({
53
+ status: "success",
54
+ isPending: false,
55
+ isSuccess: true,
56
+ output: toolOutput,
57
+ responseMetadata: toolResponseMetadata,
58
+ });
59
+ });
60
+ });
61
+ });
62
+ describe("mcp-app host", () => {
63
+ let mockPostMessage;
64
+ beforeEach(() => {
65
+ mockPostMessage = vi.fn();
66
+ Object.defineProperty(window, "parent", {
67
+ value: { postMessage: mockPostMessage },
68
+ writable: true,
69
+ configurable: true,
70
+ });
71
+ vi.stubGlobal("skybridge", { hostType: "mcp-app" });
72
+ McpAppBridge.resetInstance();
73
+ });
74
+ afterEach(() => {
75
+ vi.unstubAllGlobals();
76
+ vi.resetAllMocks();
77
+ });
78
+ const initializeBridge = () => {
79
+ const initCall = mockPostMessage.mock.calls.find((call) => call[0].method === "ui/initialize");
80
+ if (initCall) {
81
+ act(() => {
82
+ window.dispatchEvent(new MessageEvent("message", {
83
+ data: {
84
+ jsonrpc: "2.0",
85
+ id: initCall[0].id,
86
+ result: {
87
+ protocolVersion: "2025-11-21",
88
+ hostInfo: { name: "test-host", version: "1.0.0" },
89
+ hostCapabilities: {},
90
+ hostContext: {},
91
+ },
92
+ },
93
+ }));
94
+ });
95
+ }
96
+ };
97
+ it("should return pending state initially", async () => {
98
+ const { result } = renderHook(() => useToolInfo());
99
+ initializeBridge();
100
+ await waitFor(() => {
101
+ expect(result.current).toMatchObject({
102
+ status: "pending",
103
+ isPending: true,
104
+ isSuccess: false,
105
+ input: {},
106
+ output: null,
107
+ responseMetadata: null,
108
+ });
109
+ });
110
+ });
111
+ it("should return tool input from tool-input notification", async () => {
112
+ const { result } = renderHook(() => useToolInfo());
113
+ initializeBridge();
114
+ act(() => {
115
+ window.dispatchEvent(new MessageEvent("message", {
116
+ data: {
117
+ jsonrpc: "2.0",
118
+ method: "ui/notifications/tool-input",
119
+ params: {
120
+ arguments: { name: "pokemon", query: "pikachu" },
121
+ },
122
+ },
123
+ }));
124
+ });
125
+ await waitFor(() => {
126
+ expect(result.current).toMatchObject({
127
+ status: "pending",
128
+ isPending: true,
129
+ isSuccess: false,
130
+ input: { name: "pokemon", query: "pikachu" },
131
+ });
132
+ });
133
+ });
134
+ it("should return success state with output from tool-result notification", async () => {
135
+ const { result } = renderHook(() => useToolInfo());
136
+ initializeBridge();
137
+ act(() => {
138
+ window.dispatchEvent(new MessageEvent("message", {
139
+ data: {
140
+ jsonrpc: "2.0",
141
+ method: "ui/notifications/tool-result",
142
+ params: {
143
+ content: [{ type: "text", text: "Pikachu data" }],
144
+ structuredContent: { name: "pikachu", color: "yellow" },
145
+ _meta: { requestId: "123" },
146
+ },
147
+ },
148
+ }));
149
+ });
150
+ await waitFor(() => {
151
+ expect(result.current).toMatchObject({
152
+ status: "success",
153
+ isPending: false,
154
+ isSuccess: true,
155
+ output: { name: "pikachu", color: "yellow" },
156
+ responseMetadata: { requestId: "123" },
157
+ });
158
+ });
159
+ });
160
+ });
161
+ });
162
+ //# sourceMappingURL=use-tool-info.test.js.map