skybridge 0.0.0-dev.de4a871 → 0.0.0-dev.deff1f1
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 +4 -0
- package/dist/src/server/devtoolsStaticServer.js +22 -12
- package/dist/src/server/devtoolsStaticServer.js.map +1 -1
- package/dist/src/server/server.d.ts +9 -1
- package/dist/src/server/server.js +42 -15
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/server/templates/development.hbs +55 -2
- package/dist/src/server/templates/production.hbs +1 -1
- package/dist/src/server/widgetsDevServer.js +11 -3
- package/dist/src/server/widgetsDevServer.js.map +1 -1
- package/dist/src/test/widget.test.js +65 -12
- 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.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.d.ts +1 -1
- 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-d.js +1 -1
- package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.test.js +28 -3
- 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-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-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 +20 -9
- package/dist/src/web/types.js.map +1 -1
- package/package.json +28 -26
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
|
@@ -2,6 +2,10 @@ import { type RequestHandler } from "express";
|
|
|
2
2
|
/**
|
|
3
3
|
* Serve the built devtools React app
|
|
4
4
|
* This router serves static files from the devtools's dist directory.
|
|
5
|
+
*
|
|
6
|
+
* **Note:** This requires `@skybridge/devtools` to be installed as a peer dependency.
|
|
7
|
+
* Install it with: `pnpm add -D @skybridge/devtools` (or `npm install -D @skybridge/devtools`)
|
|
8
|
+
*
|
|
5
9
|
* It should be installed at the application root, like so:
|
|
6
10
|
*
|
|
7
11
|
* const app = express();
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
3
|
import cors from "cors";
|
|
5
4
|
import express, {} from "express";
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
6
|
/**
|
|
7
7
|
* Serve the built devtools React app
|
|
8
8
|
* This router serves static files from the devtools's dist directory.
|
|
9
|
+
*
|
|
10
|
+
* **Note:** This requires `@skybridge/devtools` to be installed as a peer dependency.
|
|
11
|
+
* Install it with: `pnpm add -D @skybridge/devtools` (or `npm install -D @skybridge/devtools`)
|
|
12
|
+
*
|
|
9
13
|
* It should be installed at the application root, like so:
|
|
10
14
|
*
|
|
11
15
|
* const app = express();
|
|
@@ -18,20 +22,26 @@ import express, {} from "express";
|
|
|
18
22
|
*/
|
|
19
23
|
export const devtoolsStaticServer = async () => {
|
|
20
24
|
const router = express.Router();
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
let devtoolsPath;
|
|
26
|
+
try {
|
|
27
|
+
const devtoolsPackagePath = require.resolve("@skybridge/devtools/package.json");
|
|
28
|
+
devtoolsPath = path.join(path.dirname(devtoolsPackagePath), "dist");
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new Error("@skybridge/devtools is not installed. Please install it as a dev dependency:\n" +
|
|
32
|
+
" pnpm add -D @skybridge/devtools\n" +
|
|
33
|
+
" or\n" +
|
|
34
|
+
" npm install -D @skybridge/devtools", { cause: error });
|
|
35
|
+
}
|
|
23
36
|
router.use(cors());
|
|
24
37
|
router.use(express.static(devtoolsPath));
|
|
25
38
|
router.get("/", (_req, res, next) => {
|
|
26
39
|
const indexHtmlPath = path.join(devtoolsPath, "index.html");
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
next(error);
|
|
34
|
-
}
|
|
40
|
+
res.sendFile(indexHtmlPath, (error) => {
|
|
41
|
+
if (error) {
|
|
42
|
+
next(error);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
35
45
|
});
|
|
36
46
|
return router;
|
|
37
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtoolsStaticServer.js","sourceRoot":"","sources":["../../../src/server/devtoolsStaticServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"devtoolsStaticServer.js","sourceRoot":"","sources":["../../../src/server/devtoolsStaticServer.ts"],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AC,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { McpUiResourceMeta } from "@modelcontextprotocol/ext-apps";
|
|
1
2
|
import { McpServer as McpServerBase, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
3
|
import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
3
4
|
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
@@ -7,8 +8,15 @@ export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unk
|
|
|
7
8
|
output: TOutput;
|
|
8
9
|
responseMetadata: TResponseMetadata;
|
|
9
10
|
};
|
|
11
|
+
/** User-provided resource configuration with optional CSP override */
|
|
12
|
+
export type WidgetResourceMeta = {
|
|
13
|
+
/** MCP Apps UI resource metadata (csp, domain, prefersBorder) */
|
|
14
|
+
ui?: McpUiResourceMeta;
|
|
15
|
+
} & Resource["_meta"];
|
|
10
16
|
export type WidgetHostType = "apps-sdk" | "mcp-app";
|
|
11
|
-
type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType"
|
|
17
|
+
type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType" | "_meta"> & {
|
|
18
|
+
_meta?: WidgetResourceMeta;
|
|
19
|
+
};
|
|
12
20
|
type McpServerOriginalToolConfig = Omit<Parameters<typeof McpServerBase.prototype.registerTool<ZodRawShapeCompat, ZodRawShapeCompat>>[1], "inputSchema" | "outputSchema">;
|
|
13
21
|
type Simplify<T> = {
|
|
14
22
|
[K in keyof T]: T[K];
|
|
@@ -4,36 +4,56 @@ import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mc
|
|
|
4
4
|
import { templateHelper } from "./templateHelper.js";
|
|
5
5
|
export class McpServer extends McpServerBase {
|
|
6
6
|
registerWidget(name, resourceConfig, toolConfig, toolCallback) {
|
|
7
|
-
const
|
|
8
|
-
...(resourceConfig._meta ?? {}),
|
|
9
|
-
};
|
|
10
|
-
if (toolConfig.description !== undefined) {
|
|
11
|
-
resourceMetadata["openai/widgetDescription"] = toolConfig.description;
|
|
12
|
-
}
|
|
7
|
+
const userMeta = resourceConfig._meta;
|
|
13
8
|
const appsSdkResourceConfig = {
|
|
14
9
|
hostType: "apps-sdk",
|
|
15
10
|
uri: `ui://widgets/apps-sdk/${name}.html`,
|
|
16
11
|
mimeType: "text/html+skybridge",
|
|
12
|
+
buildMeta: (serverUrl, wsServerUrl) => ({
|
|
13
|
+
"openai/widgetCSP": {
|
|
14
|
+
resource_domains: userMeta?.ui?.csp?.resourceDomains ?? [serverUrl],
|
|
15
|
+
connect_domains: userMeta?.ui?.csp?.connectDomains ?? [
|
|
16
|
+
serverUrl,
|
|
17
|
+
wsServerUrl,
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
"openai/widgetDomain": userMeta?.ui?.domain ?? serverUrl,
|
|
21
|
+
"openai/widgetDescription": toolConfig.description,
|
|
22
|
+
...(userMeta?.ui?.prefersBorder !== undefined && {
|
|
23
|
+
"openai/widgetPrefersBorder": userMeta.ui.prefersBorder,
|
|
24
|
+
}),
|
|
25
|
+
...userMeta,
|
|
26
|
+
}),
|
|
17
27
|
};
|
|
18
28
|
const extAppsResourceConfig = {
|
|
19
29
|
hostType: "mcp-app",
|
|
20
30
|
uri: `ui://widgets/ext-apps/${name}.html`,
|
|
21
31
|
mimeType: "text/html;profile=mcp-app",
|
|
32
|
+
buildMeta: (serverUrl, wsServerUrl) => ({
|
|
33
|
+
...userMeta,
|
|
34
|
+
ui: {
|
|
35
|
+
csp: {
|
|
36
|
+
resourceDomains: [serverUrl],
|
|
37
|
+
connectDomains: [serverUrl, wsServerUrl],
|
|
38
|
+
},
|
|
39
|
+
domain: serverUrl,
|
|
40
|
+
...userMeta?.ui,
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
22
43
|
};
|
|
23
|
-
[appsSdkResourceConfig, extAppsResourceConfig].forEach((
|
|
44
|
+
[appsSdkResourceConfig, extAppsResourceConfig].forEach((widgetConfig) => {
|
|
24
45
|
this.registerWidgetResource({
|
|
25
46
|
name,
|
|
26
|
-
|
|
27
|
-
widgetUri: uri,
|
|
28
|
-
mimeType,
|
|
47
|
+
widgetConfig,
|
|
29
48
|
resourceConfig,
|
|
30
|
-
resourceMetadata,
|
|
31
49
|
});
|
|
32
50
|
});
|
|
33
51
|
const toolMeta = {
|
|
34
52
|
...toolConfig._meta,
|
|
35
53
|
"openai/outputTemplate": appsSdkResourceConfig.uri,
|
|
36
|
-
|
|
54
|
+
ui: {
|
|
55
|
+
resourceUri: extAppsResourceConfig.uri,
|
|
56
|
+
},
|
|
37
57
|
};
|
|
38
58
|
this.registerTool(name, {
|
|
39
59
|
...toolConfig,
|
|
@@ -45,11 +65,13 @@ export class McpServer extends McpServerBase {
|
|
|
45
65
|
super.registerTool(name, config, cb);
|
|
46
66
|
return this;
|
|
47
67
|
}
|
|
48
|
-
registerWidgetResource({ name,
|
|
49
|
-
|
|
68
|
+
registerWidgetResource({ name, widgetConfig, resourceConfig, }) {
|
|
69
|
+
const { hostType, uri: widgetUri, mimeType, buildMeta } = widgetConfig;
|
|
70
|
+
this.registerResource(name, widgetUri, { ...resourceConfig, _meta: resourceConfig._meta }, async (uri, extra) => {
|
|
50
71
|
const serverUrl = process.env.NODE_ENV === "production"
|
|
51
72
|
? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ?? extra?.requestInfo?.headers?.host}`
|
|
52
73
|
: `http://localhost:3000`;
|
|
74
|
+
const wsServerUrl = serverUrl.replace(/^http/, "ws");
|
|
53
75
|
const html = process.env.NODE_ENV === "production"
|
|
54
76
|
? templateHelper.renderProduction({
|
|
55
77
|
hostType,
|
|
@@ -62,7 +84,12 @@ export class McpServer extends McpServerBase {
|
|
|
62
84
|
serverUrl,
|
|
63
85
|
widgetName: name,
|
|
64
86
|
});
|
|
65
|
-
|
|
87
|
+
const resourceMeta = buildMeta(serverUrl, wsServerUrl);
|
|
88
|
+
return {
|
|
89
|
+
contents: [
|
|
90
|
+
{ uri: uri.href, mimeType, text: html, _meta: resourceMeta },
|
|
91
|
+
],
|
|
92
|
+
};
|
|
66
93
|
});
|
|
67
94
|
}
|
|
68
95
|
lookupDistFile(key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,EACL,SAAS,IAAI,aAAa,GAG3B,MAAM,yCAAyC,CAAC;AAcjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA0IrD,MAAM,OAAO,SAEX,SAAQ,aAAa;IAGrB,cAAc,CAKZ,IAAW,EACX,cAA+C,EAC/C,UAGC,EACD,YAA0C;QAQ1C,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC;QAEtC,MAAM,qBAAqB,GAAyB;YAClD,QAAQ,EAAE,UAAU;YACpB,GAAG,EAAE,yBAAyB,IAAI,OAAO;YACzC,QAAQ,EAAE,qBAAqB;YAC/B,SAAS,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;gBACtC,kBAAkB,EAAE;oBAClB,gBAAgB,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,eAAe,IAAI,CAAC,SAAS,CAAC;oBACnE,eAAe,EAAE,QAAQ,EAAE,EAAE,EAAE,GA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C,CAAC;YAET,MAAM,YAAY,GAAG,SAAS,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;YAEvD,OAAO;gBACL,QAAQ,EAAE;oBACR,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE;iBAC7D;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,cAAc,CAAC,GAAW;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACrC,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAC7B,CAAC;IAEO,+BAA+B,CAAC,QAAgB;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAErC,MAAM,WAAW,GAAG,GAAG,QAAQ,MAAM,CAAC;QACtC,MAAM,YAAY,GAAG,GAAG,QAAQ,YAAY,CAAC;QAC7C,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC;IACrE,CAAC;IAEO,YAAY;QAClB,OAAO,IAAI,CAAC,KAAK,CACf,YAAY,CACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,CAAC,EACpE,OAAO,CACR,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,12 +1,65 @@
|
|
|
1
1
|
<base href="{{serverUrl}}" />
|
|
2
|
-
<script>
|
|
2
|
+
<script type="module">window.skybridge = { hostType: "{{hostType}}" };</script>
|
|
3
3
|
<script type="module">
|
|
4
|
-
import { injectIntoGlobalHook } from "{{serverUrl}}/@react-refresh";
|
|
4
|
+
import { injectIntoGlobalHook } from "{{serverUrl}}/assets/@react-refresh";
|
|
5
5
|
injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};
|
|
6
6
|
window.$RefreshSig$ = () => (type) => type;
|
|
7
7
|
window.__vite_plugin_react_preamble_installed__ = true;
|
|
8
8
|
</script>
|
|
9
9
|
<script type="module" src="{{serverUrl}}/@vite/client"></script>
|
|
10
|
+
<script type="module">
|
|
11
|
+
// Checks for browser support and shows error if local network access is denied
|
|
12
|
+
(async () => {
|
|
13
|
+
if (!navigator.permissions?.query) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Skip for non-http(s) protocols (file://, custom protocols in Electron, etc.)
|
|
18
|
+
const protocol = window.location.protocol;
|
|
19
|
+
const isNonHttpProtocol = protocol !== 'http:' && protocol !== 'https:'
|
|
20
|
+
if (isNonHttpProtocol) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const host = window.location.hostname;
|
|
25
|
+
const isLoopback = host === 'localhost'
|
|
26
|
+
|| /^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.test(host)
|
|
27
|
+
|| host === '::1';
|
|
28
|
+
if (isLoopback) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const status = await navigator.permissions.query({ name: "local-network-access" });
|
|
34
|
+
if (status.state === "denied") {
|
|
35
|
+
const errorDiv = document.createElement("div");
|
|
36
|
+
errorDiv.style.cssText = "background: #fef2f2; border: 2px solid #ef4444; border-radius: 8px; padding: 16px; text-align: center; z-index: 10000; font-family: system-ui, sans-serif;";
|
|
37
|
+
|
|
38
|
+
const errorTitle = document.createElement("div");
|
|
39
|
+
errorTitle.style.cssText = "color: #ef4444; font-size: 18px; font-weight: 600; margin-bottom: 8px;";
|
|
40
|
+
errorTitle.textContent = "Error: Local network access permission is denied.";
|
|
41
|
+
|
|
42
|
+
const errorMessage = document.createElement("div");
|
|
43
|
+
errorMessage.style.cssText = "color: #ef4444; font-size: 14px;";
|
|
44
|
+
errorMessage.textContent = "Local network access is required for your widget to connect to the local dev server. Please enable it in your browser settings. ";
|
|
45
|
+
|
|
46
|
+
const link = document.createElement("a");
|
|
47
|
+
link.href = "https://developer.chrome.com/blog/local-network-access";
|
|
48
|
+
link.target = "_blank";
|
|
49
|
+
link.rel = "noopener noreferrer";
|
|
50
|
+
link.style.cssText = "color: #ef4444; text-decoration: underline;";
|
|
51
|
+
link.textContent = "Learn more";
|
|
52
|
+
errorMessage.appendChild(link);
|
|
53
|
+
|
|
54
|
+
errorDiv.appendChild(errorTitle);
|
|
55
|
+
errorDiv.appendChild(errorMessage);
|
|
56
|
+
document.body.appendChild(errorDiv);
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
// Permission API doesn't support local-network-access, ignore silently
|
|
60
|
+
}
|
|
61
|
+
})();
|
|
62
|
+
</script>
|
|
10
63
|
<div id="root"></div>
|
|
11
64
|
<script type="module" id="dev-widget-entry">
|
|
12
65
|
import('{{serverUrl}}/src/widgets/{{widgetName}}');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<base href="{{serverUrl}}" />
|
|
2
|
-
<script>
|
|
2
|
+
<script type="module">window.skybridge = { hostType: "{{hostType}}" };</script>
|
|
3
3
|
<div id="root"></div>
|
|
4
4
|
<script type="module">
|
|
5
5
|
import('{{serverUrl}}/assets/{{widgetFile}}');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import cors from "cors";
|
|
3
4
|
import express, {} from "express";
|
|
@@ -14,10 +15,17 @@ import express, {} from "express";
|
|
|
14
15
|
export const widgetsDevServer = async () => {
|
|
15
16
|
const router = express.Router();
|
|
16
17
|
const { createServer, searchForWorkspaceRoot, loadConfigFromFile } = await import("vite");
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
// Since 0.16.0, the template is a single package that does not rely on workspace.
|
|
19
|
+
// It means that, when starting the server, the working dir is the template root
|
|
20
|
+
// hence we don't need to walk up the tree to find the workspace, which does not exist anymore.
|
|
21
|
+
let webAppRoot = path.join(process.cwd(), "web");
|
|
22
|
+
// fallback to the old behavior for backward compatibility
|
|
23
|
+
const hasWebAppRoot = existsSync(webAppRoot);
|
|
24
|
+
if (!hasWebAppRoot) {
|
|
25
|
+
const workspaceRoot = searchForWorkspaceRoot(process.cwd());
|
|
26
|
+
webAppRoot = path.join(workspaceRoot, "web");
|
|
27
|
+
}
|
|
19
28
|
const configResult = await loadConfigFromFile({ command: "serve", mode: "development" }, path.join(webAppRoot, "vite.config.ts"), webAppRoot);
|
|
20
|
-
// biome-ignore lint/correctness/noUnusedVariables: Remove build-specific options that don't apply to dev server
|
|
21
29
|
const { build, preview, ...devConfig } = configResult?.config || {};
|
|
22
30
|
const vite = await createServer({
|
|
23
31
|
...devConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widgetsDevServer.js","sourceRoot":"","sources":["../../../src/server/widgetsDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAuB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"widgetsDevServer.js","sourceRoot":"","sources":["../../../src/server/widgetsDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAuB,MAAM,SAAS,CAAC;AACvD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,IAA6B,EAAE;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,EAAE,YAAY,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,GAChE,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IAEvB,kFAAkF;IAClF,gFAA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js" },
|
|
6
6
|
"style.css": { file: "style.css" },
|
|
7
7
|
};
|
|
8
|
-
vi.
|
|
9
|
-
|
|
8
|
+
const actual = vi.hoisted(() => require("node:fs"));
|
|
9
|
+
vi.mock("node:fs", () => {
|
|
10
10
|
const readFileSyncImpl = (path, ...args) => {
|
|
11
11
|
if (typeof path === "string" && path.includes("manifest.json")) {
|
|
12
12
|
return JSON.stringify(mockManifest);
|
|
13
13
|
}
|
|
14
|
-
// Type assertion needed because readFileSync has overloads with different parameter types
|
|
15
|
-
// Using @ts-expect-error because the overloads are complex and we're forwarding args
|
|
16
|
-
// @ts-expect-error - readFileSync overloads require complex type handling
|
|
17
14
|
return actual.readFileSync(path, ...args);
|
|
18
15
|
};
|
|
19
16
|
const readFileSync = vi.fn(readFileSyncImpl);
|
|
@@ -56,11 +53,19 @@ describe("McpServer.registerWidget", () => {
|
|
|
56
53
|
uri: "ui://widgets/apps-sdk/my-widget.html",
|
|
57
54
|
mimeType: "text/html+skybridge",
|
|
58
55
|
text: expect.stringContaining('<div id="root"></div>'),
|
|
56
|
+
_meta: {
|
|
57
|
+
"openai/widgetCSP": {
|
|
58
|
+
resource_domains: [serverUrl],
|
|
59
|
+
connect_domains: [serverUrl, "ws://localhost:3000"],
|
|
60
|
+
},
|
|
61
|
+
"openai/widgetDomain": serverUrl,
|
|
62
|
+
"openai/widgetDescription": "Test tool",
|
|
63
|
+
},
|
|
59
64
|
},
|
|
60
65
|
],
|
|
61
66
|
});
|
|
62
67
|
// Check development-specific content
|
|
63
|
-
expect(result.contents[0]?.text).toContain(`${serverUrl}/@react-refresh`);
|
|
68
|
+
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/@react-refresh`);
|
|
64
69
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/@vite/client`);
|
|
65
70
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/src/widgets/my-widget`);
|
|
66
71
|
expect(result.contents[0]?.text).not.toContain(`${serverUrl}/src/widgets/my-widget.tsx`);
|
|
@@ -75,8 +80,9 @@ describe("McpServer.registerWidget", () => {
|
|
|
75
80
|
const appsSdkResourceCallback = mockRegisterResource.mock
|
|
76
81
|
.calls[0]?.[3];
|
|
77
82
|
expect(appsSdkResourceCallback).toBeDefined();
|
|
78
|
-
const
|
|
79
|
-
const
|
|
83
|
+
const host = "myapp.com";
|
|
84
|
+
const serverUrl = `https://${host}`;
|
|
85
|
+
const mockExtra = createMockExtra(host);
|
|
80
86
|
const result = await appsSdkResourceCallback(new URL("ui://widgets/apps-sdk/my-widget.html"), mockExtra);
|
|
81
87
|
expect(result).toEqual({
|
|
82
88
|
contents: [
|
|
@@ -84,11 +90,19 @@ describe("McpServer.registerWidget", () => {
|
|
|
84
90
|
uri: "ui://widgets/apps-sdk/my-widget.html",
|
|
85
91
|
mimeType: "text/html+skybridge",
|
|
86
92
|
text: expect.stringContaining('<div id="root"></div>'),
|
|
93
|
+
_meta: {
|
|
94
|
+
"openai/widgetCSP": {
|
|
95
|
+
resource_domains: [serverUrl],
|
|
96
|
+
connect_domains: [serverUrl, `wss://${host}`],
|
|
97
|
+
},
|
|
98
|
+
"openai/widgetDomain": serverUrl,
|
|
99
|
+
"openai/widgetDescription": "Test tool",
|
|
100
|
+
},
|
|
87
101
|
},
|
|
88
102
|
],
|
|
89
103
|
});
|
|
90
104
|
// Check production-specific content
|
|
91
|
-
expect(result.contents[0]?.text).not.toContain(`${serverUrl}
|
|
105
|
+
expect(result.contents[0]?.text).not.toContain(`${serverUrl}/assets/@react-refresh`);
|
|
92
106
|
expect(result.contents[0]?.text).not.toContain(`${serverUrl}@vite/client`);
|
|
93
107
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/my-widget.js`);
|
|
94
108
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/style.css`);
|
|
@@ -102,15 +116,19 @@ describe("McpServer.registerWidget", () => {
|
|
|
102
116
|
const appsSdkResourceCallback = mockRegisterResource.mock
|
|
103
117
|
.calls[0]?.[3];
|
|
104
118
|
expect(appsSdkResourceCallback).toBeDefined();
|
|
105
|
-
const
|
|
106
|
-
const
|
|
119
|
+
const host = "myapp.com";
|
|
120
|
+
const serverUrl = `https://${host}`;
|
|
121
|
+
const mockExtra = createMockExtra(host);
|
|
107
122
|
const result = await appsSdkResourceCallback(new URL("ui://widgets/apps-sdk/folder-widget.html"), mockExtra);
|
|
108
123
|
// Should resolve to folder-widget.js from the manifest entry "src/widgets/folder-widget/index.tsx"
|
|
109
124
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/folder-widget.js`);
|
|
110
125
|
});
|
|
111
126
|
it("should register resources with correct hostType for both apps-sdk and ext-apps formats", async () => {
|
|
112
127
|
const mockToolCallback = vi.fn();
|
|
113
|
-
const mockRegisterResourceConfig = {
|
|
128
|
+
const mockRegisterResourceConfig = {
|
|
129
|
+
description: "Test widget",
|
|
130
|
+
_meta: { "openai/widgetPrefersBorder": true },
|
|
131
|
+
};
|
|
114
132
|
const mockToolConfig = { description: "Test tool" };
|
|
115
133
|
server.registerWidget("my-widget", mockRegisterResourceConfig, mockToolConfig, mockToolCallback);
|
|
116
134
|
expect(mockRegisterResource).toHaveBeenCalledTimes(2);
|
|
@@ -123,6 +141,15 @@ describe("McpServer.registerWidget", () => {
|
|
|
123
141
|
uri: "ui://widgets/apps-sdk/my-widget.html",
|
|
124
142
|
mimeType: "text/html+skybridge",
|
|
125
143
|
text: expect.stringContaining('<div id="root"></div>'),
|
|
144
|
+
_meta: {
|
|
145
|
+
"openai/widgetCSP": {
|
|
146
|
+
resource_domains: ["http://localhost:3000"],
|
|
147
|
+
connect_domains: ["http://localhost:3000", "ws://localhost:3000"],
|
|
148
|
+
},
|
|
149
|
+
"openai/widgetDomain": "http://localhost:3000",
|
|
150
|
+
"openai/widgetDescription": "Test tool",
|
|
151
|
+
"openai/widgetPrefersBorder": true,
|
|
152
|
+
},
|
|
126
153
|
},
|
|
127
154
|
],
|
|
128
155
|
});
|
|
@@ -137,10 +164,36 @@ describe("McpServer.registerWidget", () => {
|
|
|
137
164
|
uri: "ui://widgets/ext-apps/my-widget.html",
|
|
138
165
|
mimeType: "text/html;profile=mcp-app",
|
|
139
166
|
text: expect.stringContaining('<div id="root"></div>'),
|
|
167
|
+
_meta: {
|
|
168
|
+
ui: {
|
|
169
|
+
csp: {
|
|
170
|
+
resourceDomains: ["http://localhost:3000"],
|
|
171
|
+
connectDomains: [
|
|
172
|
+
"http://localhost:3000",
|
|
173
|
+
"ws://localhost:3000",
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
domain: "http://localhost:3000",
|
|
177
|
+
},
|
|
178
|
+
"openai/widgetPrefersBorder": true,
|
|
179
|
+
},
|
|
140
180
|
},
|
|
141
181
|
],
|
|
142
182
|
});
|
|
143
183
|
expect(extAppsResult.contents[0]?.text).toContain('window.skybridge = { hostType: "mcp-app" }');
|
|
144
184
|
});
|
|
185
|
+
it("should register tool with ui.resourceUri metadata (not deprecated ui/resourceUri)", async () => {
|
|
186
|
+
const mockToolCallback = vi.fn();
|
|
187
|
+
const mockRegisterResourceConfig = { description: "Test widget" };
|
|
188
|
+
const mockToolConfig = { description: "Test tool" };
|
|
189
|
+
server.registerWidget("my-widget", mockRegisterResourceConfig, mockToolConfig, mockToolCallback);
|
|
190
|
+
expect(mockRegisterTool).toHaveBeenCalledTimes(1);
|
|
191
|
+
const toolCallArgs = mockRegisterTool.mock.calls[0];
|
|
192
|
+
const toolConfig = toolCallArgs?.[1];
|
|
193
|
+
expect(toolConfig._meta).toHaveProperty("ui");
|
|
194
|
+
expect(toolConfig._meta?.ui).toEqual({
|
|
195
|
+
resourceUri: "ui://widgets/ext-apps/my-widget.html",
|
|
196
|
+
});
|
|
197
|
+
});
|
|
145
198
|
});
|
|
146
199
|
//# sourceMappingURL=widget.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.test.js","sourceRoot":"","sources":["../../../src/test/widget.test.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,SAAS,EAC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,EAAE,CAAC;QAClE,MAAM,cAAc,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;QAEpD,MAAM,CAAC,cAAc,CACnB,WAAW,EACX,0BAA0B,EAC1B,cAAc,EACd,gBAAgB,CACjB,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAElD,MAAM,YAAY,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,YAAY,EAAE,CAAC,CAAC,CAAwC,CAAC;QAE5E,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC;YACnC,WAAW,EAAE,sCAAsC;SACpD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Adaptor, BridgeInterface, CallToolResponse, DisplayMode, ExternalStore } from "../types.js";
|
|
2
|
+
export declare class AppsSdkAdaptor implements Adaptor {
|
|
3
|
+
private static instance;
|
|
4
|
+
static getInstance(): AppsSdkAdaptor;
|
|
5
|
+
static resetInstance(): void;
|
|
6
|
+
getExternalStore<K extends keyof BridgeInterface>(key: K): ExternalStore<K>;
|
|
7
|
+
callTool: <ToolArgs extends Record<string, unknown> | null = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
8
|
+
requestDisplayMode: (mode: DisplayMode) => Promise<{
|
|
9
|
+
mode: DisplayMode;
|
|
10
|
+
}>;
|
|
11
|
+
sendFollowUpMessage: (prompt: string) => Promise<void>;
|
|
12
|
+
openExternal(href: string): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AppsSdkBridge } from "../apps-sdk-bridge.js";
|
|
2
|
+
export class AppsSdkAdaptor {
|
|
3
|
+
static instance = null;
|
|
4
|
+
static getInstance() {
|
|
5
|
+
if (!AppsSdkAdaptor.instance) {
|
|
6
|
+
AppsSdkAdaptor.instance = new AppsSdkAdaptor();
|
|
7
|
+
}
|
|
8
|
+
return AppsSdkAdaptor.instance;
|
|
9
|
+
}
|
|
10
|
+
static resetInstance() {
|
|
11
|
+
AppsSdkAdaptor.instance = null;
|
|
12
|
+
}
|
|
13
|
+
getExternalStore(key) {
|
|
14
|
+
const bridge = AppsSdkBridge.getInstance();
|
|
15
|
+
return {
|
|
16
|
+
subscribe: bridge.subscribe(key),
|
|
17
|
+
getSnapshot: () => bridge.getSnapshot(key),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
callTool = async (name, args) => {
|
|
21
|
+
return window.openai.callTool(name, args);
|
|
22
|
+
};
|
|
23
|
+
requestDisplayMode = (mode) => {
|
|
24
|
+
return window.openai.requestDisplayMode({ mode });
|
|
25
|
+
};
|
|
26
|
+
sendFollowUpMessage = (prompt) => {
|
|
27
|
+
return window.openai.sendFollowUpMessage({ prompt });
|
|
28
|
+
};
|
|
29
|
+
openExternal(href) {
|
|
30
|
+
window.openai.openExternal({ href });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=apps-sdk-adaptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apps-sdk-adaptor.js","sourceRoot":"","sources":["../../../../../src/web/bridges/adaptors/apps-sdk-adaptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAStD,MAAM,OAAO,cAAc;IACjB,MAAM,CAAC,QAAQ,GAA0B,IAAI,CAAC;IAE/C,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC7B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QACjD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,aAAa;QACzB,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;IACjC,CAAC;IAEM,gBAAgB,CACrB,GAAM;QAEN,MAAM,MAAM,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QAC3C,OAAO;YACL,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;YAChC,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC;SAC3C,CAAC;IACJ,CAAC;IAEM,QAAQ,GAAG,KAAK,EAIrB,IAAY,EACZ,IAAc,EACS,EAAE;QACzB,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAyB,IAAI,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC,CAAC;IAEK,kBAAkB,GAAG,CAC1B,IAAiB,EACe,EAAE;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC,CAAC;IAEK,mBAAmB,GAAG,CAAC,MAAc,EAAiB,EAAE;QAC7D,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC;IAEK,YAAY,CAAC,IAAY;QAC9B,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { McpUiRequestDisplayModeResult } from "@modelcontextprotocol/ext-apps";
|
|
2
|
+
import type { Adaptor, BridgeInterface, CallToolResponse, DisplayMode, ExternalStore } from "../types.js";
|
|
3
|
+
export declare class McpAppAdaptor implements Adaptor {
|
|
4
|
+
private static instance;
|
|
5
|
+
private stores;
|
|
6
|
+
private constructor();
|
|
7
|
+
static getInstance(): McpAppAdaptor;
|
|
8
|
+
static resetInstance(): void;
|
|
9
|
+
getExternalStore<K extends keyof BridgeInterface>(key: K): ExternalStore<K>;
|
|
10
|
+
callTool: <ToolArgs extends Record<string, unknown> | null = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
11
|
+
requestDisplayMode: (mode: DisplayMode) => Promise<McpUiRequestDisplayModeResult>;
|
|
12
|
+
sendFollowUpMessage: (prompt: string) => Promise<void>;
|
|
13
|
+
openExternal(href: string): void;
|
|
14
|
+
private initializeStores;
|
|
15
|
+
private createExternalStore;
|
|
16
|
+
}
|