@opentiny/next-sdk 0.1.14-alpha.0 → 0.1.15-beta.1
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 +490 -1
- package/agent/type.ts +8 -2
- package/agent/utils/generateReActPrompt.ts +55 -0
- package/agent/utils/parseReActAction.ts +34 -0
- package/dist/WebMcpClient.d.ts +165 -26
- package/dist/WebMcpServer.d.ts +36 -147
- package/dist/agent/AgentModelProvider.d.ts +35 -1
- package/dist/agent/type.d.ts +8 -2
- package/dist/agent/utils/generateReActPrompt.d.ts +9 -0
- package/dist/agent/utils/parseReActAction.d.ts +14 -0
- package/dist/index.es.dev.js +14874 -11156
- package/dist/index.es.js +20957 -18178
- package/dist/index.js +2411 -320
- package/dist/index.umd.dev.js +14899 -11181
- package/dist/index.umd.js +111 -71
- package/dist/{mcpsdk@1.23.0.dev.js → mcpsdk@1.24.3.dev.js} +8866 -7205
- package/dist/{mcpsdk@1.23.0.es.dev.js → mcpsdk@1.24.3.es.dev.js} +8864 -7203
- package/dist/mcpsdk@1.24.3.es.js +16781 -0
- package/dist/mcpsdk@1.24.3.js +43 -0
- package/dist/transport/ExtensionPageServerTransport.d.ts +1 -2
- package/dist/webagent.dev.js +13963 -10522
- package/dist/webagent.es.dev.js +13949 -10508
- package/dist/webagent.es.js +18247 -15690
- package/dist/webagent.js +105 -65
- package/dist/webmcp-full.dev.js +8874 -7257
- package/dist/webmcp-full.es.dev.js +8872 -7255
- package/dist/webmcp-full.es.js +10395 -9241
- package/dist/webmcp-full.js +32 -32
- package/dist/webmcp.dev.js +14 -22
- package/dist/webmcp.es.dev.js +12 -20
- package/dist/webmcp.es.js +172 -179
- package/dist/webmcp.js +1 -1
- package/dist/zod@3.25.76.dev.js +30 -32
- package/dist/zod@3.25.76.es.dev.js +28 -30
- package/dist/zod@3.25.76.es.js +143 -145
- package/dist/zod@3.25.76.js +1 -1
- package/package.json +9 -8
- package/transport/ExtensionPageServerTransport.ts +2 -4
- package/dist/mcpsdk@1.23.0.es.js +0 -15584
- package/dist/mcpsdk@1.23.0.js +0 -43
package/dist/webmcp.es.js
CHANGED
|
@@ -38,8 +38,8 @@ const ie = () => {
|
|
|
38
38
|
return typeof globalThis < "u" ? globalThis : e[r(407)](typeof window, e.kIrDB) ? window : e.llYQe(typeof global, e.kIrDB) ? global : typeof self !== r(398) ? self : e.PZfJg(Function, e[r(399)])();
|
|
39
39
|
}, qe = (r, e, t) => {
|
|
40
40
|
const s = m, n = m, o = {};
|
|
41
|
-
o[s(410)] = n(398), o.dBkaX = function(i,
|
|
42
|
-
return i ===
|
|
41
|
+
o[s(410)] = n(398), o.dBkaX = function(i, l) {
|
|
42
|
+
return i === l;
|
|
43
43
|
}, o[n(393)] = "function";
|
|
44
44
|
const a = o;
|
|
45
45
|
typeof window !== a[n(410)] ? r.postMessage(e, "*", t) : n(428) in r && a.dBkaX(typeof r.postMessage, a[s(393)]) && r.postMessage(e, t);
|
|
@@ -62,11 +62,11 @@ class W {
|
|
|
62
62
|
var n, o;
|
|
63
63
|
const a = e, i = t;
|
|
64
64
|
try {
|
|
65
|
-
const
|
|
66
|
-
(n = this[a(413)]) == null || n.call(this,
|
|
67
|
-
} catch (
|
|
68
|
-
const
|
|
69
|
-
(o = this[i(408)]) == null || o.call(this,
|
|
65
|
+
const l = ne[a(402)](s.data[a(400)]);
|
|
66
|
+
(n = this[a(413)]) == null || n.call(this, l, s[i(409)].extra);
|
|
67
|
+
} catch (l) {
|
|
68
|
+
const c = new Error("MessageChannel failed to parse message: " + l);
|
|
69
|
+
(o = this[i(408)]) == null || o.call(this, c);
|
|
70
70
|
}
|
|
71
71
|
}, this._port[e(396)] = (s) => {
|
|
72
72
|
var n;
|
|
@@ -82,15 +82,15 @@ class W {
|
|
|
82
82
|
} };
|
|
83
83
|
return new Promise((n, o) => {
|
|
84
84
|
var a;
|
|
85
|
-
const i = m,
|
|
85
|
+
const i = m, l = m;
|
|
86
86
|
try {
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const c = {};
|
|
88
|
+
c[i(403)] = t?.[i(403)];
|
|
89
89
|
const u = {};
|
|
90
|
-
u[
|
|
91
|
-
} catch (
|
|
92
|
-
const u =
|
|
93
|
-
(a = this[
|
|
90
|
+
u[l(400)] = e, u.extra = c, this[l(406)] && this[i(406)].postMessage(u), s.lEyuq(n);
|
|
91
|
+
} catch (c) {
|
|
92
|
+
const u = c instanceof Error ? c : new Error(s.YihNw(String, c));
|
|
93
|
+
(a = this[l(408)]) == null || a.call(this, u), o(u);
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
}
|
|
@@ -102,8 +102,8 @@ class W {
|
|
|
102
102
|
}
|
|
103
103
|
class X extends W {
|
|
104
104
|
constructor(e, t = ie()) {
|
|
105
|
-
const s = m, n = m, o = { EkZCC: function(i,
|
|
106
|
-
return i(
|
|
105
|
+
const s = m, n = m, o = { EkZCC: function(i, l, c, u) {
|
|
106
|
+
return i(l, c, u);
|
|
107
107
|
} };
|
|
108
108
|
super(), this[s(391)] = e, this[n(401)] = t;
|
|
109
109
|
const a = new MessageChannel();
|
|
@@ -119,9 +119,9 @@ class K extends W {
|
|
|
119
119
|
} };
|
|
120
120
|
super(), this._endpoint = e, this._globalObject = t, this[s(432)] = new Promise((o) => {
|
|
121
121
|
const a = s, i = s;
|
|
122
|
-
n[a(392)](ke, this[i(401)], (
|
|
123
|
-
const
|
|
124
|
-
|
|
122
|
+
n[a(392)](ke, this[i(401)], (l) => {
|
|
123
|
+
const c = i, u = i;
|
|
124
|
+
l.data && n[c(425)](l.data[u(422)], this[u(391)]) && (this[u(406)] = l.ports[-1 * 4852 + 1 * 1601 + 3251], o());
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
}
|
|
@@ -153,9 +153,9 @@ const Pe = async (r, e, t) => {
|
|
|
153
153
|
var s;
|
|
154
154
|
const n = g, o = g, a = {};
|
|
155
155
|
a[n(345)] = "tools/list", a.rqstG = "tools/call", a.WqUnk = "resources/list", a[n(329)] = o(358), a[n(365)] = n(335), a.ookoz = "resources/unsubscribe", a[n(385)] = n(340), a.VTIWq = "prompts/list", a.SkoRK = n(376), a.QUtUV = n(388), a.XtowM = o(332);
|
|
156
|
-
const i = a, { id:
|
|
156
|
+
const i = a, { id: l, method: c, params: u } = t;
|
|
157
157
|
let d = {};
|
|
158
|
-
switch (
|
|
158
|
+
switch (c) {
|
|
159
159
|
case i[o(345)]:
|
|
160
160
|
d = await e.listTools(u);
|
|
161
161
|
break;
|
|
@@ -190,45 +190,45 @@ const Pe = async (r, e, t) => {
|
|
|
190
190
|
d = await e.complete(u);
|
|
191
191
|
break;
|
|
192
192
|
case n(390):
|
|
193
|
-
d = await e[n(336)](u
|
|
193
|
+
d = await e[n(336)](u?.level);
|
|
194
194
|
break;
|
|
195
195
|
}
|
|
196
196
|
const h = {};
|
|
197
|
-
h[n(361)] = d, h[n(394)] = i[n(364)], h.id =
|
|
197
|
+
h[n(361)] = d, h[n(394)] = i[n(364)], h.id = l, await ((s = r?.transport) == null ? void 0 : s[n(392)](h));
|
|
198
198
|
}, Me = async (r, e, t) => {
|
|
199
199
|
var s;
|
|
200
200
|
const n = g, o = g, a = {};
|
|
201
201
|
a.jQBBS = "sampling/createMessage", a.EZqgC = "elicitation/create", a[n(370)] = o(376), a.aVeaL = o(332);
|
|
202
|
-
const i = a, { id:
|
|
202
|
+
const i = a, { id: l, method: c, params: u } = t;
|
|
203
203
|
let d = {};
|
|
204
|
-
switch (
|
|
204
|
+
switch (c) {
|
|
205
205
|
case n(368):
|
|
206
206
|
const f = {};
|
|
207
|
-
f.method =
|
|
207
|
+
f.method = c, f[o(367)] = u, d = await e.request(f, fe);
|
|
208
208
|
break;
|
|
209
209
|
case i[o(391)]:
|
|
210
210
|
const x = {};
|
|
211
|
-
x.method =
|
|
211
|
+
x.method = c, x[o(367)] = u, d = await e[o(381)](x, he);
|
|
212
212
|
break;
|
|
213
213
|
case i.EZqgC:
|
|
214
214
|
const p = {};
|
|
215
|
-
p.method =
|
|
215
|
+
p.method = c, p.params = u, d = await e.request(p, de);
|
|
216
216
|
break;
|
|
217
217
|
case i[o(370)]:
|
|
218
218
|
const _ = {};
|
|
219
|
-
_.method =
|
|
219
|
+
_.method = c, d = await e[o(381)](_, ue);
|
|
220
220
|
break;
|
|
221
221
|
}
|
|
222
222
|
const h = {};
|
|
223
|
-
return h[o(361)] = d, h.jsonrpc = i[o(387)], h.id =
|
|
223
|
+
return h[o(361)] = d, h.jsonrpc = i[o(387)], h.id = l, await ((s = r?.[n(371)]) == null ? void 0 : s.send(h)), d;
|
|
224
224
|
}, He = (r, e) => {
|
|
225
225
|
const t = g, s = { gXsjT: function(o, a) {
|
|
226
226
|
return o === a;
|
|
227
|
-
}, oegpC: t(351), lZOUC: function(o, a, i,
|
|
228
|
-
return o(a, i,
|
|
227
|
+
}, oegpC: t(351), lZOUC: function(o, a, i, l) {
|
|
228
|
+
return o(a, i, l);
|
|
229
229
|
}, ifIKG: "2.0" }, n = r._onrequest;
|
|
230
230
|
r._onrequest = async (o, a) => {
|
|
231
|
-
var i,
|
|
231
|
+
var i, l, c, u, d;
|
|
232
232
|
const h = t, f = t, { id: x, method: p } = o;
|
|
233
233
|
try {
|
|
234
234
|
s[h(333)](p, s.oegpC) ? await n[h(386)](r, o, a) : await s.lZOUC(Pe, r, e, o);
|
|
@@ -239,10 +239,10 @@ const Pe = async (r, e, t) => {
|
|
|
239
239
|
const w = {};
|
|
240
240
|
w.code = v, w.message = I, w.data = L;
|
|
241
241
|
const S = {};
|
|
242
|
-
S.error = w, S[h(394)] = s[f(331)], S.id = x, await ((i = r
|
|
243
|
-
} else (
|
|
242
|
+
S.error = w, S[h(394)] = s[f(331)], S.id = x, await ((i = r?.transport) == null ? void 0 : i.send(S));
|
|
243
|
+
} else (c = (l = r?.[f(371)]) == null ? void 0 : l.onerror) == null || c.call(l, _);
|
|
244
244
|
} catch (w) {
|
|
245
|
-
(d = (u = r
|
|
245
|
+
(d = (u = r?.[h(371)]) == null ? void 0 : u.onerror) == null || d.call(u, w);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
};
|
|
@@ -253,18 +253,18 @@ const Pe = async (r, e, t) => {
|
|
|
253
253
|
}, n[t(398)] = t(353), n.hzhyg = "notifications/cancelled";
|
|
254
254
|
const o = n;
|
|
255
255
|
r._onnotification = async (a) => {
|
|
256
|
-
var i,
|
|
257
|
-
const
|
|
258
|
-
if (o[
|
|
256
|
+
var i, l;
|
|
257
|
+
const c = t, u = s, { method: d, params: h } = a;
|
|
258
|
+
if (o[c(363)](d, o[u(398)]) && (o[c(363)](d, o.hzhyg) || h?.forward)) try {
|
|
259
259
|
await e.notification(a);
|
|
260
260
|
} catch (f) {
|
|
261
|
-
(
|
|
261
|
+
(l = (i = r?.transport) == null ? void 0 : i.onerror) == null || l.call(i, f);
|
|
262
262
|
}
|
|
263
263
|
};
|
|
264
264
|
}, Ee = (r, e) => async (t) => {
|
|
265
265
|
var s, n, o, a, i;
|
|
266
|
-
const
|
|
267
|
-
u.SEmWX =
|
|
266
|
+
const l = g, c = g, u = {};
|
|
267
|
+
u.SEmWX = l(332);
|
|
268
268
|
const d = u;
|
|
269
269
|
try {
|
|
270
270
|
return await Me(r, e, t);
|
|
@@ -273,88 +273,88 @@ const Pe = async (r, e, t) => {
|
|
|
273
273
|
try {
|
|
274
274
|
if (f) {
|
|
275
275
|
const _ = {};
|
|
276
|
-
_[
|
|
276
|
+
_[c(377)] = f, _.message = x, _.data = p;
|
|
277
277
|
const v = {};
|
|
278
|
-
v[
|
|
279
|
-
} else (o = (n = r
|
|
278
|
+
v[c(348)] = _, v.jsonrpc = d[l(338)], v.id = t.id, await ((s = r?.transport) == null ? void 0 : s[c(392)](v));
|
|
279
|
+
} else (o = (n = r?.transport) == null ? void 0 : n[c(339)]) == null || o.call(n, h);
|
|
280
280
|
} catch (_) {
|
|
281
|
-
(i = (a = r
|
|
281
|
+
(i = (a = r?.[l(371)]) == null ? void 0 : a[c(339)]) == null || i.call(a, _);
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
}, Oe = (r, e) => async (t) => {
|
|
285
285
|
var s, n, o;
|
|
286
|
-
const a = g, i = g,
|
|
287
|
-
|
|
286
|
+
const a = g, i = g, l = {};
|
|
287
|
+
l.dtUgZ = function(h, f) {
|
|
288
288
|
return h !== f;
|
|
289
|
-
},
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
289
|
+
}, l.jgCIb = a(353), l.uUjKY = "2.0";
|
|
290
|
+
const c = l, { method: u, params: d } = t;
|
|
291
|
+
if (c.dtUgZ(u, c.jgCIb) && (u !== a(400) || d?.forward)) try {
|
|
292
292
|
const h = { ...t };
|
|
293
|
-
h[a(394)] =
|
|
293
|
+
h[a(394)] = c[i(352)], await ((s = e?.[a(371)]) == null ? void 0 : s[a(392)](h));
|
|
294
294
|
} catch (h) {
|
|
295
|
-
(o = (n = r
|
|
295
|
+
(o = (n = r?.[a(371)]) == null ? void 0 : n[i(339)]) == null || o.call(n, h);
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
298
|
function g(r, e) {
|
|
299
299
|
const t = D();
|
|
300
300
|
return g = function(s, n) {
|
|
301
|
-
return s = s - (
|
|
301
|
+
return s = s - (-1017 + -1439 * -1 + -97), t[s];
|
|
302
302
|
}, g(r, e);
|
|
303
303
|
}
|
|
304
304
|
const Fe = (r, e) => async (t) => {
|
|
305
|
-
var s, n, o, a, i,
|
|
306
|
-
const
|
|
307
|
-
d[
|
|
305
|
+
var s, n, o, a, i, l;
|
|
306
|
+
const c = g, u = g, d = {};
|
|
307
|
+
d[c(401)] = u(332);
|
|
308
308
|
const h = d;
|
|
309
309
|
try {
|
|
310
|
-
await ((s = e
|
|
310
|
+
await ((s = e?.transport) == null ? void 0 : s.send(t));
|
|
311
311
|
} catch (f) {
|
|
312
312
|
const { code: x, message: p, data: _ } = f;
|
|
313
313
|
try {
|
|
314
314
|
if (x) {
|
|
315
315
|
const v = {};
|
|
316
|
-
v.code = x, v[
|
|
316
|
+
v.code = x, v[c(399)] = p, v.data = _;
|
|
317
317
|
const I = {};
|
|
318
|
-
I[
|
|
319
|
-
} else (a = (o = r
|
|
318
|
+
I[c(348)] = v, I[c(394)] = h.OhJjz, I.id = t.id, await ((n = r?.[c(371)]) == null ? void 0 : n.send(I));
|
|
319
|
+
} else (a = (o = r?.transport) == null ? void 0 : o[u(339)]) == null || a.call(o, f);
|
|
320
320
|
} catch (v) {
|
|
321
|
-
(
|
|
321
|
+
(l = (i = r?.transport) == null ? void 0 : i.onerror) == null || l.call(i, v);
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
}, Q = () => {
|
|
325
|
-
const r = g, e = g, t = { vnkqu: function(
|
|
326
|
-
return
|
|
327
|
-
}, wxDWr: function(
|
|
328
|
-
return
|
|
329
|
-
}, GdkkV: function(
|
|
330
|
-
return
|
|
331
|
-
} }, s = [], n = (
|
|
325
|
+
const r = g, e = g, t = { vnkqu: function(c, u) {
|
|
326
|
+
return c !== u;
|
|
327
|
+
}, wxDWr: function(c, u) {
|
|
328
|
+
return c(u);
|
|
329
|
+
}, GdkkV: function(c, u) {
|
|
330
|
+
return c === u;
|
|
331
|
+
} }, s = [], n = (c, u) => {
|
|
332
332
|
const d = g, h = g;
|
|
333
333
|
if (u) {
|
|
334
334
|
const f = [];
|
|
335
335
|
for (const x of s)
|
|
336
336
|
try {
|
|
337
|
-
f.push(x(
|
|
337
|
+
f.push(x(c, u));
|
|
338
338
|
} catch {
|
|
339
339
|
}
|
|
340
340
|
for (const x of f)
|
|
341
341
|
if (t[d(379)](x, null)) return x;
|
|
342
342
|
} else for (const f of s)
|
|
343
343
|
try {
|
|
344
|
-
t[h(343)](f,
|
|
344
|
+
t[h(343)](f, c);
|
|
345
345
|
} catch {
|
|
346
346
|
}
|
|
347
|
-
}, o = (
|
|
347
|
+
}, o = (c) => {
|
|
348
348
|
const u = g;
|
|
349
|
-
t[u(384)](typeof
|
|
350
|
-
}, a = (
|
|
351
|
-
const u = s.indexOf(
|
|
352
|
-
u !== -1 && s.splice(u, 1 * -6854 +
|
|
349
|
+
t[u(384)](typeof c, u(369)) && !s.includes(c) && s.push(c);
|
|
350
|
+
}, a = (c) => {
|
|
351
|
+
const u = s.indexOf(c);
|
|
352
|
+
u !== -1 && s.splice(u, 1 * -6854 + -264 + 7119);
|
|
353
353
|
}, i = () => {
|
|
354
|
-
const
|
|
355
|
-
s[
|
|
356
|
-
},
|
|
357
|
-
return
|
|
354
|
+
const c = g;
|
|
355
|
+
s[c(374)] = 7102 * 1 + 5522 + -526 * 24;
|
|
356
|
+
}, l = {};
|
|
357
|
+
return l[r(346)] = n, l[e(330)] = o, l.removeListener = a, l[r(359)] = i, l;
|
|
358
358
|
}, je = (r) => {
|
|
359
359
|
const e = g, t = g, s = { xwPeb: function(n) {
|
|
360
360
|
return n();
|
|
@@ -381,19 +381,19 @@ function D() {
|
|
|
381
381
|
}, D();
|
|
382
382
|
}
|
|
383
383
|
const Ne = (r, { beforeInit: e, afterInit: t } = {}) => {
|
|
384
|
-
const s = g, n = g, o = { tqDZP: function(i,
|
|
385
|
-
return i ===
|
|
386
|
-
}, cjSoZ: "function", iQqcJ: s(378), Zybtx: function(i,
|
|
387
|
-
return i(
|
|
384
|
+
const s = g, n = g, o = { tqDZP: function(i, l) {
|
|
385
|
+
return i === l;
|
|
386
|
+
}, cjSoZ: "function", iQqcJ: s(378), Zybtx: function(i, l) {
|
|
387
|
+
return i(l);
|
|
388
388
|
}, ElOQH: function(i) {
|
|
389
389
|
return i();
|
|
390
390
|
} }, a = new Map(r._notificationHandlers);
|
|
391
391
|
r[s(393)][s(402)](), r._notificationHandlers[s(402)](), o.tqDZP(typeof e, o[s(380)]) && e(), o[s(362)](r._onresponse.name, o[s(360)]) && (r[n(349)] = r._onresponse), o[s(347)](je, r), r.addResponseListener((i) => {
|
|
392
|
-
const
|
|
393
|
-
r.originalOnResponse[
|
|
392
|
+
const l = n;
|
|
393
|
+
r.originalOnResponse[l(386)](r, i);
|
|
394
394
|
}), o.tqDZP(typeof t, o[n(380)]) && o[s(397)](t), r[n(327)]((i) => {
|
|
395
|
-
const { method:
|
|
396
|
-
o.tqDZP(typeof
|
|
395
|
+
const { method: l } = i, c = a.get(l);
|
|
396
|
+
o.tqDZP(typeof c, o.cjSoZ) && c(i);
|
|
397
397
|
});
|
|
398
398
|
}, Ve = q, ze = q;
|
|
399
399
|
(function(r, e) {
|
|
@@ -429,7 +429,7 @@ const We = () => {
|
|
|
429
429
|
}, t[e(394)] = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
|
|
430
430
|
const s = t;
|
|
431
431
|
return s.suJHI(typeof crypto, "object") && crypto.randomUUID ? crypto[e(391)]() : s.dHTfU.replace(/[xy]/g, (n) => {
|
|
432
|
-
const o = r, a = r, i = s[o(392)](crypto[o(384)](new Uint8Array(
|
|
432
|
+
const o = r, a = r, i = s[o(392)](crypto[o(384)](new Uint8Array(8663 + 2 * -4331))[741 * 2 + -1385 * -2 + 4252 * -1], 15);
|
|
433
433
|
return (s.suJHI(n, "x") ? i : s[a(386)](i, -4377 + 4 * 1095) | 5079 + 461 * -11).toString(9449 + 4 * -461 + -7589);
|
|
434
434
|
});
|
|
435
435
|
}, De = (r) => {
|
|
@@ -449,29 +449,29 @@ const R = k;
|
|
|
449
449
|
}
|
|
450
450
|
})(B, 1472653 * 1 + -2 * -897917 + -2275789);
|
|
451
451
|
const Ae = (r, e) => {
|
|
452
|
-
const t = k, s = k, n = { FyYHt: function(
|
|
453
|
-
return c
|
|
454
|
-
}, Fxtoq: function(
|
|
455
|
-
return c
|
|
452
|
+
const t = k, s = k, n = { FyYHt: function(l, c, u) {
|
|
453
|
+
return l(c, u);
|
|
454
|
+
}, Fxtoq: function(l, c, u) {
|
|
455
|
+
return l(c, u);
|
|
456
456
|
} };
|
|
457
457
|
He(r, e), Ue(r, e);
|
|
458
458
|
const o = Ee(e, r), a = n[t(510)](Fe, e, r), i = n[s(549)](Oe, e, r);
|
|
459
459
|
e[s(537)](o), e[t(519)](a), e.addNotificationListener(i), r[s(556)] = () => {
|
|
460
|
-
const
|
|
461
|
-
e.removeRequestListener(o), e[
|
|
460
|
+
const l = s;
|
|
461
|
+
e.removeRequestListener(o), e[l(530)](a), e[l(529)](i);
|
|
462
462
|
};
|
|
463
463
|
}, $ = (r, e, t) => {
|
|
464
|
-
const s = k, n = { pMiva: function(i,
|
|
465
|
-
return i instanceof
|
|
466
|
-
}, TeTEy: s(546), fyZbd: function(i,
|
|
467
|
-
return i(
|
|
464
|
+
const s = k, n = { pMiva: function(i, l) {
|
|
465
|
+
return i instanceof l;
|
|
466
|
+
}, TeTEy: s(546), fyZbd: function(i, l, c) {
|
|
467
|
+
return i(l, c);
|
|
468
468
|
} }, o = () => {
|
|
469
469
|
var i;
|
|
470
|
-
const
|
|
471
|
-
n.pMiva(t, j) && ((i = t._eventSource) == null || i.addEventListener(n[
|
|
472
|
-
var
|
|
473
|
-
const u =
|
|
474
|
-
(
|
|
470
|
+
const l = s;
|
|
471
|
+
n.pMiva(t, j) && ((i = t._eventSource) == null || i.addEventListener(n[l(547)], () => {
|
|
472
|
+
var c;
|
|
473
|
+
const u = l;
|
|
474
|
+
(c = t[u(509)]) == null || c[u(546)]();
|
|
475
475
|
})), Ae(r, e);
|
|
476
476
|
}, a = {};
|
|
477
477
|
a.afterInit = o, n.fyZbd(Ne, e, a);
|
|
@@ -482,17 +482,17 @@ const Ae = (r, e) => {
|
|
|
482
482
|
o[t(528)] = e;
|
|
483
483
|
const a = o, i = {};
|
|
484
484
|
i[t(528)] = e;
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
const h = t, f = s, x = new Headers(
|
|
485
|
+
const l = {};
|
|
486
|
+
l[s(558)] = i, l[t(534)] = t(524);
|
|
487
|
+
const c = { requestInit: l, eventSourceInit: { async fetch(u, d) {
|
|
488
|
+
const h = t, f = s, x = new Headers(d?.[h(558)] || {});
|
|
489
489
|
Object.entries(a)[f(498)](([_, v]) => {
|
|
490
490
|
x[f(527)](_, v);
|
|
491
491
|
});
|
|
492
492
|
const p = { ...d };
|
|
493
493
|
return p[f(558)] = x, n.OfssH(fetch, u, p);
|
|
494
494
|
}, withCredentials: !0 } };
|
|
495
|
-
return r && (
|
|
495
|
+
return r && (c.requestInit[t(558)].Authorization = t(533) + r, a.Authorization = "Bearer " + r), c;
|
|
496
496
|
}, ce = (r, e = M[R(517)]()) => {
|
|
497
497
|
const t = R, s = R, n = {};
|
|
498
498
|
n.nwQhY = "include";
|
|
@@ -500,29 +500,29 @@ const Ae = (r, e) => {
|
|
|
500
500
|
a["stream-session-id"] = e;
|
|
501
501
|
const i = {};
|
|
502
502
|
i.headers = a, i.credentials = o[t(520)];
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
const
|
|
506
|
-
return r && (
|
|
503
|
+
const l = {};
|
|
504
|
+
l[t(544)] = i;
|
|
505
|
+
const c = l;
|
|
506
|
+
return r && (c.requestInit.headers[s(552)] = s(533) + r), c;
|
|
507
507
|
}, ee = async (r, e, t) => {
|
|
508
508
|
const s = R, n = R, o = { CFfFC: function(i) {
|
|
509
509
|
return i();
|
|
510
|
-
}, egwVO: function(i,
|
|
511
|
-
return i(
|
|
510
|
+
}, egwVO: function(i, l, c, u) {
|
|
511
|
+
return i(l, c, u);
|
|
512
512
|
} }, a = o.CFfFC(t);
|
|
513
513
|
try {
|
|
514
514
|
return await r[s(538)](a), a;
|
|
515
515
|
} catch (i) {
|
|
516
516
|
if (i instanceof Le) {
|
|
517
|
-
const
|
|
518
|
-
return await a[n(505)](
|
|
517
|
+
const l = await e();
|
|
518
|
+
return await a[n(505)](l), await o[s(525)](ee, r, e, t);
|
|
519
519
|
} else throw i;
|
|
520
520
|
}
|
|
521
521
|
};
|
|
522
522
|
function k(r, e) {
|
|
523
523
|
const t = B();
|
|
524
524
|
return k = function(s, n) {
|
|
525
|
-
return s = s -
|
|
525
|
+
return s = s - 498, t[s];
|
|
526
526
|
}, k(r, e);
|
|
527
527
|
}
|
|
528
528
|
const le = (r, e) => {
|
|
@@ -541,12 +541,12 @@ const le = (r, e) => {
|
|
|
541
541
|
return b();
|
|
542
542
|
}, WIVYl: function(b, T, P, E) {
|
|
543
543
|
return b(T, P, E);
|
|
544
|
-
}, jniGY: "sessionId" }, { client: n, url: o, token: a, sessionId: i, authProvider:
|
|
545
|
-
h.authProvider =
|
|
544
|
+
}, jniGY: "sessionId" }, { client: n, url: o, token: a, sessionId: i, authProvider: l, requestInit: c, eventSourceInit: u, waitForOAuthCode: d } = r, h = {};
|
|
545
|
+
h.authProvider = l, h.requestInit = c, h.eventSourceInit = u;
|
|
546
546
|
const f = h, x = i || M.randomUUID(), p = s[e(506)](ae, a, x);
|
|
547
|
-
if (
|
|
548
|
-
const b = { ...p.requestInit, ...
|
|
549
|
-
b.headers = { ...p[e(544)].headers, ...
|
|
547
|
+
if (c) {
|
|
548
|
+
const b = { ...p.requestInit, ...c };
|
|
549
|
+
b.headers = { ...p[e(544)].headers, ...c.headers }, f.requestInit = b;
|
|
550
550
|
} else f[t(544)] = p.requestInit;
|
|
551
551
|
if (u) {
|
|
552
552
|
const b = { ...p[e(559)], ...u };
|
|
@@ -562,8 +562,8 @@ const le = (r, e) => {
|
|
|
562
562
|
w.capabilities = I;
|
|
563
563
|
const S = new F(L, w), U = () => new j(new URL(o), f);
|
|
564
564
|
let C = s[t(504)](U);
|
|
565
|
-
if (
|
|
566
|
-
const b = s[e(506)](le,
|
|
565
|
+
if (l) {
|
|
566
|
+
const b = s[e(506)](le, l, d);
|
|
567
567
|
C = await s[t(513)](ee, S, b, U);
|
|
568
568
|
} else await S[e(538)](C);
|
|
569
569
|
s[t(513)]($, S, n, C), C[t(557)] = C[t(542)].searchParams[t(532)](s.jniGY);
|
|
@@ -585,12 +585,12 @@ const Ze = async (r) => {
|
|
|
585
585
|
return b(T, P, E);
|
|
586
586
|
}, FQMAh: function(b, T, P, E) {
|
|
587
587
|
return b(T, P, E);
|
|
588
|
-
} }, { client: n, url: o, token: a, sessionId: i, authProvider:
|
|
589
|
-
h.authProvider =
|
|
588
|
+
} }, { client: n, url: o, token: a, sessionId: i, authProvider: l, requestInit: c, reconnectionOptions: u, waitForOAuthCode: d } = r, h = {};
|
|
589
|
+
h.authProvider = l, h.requestInit = c, h.reconnectionOptions = u;
|
|
590
590
|
const f = h, x = i || M.randomUUID(), p = ce(a, x);
|
|
591
|
-
if (
|
|
592
|
-
const b = { ...p.requestInit, ...
|
|
593
|
-
b.headers = { ...p.requestInit.headers, ...
|
|
591
|
+
if (c) {
|
|
592
|
+
const b = { ...p.requestInit, ...c };
|
|
593
|
+
b.headers = { ...p.requestInit.headers, ...c.headers }, f[e(544)] = b;
|
|
594
594
|
} else f.requestInit = p.requestInit;
|
|
595
595
|
const _ = {};
|
|
596
596
|
_.listChanged = !0;
|
|
@@ -602,8 +602,8 @@ const Ze = async (r) => {
|
|
|
602
602
|
w.capabilities = I;
|
|
603
603
|
const S = new F(L, w), U = () => new G(new URL(o), f);
|
|
604
604
|
let C = s[e(503)](U);
|
|
605
|
-
if (
|
|
606
|
-
const b = s[e(501)](le,
|
|
605
|
+
if (l) {
|
|
606
|
+
const b = s[e(501)](le, l, d);
|
|
607
607
|
C = await s.zDnjZ(ee, S, b, U);
|
|
608
608
|
} else await S.connect(C);
|
|
609
609
|
s.FQMAh($, S, n, C);
|
|
@@ -612,11 +612,11 @@ const Ze = async (r) => {
|
|
|
612
612
|
}, Ye = async (r) => {
|
|
613
613
|
const e = R, t = R, s = { QgzDy: e(540), jkaVB: function(v, I, L, w) {
|
|
614
614
|
return v(I, L, w);
|
|
615
|
-
} }, { client: n, url: o, token: a, sessionId: i } = r,
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
const u =
|
|
615
|
+
} }, { client: n, url: o, token: a, sessionId: i } = r, l = {};
|
|
616
|
+
l.listChanged = !0;
|
|
617
|
+
const c = {};
|
|
618
|
+
c[e(550)] = l, c[e(515)] = {}, c[t(511)] = {};
|
|
619
|
+
const u = c, d = {};
|
|
620
620
|
d.name = s[t(548)], d[t(555)] = t(526);
|
|
621
621
|
const h = {};
|
|
622
622
|
h.capabilities = u;
|
|
@@ -652,30 +652,30 @@ class rt {
|
|
|
652
652
|
constructor(e) {
|
|
653
653
|
const t = y, s = y;
|
|
654
654
|
this._callBackPromise = {};
|
|
655
|
-
const { clientMetadata: n, state: o, redirectCallback: a, getAuthCodeByState: i, waitForOAuthCode:
|
|
656
|
-
this[t(428)] = n, this[t(454)] = n[t(445)][0], this._state = o || Je(), this._redirectCallback = a || this.redirectCallbackFunction, this._getAuthCodeByState = i || this.getAuthCodeByStateFunction, this[s(426)] =
|
|
655
|
+
const { clientMetadata: n, state: o, redirectCallback: a, getAuthCodeByState: i, waitForOAuthCode: l } = e;
|
|
656
|
+
this[t(428)] = n, this[t(454)] = n[t(445)][0], this._state = o || Je(), this._redirectCallback = a || this.redirectCallbackFunction, this._getAuthCodeByState = i || this.getAuthCodeByStateFunction, this[s(426)] = l || this.waitForOAuthCodeFunction();
|
|
657
657
|
}
|
|
658
658
|
async redirectCallbackFunction(e) {
|
|
659
659
|
var t, s, n, o, a, i;
|
|
660
|
-
const
|
|
660
|
+
const l = y, c = y, u = { qITTp: function(x, p, _) {
|
|
661
661
|
return x(p, _);
|
|
662
|
-
}, qcFPW:
|
|
663
|
-
!d.ok && ((s = (t = this._callBackPromise).reject) == null || s.call(t,
|
|
664
|
-
const h = await this._getAuthCodeByState(this[
|
|
662
|
+
}, qcFPW: l(452) }, d = await u.qITTp(fetch, e, { method: u[l(453)] });
|
|
663
|
+
!d.ok && ((s = (t = this._callBackPromise).reject) == null || s.call(t, c(446) + d.statusText));
|
|
664
|
+
const h = await this._getAuthCodeByState(this[c(454)], this[l(442)]);
|
|
665
665
|
if (!h.ok) {
|
|
666
|
-
(o = (n = this[
|
|
666
|
+
(o = (n = this[l(433)]).reject) == null || o.call(n, "Failed to fetch auth code: " + h.statusText);
|
|
667
667
|
return;
|
|
668
668
|
}
|
|
669
|
-
const f = await h[
|
|
670
|
-
(i = (a = this[
|
|
669
|
+
const f = await h[l(431)]();
|
|
670
|
+
(i = (a = this[c(433)])[l(456)]) == null || i.call(a, f[l(432)]);
|
|
671
671
|
}
|
|
672
672
|
async getAuthCodeByStateFunction(e, t) {
|
|
673
673
|
const s = y, n = y, o = {};
|
|
674
674
|
o.tuSmb = s(429);
|
|
675
675
|
const a = o, i = {};
|
|
676
676
|
i[s(460)] = a.tuSmb;
|
|
677
|
-
const
|
|
678
|
-
return
|
|
677
|
+
const l = {};
|
|
678
|
+
return l[n(441)] = t, fetch(e, { method: "POST", headers: i, body: new URLSearchParams(l) });
|
|
679
679
|
}
|
|
680
680
|
waitForOAuthCodeFunction() {
|
|
681
681
|
const e = y, t = this[e(433)];
|
|
@@ -754,14 +754,11 @@ class ot {
|
|
|
754
754
|
logging: {}
|
|
755
755
|
};
|
|
756
756
|
this.server = new oe(e || s, t || { capabilities: n }), this.server.server.oninitialized = () => {
|
|
757
|
-
|
|
758
|
-
(o = this.oninitialized) == null || o.call(this);
|
|
757
|
+
this.oninitialized?.();
|
|
759
758
|
}, this.server.server.onclose = () => {
|
|
760
|
-
|
|
761
|
-
(o = this.onclose) == null || o.call(this);
|
|
759
|
+
this.onclose?.();
|
|
762
760
|
}, this.server.server.onerror = (o) => {
|
|
763
|
-
|
|
764
|
-
(a = this.onerror) == null || a.call(this, o);
|
|
761
|
+
this.onerror?.(o);
|
|
765
762
|
}, this.server.server.setRequestHandler(te, async () => ({}));
|
|
766
763
|
}
|
|
767
764
|
/**
|
|
@@ -955,11 +952,9 @@ class ut {
|
|
|
955
952
|
elicitation: {}
|
|
956
953
|
};
|
|
957
954
|
this.client = new F(e || s, t || { capabilities: n }), this.client.onclose = () => {
|
|
958
|
-
|
|
959
|
-
(o = this.onclose) == null || o.call(this);
|
|
955
|
+
this.onclose?.();
|
|
960
956
|
}, this.client.onerror = (o) => {
|
|
961
|
-
|
|
962
|
-
(a = this.onerror) == null || a.call(this, o);
|
|
957
|
+
this.onerror?.(o);
|
|
963
958
|
};
|
|
964
959
|
}
|
|
965
960
|
/**
|
|
@@ -975,21 +970,21 @@ class ut {
|
|
|
975
970
|
return await (async () => {
|
|
976
971
|
const { transport: f, sessionId: x } = o === "sse" ? await Be(u) : o === "socket" ? await Ye(u) : await Ze(u);
|
|
977
972
|
f.onerror = async (p) => {
|
|
978
|
-
i
|
|
973
|
+
i?.(p);
|
|
979
974
|
}, d = { transport: f, sessionId: x };
|
|
980
975
|
})(), d;
|
|
981
976
|
}
|
|
982
|
-
const
|
|
983
|
-
let
|
|
984
|
-
if (o === "channel" && (
|
|
977
|
+
const l = new URL(t);
|
|
978
|
+
let c;
|
|
979
|
+
if (o === "channel" && (c = new X(t), await this.client.connect(c)), o === "sse") {
|
|
985
980
|
const u = ae(s, n);
|
|
986
|
-
|
|
981
|
+
c = new j(l, u), await this.client.connect(c);
|
|
987
982
|
}
|
|
988
|
-
if (o === "socket" && (
|
|
983
|
+
if (o === "socket" && (c = new re(new URL(`${t}?sessionId=${n}&token=${s}`)), c.sessionId = n, await this.client.connect(c)), typeof c > "u") {
|
|
989
984
|
const u = ce(s, n);
|
|
990
|
-
|
|
985
|
+
c = new G(l, u), await this.client.connect(c);
|
|
991
986
|
}
|
|
992
|
-
return this.transport =
|
|
987
|
+
return this.transport = c, { transport: this.transport, sessionId: this.transport.sessionId };
|
|
993
988
|
}
|
|
994
989
|
/**
|
|
995
990
|
* Closes the connection.
|
|
@@ -1202,25 +1197,24 @@ const dt = (r, e) => new j(r, e), ht = (r, e) => new G(r, e), ft = (r, e) => new
|
|
|
1202
1197
|
return window.addEventListener("message", s), () => window.removeEventListener("message", s);
|
|
1203
1198
|
};
|
|
1204
1199
|
class vt {
|
|
1205
|
-
constructor(e = null
|
|
1206
|
-
this._isStarted = !1, this._isClosed = !1, this._lastRegistration = null, this.sessionId = e || Qe(), this.
|
|
1200
|
+
constructor(e = null) {
|
|
1201
|
+
this._isStarted = !1, this._isClosed = !1, this._lastRegistration = null, this.sessionId = e || Qe(), this._messageListener1 = se(
|
|
1207
1202
|
"sidepanel-ready-to-page",
|
|
1208
1203
|
() => {
|
|
1209
|
-
this._lastRegistration && this._isStarted && this.notifyRegistration(this._lastRegistration).catch((
|
|
1210
|
-
console.error("【Page Svr Transport】 notifyRegistration失败:",
|
|
1204
|
+
this._lastRegistration && this._isStarted && this.notifyRegistration(this._lastRegistration).catch((t) => {
|
|
1205
|
+
console.error("【Page Svr Transport】 notifyRegistration失败:", t);
|
|
1211
1206
|
});
|
|
1212
1207
|
},
|
|
1213
1208
|
"content->page"
|
|
1214
1209
|
), this._messageListener2 = se(
|
|
1215
1210
|
"mcp-client-to-server-to-page",
|
|
1216
|
-
(
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
(a = this.onmessage) == null || a.call(this, n), ((i = s.mcpMessage.params) == null ? void 0 : i.name) && V(
|
|
1211
|
+
(t) => {
|
|
1212
|
+
if (t.sessionId !== this.sessionId) return;
|
|
1213
|
+
console.log("【Page Svr Transport】 即将处理 mcpMessage", t.mcpMessage);
|
|
1214
|
+
const s = ne.parse(t.mcpMessage);
|
|
1215
|
+
this.onmessage?.(s), t.mcpMessage.params?.name && V(
|
|
1222
1216
|
"update-page-app-message",
|
|
1223
|
-
{ status: "run", message:
|
|
1217
|
+
{ status: "run", message: t.mcpMessage.params?.name },
|
|
1224
1218
|
"page->content"
|
|
1225
1219
|
);
|
|
1226
1220
|
},
|
|
@@ -1243,7 +1237,6 @@ class vt {
|
|
|
1243
1237
|
}
|
|
1244
1238
|
/** 发送消息到 MCP Client */
|
|
1245
1239
|
async send(e, t) {
|
|
1246
|
-
var s;
|
|
1247
1240
|
this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法发送消息"), this._throwError(() => this._isClosed, "【Page Svr Transport】 已关闭,无法发送消息"), V(
|
|
1248
1241
|
"mcp-server-to-client-from-page",
|
|
1249
1242
|
{
|
|
@@ -1251,7 +1244,7 @@ class vt {
|
|
|
1251
1244
|
mcpMessage: e
|
|
1252
1245
|
},
|
|
1253
1246
|
"page->content"
|
|
1254
|
-
), "result" in e &&
|
|
1247
|
+
), "result" in e && e.result?.content && V(
|
|
1255
1248
|
"update-page-app-message",
|
|
1256
1249
|
{ status: "ready", message: "" },
|
|
1257
1250
|
"page->content"
|