skybridge 0.0.0-dev.bcdd9e8 → 0.0.0-dev.bed9595
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/server/server.js +4 -1
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/web/hooks/index.d.ts +13 -0
- package/dist/src/web/hooks/index.js +14 -0
- package/dist/src/web/hooks/index.js.map +1 -0
- package/dist/src/web/hooks/use-call-tool.d.ts +62 -0
- package/dist/src/web/{use-call-tool.js → hooks/use-call-tool.js} +26 -4
- package/dist/src/web/hooks/use-call-tool.js.map +1 -0
- package/dist/src/web/hooks/use-call-tool.test.js +164 -0
- package/dist/src/web/hooks/use-call-tool.test.js.map +1 -0
- package/dist/src/web/hooks/use-display-mode.d.ts +4 -0
- package/dist/src/web/hooks/use-display-mode.js +7 -0
- package/dist/src/web/hooks/use-display-mode.js.map +1 -0
- package/dist/src/web/hooks/use-display-mode.test.js +40 -0
- package/dist/src/web/hooks/use-display-mode.test.js.map +1 -0
- package/dist/src/web/hooks/use-locale.d.ts +1 -0
- package/dist/src/web/hooks/use-locale.js +5 -0
- package/dist/src/web/hooks/use-locale.js.map +1 -0
- package/dist/src/web/hooks/use-locale.test.js +21 -0
- package/dist/src/web/hooks/use-locale.test.js.map +1 -0
- package/dist/src/web/hooks/use-open-external.d.ts +1 -0
- package/dist/src/web/hooks/use-open-external.js +6 -0
- package/dist/src/web/hooks/use-open-external.js.map +1 -0
- package/dist/src/web/hooks/use-open-external.test.d.ts +1 -0
- package/dist/src/web/hooks/use-open-external.test.js +24 -0
- package/dist/src/web/hooks/use-open-external.test.js.map +1 -0
- package/dist/src/web/{use-openai-global.d.ts → hooks/use-openai-global.d.ts} +1 -1
- package/dist/src/web/{use-openai-global.js → hooks/use-openai-global.js} +4 -2
- package/dist/src/web/hooks/use-openai-global.js.map +1 -0
- package/dist/src/web/hooks/use-request-modal.d.ts +5 -0
- package/dist/src/web/hooks/use-request-modal.js +9 -0
- package/dist/src/web/hooks/use-request-modal.js.map +1 -0
- package/dist/src/web/hooks/use-request-modal.test.d.ts +1 -0
- package/dist/src/web/hooks/use-request-modal.test.js +24 -0
- package/dist/src/web/hooks/use-request-modal.test.js.map +1 -0
- package/dist/src/web/hooks/use-send-follow-up-message.d.ts +1 -0
- package/dist/src/web/hooks/use-send-follow-up-message.js +11 -0
- package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -0
- package/dist/src/web/hooks/use-theme.d.ts +1 -0
- package/dist/src/web/hooks/use-theme.js +5 -0
- package/dist/src/web/hooks/use-theme.js.map +1 -0
- package/dist/src/web/hooks/use-theme.test.d.ts +1 -0
- package/dist/src/web/hooks/use-theme.test.js +26 -0
- package/dist/src/web/hooks/use-theme.test.js.map +1 -0
- package/dist/src/web/hooks/use-tool-info.d.ts +23 -0
- package/dist/src/web/hooks/use-tool-info.js +22 -0
- package/dist/src/web/hooks/use-tool-info.js.map +1 -0
- package/dist/src/web/hooks/use-tool-info.test.d.ts +1 -0
- package/dist/src/web/hooks/use-tool-info.test.js +134 -0
- package/dist/src/web/hooks/use-tool-info.test.js.map +1 -0
- package/dist/src/web/hooks/use-tool-output.d.ts +4 -0
- package/dist/src/web/hooks/use-tool-output.js +9 -0
- package/dist/src/web/hooks/use-tool-output.js.map +1 -0
- package/dist/src/web/hooks/use-tool-response-metadata.d.ts +4 -0
- package/dist/src/web/hooks/use-tool-response-metadata.js +8 -0
- package/dist/src/web/hooks/use-tool-response-metadata.js.map +1 -0
- package/dist/src/web/hooks/use-user-agent.d.ts +1 -0
- package/dist/src/web/hooks/use-user-agent.js +5 -0
- package/dist/src/web/hooks/use-user-agent.js.map +1 -0
- package/dist/src/web/hooks/use-user-agent.test.d.ts +1 -0
- package/dist/src/web/hooks/use-user-agent.test.js +31 -0
- package/dist/src/web/hooks/use-user-agent.test.js.map +1 -0
- package/dist/src/web/{use-widget-state.d.ts → hooks/use-widget-state.d.ts} +1 -1
- package/dist/src/web/hooks/use-widget-state.js.map +1 -0
- package/dist/src/web/hooks/use-widget-state.test.d.ts +1 -0
- package/dist/src/web/{use-widget-state.test.js → hooks/use-widget-state.test.js} +0 -1
- package/dist/src/web/hooks/use-widget-state.test.js.map +1 -0
- package/dist/src/web/index.d.ts +1 -5
- package/dist/src/web/index.js +1 -5
- package/dist/src/web/index.js.map +1 -1
- package/dist/src/web/types.d.ts +16 -3
- package/dist/src/web/types.js.map +1 -1
- package/dist/vitest.config.js +0 -1
- package/dist/vitest.config.js.map +1 -1
- package/package.json +5 -2
- package/dist/src/test/setup.js +0 -9
- package/dist/src/test/setup.js.map +0 -1
- package/dist/src/web/use-call-tool.d.ts +0 -54
- package/dist/src/web/use-call-tool.js.map +0 -1
- package/dist/src/web/use-call-tool.test.js +0 -66
- package/dist/src/web/use-call-tool.test.js.map +0 -1
- package/dist/src/web/use-openai-global.js.map +0 -1
- package/dist/src/web/use-tool-output.d.ts +0 -1
- package/dist/src/web/use-tool-output.js +0 -5
- package/dist/src/web/use-tool-output.js.map +0 -1
- package/dist/src/web/use-tool-response-metadata.d.ts +0 -1
- package/dist/src/web/use-tool-response-metadata.js +0 -5
- package/dist/src/web/use-tool-response-metadata.js.map +0 -1
- package/dist/src/web/use-widget-state.js.map +0 -1
- package/dist/src/web/use-widget-state.test.js.map +0 -1
- /package/dist/src/web/{use-call-tool.test.d.ts → hooks/use-call-tool.test.d.ts} +0 -0
- /package/dist/src/{test/setup.d.ts → web/hooks/use-display-mode.test.d.ts} +0 -0
- /package/dist/src/web/{use-widget-state.test.d.ts → hooks/use-locale.test.d.ts} +0 -0
- /package/dist/src/web/{use-widget-state.js → hooks/use-widget-state.js} +0 -0
|
@@ -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,23 @@
|
|
|
1
|
+
import type { UnknownObject } from "../types.js";
|
|
2
|
+
type ToolState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = {
|
|
3
|
+
status: "pending";
|
|
4
|
+
isPending: true;
|
|
5
|
+
isSuccess: false;
|
|
6
|
+
input: ToolInput;
|
|
7
|
+
output: undefined;
|
|
8
|
+
responseMetadata: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
status: "success";
|
|
11
|
+
isPending: false;
|
|
12
|
+
isSuccess: true;
|
|
13
|
+
input: ToolInput;
|
|
14
|
+
output: ToolOutput;
|
|
15
|
+
responseMetadata: ToolResponseMetadata;
|
|
16
|
+
};
|
|
17
|
+
type ToolSignature = {
|
|
18
|
+
input: UnknownObject;
|
|
19
|
+
output: UnknownObject;
|
|
20
|
+
responseMetadata: UnknownObject;
|
|
21
|
+
};
|
|
22
|
+
export declare function useToolInfo<TS extends Partial<ToolSignature> = {}>(): ToolState<TS["input"] extends UnknownObject ? TS["input"] : UnknownObject, TS["output"] extends UnknownObject ? TS["output"] : UnknownObject, TS["responseMetadata"] extends UnknownObject ? TS["responseMetadata"] : UnknownObject>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useOpenAiGlobal } from "./use-openai-global.js";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
export function useToolInfo() {
|
|
4
|
+
const [status, setStatus] = useState("pending");
|
|
5
|
+
const input = useOpenAiGlobal("toolInput");
|
|
6
|
+
const output = useOpenAiGlobal("toolOutput") ?? undefined;
|
|
7
|
+
const responseMetadata = useOpenAiGlobal("toolResponseMetadata") ?? undefined;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
setStatus(output === undefined && responseMetadata === undefined
|
|
10
|
+
? "pending"
|
|
11
|
+
: "success");
|
|
12
|
+
}, [output, responseMetadata]);
|
|
13
|
+
return {
|
|
14
|
+
input,
|
|
15
|
+
status,
|
|
16
|
+
isPending: status === "pending",
|
|
17
|
+
isSuccess: status === "success",
|
|
18
|
+
output,
|
|
19
|
+
responseMetadata,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# 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,wBAAwB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA+B5C,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAwB,SAAS,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,eAAe,CAAC,WAAW,CAAE,CAAC;IAC5C,MAAM,MAAM,GAAG,eAAe,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC;IAC1D,MAAM,gBAAgB,GAAG,eAAe,CAAC,sBAAsB,CAAC,IAAI,SAAS,CAAC;IAE9E,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CACP,MAAM,KAAK,SAAS,IAAI,gBAAgB,KAAK,SAAS;YACpD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,SAAS,CACd,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAU/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,134 @@
|
|
|
1
|
+
import { fireEvent, renderHook, waitFor, act } from "@testing-library/react";
|
|
2
|
+
import { expectType } from "tsd";
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { useToolInfo } from "./use-tool-info.js";
|
|
5
|
+
import { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, } from "../types.js";
|
|
6
|
+
describe("useToolInfo", () => {
|
|
7
|
+
let OpenaiMock;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
OpenaiMock = {
|
|
10
|
+
toolInput: { name: "pokemon", args: { name: "pikachu" } },
|
|
11
|
+
toolOutput: null,
|
|
12
|
+
toolResponseMetadata: null,
|
|
13
|
+
};
|
|
14
|
+
vi.stubGlobal("openai", OpenaiMock);
|
|
15
|
+
});
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
vi.unstubAllGlobals();
|
|
18
|
+
vi.resetAllMocks();
|
|
19
|
+
});
|
|
20
|
+
it("should return toolInput on initial mount window.openai", () => {
|
|
21
|
+
const { result } = renderHook(() => useToolInfo());
|
|
22
|
+
expect(result.current).toMatchObject({
|
|
23
|
+
input: { name: "pokemon", args: { name: "pikachu" } },
|
|
24
|
+
status: "pending",
|
|
25
|
+
isPending: true,
|
|
26
|
+
isSuccess: false,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it("should eventually return tool output and response metadata once tool call completes", async () => {
|
|
30
|
+
const toolOutput = {
|
|
31
|
+
name: "pikachu",
|
|
32
|
+
color: "yellow",
|
|
33
|
+
description: "When several of these POKéMON gather, their\felectricity could build and cause lightning storms.",
|
|
34
|
+
};
|
|
35
|
+
const toolResponseMetadata = { id: 12 };
|
|
36
|
+
const { result } = renderHook(() => useToolInfo());
|
|
37
|
+
act(() => {
|
|
38
|
+
OpenaiMock.toolOutput = toolOutput;
|
|
39
|
+
OpenaiMock.toolResponseMetadata = toolResponseMetadata;
|
|
40
|
+
fireEvent(window, new SetGlobalsEvent(SET_GLOBALS_EVENT_TYPE, {
|
|
41
|
+
detail: {
|
|
42
|
+
globals: {
|
|
43
|
+
toolOutput,
|
|
44
|
+
toolResponseMetadata,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}));
|
|
48
|
+
});
|
|
49
|
+
await waitFor(() => {
|
|
50
|
+
expect(result.current).toMatchObject({
|
|
51
|
+
status: "success",
|
|
52
|
+
isPending: false,
|
|
53
|
+
isSuccess: true,
|
|
54
|
+
output: toolOutput,
|
|
55
|
+
responseMetadata: toolResponseMetadata,
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe("useToolInfo - TypeScript typing", () => {
|
|
61
|
+
it("should have correct types when no generic parameter is provided", () => {
|
|
62
|
+
const { result } = renderHook(() => useToolInfo());
|
|
63
|
+
expectType(result.current.status);
|
|
64
|
+
expectType(result.current.isPending);
|
|
65
|
+
expectType(result.current.isSuccess);
|
|
66
|
+
expectType(result.current.input);
|
|
67
|
+
});
|
|
68
|
+
it("should correctly type input, output, and responseMetadata with explicit ToolSignature", () => {
|
|
69
|
+
const { result } = renderHook(() => useToolInfo());
|
|
70
|
+
expectType(result.current.input);
|
|
71
|
+
// When pending, output and responseMetadata should be undefined
|
|
72
|
+
if (result.current.status === "pending") {
|
|
73
|
+
expectType(result.current.output);
|
|
74
|
+
expectType(result.current.responseMetadata);
|
|
75
|
+
expectType(result.current.isPending);
|
|
76
|
+
expectType(result.current.isSuccess);
|
|
77
|
+
}
|
|
78
|
+
// When success, output and responseMetadata should be defined
|
|
79
|
+
if (result.current.status === "success") {
|
|
80
|
+
expectType(result.current.output);
|
|
81
|
+
expectType(result.current.responseMetadata);
|
|
82
|
+
expectType(result.current.isPending);
|
|
83
|
+
expectType(result.current.isSuccess);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
it("should correctly narrow types based on status discriminated union", () => {
|
|
87
|
+
const { result } = renderHook(() => useToolInfo());
|
|
88
|
+
// Test type narrowing
|
|
89
|
+
if (result.current.isPending) {
|
|
90
|
+
expectType(result.current.status);
|
|
91
|
+
expectType(result.current.isPending);
|
|
92
|
+
expectType(result.current.isSuccess);
|
|
93
|
+
expectType(result.current.output);
|
|
94
|
+
expectType(result.current.responseMetadata);
|
|
95
|
+
}
|
|
96
|
+
if (result.current.isSuccess) {
|
|
97
|
+
expectType(result.current.status);
|
|
98
|
+
expectType(result.current.isPending);
|
|
99
|
+
expectType(result.current.isSuccess);
|
|
100
|
+
expectType(result.current.output);
|
|
101
|
+
expectType(result.current.responseMetadata);
|
|
102
|
+
}
|
|
103
|
+
if (result.current.status === "pending") {
|
|
104
|
+
expectType(result.current.input);
|
|
105
|
+
expectType(result.current.isPending);
|
|
106
|
+
expectType(result.current.isSuccess);
|
|
107
|
+
expectType(result.current.output);
|
|
108
|
+
expectType(result.current.responseMetadata);
|
|
109
|
+
}
|
|
110
|
+
if (result.current.status === "success") {
|
|
111
|
+
expectType(result.current.input);
|
|
112
|
+
expectType(result.current.isPending);
|
|
113
|
+
expectType(result.current.isSuccess);
|
|
114
|
+
expectType(result.current.output);
|
|
115
|
+
expectType(result.current.responseMetadata);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
it("should handle partial ToolSignature with only input specified", () => {
|
|
119
|
+
const { result } = renderHook(() => useToolInfo());
|
|
120
|
+
expectType(result.current.input);
|
|
121
|
+
if (result.current.status === "success") {
|
|
122
|
+
expectType(result.current.output);
|
|
123
|
+
expectType(result.current.responseMetadata);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
it("should handle ToolSignature with only output specified", () => {
|
|
127
|
+
const { result } = renderHook(() => useToolInfo());
|
|
128
|
+
expectType(result.current.input);
|
|
129
|
+
if (result.current.status === "success") {
|
|
130
|
+
expectType(result.current.output);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
//# 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,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,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;AACjD,OAAO,EACL,sBAAsB,EACtB,eAAe,GAEhB,MAAM,aAAa,CAAC;AAErB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,UAGH,CAAC;IAEF,UAAU,CAAC,GAA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AAY,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE5C,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACxC,UAAU,CAA0B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC3D,UAAU,CAA0B,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACvE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAGhE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CACjC,WAAW,EAEP,CACL,CAAC;QAEF,UAAU,CAA0B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE1D,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACxC,UAAU,CAAa,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -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,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 @@
|
|
|
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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type SetStateAction } from "react";
|
|
2
|
-
import type { UnknownObject } from "
|
|
2
|
+
import type { UnknownObject } from "../types.js";
|
|
3
3
|
export declare function useWidgetState<T extends UnknownObject>(defaultState: T | (() => T)): readonly [T, (state: SetStateAction<T>) => void];
|
|
4
4
|
export declare function useWidgetState<T extends UnknownObject>(defaultState?: T | (() => T | null) | null): readonly [T | null, (state: SetStateAction<T | null>) => void];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-widget-state.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-widget-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAuB,MAAM,OAAO,CAAC;AAE9E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAQzD,MAAM,UAA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
-
console.log("widgetState", result.current[0]);
|
|
48
47
|
expect(result.current[0]).toEqual({ count: 1, name: "test" });
|
|
49
48
|
});
|
|
50
49
|
it("should update state when window.openai.widgetState changes", () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-widget-state.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-widget-state.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;AAEzD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,UAA0D,CAAC;IAE/D,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG;YACX,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;SACrD,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,MAAM,YAAY,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAChD,MAAM,WAAW,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAEjD,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACrF,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC;QAC9B,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc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,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,oBAAoB,CAAC;YACrD,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;QACtC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC;QAE5E,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAEhD,8CAA8C;QAC9C,UAAU,CAAC,WAAW,GAAG,WAAW,CAAC;QACrC,sDAAsD;QACtD,QAAQ,EAAE,CAAC;QAEX,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/src/web/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export { useOpenAiGlobal } from "./use-openai-global.js";
|
|
2
|
-
export { useToolOutput } from "./use-tool-output.js";
|
|
3
|
-
export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
|
|
4
|
-
export { useCallTool } from "./use-call-tool.js";
|
|
5
1
|
export * from "./types.js";
|
|
6
2
|
export { mountWidget } from "./mount-widget.js";
|
|
7
3
|
export { skybridge } from "./plugin.js";
|
|
8
|
-
export
|
|
4
|
+
export * from "./hooks/index.js";
|
package/dist/src/web/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
export { useOpenAiGlobal } from "./use-openai-global.js";
|
|
2
|
-
export { useToolOutput } from "./use-tool-output.js";
|
|
3
|
-
export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
|
|
4
|
-
export { useCallTool } from "./use-call-tool.js";
|
|
5
1
|
export * from "./types.js";
|
|
6
2
|
export { mountWidget } from "./mount-widget.js";
|
|
7
3
|
export { skybridge } from "./plugin.js";
|
|
8
|
-
export
|
|
4
|
+
export * from "./hooks/index.js";
|
|
9
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,cAAc,kBAAkB,CAAC"}
|
package/dist/src/web/types.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ export type RequestDisplayMode = (args: {
|
|
|
9
9
|
}) => Promise<{
|
|
10
10
|
mode: DisplayMode;
|
|
11
11
|
}>;
|
|
12
|
+
export type RequestModal = (options: RequestModalOptions) => Promise<void>;
|
|
13
|
+
export type RequestModalOptions = {
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
12
16
|
export declare const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
|
|
13
17
|
export declare class ToolResponseEvent extends CustomEvent<{
|
|
14
18
|
tool: {
|
|
@@ -26,7 +30,7 @@ declare global {
|
|
|
26
30
|
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
|
-
export type OpenAiGlobals<ToolInput extends UnknownObject =
|
|
33
|
+
export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
|
|
30
34
|
theme: Theme;
|
|
31
35
|
userAgent: UserAgent;
|
|
32
36
|
locale: string;
|
|
@@ -34,9 +38,13 @@ export type OpenAiGlobals<ToolInput extends UnknownObject = UnknownObject, ToolO
|
|
|
34
38
|
displayMode: DisplayMode;
|
|
35
39
|
safeArea: SafeArea;
|
|
36
40
|
toolInput: ToolInput;
|
|
37
|
-
toolOutput: ToolOutput |
|
|
41
|
+
toolOutput: ToolOutput | {
|
|
42
|
+
text: string;
|
|
43
|
+
} | null;
|
|
38
44
|
toolResponseMetadata: ToolResponseMetadata | null;
|
|
39
45
|
widgetState: WidgetState | null;
|
|
46
|
+
requestDisplayMode: RequestDisplayMode;
|
|
47
|
+
requestModal: RequestModal;
|
|
40
48
|
};
|
|
41
49
|
export type CallToolArgs = Record<string, unknown> | null;
|
|
42
50
|
export type CallToolResponse = {
|
|
@@ -49,9 +57,14 @@ export type CallToolResponse = {
|
|
|
49
57
|
result: string;
|
|
50
58
|
meta: Record<string, unknown>;
|
|
51
59
|
};
|
|
60
|
+
export type DefaultCallToolResponse = {
|
|
61
|
+
structuredContent: Record<string, unknown>;
|
|
62
|
+
meta: Record<string, unknown>;
|
|
63
|
+
};
|
|
64
|
+
export type CallToolResponseConstraint = Partial<Pick<CallToolResponse, "structuredContent" | "meta">>;
|
|
52
65
|
type API<WidgetState extends UnknownObject> = {
|
|
53
66
|
/** Calls a tool on your MCP. Returns the full response. */
|
|
54
|
-
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends
|
|
67
|
+
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponseConstraint = DefaultCallToolResponse>(name: string, args: ToolArgs) => Promise<CallToolResponse & ToolResponse>;
|
|
55
68
|
/** Triggers a followup turn in the ChatGPT conversation */
|
|
56
69
|
sendFollowUpMessage: (args: {
|
|
57
70
|
prompt: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AAsFD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
|
package/dist/vitest.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,IAAI;KACd;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.bed9595",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc && pnpm run build:templates",
|
|
21
21
|
"build:templates": "cp -r src/server/templates dist/src/server/",
|
|
22
|
-
"test": "
|
|
22
|
+
"test": "pnpm run test:unit && pnpm run test:type",
|
|
23
|
+
"test:unit": "vitest run --silent",
|
|
24
|
+
"test:type": "tsc --noEmit",
|
|
23
25
|
"docs:dev": "pnpm --filter @skybridge/docs start",
|
|
24
26
|
"docs:build": "pnpm --filter @skybridge/docs build",
|
|
25
27
|
"docs:serve": "pnpm --filter @skybridge/docs serve"
|
|
@@ -56,6 +58,7 @@
|
|
|
56
58
|
"@types/react-dom": "^19.2.2",
|
|
57
59
|
"@vitest/ui": "^2.1.8",
|
|
58
60
|
"jsdom": "^25.0.1",
|
|
61
|
+
"tsd": "^0.33.0",
|
|
59
62
|
"typescript": "^5.9.3",
|
|
60
63
|
"vitest": "^2.1.8"
|
|
61
64
|
},
|
package/dist/src/test/setup.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/test/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,+CAA+C;AAC/C,MAAM,CAAC,OAAO,GAAG;IACf,GAAG,OAAO;IACV,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;IACd,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;CACb,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { CallToolArgs, CallToolResponse } from "./types.js";
|
|
2
|
-
export declare const useCallTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string) => {
|
|
3
|
-
callTool: (toolArgs: ToolArgs, sideEffects?: {
|
|
4
|
-
onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
|
|
5
|
-
onError?: (error: unknown, toolArgs: ToolArgs) => void;
|
|
6
|
-
}) => void;
|
|
7
|
-
callToolAsync: (toolArgs: ToolArgs) => Promise<ToolResponse>;
|
|
8
|
-
status: "idle";
|
|
9
|
-
isIdle: true;
|
|
10
|
-
isPending: false;
|
|
11
|
-
isSuccess: false;
|
|
12
|
-
isError: false;
|
|
13
|
-
data: undefined;
|
|
14
|
-
error: undefined;
|
|
15
|
-
} | {
|
|
16
|
-
callTool: (toolArgs: ToolArgs, sideEffects?: {
|
|
17
|
-
onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
|
|
18
|
-
onError?: (error: unknown, toolArgs: ToolArgs) => void;
|
|
19
|
-
}) => void;
|
|
20
|
-
callToolAsync: (toolArgs: ToolArgs) => Promise<ToolResponse>;
|
|
21
|
-
status: "pending";
|
|
22
|
-
isIdle: false;
|
|
23
|
-
isPending: true;
|
|
24
|
-
isSuccess: false;
|
|
25
|
-
isError: false;
|
|
26
|
-
data: undefined;
|
|
27
|
-
error: undefined;
|
|
28
|
-
} | {
|
|
29
|
-
callTool: (toolArgs: ToolArgs, sideEffects?: {
|
|
30
|
-
onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
|
|
31
|
-
onError?: (error: unknown, toolArgs: ToolArgs) => void;
|
|
32
|
-
}) => void;
|
|
33
|
-
callToolAsync: (toolArgs: ToolArgs) => Promise<ToolResponse>;
|
|
34
|
-
status: "error";
|
|
35
|
-
isIdle: false;
|
|
36
|
-
isPending: false;
|
|
37
|
-
isSuccess: false;
|
|
38
|
-
isError: true;
|
|
39
|
-
data: undefined;
|
|
40
|
-
error: unknown;
|
|
41
|
-
} | {
|
|
42
|
-
callTool: (toolArgs: ToolArgs, sideEffects?: {
|
|
43
|
-
onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
|
|
44
|
-
onError?: (error: unknown, toolArgs: ToolArgs) => void;
|
|
45
|
-
}) => void;
|
|
46
|
-
callToolAsync: (toolArgs: ToolArgs) => Promise<ToolResponse>;
|
|
47
|
-
status: "success";
|
|
48
|
-
isIdle: false;
|
|
49
|
-
isPending: false;
|
|
50
|
-
isSuccess: true;
|
|
51
|
-
isError: false;
|
|
52
|
-
data: ToolResponse;
|
|
53
|
-
error: undefined;
|
|
54
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-call-tool.js","sourceRoot":"","sources":["../../../src/web/use-call-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA4BjC,MAAM,CAAC,MAAM,WAAW,GAAG,CAIzB,IAAY,EACZ,EAAE;IACF,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAK1D,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAEzD,MAAM,aAAa,GAAG,KAAK,EAAE,QAAkB,EAAE,EAAE;QACjD,gBAAgB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CACvC,IAAI,EACJ,QAAQ,CACT,CAAC;YACF,gBAAgB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAEhE,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,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