skybridge 0.0.0-dev.6ca41d7 → 0.0.0-dev.6de743f
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/web/hooks/use-call-tool.d.ts +11 -11
- package/dist/src/web/hooks/use-call-tool.js +8 -6
- package/dist/src/web/hooks/use-call-tool.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +5 -3
- 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 +1 -75
- package/dist/src/web/hooks/use-tool-info.test.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 +45 -0
- package/dist/src/web/proxy.js.map +1 -0
- package/dist/src/web/types.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { CallToolArgs, CallToolResponse } from "../types.js";
|
|
2
|
-
type CallToolResponseConstraint = Partial<Pick<CallToolResponse, "structuredContent" | "meta">>;
|
|
3
2
|
type SideEffects<ToolArgs, ToolResponse> = {
|
|
4
3
|
onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
|
|
5
4
|
onError?: (error: unknown, toolArgs: ToolArgs) => void;
|
|
6
5
|
onSettled?: (data: ToolResponse | undefined, error: unknown | undefined, toolArgs: ToolArgs) => void;
|
|
7
6
|
};
|
|
8
|
-
type CallToolAsyncFn<
|
|
9
|
-
|
|
7
|
+
type CallToolAsyncFn<ToolArgs, ToolResponse> = ToolArgs extends null ? () => Promise<ToolResponse> : (toolArgs: ToolArgs) => Promise<ToolResponse>;
|
|
8
|
+
type ToolResponseSignature = Pick<CallToolResponse, "structuredContent" | "meta">;
|
|
9
|
+
export declare const useCallTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends Partial<ToolResponseSignature> = {}>(name: string) => {
|
|
10
10
|
callTool: {
|
|
11
|
-
(sideEffects?: SideEffects<ToolArgs, ToolResponse>): void;
|
|
12
|
-
(toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, ToolResponse>): void;
|
|
11
|
+
(sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
|
|
12
|
+
(toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
|
|
13
13
|
};
|
|
14
14
|
callToolAsync: CallToolAsyncFn<ToolArgs, CallToolResponse & ToolResponse>;
|
|
15
15
|
status: "idle";
|
|
@@ -21,8 +21,8 @@ export declare const useCallTool: <ToolArgs extends CallToolArgs = null, ToolRes
|
|
|
21
21
|
error: undefined;
|
|
22
22
|
} | {
|
|
23
23
|
callTool: {
|
|
24
|
-
(sideEffects?: SideEffects<ToolArgs, ToolResponse>): void;
|
|
25
|
-
(toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, ToolResponse>): void;
|
|
24
|
+
(sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
|
|
25
|
+
(toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
|
|
26
26
|
};
|
|
27
27
|
callToolAsync: CallToolAsyncFn<ToolArgs, CallToolResponse & ToolResponse>;
|
|
28
28
|
status: "pending";
|
|
@@ -34,8 +34,8 @@ export declare const useCallTool: <ToolArgs extends CallToolArgs = null, ToolRes
|
|
|
34
34
|
error: undefined;
|
|
35
35
|
} | {
|
|
36
36
|
callTool: {
|
|
37
|
-
(sideEffects?: SideEffects<ToolArgs, ToolResponse>): void;
|
|
38
|
-
(toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, ToolResponse>): void;
|
|
37
|
+
(sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
|
|
38
|
+
(toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
|
|
39
39
|
};
|
|
40
40
|
callToolAsync: CallToolAsyncFn<ToolArgs, CallToolResponse & ToolResponse>;
|
|
41
41
|
status: "error";
|
|
@@ -47,8 +47,8 @@ export declare const useCallTool: <ToolArgs extends CallToolArgs = null, ToolRes
|
|
|
47
47
|
error: unknown;
|
|
48
48
|
} | {
|
|
49
49
|
callTool: {
|
|
50
|
-
(sideEffects?: SideEffects<ToolArgs, ToolResponse>): void;
|
|
51
|
-
(toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, ToolResponse>): void;
|
|
50
|
+
(sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
|
|
51
|
+
(toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
|
|
52
52
|
};
|
|
53
53
|
callToolAsync: CallToolAsyncFn<ToolArgs, CallToolResponse & ToolResponse>;
|
|
54
54
|
status: "success";
|
|
@@ -19,16 +19,18 @@ export const useCallTool = (name) => {
|
|
|
19
19
|
}
|
|
20
20
|
return execute(toolArgs);
|
|
21
21
|
});
|
|
22
|
-
function callTool(
|
|
22
|
+
function callTool(firstArg, sideEffects) {
|
|
23
23
|
let toolArgs;
|
|
24
|
-
if (
|
|
25
|
-
typeof
|
|
26
|
-
("onSuccess" in
|
|
24
|
+
if (firstArg &&
|
|
25
|
+
typeof firstArg === "object" &&
|
|
26
|
+
("onSuccess" in firstArg ||
|
|
27
|
+
"onError" in firstArg ||
|
|
28
|
+
"onSettled" in firstArg)) {
|
|
27
29
|
toolArgs = null; // no toolArgs provided
|
|
28
|
-
sideEffects =
|
|
30
|
+
sideEffects = firstArg;
|
|
29
31
|
}
|
|
30
32
|
else {
|
|
31
|
-
toolArgs = (
|
|
33
|
+
toolArgs = (firstArg === undefined ? null : firstArg);
|
|
32
34
|
}
|
|
33
35
|
execute(toolArgs)
|
|
34
36
|
.then((data) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-call-tool.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-call-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"use-call-tool.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-call-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAoEjC,MAAM,CAAC,MAAM,WAAW,GAAG,CAIzB,IAAY,EACZ,EAAE;IAGF,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,OAAO,GAAG,KAAK,EACnB,QAAkB,EACiB,EAAE;QACrC,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,CAGvC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAClB,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,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;YAC9D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,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AAC;YACpD,CAAC;QACH,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,aAAa,GAAG;QACpB,MAAM;QACN,IAAI;QACJ,KAAK;QACL,MAAM,EAAE,MAAM,KAAK,MAAM;QACzB,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,OAAO,EAAE,MAAM,KAAK,OAAO;KACe,CAAC;IAE7C,OAAO;QACL,GAAG,aAAa;QAChB,QAAQ;QACR,aAAa;KACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { UnknownObject } from "../types.js";
|
|
2
|
-
type
|
|
2
|
+
type ToolPendingState<ToolInput extends UnknownObject> = {
|
|
3
3
|
status: "pending";
|
|
4
4
|
isPending: true;
|
|
5
5
|
isSuccess: false;
|
|
6
6
|
input: ToolInput;
|
|
7
7
|
output: undefined;
|
|
8
8
|
responseMetadata: undefined;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
|
+
type ToolSuccessState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = {
|
|
10
11
|
status: "success";
|
|
11
12
|
isPending: false;
|
|
12
13
|
isSuccess: true;
|
|
@@ -14,10 +15,11 @@ type ToolState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject
|
|
|
14
15
|
output: ToolOutput;
|
|
15
16
|
responseMetadata: ToolResponseMetadata;
|
|
16
17
|
};
|
|
18
|
+
type ToolState<ToolInput extends UnknownObject, ToolOutput extends UnknownObject, ToolResponseMetadata extends UnknownObject> = ToolPendingState<ToolInput> | ToolSuccessState<ToolInput, ToolOutput, ToolResponseMetadata>;
|
|
17
19
|
type ToolSignature = {
|
|
18
20
|
input: UnknownObject;
|
|
19
21
|
output: UnknownObject;
|
|
20
22
|
responseMetadata: UnknownObject;
|
|
21
23
|
};
|
|
22
|
-
export declare function useToolInfo<TS extends Partial<ToolSignature> = {}>(): ToolState<
|
|
24
|
+
export declare function useToolInfo<TS extends Partial<ToolSignature> = {}>(): ToolState<UnknownObject & TS["input"], UnknownObject & TS["output"], UnknownObject & TS["responseMetadata"]>;
|
|
23
25
|
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,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
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,iEA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C,CAAC;IAEH,IAAI,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAGlE,MAAM,MAAM,GAAG,WAAW,EAEtB,CAAC;QAEL,YAAY,CAA0B,MAAM,CAAC,KAAK,CAAC,CAAC;QAEpD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAAa,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fireEvent, renderHook, waitFor, act } from "@testing-library/react";
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, it, vi
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
3
|
import { useToolInfo } from "./use-tool-info.js";
|
|
4
4
|
import { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, } from "../types.js";
|
|
5
5
|
describe("useToolInfo", () => {
|
|
@@ -56,78 +56,4 @@ describe("useToolInfo", () => {
|
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
-
describe("useToolInfo - TypeScript typing", () => {
|
|
60
|
-
it("should have correct types when no generic parameter is provided", () => {
|
|
61
|
-
const { result } = renderHook(() => useToolInfo());
|
|
62
|
-
expectTypeOf(result.current.status);
|
|
63
|
-
expectTypeOf(result.current.isPending);
|
|
64
|
-
expectTypeOf(result.current.isSuccess);
|
|
65
|
-
expectTypeOf(result.current.input);
|
|
66
|
-
});
|
|
67
|
-
it("should correctly type input, output, and responseMetadata with explicit ToolSignature", () => {
|
|
68
|
-
const { result } = renderHook(() => useToolInfo());
|
|
69
|
-
expectTypeOf(result.current.input);
|
|
70
|
-
// When pending, output and responseMetadata should be undefined
|
|
71
|
-
if (result.current.status === "pending") {
|
|
72
|
-
expectTypeOf(result.current.output);
|
|
73
|
-
expectTypeOf(result.current.responseMetadata);
|
|
74
|
-
expectTypeOf(result.current.isPending);
|
|
75
|
-
expectTypeOf(result.current.isSuccess);
|
|
76
|
-
}
|
|
77
|
-
// When success, output and responseMetadata should be defined
|
|
78
|
-
if (result.current.status === "success") {
|
|
79
|
-
expectTypeOf(result.current.output);
|
|
80
|
-
expectTypeOf(result.current.responseMetadata);
|
|
81
|
-
expectTypeOf(result.current.isPending);
|
|
82
|
-
expectTypeOf(result.current.isSuccess);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
it("should correctly narrow types based on status discriminated union", () => {
|
|
86
|
-
const { result } = renderHook(() => useToolInfo());
|
|
87
|
-
// Test type narrowing
|
|
88
|
-
if (result.current.isPending) {
|
|
89
|
-
expectTypeOf(result.current.status);
|
|
90
|
-
expectTypeOf(result.current.isPending);
|
|
91
|
-
expectTypeOf(result.current.isSuccess);
|
|
92
|
-
expectTypeOf(result.current.output);
|
|
93
|
-
expectTypeOf(result.current.responseMetadata);
|
|
94
|
-
}
|
|
95
|
-
if (result.current.isSuccess) {
|
|
96
|
-
expectTypeOf(result.current.status);
|
|
97
|
-
expectTypeOf(result.current.isPending);
|
|
98
|
-
expectTypeOf(result.current.isSuccess);
|
|
99
|
-
expectTypeOf(result.current.output);
|
|
100
|
-
expectTypeOf(result.current.responseMetadata);
|
|
101
|
-
}
|
|
102
|
-
if (result.current.status === "pending") {
|
|
103
|
-
expectTypeOf(result.current.input);
|
|
104
|
-
expectTypeOf(result.current.isPending);
|
|
105
|
-
expectTypeOf(result.current.isSuccess);
|
|
106
|
-
expectTypeOf(result.current.output);
|
|
107
|
-
expectTypeOf(result.current.responseMetadata);
|
|
108
|
-
}
|
|
109
|
-
if (result.current.status === "success") {
|
|
110
|
-
expectTypeOf(result.current.input);
|
|
111
|
-
expectTypeOf(result.current.isPending);
|
|
112
|
-
expectTypeOf(result.current.isSuccess);
|
|
113
|
-
expectTypeOf(result.current.output);
|
|
114
|
-
expectTypeOf(result.current.responseMetadata);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
it("should handle partial ToolSignature with only input specified", () => {
|
|
118
|
-
const { result } = renderHook(() => useToolInfo());
|
|
119
|
-
expectTypeOf(result.current.input);
|
|
120
|
-
if (result.current.status === "success") {
|
|
121
|
-
expectTypeOf(result.current.output);
|
|
122
|
-
expectTypeOf(result.current.responseMetadata);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
it("should handle ToolSignature with only output specified", () => {
|
|
126
|
-
const { result } = renderHook(() => useToolInfo());
|
|
127
|
-
expectTypeOf(result.current.input);
|
|
128
|
-
if (result.current.status === "success") {
|
|
129
|
-
expectTypeOf(result.current.output);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
59
|
//# sourceMappingURL=use-tool-info.test.js.map
|
|
@@ -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,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,
|
|
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,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,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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,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,45 @@
|
|
|
1
|
+
export function installOpenAILoggingProxy() {
|
|
2
|
+
if (typeof window === "undefined" || !window.openai) {
|
|
3
|
+
console.warn("[openai-proxy] window.openai not found, skipping proxy installation");
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const originalOpenAI = window.openai;
|
|
7
|
+
const handler = {
|
|
8
|
+
get(target, prop, receiver) {
|
|
9
|
+
const value = Reflect.get(target, prop, receiver);
|
|
10
|
+
if (typeof value === "function") {
|
|
11
|
+
return function (...args) {
|
|
12
|
+
const methodName = String(prop);
|
|
13
|
+
console.groupCollapsed(`%c[openai] %c${methodName}`, "color: #6366f1; font-weight: bold", "color: #22c55e; font-weight: bold");
|
|
14
|
+
console.log("%cArguments:", "color: #f59e0b; font-weight: bold", args);
|
|
15
|
+
console.trace("Call stack");
|
|
16
|
+
console.groupEnd();
|
|
17
|
+
const result = value.apply(target, args);
|
|
18
|
+
if (result instanceof Promise) {
|
|
19
|
+
return result.then((resolved) => {
|
|
20
|
+
console.groupCollapsed(`%c[openai] %c${methodName} %c✓ resolved`, "color: #6366f1; font-weight: bold", "color: #22c55e; font-weight: bold", "color: #10b981");
|
|
21
|
+
console.log("%cResult:", "color: #06b6d4; font-weight: bold", resolved);
|
|
22
|
+
console.groupEnd();
|
|
23
|
+
return resolved;
|
|
24
|
+
}, (error) => {
|
|
25
|
+
console.groupCollapsed(`%c[openai] %c${methodName} %c✗ rejected`, "color: #6366f1; font-weight: bold", "color: #22c55e; font-weight: bold", "color: #ef4444");
|
|
26
|
+
console.error("%cError:", "color: #ef4444; font-weight: bold", error);
|
|
27
|
+
console.groupEnd();
|
|
28
|
+
throw error;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
console.log(`%c[openai] %cget %c${String(prop)}`, "color: #6366f1; font-weight: bold", "color: #a855f7", "color: #22c55e", "→", value);
|
|
35
|
+
return value;
|
|
36
|
+
},
|
|
37
|
+
set(target, prop, value, receiver) {
|
|
38
|
+
console.log(`%c[openai] %cset %c${String(prop)}`, "color: #6366f1; font-weight: bold", "color: #f97316", "color: #22c55e", "←", value);
|
|
39
|
+
return Reflect.set(target, prop, value, receiver);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
window.openai = new Proxy(originalOpenAI, handler);
|
|
43
|
+
console.log("%c[openai-proxy] %cInstalled logging proxy for window.openai", "color: #6366f1; font-weight: bold", "color: #94a3b8");
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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C,QAAQ,EAAE,CAAC;4BACnB,OAAO,QAAQ,CAAC;wBAClB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;4BACR,OAAO,CAAC,cAAc,CACpB,gBAAgB,UAAU,eAAe,EACzC,mCAAmC,EACnC,mCAAmC,EACnC,gBAAgB,CACjB,CAAC;4BACF,OAAO,CAAC,KAAK,CACX,UAAU,EACV,mCAAmC,EACnC,KAAK,CACN,CAAC;4BACF,OAAO,CAAC,QAAQ,EAAE,CAAC;4BACnB,MAAM,KAAK,CAAC;wBACd,CAAC,CACF,CAAC;oBACJ,CAAC;oBAED,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC;YACJ,CAAC;YAED,OAAO,CAAC,GAAG,CACT,sBAAsB,MAAM,CAAC,IAAI,CAAC,EAAE,EACpC,mCAAmC,EACnC,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,EACH,KAAK,CACN,CAAC;YAEF,OAAO,KAAK,CAAC;QACf,CAAC;QAED,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ;YAC/B,OAAO,CAAC,GAAG,CACT,sBAAsB,MAAM,CAAC,IAAI,CAAC,EAAE,EACpC,mCAAmC,EACnC,gBAAgB,EAChB,gBAAgB,EAChB,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,mCAAmC,EACnC,gBAAgB,CACjB,CAAC;AACJ,CAAC"}
|
package/dist/src/web/types.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput exten
|
|
|
38
38
|
displayMode: DisplayMode;
|
|
39
39
|
safeArea: SafeArea;
|
|
40
40
|
toolInput: ToolInput;
|
|
41
|
-
toolOutput: ToolOutput |
|
|
41
|
+
toolOutput: ToolOutput | {
|
|
42
|
+
text: string;
|
|
43
|
+
} | null;
|
|
42
44
|
toolResponseMetadata: ToolResponseMetadata | null;
|
|
43
45
|
widgetState: WidgetState | null;
|
|
44
46
|
requestDisplayMode: RequestDisplayMode;
|
|
@@ -57,7 +59,7 @@ export type CallToolResponse = {
|
|
|
57
59
|
};
|
|
58
60
|
type API<WidgetState extends UnknownObject> = {
|
|
59
61
|
/** Calls a tool on your MCP. Returns the full response. */
|
|
60
|
-
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<
|
|
62
|
+
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
61
63
|
/** Triggers a followup turn in the ChatGPT conversation */
|
|
62
64
|
sendFollowUpMessage: (args: {
|
|
63
65
|
prompt: string;
|