skybridge 0.0.0-dev.a44b45b → 0.0.0-dev.a4ea8e7
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/devtoolsStaticServer.d.ts +15 -0
- package/dist/src/server/devtoolsStaticServer.js +38 -0
- package/dist/src/server/devtoolsStaticServer.js.map +1 -0
- package/dist/src/server/index.d.ts +3 -2
- package/dist/src/server/index.js +1 -0
- package/dist/src/server/index.js.map +1 -1
- package/dist/src/server/inferUtilityTypes.d.ts +10 -0
- package/dist/src/server/server.d.ts +32 -15
- package/dist/src/server/server.js +52 -32
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/server/templateHelper.d.ts +3 -0
- package/dist/src/server/templateHelper.js +3 -2
- package/dist/src/server/templateHelper.js.map +1 -1
- package/dist/src/server/templates/development.hbs +3 -2
- package/dist/src/server/templates/production.hbs +1 -0
- package/dist/src/test/utils.d.ts +53 -7
- package/dist/src/test/utils.js +78 -0
- package/dist/src/test/utils.js.map +1 -1
- package/dist/src/test/widget.test.js +68 -11
- package/dist/src/test/widget.test.js.map +1 -1
- package/dist/src/web/bridges/apps-sdk-adapter.d.ts +2 -0
- package/dist/src/web/bridges/apps-sdk-adapter.js +4 -0
- package/dist/src/web/bridges/apps-sdk-adapter.js.map +1 -0
- package/dist/src/web/bridges/apps-sdk-bridge.d.ts +8 -0
- package/dist/src/web/bridges/apps-sdk-bridge.js +41 -0
- package/dist/src/web/bridges/apps-sdk-bridge.js.map +1 -0
- package/dist/src/web/bridges/get-bridge-methods.d.ts +2 -0
- package/dist/src/web/bridges/get-bridge-methods.js +8 -0
- package/dist/src/web/bridges/get-bridge-methods.js.map +1 -0
- package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.d.ts +2 -0
- package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js +7 -0
- package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js.map +1 -0
- package/dist/src/web/bridges/hooks/use-bridge.d.ts +2 -0
- package/dist/src/web/bridges/hooks/use-bridge.js +57 -0
- package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -0
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +4 -0
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js +7 -0
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -0
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +58 -0
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -0
- package/dist/src/web/bridges/index.d.ts +4 -0
- package/dist/src/web/bridges/index.js +5 -0
- package/dist/src/web/bridges/index.js.map +1 -0
- package/dist/src/web/bridges/mcp-app-adapter.d.ts +2 -0
- package/dist/src/web/bridges/mcp-app-adapter.js +12 -0
- package/dist/src/web/bridges/mcp-app-adapter.js.map +1 -0
- package/dist/src/web/bridges/mcp-app-bridge.d.ts +29 -0
- package/dist/src/web/bridges/mcp-app-bridge.js +130 -0
- package/dist/src/web/bridges/mcp-app-bridge.js.map +1 -0
- package/dist/src/web/bridges/types.d.ts +22 -0
- package/dist/src/web/bridges/types.js +2 -0
- package/dist/src/web/bridges/types.js.map +1 -0
- package/dist/src/web/data-llm.test.js.map +1 -1
- package/dist/src/web/generate-helpers.d.ts +7 -5
- package/dist/src/web/generate-helpers.js +4 -2
- package/dist/src/web/generate-helpers.js.map +1 -1
- package/dist/src/web/generate-helpers.test-d.js +53 -1
- package/dist/src/web/generate-helpers.test-d.js.map +1 -1
- package/dist/src/web/hooks/index.d.ts +2 -3
- package/dist/src/web/hooks/index.js +2 -3
- package/dist/src/web/hooks/index.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.d.ts +1 -1
- package/dist/src/web/hooks/use-call-tool.test.js +8 -14
- package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.d.ts +2 -2
- package/dist/src/web/hooks/use-display-mode.js +6 -3
- package/dist/src/web/hooks/use-display-mode.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.test.js +1 -0
- package/dist/src/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/src/web/hooks/use-layout.d.ts +22 -0
- package/dist/src/web/hooks/use-layout.js +23 -0
- package/dist/src/web/hooks/use-layout.js.map +1 -0
- package/dist/src/web/hooks/use-layout.test.js +46 -0
- package/dist/src/web/hooks/use-layout.test.js.map +1 -0
- package/dist/src/web/hooks/use-openai-global.d.ts +3 -2
- package/dist/src/web/hooks/use-openai-global.js +3 -20
- package/dist/src/web/hooks/use-openai-global.js.map +1 -1
- package/dist/src/web/hooks/use-request-modal.d.ts +6 -3
- package/dist/src/web/hooks/use-request-modal.js +6 -1
- package/dist/src/web/hooks/use-request-modal.js.map +1 -1
- package/dist/src/web/hooks/use-request-modal.test.js +35 -2
- package/dist/src/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +1 -1
- package/dist/src/web/hooks/use-tool-info.js +5 -7
- package/dist/src/web/hooks/use-tool-info.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test.js +1 -0
- package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/src/web/hooks/use-user.d.ts +18 -0
- package/dist/src/web/hooks/use-user.js +19 -0
- package/dist/src/web/hooks/use-user.js.map +1 -0
- package/dist/src/web/hooks/use-user.test.js +44 -0
- package/dist/src/web/hooks/use-user.test.js.map +1 -0
- package/dist/src/web/hooks/use-widget-state.js +2 -2
- package/dist/src/web/hooks/use-widget-state.js.map +1 -1
- package/dist/src/web/hooks/use-widget-state.test.js +1 -0
- 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/plugin/plugin.js +10 -4
- package/dist/src/web/plugin/plugin.js.map +1 -1
- package/dist/src/web/proxy.js +5 -0
- package/dist/src/web/proxy.js.map +1 -1
- package/dist/src/web/types.d.ts +24 -6
- package/dist/src/web/types.js.map +1 -1
- package/package.json +8 -6
- package/LICENSE +0 -21
- package/README.md +0 -123
- package/dist/src/web/hooks/use-locale.d.ts +0 -1
- package/dist/src/web/hooks/use-locale.js +0 -5
- package/dist/src/web/hooks/use-locale.js.map +0 -1
- package/dist/src/web/hooks/use-locale.test.js +0 -21
- package/dist/src/web/hooks/use-locale.test.js.map +0 -1
- package/dist/src/web/hooks/use-theme.d.ts +0 -1
- package/dist/src/web/hooks/use-theme.js +0 -5
- package/dist/src/web/hooks/use-theme.js.map +0 -1
- package/dist/src/web/hooks/use-theme.test.js +0 -26
- package/dist/src/web/hooks/use-theme.test.js.map +0 -1
- package/dist/src/web/hooks/use-user-agent.d.ts +0 -1
- package/dist/src/web/hooks/use-user-agent.js +0 -5
- package/dist/src/web/hooks/use-user-agent.js.map +0 -1
- package/dist/src/web/hooks/use-user-agent.test.js +0 -31
- package/dist/src/web/hooks/use-user-agent.test.js.map +0 -1
- /package/dist/src/web/{hooks/use-locale.test.d.ts → bridges/hooks/use-mcp-app-bridge.test.d.ts} +0 -0
- /package/dist/src/web/hooks/{use-theme.test.d.ts → use-layout.test.d.ts} +0 -0
- /package/dist/src/web/hooks/{use-user-agent.test.d.ts → use-user.test.d.ts} +0 -0
|
@@ -5,18 +5,51 @@ describe("useRequestModal", () => {
|
|
|
5
5
|
let requestModalMock;
|
|
6
6
|
beforeEach(() => {
|
|
7
7
|
requestModalMock = vi.fn();
|
|
8
|
+
vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
|
|
8
9
|
vi.stubGlobal("openai", {
|
|
9
10
|
requestModal: requestModalMock,
|
|
11
|
+
view: { mode: "inline" },
|
|
10
12
|
});
|
|
11
13
|
});
|
|
12
14
|
afterEach(() => {
|
|
13
15
|
vi.unstubAllGlobals();
|
|
14
16
|
vi.resetAllMocks();
|
|
15
17
|
});
|
|
16
|
-
it("should return
|
|
18
|
+
it("should return an object with open, isOpen, and params properties where isOpen is false when mode is not modal", () => {
|
|
17
19
|
const { result } = renderHook(() => useRequestModal());
|
|
20
|
+
expect(typeof result.current).toBe("object");
|
|
21
|
+
expect(result.current).toHaveProperty("open");
|
|
22
|
+
expect(result.current).toHaveProperty("isOpen");
|
|
23
|
+
expect(result.current).toHaveProperty("params");
|
|
24
|
+
const { open, isOpen, params } = result.current;
|
|
25
|
+
expect(typeof open).toBe("function");
|
|
26
|
+
expect(isOpen).toBe(false);
|
|
27
|
+
expect(params).toBeUndefined();
|
|
28
|
+
});
|
|
29
|
+
it("should return isOpen as true when mode is modal", () => {
|
|
30
|
+
vi.stubGlobal("openai", {
|
|
31
|
+
requestModal: requestModalMock,
|
|
32
|
+
view: { mode: "modal" },
|
|
33
|
+
});
|
|
34
|
+
const { result } = renderHook(() => useRequestModal());
|
|
35
|
+
const { isOpen } = result.current;
|
|
36
|
+
expect(isOpen).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
it("should return params from view when available", () => {
|
|
39
|
+
const testParams = { foo: "bar", baz: 42 };
|
|
40
|
+
vi.stubGlobal("openai", {
|
|
41
|
+
requestModal: requestModalMock,
|
|
42
|
+
view: { mode: "modal", params: testParams },
|
|
43
|
+
});
|
|
44
|
+
const { result } = renderHook(() => useRequestModal());
|
|
45
|
+
const { params } = result.current;
|
|
46
|
+
expect(params).toEqual(testParams);
|
|
47
|
+
});
|
|
48
|
+
it("should call window.openai.requestModal with the options when open is called", () => {
|
|
49
|
+
const { result } = renderHook(() => useRequestModal());
|
|
50
|
+
const { open } = result.current;
|
|
18
51
|
const options = { title: "Test Modal" };
|
|
19
|
-
|
|
52
|
+
open(options);
|
|
20
53
|
expect(requestModalMock).toHaveBeenCalledTimes(1);
|
|
21
54
|
expect(requestModalMock).toHaveBeenCalledWith(options);
|
|
22
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-request-modal.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-request-modal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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AC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;QAC3C,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtB,YAAY,EAAE,gBAAgB;YAC9B,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE;SAC5C,CAAC,CAAC;QAEH,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QACvD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;QAElC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACrF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QACvD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;QAEhC,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEd,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -21,5 +21,5 @@ type ToolSignature = {
|
|
|
21
21
|
output: UnknownObject;
|
|
22
22
|
responseMetadata: UnknownObject;
|
|
23
23
|
};
|
|
24
|
-
export declare function useToolInfo<TS extends Partial<ToolSignature> =
|
|
24
|
+
export declare function useToolInfo<TS extends Partial<ToolSignature> = Record<string, never>>(): ToolState<UnknownObject & TS["input"], UnknownObject & TS["output"], UnknownObject & TS["responseMetadata"]>;
|
|
25
25
|
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useAppsSdkBridge } from "../bridges/index.js";
|
|
3
3
|
export function useToolInfo() {
|
|
4
4
|
const [status, setStatus] = useState("pending");
|
|
5
|
-
const input =
|
|
6
|
-
const output =
|
|
7
|
-
const responseMetadata =
|
|
5
|
+
const input = useAppsSdkBridge("toolInput");
|
|
6
|
+
const output = useAppsSdkBridge("toolOutput");
|
|
7
|
+
const responseMetadata = useAppsSdkBridge("toolResponseMetadata");
|
|
8
8
|
useEffect(() => {
|
|
9
|
-
setStatus(output ===
|
|
10
|
-
? "pending"
|
|
11
|
-
: "success");
|
|
9
|
+
setStatus(output === null && responseMetadata === null ? "pending" : "success");
|
|
12
10
|
}, [output, responseMetadata]);
|
|
13
11
|
return {
|
|
14
12
|
input,
|
|
@@ -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;
|
|
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,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAuCvD,MAAM,UAAU,WAAW;IAGzB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAwB,SAAS,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IAElE,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CACP,MAAM,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CACrE,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"}
|
|
@@ -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,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAEL,sBAAsB,EACtB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,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,EAAE,IAAI;SAC3B,CAAC;QACF,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"use-tool-info.test.js","sourceRoot":"","sources":["../../../../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,SAAS;YACjB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qFAAqF,EAAE,KAAK,IAAI,EAAE;QACnG,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,QAAQ;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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { UserAgent } from "../types.js";
|
|
2
|
+
export type UserState = {
|
|
3
|
+
locale: string;
|
|
4
|
+
userAgent: UserAgent;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Hook for accessing session-stable user information.
|
|
8
|
+
* These values are set once at initialization and do not change during the session.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const { locale, userAgent } = useUser();
|
|
13
|
+
*
|
|
14
|
+
* // Access device type
|
|
15
|
+
* const isMobile = userAgent.device.type === "mobile";
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function useUser(): UserState;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useAppsSdkBridge, useBridge } from "../bridges/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Hook for accessing session-stable user information.
|
|
4
|
+
* These values are set once at initialization and do not change during the session.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const { locale, userAgent } = useUser();
|
|
9
|
+
*
|
|
10
|
+
* // Access device type
|
|
11
|
+
* const isMobile = userAgent.device.type === "mobile";
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export function useUser() {
|
|
15
|
+
const locale = useBridge("locale");
|
|
16
|
+
const userAgent = useAppsSdkBridge("userAgent");
|
|
17
|
+
return { locale, userAgent };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=use-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-user.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQlE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,OAAO;IACrB,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAEhD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { renderHook } from "@testing-library/react";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { useUser } from "./use-user.js";
|
|
4
|
+
describe("useUser", () => {
|
|
5
|
+
let OpenaiMock;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
OpenaiMock = {
|
|
8
|
+
locale: "en-US",
|
|
9
|
+
userAgent: {
|
|
10
|
+
device: { type: "desktop" },
|
|
11
|
+
capabilities: { hover: true, touch: false },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
vi.stubGlobal("openai", OpenaiMock);
|
|
15
|
+
vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
|
|
16
|
+
});
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
vi.unstubAllGlobals();
|
|
19
|
+
vi.resetAllMocks();
|
|
20
|
+
});
|
|
21
|
+
it("should return locale and userAgent from window.openai", () => {
|
|
22
|
+
const { result } = renderHook(() => useUser());
|
|
23
|
+
expect(result.current.locale).toBe("en-US");
|
|
24
|
+
expect(result.current.userAgent).toEqual({
|
|
25
|
+
device: { type: "desktop" },
|
|
26
|
+
capabilities: { hover: true, touch: false },
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it("should return mobile userAgent when set to mobile", () => {
|
|
30
|
+
OpenaiMock.userAgent = {
|
|
31
|
+
device: { type: "mobile" },
|
|
32
|
+
capabilities: { hover: false, touch: true },
|
|
33
|
+
};
|
|
34
|
+
const { result } = renderHook(() => useUser());
|
|
35
|
+
expect(result.current.userAgent.device.type).toBe("mobile");
|
|
36
|
+
expect(result.current.userAgent.capabilities.touch).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
it("should return different locale when set", () => {
|
|
39
|
+
OpenaiMock.locale = "es-ES";
|
|
40
|
+
const { result } = renderHook(() => useUser());
|
|
41
|
+
expect(result.current.locale).toBe("es-ES");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=use-user.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-user.test.js","sour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AK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,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,OAAO,EAAE,CAAC,CAAC;QAE/C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5D,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC;QAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAE/C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { useAppsSdkBridge } from "../bridges/index.js";
|
|
2
3
|
import { filterWidgetContext, injectWidgetContext } from "../helpers/state.js";
|
|
3
|
-
import { useOpenAiGlobal } from "./use-openai-global.js";
|
|
4
4
|
export function useWidgetState(defaultState) {
|
|
5
|
-
const widgetStateFromWindow =
|
|
5
|
+
const widgetStateFromWindow = useAppsSdkBridge("widgetState");
|
|
6
6
|
const [widgetState, _setWidgetState] = useState(() => {
|
|
7
7
|
if (widgetStateFromWindow !== null) {
|
|
8
8
|
return filterWidgetContext(widgetStateFromWindow);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-widget-state.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-widget-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-widget-state.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-widget-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAS/E,MAAM,UAAU,cAAc,CAC5B,YAA0C;IAE1C,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,aAAa,CAAa,CAAC;IAE1E,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAW,GAAG,EAAE;QAC7D,IAAI,qBAAqB,KAAK,IAAI,EAAE,CAAC;YACnC,OAAO,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,OAAO,YAAY,KAAK,UAAU;YACvC,CAAC,CAAC,YAAY,EAAE;YAChB,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,kCAAkC;QAClC,IAAI,qBAAqB,KAAK,IAAI,EAAE,CAAC;YACnC,eAAe,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAC9D,CAAC;IACH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C,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,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,cAAc,YAAY,CAAC"}
|
|
@@ -7,11 +7,17 @@ export function skybridge() {
|
|
|
7
7
|
const { globSync } = await import("node:fs");
|
|
8
8
|
const { resolve } = await import("node:path");
|
|
9
9
|
const projectRoot = config.root || process.cwd();
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
const flatWidgetPattern = resolve(projectRoot, "src/widgets/*.{js,ts,jsx,tsx,html}");
|
|
11
|
+
const dirWidgetPattern = resolve(projectRoot, "src/widgets/*/index.tsx");
|
|
12
|
+
const flatWidgets = globSync(flatWidgetPattern).map((file) => [
|
|
13
|
+
file.match(/src\/widgets\/([^/]+)\.tsx$/)?.[1],
|
|
13
14
|
file,
|
|
14
|
-
])
|
|
15
|
+
]);
|
|
16
|
+
const dirWidgets = globSync(dirWidgetPattern).map((file) => [
|
|
17
|
+
file.match(/src\/widgets\/([^/]+)\/index\.tsx$/)?.[1],
|
|
18
|
+
file,
|
|
19
|
+
]);
|
|
20
|
+
const input = Object.fromEntries([...flatWidgets, ...dirWidgets]);
|
|
15
21
|
return {
|
|
16
22
|
base: "/assets",
|
|
17
23
|
build: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../src/web/plugin/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExE,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,IAAI,EAAE,WAAW;QAEjB,KAAK,CAAC,MAAM,CAAC,MAAM;YACjB,4EAA4E;YAC5E,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;YAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9C,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACjD,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../src/web/plugin/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExE,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,IAAI,EAAE,WAAW;QAEjB,KAAK,CAAC,MAAM,CAAC,MAAM;YACjB,4EAA4E;YAC5E,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;YAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9C,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACjD,MAAM,iBAAiB,GAAG,OAAO,CAC/B,WAAW,EACX,oCAAoC,CACrC,CAAC;YACF,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,EAAE,yBAAyB,CAAC,CAAC;YAEzE,MAAM,WAAW,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC5D,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC9C,IAAI;aACL,CAAC,CAAC;YACH,MAAM,UAAU,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC1D,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACrD,IAAI;aACL,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,WAAW,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC;YAElE,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,IAAI;oBACZ,YAAY,EAAE,KAAK;oBACnB,aAAa,EAAE;wBACb,KAAK;qBACN;iBACF;aACF,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,KAAK;QACd,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE;YACtB,OAAO,MAAM,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/src/web/proxy.js
CHANGED
|
@@ -9,6 +9,11 @@ export function installOpenAILoggingProxy() {
|
|
|
9
9
|
console.warn("[openai-proxy] window.openai not found, skipping proxy installation");
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
+
const descriptor = Object.getOwnPropertyDescriptor(window, "openai");
|
|
13
|
+
if (descriptor?.configurable === false || descriptor?.writable === false) {
|
|
14
|
+
console.warn("[openai-proxy] window.openai is not configurable or writable, skipping proxy installation");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
12
17
|
const originalOpenAI = window.openai;
|
|
13
18
|
const handler = {
|
|
14
19
|
get(target, prop, receiver) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","source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EF,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,4 +1,5 @@
|
|
|
1
1
|
import "react";
|
|
2
|
+
import type { WidgetHostType } from "../server/index.js";
|
|
2
3
|
declare module "react" {
|
|
3
4
|
interface HTMLAttributes<T> {
|
|
4
5
|
"data-llm"?: string;
|
|
@@ -10,7 +11,7 @@ export type Prettify<T> = {
|
|
|
10
11
|
} & {};
|
|
11
12
|
export type Objectify<T> = T & UnknownObject;
|
|
12
13
|
type RequiredKeys<T> = {
|
|
13
|
-
[K in keyof T]-?:
|
|
14
|
+
[K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
|
|
14
15
|
}[keyof T];
|
|
15
16
|
export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
|
|
16
17
|
type WidgetState = UnknownObject;
|
|
@@ -28,19 +29,24 @@ export declare class ToolResponseEvent extends CustomEvent<{
|
|
|
28
29
|
}
|
|
29
30
|
declare global {
|
|
30
31
|
interface Window {
|
|
32
|
+
skybridge: SkybridgeProperties;
|
|
31
33
|
openai: OpenAiMethods<WidgetState> & OpenAiProperties;
|
|
32
34
|
}
|
|
33
35
|
interface WindowEventMap {
|
|
34
36
|
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
|
-
export type
|
|
39
|
+
export type SkybridgeProperties = {
|
|
40
|
+
hostType: WidgetHostType;
|
|
41
|
+
};
|
|
42
|
+
export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
|
|
38
43
|
theme: Theme;
|
|
39
44
|
userAgent: UserAgent;
|
|
40
45
|
locale: string;
|
|
41
46
|
maxHeight: number;
|
|
42
47
|
displayMode: DisplayMode;
|
|
43
48
|
safeArea: SafeArea;
|
|
49
|
+
view: View;
|
|
44
50
|
toolInput: ToolInput;
|
|
45
51
|
toolOutput: ToolOutput | {
|
|
46
52
|
text: string;
|
|
@@ -59,6 +65,16 @@ export type CallToolResponse = {
|
|
|
59
65
|
result: string;
|
|
60
66
|
meta: Record<string, unknown>;
|
|
61
67
|
};
|
|
68
|
+
export type RequestModalOptions = {
|
|
69
|
+
title?: string;
|
|
70
|
+
params?: Record<string, unknown>;
|
|
71
|
+
anchor?: {
|
|
72
|
+
top?: number;
|
|
73
|
+
left?: number;
|
|
74
|
+
width?: number;
|
|
75
|
+
height?: number;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
62
78
|
export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
|
|
63
79
|
/** Calls a tool on your MCP. Returns the full response. */
|
|
64
80
|
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
@@ -89,9 +105,7 @@ export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
|
|
|
89
105
|
* Opens a modal portaled outside of the widget iFrame.
|
|
90
106
|
* This ensures the modal is correctly displayed and not limited to the widget's area.
|
|
91
107
|
*/
|
|
92
|
-
requestModal: (args:
|
|
93
|
-
title: string;
|
|
94
|
-
}) => Promise<void>;
|
|
108
|
+
requestModal: (args: RequestModalOptions) => Promise<void>;
|
|
95
109
|
/** Uploads a new file to the host */
|
|
96
110
|
uploadFile: (file: File) => Promise<FileMetadata>;
|
|
97
111
|
/**
|
|
@@ -109,7 +123,11 @@ export declare class SetGlobalsEvent extends CustomEvent<{
|
|
|
109
123
|
readonly type = "openai:set_globals";
|
|
110
124
|
}
|
|
111
125
|
export type CallTool = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
|
|
112
|
-
export type DisplayMode = "pip" | "inline" | "fullscreen";
|
|
126
|
+
export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
|
|
127
|
+
export type View = {
|
|
128
|
+
mode: DisplayMode;
|
|
129
|
+
params?: Record<string, unknown>;
|
|
130
|
+
};
|
|
113
131
|
export type Theme = "light" | "dark";
|
|
114
132
|
export type SafeAreaInsets = {
|
|
115
133
|
top: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC;AAwBf,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AA0GD,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,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.a4ea8e7",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT apps",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/alpic-ai/skybridge.git"
|
|
8
|
+
},
|
|
5
9
|
"type": "module",
|
|
6
10
|
"files": [
|
|
7
11
|
"dist"
|
|
@@ -19,14 +23,11 @@
|
|
|
19
23
|
"scripts": {
|
|
20
24
|
"build": "tsc && pnpm run build:templates",
|
|
21
25
|
"build:templates": "cp -r src/server/templates dist/src/server/",
|
|
22
|
-
"format": "biome check --write",
|
|
26
|
+
"format": "biome check --write --error-on-warnings",
|
|
23
27
|
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
24
28
|
"test:unit": "vitest run",
|
|
25
29
|
"test:type": "tsc --noEmit",
|
|
26
|
-
"test:format": "biome
|
|
27
|
-
"docs:dev": "pnpm --filter @skybridge/docs start",
|
|
28
|
-
"docs:build": "pnpm --filter @skybridge/docs build",
|
|
29
|
-
"docs:serve": "pnpm --filter @skybridge/docs serve"
|
|
30
|
+
"test:format": "biome ci"
|
|
30
31
|
},
|
|
31
32
|
"keywords": [
|
|
32
33
|
"chatgpt",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@biomejs/biome": "2.3.8",
|
|
56
|
+
"@modelcontextprotocol/ext-apps": "^0.2.2",
|
|
55
57
|
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
56
58
|
"@testing-library/dom": "^10.4.1",
|
|
57
59
|
"@testing-library/react": "^16.3.0",
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Alpic
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
<img alt="Skybridge" src="docs/static/img/logo.png" width="220">
|
|
4
|
-
|
|
5
|
-
# Skybridge
|
|
6
|
-
|
|
7
|
-
**Build ChatGPT Apps. The Modern TypeScript Way.**
|
|
8
|
-
|
|
9
|
-
The fullstack TypeScript framework for ChatGPT Apps.<br />
|
|
10
|
-
**Type-safe. React-powered. Zero config.**
|
|
11
|
-
|
|
12
|
-
<br />
|
|
13
|
-
|
|
14
|
-
[](https://www.npmjs.com/package/skybridge)
|
|
15
|
-
[](https://www.npmjs.com/package/skybridge)
|
|
16
|
-
[](https://github.com/alpic-ai/skybridge/blob/main/LICENSE)
|
|
17
|
-
|
|
18
|
-
<br />
|
|
19
|
-
|
|
20
|
-
[Documentation](https://skybridge.tech) · [Quick Start](https://github.com/new?template_name=apps-sdk-template&template_owner=alpic-ai) · [Examples](https://github.com/alpic-ai/apps-sdk-template)
|
|
21
|
-
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
<br />
|
|
25
|
-
|
|
26
|
-
## ✨ Why Skybridge?
|
|
27
|
-
|
|
28
|
-
ChatGPT Apps let you embed **rich, interactive UIs** directly in conversations. But the raw SDK is low-level—no hooks, no type safety, no dev tools, and no HMR.
|
|
29
|
-
|
|
30
|
-
**Skybridge fixes that.**
|
|
31
|
-
|
|
32
|
-
| | |
|
|
33
|
-
|:--|:--|
|
|
34
|
-
| 👨💻 **Full Dev Environment** — HMR, debug traces, and local emulator. No more refresh loops. | ✅ **End-to-End Type Safety** — tRPC-style inference from server to widget. Autocomplete everywhere. |
|
|
35
|
-
| 🔄 **Widget-to-Model Sync** — Keep the model aware of UI state with `data-llm`. Dual surfaces, one source of truth. | ⚒️ **React Query-style Hooks** — `isPending`, `isError`, callbacks. State management you already know. |
|
|
36
|
-
|
|
37
|
-
<br />
|
|
38
|
-
|
|
39
|
-
## 🚀 Get Started
|
|
40
|
-
|
|
41
|
-
**Create a new ChatGPT app:**
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
gh repo create my-app --template alpic-ai/apps-sdk-template --clone
|
|
45
|
-
cd my-app && pnpm install
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
**Or add to an existing project:**
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
npm i skybridge
|
|
52
|
-
yarn add skybridge
|
|
53
|
-
pnpm add skybridge
|
|
54
|
-
bun add skybridge
|
|
55
|
-
deno add skybridge
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
<div align="center">
|
|
59
|
-
|
|
60
|
-
**👉 [Read the Docs](https://skybridge.tech) 👈**
|
|
61
|
-
|
|
62
|
-
</div>
|
|
63
|
-
|
|
64
|
-
<br />
|
|
65
|
-
|
|
66
|
-
## 📦 The Stack
|
|
67
|
-
|
|
68
|
-
- **`skybridge/server`** — Drop-in MCP SDK replacement with widget registration and type inference.
|
|
69
|
-
- **`skybridge/web`** — React hooks and components for ChatGPT's runtime.
|
|
70
|
-
|
|
71
|
-
### Server
|
|
72
|
-
|
|
73
|
-
```ts
|
|
74
|
-
import { McpServer } from "skybridge/server";
|
|
75
|
-
|
|
76
|
-
server.registerWidget("flights", {}, {
|
|
77
|
-
inputSchema: { destination: z.string() },
|
|
78
|
-
}, async ({ destination }) => {
|
|
79
|
-
const flights = await searchFlights(destination);
|
|
80
|
-
return { structuredContent: { flights } };
|
|
81
|
-
});
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Widget
|
|
85
|
-
|
|
86
|
-
```tsx
|
|
87
|
-
import { useToolInfo } from "skybridge/web";
|
|
88
|
-
|
|
89
|
-
function FlightsWidget() {
|
|
90
|
-
const { output } = useToolInfo();
|
|
91
|
-
|
|
92
|
-
return output.structuredContent.flights.map(f =>
|
|
93
|
-
<FlightCard key={f.id} flight={f} />
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
<br />
|
|
99
|
-
|
|
100
|
-
## 🎯 Features at a Glance
|
|
101
|
-
|
|
102
|
-
- **Live Reload** — Vite HMR. See changes instantly without reinstalling.
|
|
103
|
-
- **Typed Hooks** — Full autocomplete for tools, inputs, outputs.
|
|
104
|
-
- **Widget → Tool Calls** — Trigger server actions from UI.
|
|
105
|
-
- **Dual Surface Sync** — Keep model aware of what users see with `data-llm`.
|
|
106
|
-
- **React Query-style API** — `isPending`, `isError`, callbacks.
|
|
107
|
-
- **MCP Compatible** — Extends the official SDK. Works with any MCP client.
|
|
108
|
-
|
|
109
|
-
<br />
|
|
110
|
-
|
|
111
|
-
<div align="center">
|
|
112
|
-
|
|
113
|
-
[](https://github.com/alpic-ai/skybridge/discussions)
|
|
114
|
-
[](https://github.com/alpic-ai/skybridge/issues)
|
|
115
|
-
[](https://discord.com/invite/gNAazGueab)
|
|
116
|
-
|
|
117
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions
|
|
118
|
-
|
|
119
|
-
<br />
|
|
120
|
-
|
|
121
|
-
**[MIT License](LICENSE)** · Made with ❤️ by **[Alpic](https://alpic.ai)**
|
|
122
|
-
|
|
123
|
-
</div>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useLocale(): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-locale.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,UAAU,SAAS;IACvB,OAAO,eAAe,CAAC,QAAQ,CAAE,CAAC;AACpC,CAAC"}
|