@opentiny/next-sdk 0.1.8 → 0.1.10
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/WebMcpClient.ts +9 -37
- package/agent/AgentModelProvider.ts +56 -43
- package/agent/type.ts +2 -2
- package/agent/utils/getAISDKTools.ts +2 -2
- package/dist/WebMcpClient.d.ts +1 -4
- package/dist/WebMcpClient.js +9 -33
- package/dist/agent/AgentModelProvider.d.ts +21 -16
- package/dist/agent/AgentModelProvider.js +72 -51
- package/dist/agent/type.d.ts +2 -2
- package/dist/agent/utils/getAISDKTools.d.ts +2 -2
- package/dist/agent/utils/getAISDKTools.js +2 -2
- package/dist/index.es.dev.js +56 -57
- package/dist/index.es.js +4076 -4070
- package/dist/index.umd.dev.js +56 -57
- package/dist/index.umd.js +27 -27
- package/dist/remoter/createRemoter.js +1 -1
- package/dist/webagent.dev.js +48 -28
- package/dist/webagent.es.dev.js +48 -28
- package/dist/webagent.es.js +1617 -1602
- package/dist/webagent.js +21 -21
- package/dist/webmcp-full.dev.js +930 -987
- package/dist/webmcp-full.es.dev.js +930 -987
- package/dist/webmcp-full.es.js +1388 -1397
- package/dist/webmcp-full.js +7 -7
- package/dist/webmcp.dev.js +8 -29
- package/dist/webmcp.es.dev.js +8 -29
- package/dist/webmcp.es.js +432 -441
- package/dist/webmcp.js +1 -1
- package/package.json +1 -1
- package/remoter/createRemoter.ts +1 -1
- package/runtime.html +21 -80
package/dist/webmcp.dev.js
CHANGED
|
@@ -1061,25 +1061,14 @@
|
|
|
1061
1061
|
await this.client.connect(this.transport);
|
|
1062
1062
|
return { transport: this.transport, sessionId: this.transport.sessionId };
|
|
1063
1063
|
}
|
|
1064
|
-
const { url, token, sessionId,
|
|
1064
|
+
const { url, token, sessionId, type, agent, onError } = options;
|
|
1065
1065
|
if (agent === true) {
|
|
1066
|
-
const proxyOptions = { client: this.client, url, token, sessionId
|
|
1067
|
-
let reconnect = false;
|
|
1066
|
+
const proxyOptions = { client: this.client, url, token, sessionId };
|
|
1068
1067
|
let response;
|
|
1069
1068
|
const connectProxy = async () => {
|
|
1070
1069
|
const { transport: transport2, sessionId: sessionId2 } = type === "sse" ? await createSseProxy(proxyOptions) : type === "socket" ? await createSocketProxy(proxyOptions) : await createStreamProxy(proxyOptions);
|
|
1071
1070
|
transport2.onerror = async (error) => {
|
|
1072
1071
|
onError == null ? void 0 : onError(error);
|
|
1073
|
-
if (error.message === "Unauthorized" && !reconnect) {
|
|
1074
|
-
if (typeof onUnauthorized === "function") {
|
|
1075
|
-
await onUnauthorized(connectProxy);
|
|
1076
|
-
} else {
|
|
1077
|
-
reconnect = true;
|
|
1078
|
-
await connectProxy();
|
|
1079
|
-
reconnect = false;
|
|
1080
|
-
await (onReconnect == null ? void 0 : onReconnect());
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
1072
|
};
|
|
1084
1073
|
response = { transport: transport2, sessionId: sessionId2 };
|
|
1085
1074
|
};
|
|
@@ -1093,14 +1082,9 @@
|
|
|
1093
1082
|
await this.client.connect(transport);
|
|
1094
1083
|
}
|
|
1095
1084
|
if (type === "sse") {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
} else {
|
|
1100
|
-
const opts = sseOptions(token, sessionId);
|
|
1101
|
-
transport = new sse_js.SSEClientTransport(endpoint, opts);
|
|
1102
|
-
await this.client.connect(transport);
|
|
1103
|
-
}
|
|
1085
|
+
const opts = sseOptions(token, sessionId);
|
|
1086
|
+
transport = new sse_js.SSEClientTransport(endpoint, opts);
|
|
1087
|
+
await this.client.connect(transport);
|
|
1104
1088
|
}
|
|
1105
1089
|
if (type === "socket") {
|
|
1106
1090
|
transport = new websocket_js.WebSocketClientTransport(new URL(`${url}?sessionId=${sessionId}&token=${token}`));
|
|
@@ -1108,14 +1092,9 @@
|
|
|
1108
1092
|
await this.client.connect(transport);
|
|
1109
1093
|
}
|
|
1110
1094
|
if (typeof transport === "undefined") {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
} else {
|
|
1115
|
-
const opts = streamOptions(token, sessionId);
|
|
1116
|
-
transport = new streamableHttp_js.StreamableHTTPClientTransport(endpoint, opts);
|
|
1117
|
-
await this.client.connect(transport);
|
|
1118
|
-
}
|
|
1095
|
+
const opts = streamOptions(token, sessionId);
|
|
1096
|
+
transport = new streamableHttp_js.StreamableHTTPClientTransport(endpoint, opts);
|
|
1097
|
+
await this.client.connect(transport);
|
|
1119
1098
|
}
|
|
1120
1099
|
this.transport = transport;
|
|
1121
1100
|
return { transport: this.transport, sessionId: this.transport.sessionId };
|
package/dist/webmcp.es.dev.js
CHANGED
|
@@ -1070,25 +1070,14 @@ class WebMcpClient {
|
|
|
1070
1070
|
await this.client.connect(this.transport);
|
|
1071
1071
|
return { transport: this.transport, sessionId: this.transport.sessionId };
|
|
1072
1072
|
}
|
|
1073
|
-
const { url, token, sessionId,
|
|
1073
|
+
const { url, token, sessionId, type, agent, onError } = options;
|
|
1074
1074
|
if (agent === true) {
|
|
1075
|
-
const proxyOptions = { client: this.client, url, token, sessionId
|
|
1076
|
-
let reconnect = false;
|
|
1075
|
+
const proxyOptions = { client: this.client, url, token, sessionId };
|
|
1077
1076
|
let response;
|
|
1078
1077
|
const connectProxy = async () => {
|
|
1079
1078
|
const { transport: transport2, sessionId: sessionId2 } = type === "sse" ? await createSseProxy(proxyOptions) : type === "socket" ? await createSocketProxy(proxyOptions) : await createStreamProxy(proxyOptions);
|
|
1080
1079
|
transport2.onerror = async (error) => {
|
|
1081
1080
|
onError == null ? void 0 : onError(error);
|
|
1082
|
-
if (error.message === "Unauthorized" && !reconnect) {
|
|
1083
|
-
if (typeof onUnauthorized === "function") {
|
|
1084
|
-
await onUnauthorized(connectProxy);
|
|
1085
|
-
} else {
|
|
1086
|
-
reconnect = true;
|
|
1087
|
-
await connectProxy();
|
|
1088
|
-
reconnect = false;
|
|
1089
|
-
await (onReconnect == null ? void 0 : onReconnect());
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
1081
|
};
|
|
1093
1082
|
response = { transport: transport2, sessionId: sessionId2 };
|
|
1094
1083
|
};
|
|
@@ -1102,14 +1091,9 @@ class WebMcpClient {
|
|
|
1102
1091
|
await this.client.connect(transport);
|
|
1103
1092
|
}
|
|
1104
1093
|
if (type === "sse") {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
} else {
|
|
1109
|
-
const opts = sseOptions(token, sessionId);
|
|
1110
|
-
transport = new SSEClientTransport(endpoint, opts);
|
|
1111
|
-
await this.client.connect(transport);
|
|
1112
|
-
}
|
|
1094
|
+
const opts = sseOptions(token, sessionId);
|
|
1095
|
+
transport = new SSEClientTransport(endpoint, opts);
|
|
1096
|
+
await this.client.connect(transport);
|
|
1113
1097
|
}
|
|
1114
1098
|
if (type === "socket") {
|
|
1115
1099
|
transport = new WebSocketClientTransport(new URL(`${url}?sessionId=${sessionId}&token=${token}`));
|
|
@@ -1117,14 +1101,9 @@ class WebMcpClient {
|
|
|
1117
1101
|
await this.client.connect(transport);
|
|
1118
1102
|
}
|
|
1119
1103
|
if (typeof transport === "undefined") {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
} else {
|
|
1124
|
-
const opts = streamOptions(token, sessionId);
|
|
1125
|
-
transport = new StreamableHTTPClientTransport(endpoint, opts);
|
|
1126
|
-
await this.client.connect(transport);
|
|
1127
|
-
}
|
|
1104
|
+
const opts = streamOptions(token, sessionId);
|
|
1105
|
+
transport = new StreamableHTTPClientTransport(endpoint, opts);
|
|
1106
|
+
await this.client.connect(transport);
|
|
1128
1107
|
}
|
|
1129
1108
|
this.transport = transport;
|
|
1130
1109
|
return { transport: this.transport, sessionId: this.transport.sessionId };
|