skybridge 0.0.0-dev.d1820df → 0.0.0-dev.d26cb78
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/cli/header.d.ts +4 -0
- package/dist/cli/header.js +6 -0
- package/dist/cli/header.js.map +1 -0
- package/dist/cli/run-command.d.ts +2 -0
- package/dist/cli/run-command.js +43 -0
- package/dist/cli/run-command.js.map +1 -0
- package/dist/cli/use-execute-steps.d.ts +10 -0
- package/dist/cli/use-execute-steps.js +31 -0
- package/dist/cli/use-execute-steps.js.map +1 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.js +44 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/dev.js +8 -18
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.d.ts +7 -0
- package/dist/commands/start.js +33 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/server/server.d.ts +2 -4
- package/dist/server/server.js +59 -53
- package/dist/server/server.js.map +1 -1
- package/dist/test/widget.test.js +21 -0
- package/dist/test/widget.test.js.map +1 -1
- package/dist/web/bridges/{adaptors/apps-sdk-adaptor.d.ts → apps-sdk/adaptor.d.ts} +3 -2
- package/dist/web/bridges/{adaptors/apps-sdk-adaptor.js → apps-sdk/adaptor.js} +9 -3
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +10 -0
- package/dist/web/bridges/{apps-sdk-bridge.js → apps-sdk/bridge.js} +2 -2
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
- package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
- package/dist/web/bridges/apps-sdk/index.js +5 -0
- package/dist/web/bridges/apps-sdk/index.js.map +1 -0
- package/dist/web/bridges/apps-sdk/types.d.ts +121 -0
- package/dist/web/bridges/apps-sdk/types.js +10 -0
- package/dist/web/bridges/apps-sdk/types.js.map +1 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +2 -0
- package/dist/web/bridges/{hooks/use-apps-sdk-bridge.js → apps-sdk/use-apps-sdk-context.js} +3 -3
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
- package/dist/web/bridges/get-adaptor.d.ts +2 -0
- package/dist/web/bridges/get-adaptor.js +8 -0
- package/dist/web/bridges/get-adaptor.js.map +1 -0
- package/dist/web/bridges/index.d.ts +5 -4
- package/dist/web/bridges/index.js +5 -4
- package/dist/web/bridges/index.js.map +1 -1
- package/dist/web/bridges/{adaptors/mcp-app-adaptor.d.ts → mcp-app/adaptor.d.ts} +6 -3
- package/dist/web/bridges/{adaptors/mcp-app-adaptor.js → mcp-app/adaptor.js} +44 -14
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
- package/dist/web/bridges/{mcp-app-bridge.d.ts → mcp-app/bridge.d.ts} +10 -13
- package/dist/web/bridges/{mcp-app-bridge.js → mcp-app/bridge.js} +71 -33
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
- package/dist/web/bridges/mcp-app/index.d.ts +4 -0
- package/dist/web/bridges/mcp-app/index.js +4 -0
- package/dist/web/bridges/mcp-app/index.js.map +1 -0
- package/dist/web/bridges/mcp-app/types.d.ts +8 -0
- package/dist/web/bridges/mcp-app/types.js +2 -0
- package/dist/web/bridges/mcp-app/types.js.map +1 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -0
- package/dist/web/bridges/{hooks/use-mcp-app-bridge.js → mcp-app/use-mcp-app-context.js} +3 -3
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
- package/dist/web/bridges/{hooks/use-mcp-app-bridge.test.js → mcp-app/use-mcp-app-context.test.js} +17 -13
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
- package/dist/web/bridges/types.d.ts +41 -24
- package/dist/web/bridges/use-host-context.d.ts +2 -0
- package/dist/web/bridges/use-host-context.js +8 -0
- package/dist/web/bridges/use-host-context.js.map +1 -0
- package/dist/web/create-store.js +6 -7
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +108 -52
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.js +5 -3
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +128 -65
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +3 -2
- package/dist/web/generate-helpers.js +1 -1
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/helpers/state.js +13 -8
- package/dist/web/helpers/state.js.map +1 -1
- package/dist/web/hooks/index.d.ts +0 -1
- package/dist/web/hooks/index.js +0 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.d.ts +8 -2
- package/dist/web/hooks/test/utils.js +33 -13
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.d.ts +3 -2
- package/dist/web/hooks/use-call-tool.js +2 -2
- package/dist/web/hooks/use-call-tool.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test-d.js +1 -1
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +3 -3
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-display-mode.js +3 -4
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-layout.d.ts +2 -2
- package/dist/web/hooks/use-layout.js +4 -4
- package/dist/web/hooks/use-layout.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +6 -5
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.js +2 -2
- package/dist/web/hooks/use-open-external.test.js +1 -1
- package/dist/web/hooks/use-request-modal.d.ts +1 -1
- package/dist/web/hooks/use-request-modal.js +2 -2
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-send-follow-up-message.js +2 -2
- package/dist/web/hooks/use-tool-info.js +4 -4
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +4 -4
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.d.ts +1 -1
- package/dist/web/hooks/use-user.js +3 -3
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +4 -3
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-widget-state.js +10 -10
- package/dist/web/hooks/use-widget-state.js.map +1 -1
- package/dist/web/types.d.ts +0 -133
- package/dist/web/types.js +0 -9
- package/dist/web/types.js.map +1 -1
- package/package.json +9 -9
- package/dist/cli/use-version.d.ts +0 -1
- package/dist/cli/use-version.js +0 -33
- package/dist/cli/use-version.js.map +0 -1
- package/dist/web/bridges/adaptors/apps-sdk-adaptor.js.map +0 -1
- package/dist/web/bridges/adaptors/mcp-app-adaptor.js.map +0 -1
- package/dist/web/bridges/apps-sdk-bridge.d.ts +0 -10
- package/dist/web/bridges/apps-sdk-bridge.js.map +0 -1
- package/dist/web/bridges/hooks/use-adaptor.d.ts +0 -2
- package/dist/web/bridges/hooks/use-adaptor.js +0 -8
- package/dist/web/bridges/hooks/use-adaptor.js.map +0 -1
- package/dist/web/bridges/hooks/use-apps-sdk-bridge.d.ts +0 -2
- package/dist/web/bridges/hooks/use-apps-sdk-bridge.js.map +0 -1
- package/dist/web/bridges/hooks/use-bridge.d.ts +0 -2
- package/dist/web/bridges/hooks/use-bridge.js +0 -8
- package/dist/web/bridges/hooks/use-bridge.js.map +0 -1
- package/dist/web/bridges/hooks/use-mcp-app-bridge.d.ts +0 -5
- package/dist/web/bridges/hooks/use-mcp-app-bridge.js.map +0 -1
- package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js.map +0 -1
- package/dist/web/bridges/mcp-app-bridge.js.map +0 -1
- package/dist/web/hooks/use-openai-global.d.ts +0 -3
- package/dist/web/hooks/use-openai-global.js +0 -6
- package/dist/web/hooks/use-openai-global.js.map +0 -1
- /package/dist/web/bridges/{hooks/use-mcp-app-bridge.test.d.ts → mcp-app/use-mcp-app-context.test.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SET_GLOBALS_EVENT_TYPE, } from "
|
|
1
|
+
import { SET_GLOBALS_EVENT_TYPE, } from "./types.js";
|
|
2
2
|
export class AppsSdkBridge {
|
|
3
3
|
static instance = null;
|
|
4
4
|
static getInstance() {
|
|
@@ -43,4 +43,4 @@ export class AppsSdkBridge {
|
|
|
43
43
|
return window.openai[key];
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/bridge.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,sBAAsB,GAEvB,MAAM,YAAY,CAAC;AAEpB,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,QAAQ,GAAyB,IAAI,CAAC;IAE9C,MAAM,CAAC,WAAW;QACvB,IACE,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU;YACxC,MAAM,CAAC,MAAM,KAAK,SAAS,EAC3B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;QACJ,CAAC;QACD,IAAI,aAAa,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YACpC,aAAa,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QAC/C,CAAC;QACD,OAAO,aAAa,CAAC,QAAQ,CAAC;IAChC,CAAC;IAEM,MAAM,CAAC,aAAa;QACzB,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC;QAChC,CAAC;IACH,CAAC;IAIM,SAAS,CACd,SAAmE;QAEnE,MAAM,IAAI,GAAsC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACtE,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAChB,OAAO,CAAC,QAAoB,EAAE,EAAE;YAC9B,MAAM,eAAe,GAAG,CAAC,KAAsB,EAAE,EAAE;gBACjD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CACjC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CACjD,CAAC;gBACF,IAAI,CAAC,iBAAiB,EAAE,CAAC;oBACvB,OAAO;gBACT,CAAC;gBACD,QAAQ,EAAE,CAAC;YACb,CAAC,CAAC;YAEF,MAAM,CAAC,gBAAgB,CAAC,sBAAsB,EAAE,eAAe,EAAE;gBAC/D,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YAEH,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;YACtE,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAEM,WAAW,GAAG,CAAiC,GAAM,EAAE,EAAE;QAC9D,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,+EAA+E,GAAG,8CAA8C,CACjI,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AppsSdkAdaptor } from "./adaptor.js";
|
|
2
|
+
export { AppsSdkBridge } from "./bridge.js";
|
|
3
|
+
export type { AppsSdkContext, AppsSdkMethods, RequestModalOptions, ToolResponseEvent, } from "./types.js";
|
|
4
|
+
export { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, TOOL_RESPONSE_EVENT_TYPE, } from "./types.js";
|
|
5
|
+
export { useAppsSdkContext } from "./use-apps-sdk-context.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AppsSdkAdaptor } from "./adaptor.js";
|
|
2
|
+
export { AppsSdkBridge } from "./bridge.js";
|
|
3
|
+
export { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, TOOL_RESPONSE_EVENT_TYPE, } from "./types.js";
|
|
4
|
+
export { useAppsSdkContext } from "./use-apps-sdk-context.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO5C,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { UnknownObject } from "../../types.js";
|
|
2
|
+
import type { CallToolArgs, CallToolResponse } from "../types.js";
|
|
3
|
+
type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
|
|
4
|
+
type WidgetState = UnknownObject;
|
|
5
|
+
type FileMetadata = {
|
|
6
|
+
fileId: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
|
|
9
|
+
export declare class ToolResponseEvent extends CustomEvent<{
|
|
10
|
+
tool: {
|
|
11
|
+
name: string;
|
|
12
|
+
args: UnknownObject;
|
|
13
|
+
};
|
|
14
|
+
}> {
|
|
15
|
+
readonly type = "openai:tool_response";
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
openai: AppsSdkMethods<WidgetState> & AppsSdkContext;
|
|
20
|
+
}
|
|
21
|
+
interface WindowEventMap {
|
|
22
|
+
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export type AppsSdkContext<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
|
|
26
|
+
theme: Theme;
|
|
27
|
+
userAgent: UserAgent;
|
|
28
|
+
locale: string;
|
|
29
|
+
maxHeight: number | undefined;
|
|
30
|
+
displayMode: DisplayMode;
|
|
31
|
+
safeArea: SafeArea;
|
|
32
|
+
view: View;
|
|
33
|
+
toolInput: ToolInput;
|
|
34
|
+
toolOutput: ToolOutput | {
|
|
35
|
+
text: string;
|
|
36
|
+
} | null;
|
|
37
|
+
toolResponseMetadata: ToolResponseMetadata | null;
|
|
38
|
+
widgetState: WidgetState | null;
|
|
39
|
+
};
|
|
40
|
+
export type RequestModalOptions = {
|
|
41
|
+
title?: string;
|
|
42
|
+
params?: Record<string, unknown>;
|
|
43
|
+
anchor?: {
|
|
44
|
+
top?: number;
|
|
45
|
+
left?: number;
|
|
46
|
+
width?: number;
|
|
47
|
+
height?: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export type AppsSdkMethods<WidgetState extends UnknownObject = UnknownObject> = {
|
|
51
|
+
/** Calls a tool on your MCP. Returns the full response. */
|
|
52
|
+
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
53
|
+
/** Triggers a followup turn in the ChatGPT conversation */
|
|
54
|
+
sendFollowUpMessage: (args: {
|
|
55
|
+
prompt: string;
|
|
56
|
+
}) => Promise<void>;
|
|
57
|
+
/** Opens an external link, redirects web page or mobile app */
|
|
58
|
+
openExternal(args: {
|
|
59
|
+
href: string;
|
|
60
|
+
}): void;
|
|
61
|
+
/** For transitioning an app from inline to fullscreen or pip */
|
|
62
|
+
requestDisplayMode: (args: {
|
|
63
|
+
mode: DisplayMode;
|
|
64
|
+
}) => Promise<{
|
|
65
|
+
/**
|
|
66
|
+
* The granted display mode. The host may reject the request.
|
|
67
|
+
* For mobile, PiP is always coerced to fullscreen.
|
|
68
|
+
*/
|
|
69
|
+
mode: DisplayMode;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Sets the widget state.
|
|
73
|
+
* This state is persisted across widget renders.
|
|
74
|
+
*/
|
|
75
|
+
setWidgetState: (state: WidgetState) => Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Opens a modal portaled outside of the widget iFrame.
|
|
78
|
+
* This ensures the modal is correctly displayed and not limited to the widget's area.
|
|
79
|
+
*/
|
|
80
|
+
requestModal: (args: RequestModalOptions) => Promise<void>;
|
|
81
|
+
/** Uploads a new file to the host */
|
|
82
|
+
uploadFile: (file: File) => Promise<FileMetadata>;
|
|
83
|
+
/**
|
|
84
|
+
* Downloads a file from the host that was previously uploaded.
|
|
85
|
+
* Only files uploaded by the same connector instance can be downloaded.
|
|
86
|
+
*/
|
|
87
|
+
getFileDownloadUrl: (file: FileMetadata) => Promise<{
|
|
88
|
+
downloadUrl: string;
|
|
89
|
+
}>;
|
|
90
|
+
};
|
|
91
|
+
export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
92
|
+
export declare class SetGlobalsEvent extends CustomEvent<{
|
|
93
|
+
globals: Partial<AppsSdkContext>;
|
|
94
|
+
}> {
|
|
95
|
+
readonly type = "openai:set_globals";
|
|
96
|
+
}
|
|
97
|
+
type View = {
|
|
98
|
+
mode: DisplayMode;
|
|
99
|
+
params?: Record<string, unknown>;
|
|
100
|
+
};
|
|
101
|
+
type Theme = "light" | "dark";
|
|
102
|
+
type SafeAreaInsets = {
|
|
103
|
+
top: number;
|
|
104
|
+
bottom: number;
|
|
105
|
+
left: number;
|
|
106
|
+
right: number;
|
|
107
|
+
};
|
|
108
|
+
type SafeArea = {
|
|
109
|
+
insets: SafeAreaInsets;
|
|
110
|
+
};
|
|
111
|
+
type DeviceType = "mobile" | "tablet" | "desktop" | "unknown";
|
|
112
|
+
type UserAgent = {
|
|
113
|
+
device: {
|
|
114
|
+
type: DeviceType;
|
|
115
|
+
};
|
|
116
|
+
capabilities: {
|
|
117
|
+
hover: boolean;
|
|
118
|
+
touch: boolean;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
|
|
2
|
+
export class ToolResponseEvent extends CustomEvent {
|
|
3
|
+
type = TOOL_RESPONSE_EVENT_TYPE;
|
|
4
|
+
}
|
|
5
|
+
// Dispatched when any global changes in the host page
|
|
6
|
+
export const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
7
|
+
export class SetGlobalsEvent extends CustomEvent {
|
|
8
|
+
type = SET_GLOBALS_EVENT_TYPE;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/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;AA2FD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
|
-
import { AppsSdkBridge } from "
|
|
3
|
-
export function
|
|
2
|
+
import { AppsSdkBridge } from "./bridge.js";
|
|
3
|
+
export function useAppsSdkContext(key) {
|
|
4
4
|
const bridge = AppsSdkBridge.getInstance();
|
|
5
5
|
return useSyncExternalStore(bridge.subscribe(key), () => bridge.getSnapshot(key));
|
|
6
6
|
}
|
|
7
|
-
//# sourceMappingURL=use-apps-sdk-
|
|
7
|
+
//# sourceMappingURL=use-apps-sdk-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-apps-sdk-context.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/use-apps-sdk-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,UAAU,iBAAiB,CAC/B,GAAM;IAEN,MAAM,MAAM,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAC3C,OAAO,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CACtD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AppsSdkAdaptor } from "./apps-sdk/adaptor.js";
|
|
2
|
+
import { McpAppAdaptor } from "./mcp-app/adaptor.js";
|
|
3
|
+
export const getAdaptor = () => {
|
|
4
|
+
return window.skybridge.hostType === "apps-sdk"
|
|
5
|
+
? AppsSdkAdaptor.getInstance()
|
|
6
|
+
: McpAppAdaptor.getInstance();
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=get-adaptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-adaptor.js","sourceRoot":"","sources":["../../../src/web/bridges/get-adaptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAY,EAAE;IACtC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU;QAC7C,CAAC,CAAC,cAAc,CAAC,WAAW,EAAE;QAC9B,CAAC,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export * from "./apps-sdk/index.js";
|
|
2
|
+
export { getAdaptor } from "./get-adaptor.js";
|
|
3
|
+
export * from "./mcp-app/index.js";
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export { useHostContext } from "./use-host-context.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export * from "./apps-sdk/index.js";
|
|
2
|
+
export { getAdaptor } from "./get-adaptor.js";
|
|
3
|
+
export * from "./mcp-app/index.js";
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export { useHostContext } from "./use-host-context.js";
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/bridges/index.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/bridges/index.tsx"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { McpUiRequestDisplayModeResult } from "@modelcontextprotocol/ext-apps";
|
|
2
|
-
import type { Adaptor,
|
|
2
|
+
import type { Adaptor, CallToolResponse, DisplayMode, HostContext, HostContextStore, SetWidgetStateAction } from "../types.js";
|
|
3
3
|
export declare class McpAppAdaptor implements Adaptor {
|
|
4
4
|
private static instance;
|
|
5
5
|
private stores;
|
|
6
|
+
private _widgetState;
|
|
7
|
+
private widgetStateListeners;
|
|
6
8
|
private constructor();
|
|
7
9
|
static getInstance(): McpAppAdaptor;
|
|
8
10
|
static resetInstance(): void;
|
|
9
|
-
|
|
11
|
+
getHostContextStore<K extends keyof HostContext>(key: K): HostContextStore<K>;
|
|
10
12
|
callTool: <ToolArgs extends Record<string, unknown> | null = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
11
13
|
requestDisplayMode: (mode: DisplayMode) => Promise<McpUiRequestDisplayModeResult>;
|
|
12
14
|
sendFollowUpMessage: (prompt: string) => Promise<void>;
|
|
13
15
|
openExternal(href: string): void;
|
|
14
16
|
private initializeStores;
|
|
15
|
-
|
|
17
|
+
setWidgetState: (stateOrUpdater: SetWidgetStateAction) => Promise<void>;
|
|
18
|
+
private createHostContextStore;
|
|
16
19
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { dequal } from "dequal/lite";
|
|
2
|
-
import { McpAppBridge
|
|
2
|
+
import { McpAppBridge } from "./bridge.js";
|
|
3
3
|
export class McpAppAdaptor {
|
|
4
4
|
static instance = null;
|
|
5
5
|
stores;
|
|
6
|
+
_widgetState = null;
|
|
7
|
+
widgetStateListeners = new Set();
|
|
6
8
|
constructor() {
|
|
7
9
|
this.stores = this.initializeStores();
|
|
8
10
|
}
|
|
@@ -15,7 +17,7 @@ export class McpAppAdaptor {
|
|
|
15
17
|
static resetInstance() {
|
|
16
18
|
McpAppAdaptor.instance = null;
|
|
17
19
|
}
|
|
18
|
-
|
|
20
|
+
getHostContextStore(key) {
|
|
19
21
|
return this.stores[key];
|
|
20
22
|
}
|
|
21
23
|
callTool = async (name, args) => {
|
|
@@ -36,7 +38,7 @@ export class McpAppAdaptor {
|
|
|
36
38
|
structuredContent: response.structuredContent ?? {},
|
|
37
39
|
isError: response.isError ?? false,
|
|
38
40
|
result,
|
|
39
|
-
|
|
41
|
+
meta: response._meta ?? {},
|
|
40
42
|
};
|
|
41
43
|
};
|
|
42
44
|
requestDisplayMode = (mode) => {
|
|
@@ -73,14 +75,19 @@ export class McpAppAdaptor {
|
|
|
73
75
|
}
|
|
74
76
|
initializeStores() {
|
|
75
77
|
return {
|
|
76
|
-
theme: this.
|
|
77
|
-
locale: this.
|
|
78
|
-
safeArea: this.
|
|
78
|
+
theme: this.createHostContextStore(["theme"], ({ theme }) => theme ?? "light"),
|
|
79
|
+
locale: this.createHostContextStore(["locale"], ({ locale }) => locale ?? "en-US"),
|
|
80
|
+
safeArea: this.createHostContextStore(["safeAreaInsets"], ({ safeAreaInsets }) => ({
|
|
79
81
|
insets: safeAreaInsets ?? { top: 0, right: 0, bottom: 0, left: 0 },
|
|
80
82
|
})),
|
|
81
|
-
displayMode: this.
|
|
82
|
-
maxHeight: this.
|
|
83
|
-
|
|
83
|
+
displayMode: this.createHostContextStore(["displayMode"], ({ displayMode }) => displayMode ?? "inline"),
|
|
84
|
+
maxHeight: this.createHostContextStore(["containerDimensions"], ({ containerDimensions }) => {
|
|
85
|
+
if (containerDimensions && "maxHeight" in containerDimensions) {
|
|
86
|
+
return containerDimensions.maxHeight;
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}),
|
|
90
|
+
userAgent: this.createHostContextStore(["platform", "deviceCapabilities"], ({ platform, deviceCapabilities }) => ({
|
|
84
91
|
device: {
|
|
85
92
|
type: platform === "web" ? "desktop" : (platform ?? "unknown"),
|
|
86
93
|
},
|
|
@@ -90,12 +97,35 @@ export class McpAppAdaptor {
|
|
|
90
97
|
...deviceCapabilities,
|
|
91
98
|
},
|
|
92
99
|
})),
|
|
93
|
-
toolInput: this.
|
|
94
|
-
toolOutput: this.
|
|
95
|
-
toolResponseMetadata: this.
|
|
100
|
+
toolInput: this.createHostContextStore(["toolInput"], ({ toolInput }) => toolInput ?? null),
|
|
101
|
+
toolOutput: this.createHostContextStore(["toolResult"], ({ toolResult }) => toolResult?.structuredContent ?? null),
|
|
102
|
+
toolResponseMetadata: this.createHostContextStore(["toolResult"], ({ toolResult }) => toolResult?._meta ?? null),
|
|
103
|
+
widgetState: {
|
|
104
|
+
subscribe: (onChange) => {
|
|
105
|
+
this.widgetStateListeners.add(onChange);
|
|
106
|
+
return () => {
|
|
107
|
+
this.widgetStateListeners.delete(onChange);
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
getSnapshot: () => this._widgetState,
|
|
111
|
+
},
|
|
96
112
|
};
|
|
97
113
|
}
|
|
98
|
-
|
|
114
|
+
setWidgetState = async (stateOrUpdater) => {
|
|
115
|
+
const newState = typeof stateOrUpdater === "function"
|
|
116
|
+
? stateOrUpdater(this._widgetState)
|
|
117
|
+
: stateOrUpdater;
|
|
118
|
+
const bridge = McpAppBridge.getInstance();
|
|
119
|
+
await bridge.request({
|
|
120
|
+
method: "ui/update-model-context",
|
|
121
|
+
params: { structuredContent: newState },
|
|
122
|
+
});
|
|
123
|
+
this._widgetState = newState;
|
|
124
|
+
this.widgetStateListeners.forEach((listener) => {
|
|
125
|
+
listener();
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
createHostContextStore(keys, computeSnapshot) {
|
|
99
129
|
const bridge = McpAppBridge.getInstance();
|
|
100
130
|
let cachedValue;
|
|
101
131
|
return {
|
|
@@ -112,4 +142,4 @@ export class McpAppAdaptor {
|
|
|
112
142
|
};
|
|
113
143
|
}
|
|
114
144
|
}
|
|
115
|
-
//# sourceMappingURL=
|
|
145
|
+
//# sourceMappingURL=adaptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/adaptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,MAAM,OAA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AsB,CAG5B,IAAU,EAAE,eAAkD;QAC9D,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,WAA0B,CAAC;QAE/B,OAAO;YACL,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;YACjC,WAAW,EAAE,GAAG,EAAE;gBAChB,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAChC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CACvB,CAAC;gBACvB,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;gBAE1C,IAAI,WAAW,KAAK,SAAS,IAAI,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC;oBAC/D,OAAO,WAAW,CAAC;gBACrB,CAAC;gBAED,WAAW,GAAG,QAAQ,CAAC;gBACvB,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import type { McpUiHostContext, McpUiInitializeRequest
|
|
2
|
-
import type { Bridge, Subscribe } from "
|
|
1
|
+
import type { McpUiHostContext, McpUiInitializeRequest } from "@modelcontextprotocol/ext-apps";
|
|
2
|
+
import type { Bridge, Subscribe } from "../types.js";
|
|
3
|
+
import type { McpAppContext, McpAppContextKey } from "./types.js";
|
|
3
4
|
type McpAppInitializationOptions = Pick<McpUiInitializeRequest["params"], "appInfo">;
|
|
4
|
-
export type McpToolState = {
|
|
5
|
-
toolInput: NonNullable<McpUiToolInputNotification["params"]["arguments"]> | null;
|
|
6
|
-
toolResult: McpUiToolResultNotification["params"] | null;
|
|
7
|
-
toolCancelled: McpUiToolCancelledNotification["params"] | null;
|
|
8
|
-
};
|
|
9
|
-
export type McpAppBridgeContext = McpUiHostContext & McpToolState;
|
|
10
|
-
export type McpAppBridgeKey = keyof McpAppBridgeContext;
|
|
11
5
|
export declare class McpAppBridge implements Bridge<McpUiHostContext> {
|
|
12
6
|
private static instance;
|
|
13
|
-
context:
|
|
7
|
+
context: McpAppContext;
|
|
14
8
|
private listeners;
|
|
15
9
|
private pendingRequests;
|
|
16
10
|
private nextId;
|
|
@@ -20,9 +14,9 @@ export declare class McpAppBridge implements Bridge<McpUiHostContext> {
|
|
|
20
14
|
private cleanupSizeObserver;
|
|
21
15
|
constructor(options: McpAppInitializationOptions, requestTimeout?: number);
|
|
22
16
|
static getInstance(options?: Partial<McpAppInitializationOptions>, requestTimeout?: number): McpAppBridge;
|
|
23
|
-
subscribe(key:
|
|
24
|
-
subscribe(keys: readonly
|
|
25
|
-
getSnapshot<K extends keyof
|
|
17
|
+
subscribe(key: McpAppContextKey): Subscribe;
|
|
18
|
+
subscribe(keys: readonly McpAppContextKey[]): Subscribe;
|
|
19
|
+
getSnapshot<K extends keyof McpAppContext>(key: K): McpAppContext[K];
|
|
26
20
|
cleanup: () => void;
|
|
27
21
|
static resetInstance(): void;
|
|
28
22
|
request<R extends {
|
|
@@ -33,6 +27,9 @@ export declare class McpAppBridge implements Bridge<McpUiHostContext> {
|
|
|
33
27
|
private updateContext;
|
|
34
28
|
private init;
|
|
35
29
|
private handleMessage;
|
|
30
|
+
private handleResponse;
|
|
31
|
+
private handleNotification;
|
|
32
|
+
private handleRequest;
|
|
36
33
|
private connect;
|
|
37
34
|
private notify;
|
|
38
35
|
private sendSizeChanged;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
const LATEST_PROTOCOL_VERSION = "2025-11-21";
|
|
2
|
+
var JsonRpcErrorCode;
|
|
3
|
+
(function (JsonRpcErrorCode) {
|
|
4
|
+
JsonRpcErrorCode[JsonRpcErrorCode["ParseError"] = -32700] = "ParseError";
|
|
5
|
+
JsonRpcErrorCode[JsonRpcErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
|
|
6
|
+
JsonRpcErrorCode[JsonRpcErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
7
|
+
JsonRpcErrorCode[JsonRpcErrorCode["InvalidParams"] = -32602] = "InvalidParams";
|
|
8
|
+
JsonRpcErrorCode[JsonRpcErrorCode["InternalError"] = -32603] = "InternalError";
|
|
9
|
+
})(JsonRpcErrorCode || (JsonRpcErrorCode = {}));
|
|
2
10
|
export class McpAppBridge {
|
|
3
11
|
static instance = null;
|
|
4
12
|
context = {
|
|
@@ -21,6 +29,7 @@ export class McpAppBridge {
|
|
|
21
29
|
appCapabilities: {},
|
|
22
30
|
protocolVersion: LATEST_PROTOCOL_VERSION,
|
|
23
31
|
};
|
|
32
|
+
this.init();
|
|
24
33
|
}
|
|
25
34
|
static getInstance(options, requestTimeout) {
|
|
26
35
|
if (window.skybridge.hostType !== "mcp-app") {
|
|
@@ -43,7 +52,6 @@ export class McpAppBridge {
|
|
|
43
52
|
for (const key of keys) {
|
|
44
53
|
this.listeners.set(key, new Set([...(this.listeners.get(key) || []), onChange]));
|
|
45
54
|
}
|
|
46
|
-
this.init();
|
|
47
55
|
return () => {
|
|
48
56
|
for (const key of keys) {
|
|
49
57
|
this.listeners.get(key)?.delete(onChange);
|
|
@@ -112,39 +120,70 @@ export class McpAppBridge {
|
|
|
112
120
|
return;
|
|
113
121
|
}
|
|
114
122
|
if ("id" in data) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.pendingRequests.delete(data.id);
|
|
119
|
-
if ("error" in data) {
|
|
120
|
-
request.reject(new Error(data.error.message));
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
request.resolve(data.result);
|
|
123
|
+
if ("method" in data) {
|
|
124
|
+
this.handleRequest(data);
|
|
125
|
+
return;
|
|
124
126
|
}
|
|
127
|
+
this.handleResponse(data);
|
|
125
128
|
return;
|
|
126
129
|
}
|
|
127
|
-
|
|
130
|
+
this.handleNotification(data);
|
|
131
|
+
};
|
|
132
|
+
handleResponse(response) {
|
|
133
|
+
const request = this.pendingRequests.get(response.id);
|
|
134
|
+
if (request) {
|
|
135
|
+
clearTimeout(request.timeout);
|
|
136
|
+
this.pendingRequests.delete(response.id);
|
|
137
|
+
if ("error" in response) {
|
|
138
|
+
request.reject(new Error(response.error.message));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
request.resolve(response.result);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
handleNotification = (notification) => {
|
|
145
|
+
switch (notification.method) {
|
|
128
146
|
case "ui/notifications/host-context-changed":
|
|
129
|
-
this.updateContext(
|
|
147
|
+
this.updateContext(notification.params);
|
|
130
148
|
return;
|
|
131
149
|
case "ui/notifications/tool-input":
|
|
132
150
|
this.updateContext({
|
|
133
|
-
toolInput:
|
|
151
|
+
toolInput: notification.params.arguments ?? {},
|
|
134
152
|
});
|
|
135
153
|
return;
|
|
136
154
|
case "ui/notifications/tool-result":
|
|
137
155
|
this.updateContext({
|
|
138
|
-
toolResult:
|
|
156
|
+
toolResult: notification.params,
|
|
139
157
|
});
|
|
140
158
|
return;
|
|
141
159
|
case "ui/notifications/tool-cancelled":
|
|
142
160
|
this.updateContext({
|
|
143
|
-
toolCancelled:
|
|
161
|
+
toolCancelled: notification.params,
|
|
144
162
|
});
|
|
145
163
|
return;
|
|
146
164
|
}
|
|
147
165
|
};
|
|
166
|
+
handleRequest = (request) => {
|
|
167
|
+
switch (request.method) {
|
|
168
|
+
case "ui/resource-teardown":
|
|
169
|
+
this.cleanup();
|
|
170
|
+
window.parent.postMessage({
|
|
171
|
+
jsonrpc: "2.0",
|
|
172
|
+
id: request.id,
|
|
173
|
+
result: {},
|
|
174
|
+
}, "*");
|
|
175
|
+
return;
|
|
176
|
+
default:
|
|
177
|
+
window.parent.postMessage({
|
|
178
|
+
jsonrpc: "2.0",
|
|
179
|
+
id: request.id,
|
|
180
|
+
error: {
|
|
181
|
+
code: JsonRpcErrorCode.MethodNotFound,
|
|
182
|
+
message: "Unsupported Request",
|
|
183
|
+
},
|
|
184
|
+
}, "*");
|
|
185
|
+
}
|
|
186
|
+
};
|
|
148
187
|
async connect() {
|
|
149
188
|
try {
|
|
150
189
|
const result = await this.request({
|
|
@@ -181,23 +220,22 @@ export class McpAppBridge {
|
|
|
181
220
|
scheduled = true;
|
|
182
221
|
requestAnimationFrame(() => {
|
|
183
222
|
scheduled = false;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const height = Math.ceil(rect.height);
|
|
223
|
+
let width;
|
|
224
|
+
let height;
|
|
225
|
+
// In fullscreen mode, use viewport size since the widget should fill
|
|
226
|
+
// the entire available space provided by the host.
|
|
227
|
+
if (this.context.displayMode === "fullscreen") {
|
|
228
|
+
width = window.innerWidth;
|
|
229
|
+
height = window.innerHeight;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
// Use scrollWidth/scrollHeight to measure actual rendered content size.
|
|
233
|
+
// This works better than fit-content for viewport-based layouts (vw/vh)
|
|
234
|
+
// and fluid elements like maps that want to fill available space.
|
|
235
|
+
const body = document.body;
|
|
236
|
+
width = Math.ceil(body.scrollWidth);
|
|
237
|
+
height = Math.ceil(body.scrollHeight);
|
|
238
|
+
}
|
|
201
239
|
// Only send if size actually changed (prevents feedback loops from
|
|
202
240
|
// style changes)
|
|
203
241
|
if (width !== lastWidth || height !== lastHeight) {
|
|
@@ -214,4 +252,4 @@ export class McpAppBridge {
|
|
|
214
252
|
return () => resizeObserver.disconnect();
|
|
215
253
|
}
|
|
216
254
|
}
|
|
217
|
-
//# sourceMappingURL=
|
|
255
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-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cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACjD,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEtC,OAAO,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;IAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { McpUiHostContext, McpUiToolCancelledNotification, McpUiToolInputNotification, McpUiToolResultNotification } from "@modelcontextprotocol/ext-apps";
|
|
2
|
+
export type McpToolState = {
|
|
3
|
+
toolInput: NonNullable<McpUiToolInputNotification["params"]["arguments"]> | null;
|
|
4
|
+
toolResult: McpUiToolResultNotification["params"] | null;
|
|
5
|
+
toolCancelled: McpUiToolCancelledNotification["params"] | null;
|
|
6
|
+
};
|
|
7
|
+
export type McpAppContext = McpUiHostContext & McpToolState;
|
|
8
|
+
export type McpAppContextKey = keyof McpAppContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/types.ts"],"names":[],"mappings":""}
|