skybridge 0.0.0-dev.6be2d61 → 0.0.0-dev.6c90103
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/index.d.ts +0 -1
- package/dist/src/server/index.js +0 -1
- package/dist/src/server/index.js.map +1 -1
- package/dist/src/server/server.d.ts +28 -1
- package/dist/src/server/server.js +73 -18
- 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.d.ts +2 -2
- package/dist/src/server/widgetsDevServer.js +11 -3
- package/dist/src/server/widgetsDevServer.js.map +1 -1
- package/dist/src/test/widget.test.js +117 -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-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 +3 -5
- package/dist/src/web/types.js.map +1 -1
- package/package.json +25 -26
- package/dist/src/server/devtoolsStaticServer.d.ts +0 -15
- package/dist/src/server/devtoolsStaticServer.js +0 -38
- package/dist/src/server/devtoolsStaticServer.js.map +0 -1
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.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { devtoolsStaticServer } from "./devtoolsStaticServer.js";
|
|
2
1
|
export type { AnyToolRegistry, InferTools, ToolInput, ToolNames, ToolOutput, ToolResponseMetadata, } from "./inferUtilityTypes.js";
|
|
3
2
|
export type { McpServerTypes, ToolDef, WidgetHostType } from "./server.js";
|
|
4
3
|
export { McpServer } from "./server.js";
|
package/dist/src/server/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,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,34 @@ export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unk
|
|
|
7
8
|
output: TOutput;
|
|
8
9
|
responseMetadata: TResponseMetadata;
|
|
9
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Extended MCP Apps CSP with upcoming fields from ext-apps PR #158
|
|
13
|
+
* and Skybridge-specific fields for OpenAI compatibility
|
|
14
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/pull/158
|
|
15
|
+
*/
|
|
16
|
+
type ExtendedMcpUiResourceCsp = McpUiResourceMeta["csp"] & {
|
|
17
|
+
/** Origins allowed for nested iframe embeds */
|
|
18
|
+
frameDomains?: string[];
|
|
19
|
+
/** Origins permitted for the <base> tag URI directive */
|
|
20
|
+
baseUriDomains?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Origins that can receive openExternal redirects without safe-link modal (OpenAI-specific)
|
|
23
|
+
* @see https://developers.openai.com/apps-sdk/reference#component-resource-_meta-fields
|
|
24
|
+
*/
|
|
25
|
+
redirectDomains?: string[];
|
|
26
|
+
};
|
|
27
|
+
/** Extended MCP Apps resource metadata with upcoming CSP fields */
|
|
28
|
+
type ExtendedMcpUiResourceMeta = Omit<McpUiResourceMeta, "csp"> & {
|
|
29
|
+
csp?: ExtendedMcpUiResourceCsp;
|
|
30
|
+
};
|
|
31
|
+
/** User-provided resource configuration with optional CSP override */
|
|
32
|
+
export type WidgetResourceMeta = {
|
|
33
|
+
ui?: ExtendedMcpUiResourceMeta;
|
|
34
|
+
} & Resource["_meta"];
|
|
10
35
|
export type WidgetHostType = "apps-sdk" | "mcp-app";
|
|
11
|
-
type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType"
|
|
36
|
+
type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType" | "_meta"> & {
|
|
37
|
+
_meta?: WidgetResourceMeta;
|
|
38
|
+
};
|
|
12
39
|
type McpServerOriginalToolConfig = Omit<Parameters<typeof McpServerBase.prototype.registerTool<ZodRawShapeCompat, ZodRawShapeCompat>>[1], "inputSchema" | "outputSchema">;
|
|
13
40
|
type Simplify<T> = {
|
|
14
41
|
[K in keyof T]: T[K];
|
|
@@ -1,39 +1,77 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { mergeWith, union } from "es-toolkit";
|
|
4
5
|
import { templateHelper } from "./templateHelper.js";
|
|
6
|
+
const mergeWithUnion = (target, source) => {
|
|
7
|
+
return mergeWith(target, source, (targetVal, sourceVal) => {
|
|
8
|
+
if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {
|
|
9
|
+
return union(targetVal, sourceVal);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
};
|
|
5
13
|
export class McpServer extends McpServerBase {
|
|
6
14
|
registerWidget(name, resourceConfig, toolConfig, toolCallback) {
|
|
7
|
-
const
|
|
8
|
-
...(resourceConfig._meta ?? {}),
|
|
9
|
-
};
|
|
10
|
-
if (toolConfig.description !== undefined) {
|
|
11
|
-
resourceMetadata["openai/widgetDescription"] = toolConfig.description;
|
|
12
|
-
}
|
|
15
|
+
const userMeta = resourceConfig._meta;
|
|
13
16
|
const appsSdkResourceConfig = {
|
|
14
17
|
hostType: "apps-sdk",
|
|
15
18
|
uri: `ui://widgets/apps-sdk/${name}.html`,
|
|
16
19
|
mimeType: "text/html+skybridge",
|
|
20
|
+
buildContentMeta: ({ resourceDomains, connectDomains, domain }) => {
|
|
21
|
+
const userUi = userMeta?.ui;
|
|
22
|
+
const userCsp = userUi?.csp;
|
|
23
|
+
const defaults = {
|
|
24
|
+
"openai/widgetCSP": {
|
|
25
|
+
resource_domains: resourceDomains,
|
|
26
|
+
connect_domains: connectDomains,
|
|
27
|
+
},
|
|
28
|
+
"openai/widgetDomain": domain,
|
|
29
|
+
"openai/widgetDescription": toolConfig.description,
|
|
30
|
+
};
|
|
31
|
+
const fromUi = {
|
|
32
|
+
"openai/widgetCSP": {
|
|
33
|
+
resource_domains: userCsp?.resourceDomains,
|
|
34
|
+
connect_domains: userCsp?.connectDomains,
|
|
35
|
+
frame_domains: userCsp?.frameDomains,
|
|
36
|
+
redirect_domains: userCsp?.redirectDomains,
|
|
37
|
+
},
|
|
38
|
+
"openai/widgetDomain": userUi?.domain,
|
|
39
|
+
"openai/widgetPrefersBorder": userUi?.prefersBorder,
|
|
40
|
+
};
|
|
41
|
+
const directOpenaiKeys = Object.fromEntries(Object.entries(userMeta ?? {}).filter(([key]) => key.startsWith("openai/")));
|
|
42
|
+
return mergeWithUnion(mergeWithUnion(defaults, fromUi), directOpenaiKeys);
|
|
43
|
+
},
|
|
17
44
|
};
|
|
18
45
|
const extAppsResourceConfig = {
|
|
19
46
|
hostType: "mcp-app",
|
|
20
47
|
uri: `ui://widgets/ext-apps/${name}.html`,
|
|
21
48
|
mimeType: "text/html;profile=mcp-app",
|
|
49
|
+
buildContentMeta: ({ resourceDomains, connectDomains, domain }) => {
|
|
50
|
+
const defaults = {
|
|
51
|
+
ui: {
|
|
52
|
+
csp: {
|
|
53
|
+
resourceDomains,
|
|
54
|
+
connectDomains,
|
|
55
|
+
},
|
|
56
|
+
domain,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
return mergeWithUnion(defaults, { ui: userMeta?.ui });
|
|
60
|
+
},
|
|
22
61
|
};
|
|
23
|
-
[appsSdkResourceConfig, extAppsResourceConfig].forEach((
|
|
62
|
+
[appsSdkResourceConfig, extAppsResourceConfig].forEach((widgetConfig) => {
|
|
24
63
|
this.registerWidgetResource({
|
|
25
64
|
name,
|
|
26
|
-
|
|
27
|
-
widgetUri: uri,
|
|
28
|
-
mimeType,
|
|
65
|
+
widgetConfig,
|
|
29
66
|
resourceConfig,
|
|
30
|
-
resourceMetadata,
|
|
31
67
|
});
|
|
32
68
|
});
|
|
33
69
|
const toolMeta = {
|
|
34
70
|
...toolConfig._meta,
|
|
35
71
|
"openai/outputTemplate": appsSdkResourceConfig.uri,
|
|
36
|
-
|
|
72
|
+
ui: {
|
|
73
|
+
resourceUri: extAppsResourceConfig.uri,
|
|
74
|
+
},
|
|
37
75
|
};
|
|
38
76
|
this.registerTool(name, {
|
|
39
77
|
...toolConfig,
|
|
@@ -45,12 +83,15 @@ export class McpServer extends McpServerBase {
|
|
|
45
83
|
super.registerTool(name, config, cb);
|
|
46
84
|
return this;
|
|
47
85
|
}
|
|
48
|
-
registerWidgetResource({ name,
|
|
49
|
-
|
|
50
|
-
|
|
86
|
+
registerWidgetResource({ name, widgetConfig, resourceConfig, }) {
|
|
87
|
+
const { hostType, uri: widgetUri, mimeType, buildContentMeta, } = widgetConfig;
|
|
88
|
+
this.registerResource(name, widgetUri, { ...resourceConfig, _meta: resourceConfig._meta }, async (uri, extra) => {
|
|
89
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
90
|
+
const serverUrl = isProduction
|
|
51
91
|
? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ?? extra?.requestInfo?.headers?.host}`
|
|
52
|
-
:
|
|
53
|
-
const
|
|
92
|
+
: "http://localhost:3000";
|
|
93
|
+
const wsServerUrl = serverUrl.replace(/^http/, "ws");
|
|
94
|
+
const html = isProduction
|
|
54
95
|
? templateHelper.renderProduction({
|
|
55
96
|
hostType,
|
|
56
97
|
serverUrl,
|
|
@@ -62,7 +103,21 @@ export class McpServer extends McpServerBase {
|
|
|
62
103
|
serverUrl,
|
|
63
104
|
widgetName: name,
|
|
64
105
|
});
|
|
65
|
-
|
|
106
|
+
const connectDomains = [serverUrl, wsServerUrl];
|
|
107
|
+
if (!isProduction) {
|
|
108
|
+
const VITE_HMR_WEBSOCKET_DEFAULT_URL = "ws://localhost:24678";
|
|
109
|
+
connectDomains.push(VITE_HMR_WEBSOCKET_DEFAULT_URL);
|
|
110
|
+
}
|
|
111
|
+
const contentMeta = buildContentMeta({
|
|
112
|
+
resourceDomains: [serverUrl],
|
|
113
|
+
connectDomains,
|
|
114
|
+
domain: serverUrl,
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
contents: [
|
|
118
|
+
{ uri: uri.href, mimeType, text: html, _meta: contentMeta },
|
|
119
|
+
],
|
|
120
|
+
};
|
|
66
121
|
});
|
|
67
122
|
}
|
|
68
123
|
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,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,MAAS,EACF,EAAE;IACT,OAAO,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;QACxD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACzD,OAAO,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA8KF,MAAM,OAAO,SAEX,SAAQ,aAAa;IAGrB,cAAc,CAKZ,IAAW,EAC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C;YAEH,OAAO;gBACL,QAAQ,EAAE;oBACR,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE;iBAC5D;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,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Router } from "express";
|
|
2
2
|
/**
|
|
3
3
|
* Install Vite dev server
|
|
4
4
|
* This router MUST be installed at the application root, like so:
|
|
@@ -9,4 +9,4 @@ import { type RequestHandler } from "express";
|
|
|
9
9
|
* app.use(await widgetsRouter());
|
|
10
10
|
* }
|
|
11
11
|
*/
|
|
12
|
-
export declare const widgetsDevServer: () => Promise<
|
|
12
|
+
export declare const widgetsDevServer: () => Promise<Router>;
|
|
@@ -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,
|
|
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,EAAe,MAAM,SAAS,CAAC;AAC/C;;;;;;;;;GASG;AACH,MAAM,C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AC,IAAI,EAAE,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -5,15 +5,12 @@ const mockManifest = {
|
|
|
5
5
|
"src/widgets/folder-widget/index.tsx": { file: "folder-widget.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,23 @@ 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: [
|
|
60
|
+
serverUrl,
|
|
61
|
+
"ws://localhost:3000",
|
|
62
|
+
"ws://localhost:24678",
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
"openai/widgetDomain": serverUrl,
|
|
66
|
+
"openai/widgetDescription": "Test tool",
|
|
67
|
+
},
|
|
59
68
|
},
|
|
60
69
|
],
|
|
61
70
|
});
|
|
62
71
|
// Check development-specific content
|
|
63
|
-
expect(result.contents[0]?.text).toContain(`${serverUrl}/@react-refresh`);
|
|
72
|
+
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/@react-refresh`);
|
|
64
73
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/@vite/client`);
|
|
65
74
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/src/widgets/my-widget`);
|
|
66
75
|
expect(result.contents[0]?.text).not.toContain(`${serverUrl}/src/widgets/my-widget.tsx`);
|
|
@@ -75,8 +84,9 @@ describe("McpServer.registerWidget", () => {
|
|
|
75
84
|
const appsSdkResourceCallback = mockRegisterResource.mock
|
|
76
85
|
.calls[0]?.[3];
|
|
77
86
|
expect(appsSdkResourceCallback).toBeDefined();
|
|
78
|
-
const
|
|
79
|
-
const
|
|
87
|
+
const host = "myapp.com";
|
|
88
|
+
const serverUrl = `https://${host}`;
|
|
89
|
+
const mockExtra = createMockExtra(host);
|
|
80
90
|
const result = await appsSdkResourceCallback(new URL("ui://widgets/apps-sdk/my-widget.html"), mockExtra);
|
|
81
91
|
expect(result).toEqual({
|
|
82
92
|
contents: [
|
|
@@ -84,11 +94,19 @@ describe("McpServer.registerWidget", () => {
|
|
|
84
94
|
uri: "ui://widgets/apps-sdk/my-widget.html",
|
|
85
95
|
mimeType: "text/html+skybridge",
|
|
86
96
|
text: expect.stringContaining('<div id="root"></div>'),
|
|
97
|
+
_meta: {
|
|
98
|
+
"openai/widgetCSP": {
|
|
99
|
+
resource_domains: [serverUrl],
|
|
100
|
+
connect_domains: [serverUrl, `wss://${host}`],
|
|
101
|
+
},
|
|
102
|
+
"openai/widgetDomain": serverUrl,
|
|
103
|
+
"openai/widgetDescription": "Test tool",
|
|
104
|
+
},
|
|
87
105
|
},
|
|
88
106
|
],
|
|
89
107
|
});
|
|
90
108
|
// Check production-specific content
|
|
91
|
-
expect(result.contents[0]?.text).not.toContain(`${serverUrl}
|
|
109
|
+
expect(result.contents[0]?.text).not.toContain(`${serverUrl}/assets/@react-refresh`);
|
|
92
110
|
expect(result.contents[0]?.text).not.toContain(`${serverUrl}@vite/client`);
|
|
93
111
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/my-widget.js`);
|
|
94
112
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/style.css`);
|
|
@@ -102,15 +120,19 @@ describe("McpServer.registerWidget", () => {
|
|
|
102
120
|
const appsSdkResourceCallback = mockRegisterResource.mock
|
|
103
121
|
.calls[0]?.[3];
|
|
104
122
|
expect(appsSdkResourceCallback).toBeDefined();
|
|
105
|
-
const
|
|
106
|
-
const
|
|
123
|
+
const host = "myapp.com";
|
|
124
|
+
const serverUrl = `https://${host}`;
|
|
125
|
+
const mockExtra = createMockExtra(host);
|
|
107
126
|
const result = await appsSdkResourceCallback(new URL("ui://widgets/apps-sdk/folder-widget.html"), mockExtra);
|
|
108
127
|
// Should resolve to folder-widget.js from the manifest entry "src/widgets/folder-widget/index.tsx"
|
|
109
128
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/folder-widget.js`);
|
|
110
129
|
});
|
|
111
130
|
it("should register resources with correct hostType for both apps-sdk and ext-apps formats", async () => {
|
|
112
131
|
const mockToolCallback = vi.fn();
|
|
113
|
-
const mockRegisterResourceConfig = {
|
|
132
|
+
const mockRegisterResourceConfig = {
|
|
133
|
+
description: "Test widget",
|
|
134
|
+
_meta: { "openai/widgetPrefersBorder": true },
|
|
135
|
+
};
|
|
114
136
|
const mockToolConfig = { description: "Test tool" };
|
|
115
137
|
server.registerWidget("my-widget", mockRegisterResourceConfig, mockToolConfig, mockToolCallback);
|
|
116
138
|
expect(mockRegisterResource).toHaveBeenCalledTimes(2);
|
|
@@ -123,6 +145,19 @@ describe("McpServer.registerWidget", () => {
|
|
|
123
145
|
uri: "ui://widgets/apps-sdk/my-widget.html",
|
|
124
146
|
mimeType: "text/html+skybridge",
|
|
125
147
|
text: expect.stringContaining('<div id="root"></div>'),
|
|
148
|
+
_meta: {
|
|
149
|
+
"openai/widgetCSP": {
|
|
150
|
+
resource_domains: ["http://localhost:3000"],
|
|
151
|
+
connect_domains: [
|
|
152
|
+
"http://localhost:3000",
|
|
153
|
+
"ws://localhost:3000",
|
|
154
|
+
"ws://localhost:24678",
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
"openai/widgetDomain": "http://localhost:3000",
|
|
158
|
+
"openai/widgetDescription": "Test tool",
|
|
159
|
+
"openai/widgetPrefersBorder": true,
|
|
160
|
+
},
|
|
126
161
|
},
|
|
127
162
|
],
|
|
128
163
|
});
|
|
@@ -137,10 +172,80 @@ describe("McpServer.registerWidget", () => {
|
|
|
137
172
|
uri: "ui://widgets/ext-apps/my-widget.html",
|
|
138
173
|
mimeType: "text/html;profile=mcp-app",
|
|
139
174
|
text: expect.stringContaining('<div id="root"></div>'),
|
|
175
|
+
_meta: {
|
|
176
|
+
ui: {
|
|
177
|
+
csp: {
|
|
178
|
+
resourceDomains: ["http://localhost:3000"],
|
|
179
|
+
connectDomains: [
|
|
180
|
+
"http://localhost:3000",
|
|
181
|
+
"ws://localhost:3000",
|
|
182
|
+
"ws://localhost:24678",
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
domain: "http://localhost:3000",
|
|
186
|
+
},
|
|
187
|
+
},
|
|
140
188
|
},
|
|
141
189
|
],
|
|
142
190
|
});
|
|
143
191
|
expect(extAppsResult.contents[0]?.text).toContain('window.skybridge = { hostType: "mcp-app" }');
|
|
144
192
|
});
|
|
193
|
+
it("should register tool with ui.resourceUri metadata (not deprecated ui/resourceUri)", async () => {
|
|
194
|
+
const mockToolCallback = vi.fn();
|
|
195
|
+
const mockRegisterResourceConfig = { description: "Test widget" };
|
|
196
|
+
const mockToolConfig = { description: "Test tool" };
|
|
197
|
+
server.registerWidget("my-widget", mockRegisterResourceConfig, mockToolConfig, mockToolCallback);
|
|
198
|
+
expect(mockRegisterTool).toHaveBeenCalledTimes(1);
|
|
199
|
+
const toolCallArgs = mockRegisterTool.mock.calls[0];
|
|
200
|
+
const toolConfig = toolCallArgs?.[1];
|
|
201
|
+
expect(toolConfig._meta).toHaveProperty("ui");
|
|
202
|
+
expect(toolConfig._meta?.ui).toEqual({
|
|
203
|
+
resourceUri: "ui://widgets/ext-apps/my-widget.html",
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
it("should apply meta overrides in correct priority: defaults < ui.* < direct openai/* keys", async () => {
|
|
207
|
+
const mockToolCallback = vi.fn();
|
|
208
|
+
const mockRegisterResourceConfig = {
|
|
209
|
+
description: "Test widget",
|
|
210
|
+
_meta: {
|
|
211
|
+
// ui.csp overrides (middle priority)
|
|
212
|
+
ui: {
|
|
213
|
+
csp: {
|
|
214
|
+
resourceDomains: ["https://from-ui-csp.com"],
|
|
215
|
+
connectDomains: ["https://from-ui-csp.com"],
|
|
216
|
+
},
|
|
217
|
+
domain: "https://from-ui-domain.com",
|
|
218
|
+
prefersBorder: false,
|
|
219
|
+
},
|
|
220
|
+
// Direct openai/* keys (highest priority) - should override ui.*
|
|
221
|
+
"openai/widgetDomain": "https://direct-override.com",
|
|
222
|
+
"openai/widgetPrefersBorder": true,
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
const mockToolConfig = { description: "Test tool" };
|
|
226
|
+
server.registerWidget("override-test", mockRegisterResourceConfig, mockToolConfig, mockToolCallback);
|
|
227
|
+
const appsSdkCallback = mockRegisterResource.mock
|
|
228
|
+
.calls[0]?.[3];
|
|
229
|
+
const result = await appsSdkCallback(new URL("ui://widgets/apps-sdk/override-test.html"), createMockExtra("__not_used__"));
|
|
230
|
+
const meta = result.contents[0]?._meta;
|
|
231
|
+
// CSP arrays are merged with union - all unique domains from defaults and user config are preserved
|
|
232
|
+
expect(meta["openai/widgetCSP"]).toEqual({
|
|
233
|
+
resource_domains: ["http://localhost:3000", "https://from-ui-csp.com"],
|
|
234
|
+
connect_domains: [
|
|
235
|
+
"http://localhost:3000",
|
|
236
|
+
"ws://localhost:3000",
|
|
237
|
+
"ws://localhost:24678",
|
|
238
|
+
"https://from-ui-csp.com",
|
|
239
|
+
],
|
|
240
|
+
frame_domains: undefined,
|
|
241
|
+
redirect_domains: undefined,
|
|
242
|
+
});
|
|
243
|
+
// Domain should be overridden by direct openai/* key (highest priority)
|
|
244
|
+
expect(meta["openai/widgetDomain"]).toBe("https://direct-override.com");
|
|
245
|
+
// PrefersBorder should be overridden by direct openai/* key (highest priority)
|
|
246
|
+
expect(meta["openai/widgetPrefersBorder"]).toBe(true);
|
|
247
|
+
// Description should be from defaults (toolConfig.description)
|
|
248
|
+
expect(meta["openai/widgetDescription"]).toBe("Test tool");
|
|
249
|
+
});
|
|
145
250
|
});
|
|
146
251
|
//# 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,EACT,UAAU,EACV,QAAQ,EACR,MAAM,EACN,EAAE,EAEF,EAAE,GACH,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,MAAM,YAAY,GAAG;IACnB,2BAA2B,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;IACrD,qCAAqC,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;IACnE,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;CACnC,CAAC;AAEF,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"widget.test.js","sourceRoot":"","sources":["../../../src/test/widget.test.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,EACN,EAAE,EAEF,EAAE,GACH,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,MAAM,YAAY,GAAG;IACnB,2BA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C,6BAA6B,CAAC,CAAC;QAExE,+EAA+E;QAC/E,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEtD,+DAA+D;QAC/D,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7D,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
|
+
}
|