skybridge 0.0.0-dev.e2cf49b → 0.0.0-dev.e3e0986
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/README.md +122 -0
- package/dist/src/server/index.d.ts +2 -0
- package/dist/src/server/inferUtilityTypes.d.ts +33 -0
- package/dist/src/server/inferUtilityTypes.js +2 -0
- package/dist/src/server/inferUtilityTypes.js.map +1 -0
- package/dist/src/server/server.d.ts +13 -7
- package/dist/src/server/server.js +5 -1
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/test/utils.js +1 -1
- package/dist/src/test/utils.js.map +1 -1
- package/dist/src/web/hooks/index.d.ts +2 -1
- package/dist/src/web/hooks/index.js +2 -1
- package/dist/src/web/hooks/index.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.d.ts +16 -16
- package/dist/src/web/hooks/use-call-tool.js +12 -10
- package/dist/src/web/hooks/use-call-tool.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.test.js +61 -2
- package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/src/web/hooks/use-files.d.ts +10 -0
- package/dist/src/web/hooks/use-files.js +7 -0
- package/dist/src/web/hooks/use-files.js.map +1 -0
- package/dist/src/web/hooks/use-files.test.js +29 -0
- package/dist/src/web/hooks/use-files.test.js.map +1 -0
- package/dist/src/web/hooks/use-openai-global.js +3 -1
- package/dist/src/web/hooks/use-openai-global.js.map +1 -1
- package/dist/src/web/hooks/use-request-modal.d.ts +3 -2
- package/dist/src/web/hooks/use-request-modal.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +24 -4
- package/dist/src/web/hooks/use-tool-info.js +17 -4
- package/dist/src/web/hooks/use-tool-info.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test-d.d.ts +1 -0
- package/dist/src/web/hooks/use-tool-info.test-d.js +74 -0
- package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -0
- package/dist/src/web/hooks/use-tool-info.test.js +36 -15
- package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/src/web/hooks/use-tool-output.d.ts +1 -1
- package/dist/src/web/hooks/use-widget-state.test.js +0 -1
- package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
- package/dist/src/web/index.d.ts +1 -0
- package/dist/src/web/index.js +1 -0
- package/dist/src/web/index.js.map +1 -1
- package/dist/src/web/mount-widget.js +5 -0
- package/dist/src/web/mount-widget.js.map +1 -1
- package/dist/src/web/proxy.d.ts +1 -0
- package/dist/src/web/proxy.js +48 -0
- package/dist/src/web/proxy.js.map +1 -0
- package/dist/src/web/typed-hooks.d.ts +61 -0
- package/dist/src/web/typed-hooks.js +61 -0
- package/dist/src/web/typed-hooks.js.map +1 -0
- package/dist/src/web/typed-hooks.test-d.d.ts +1 -0
- package/dist/src/web/typed-hooks.test-d.js +72 -0
- package/dist/src/web/typed-hooks.test-d.js.map +1 -0
- package/dist/src/web/typed-hooks.test.d.ts +1 -0
- package/dist/src/web/typed-hooks.test.js +10 -0
- package/dist/src/web/typed-hooks.test.js.map +1 -0
- package/dist/src/web/types.d.ts +29 -20
- 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 +4 -2
- package/dist/src/test/setup.js +0 -9
- package/dist/src/test/setup.js.map +0 -1
- /package/dist/src/{test/setup.d.ts → web/hooks/use-files.test.d.ts} +0 -0
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
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
|
+
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> = {}>(): ToolState<UnknownObject & TS["input"], UnknownObject & TS["output"], UnknownObject & TS["responseMetadata"]>;
|
|
25
|
+
export {};
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { useOpenAiGlobal } from "
|
|
1
|
+
import { useOpenAiGlobal } from "./use-openai-global.js";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
2
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]);
|
|
3
13
|
return {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
14
|
+
input,
|
|
15
|
+
status,
|
|
16
|
+
isPending: status === "pending",
|
|
17
|
+
isSuccess: status === "success",
|
|
18
|
+
output,
|
|
19
|
+
responseMetadata,
|
|
7
20
|
};
|
|
8
21
|
}
|
|
9
22
|
//# sourceMappingURL=use-tool-info.js.map
|
|
@@ -1 +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,
|
|
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;AAuC5C,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;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,74 @@
|
|
|
1
|
+
import { expectTypeOf, test } from "vitest";
|
|
2
|
+
import { renderHook } from "@testing-library/react";
|
|
3
|
+
import { useToolInfo } from "./use-tool-info.js";
|
|
4
|
+
test("useToolInfo - TypeScript typing", () => {
|
|
5
|
+
test("should have correct types when no generic parameter is provided", () => {
|
|
6
|
+
const result = useToolInfo();
|
|
7
|
+
expectTypeOf(result.status);
|
|
8
|
+
expectTypeOf(result.isPending);
|
|
9
|
+
expectTypeOf(result.isSuccess);
|
|
10
|
+
expectTypeOf(result.input);
|
|
11
|
+
});
|
|
12
|
+
test("should correctly type input, output, and responseMetadata with explicit ToolSignature", () => {
|
|
13
|
+
const result = useToolInfo();
|
|
14
|
+
expectTypeOf(result.input);
|
|
15
|
+
// When pending, output and responseMetadata should be undefined
|
|
16
|
+
if (result.status === "pending") {
|
|
17
|
+
expectTypeOf(result.output);
|
|
18
|
+
expectTypeOf(result.responseMetadata);
|
|
19
|
+
}
|
|
20
|
+
// When success, output and responseMetadata should be defined
|
|
21
|
+
if (result.status === "success") {
|
|
22
|
+
expectTypeOf(result.output);
|
|
23
|
+
expectTypeOf(result.responseMetadata);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
test("should correctly narrow types based on status discriminated union", () => {
|
|
27
|
+
const result = useToolInfo();
|
|
28
|
+
// Test type narrowing
|
|
29
|
+
if (result.isPending) {
|
|
30
|
+
expectTypeOf(result.status);
|
|
31
|
+
expectTypeOf(result.isPending);
|
|
32
|
+
expectTypeOf(result.isSuccess);
|
|
33
|
+
expectTypeOf(result.output);
|
|
34
|
+
expectTypeOf(result.responseMetadata);
|
|
35
|
+
}
|
|
36
|
+
if (result.isSuccess) {
|
|
37
|
+
expectTypeOf(result.status);
|
|
38
|
+
expectTypeOf(result.isPending);
|
|
39
|
+
expectTypeOf(result.isSuccess);
|
|
40
|
+
expectTypeOf(result.output);
|
|
41
|
+
expectTypeOf(result.responseMetadata);
|
|
42
|
+
}
|
|
43
|
+
if (result.status === "pending") {
|
|
44
|
+
expectTypeOf(result.input);
|
|
45
|
+
expectTypeOf(result.isPending);
|
|
46
|
+
expectTypeOf(result.isSuccess);
|
|
47
|
+
expectTypeOf(result.output);
|
|
48
|
+
expectTypeOf(result.responseMetadata);
|
|
49
|
+
}
|
|
50
|
+
if (result.status === "success") {
|
|
51
|
+
expectTypeOf(result.input);
|
|
52
|
+
expectTypeOf(result.isPending);
|
|
53
|
+
expectTypeOf(result.isSuccess);
|
|
54
|
+
expectTypeOf(result.output);
|
|
55
|
+
expectTypeOf(result.responseMetadata);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
test("should handle partial ToolSignature with only input specified", () => {
|
|
59
|
+
const result = useToolInfo();
|
|
60
|
+
expectTypeOf(result.input);
|
|
61
|
+
if (result.status === "success") {
|
|
62
|
+
expectTypeOf(result.output);
|
|
63
|
+
expectTypeOf(result.responseMetadata);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
test("should handle ToolSignature with only output specified", () => {
|
|
67
|
+
const result = useToolInfo();
|
|
68
|
+
expectTypeOf(result.input);
|
|
69
|
+
if (result.status === "success") {
|
|
70
|
+
expectTypeOf(result.output);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//# 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,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,IAAI,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC3C,IAAI,CAAC,iEAAiE,EAAE,GAAG,EAAE;QAC3E,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;QAE7B,YAAY,CAAwB,MAAM,CAAC,MAAM,CAAC,CAAC;QACnD,YAAY,CAAU,MAAM,CAAC,SAAS,CAAC,C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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"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { renderHook } from "@testing-library/react";
|
|
1
|
+
import { fireEvent, renderHook, waitFor, act } 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,43 @@ 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
|
-
expect(result.current
|
|
25
|
-
name: "pikachu",
|
|
26
|
-
|
|
21
|
+
expect(result.current).toMatchObject({
|
|
22
|
+
input: { name: "pokemon", args: { name: "pikachu" } },
|
|
23
|
+
status: "pending",
|
|
24
|
+
isPending: true,
|
|
25
|
+
isSuccess: false,
|
|
27
26
|
});
|
|
28
|
-
|
|
27
|
+
});
|
|
28
|
+
it("should eventually return tool output and response metadata once tool call completes", async () => {
|
|
29
|
+
const toolOutput = {
|
|
29
30
|
name: "pikachu",
|
|
30
31
|
color: "yellow",
|
|
31
32
|
description: "When several of these POKéMON gather, their\felectricity could build and cause lightning storms.",
|
|
33
|
+
};
|
|
34
|
+
const toolResponseMetadata = { id: 12 };
|
|
35
|
+
const { result } = renderHook(() => useToolInfo());
|
|
36
|
+
act(() => {
|
|
37
|
+
OpenaiMock.toolOutput = toolOutput;
|
|
38
|
+
OpenaiMock.toolResponseMetadata = toolResponseMetadata;
|
|
39
|
+
fireEvent(window, new SetGlobalsEvent(SET_GLOBALS_EVENT_TYPE, {
|
|
40
|
+
detail: {
|
|
41
|
+
globals: {
|
|
42
|
+
toolOutput,
|
|
43
|
+
toolResponseMetadata,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}));
|
|
32
47
|
});
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
await waitFor(() => {
|
|
49
|
+
expect(result.current).toMatchObject({
|
|
50
|
+
status: "success",
|
|
51
|
+
isPending: false,
|
|
52
|
+
isSuccess: true,
|
|
53
|
+
output: toolOutput,
|
|
54
|
+
responseMetadata: toolResponseMetadata,
|
|
55
|
+
});
|
|
35
56
|
});
|
|
36
57
|
});
|
|
37
58
|
});
|
|
@@ -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,GAAG,EAAE,MAAM,wBAAwB,CAAC;A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AQ;YACf,WAAW,EACT,kGAAkG;SACrG,CAAC;QACF,MAAM,oBAAoB,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;QACxC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QAEnD,GAAG,CAAC,GAAG,EAAE;YACP,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC;YACnC,UAAU,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;YACvD,SAAS,CACP,MAAM,EACN,IAAI,eAAe,CAAC,sBAAsB,EAAE;gBAC1C,MAAM,EAAE;oBACN,OAAO,EAAE;wBACP,UAAU;wBACV,oBAAoB;qBACrB;iBACF;aACF,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;gBACnC,MAAM,EAAE,SAAS;gBACjB,SAAS,EAAE,KAAK;gBAChB,SAAS,EAAE,IAAI;gBACf,MAAM,EAAE,UAAU;gBAClB,gBAAgB,EAAE,oBAAoB;aACvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `output` property.
|
|
3
3
|
*/
|
|
4
|
-
export declare function useToolOutput(): import("../types.js").UnknownObject |
|
|
4
|
+
export declare function useToolOutput(): import("../types.js").UnknownObject | undefined;
|
|
@@ -44,7 +44,6 @@ describe("useWidgetState", () => {
|
|
|
44
44
|
count: 1,
|
|
45
45
|
name: "test",
|
|
46
46
|
});
|
|
47
|
-
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", () => {
|
|
@@ -1 +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,CAAC,YAAY,CAAC,CAAC,CAAC;QAElE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,Y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AElE,GAAG,CAAC,GAAG,EAAE;YACP,MAAM,CAAC,OAAO,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
package/dist/src/web/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
1
2
|
import { createElement, StrictMode } from "react";
|
|
2
3
|
import { createRoot } from "react-dom/client";
|
|
4
|
+
import { installOpenAILoggingProxy } from "./proxy.js";
|
|
3
5
|
let rootInstance = null;
|
|
4
6
|
export const mountWidget = (component) => {
|
|
5
7
|
const rootElement = document.getElementById("root");
|
|
@@ -9,6 +11,9 @@ export const mountWidget = (component) => {
|
|
|
9
11
|
if (!rootInstance) {
|
|
10
12
|
rootInstance = createRoot(rootElement);
|
|
11
13
|
}
|
|
14
|
+
if (import.meta.env.DEV) {
|
|
15
|
+
installOpenAILoggingProxy();
|
|
16
|
+
}
|
|
12
17
|
rootInstance.render(createElement(StrictMode, null, component));
|
|
13
18
|
};
|
|
14
19
|
//# sourceMappingURL=mount-widget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-widget.js","sourceRoot":"","sources":["../../../src/web/mount-widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"mount-widget.js","sourceRoot":"","sources":["../../../src/web/mount-widget.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,IAAI,YAAY,GAAgB,IAAI,CAAC;AAErC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,SAA0B,EAAE,EAAE;IACxD,MAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACxB,yBAAyB,EAAE,CAAC;IAC9B,CAAC;IAED,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAClE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function installOpenAILoggingProxy(): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const colors = {
|
|
2
|
+
brand: "#6366f1",
|
|
3
|
+
info: "#22223b",
|
|
4
|
+
success: "#22c55e",
|
|
5
|
+
error: "#ef4444",
|
|
6
|
+
};
|
|
7
|
+
export function installOpenAILoggingProxy() {
|
|
8
|
+
if (typeof window === "undefined" || !window.openai) {
|
|
9
|
+
console.warn("[openai-proxy] window.openai not found, skipping proxy installation");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const originalOpenAI = window.openai;
|
|
13
|
+
const handler = {
|
|
14
|
+
get(target, prop, receiver) {
|
|
15
|
+
const value = Reflect.get(target, prop, receiver);
|
|
16
|
+
if (typeof value !== "function") {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
return function (...args) {
|
|
20
|
+
const methodName = String(prop);
|
|
21
|
+
console.group(`%c[openai] %cmethod %c${methodName}`, `color: ${colors.brand}; font-weight: normal`, `color: ${colors.info}; font-weight: normal`, `color: ${colors.success}`);
|
|
22
|
+
console.log("%c← args:", `color: ${colors.info}`, args);
|
|
23
|
+
const result = value.apply(target, args);
|
|
24
|
+
if (result && typeof result.then === "function") {
|
|
25
|
+
return result.then((resolved) => {
|
|
26
|
+
console.log("%c→ resolved:", `color: ${colors.success}`, resolved);
|
|
27
|
+
console.groupEnd();
|
|
28
|
+
return resolved;
|
|
29
|
+
}, (error) => {
|
|
30
|
+
console.error("%c→ rejected:", `color: ${colors.error}`, error);
|
|
31
|
+
console.groupEnd();
|
|
32
|
+
throw error;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
console.log("%c→ returned:", `color: ${colors.success}`, result);
|
|
36
|
+
console.groupEnd();
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
set(target, prop, value, receiver) {
|
|
41
|
+
console.log(`%c[openai] %cupdate %c${String(prop)}`, `color: ${colors.brand}`, `color: ${colors.info}`, `color: ${colors.success}; font-weight: bold`, "←", value);
|
|
42
|
+
return Reflect.set(target, prop, value, receiver);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
window.openai = new Proxy(originalOpenAI, handler);
|
|
46
|
+
console.log("%c[openai-proxy] %cInstalled logging proxy for window.openai", `color: ${colors.brand}`, `color: ${colors.info}`);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/web/proxy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,O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AC;wBACnB,OAAO,QAAQ,CAAC;oBAClB,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;wBACjB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;wBAChE,OAAO,CAAC,QAAQ,EAAE,CAAC;wBACnB,MAAM,KAAK,CAAC;oBACd,CAAC,CACF,CAAC;gBACJ,CAAC;gBAED,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;gBACjE,OAAO,CAAC,QAAQ,EAAE,CAAC;gBAEnB,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC;QAED,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ;YAC/B,OAAO,CAAC,GAAG,CACT,yBAAyB,MAAM,CAAC,IAAI,CAAC,EAAE,EACvC,UAAU,MAAM,CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,EACvB,UAAU,MAAM,CAAC,OAAO,qBAAqB,EAC7C,GAAG,EACH,KAAK,CACN,CAAC;YAEF,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnD,OAAO,CAAC,GAAG,CACT,8DAA8D,EAC9D,UAAU,MAAM,CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useCallTool } from "./hooks/use-call-tool.js";
|
|
2
|
+
import type { ToolPendingState, ToolSuccessState } from "./hooks/use-tool-info.js";
|
|
3
|
+
import type { McpServer, InferWidgets, AnyWidgetRegistry, WidgetInput, WidgetOutput } from "../server/index.js";
|
|
4
|
+
import type { CallToolArgs, UnknownObject } from "./types.js";
|
|
5
|
+
type TypedCallToolReturn<TInput, TOutput> = ReturnType<typeof useCallTool<TInput & CallToolArgs, {
|
|
6
|
+
structuredContent: TOutput & UnknownObject;
|
|
7
|
+
}>>;
|
|
8
|
+
type TypedToolInfoReturn<TInput extends UnknownObject, TOutput extends UnknownObject, TResponseMetadata extends UnknownObject> = ToolPendingState<TInput> | ToolSuccessState<TInput, TOutput, TResponseMetadata>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates typed versions of skybridge hooks with full type inference
|
|
11
|
+
* for tool names, inputs, and outputs.
|
|
12
|
+
*
|
|
13
|
+
* Set this up once in a dedicated file and export the typed hooks:
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // web/src/skybridge.ts (one-time setup)
|
|
18
|
+
* import type { AppType } from "../server";
|
|
19
|
+
* import { createTypedHooks } from "skybridge/web";
|
|
20
|
+
*
|
|
21
|
+
* export const { useCallTool, useToolInfo } = createTypedHooks<AppType>();
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // web/src/widgets/search.tsx (usage)
|
|
26
|
+
* import { useCallTool, useToolInfo } from "../skybridge";
|
|
27
|
+
*
|
|
28
|
+
* export function SearchWidget() {
|
|
29
|
+
* const { callTool, data } = useCallTool("search");
|
|
30
|
+
* // ^ autocomplete for tool names
|
|
31
|
+
* callTool({ query: "test" });
|
|
32
|
+
* // ^ autocomplete for input fields
|
|
33
|
+
*
|
|
34
|
+
* const toolInfo = useToolInfo<"search">();
|
|
35
|
+
* // ^ autocomplete for tool names
|
|
36
|
+
* // toolInfo.input is typed based on widget input schema
|
|
37
|
+
* // toolInfo.output is typed based on widget output schema
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function createTypedHooks<T extends McpServer<AnyWidgetRegistry>>(): {
|
|
42
|
+
/**
|
|
43
|
+
* Typed version of useCallTool that provides autocomplete for tool names
|
|
44
|
+
* and type inference for inputs and outputs.
|
|
45
|
+
*/
|
|
46
|
+
useCallTool: <K extends keyof InferWidgets<T> & string>(name: K) => TypedCallToolReturn<InferWidgets<T>[K]["input"], InferWidgets<T>[K]["output"]>;
|
|
47
|
+
/**
|
|
48
|
+
* Typed version of useToolInfo that provides autocomplete for widget names
|
|
49
|
+
* and type inference for inputs, outputs, and responseMetadata.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const toolInfo = useToolInfo<"search-voyage">();
|
|
54
|
+
* // toolInfo.input is typed as { destination: string; ... }
|
|
55
|
+
* // toolInfo.output is typed as { results: Array<...>; ... } | undefined
|
|
56
|
+
* // toolInfo.status narrows correctly: "pending" | "success"
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
useToolInfo: <K extends keyof InferWidgets<T> & string>() => TypedToolInfoReturn<WidgetInput<T, K> & UnknownObject, WidgetOutput<T, K> & UnknownObject, UnknownObject>;
|
|
60
|
+
};
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useCallTool } from "./hooks/use-call-tool.js";
|
|
2
|
+
import { useToolInfo } from "./hooks/use-tool-info.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates typed versions of skybridge hooks with full type inference
|
|
5
|
+
* for tool names, inputs, and outputs.
|
|
6
|
+
*
|
|
7
|
+
* Set this up once in a dedicated file and export the typed hooks:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // web/src/skybridge.ts (one-time setup)
|
|
12
|
+
* import type { AppType } from "../server";
|
|
13
|
+
* import { createTypedHooks } from "skybridge/web";
|
|
14
|
+
*
|
|
15
|
+
* export const { useCallTool, useToolInfo } = createTypedHooks<AppType>();
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // web/src/widgets/search.tsx (usage)
|
|
20
|
+
* import { useCallTool, useToolInfo } from "../skybridge";
|
|
21
|
+
*
|
|
22
|
+
* export function SearchWidget() {
|
|
23
|
+
* const { callTool, data } = useCallTool("search");
|
|
24
|
+
* // ^ autocomplete for tool names
|
|
25
|
+
* callTool({ query: "test" });
|
|
26
|
+
* // ^ autocomplete for input fields
|
|
27
|
+
*
|
|
28
|
+
* const toolInfo = useToolInfo<"search">();
|
|
29
|
+
* // ^ autocomplete for tool names
|
|
30
|
+
* // toolInfo.input is typed based on widget input schema
|
|
31
|
+
* // toolInfo.output is typed based on widget output schema
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function createTypedHooks() {
|
|
36
|
+
return {
|
|
37
|
+
/**
|
|
38
|
+
* Typed version of useCallTool that provides autocomplete for tool names
|
|
39
|
+
* and type inference for inputs and outputs.
|
|
40
|
+
*/
|
|
41
|
+
useCallTool: (name) => {
|
|
42
|
+
return useCallTool(name);
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Typed version of useToolInfo that provides autocomplete for widget names
|
|
46
|
+
* and type inference for inputs, outputs, and responseMetadata.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const toolInfo = useToolInfo<"search-voyage">();
|
|
51
|
+
* // toolInfo.input is typed as { destination: string; ... }
|
|
52
|
+
* // toolInfo.output is typed as { results: Array<...>; ... } | undefined
|
|
53
|
+
* // toolInfo.status narrows correctly: "pending" | "success"
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
useToolInfo: () => {
|
|
57
|
+
return useToolInfo();
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=typed-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-hooks.js","sourceRoot":"","sources":["../../../src/web/typed-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAgCvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,gBAAgB;IAI9B,OAAO;QACL;;;WAGG;QACH,WAAW,EAAE,CACX,IAAO,EAIP,EAAE;YACF,OAAO,WAAW,CAGhB,IAAI,CAGL,CAAC;QACJ,CAAC;QACD;;;;;;;;;;;WAWG;QACH,WAAW,EAAE,GAIX,EAAE;YACF,OAAO,WAAW,EAQjB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { expectTypeOf, test } from "vitest";
|
|
2
|
+
import { createTypedHooks } from "./typed-hooks.js";
|
|
3
|
+
test("InferWidgets extracts the widget registry type", () => {
|
|
4
|
+
expectTypeOf().toHaveProperty("search-voyage");
|
|
5
|
+
expectTypeOf().toHaveProperty("get-trip-details");
|
|
6
|
+
expectTypeOf().toHaveProperty("no-input-widget");
|
|
7
|
+
});
|
|
8
|
+
test("WidgetNames returns a union of widget name literals", () => {
|
|
9
|
+
expectTypeOf().toEqualTypeOf();
|
|
10
|
+
});
|
|
11
|
+
test("WidgetInput extracts the correct input type from Zod schema", () => {
|
|
12
|
+
expectTypeOf().toEqualTypeOf();
|
|
13
|
+
expectTypeOf().toEqualTypeOf();
|
|
14
|
+
});
|
|
15
|
+
test("WidgetOutput extracts the correct output type from Zod schema", () => {
|
|
16
|
+
expectTypeOf().toEqualTypeOf();
|
|
17
|
+
expectTypeOf().toEqualTypeOf();
|
|
18
|
+
});
|
|
19
|
+
test("createTypedHooks provides autocomplete for widget names", () => {
|
|
20
|
+
const { useCallTool } = createTypedHooks();
|
|
21
|
+
useCallTool("search-voyage");
|
|
22
|
+
useCallTool("get-trip-details");
|
|
23
|
+
useCallTool("no-input-widget");
|
|
24
|
+
// @ts-expect-error - "invalid-name" is not a valid widget name
|
|
25
|
+
useCallTool("invalid-name");
|
|
26
|
+
});
|
|
27
|
+
test("useCallTool returns correctly typed callTool function", () => {
|
|
28
|
+
const { useCallTool } = createTypedHooks();
|
|
29
|
+
const { callTool } = useCallTool("search-voyage");
|
|
30
|
+
callTool({ destination: "Spain" });
|
|
31
|
+
callTool({ destination: "France", departureDate: "2024-06-01" });
|
|
32
|
+
callTool({ destination: "Italy", maxPrice: 1000 });
|
|
33
|
+
});
|
|
34
|
+
test("useCallTool returns correctly typed data", () => {
|
|
35
|
+
const { useCallTool } = createTypedHooks();
|
|
36
|
+
const { data } = useCallTool("search-voyage");
|
|
37
|
+
if (data) {
|
|
38
|
+
expectTypeOf(data.structuredContent).toExtend();
|
|
39
|
+
expectTypeOf(data.structuredContent.results).toBeArray();
|
|
40
|
+
expectTypeOf(data.structuredContent.totalCount).toBeNumber();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
test("widgets with no outputSchema have empty object output type", () => {
|
|
44
|
+
expectTypeOf().toEqualTypeOf();
|
|
45
|
+
});
|
|
46
|
+
test("createTypedHooks provides autocomplete for widget names in useToolInfo", () => {
|
|
47
|
+
const { useToolInfo } = createTypedHooks();
|
|
48
|
+
useToolInfo();
|
|
49
|
+
useToolInfo();
|
|
50
|
+
useToolInfo();
|
|
51
|
+
// @ts-expect-error - "invalid-name" is not a valid widget name
|
|
52
|
+
useToolInfo();
|
|
53
|
+
});
|
|
54
|
+
test("useToolInfo infers input types from WidgetInput utility", () => {
|
|
55
|
+
const { useToolInfo } = createTypedHooks();
|
|
56
|
+
const toolInfo = useToolInfo();
|
|
57
|
+
expectTypeOf(toolInfo.input).toExtend();
|
|
58
|
+
const detailsInfo = useToolInfo();
|
|
59
|
+
expectTypeOf(detailsInfo.input).toExtend();
|
|
60
|
+
});
|
|
61
|
+
test("useToolInfo infers output types from WidgetOutput utility", () => {
|
|
62
|
+
const { useToolInfo } = createTypedHooks();
|
|
63
|
+
const toolInfo = useToolInfo();
|
|
64
|
+
if (toolInfo.status === "success") {
|
|
65
|
+
expectTypeOf(toolInfo.output).toExtend();
|
|
66
|
+
}
|
|
67
|
+
const detailsInfo = useToolInfo();
|
|
68
|
+
if (detailsInfo.status === "success") {
|
|
69
|
+
expectTypeOf(detailsInfo.output).toExtend();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=typed-hooks.test-d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-hooks.test-d.js","sourceRoot":"","sources":["../../../src/web/typed-hooks.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAuCpD,IAAI,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAG1D,YAAY,EAAW,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IACxD,YAAY,EAAW,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAC3D,YAAY,EAAW,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,qDAAqD,EAAE,GAAG,EAAE;IAG/D,YAAY,EAAS,CAAC,aAAa,EAEhC,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,6DAA6D,EAAE,GAAG,EAAE;IAGvE,YAAY,EAAe,CAAC,aAAa,EAIrC,CAAC;IAIL,YAAY,EAAgB,CAAC,aAAa,EAEtC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,+DAA+D,EAAE,GAAG,EAAE;IAGzE,YAAY,EAAgB,CAAC,aAAa,EAOtC,CAAC;IAIL,YAAY,EAAiB,CAAC,aAAa,EAIvC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH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import { describe, expect, it } from "vitest";
|
|
2
|
+
import { createTypedHooks } from "./typed-hooks.js";
|
|
3
|
+
describe("createTypedHooks", () => {
|
|
4
|
+
it("should return an object with useCallTool hook", () => {
|
|
5
|
+
const hooks = createTypedHooks();
|
|
6
|
+
expect(hooks).toHaveProperty("useCallTool");
|
|
7
|
+
expect(typeof hooks.useCallTool).toBe("function");
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=typed-hooks.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-hooks.test.js","sourceRoot":"","sources":["../../../src/web/typed-hooks.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAYpD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,KAAK,GAAG,gBAAgB,EAAc,CAAC;QAC7C,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|