@opentiny/next-sdk 0.1.15-beta.1 → 0.1.15
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/agent/AgentModelProvider.ts +1 -490
- package/agent/type.ts +2 -8
- package/dist/WebMcpClient.d.ts +26 -165
- package/dist/WebMcpServer.d.ts +147 -36
- package/dist/agent/AgentModelProvider.d.ts +1 -35
- package/dist/agent/type.d.ts +2 -8
- package/dist/index.es.dev.js +11175 -14893
- package/dist/index.es.js +18206 -20985
- package/dist/index.js +320 -2411
- package/dist/index.umd.dev.js +11200 -14918
- package/dist/index.umd.js +71 -111
- package/dist/{mcpsdk@1.24.3.dev.js → mcpsdk@1.23.0.dev.js} +6652 -8271
- package/dist/{mcpsdk@1.24.3.es.dev.js → mcpsdk@1.23.0.es.dev.js} +6641 -8260
- package/dist/mcpsdk@1.23.0.es.js +15584 -0
- package/dist/mcpsdk@1.23.0.js +43 -0
- package/dist/transport/ExtensionPageServerTransport.d.ts +2 -1
- package/dist/webagent.dev.js +19914 -23355
- package/dist/webagent.es.dev.js +19889 -23330
- package/dist/webagent.es.js +15583 -18140
- package/dist/webagent.js +65 -105
- package/dist/webmcp-full.dev.js +7263 -8880
- package/dist/webmcp-full.es.dev.js +7261 -8878
- package/dist/webmcp-full.es.js +9267 -10421
- package/dist/webmcp-full.js +32 -32
- package/dist/webmcp.dev.js +22 -14
- package/dist/webmcp.es.dev.js +20 -12
- package/dist/webmcp.es.js +179 -172
- package/dist/webmcp.js +1 -1
- package/dist/zod@3.25.76.dev.js +32 -30
- package/dist/zod@3.25.76.es.dev.js +30 -28
- package/dist/zod@3.25.76.es.js +145 -143
- package/dist/zod@3.25.76.js +1 -1
- package/package.json +8 -9
- package/transport/ExtensionPageServerTransport.ts +4 -2
- package/agent/utils/generateReActPrompt.ts +0 -55
- package/agent/utils/parseReActAction.ts +0 -34
- package/dist/agent/utils/generateReActPrompt.d.ts +0 -9
- package/dist/agent/utils/parseReActAction.d.ts +0 -14
- package/dist/mcpsdk@1.24.3.es.js +0 -16781
- package/dist/mcpsdk@1.24.3.js +0 -43
package/dist/webmcp.dev.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global2, factory) {
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("ajv"), require("@modelcontextprotocol/sdk/types.js"), require("@modelcontextprotocol/sdk/client/index.js"), require("@modelcontextprotocol/sdk/client/sse.js"), require("@modelcontextprotocol/sdk/client/streamableHttp.js"), require("@modelcontextprotocol/sdk/client/websocket.js"), require("@modelcontextprotocol/sdk/client/auth.js"), require("@modelcontextprotocol/sdk/server/mcp.js"), require("zod"), require("@modelcontextprotocol/sdk/shared/uriTemplate.js"), require("@modelcontextprotocol/sdk/server/completable.js"), require("@modelcontextprotocol/sdk/shared/metadataUtils.js")) : typeof define === "function" && define.amd ? define(["exports", "ajv", "@modelcontextprotocol/sdk/types.js", "@modelcontextprotocol/sdk/client/index.js", "@modelcontextprotocol/sdk/client/sse.js", "@modelcontextprotocol/sdk/client/streamableHttp.js", "@modelcontextprotocol/sdk/client/websocket.js", "@modelcontextprotocol/sdk/client/auth.js", "@modelcontextprotocol/sdk/server/mcp.js", "zod", "@modelcontextprotocol/sdk/shared/uriTemplate.js", "@modelcontextprotocol/sdk/server/completable.js", "@modelcontextprotocol/sdk/shared/metadataUtils.js"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.WebMCP = {}, global2.MCPSDK, global2.MCPSDK, global2.MCPSDK, global2.MCPSDK, global2.MCPSDK, global2.websocket_js, global2.MCPSDK, global2.MCPSDK, global2.Zod, global2.MCPSDK, global2.MCPSDK, global2.MCPSDK));
|
|
3
|
-
})(this,
|
|
3
|
+
})(this, function(exports2, ajv, types_js, index_js, sse_js, streamableHttp_js, websocket_js, auth_js, mcp_js, zod, uriTemplate_js, completable_js, metadataUtils_js) {
|
|
4
4
|
"use strict";
|
|
5
5
|
function _0x425b() {
|
|
6
6
|
const _0x4fe318 = ["224340fQYLJj", "function", "onmessage", "port2", "341XVdnBD", "313767JEBgqL", "950bpstaX", "1354759gUhUbE", "wRKyh", "onclose", "2044SvCTUj", "endpoint", "24msSkHx", "164VuWYGY", "mOWMr", "EkZCC", "addEventListener", "postMessage", "120705iyGzUz", "8878392ivIdKn", "close", "_listen", "3619482FaLQHc", "start", "_endpoint", "kgkem", "bzNYT", "MessageChannel transport error: ", "stringify", "onmessageerror", "HvyCv", "undefined", "Jwyua", "message", "_globalObject", "parse", "authInfo", "thraG", "220pGvxgp", "_port", "EGhzU", "onerror", "data", "MhriV"];
|
|
@@ -811,13 +811,16 @@
|
|
|
811
811
|
};
|
|
812
812
|
this.server = new mcp_js.McpServer(serverInfo || info, options || { capabilities });
|
|
813
813
|
this.server.server.oninitialized = () => {
|
|
814
|
-
|
|
814
|
+
var _a;
|
|
815
|
+
(_a = this.oninitialized) == null ? void 0 : _a.call(this);
|
|
815
816
|
};
|
|
816
817
|
this.server.server.onclose = () => {
|
|
817
|
-
|
|
818
|
+
var _a;
|
|
819
|
+
(_a = this.onclose) == null ? void 0 : _a.call(this);
|
|
818
820
|
};
|
|
819
821
|
this.server.server.onerror = (error) => {
|
|
820
|
-
|
|
822
|
+
var _a;
|
|
823
|
+
(_a = this.onerror) == null ? void 0 : _a.call(this, error);
|
|
821
824
|
};
|
|
822
825
|
this.server.server.setRequestHandler(types_js.SetLevelRequestSchema, async () => {
|
|
823
826
|
return {};
|
|
@@ -1038,10 +1041,12 @@
|
|
|
1038
1041
|
};
|
|
1039
1042
|
this.client = new index_js.Client(clientInfo || info, options || { capabilities });
|
|
1040
1043
|
this.client.onclose = () => {
|
|
1041
|
-
|
|
1044
|
+
var _a;
|
|
1045
|
+
(_a = this.onclose) == null ? void 0 : _a.call(this);
|
|
1042
1046
|
};
|
|
1043
1047
|
this.client.onerror = (error) => {
|
|
1044
|
-
|
|
1048
|
+
var _a;
|
|
1049
|
+
(_a = this.onerror) == null ? void 0 : _a.call(this, error);
|
|
1045
1050
|
};
|
|
1046
1051
|
}
|
|
1047
1052
|
/**
|
|
@@ -1063,7 +1068,7 @@
|
|
|
1063
1068
|
const connectProxy = async () => {
|
|
1064
1069
|
const { transport: transport2, sessionId: sessionId2 } = type === "sse" ? await createSseProxy(proxyOptions) : type === "socket" ? await createSocketProxy(proxyOptions) : await createStreamProxy(proxyOptions);
|
|
1065
1070
|
transport2.onerror = async (error) => {
|
|
1066
|
-
onError
|
|
1071
|
+
onError == null ? void 0 : onError(error);
|
|
1067
1072
|
};
|
|
1068
1073
|
response = { transport: transport2, sessionId: sessionId2 };
|
|
1069
1074
|
};
|
|
@@ -1330,11 +1335,12 @@
|
|
|
1330
1335
|
return () => window.removeEventListener("message", handler);
|
|
1331
1336
|
};
|
|
1332
1337
|
class ExtensionPageServerTransport {
|
|
1333
|
-
constructor(sessionId = null) {
|
|
1338
|
+
constructor(sessionId = null, tabId) {
|
|
1334
1339
|
this._isStarted = false;
|
|
1335
1340
|
this._isClosed = false;
|
|
1336
1341
|
this._lastRegistration = null;
|
|
1337
1342
|
this.sessionId = sessionId || randomUUID();
|
|
1343
|
+
this.tabId = tabId;
|
|
1338
1344
|
this._messageListener1 = onWindowMessage(
|
|
1339
1345
|
"sidepanel-ready-to-page",
|
|
1340
1346
|
() => {
|
|
@@ -1349,15 +1355,16 @@
|
|
|
1349
1355
|
this._messageListener2 = onWindowMessage(
|
|
1350
1356
|
"mcp-client-to-server-to-page",
|
|
1351
1357
|
(data) => {
|
|
1352
|
-
|
|
1358
|
+
var _a, _b, _c;
|
|
1359
|
+
if (data.sessionId !== this.sessionId || data.tabId !== this.tabId) return;
|
|
1353
1360
|
console.log("【Page Svr Transport】 即将处理 mcpMessage", data.mcpMessage);
|
|
1354
1361
|
const mcpMessage = types_js.JSONRPCMessageSchema.parse(data.mcpMessage);
|
|
1355
|
-
this.onmessage
|
|
1356
|
-
const toolName = data.mcpMessage.params
|
|
1362
|
+
(_a = this.onmessage) == null ? void 0 : _a.call(this, mcpMessage);
|
|
1363
|
+
const toolName = (_b = data.mcpMessage.params) == null ? void 0 : _b.name;
|
|
1357
1364
|
if (toolName) {
|
|
1358
1365
|
sendWindowMessage(
|
|
1359
1366
|
"update-page-app-message",
|
|
1360
|
-
{ status: "run", message: data.mcpMessage.params
|
|
1367
|
+
{ status: "run", message: (_c = data.mcpMessage.params) == null ? void 0 : _c.name },
|
|
1361
1368
|
"page->content"
|
|
1362
1369
|
);
|
|
1363
1370
|
}
|
|
@@ -1384,6 +1391,7 @@
|
|
|
1384
1391
|
}
|
|
1385
1392
|
/** 发送消息到 MCP Client */
|
|
1386
1393
|
async send(message, _options) {
|
|
1394
|
+
var _a;
|
|
1387
1395
|
this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法发送消息");
|
|
1388
1396
|
this._throwError(() => this._isClosed, "【Page Svr Transport】 已关闭,无法发送消息");
|
|
1389
1397
|
sendWindowMessage(
|
|
@@ -1394,7 +1402,7 @@
|
|
|
1394
1402
|
},
|
|
1395
1403
|
"page->content"
|
|
1396
1404
|
);
|
|
1397
|
-
if ("result" in message && message.result
|
|
1405
|
+
if ("result" in message && ((_a = message.result) == null ? void 0 : _a.content)) {
|
|
1398
1406
|
sendWindowMessage(
|
|
1399
1407
|
"update-page-app-message",
|
|
1400
1408
|
{ status: "ready", message: "" },
|
|
@@ -1475,4 +1483,4 @@
|
|
|
1475
1483
|
exports2.isSSEClientTransport = isSSEClientTransport;
|
|
1476
1484
|
exports2.isStreamableHTTPClientTransport = isStreamableHTTPClientTransport;
|
|
1477
1485
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
1478
|
-
})
|
|
1486
|
+
});
|
package/dist/webmcp.es.dev.js
CHANGED
|
@@ -820,13 +820,16 @@ class WebMcpServer {
|
|
|
820
820
|
};
|
|
821
821
|
this.server = new McpServer(serverInfo || info, options || { capabilities });
|
|
822
822
|
this.server.server.oninitialized = () => {
|
|
823
|
-
|
|
823
|
+
var _a;
|
|
824
|
+
(_a = this.oninitialized) == null ? void 0 : _a.call(this);
|
|
824
825
|
};
|
|
825
826
|
this.server.server.onclose = () => {
|
|
826
|
-
|
|
827
|
+
var _a;
|
|
828
|
+
(_a = this.onclose) == null ? void 0 : _a.call(this);
|
|
827
829
|
};
|
|
828
830
|
this.server.server.onerror = (error) => {
|
|
829
|
-
|
|
831
|
+
var _a;
|
|
832
|
+
(_a = this.onerror) == null ? void 0 : _a.call(this, error);
|
|
830
833
|
};
|
|
831
834
|
this.server.server.setRequestHandler(SetLevelRequestSchema, async () => {
|
|
832
835
|
return {};
|
|
@@ -1047,10 +1050,12 @@ class WebMcpClient {
|
|
|
1047
1050
|
};
|
|
1048
1051
|
this.client = new Client(clientInfo || info, options || { capabilities });
|
|
1049
1052
|
this.client.onclose = () => {
|
|
1050
|
-
|
|
1053
|
+
var _a;
|
|
1054
|
+
(_a = this.onclose) == null ? void 0 : _a.call(this);
|
|
1051
1055
|
};
|
|
1052
1056
|
this.client.onerror = (error) => {
|
|
1053
|
-
|
|
1057
|
+
var _a;
|
|
1058
|
+
(_a = this.onerror) == null ? void 0 : _a.call(this, error);
|
|
1054
1059
|
};
|
|
1055
1060
|
}
|
|
1056
1061
|
/**
|
|
@@ -1072,7 +1077,7 @@ class WebMcpClient {
|
|
|
1072
1077
|
const connectProxy = async () => {
|
|
1073
1078
|
const { transport: transport2, sessionId: sessionId2 } = type === "sse" ? await createSseProxy(proxyOptions) : type === "socket" ? await createSocketProxy(proxyOptions) : await createStreamProxy(proxyOptions);
|
|
1074
1079
|
transport2.onerror = async (error) => {
|
|
1075
|
-
onError
|
|
1080
|
+
onError == null ? void 0 : onError(error);
|
|
1076
1081
|
};
|
|
1077
1082
|
response = { transport: transport2, sessionId: sessionId2 };
|
|
1078
1083
|
};
|
|
@@ -1339,11 +1344,12 @@ const onWindowMessage = (type, cb, direction) => {
|
|
|
1339
1344
|
return () => window.removeEventListener("message", handler);
|
|
1340
1345
|
};
|
|
1341
1346
|
class ExtensionPageServerTransport {
|
|
1342
|
-
constructor(sessionId = null) {
|
|
1347
|
+
constructor(sessionId = null, tabId) {
|
|
1343
1348
|
this._isStarted = false;
|
|
1344
1349
|
this._isClosed = false;
|
|
1345
1350
|
this._lastRegistration = null;
|
|
1346
1351
|
this.sessionId = sessionId || randomUUID();
|
|
1352
|
+
this.tabId = tabId;
|
|
1347
1353
|
this._messageListener1 = onWindowMessage(
|
|
1348
1354
|
"sidepanel-ready-to-page",
|
|
1349
1355
|
() => {
|
|
@@ -1358,15 +1364,16 @@ class ExtensionPageServerTransport {
|
|
|
1358
1364
|
this._messageListener2 = onWindowMessage(
|
|
1359
1365
|
"mcp-client-to-server-to-page",
|
|
1360
1366
|
(data) => {
|
|
1361
|
-
|
|
1367
|
+
var _a, _b, _c;
|
|
1368
|
+
if (data.sessionId !== this.sessionId || data.tabId !== this.tabId) return;
|
|
1362
1369
|
console.log("【Page Svr Transport】 即将处理 mcpMessage", data.mcpMessage);
|
|
1363
1370
|
const mcpMessage = JSONRPCMessageSchema.parse(data.mcpMessage);
|
|
1364
|
-
this.onmessage
|
|
1365
|
-
const toolName = data.mcpMessage.params
|
|
1371
|
+
(_a = this.onmessage) == null ? void 0 : _a.call(this, mcpMessage);
|
|
1372
|
+
const toolName = (_b = data.mcpMessage.params) == null ? void 0 : _b.name;
|
|
1366
1373
|
if (toolName) {
|
|
1367
1374
|
sendWindowMessage(
|
|
1368
1375
|
"update-page-app-message",
|
|
1369
|
-
{ status: "run", message: data.mcpMessage.params
|
|
1376
|
+
{ status: "run", message: (_c = data.mcpMessage.params) == null ? void 0 : _c.name },
|
|
1370
1377
|
"page->content"
|
|
1371
1378
|
);
|
|
1372
1379
|
}
|
|
@@ -1393,6 +1400,7 @@ class ExtensionPageServerTransport {
|
|
|
1393
1400
|
}
|
|
1394
1401
|
/** 发送消息到 MCP Client */
|
|
1395
1402
|
async send(message, _options) {
|
|
1403
|
+
var _a;
|
|
1396
1404
|
this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法发送消息");
|
|
1397
1405
|
this._throwError(() => this._isClosed, "【Page Svr Transport】 已关闭,无法发送消息");
|
|
1398
1406
|
sendWindowMessage(
|
|
@@ -1403,7 +1411,7 @@ class ExtensionPageServerTransport {
|
|
|
1403
1411
|
},
|
|
1404
1412
|
"page->content"
|
|
1405
1413
|
);
|
|
1406
|
-
if ("result" in message && message.result
|
|
1414
|
+
if ("result" in message && ((_a = message.result) == null ? void 0 : _a.content)) {
|
|
1407
1415
|
sendWindowMessage(
|
|
1408
1416
|
"update-page-app-message",
|
|
1409
1417
|
{ status: "ready", message: "" },
|