skybridge 0.0.0-dev.d3a72fb → 0.0.0-dev.d425dbf
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/LICENSE +21 -0
- package/dist/src/server/devtoolsStaticServer.d.ts +6 -2
- package/dist/src/server/devtoolsStaticServer.js +23 -13
- package/dist/src/server/devtoolsStaticServer.js.map +1 -1
- package/dist/src/server/server.js +1 -1
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/server/templates/development.hbs +39 -1
- package/dist/src/server/widgetsDevServer.js +0 -1
- package/dist/src/server/widgetsDevServer.js.map +1 -1
- package/dist/src/test/widget.test.js +4 -7
- package/dist/src/test/widget.test.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.js +3 -14
- package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -1
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +6 -15
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -1
- package/dist/src/web/bridges/index.d.ts +1 -1
- package/dist/src/web/bridges/index.js +1 -1
- package/dist/src/web/bridges/index.js.map +1 -1
- package/dist/src/web/bridges/mcp-app-bridge.d.ts +4 -3
- package/dist/src/web/bridges/mcp-app-bridge.js.map +1 -1
- package/dist/src/web/bridges/types.d.ts +20 -9
- package/dist/src/web/hooks/test/utils.d.ts +2 -2
- package/dist/src/web/hooks/test/utils.js +9 -8
- package/dist/src/web/hooks/test/utils.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.js +3 -3
- package/dist/src/web/hooks/use-call-tool.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.d.ts +3 -3
- package/dist/src/web/hooks/use-display-mode.js +3 -3
- package/dist/src/web/hooks/use-display-mode.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 +4 -2
- package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test.js +4 -3
- package/dist/src/web/hooks/use-tool-info.test.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/package.json +25 -26
- package/dist/src/web/bridges/apps-sdk-adapter.d.ts +0 -4
- package/dist/src/web/bridges/apps-sdk-adapter.js +0 -10
- package/dist/src/web/bridges/apps-sdk-adapter.js.map +0 -1
- package/dist/src/web/bridges/get-bridge-methods.d.ts +0 -2
- package/dist/src/web/bridges/get-bridge-methods.js +0 -8
- package/dist/src/web/bridges/get-bridge-methods.js.map +0 -1
- package/dist/src/web/bridges/hooks/types.d.ts +0 -6
- package/dist/src/web/bridges/hooks/types.js +0 -2
- package/dist/src/web/bridges/hooks/types.js.map +0 -1
- package/dist/src/web/bridges/mcp-app-adapter.d.ts +0 -6
- package/dist/src/web/bridges/mcp-app-adapter.js +0 -80
- package/dist/src/web/bridges/mcp-app-adapter.js.map +0 -1
|
@@ -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,CAAC;
|
|
1
|
+
{"version":3,"file":"use-user.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7D,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;AAE5D,OAAO,EAAE,4BAA4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,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"}
|
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.d425dbf",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT apps",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,15 +20,6 @@
|
|
|
20
20
|
"default": "./dist/src/web/index.js"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "tsc && pnpm run build:templates",
|
|
25
|
-
"build:templates": "cp -r src/server/templates dist/src/server/",
|
|
26
|
-
"format": "biome check --write --error-on-warnings",
|
|
27
|
-
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
28
|
-
"test:unit": "vitest run",
|
|
29
|
-
"test:type": "tsc --noEmit",
|
|
30
|
-
"test:format": "biome ci"
|
|
31
|
-
},
|
|
32
23
|
"keywords": [
|
|
33
24
|
"chatgpt",
|
|
34
25
|
"app",
|
|
@@ -45,31 +36,39 @@
|
|
|
45
36
|
"dependencies": {
|
|
46
37
|
"@babel/core": "^7.28.5",
|
|
47
38
|
"cors": "^2.8.5",
|
|
48
|
-
"
|
|
39
|
+
"dequal": "^2.0.3",
|
|
40
|
+
"express": "^5.2.1",
|
|
49
41
|
"handlebars": "^4.7.8",
|
|
50
42
|
"superjson": "^2.2.6",
|
|
51
|
-
"vite": "^7.
|
|
43
|
+
"vite": "^7.3.0",
|
|
52
44
|
"zustand": "^5.0.9"
|
|
53
45
|
},
|
|
54
46
|
"devDependencies": {
|
|
55
|
-
"@biomejs/biome": "2.3.8",
|
|
56
47
|
"@modelcontextprotocol/ext-apps": "^0.2.2",
|
|
57
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
48
|
+
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
58
49
|
"@testing-library/dom": "^10.4.1",
|
|
59
|
-
"@testing-library/react": "^16.3.
|
|
50
|
+
"@testing-library/react": "^16.3.1",
|
|
60
51
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
61
52
|
"@types/babel__core": "^7.20.5",
|
|
62
53
|
"@types/cors": "^2.8.19",
|
|
63
|
-
"@types/express": "^5.0.
|
|
64
|
-
"@types/jsdom": "^
|
|
65
|
-
"@types/node": "^22.
|
|
66
|
-
"@types/react": "^19.2.
|
|
67
|
-
"@types/react-dom": "^19.2.
|
|
68
|
-
"@vitest/ui": "^
|
|
69
|
-
"jsdom": "^
|
|
54
|
+
"@types/express": "^5.0.6",
|
|
55
|
+
"@types/jsdom": "^27.0.0",
|
|
56
|
+
"@types/node": "^22.19.3",
|
|
57
|
+
"@types/react": "^19.2.7",
|
|
58
|
+
"@types/react-dom": "^19.2.3",
|
|
59
|
+
"@vitest/ui": "^4.0.16",
|
|
60
|
+
"jsdom": "^27.4.0",
|
|
70
61
|
"typescript": "^5.9.3",
|
|
71
|
-
"vitest": "^
|
|
72
|
-
"zod": "^4.
|
|
62
|
+
"vitest": "^4.0.16",
|
|
63
|
+
"zod": "^4.3.5"
|
|
73
64
|
},
|
|
74
|
-
"
|
|
75
|
-
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsc && pnpm run build:templates",
|
|
67
|
+
"build:templates": "cp -r src/server/templates dist/src/server/",
|
|
68
|
+
"format": "biome check --write --error-on-warnings",
|
|
69
|
+
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
70
|
+
"test:unit": "vitest run",
|
|
71
|
+
"test:type": "tsc --noEmit",
|
|
72
|
+
"test:format": "biome ci"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { CallToolResponse, Methods } from "./types.js";
|
|
2
|
-
export declare const callTool: <ToolArgs extends Record<string, unknown> | null = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
3
|
-
export declare const requestDisplayMode: Methods["requestDisplayMode"];
|
|
4
|
-
export declare const sendFollowUpMessage: Methods["sendFollowUpMessage"];
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const callTool = async (name, args) => {
|
|
2
|
-
return window.openai.callTool(name, args);
|
|
3
|
-
};
|
|
4
|
-
export const requestDisplayMode = ({ mode }) => {
|
|
5
|
-
return window.openai.requestDisplayMode({ mode });
|
|
6
|
-
};
|
|
7
|
-
export const sendFollowUpMessage = (prompt) => {
|
|
8
|
-
return window.openai.sendFollowUpMessage({ prompt });
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=apps-sdk-adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apps-sdk-adapter.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk-adapter.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAI3B,IAAY,EACZ,IAAc,EACS,EAAE;IACzB,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAyB,IAAI,EAAE,IAAI,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAkC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAmC,CAAC,MAAM,EAAE,EAAE;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as AppsSdkAdapter from "./apps-sdk-adapter.js";
|
|
2
|
-
import * as McpAppAdapter from "./mcp-app-adapter.js";
|
|
3
|
-
export const getBridgeMethods = () => {
|
|
4
|
-
return window.skybridge.hostType === "apps-sdk"
|
|
5
|
-
? AppsSdkAdapter
|
|
6
|
-
: McpAppAdapter;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=get-bridge-methods.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-bridge-methods.js","sourceRoot":"","sources":["../../../../src/web/bridges/get-bridge-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAC;AAGtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAY,EAAE;IAC5C,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU;QAC7C,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,aAAa,CAAC;AACpB,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/web/bridges/hooks/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BridgeExternalStore } from "./hooks/types.js";
|
|
2
|
-
import type { BridgeInterface, CallToolResponse, Methods } from "./types.js";
|
|
3
|
-
export declare const callTool: <ToolArgs extends Record<string, unknown> | null = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
4
|
-
export declare const requestDisplayMode: Methods["requestDisplayMode"];
|
|
5
|
-
export declare const sendFollowUpMessage: Methods["sendFollowUpMessage"];
|
|
6
|
-
export declare const getMcpAppAdapter: () => { [K in keyof BridgeInterface]: BridgeExternalStore<K>; };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { McpAppBridge, } from "./mcp-app-bridge.js";
|
|
2
|
-
export const callTool = async (name, args) => {
|
|
3
|
-
const bridge = McpAppBridge.getInstance();
|
|
4
|
-
const response = await bridge.request({
|
|
5
|
-
method: "tools/call",
|
|
6
|
-
params: {
|
|
7
|
-
name,
|
|
8
|
-
arguments: args ?? undefined,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
const result = response.content
|
|
12
|
-
.filter((content) => content.type === "text")
|
|
13
|
-
.map(({ text }) => text)
|
|
14
|
-
.join("\n");
|
|
15
|
-
return {
|
|
16
|
-
content: response.content,
|
|
17
|
-
structuredContent: response.structuredContent ?? {},
|
|
18
|
-
isError: response.isError ?? false,
|
|
19
|
-
result,
|
|
20
|
-
meta: response._meta ?? {},
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export const requestDisplayMode = ({ mode }) => {
|
|
24
|
-
const bridge = McpAppBridge.getInstance();
|
|
25
|
-
if (mode !== "modal") {
|
|
26
|
-
return bridge.request({
|
|
27
|
-
method: "ui/request-display-mode",
|
|
28
|
-
params: { mode },
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
throw new Error("Modal display mode is not accessible in MCP App.");
|
|
32
|
-
};
|
|
33
|
-
export const sendFollowUpMessage = async (prompt) => {
|
|
34
|
-
const bridge = McpAppBridge.getInstance();
|
|
35
|
-
await bridge.request({
|
|
36
|
-
method: "ui/message",
|
|
37
|
-
params: {
|
|
38
|
-
role: "user",
|
|
39
|
-
content: [
|
|
40
|
-
{
|
|
41
|
-
type: "text",
|
|
42
|
-
text: prompt,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
const createExternalStore = (keys, getSnapshot) => {
|
|
49
|
-
const bridge = McpAppBridge.getInstance();
|
|
50
|
-
return {
|
|
51
|
-
subscribe: bridge.subscribe(keys),
|
|
52
|
-
getSnapshot: () => {
|
|
53
|
-
const context = Object.fromEntries(keys.map((k) => [k, bridge.getSnapshot(k)]));
|
|
54
|
-
return getSnapshot(context);
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export const getMcpAppAdapter = () => ({
|
|
59
|
-
theme: createExternalStore(["theme"], ({ theme }) => theme ?? "light"),
|
|
60
|
-
locale: createExternalStore(["locale"], ({ locale }) => locale ?? "en-US"),
|
|
61
|
-
safeArea: createExternalStore(["safeAreaInsets"], ({ safeAreaInsets }) => ({
|
|
62
|
-
insets: safeAreaInsets ?? { top: 0, right: 0, bottom: 0, left: 0 },
|
|
63
|
-
})),
|
|
64
|
-
displayMode: createExternalStore(["displayMode"], ({ displayMode }) => displayMode ?? "inline"),
|
|
65
|
-
maxHeight: createExternalStore(["viewport"], ({ viewport }) => viewport?.maxHeight ?? window.innerHeight),
|
|
66
|
-
userAgent: createExternalStore(["platform", "deviceCapabilities"], ({ platform, deviceCapabilities }) => ({
|
|
67
|
-
device: {
|
|
68
|
-
type: platform === "web" ? "desktop" : (platform ?? "unknown"),
|
|
69
|
-
},
|
|
70
|
-
capabilities: {
|
|
71
|
-
hover: true,
|
|
72
|
-
touch: true,
|
|
73
|
-
...deviceCapabilities,
|
|
74
|
-
},
|
|
75
|
-
})),
|
|
76
|
-
toolInput: createExternalStore(["toolInput"], ({ toolInput }) => toolInput ?? null),
|
|
77
|
-
toolOutput: createExternalStore(["toolResult"], ({ toolResult }) => toolResult?.structuredContent ?? null),
|
|
78
|
-
toolResponseMetadata: createExternalStore(["toolResult"], ({ toolResult }) => toolResult?._meta ?? null),
|
|
79
|
-
});
|
|
80
|
-
//# sourceMappingURL=mcp-app-adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-app-adapter.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app-adapter.ts"],"names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