skybridge 0.0.0-dev.ea1eaa2 → 0.0.0-dev.eac9740

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 (104) hide show
  1. package/README.md +196 -1
  2. package/dist/src/server/index.d.ts +0 -1
  3. package/dist/src/server/index.js +0 -1
  4. package/dist/src/server/index.js.map +1 -1
  5. package/dist/src/server/server.d.ts +1 -0
  6. package/dist/src/server/server.js +18 -10
  7. package/dist/src/server/server.js.map +1 -1
  8. package/dist/src/server/templateHelper.d.ts +9 -8
  9. package/dist/src/server/templateHelper.js +0 -8
  10. package/dist/src/server/templateHelper.js.map +1 -1
  11. package/dist/src/server/templates/development.hbs +12 -0
  12. package/dist/src/server/templates/production.hbs +6 -0
  13. package/dist/src/server/widgetsDevServer.d.ts +5 -2
  14. package/dist/src/server/widgetsDevServer.js +5 -2
  15. package/dist/src/server/widgetsDevServer.js.map +1 -1
  16. package/dist/src/test/widget.test.js +24 -6
  17. package/dist/src/test/widget.test.js.map +1 -1
  18. package/dist/src/web/hooks/index.d.ts +13 -0
  19. package/dist/src/web/hooks/index.js +14 -0
  20. package/dist/src/web/hooks/index.js.map +1 -0
  21. package/dist/src/web/hooks/use-call-tool.d.ts +58 -0
  22. package/dist/src/web/hooks/use-call-tool.js +50 -0
  23. package/dist/src/web/hooks/use-call-tool.js.map +1 -0
  24. package/dist/src/web/hooks/use-call-tool.test.d.ts +1 -0
  25. package/dist/src/web/hooks/use-call-tool.test.js +104 -0
  26. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -0
  27. package/dist/src/web/hooks/use-display-mode.d.ts +4 -0
  28. package/dist/src/web/hooks/use-display-mode.js +7 -0
  29. package/dist/src/web/hooks/use-display-mode.js.map +1 -0
  30. package/dist/src/web/hooks/use-display-mode.test.d.ts +1 -0
  31. package/dist/src/web/hooks/use-display-mode.test.js +40 -0
  32. package/dist/src/web/hooks/use-display-mode.test.js.map +1 -0
  33. package/dist/src/web/hooks/use-locale.d.ts +1 -0
  34. package/dist/src/web/hooks/use-locale.js +5 -0
  35. package/dist/src/web/hooks/use-locale.js.map +1 -0
  36. package/dist/src/web/hooks/use-locale.test.d.ts +1 -0
  37. package/dist/src/web/hooks/use-locale.test.js +21 -0
  38. package/dist/src/web/hooks/use-locale.test.js.map +1 -0
  39. package/dist/src/web/hooks/use-open-external.d.ts +1 -0
  40. package/dist/src/web/hooks/use-open-external.js +6 -0
  41. package/dist/src/web/hooks/use-open-external.js.map +1 -0
  42. package/dist/src/web/hooks/use-open-external.test.d.ts +1 -0
  43. package/dist/src/web/hooks/use-open-external.test.js +24 -0
  44. package/dist/src/web/hooks/use-open-external.test.js.map +1 -0
  45. package/dist/src/web/{use-openai-global.d.ts → hooks/use-openai-global.d.ts} +1 -1
  46. package/dist/src/web/{use-openai-global.js → hooks/use-openai-global.js} +1 -1
  47. package/dist/src/web/hooks/use-openai-global.js.map +1 -0
  48. package/dist/src/web/hooks/use-request-modal.d.ts +5 -0
  49. package/dist/src/web/hooks/use-request-modal.js +9 -0
  50. package/dist/src/web/hooks/use-request-modal.js.map +1 -0
  51. package/dist/src/web/hooks/use-request-modal.test.d.ts +1 -0
  52. package/dist/src/web/hooks/use-request-modal.test.js +24 -0
  53. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -0
  54. package/dist/src/web/hooks/use-send-follow-up-message.d.ts +1 -0
  55. package/dist/src/web/hooks/use-send-follow-up-message.js +11 -0
  56. package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -0
  57. package/dist/src/web/hooks/use-theme.d.ts +1 -0
  58. package/dist/src/web/hooks/use-theme.js +5 -0
  59. package/dist/src/web/hooks/use-theme.js.map +1 -0
  60. package/dist/src/web/hooks/use-theme.test.d.ts +1 -0
  61. package/dist/src/web/hooks/use-theme.test.js +26 -0
  62. package/dist/src/web/hooks/use-theme.test.js.map +1 -0
  63. package/dist/src/web/hooks/use-tool-info.d.ts +5 -0
  64. package/dist/src/web/hooks/use-tool-info.js +9 -0
  65. package/dist/src/web/hooks/use-tool-info.js.map +1 -0
  66. package/dist/src/web/hooks/use-tool-info.test.d.ts +1 -0
  67. package/dist/src/web/hooks/use-tool-info.test.js +38 -0
  68. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -0
  69. package/dist/src/web/hooks/use-tool-output.d.ts +4 -0
  70. package/dist/src/web/hooks/use-tool-output.js +9 -0
  71. package/dist/src/web/hooks/use-tool-output.js.map +1 -0
  72. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +4 -0
  73. package/dist/src/web/hooks/use-tool-response-metadata.js +8 -0
  74. package/dist/src/web/hooks/use-tool-response-metadata.js.map +1 -0
  75. package/dist/src/web/hooks/use-user-agent.d.ts +1 -0
  76. package/dist/src/web/hooks/use-user-agent.js +5 -0
  77. package/dist/src/web/hooks/use-user-agent.js.map +1 -0
  78. package/dist/src/web/hooks/use-user-agent.test.d.ts +1 -0
  79. package/dist/src/web/hooks/use-user-agent.test.js +31 -0
  80. package/dist/src/web/hooks/use-user-agent.test.js.map +1 -0
  81. package/dist/src/web/hooks/use-widget-state.d.ts +4 -0
  82. package/dist/src/web/hooks/use-widget-state.js +30 -0
  83. package/dist/src/web/hooks/use-widget-state.js.map +1 -0
  84. package/dist/src/web/hooks/use-widget-state.test.d.ts +1 -0
  85. package/dist/src/web/hooks/use-widget-state.test.js +61 -0
  86. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -0
  87. package/dist/src/web/index.d.ts +2 -2
  88. package/dist/src/web/index.js +2 -2
  89. package/dist/src/web/index.js.map +1 -1
  90. package/dist/src/web/mount-widget.js +7 -3
  91. package/dist/src/web/mount-widget.js.map +1 -1
  92. package/dist/src/web/plugin.d.ts +2 -0
  93. package/dist/src/web/plugin.js +28 -0
  94. package/dist/src/web/plugin.js.map +1 -0
  95. package/dist/src/web/types.d.ts +17 -2
  96. package/dist/src/web/types.js.map +1 -1
  97. package/package.json +16 -12
  98. package/dist/src/server/middleware.d.ts +0 -3
  99. package/dist/src/server/middleware.js +0 -47
  100. package/dist/src/server/middleware.js.map +0 -1
  101. package/dist/src/web/use-openai-global.js.map +0 -1
  102. package/dist/src/web/use-tool-output.d.ts +0 -3
  103. package/dist/src/web/use-tool-output.js +0 -5
  104. package/dist/src/web/use-tool-output.js.map +0 -1
@@ -0,0 +1,104 @@
1
+ import { useCallTool } from "./use-call-tool.js";
2
+ import { describe, it, expect, vi, beforeEach, afterEach, } from "vitest";
3
+ import { renderHook, act, waitFor } from "@testing-library/react";
4
+ describe("useCallTool - onSuccess callback", () => {
5
+ let OpenaiMock;
6
+ beforeEach(() => {
7
+ OpenaiMock = {
8
+ callTool: vi.fn(),
9
+ };
10
+ vi.stubGlobal("openai", OpenaiMock);
11
+ });
12
+ afterEach(() => {
13
+ vi.unstubAllGlobals();
14
+ vi.resetAllMocks();
15
+ });
16
+ const toolName = "test-tool";
17
+ const args = { input: "test input" };
18
+ const data = {
19
+ content: [{ type: "text", text: "test result" }],
20
+ structuredContent: { result: "test" },
21
+ isError: false,
22
+ result: "test result",
23
+ meta: {},
24
+ };
25
+ const error = new Error("test error");
26
+ it("should call window.openai.callTool with correct arguments", async () => {
27
+ const { result } = renderHook(() => useCallTool(toolName));
28
+ act(() => {
29
+ result.current.callTool(args);
30
+ });
31
+ expect(OpenaiMock.callTool).toHaveBeenCalledWith(toolName, args);
32
+ });
33
+ it("should call onSuccess callback with correct data and toolArgs on successful execution", async () => {
34
+ const onSuccess = vi.fn();
35
+ const onError = vi.fn();
36
+ OpenaiMock.callTool.mockResolvedValueOnce(data);
37
+ const { result } = renderHook(() => useCallTool(toolName));
38
+ act(() => {
39
+ result.current.callTool(args, {
40
+ onSuccess,
41
+ onError,
42
+ });
43
+ });
44
+ await waitFor(() => {
45
+ expect(onSuccess).toHaveBeenCalledWith(data, args);
46
+ expect(onError).not.toHaveBeenCalled();
47
+ });
48
+ });
49
+ it("should call onError callback with error and toolArgs on failed execution", async () => {
50
+ const onSuccess = vi.fn();
51
+ const onError = vi.fn();
52
+ OpenaiMock.callTool.mockRejectedValueOnce(error);
53
+ const { result } = renderHook(() => useCallTool(toolName));
54
+ act(() => {
55
+ result.current.callTool(args, {
56
+ onSuccess,
57
+ onError,
58
+ });
59
+ });
60
+ await waitFor(() => {
61
+ expect(onSuccess).not.toHaveBeenCalled();
62
+ expect(onError).toHaveBeenCalledWith(error, args);
63
+ });
64
+ });
65
+ it("should call onSettled callback with data and undefined error on successful execution", async () => {
66
+ const onSuccess = vi.fn();
67
+ const onError = vi.fn();
68
+ const onSettled = vi.fn();
69
+ OpenaiMock.callTool.mockResolvedValueOnce(data);
70
+ const { result } = renderHook(() => useCallTool(toolName));
71
+ act(() => {
72
+ result.current.callTool(args, {
73
+ onSuccess,
74
+ onError,
75
+ onSettled,
76
+ });
77
+ });
78
+ await waitFor(() => {
79
+ expect(onSuccess).toHaveBeenCalledWith(data, args);
80
+ expect(onSettled).toHaveBeenCalledWith(data, undefined, args);
81
+ expect(onError).not.toHaveBeenCalled();
82
+ });
83
+ });
84
+ it("should call onSettled callback with undefined data and error on failed execution", async () => {
85
+ const onSuccess = vi.fn();
86
+ const onError = vi.fn();
87
+ const onSettled = vi.fn();
88
+ OpenaiMock.callTool.mockRejectedValueOnce(error);
89
+ const { result } = renderHook(() => useCallTool(toolName));
90
+ act(() => {
91
+ result.current.callTool(args, {
92
+ onSuccess,
93
+ onError,
94
+ onSettled,
95
+ });
96
+ });
97
+ await waitFor(() => {
98
+ expect(onError).toHaveBeenCalledWith(error, args);
99
+ expect(onSettled).toHaveBeenCalledWith(undefined, error, args);
100
+ expect(onSuccess).not.toHaveBeenCalled();
101
+ });
102
+ });
103
+ });
104
+ //# sourceMappingURL=use-call-tool.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-call-tool.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-call-tool.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EACL,QAAQ,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E,CAAC,EAAE,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACxB,MAAM,SAAS,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1B,UAAU,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CACjC,WAAW,CAA2B,QAAQ,CAAC,CAChD,CAAC;QAEF,GAAG,CAAC,GAAG,EAAE;YACP,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;gBAC5B,SAAS;gBACT,OAAO;gBACP,SAAS;aACV,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAClD,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC/D,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { DisplayMode } from "../types.js";
2
+ export declare function useDisplayMode(): readonly [DisplayMode, (mode: DisplayMode) => Promise<{
3
+ mode: DisplayMode;
4
+ }>];
@@ -0,0 +1,7 @@
1
+ import { useOpenAiGlobal } from "./use-openai-global.js";
2
+ export function useDisplayMode() {
3
+ const displayMode = useOpenAiGlobal("displayMode");
4
+ const setDisplayMode = (mode) => window.openai.requestDisplayMode({ mode });
5
+ return [displayMode, setDisplayMode];
6
+ }
7
+ //# sourceMappingURL=use-display-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-display-mode.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-display-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,UAAU,cAAc;IAC5B,MAAM,WAAW,GAAG,eAAe,CAAC,aAAa,CAAE,CAAC;IACpD,MAAM,cAAc,GAAG,CAAC,IAAiB,EAAE,EAAE,CAC3C,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7C,OAAO,CAAC,WAAW,EAAE,cAAc,CAAU,CAAC;AAChD,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { useDisplayMode } from "./use-display-mode.js";
2
+ import { describe, it, expect, vi, beforeEach, afterEach, } from "vitest";
3
+ import { renderHook, act } from "@testing-library/react";
4
+ describe("useDisplayMode", () => {
5
+ let OpenaiMock;
6
+ beforeEach(() => {
7
+ OpenaiMock = {
8
+ displayMode: "inline",
9
+ requestDisplayMode: vi.fn().mockResolvedValue({ mode: "inline" }),
10
+ };
11
+ vi.stubGlobal("openai", OpenaiMock);
12
+ });
13
+ afterEach(() => {
14
+ vi.unstubAllGlobals();
15
+ vi.resetAllMocks();
16
+ });
17
+ it("should return the current display mode from window.openai.displayMode", () => {
18
+ OpenaiMock.displayMode = "inline";
19
+ const { result } = renderHook(() => useDisplayMode());
20
+ expect(result.current[0]).toBe("inline");
21
+ });
22
+ it("should return different display modes when window.openai.displayMode changes", () => {
23
+ OpenaiMock.displayMode = "inline";
24
+ const { result, rerender } = renderHook(() => useDisplayMode());
25
+ expect(result.current[0]).toBe("inline");
26
+ OpenaiMock.displayMode = "fullscreen";
27
+ rerender();
28
+ expect(result.current[0]).toBe("fullscreen");
29
+ });
30
+ it("should call window.openai.requestDisplayMode with correct mode when setDisplayMode is called", async () => {
31
+ const { result } = renderHook(() => useDisplayMode());
32
+ await act(async () => {
33
+ await result.current[1]("fullscreen");
34
+ });
35
+ expect(OpenaiMock.requestDisplayMode).toHaveBeenCalledWith({
36
+ mode: "fullscreen",
37
+ });
38
+ });
39
+ });
40
+ //# sourceMappingURL=use-display-mode.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-display-mode.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-display-mode.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,QAAQ,EACR,EAAE,EACF,MAAM,EACN,EAAE,EACF,UAAU,EACV,SAAS,GAEV,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAGzD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,UAGH,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG;YACX,WAAW,EAAE,QAAQ;YACrB,kBAAkB,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SAClE,CAAC;QACF,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,EAAE,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,UAAU,CAAC,WAAW,GAAG,QAAQ,CAAC;QAClC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QAEtD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8EAA8E,EAAE,GAAG,EAAE;QACtF,UAAU,CAAC,WAAW,GAAG,QAAQ,CAAC;QAClC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QAEhE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzC,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;QACtC,QAAQ,EAAE,CAAC;QAEX,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8FAA8F,EAAE,KAAK,IAAI,EAAE;QAC5G,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QAEtD,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;YACnB,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,oBAAoB,CAAC;YACzD,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useLocale(): string;
@@ -0,0 +1,5 @@
1
+ import { useOpenAiGlobal } from "./use-openai-global.js";
2
+ export function useLocale() {
3
+ return useOpenAiGlobal("locale");
4
+ }
5
+ //# sourceMappingURL=use-locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-locale.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,UAAU,SAAS;IACvB,OAAO,eAAe,CAAC,QAAQ,CAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import { useLocale } from "./use-locale.js";
2
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
3
+ import { renderHook } from "@testing-library/react";
4
+ describe("useLocale", () => {
5
+ let OpenaiMock;
6
+ beforeEach(() => {
7
+ OpenaiMock = {
8
+ locale: "en-US",
9
+ };
10
+ vi.stubGlobal("openai", OpenaiMock);
11
+ });
12
+ afterEach(() => {
13
+ vi.unstubAllGlobals();
14
+ vi.resetAllMocks();
15
+ });
16
+ it("should return the current locale from window.openai.locale", () => {
17
+ const { result } = renderHook(() => useLocale());
18
+ expect(result.current).toBe("en-US");
19
+ });
20
+ });
21
+ //# sourceMappingURL=use-locale.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-locale.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-locale.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,UAEH,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG;YACX,MAAM,EAAE,OAAO;SAChB,CAAC;QACF,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,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useOpenExternal(): (href: string) => void;
@@ -0,0 +1,6 @@
1
+ export function useOpenExternal() {
2
+ return (href) => {
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 { useOpenExternal } from "./use-open-external.js";
2
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
3
+ import { renderHook } from "@testing-library/react";
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,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,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"}
@@ -1,2 +1,2 @@
1
- import { type OpenAiGlobals } from "./types.js";
1
+ import { type OpenAiGlobals } from "../types.js";
2
2
  export declare function useOpenAiGlobal<K extends keyof OpenAiGlobals>(key: K): OpenAiGlobals[K] | undefined;
@@ -1,5 +1,5 @@
1
1
  import { useSyncExternalStore } from "react";
2
- import { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent } from "./types.js";
2
+ import { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, } from "../types.js";
3
3
  export function useOpenAiGlobal(key) {
4
4
  return useSyncExternalStore((onChange) => {
5
5
  const handleSetGlobal = (event) => {
@@ -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,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EACL,sBAAsB,EACtB,eAAe,GAEhB,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,eAAe,CAC7B,GAAM;IAEN,OAAO,oBAAoB,CACzB,CAAC,QAAQ,EAAE,EAAE;QACX,MAAM,eAAe,GAAG,CAAC,KAAsB,EAAE,EAAE;YACjD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAO;YACT,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;YACvD,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,sBAAsB,EAAE,eAAe,EAAE;YAC/D,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;QACtE,CAAC,CAAC;IACJ,CAAC,EACD,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
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(): (options: RequestModalOptions) => void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Triggers a modal containing the widget rendered in display mode "modal"
3
+ */
4
+ export function useRequestModal() {
5
+ return (options) => {
6
+ window.openai.requestModal(options);
7
+ };
8
+ }
9
+ //# 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":"AAEA;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,OAA4B,EAAE,EAAE;QACtC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { useRequestModal } from "./use-request-modal.js";
2
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
3
+ import { renderHook } from "@testing-library/react";
4
+ describe("useRequestModal", () => {
5
+ let requestModalMock;
6
+ beforeEach(() => {
7
+ requestModalMock = vi.fn();
8
+ vi.stubGlobal("openai", {
9
+ requestModal: requestModalMock,
10
+ });
11
+ });
12
+ afterEach(() => {
13
+ vi.unstubAllGlobals();
14
+ vi.resetAllMocks();
15
+ });
16
+ it("should return a function that calls window.openai.requestModal with the options", () => {
17
+ const { result } = renderHook(() => useRequestModal());
18
+ const options = { title: "Test Modal" };
19
+ result.current(options);
20
+ expect(requestModalMock).toHaveBeenCalledTimes(1);
21
+ expect(requestModalMock).toHaveBeenCalledWith(options);
22
+ });
23
+ });
24
+ //# 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,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,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,iFAAiF,EAAE,GAAG,EAAE;QACzF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QAEvD,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QACxC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAExB,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,11 @@
1
+ import { useCallback } from "react";
2
+ export function useSendFollowUpMessage() {
3
+ const sendFollowUpMessage = useCallback(async (prompt) => {
4
+ if (!window.openai?.sendFollowUpMessage) {
5
+ throw new Error("window.openai.sendFollowUpMessage is not available");
6
+ }
7
+ return window.openai.sendFollowUpMessage({ prompt });
8
+ }, []);
9
+ return sendFollowUpMessage;
10
+ }
11
+ //# 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,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,MAAM,UAAU,sBAAsB;IACpC,MAAM,mBAAmB,GAAG,WAAW,CACrC,KAAK,EAAE,MAAc,EAAiB,EAAE;QACtC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useTheme(): import("../types.js").Theme;
@@ -0,0 +1,5 @@
1
+ import { useOpenAiGlobal } from "./use-openai-global.js";
2
+ export function useTheme() {
3
+ return useOpenAiGlobal("theme");
4
+ }
5
+ //# sourceMappingURL=use-theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-theme.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,UAAU,QAAQ;IACtB,OAAO,eAAe,CAAC,OAAO,CAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import { useTheme } from "./use-theme.js";
2
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
3
+ import { renderHook } from "@testing-library/react";
4
+ describe("useTheme", () => {
5
+ let OpenaiMock;
6
+ beforeEach(() => {
7
+ OpenaiMock = {
8
+ theme: "light",
9
+ };
10
+ vi.stubGlobal("openai", OpenaiMock);
11
+ });
12
+ afterEach(() => {
13
+ vi.unstubAllGlobals();
14
+ vi.resetAllMocks();
15
+ });
16
+ it("should return the current theme from window.openai.theme", () => {
17
+ const { result } = renderHook(() => useTheme());
18
+ expect(result.current).toBe("light");
19
+ });
20
+ it("should return dark theme when set to dark", () => {
21
+ OpenaiMock.theme = "dark";
22
+ const { result } = renderHook(() => useTheme());
23
+ expect(result.current).toBe("dark");
24
+ });
25
+ });
26
+ //# sourceMappingURL=use-theme.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-theme.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-theme.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAI,UAEH,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG;YACX,KAAK,EAAE,OAAO;SACf,CAAC;QACF,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,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEhD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,UAAU,CAAC,KAAK,GAAG,MAAM,CAAC;QAC1B,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEhD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function useToolInfo(): {
2
+ output: import("skybridge/web").UnknownObject | null | undefined;
3
+ input: import("skybridge/web").UnknownObject | undefined;
4
+ responseMetadata: import("skybridge/web").UnknownObject | null | undefined;
5
+ };
@@ -0,0 +1,9 @@
1
+ import { useOpenAiGlobal } from "skybridge/web";
2
+ export function useToolInfo() {
3
+ return {
4
+ output: useOpenAiGlobal("toolOutput"),
5
+ input: useOpenAiGlobal("toolInput"),
6
+ responseMetadata: useOpenAiGlobal("toolResponseMetadata"),
7
+ };
8
+ }
9
+ //# 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,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,MAAM,EAAE,eAAe,CAAC,YAAY,CAAC;QACrC,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC;QACnC,gBAAgB,EAAE,eAAe,CAAC,sBAAsB,CAAC;KAC1D,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { renderHook } from "@testing-library/react";
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { useToolInfo } from "./use-tool-info.js";
4
+ describe("useToolInfo", () => {
5
+ let OpenaiMock;
6
+ beforeEach(() => {
7
+ OpenaiMock = {
8
+ toolInput: { name: "pikachu", args: { param: "value" } },
9
+ toolOutput: {
10
+ name: "pikachu",
11
+ color: "yellow",
12
+ description: "When several of these POKéMON gather, their\felectricity could build and cause lightning storms.",
13
+ },
14
+ toolResponseMetadata: { id: 12 },
15
+ };
16
+ vi.stubGlobal("openai", OpenaiMock);
17
+ });
18
+ afterEach(() => {
19
+ vi.unstubAllGlobals();
20
+ vi.resetAllMocks();
21
+ });
22
+ it("should return toolInput, toolOutput, and toolResponseMetadata from window.openai", () => {
23
+ const { result } = renderHook(() => useToolInfo());
24
+ expect(result.current.input).toEqual({
25
+ name: "pikachu",
26
+ args: { param: "value" },
27
+ });
28
+ expect(result.current.output).toEqual({
29
+ name: "pikachu",
30
+ color: "yellow",
31
+ description: "When several of these POKéMON gather, their\felectricity could build and cause lightning storms.",
32
+ });
33
+ expect(result.current.responseMetadata).toEqual({
34
+ id: 12,
35
+ });
36
+ });
37
+ });
38
+ //# sourceMappingURL=use-tool-info.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tool-info.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-tool-info.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,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,UAIH,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG;YACX,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACxD,UAAU,EAAE;gBACV,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,QAAQ;gBACf,WAAW,EACT,kGAAkG;aACrG;YACD,oBAAoB,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;SACjC,CAAC;QACF,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,EAAE,CAAC,kFAAkF,EAAE,GAAG,EAAE;QAC1F,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QAEnD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;YACnC,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;SACzB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACpC,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,QAAQ;YACf,WAAW,EACT,kGAAkG;SACrG,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC;YAC9C,EAAE,EAAE,EAAE;SACP,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `output` property.
3
+ */
4
+ export declare function useToolOutput(): import("../types.js").UnknownObject | null | undefined;
@@ -0,0 +1,9 @@
1
+ import { useToolInfo } from "./use-tool-info.js";
2
+ /**
3
+ * @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `output` property.
4
+ */
5
+ export function useToolOutput() {
6
+ const { output } = useToolInfo();
7
+ return output;
8
+ }
9
+ //# sourceMappingURL=use-tool-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tool-output.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-tool-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IAEjC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `responseMetadata` property.
3
+ */
4
+ export declare function useToolResponseMetadata(): import("../types.js").UnknownObject | null | undefined;
@@ -0,0 +1,8 @@
1
+ import { useOpenAiGlobal } from "./use-openai-global.js";
2
+ /**
3
+ * @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `responseMetadata` property.
4
+ */
5
+ export function useToolResponseMetadata() {
6
+ return useOpenAiGlobal("toolResponseMetadata");
7
+ }
8
+ //# sourceMappingURL=use-tool-response-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tool-response-metadata.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-tool-response-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,eAAe,CAAC,sBAAsB,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useUserAgent(): import("../types.js").UserAgent;
@@ -0,0 +1,5 @@
1
+ import { useOpenAiGlobal } from "./use-openai-global.js";
2
+ export function useUserAgent() {
3
+ return useOpenAiGlobal("userAgent");
4
+ }
5
+ //# sourceMappingURL=use-user-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-user-agent.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,UAAU,YAAY;IAC1B,OAAO,eAAe,CAAC,WAAW,CAAE,CAAC;AACvC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import { useUserAgent } from "./use-user-agent.js";
2
+ import { describe, it, expect, vi, beforeEach, afterEach, } from "vitest";
3
+ import { renderHook } from "@testing-library/react";
4
+ describe("useUserAgent", () => {
5
+ let OpenaiMock;
6
+ beforeEach(() => {
7
+ OpenaiMock = {
8
+ userAgent: {
9
+ device: { type: "mobile" },
10
+ capabilities: { hover: false, touch: true },
11
+ },
12
+ };
13
+ vi.stubGlobal("openai", OpenaiMock);
14
+ });
15
+ afterEach(() => {
16
+ vi.unstubAllGlobals();
17
+ vi.resetAllMocks();
18
+ });
19
+ it("should return the current user agent from window.openai.userAgent", () => {
20
+ OpenaiMock.userAgent = {
21
+ device: { type: "mobile" },
22
+ capabilities: { hover: false, touch: true },
23
+ };
24
+ const { result } = renderHook(() => useUserAgent());
25
+ expect(result.current).toEqual({
26
+ device: { type: "mobile" },
27
+ capabilities: { hover: false, touch: true },
28
+ });
29
+ });
30
+ });
31
+ //# sourceMappingURL=use-user-agent.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-user-agent.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user-agent.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,QAAQ,EACR,EAAE,EACF,MAAM,EACN,EAAE,EACF,UAAU,EACV,SAAS,GAEV,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,UAEH,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG;YACX,SAAS,EAAE;gBACT,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC1B,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;aAC5C;SACF,CAAC;QACF,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,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,UAAU,CAAC,SAAS,GAAG;YACrB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;SAC5C,CAAC;QACF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;QAEpD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;YAC7B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type SetStateAction } from "react";
2
+ import type { UnknownObject } from "../types.js";
3
+ export declare function useWidgetState<T extends UnknownObject>(defaultState: T | (() => T)): readonly [T, (state: SetStateAction<T>) => void];
4
+ export declare function useWidgetState<T extends UnknownObject>(defaultState?: T | (() => T | null) | null): readonly [T | null, (state: SetStateAction<T | null>) => void];