skybridge 0.0.0-dev.72ef616 → 0.0.0-dev.760fce0

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.
Files changed (59) hide show
  1. package/dist/src/server/server.js +1 -1
  2. package/dist/src/server/server.js.map +1 -1
  3. package/dist/src/server/widgetsDevServer.js +0 -1
  4. package/dist/src/server/widgetsDevServer.js.map +1 -1
  5. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.d.ts +13 -0
  6. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js +33 -0
  7. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js.map +1 -0
  8. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.d.ts +16 -0
  9. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js +115 -0
  10. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js.map +1 -0
  11. package/dist/src/web/bridges/apps-sdk-bridge.d.ts +4 -2
  12. package/dist/src/web/bridges/apps-sdk-bridge.js +19 -14
  13. package/dist/src/web/bridges/apps-sdk-bridge.js.map +1 -1
  14. package/dist/src/web/bridges/hooks/use-adaptor.d.ts +2 -0
  15. package/dist/src/web/bridges/hooks/use-adaptor.js +8 -0
  16. package/dist/src/web/bridges/hooks/use-adaptor.js.map +1 -0
  17. package/dist/src/web/bridges/hooks/use-bridge.js +3 -14
  18. package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -1
  19. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +6 -15
  20. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -1
  21. package/dist/src/web/bridges/index.d.ts +1 -1
  22. package/dist/src/web/bridges/index.js +1 -1
  23. package/dist/src/web/bridges/index.js.map +1 -1
  24. package/dist/src/web/bridges/mcp-app-bridge.d.ts +4 -3
  25. package/dist/src/web/bridges/mcp-app-bridge.js.map +1 -1
  26. package/dist/src/web/bridges/types.d.ts +20 -9
  27. package/dist/src/web/hooks/test/utils.d.ts +2 -2
  28. package/dist/src/web/hooks/test/utils.js +9 -8
  29. package/dist/src/web/hooks/test/utils.js.map +1 -1
  30. package/dist/src/web/hooks/use-call-tool.js +3 -3
  31. package/dist/src/web/hooks/use-call-tool.js.map +1 -1
  32. package/dist/src/web/hooks/use-display-mode.d.ts +3 -3
  33. package/dist/src/web/hooks/use-display-mode.js +3 -3
  34. package/dist/src/web/hooks/use-display-mode.js.map +1 -1
  35. package/dist/src/web/hooks/use-layout.test.js +87 -38
  36. package/dist/src/web/hooks/use-layout.test.js.map +1 -1
  37. package/dist/src/web/hooks/use-open-external.js +5 -3
  38. package/dist/src/web/hooks/use-open-external.js.map +1 -1
  39. package/dist/src/web/hooks/use-open-external.test.js +41 -15
  40. package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
  41. package/dist/src/web/hooks/use-send-follow-up-message.js +4 -2
  42. package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -1
  43. package/dist/src/web/hooks/use-tool-info.test.js +4 -3
  44. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
  45. package/dist/src/web/hooks/use-user.test.js +83 -34
  46. package/dist/src/web/hooks/use-user.test.js.map +1 -1
  47. package/package.json +2 -2
  48. package/dist/src/web/bridges/apps-sdk-adapter.d.ts +0 -4
  49. package/dist/src/web/bridges/apps-sdk-adapter.js +0 -10
  50. package/dist/src/web/bridges/apps-sdk-adapter.js.map +0 -1
  51. package/dist/src/web/bridges/get-bridge-methods.d.ts +0 -2
  52. package/dist/src/web/bridges/get-bridge-methods.js +0 -8
  53. package/dist/src/web/bridges/get-bridge-methods.js.map +0 -1
  54. package/dist/src/web/bridges/hooks/types.d.ts +0 -6
  55. package/dist/src/web/bridges/hooks/types.js +0 -2
  56. package/dist/src/web/bridges/hooks/types.js.map +0 -1
  57. package/dist/src/web/bridges/mcp-app-adapter.d.ts +0 -6
  58. package/dist/src/web/bridges/mcp-app-adapter.js +0 -80
  59. package/dist/src/web/bridges/mcp-app-adapter.js.map +0 -1
@@ -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":[],"mappings":"AAYA,OAAO,EACL,YAAY,GAGb,MAAM,qBAAqB,CAAC;AAG7B,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAI3B,IAAY,EACZ,IAAc,EACS,EAAE;IACzB,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC;IAC1C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAkC;QACrE,MAAM,EAAE,YAAY;QACpB,MAAM,EAAE;YACN,IAAI;YACJ,SAAS,EAAE,IAAI,IAAI,SAAS;SAC7B;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO;SAC5B,MAAM,CACL,CAAC,OAAO,EAA6C,EAAE,CACrD,OAAO,CAAC,IAAI,KAAK,MAAM,CAC1B;SACA,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;SACvB,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;QACL,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,IAAI,EAAE;QACnD,OAAO,EAAE,QAAQ,CAAC,OAAO,IA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