skybridge 0.0.0-dev.bed9595 → 0.0.0-dev.c210709
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 +173 -0
- package/dist/src/server/index.d.ts +2 -0
- package/dist/src/server/inferUtilityTypes.d.ts +48 -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 +31 -9
- package/dist/src/server/server.js +5 -0
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/test/utils.d.ts +61 -0
- package/dist/src/test/utils.js +122 -1
- package/dist/src/test/utils.js.map +1 -1
- package/dist/src/web/generate-helpers.d.ts +112 -0
- package/dist/src/web/generate-helpers.js +107 -0
- package/dist/src/web/generate-helpers.js.map +1 -0
- package/dist/src/web/generate-helpers.test-d.d.ts +1 -0
- package/dist/src/web/generate-helpers.test-d.js +90 -0
- package/dist/src/web/generate-helpers.test-d.js.map +1 -0
- package/dist/src/web/generate-helpers.test.d.ts +1 -0
- package/dist/src/web/generate-helpers.test.js +17 -0
- package/dist/src/web/generate-helpers.test.js.map +1 -0
- 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 +53 -16
- 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-call-tool.test.js +4 -5
- 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.d.ts +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-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 +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 +0 -75
- package/dist/src/web/hooks/use-tool-info.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/types.d.ts +29 -22
- package/dist/src/web/types.js.map +1 -1
- package/package.json +1 -2
|
@@ -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,CAAC;QACxC,YAAY,CAAU,MAAM,CAAC,SAAS,CAAC,CAAC;QACxC,YAAY,CAA0B,MAAM,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uFAAuF,EAAE,GAAG,EAAE;QAKjG,MAAM,MAAM,GAAG,WAAW,EAItB,CAAC;QAEL,YAAY,CAAY,MAAM,CAAC,KAAK,CAAC,CAAC;QAEtC,gEAAgE;QAChE,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAAY,MAAM,CAAC,MAAM,CAAC,CAAC;YACvC,YAAY,CAAY,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACnD,CAAC;QAED,8DAA8D;QAC9D,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAAa,MAAM,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AQ,MAAM,CAAC,SAAS,CAAC,CAAC;YACtC,YAAY,CAAO,MAAM,CAAC,SAAS,CAAC,CAAC;YACrC,YAAY,CAAa,MAAM,CAAC,MAAM,CAAC,CAAC;YACxC,YAAY,CAAe,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,+DAA+D,EAAE,GAAG,EAAE;QAGzE,MAAM,MAAM,GAAG,WAAW,EAEtB,CAAC;QAEL,YAAY,CAAY,MAAM,CAAC,KAAK,CAAC,CAAC;QAEtC,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,YAAY,CAA0B,MAAM,CAAC,MAAM,CAAC,CAAC;YACrD,YAAY,CAA0B,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC,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,4 @@
|
|
|
1
1
|
import { fireEvent, renderHook, waitFor, act } from "@testing-library/react";
|
|
2
|
-
import { expectType } from "tsd";
|
|
3
2
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
3
|
import { useToolInfo } from "./use-tool-info.js";
|
|
5
4
|
import { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, } from "../types.js";
|
|
@@ -57,78 +56,4 @@ describe("useToolInfo", () => {
|
|
|
57
56
|
});
|
|
58
57
|
});
|
|
59
58
|
});
|
|
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
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,EAAE,
|
|
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,E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AG,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"}
|
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,eAAe,EAAE,MAAM,uBAAuB,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,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;CACR,CAAC;AAEX,MAAM,UAAU,yBAAyB;IACvC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACpD,OAAO,CAAC,IAAI,CACV,qEAAqE,CACtE,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAErC,MAAM,OAAO,GAAwC;QACnD,GAAG,CAAC,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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"}
|
package/dist/src/web/types.d.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
export type UnknownObject = Record<string, unknown>;
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) => Promise<{
|
|
10
|
-
mode: DisplayMode;
|
|
11
|
-
}>;
|
|
12
|
-
export type RequestModal = (options: RequestModalOptions) => Promise<void>;
|
|
13
|
-
export type RequestModalOptions = {
|
|
14
|
-
title: string;
|
|
2
|
+
export type Prettify<T> = {
|
|
3
|
+
[K in keyof T]: T[K];
|
|
4
|
+
} & {};
|
|
5
|
+
export type Objectify<T> = T & UnknownObject;
|
|
6
|
+
type WidgetState = UnknownObject;
|
|
7
|
+
type FileMetadata = {
|
|
8
|
+
fileId: string;
|
|
15
9
|
};
|
|
16
10
|
export declare const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
|
|
17
11
|
export declare class ToolResponseEvent extends CustomEvent<{
|
|
@@ -43,8 +37,6 @@ export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput exten
|
|
|
43
37
|
} | null;
|
|
44
38
|
toolResponseMetadata: ToolResponseMetadata | null;
|
|
45
39
|
widgetState: WidgetState | null;
|
|
46
|
-
requestDisplayMode: RequestDisplayMode;
|
|
47
|
-
requestModal: RequestModal;
|
|
48
40
|
};
|
|
49
41
|
export type CallToolArgs = Record<string, unknown> | null;
|
|
50
42
|
export type CallToolResponse = {
|
|
@@ -57,20 +49,15 @@ export type CallToolResponse = {
|
|
|
57
49
|
result: string;
|
|
58
50
|
meta: Record<string, unknown>;
|
|
59
51
|
};
|
|
60
|
-
export type DefaultCallToolResponse = {
|
|
61
|
-
structuredContent: Record<string, unknown>;
|
|
62
|
-
meta: Record<string, unknown>;
|
|
63
|
-
};
|
|
64
|
-
export type CallToolResponseConstraint = Partial<Pick<CallToolResponse, "structuredContent" | "meta">>;
|
|
65
52
|
type API<WidgetState extends UnknownObject> = {
|
|
66
53
|
/** Calls a tool on your MCP. Returns the full response. */
|
|
67
|
-
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends
|
|
54
|
+
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
68
55
|
/** Triggers a followup turn in the ChatGPT conversation */
|
|
69
56
|
sendFollowUpMessage: (args: {
|
|
70
57
|
prompt: string;
|
|
71
58
|
}) => Promise<void>;
|
|
72
59
|
/** Opens an external link, redirects web page or mobile app */
|
|
73
|
-
openExternal(
|
|
60
|
+
openExternal(args: {
|
|
74
61
|
href: string;
|
|
75
62
|
}): void;
|
|
76
63
|
/** For transitioning an app from inline to fullscreen or pip */
|
|
@@ -83,7 +70,27 @@ type API<WidgetState extends UnknownObject> = {
|
|
|
83
70
|
*/
|
|
84
71
|
mode: DisplayMode;
|
|
85
72
|
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Sets the widget state.
|
|
75
|
+
* This state is persisted across widget renders.
|
|
76
|
+
*/
|
|
86
77
|
setWidgetState: (state: WidgetState) => Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Opens a modal portaled outside of the widget iFrame.
|
|
80
|
+
* This ensures the modal is correctly displayed and not limited to the widget's area.
|
|
81
|
+
*/
|
|
82
|
+
requestModal: (args: {
|
|
83
|
+
title: string;
|
|
84
|
+
}) => Promise<void>;
|
|
85
|
+
/** Uploads a new file to the host */
|
|
86
|
+
uploadFile: (file: File) => Promise<FileMetadata>;
|
|
87
|
+
/**
|
|
88
|
+
* Downloads a file from the host that was previously uploaded.
|
|
89
|
+
* Only files uploaded by the same connector instance can be downloaded.
|
|
90
|
+
*/
|
|
91
|
+
downloadFile: (file: FileMetadata) => Promise<{
|
|
92
|
+
downloadUrl: string;
|
|
93
|
+
}>;
|
|
87
94
|
};
|
|
88
95
|
export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
89
96
|
export declare class SetGlobalsEvent extends CustomEvent<{
|
|
@@ -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":"AASA,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AA8FD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
|
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.c210709",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"@types/react-dom": "^19.2.2",
|
|
59
59
|
"@vitest/ui": "^2.1.8",
|
|
60
60
|
"jsdom": "^25.0.1",
|
|
61
|
-
"tsd": "^0.33.0",
|
|
62
61
|
"typescript": "^5.9.3",
|
|
63
62
|
"vitest": "^2.1.8"
|
|
64
63
|
},
|