skybridge 0.0.0-dev.d7157b3 → 0.0.0-dev.d8535f2
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.
|
@@ -10,5 +10,9 @@ type BaseToolState<TStatus extends "pending" | "success", ToolInput extends Unkn
|
|
|
10
10
|
type PendingToolState<ToolInput extends UnknownObject> = BaseToolState<"pending", ToolInput>;
|
|
11
11
|
type SuccessToolState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = BaseToolState<"success", ToolInput, ToolOutput, ToolResponseMetadata>;
|
|
12
12
|
type ToolState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = PendingToolState<ToolInput> | SuccessToolState<ToolInput, ToolOutput, ToolResponseMetadata>;
|
|
13
|
-
export declare function useToolInfo<
|
|
13
|
+
export declare function useToolInfo<ToolSignature extends Partial<{
|
|
14
|
+
input: UnknownObject;
|
|
15
|
+
output: UnknownObject;
|
|
16
|
+
responseMetadata: UnknownObject;
|
|
17
|
+
}>>(): ToolState<ToolSignature["input"] extends UnknownObject ? ToolSignature["input"] : {}, ToolSignature["output"] extends UnknownObject ? ToolSignature["output"] : UnknownObject, ToolSignature["responseMetadata"] extends UnknownObject ? ToolSignature["responseMetadata"] : UnknownObject>;
|
|
14
18
|
export {};
|
|
@@ -1 +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,eAAe,EAAsB,MAAM,eAAe,CAAC;AAoCpE,MAAM,UAAU,WAAW;
|
|
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,eAAe,EAAsB,MAAM,eAAe,CAAC;AAoCpE,MAAM,UAAU,WAAW;IAOzB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAwB,SAAS,CAAC,CAAC;IACvE,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;IAE/B,OAAO;QACL,KAAK,EAAE,eAAe,CAAC,WAAW,CAAE;QACpC,MAAM;QACN,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,MAAM;QACN,gBAAgB;KASjB,CAAC;AACJ,CAAC"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { renderHook } from "@testing-library/react";
|
|
1
|
+
import { fireEvent, renderHook, waitFor } from "@testing-library/react";
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
3
|
import { useToolInfo } from "./use-tool-info.js";
|
|
4
|
+
import { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, } from "../types.js";
|
|
4
5
|
describe("useToolInfo", () => {
|
|
5
6
|
let OpenaiMock;
|
|
6
7
|
beforeEach(() => {
|
|
7
8
|
OpenaiMock = {
|
|
8
|
-
toolInput: { name: "
|
|
9
|
-
toolOutput:
|
|
10
|
-
|
|
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 },
|
|
9
|
+
toolInput: { name: "pokemon", args: { name: "pikachu" } },
|
|
10
|
+
toolOutput: null,
|
|
11
|
+
toolResponseMetadata: null,
|
|
15
12
|
};
|
|
16
13
|
vi.stubGlobal("openai", OpenaiMock);
|
|
17
14
|
});
|
|
@@ -19,19 +16,42 @@ describe("useToolInfo", () => {
|
|
|
19
16
|
vi.unstubAllGlobals();
|
|
20
17
|
vi.resetAllMocks();
|
|
21
18
|
});
|
|
22
|
-
it("should return toolInput
|
|
19
|
+
it("should return toolInput on initial mount window.openai", () => {
|
|
23
20
|
const { result } = renderHook(() => useToolInfo());
|
|
24
21
|
expect(result.current.input).toEqual({
|
|
25
|
-
name: "
|
|
26
|
-
args: {
|
|
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.",
|
|
22
|
+
name: "pokemon",
|
|
23
|
+
args: { name: "pikachu" },
|
|
32
24
|
});
|
|
33
|
-
expect(result.current.
|
|
34
|
-
|
|
25
|
+
expect(result.current.status).toEqual("pending");
|
|
26
|
+
expect(result.current.isPending).toEqual(true);
|
|
27
|
+
expect(result.current.isSuccess).toEqual(false);
|
|
28
|
+
expect(result.current.output).toEqual(undefined);
|
|
29
|
+
expect(result.current.responseMetadata).toEqual(undefined);
|
|
30
|
+
});
|
|
31
|
+
it("should eventually return tool output and response metadata once tool call completes", () => {
|
|
32
|
+
const { result } = renderHook(() => useToolInfo());
|
|
33
|
+
fireEvent(window, new SetGlobalsEvent(SET_GLOBALS_EVENT_TYPE, {
|
|
34
|
+
detail: {
|
|
35
|
+
globals: {
|
|
36
|
+
toolOutput: {
|
|
37
|
+
name: "pikachu",
|
|
38
|
+
color: "yellow",
|
|
39
|
+
description: "When several of these POKéMON gather, their\felectricity could build and cause lightning storms.",
|
|
40
|
+
},
|
|
41
|
+
toolResponseMetadata: { id: 12 },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
waitFor(() => {
|
|
46
|
+
expect(result.current.status).toEqual("success");
|
|
47
|
+
expect(result.current.isPending).toEqual(false);
|
|
48
|
+
expect(result.current.isSuccess).toEqual(true);
|
|
49
|
+
expect(result.current.output).toEqual({
|
|
50
|
+
name: "pikachu",
|
|
51
|
+
color: "yellow",
|
|
52
|
+
description: "When several of these POKéMON gather, their\felectricity could build and cause lightning storms.",
|
|
53
|
+
});
|
|
54
|
+
expect(result.current.responseMetadata).toEqual({ id: 12 });
|
|
35
55
|
});
|
|
36
56
|
});
|
|
37
57
|
});
|
|
@@ -1 +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;
|
|
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,MAAM,wBAAwB,CAAC;AACxE,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,GAAG,EAAE;QACd,UAAU,GAAG;YACX,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;YACzD,UAAU,EAAE,IAAI;YAChB,oBAAoB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