skybridge 0.0.0-dev.fe52f66 → 0.0.0-dev.fe9bc33
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/README.md +17 -9
- package/dist/cli/types.d.ts +5 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/use-nodemon.d.ts +1 -6
- package/dist/cli/use-nodemon.js +7 -3
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-tunnel.d.ts +8 -0
- package/dist/cli/use-tunnel.js +101 -0
- package/dist/cli/use-tunnel.js.map +1 -0
- package/dist/commands/dev.d.ts +1 -1
- package/dist/commands/dev.js +9 -7
- package/dist/commands/dev.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.d.ts +5 -6
- package/dist/server/asset-base-url-transform-plugin.js +8 -9
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.test.js +12 -13
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
- package/dist/server/express.d.ts +8 -2
- package/dist/server/express.js +24 -19
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +189 -11
- package/dist/server/express.test.js.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/metric.d.ts +14 -0
- package/dist/server/metric.js +62 -0
- package/dist/server/metric.js.map +1 -0
- package/dist/server/middleware.d.ts +124 -0
- package/dist/server/middleware.js +93 -0
- package/dist/server/middleware.js.map +1 -0
- package/dist/server/middleware.test-d.d.ts +1 -0
- package/dist/server/middleware.test-d.js +75 -0
- package/dist/server/middleware.test-d.js.map +1 -0
- package/dist/server/middleware.test.d.ts +1 -0
- package/dist/server/middleware.test.js +490 -0
- package/dist/server/middleware.test.js.map +1 -0
- package/dist/server/server.d.ts +47 -2
- package/dist/server/server.js +129 -33
- package/dist/server/server.js.map +1 -1
- package/dist/server/templateHelper.d.ts +0 -1
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates/development.hbs +0 -55
- package/dist/server/widgetsDevServer.d.ts +2 -1
- package/dist/server/widgetsDevServer.js +3 -14
- package/dist/server/widgetsDevServer.js.map +1 -1
- package/dist/test/widget.test.js +57 -15
- package/dist/test/widget.test.js.map +1 -1
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/web/bridges/mcp-app/adaptor.d.ts +8 -2
- package/dist/web/bridges/mcp-app/adaptor.js +107 -35
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.d.ts +13 -30
- package/dist/web/bridges/mcp-app/bridge.js +43 -201
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -3
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +2 -2
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/types.d.ts +1 -0
- package/dist/web/components/modal-provider.js +1 -3
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.js +15 -1
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +3 -1
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.test.js +1 -0
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/hooks/test/utils.js +4 -0
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +3 -3
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +15 -10
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +5 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +1 -1
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.js +18 -2
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +29 -1
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-widget-state.test.js +114 -1
- package/dist/web/hooks/use-widget-state.test.js.map +1 -1
- package/dist/web/plugin/transform-data-llm.js +1 -1
- package/dist/web/plugin/transform-data-llm.js.map +1 -1
- package/package.json +15 -14
- package/tsconfig.base.json +3 -0
- package/dist/server/const.d.ts +0 -1
- package/dist/server/const.js +0 -2
- package/dist/server/const.js.map +0 -1
package/dist/server/server.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import type { McpUiResourceMeta } from "@modelcontextprotocol/ext-apps";
|
|
|
2
2
|
import { McpServer as McpServerBase, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
4
4
|
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
5
|
-
import type { CallToolResult, Resource, ServerNotification, ServerRequest, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
-
import type { RequestHandler } from "express";
|
|
5
|
+
import type { CallToolResult, Resource, ServerNotification, ServerRequest, ServerResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
import type { ErrorRequestHandler, RequestHandler } from "express";
|
|
7
|
+
import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
|
|
7
8
|
export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
|
|
8
9
|
input: TInput;
|
|
9
10
|
output: TOutput;
|
|
@@ -84,8 +85,52 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
84
85
|
readonly $types: McpServerTypes<TTools>;
|
|
85
86
|
private express?;
|
|
86
87
|
private customMiddleware;
|
|
88
|
+
private customErrorMiddleware;
|
|
89
|
+
private mcpMiddlewareEntries;
|
|
90
|
+
private mcpMiddlewareApplied;
|
|
87
91
|
use(...handlers: RequestHandler[]): this;
|
|
88
92
|
use(path: string, ...handlers: RequestHandler[]): this;
|
|
93
|
+
useOnError(...handlers: ErrorRequestHandler[]): this;
|
|
94
|
+
useOnError(path: string, ...handlers: ErrorRequestHandler[]): this;
|
|
95
|
+
/**
|
|
96
|
+
* Register MCP protocol-level middleware (catch-all).
|
|
97
|
+
*/
|
|
98
|
+
mcpMiddleware(handler: McpMiddlewareFn): this;
|
|
99
|
+
/**
|
|
100
|
+
* Register MCP protocol-level middleware for all requests (`extra` is `McpExtra`).
|
|
101
|
+
*/
|
|
102
|
+
mcpMiddleware(filter: "request", handler: (request: {
|
|
103
|
+
method: string;
|
|
104
|
+
params: Record<string, unknown>;
|
|
105
|
+
}, extra: McpExtra, next: () => Promise<ServerResult>) => Promise<unknown> | unknown): this;
|
|
106
|
+
/**
|
|
107
|
+
* Register MCP protocol-level middleware for all notifications (`extra` is `undefined`).
|
|
108
|
+
*/
|
|
109
|
+
mcpMiddleware(filter: "notification", handler: (request: {
|
|
110
|
+
method: string;
|
|
111
|
+
params: Record<string, unknown>;
|
|
112
|
+
}, extra: undefined, next: () => Promise<undefined>) => Promise<unknown> | unknown): this;
|
|
113
|
+
/**
|
|
114
|
+
* Register MCP protocol-level middleware for an exact method.
|
|
115
|
+
* Narrows `params`, `extra`, and `next()` result based on the method string.
|
|
116
|
+
*/
|
|
117
|
+
mcpMiddleware<M extends McpMethodString>(filter: M, handler: McpTypedMiddlewareFn<M>): this;
|
|
118
|
+
/**
|
|
119
|
+
* Register MCP protocol-level middleware for a wildcard pattern (e.g. `"tools/*"`).
|
|
120
|
+
* `next()` returns the union of result types for matching methods.
|
|
121
|
+
*/
|
|
122
|
+
mcpMiddleware<W extends McpWildcard>(filter: W, handler: (request: {
|
|
123
|
+
method: string;
|
|
124
|
+
params: Record<string, unknown>;
|
|
125
|
+
}, extra: McpExtraFor<W>, next: () => Promise<McpResultFor<W>>) => Promise<unknown> | unknown): this;
|
|
126
|
+
/**
|
|
127
|
+
* Register MCP protocol-level middleware with a method filter.
|
|
128
|
+
* Filter can be an exact method (`"tools/call"`), wildcard (`"tools/*"`),
|
|
129
|
+
* category (`"request"` | `"notification"`), or an array of those.
|
|
130
|
+
*/
|
|
131
|
+
mcpMiddleware(filter: McpMiddlewareFilter, handler: McpMiddlewareFn): this;
|
|
132
|
+
private applyMcpMiddleware;
|
|
133
|
+
connect(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
|
|
89
134
|
run(): Promise<void>;
|
|
90
135
|
registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends {
|
|
91
136
|
content: CallToolResult["content"];
|
package/dist/server/server.js
CHANGED
|
@@ -4,8 +4,9 @@ import http from "node:http";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
6
|
import { mergeWith, union } from "es-toolkit";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { createApp } from "./express.js";
|
|
8
|
+
import { createMiddlewareEntry } from "./metric.js";
|
|
9
|
+
import { buildMiddlewareChain, getHandlerMaps } from "./middleware.js";
|
|
9
10
|
import { templateHelper } from "./templateHelper.js";
|
|
10
11
|
const mergeWithUnion = (target, source) => {
|
|
11
12
|
return mergeWith(target, source, (targetVal, sourceVal) => {
|
|
@@ -17,6 +18,9 @@ const mergeWithUnion = (target, source) => {
|
|
|
17
18
|
export class McpServer extends McpServerBase {
|
|
18
19
|
express;
|
|
19
20
|
customMiddleware = [];
|
|
21
|
+
customErrorMiddleware = [];
|
|
22
|
+
mcpMiddlewareEntries = [];
|
|
23
|
+
mcpMiddlewareApplied = false;
|
|
20
24
|
use(pathOrHandler, ...handlers) {
|
|
21
25
|
if (typeof pathOrHandler === "string") {
|
|
22
26
|
this.customMiddleware.push({
|
|
@@ -31,22 +35,88 @@ export class McpServer extends McpServerBase {
|
|
|
31
35
|
}
|
|
32
36
|
return this;
|
|
33
37
|
}
|
|
38
|
+
useOnError(pathOrHandler, ...handlers) {
|
|
39
|
+
if (typeof pathOrHandler === "string") {
|
|
40
|
+
this.customErrorMiddleware.push({ path: pathOrHandler, handlers });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.customErrorMiddleware.push({
|
|
44
|
+
handlers: [pathOrHandler, ...handlers],
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
mcpMiddleware(filterOrHandler,
|
|
50
|
+
// biome-ignore lint/suspicious/noExplicitAny: overloads narrow the handler type at call sites; implementation must accept all variants
|
|
51
|
+
maybeHandler) {
|
|
52
|
+
if (this.mcpMiddlewareApplied) {
|
|
53
|
+
throw new Error("Cannot register MCP middleware after run() or connect() has been called");
|
|
54
|
+
}
|
|
55
|
+
const handler = maybeHandler;
|
|
56
|
+
if (typeof filterOrHandler === "function") {
|
|
57
|
+
this.mcpMiddlewareEntries.push({
|
|
58
|
+
filter: null,
|
|
59
|
+
handler: filterOrHandler,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else if (handler) {
|
|
63
|
+
this.mcpMiddlewareEntries.push({
|
|
64
|
+
filter: filterOrHandler,
|
|
65
|
+
handler,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error("mcpMiddleware requires a handler function when a filter is provided");
|
|
70
|
+
}
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
applyMcpMiddleware() {
|
|
74
|
+
if (this.mcpMiddlewareApplied) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.mcpMiddlewareApplied = true;
|
|
78
|
+
const monitoringEntry = createMiddlewareEntry();
|
|
79
|
+
const entries = monitoringEntry
|
|
80
|
+
? [monitoringEntry, ...this.mcpMiddlewareEntries]
|
|
81
|
+
: this.mcpMiddlewareEntries;
|
|
82
|
+
if (entries.length === 0) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const { requestHandlers, notificationHandlers } = getHandlerMaps(this.server);
|
|
86
|
+
// Wrap existing handlers and proxy future .set() for lazy SDK registration
|
|
87
|
+
const instrumentMap = (map, isNotification) => {
|
|
88
|
+
for (const [method, handler] of map) {
|
|
89
|
+
map.set(method, buildMiddlewareChain(method, isNotification, handler, entries));
|
|
90
|
+
}
|
|
91
|
+
const originalSet = map.set.bind(map);
|
|
92
|
+
map.set = (method, handler) => originalSet(method, buildMiddlewareChain(method, isNotification, handler, entries));
|
|
93
|
+
};
|
|
94
|
+
instrumentMap(requestHandlers, false);
|
|
95
|
+
instrumentMap(notificationHandlers, true);
|
|
96
|
+
}
|
|
97
|
+
async connect(transport) {
|
|
98
|
+
this.applyMcpMiddleware();
|
|
99
|
+
return super.connect(transport);
|
|
100
|
+
}
|
|
34
101
|
async run() {
|
|
102
|
+
this.applyMcpMiddleware();
|
|
103
|
+
const httpServer = http.createServer();
|
|
35
104
|
if (!this.express) {
|
|
36
|
-
this.express = await
|
|
37
|
-
|
|
105
|
+
this.express = await createApp({
|
|
106
|
+
mcpServer: this,
|
|
107
|
+
httpServer,
|
|
38
108
|
customMiddleware: this.customMiddleware,
|
|
109
|
+
errorMiddleware: this.customErrorMiddleware,
|
|
39
110
|
});
|
|
40
111
|
}
|
|
41
|
-
|
|
112
|
+
httpServer.on("request", this.express);
|
|
42
113
|
return new Promise((resolve, reject) => {
|
|
43
|
-
|
|
44
|
-
server.on("error", (error) => {
|
|
114
|
+
httpServer.on("error", (error) => {
|
|
45
115
|
console.error("Failed to start server:", error);
|
|
46
116
|
reject(error);
|
|
47
117
|
});
|
|
48
118
|
const port = parseInt(process.env.__PORT ?? "3000", 10);
|
|
49
|
-
|
|
119
|
+
httpServer.listen(port, () => {
|
|
50
120
|
resolve();
|
|
51
121
|
});
|
|
52
122
|
});
|
|
@@ -122,10 +192,20 @@ export class McpServer extends McpServerBase {
|
|
|
122
192
|
toolMeta["ui/resourceUri"] = widgetConfig.uri;
|
|
123
193
|
toolMeta.ui = { resourceUri: widgetConfig.uri };
|
|
124
194
|
}
|
|
195
|
+
const wrappedToolCallback = async (args, extra) => {
|
|
196
|
+
const result = await toolCallback(args, extra);
|
|
197
|
+
return {
|
|
198
|
+
...result,
|
|
199
|
+
_meta: {
|
|
200
|
+
...result._meta,
|
|
201
|
+
viewUUID: crypto.randomUUID(),
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
};
|
|
125
205
|
this.registerTool(name, {
|
|
126
206
|
...toolConfig,
|
|
127
207
|
_meta: toolMeta,
|
|
128
|
-
},
|
|
208
|
+
}, wrappedToolCallback);
|
|
129
209
|
return this;
|
|
130
210
|
}
|
|
131
211
|
registerTool(name, config, cb) {
|
|
@@ -136,15 +216,33 @@ export class McpServer extends McpServerBase {
|
|
|
136
216
|
const { hostType, uri: widgetUri, mimeType, buildContentMeta, } = widgetConfig;
|
|
137
217
|
this.registerResource(name, widgetUri, { ...resourceConfig, _meta: resourceConfig._meta }, async (uri, extra) => {
|
|
138
218
|
const isProduction = process.env.NODE_ENV === "production";
|
|
139
|
-
const useForwardedHost = process.env.SKYBRIDGE_USE_FORWARDED_HOST === "true";
|
|
140
219
|
const isClaude = extra?.requestInfo?.headers?.["user-agent"] === "Claude-User";
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
220
|
+
const headers = extra?.requestInfo?.headers || {};
|
|
221
|
+
const header = (key) => {
|
|
222
|
+
const val = headers[key];
|
|
223
|
+
return Array.isArray(val) ? val[0] : val;
|
|
224
|
+
};
|
|
225
|
+
let serverUrl;
|
|
226
|
+
const forwardedHost = header("x-forwarded-host");
|
|
227
|
+
const origin = header("origin");
|
|
228
|
+
const host = header("host");
|
|
229
|
+
if (forwardedHost) {
|
|
230
|
+
const proto = header("x-forwarded-proto") || "https";
|
|
231
|
+
serverUrl = `${proto}://${forwardedHost}`;
|
|
232
|
+
}
|
|
233
|
+
else if (origin) {
|
|
234
|
+
serverUrl = origin;
|
|
235
|
+
}
|
|
236
|
+
else if (host) {
|
|
237
|
+
const proto = ["127.0.0.1:", "localhost:"].some((p) => host.startsWith(p))
|
|
238
|
+
? "http"
|
|
239
|
+
: "https";
|
|
240
|
+
serverUrl = `${proto}://${host}`;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
const devPort = process.env.__PORT || "3000";
|
|
244
|
+
serverUrl = `http://localhost:${devPort}`;
|
|
245
|
+
}
|
|
148
246
|
const html = isProduction
|
|
149
247
|
? templateHelper.renderProduction({
|
|
150
248
|
hostType,
|
|
@@ -155,27 +253,25 @@ export class McpServer extends McpServerBase {
|
|
|
155
253
|
: templateHelper.renderDevelopment({
|
|
156
254
|
hostType,
|
|
157
255
|
serverUrl,
|
|
158
|
-
useLocalNetworkAccess: !useExternalHost,
|
|
159
256
|
widgetName: name,
|
|
160
257
|
});
|
|
161
258
|
const connectDomains = [serverUrl];
|
|
162
259
|
if (!isProduction) {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
connectDomains.push(
|
|
260
|
+
const wsUrl = new URL(serverUrl);
|
|
261
|
+
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
262
|
+
connectDomains.push(wsUrl.origin);
|
|
263
|
+
}
|
|
264
|
+
let contentMetaOverrides = {};
|
|
265
|
+
if (isClaude) {
|
|
266
|
+
const pathname = extra?.requestInfo?.url?.pathname ?? "";
|
|
267
|
+
const url = `${serverUrl}${pathname}`;
|
|
268
|
+
const hash = crypto
|
|
269
|
+
.createHash("sha256")
|
|
270
|
+
.update(url)
|
|
271
|
+
.digest("hex")
|
|
272
|
+
.slice(0, 32);
|
|
273
|
+
contentMetaOverrides = { domain: `${hash}.claudemcpcontent.com` };
|
|
166
274
|
}
|
|
167
|
-
const pathname = extra?.requestInfo?.url?.pathname ?? "";
|
|
168
|
-
const url = `https://${hostFromHeaders}${pathname}`;
|
|
169
|
-
const hash = crypto
|
|
170
|
-
.createHash("sha256")
|
|
171
|
-
.update(url)
|
|
172
|
-
.digest("hex")
|
|
173
|
-
.slice(0, 32);
|
|
174
|
-
const contentMetaOverrides = isClaude
|
|
175
|
-
? {
|
|
176
|
-
domain: `${hash}.claudemcpcontent.com`,
|
|
177
|
-
}
|
|
178
|
-
: {};
|
|
179
275
|
const contentMeta = buildContentMeta({
|
|
180
276
|
resourceDomains: [serverUrl],
|
|
181
277
|
connectDomains,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,EACL,SAAS,IAAI,aAAa,GAG3B,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,EACL,SAAS,IAAI,aAAa,GAG3B,MAAM,yCAAyC,CAAC;AAejD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA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CAAC;IACxB,CAAC;IAED,iBAAiB,CAAC,IAIjB;QACC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAClD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -6,61 +6,6 @@
|
|
|
6
6
|
window.__vite_plugin_react_preamble_installed__ = true;
|
|
7
7
|
</script>
|
|
8
8
|
<script type="module" src="{{serverUrl}}/@vite/client"></script>
|
|
9
|
-
{{#if useLocalNetworkAccess}}
|
|
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>
|
|
63
|
-
{{/if}}
|
|
64
9
|
<div id="root"></div>
|
|
65
10
|
<script type="module" id="dev-widget-entry">
|
|
66
11
|
import('{{serverUrl}}/src/widgets/{{widgetName}}');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type http from "node:http";
|
|
1
2
|
import { type Router } from "express";
|
|
2
3
|
/**
|
|
3
4
|
* Install Vite dev server
|
|
@@ -9,4 +10,4 @@ import { type Router } from "express";
|
|
|
9
10
|
* app.use(await widgetsRouter());
|
|
10
11
|
* }
|
|
11
12
|
*/
|
|
12
|
-
export declare const widgetsDevServer: () => Promise<Router>;
|
|
13
|
+
export declare const widgetsDevServer: (httpServer: http.Server) => Promise<Router>;
|
|
@@ -2,9 +2,7 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import cors from "cors";
|
|
4
4
|
import express, {} from "express";
|
|
5
|
-
import { detectAvailablePort } from "../cli/detect-port.js";
|
|
6
5
|
import { assetBaseUrlTransformPlugin } from "./asset-base-url-transform-plugin.js";
|
|
7
|
-
import { DEFAULT_HMR_PORT } from "./const.js";
|
|
8
6
|
/**
|
|
9
7
|
* Install Vite dev server
|
|
10
8
|
* This router MUST be installed at the application root, like so:
|
|
@@ -15,7 +13,7 @@ import { DEFAULT_HMR_PORT } from "./const.js";
|
|
|
15
13
|
* app.use(await widgetsRouter());
|
|
16
14
|
* }
|
|
17
15
|
*/
|
|
18
|
-
export const widgetsDevServer = async () => {
|
|
16
|
+
export const widgetsDevServer = async (httpServer) => {
|
|
19
17
|
const router = express.Router();
|
|
20
18
|
const { createServer, searchForWorkspaceRoot, loadConfigFromFile } = await import("vite");
|
|
21
19
|
// Since 0.16.0, the template is a single package that does not rely on workspace.
|
|
@@ -30,8 +28,6 @@ export const widgetsDevServer = async () => {
|
|
|
30
28
|
}
|
|
31
29
|
const configResult = await loadConfigFromFile({ command: "serve", mode: "development" }, path.join(webAppRoot, "vite.config.ts"), webAppRoot);
|
|
32
30
|
const { build, preview, plugins: userPlugins = [], ...devConfig } = configResult?.config || {};
|
|
33
|
-
const hmrPort = await detectAvailablePort(DEFAULT_HMR_PORT, "localhost");
|
|
34
|
-
process.env.__SKYBRIDGE_HMR_PORT = String(hmrPort);
|
|
35
31
|
const vite = await createServer({
|
|
36
32
|
...devConfig,
|
|
37
33
|
configFile: false, // Keep this to prevent vite from trying to resolve path in the target config file
|
|
@@ -40,21 +36,14 @@ export const widgetsDevServer = async () => {
|
|
|
40
36
|
allowedHosts: true,
|
|
41
37
|
middlewareMode: true,
|
|
42
38
|
hmr: {
|
|
43
|
-
|
|
44
|
-
host: "localhost",
|
|
45
|
-
port: hmrPort,
|
|
39
|
+
server: httpServer,
|
|
46
40
|
},
|
|
47
41
|
},
|
|
48
42
|
root: webAppRoot,
|
|
49
43
|
optimizeDeps: {
|
|
50
44
|
include: ["react", "react-dom/client"],
|
|
51
45
|
},
|
|
52
|
-
plugins: [
|
|
53
|
-
...userPlugins,
|
|
54
|
-
assetBaseUrlTransformPlugin({
|
|
55
|
-
devServerOrigin: `http://localhost:${process.env.__PORT ?? "3000"}`,
|
|
56
|
-
}),
|
|
57
|
-
],
|
|
46
|
+
plugins: [...userPlugins, assetBaseUrlTransformPlugin()],
|
|
58
47
|
});
|
|
59
48
|
router.use(cors());
|
|
60
49
|
router.use("/", vite.middlewares);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widgetsDevServer.js","sourceRoot":"","sources":["../../src/server/widgetsDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,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;AAErC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAe,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAEnF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACnC,UAAuB,EACN,EAAE;IACnB,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,gFAAgF;IAChF,+FAA+F;IAC/F,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;IAEjD,0DAA0D;IAC1D,MA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
const appsSdkResourceCallback = mockRegisterResource.mock
|
|
44
44
|
.calls[0]?.[3];
|
|
45
45
|
expect(appsSdkResourceCallback).toBeDefined();
|
|
46
|
-
const
|
|
47
|
-
const
|
|
46
|
+
const host = "localhost:3000";
|
|
47
|
+
const serverUrl = `http://${host}`;
|
|
48
|
+
const hmrUrl = `ws://${host}`;
|
|
49
|
+
const mockExtra = createMockExtra(host);
|
|
48
50
|
const result = await appsSdkResourceCallback(new URL("ui://widgets/apps-sdk/my-widget.html"), mockExtra);
|
|
49
51
|
expect(mockRegisterTool).toHaveBeenCalled();
|
|
50
52
|
expect(result).toEqual({
|
|
@@ -56,7 +58,7 @@ describe("McpServer.registerWidget", () => {
|
|
|
56
58
|
_meta: {
|
|
57
59
|
"openai/widgetCSP": {
|
|
58
60
|
resource_domains: [serverUrl],
|
|
59
|
-
connect_domains: [serverUrl,
|
|
61
|
+
connect_domains: [serverUrl, hmrUrl],
|
|
60
62
|
},
|
|
61
63
|
"openai/widgetDomain": serverUrl,
|
|
62
64
|
"openai/widgetDescription": "Test widget",
|
|
@@ -134,8 +136,10 @@ describe("McpServer.registerWidget", () => {
|
|
|
134
136
|
expect(mockRegisterResource).toHaveBeenCalledTimes(2);
|
|
135
137
|
const appsSdkCallback = mockRegisterResource.mock
|
|
136
138
|
.calls[0]?.[3];
|
|
137
|
-
const appsSdkResult = await appsSdkCallback(new URL("ui://widgets/apps-sdk/my-widget.html"), createMockExtra("
|
|
138
|
-
const
|
|
139
|
+
const appsSdkResult = await appsSdkCallback(new URL("ui://widgets/apps-sdk/my-widget.html"), createMockExtra("localhost:3000"));
|
|
140
|
+
const host = "localhost:3000";
|
|
141
|
+
const serverUrl = `http://${host}`;
|
|
142
|
+
const hmrUrl = `ws://${host}`;
|
|
139
143
|
expect(appsSdkResult).toEqual({
|
|
140
144
|
contents: [
|
|
141
145
|
{
|
|
@@ -145,7 +149,7 @@ describe("McpServer.registerWidget", () => {
|
|
|
145
149
|
_meta: {
|
|
146
150
|
"openai/widgetCSP": {
|
|
147
151
|
resource_domains: [serverUrl],
|
|
148
|
-
connect_domains: [serverUrl,
|
|
152
|
+
connect_domains: [serverUrl, hmrUrl],
|
|
149
153
|
},
|
|
150
154
|
"openai/widgetDomain": serverUrl,
|
|
151
155
|
"openai/widgetDescription": "Test widget",
|
|
@@ -158,7 +162,7 @@ describe("McpServer.registerWidget", () => {
|
|
|
158
162
|
const extAppsResourceCallback = mockRegisterResource.mock
|
|
159
163
|
.calls[1]?.[3];
|
|
160
164
|
expect(extAppsResourceCallback).toBeDefined();
|
|
161
|
-
const extAppsResult = await extAppsResourceCallback(new URL("ui://widgets/ext-apps/my-widget.html"), createMockExtra(
|
|
165
|
+
const extAppsResult = await extAppsResourceCallback(new URL("ui://widgets/ext-apps/my-widget.html"), createMockExtra(host));
|
|
162
166
|
expect(extAppsResult).toEqual({
|
|
163
167
|
contents: [
|
|
164
168
|
{
|
|
@@ -169,7 +173,7 @@ describe("McpServer.registerWidget", () => {
|
|
|
169
173
|
ui: {
|
|
170
174
|
csp: {
|
|
171
175
|
resourceDomains: [serverUrl],
|
|
172
|
-
connectDomains: [serverUrl,
|
|
176
|
+
connectDomains: [serverUrl, hmrUrl],
|
|
173
177
|
},
|
|
174
178
|
domain: serverUrl,
|
|
175
179
|
},
|
|
@@ -215,17 +219,15 @@ describe("McpServer.registerWidget", () => {
|
|
|
215
219
|
server.registerWidget("override-test", mockRegisterResourceConfig, mockToolConfig, mockToolCallback);
|
|
216
220
|
const appsSdkCallback = mockRegisterResource.mock
|
|
217
221
|
.calls[0]?.[3];
|
|
218
|
-
const
|
|
219
|
-
const
|
|
222
|
+
const host = `localhost:3000`;
|
|
223
|
+
const serverUrl = `http://${host}`;
|
|
224
|
+
const hmrUrl = `ws://${host}`;
|
|
225
|
+
const result = await appsSdkCallback(new URL("ui://widgets/apps-sdk/override-test.html"), createMockExtra(host));
|
|
220
226
|
const meta = result.contents[0]?._meta;
|
|
221
227
|
// CSP arrays are merged with union - all unique domains from defaults and user config are preserved
|
|
222
228
|
expect(meta["openai/widgetCSP"]).toEqual({
|
|
223
229
|
resource_domains: [serverUrl, "https://from-ui-csp.com"],
|
|
224
|
-
connect_domains: [
|
|
225
|
-
serverUrl,
|
|
226
|
-
"ws://localhost:24678",
|
|
227
|
-
"https://from-ui-csp.com",
|
|
228
|
-
],
|
|
230
|
+
connect_domains: [serverUrl, hmrUrl, "https://from-ui-csp.com"],
|
|
229
231
|
frame_domains: undefined,
|
|
230
232
|
redirect_domains: undefined,
|
|
231
233
|
});
|
|
@@ -248,6 +250,46 @@ describe("McpServer.registerWidget", () => {
|
|
|
248
250
|
});
|
|
249
251
|
expect(toolConfig._meta?.["openai/outputTemplate"]).to.be.undefined;
|
|
250
252
|
});
|
|
253
|
+
it("should inject viewUUID into _meta of tool callback results", async () => {
|
|
254
|
+
const mockToolCallback = vi.fn().mockResolvedValue({
|
|
255
|
+
content: [{ type: "text", text: "result" }],
|
|
256
|
+
structuredContent: { data: "test" },
|
|
257
|
+
});
|
|
258
|
+
server.registerWidget("my-widget", { description: "Test widget" }, { description: "Test tool" }, mockToolCallback);
|
|
259
|
+
// The registerTool should have been called with a wrapped callback
|
|
260
|
+
const wrappedCallback = mockRegisterTool.mock.calls[0]?.[2];
|
|
261
|
+
expect(wrappedCallback).toBeDefined();
|
|
262
|
+
const result = await wrappedCallback({}, {});
|
|
263
|
+
expect(result._meta).toBeDefined();
|
|
264
|
+
expect(result._meta?.viewUUID).toBeDefined();
|
|
265
|
+
expect(typeof result._meta?.viewUUID).toBe("string");
|
|
266
|
+
// UUID v4 format
|
|
267
|
+
expect(result._meta?.viewUUID).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
|
|
268
|
+
});
|
|
269
|
+
it("should preserve existing _meta when injecting viewUUID", async () => {
|
|
270
|
+
const mockToolCallback = vi.fn().mockResolvedValue({
|
|
271
|
+
content: [{ type: "text", text: "result" }],
|
|
272
|
+
structuredContent: { data: "test" },
|
|
273
|
+
_meta: { requestId: "req-123", cached: true },
|
|
274
|
+
});
|
|
275
|
+
server.registerWidget("my-widget", { description: "Test widget" }, { description: "Test tool" }, mockToolCallback);
|
|
276
|
+
const wrappedCallback = mockRegisterTool.mock.calls[0]?.[2];
|
|
277
|
+
const result = await wrappedCallback({}, {});
|
|
278
|
+
expect(result._meta?.requestId).toBe("req-123");
|
|
279
|
+
expect(result._meta?.cached).toBe(true);
|
|
280
|
+
expect(result._meta?.viewUUID).toBeDefined();
|
|
281
|
+
});
|
|
282
|
+
it("should generate unique viewUUIDs across calls", async () => {
|
|
283
|
+
const mockToolCallback = vi.fn().mockResolvedValue({
|
|
284
|
+
content: [{ type: "text", text: "result" }],
|
|
285
|
+
structuredContent: {},
|
|
286
|
+
});
|
|
287
|
+
server.registerWidget("my-widget", { description: "Test widget" }, { description: "Test tool" }, mockToolCallback);
|
|
288
|
+
const wrappedCallback = mockRegisterTool.mock.calls[0]?.[2];
|
|
289
|
+
const result1 = await wrappedCallback({}, {});
|
|
290
|
+
const result2 = await wrappedCallback({}, {});
|
|
291
|
+
expect(result1._meta?.viewUUID).not.toBe(result2._meta?.viewUUID);
|
|
292
|
+
});
|
|
251
293
|
it("should register tool with uopenai/outputTemplate metadata only", async () => {
|
|
252
294
|
const mockToolCallback = vi.fn();
|
|
253
295
|
server.registerWidget("my-widget", { description: "Test widget", hosts: ["apps-sdk"] }, { description: "Test tool" }, mockToolCallback);
|