skybridge 0.0.0-dev.fcc9bec → 0.0.0-dev.fd77b0f
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/server.js +1 -1
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/server/templates/development.hbs +1 -1
- package/dist/src/server/templates/production.hbs +1 -1
- package/dist/src/server/widgetsDevServer.js +0 -1
- package/dist/src/server/widgetsDevServer.js.map +1 -1
- package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.d.ts +13 -0
- package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js +33 -0
- package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js.map +1 -0
- package/dist/src/web/bridges/adaptors/mcp-app-adaptor.d.ts +16 -0
- package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js +115 -0
- package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js.map +1 -0
- package/dist/src/web/bridges/apps-sdk-bridge.d.ts +4 -2
- package/dist/src/web/bridges/apps-sdk-bridge.js +19 -14
- package/dist/src/web/bridges/apps-sdk-bridge.js.map +1 -1
- package/dist/src/web/bridges/hooks/use-adaptor.d.ts +2 -0
- package/dist/src/web/bridges/hooks/use-adaptor.js +8 -0
- package/dist/src/web/bridges/hooks/use-adaptor.js.map +1 -0
- package/dist/src/web/bridges/hooks/use-bridge.d.ts +2 -3
- package/dist/src/web/bridges/hooks/use-bridge.js +5 -24
- package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -1
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +3 -2
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js +1 -1
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -1
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +9 -26
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -1
- package/dist/src/web/bridges/index.d.ts +1 -0
- package/dist/src/web/bridges/index.js +1 -0
- package/dist/src/web/bridges/index.js.map +1 -1
- package/dist/src/web/bridges/mcp-app-bridge.d.ts +19 -7
- package/dist/src/web/bridges/mcp-app-bridge.js +58 -26
- package/dist/src/web/bridges/mcp-app-bridge.js.map +1 -1
- package/dist/src/web/bridges/types.d.ts +57 -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.js +4 -2
- package/dist/src/web/data-llm.js.map +1 -1
- package/dist/src/web/generate-helpers.test-d.js +4 -1
- package/dist/src/web/generate-helpers.test-d.js.map +1 -1
- package/dist/src/web/hooks/test/utils.d.ts +10 -0
- package/dist/src/web/hooks/test/utils.js +40 -0
- package/dist/src/web/hooks/test/utils.js.map +1 -0
- package/dist/src/web/hooks/use-call-tool.js +12 -4
- package/dist/src/web/hooks/use-call-tool.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.test.js +26 -0
- package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.d.ts +1 -1
- 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-layout.js +3 -3
- package/dist/src/web/hooks/use-layout.js.map +1 -1
- package/dist/src/web/hooks/use-layout.test.js +87 -38
- package/dist/src/web/hooks/use-layout.test.js.map +1 -1
- package/dist/src/web/hooks/use-open-external.js +5 -3
- package/dist/src/web/hooks/use-open-external.js.map +1 -1
- package/dist/src/web/hooks/use-open-external.test.js +41 -15
- package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/src/web/hooks/use-send-follow-up-message.js +3 -6
- package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +12 -1
- package/dist/src/web/hooks/use-tool-info.js +15 -9
- package/dist/src/web/hooks/use-tool-info.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test-d.js +40 -4
- package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test.js +117 -47
- package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/src/web/hooks/use-user.js +2 -2
- package/dist/src/web/hooks/use-user.js.map +1 -1
- package/dist/src/web/hooks/use-user.test.js +83 -34
- package/dist/src/web/hooks/use-user.test.js.map +1 -1
- package/dist/src/web/plugin/transform-data-llm.js +6 -3
- package/dist/src/web/plugin/transform-data-llm.js.map +1 -1
- package/dist/src/web/types.d.ts +2 -4
- package/dist/src/web/types.js.map +1 -1
- package/package.json +7 -3
|
@@ -1,58 +1,128 @@
|
|
|
1
1
|
import { act, fireEvent, renderHook, waitFor } from "@testing-library/react";
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { McpAppAdaptor } from "../bridges/adaptors/mcp-app-adaptor.js";
|
|
4
|
+
import { McpAppBridge } from "../bridges/mcp-app-bridge.js";
|
|
3
5
|
import { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, } from "../types.js";
|
|
6
|
+
import { fireToolInputNotification, fireToolResultNotification, getMcpAppHostPostMessageMock, } from "./test/utils.js";
|
|
4
7
|
import { useToolInfo } from "./use-tool-info.js";
|
|
5
8
|
describe("useToolInfo", () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
vi.unstubAllGlobals();
|
|
18
|
-
vi.resetAllMocks();
|
|
19
|
-
});
|
|
20
|
-
it("should return toolInput on initial mount window.openai", () => {
|
|
21
|
-
const { result } = renderHook(() => useToolInfo());
|
|
22
|
-
expect(result.current).toMatchObject({
|
|
23
|
-
input: { name: "pokemon", args: { name: "pikachu" } },
|
|
24
|
-
status: "pending",
|
|
25
|
-
isPending: true,
|
|
26
|
-
isSuccess: false,
|
|
9
|
+
describe("apps-sdk host", () => {
|
|
10
|
+
let OpenaiMock;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
OpenaiMock = {
|
|
13
|
+
toolInput: { name: "pokemon", args: { name: "pikachu" } },
|
|
14
|
+
toolOutput: null,
|
|
15
|
+
toolResponseMetadata: null,
|
|
16
|
+
};
|
|
17
|
+
vi.stubGlobal("openai", OpenaiMock);
|
|
18
|
+
vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
|
|
27
19
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
name: "pikachu",
|
|
32
|
-
color: "yellow",
|
|
33
|
-
description: "When several of these POKéMON gather, their\felectricity could build and cause lightning storms.",
|
|
34
|
-
};
|
|
35
|
-
const toolResponseMetadata = { id: 12 };
|
|
36
|
-
const { result } = renderHook(() => useToolInfo());
|
|
37
|
-
act(() => {
|
|
38
|
-
OpenaiMock.toolOutput = toolOutput;
|
|
39
|
-
OpenaiMock.toolResponseMetadata = toolResponseMetadata;
|
|
40
|
-
fireEvent(window, new SetGlobalsEvent(SET_GLOBALS_EVENT_TYPE, {
|
|
41
|
-
detail: {
|
|
42
|
-
globals: {
|
|
43
|
-
toolOutput,
|
|
44
|
-
toolResponseMetadata,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
}));
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
vi.unstubAllGlobals();
|
|
22
|
+
vi.resetAllMocks();
|
|
48
23
|
});
|
|
49
|
-
|
|
24
|
+
it("should return toolInput on initial mount window.openai", () => {
|
|
25
|
+
const { result } = renderHook(() => useToolInfo());
|
|
50
26
|
expect(result.current).toMatchObject({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
27
|
+
input: { name: "pokemon", args: { name: "pikachu" } },
|
|
28
|
+
status: "pending",
|
|
29
|
+
isIdle: false,
|
|
30
|
+
isPending: true,
|
|
31
|
+
isSuccess: false,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
it("should eventually return tool output and response metadata once tool call completes", async () => {
|
|
35
|
+
const toolOutput = {
|
|
36
|
+
name: "pikachu",
|
|
37
|
+
color: "yellow",
|
|
38
|
+
description: "When several of these POKéMON gather, their\felectricity could build and cause lightning storms.",
|
|
39
|
+
};
|
|
40
|
+
const toolResponseMetadata = { id: 12 };
|
|
41
|
+
const { result } = renderHook(() => useToolInfo());
|
|
42
|
+
act(() => {
|
|
43
|
+
OpenaiMock.toolOutput = toolOutput;
|
|
44
|
+
OpenaiMock.toolResponseMetadata = toolResponseMetadata;
|
|
45
|
+
fireEvent(window, new SetGlobalsEvent(SET_GLOBALS_EVENT_TYPE, {
|
|
46
|
+
detail: {
|
|
47
|
+
globals: {
|
|
48
|
+
toolOutput,
|
|
49
|
+
toolResponseMetadata,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
53
|
+
});
|
|
54
|
+
await waitFor(() => {
|
|
55
|
+
expect(result.current).toMatchObject({
|
|
56
|
+
status: "success",
|
|
57
|
+
isIdle: false,
|
|
58
|
+
isPending: false,
|
|
59
|
+
isSuccess: true,
|
|
60
|
+
output: toolOutput,
|
|
61
|
+
responseMetadata: toolResponseMetadata,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
describe("mcp-app host", () => {
|
|
67
|
+
beforeEach(() => {
|
|
68
|
+
vi.stubGlobal("parent", { postMessage: getMcpAppHostPostMessageMock() });
|
|
69
|
+
vi.stubGlobal("skybridge", { hostType: "mcp-app" });
|
|
70
|
+
});
|
|
71
|
+
afterEach(() => {
|
|
72
|
+
vi.unstubAllGlobals();
|
|
73
|
+
vi.resetAllMocks();
|
|
74
|
+
McpAppBridge.resetInstance();
|
|
75
|
+
McpAppAdaptor.resetInstance();
|
|
76
|
+
});
|
|
77
|
+
it("should return idle state initially when tool input is not yet set", async () => {
|
|
78
|
+
const { result } = renderHook(() => useToolInfo());
|
|
79
|
+
await waitFor(() => {
|
|
80
|
+
expect(result.current).toMatchObject({
|
|
81
|
+
status: "idle",
|
|
82
|
+
isIdle: true,
|
|
83
|
+
isPending: false,
|
|
84
|
+
isSuccess: false,
|
|
85
|
+
input: null,
|
|
86
|
+
output: null,
|
|
87
|
+
responseMetadata: null,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
it("should return pending state with tool input from tool-input notification", async () => {
|
|
92
|
+
const { result } = renderHook(() => useToolInfo());
|
|
93
|
+
act(() => {
|
|
94
|
+
fireToolInputNotification({ name: "pokemon", query: "pikachu" });
|
|
95
|
+
});
|
|
96
|
+
await waitFor(() => {
|
|
97
|
+
expect(result.current).toMatchObject({
|
|
98
|
+
status: "pending",
|
|
99
|
+
isIdle: false,
|
|
100
|
+
isPending: true,
|
|
101
|
+
isSuccess: false,
|
|
102
|
+
input: { name: "pokemon", query: "pikachu" },
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
it("should return success state with output from tool-result notification", async () => {
|
|
107
|
+
const { result } = renderHook(() => useToolInfo());
|
|
108
|
+
act(() => {
|
|
109
|
+
fireToolInputNotification({ name: "pokemon", query: "pikachu" });
|
|
110
|
+
fireToolResultNotification({
|
|
111
|
+
content: [{ type: "text", text: "Pikachu data" }],
|
|
112
|
+
structuredContent: { name: "pikachu", color: "yellow" },
|
|
113
|
+
_meta: { requestId: "123" },
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
await waitFor(() => {
|
|
117
|
+
expect(result.current).toMatchObject({
|
|
118
|
+
status: "success",
|
|
119
|
+
isIdle: false,
|
|
120
|
+
isPending: false,
|
|
121
|
+
isSuccess: true,
|
|
122
|
+
input: { name: "pokemon", query: "pikachu" },
|
|
123
|
+
output: { name: "pikachu", color: "yellow" },
|
|
124
|
+
responseMetadata: { requestId: "123" },
|
|
125
|
+
});
|
|
56
126
|
});
|
|
57
127
|
});
|
|
58
128
|
});
|
|
@@ -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;
|
|
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,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAEL,sBAAsB,EACtB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,IAAI,UAGH,CAAC;QAEF,UAAU,CAAC,GAAG,EAAE;YACd,UA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AC;gBACjE,0BAA0B,CAAC;oBACzB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;oBACjD,iBAAiB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;oBACvD,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;iBAC5B,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,MAAM,OAAO,CAAC,GAAG,EAAE;gBACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;oBACnC,MAAM,EAAE,SAAS;oBACjB,MAAM,EAAE,KAAK;oBACb,SAAS,EAAE,KAAK;oBAChB,SAAS,EAAE,IAAI;oBACf,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;oBAC5C,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;oBAC5C,gBAAgB,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;iBACvC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useBridge } from "../bridges/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Hook for accessing session-stable user information.
|
|
4
4
|
* These values are set once at initialization and do not change during the session.
|
|
@@ -13,7 +13,7 @@ import { useAppsSdkBridge, useBridge } from "../bridges/index.js";
|
|
|
13
13
|
*/
|
|
14
14
|
export function useUser() {
|
|
15
15
|
const locale = useBridge("locale");
|
|
16
|
-
const userAgent =
|
|
16
|
+
const userAgent = useBridge("userAgent");
|
|
17
17
|
return { locale, userAgent };
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=use-user.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-user.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-user.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQhD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,OAAO;IACrB,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -1,44 +1,93 @@
|
|
|
1
|
-
import { renderHook } from "@testing-library/react";
|
|
1
|
+
import { renderHook, waitFor } from "@testing-library/react";
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { McpAppAdaptor } from "../bridges/adaptors/mcp-app-adaptor.js";
|
|
4
|
+
import { McpAppBridge } from "../bridges/mcp-app-bridge.js";
|
|
5
|
+
import { getMcpAppHostPostMessageMock } from "./test/utils.js";
|
|
3
6
|
import { useUser } from "./use-user.js";
|
|
4
7
|
describe("useUser", () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
describe("apps-sdk host type", () => {
|
|
9
|
+
let OpenaiMock;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
OpenaiMock = {
|
|
12
|
+
locale: "en-US",
|
|
13
|
+
userAgent: {
|
|
14
|
+
device: { type: "desktop" },
|
|
15
|
+
capabilities: { hover: true, touch: false },
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
vi.stubGlobal("openai", OpenaiMock);
|
|
19
|
+
vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
vi.unstubAllGlobals();
|
|
23
|
+
vi.resetAllMocks();
|
|
24
|
+
});
|
|
25
|
+
it("should return locale and userAgent from window.openai", () => {
|
|
26
|
+
const { result } = renderHook(() => useUser());
|
|
27
|
+
expect(result.current.locale).toBe("en-US");
|
|
28
|
+
expect(result.current.userAgent).toEqual({
|
|
10
29
|
device: { type: "desktop" },
|
|
11
30
|
capabilities: { hover: true, touch: false },
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
it("should return mobile userAgent when set to mobile", () => {
|
|
34
|
+
OpenaiMock.userAgent = {
|
|
35
|
+
device: { type: "mobile" },
|
|
36
|
+
capabilities: { hover: false, touch: true },
|
|
37
|
+
};
|
|
38
|
+
const { result } = renderHook(() => useUser());
|
|
39
|
+
expect(result.current.userAgent.device.type).toBe("mobile");
|
|
40
|
+
expect(result.current.userAgent.capabilities.touch).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
it("should return different locale when set", () => {
|
|
43
|
+
OpenaiMock.locale = "es-ES";
|
|
44
|
+
const { result } = renderHook(() => useUser());
|
|
45
|
+
expect(result.current.locale).toBe("es-ES");
|
|
27
46
|
});
|
|
28
47
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
describe("mcp-app host type", () => {
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
vi.stubGlobal("skybridge", { hostType: "mcp-app" });
|
|
51
|
+
});
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
vi.unstubAllGlobals();
|
|
54
|
+
vi.resetAllMocks();
|
|
55
|
+
McpAppBridge.resetInstance();
|
|
56
|
+
McpAppAdaptor.resetInstance();
|
|
57
|
+
});
|
|
58
|
+
it("should return locale and userAgent from mcp host context", async () => {
|
|
59
|
+
vi.stubGlobal("parent", {
|
|
60
|
+
postMessage: getMcpAppHostPostMessageMock({
|
|
61
|
+
locale: "fr-FR",
|
|
62
|
+
platform: "web",
|
|
63
|
+
deviceCapabilities: { hover: true, touch: false },
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
const { result } = renderHook(() => useUser());
|
|
67
|
+
await waitFor(() => {
|
|
68
|
+
expect(result.current.locale).toBe("fr-FR");
|
|
69
|
+
expect(result.current.userAgent).toEqual({
|
|
70
|
+
device: { type: "desktop" },
|
|
71
|
+
capabilities: { hover: true, touch: false },
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
it("should maintain userAgent referential stability when data has not changed", async () => {
|
|
76
|
+
vi.stubGlobal("parent", {
|
|
77
|
+
postMessage: getMcpAppHostPostMessageMock({
|
|
78
|
+
locale: "en-US",
|
|
79
|
+
platform: "web",
|
|
80
|
+
deviceCapabilities: { hover: true, touch: false },
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
const { result, rerender } = renderHook(() => useUser());
|
|
84
|
+
await waitFor(() => {
|
|
85
|
+
expect(result.current.userAgent).toBeDefined();
|
|
86
|
+
});
|
|
87
|
+
const initialUserAgent = result.current.userAgent;
|
|
88
|
+
rerender();
|
|
89
|
+
expect(result.current.userAgent).toBe(initialUserAgent);
|
|
90
|
+
});
|
|
42
91
|
});
|
|
43
92
|
});
|
|
44
93
|
//# sourceMappingURL=use-user.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-user.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CA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EAAE;gBACtB,WAAW,EAAE,4BAA4B,CAAC;oBACxC,MAAM,EAAE,OAAO;oBACf,QAAQ,EAAE,KAAK;oBACf,kBAAkB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;iBAClD,CAAC;aACH,CAAC,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YAEzD,MAAM,OAAO,CAAC,GAAG,EAAE;gBACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;YACjD,CAAC,CAAC,CAAC;YAEH,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;YAElD,QAAQ,EAAE,CAAC;YAEX,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -8,10 +8,12 @@ function createBabelPlugin(t) {
|
|
|
8
8
|
state.hasDataLLMImport = false;
|
|
9
9
|
state.needsDataLLMImport = false;
|
|
10
10
|
for (const node of path.node.body) {
|
|
11
|
-
if (!t.isImportDeclaration(node))
|
|
11
|
+
if (!t.isImportDeclaration(node)) {
|
|
12
12
|
continue;
|
|
13
|
-
|
|
13
|
+
}
|
|
14
|
+
if (node.source.value !== LLM_IMPORT_SOURCE) {
|
|
14
15
|
continue;
|
|
16
|
+
}
|
|
15
17
|
const hasSpecifier = node.specifiers.some((s) => t.isImportSpecifier(s) &&
|
|
16
18
|
t.isIdentifier(s.imported, { name: "DataLLM" }));
|
|
17
19
|
if (hasSpecifier) {
|
|
@@ -34,8 +36,9 @@ function createBabelPlugin(t) {
|
|
|
34
36
|
const attributes = opening.attributes;
|
|
35
37
|
const llmAttributeIndex = attributes.findIndex((attribute) => t.isJSXAttribute(attribute) &&
|
|
36
38
|
t.isJSXIdentifier(attribute.name, { name: "data-llm" }));
|
|
37
|
-
if (llmAttributeIndex === -1)
|
|
39
|
+
if (llmAttributeIndex === -1) {
|
|
38
40
|
return;
|
|
41
|
+
}
|
|
39
42
|
const llmAttribute = attributes[llmAttributeIndex];
|
|
40
43
|
let contentExpression;
|
|
41
44
|
if (t.isStringLiteral(llmAttribute.value)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-data-llm.js","sourceRoot":"","sources":["../../../../src/web/plugin/transform-data-llm.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAO1C,SAAS,iBAAiB,CAAC,CAAe;IACxC,OAAO;QACL,IAAI,EAAE,gBAAgB;QAEtB,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,KAAK,CAAC,IAAI,EAAE,KAAK;oBACf,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC;oBAC/B,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC;oBAEjC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;wBAClC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"transform-data-llm.js","sourceRoot":"","sources":["../../../../src/web/plugin/transform-data-llm.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAO1C,SAAS,iBAAiB,CAAC,CAAe;IACxC,OAAO;QACL,IAAI,EAAE,gBAAgB;QAEtB,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,KAAK,CAAC,IAAI,EAAE,KAAK;oBACf,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC;oBAC/B,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC;oBAEjC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IA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CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,IAAI;KACxB,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/src/web/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "react";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
3
|
import type { WidgetHostType } from "../server/index.js";
|
|
3
4
|
declare module "react" {
|
|
4
5
|
interface HTMLAttributes<T> {
|
|
@@ -56,10 +57,7 @@ export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unk
|
|
|
56
57
|
};
|
|
57
58
|
export type CallToolArgs = Record<string, unknown> | null;
|
|
58
59
|
export type CallToolResponse = {
|
|
59
|
-
content:
|
|
60
|
-
type: "text";
|
|
61
|
-
text: string;
|
|
62
|
-
}[];
|
|
60
|
+
content: CallToolResult["content"];
|
|
63
61
|
structuredContent: Record<string, unknown>;
|
|
64
62
|
isError: boolean;
|
|
65
63
|
result: string;
|
|
@@ -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;AAyBf,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AAuGD,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.fd77b0f",
|
|
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"
|
|
@@ -41,6 +45,7 @@
|
|
|
41
45
|
"dependencies": {
|
|
42
46
|
"@babel/core": "^7.28.5",
|
|
43
47
|
"cors": "^2.8.5",
|
|
48
|
+
"dequal": "^2.0.3",
|
|
44
49
|
"express": "^5.1.0",
|
|
45
50
|
"handlebars": "^4.7.8",
|
|
46
51
|
"superjson": "^2.2.6",
|
|
@@ -48,7 +53,6 @@
|
|
|
48
53
|
"zustand": "^5.0.9"
|
|
49
54
|
},
|
|
50
55
|
"devDependencies": {
|
|
51
|
-
"@biomejs/biome": "2.3.8",
|
|
52
56
|
"@modelcontextprotocol/ext-apps": "^0.2.2",
|
|
53
57
|
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
54
58
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -57,7 +61,7 @@
|
|
|
57
61
|
"@types/babel__core": "^7.20.5",
|
|
58
62
|
"@types/cors": "^2.8.19",
|
|
59
63
|
"@types/express": "^5.0.3",
|
|
60
|
-
"@types/jsdom": "^21.1.
|
|
64
|
+
"@types/jsdom": "^21.1.7",
|
|
61
65
|
"@types/node": "^22.15.30",
|
|
62
66
|
"@types/react": "^19.2.2",
|
|
63
67
|
"@types/react-dom": "^19.2.2",
|