@opentiny/next-sdk 0.2.10 → 0.3.0-alpha.0

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.
@@ -1369,17 +1369,6 @@
1369
1369
  this._isClosed = false;
1370
1370
  this._lastRegistration = null;
1371
1371
  this.sessionId = sessionId || randomUUID();
1372
- this._messageListener1 = onWindowMessage(
1373
- "sidepanel-ready-to-page",
1374
- () => {
1375
- if (this._lastRegistration && this._isStarted) {
1376
- this.notifyRegistration(this._lastRegistration).catch((error) => {
1377
- console.error("【Page Svr Transport】 notifyRegistration失败:", error);
1378
- });
1379
- }
1380
- },
1381
- "content->page"
1382
- );
1383
1372
  this._messageListener2 = onWindowMessage(
1384
1373
  "mcp-client-to-server-to-page",
1385
1374
  (data) => {
@@ -1462,7 +1451,6 @@
1462
1451
  async close() {
1463
1452
  if (this._isClosed) return;
1464
1453
  try {
1465
- this._messageListener1 && this._messageListener1();
1466
1454
  this._messageListener2 && this._messageListener2();
1467
1455
  this._isClosed = true;
1468
1456
  this._isStarted = false;
@@ -1378,17 +1378,6 @@ class ExtensionPageServerTransport {
1378
1378
  this._isClosed = false;
1379
1379
  this._lastRegistration = null;
1380
1380
  this.sessionId = sessionId || randomUUID();
1381
- this._messageListener1 = onWindowMessage(
1382
- "sidepanel-ready-to-page",
1383
- () => {
1384
- if (this._lastRegistration && this._isStarted) {
1385
- this.notifyRegistration(this._lastRegistration).catch((error) => {
1386
- console.error("【Page Svr Transport】 notifyRegistration失败:", error);
1387
- });
1388
- }
1389
- },
1390
- "content->page"
1391
- );
1392
1381
  this._messageListener2 = onWindowMessage(
1393
1382
  "mcp-client-to-server-to-page",
1394
1383
  (data) => {
@@ -1471,7 +1460,6 @@ class ExtensionPageServerTransport {
1471
1460
  async close() {
1472
1461
  if (this._isClosed) return;
1473
1462
  try {
1474
- this._messageListener1 && this._messageListener1();
1475
1463
  this._messageListener2 && this._messageListener2();
1476
1464
  this._isClosed = true;
1477
1465
  this._isStarted = false;
package/dist/webmcp.es.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { default as bt } from "ajv";
2
- import { JSONRPCMessageSchema as oe, EmptyResultSchema as he, ElicitResultSchema as fe, CreateMessageResultSchema as pe, ListRootsResultSchema as xe, SetLevelRequestSchema as se, SubscribeRequestSchema as _e, UnsubscribeRequestSchema as ve, ListResourcesRequestSchema as me, RootsListChangedNotificationSchema as ge, CallToolResultSchema as we, ElicitRequestSchema as be, CreateMessageRequestSchema as ye, ListRootsRequestSchema as Ie, ToolListChangedNotificationSchema as Ce, PromptListChangedNotificationSchema as Re, ResourceListChangedNotificationSchema as Se, ResourceUpdatedNotificationSchema as Le, LoggingMessageNotificationSchema as Pe } from "@modelcontextprotocol/sdk/types.js";
2
+ import { JSONRPCMessageSchema as re, EmptyResultSchema as de, ElicitResultSchema as he, CreateMessageResultSchema as fe, ListRootsResultSchema as pe, SetLevelRequestSchema as se, SubscribeRequestSchema as xe, UnsubscribeRequestSchema as _e, ListResourcesRequestSchema as ve, RootsListChangedNotificationSchema as me, CallToolResultSchema as ge, ElicitRequestSchema as we, CreateMessageRequestSchema as be, ListRootsRequestSchema as ye, ToolListChangedNotificationSchema as Ie, PromptListChangedNotificationSchema as Ce, ResourceListChangedNotificationSchema as Re, ResourceUpdatedNotificationSchema as Se, LoggingMessageNotificationSchema as Le } from "@modelcontextprotocol/sdk/types.js";
3
3
  import { Client as A } from "@modelcontextprotocol/sdk/client/index.js";
4
4
  import { SSEClientTransport as V } from "@modelcontextprotocol/sdk/client/sse.js";
5
5
  import { StreamableHTTPClientTransport as Q } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
6
- import { WebSocketClientTransport as ie } from "@modelcontextprotocol/sdk/client/websocket.js";
7
- import { UnauthorizedError as ke } from "@modelcontextprotocol/sdk/client/auth.js";
8
- import { McpServer as ae } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { WebSocketClientTransport as oe } from "@modelcontextprotocol/sdk/client/websocket.js";
7
+ import { UnauthorizedError as Pe } from "@modelcontextprotocol/sdk/client/auth.js";
8
+ import { McpServer as ie } from "@modelcontextprotocol/sdk/server/mcp.js";
9
9
  import { ResourceTemplate as It } from "@modelcontextprotocol/sdk/server/mcp.js";
10
10
  import { z as Rt } from "zod";
11
11
  import { UriTemplate as Lt } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
@@ -22,7 +22,7 @@ const H = I;
22
22
  s.push(s.shift());
23
23
  }
24
24
  })(B, -118057 + 3521 * -35 + -2099 * -233);
25
- const ce = () => {
25
+ const ae = () => {
26
26
  const r = I, e = I, t = {};
27
27
  t[r(420)] = "3|0|2|1|4", t.vQYJZ = function(a, i) {
28
28
  return a !== i;
@@ -50,7 +50,7 @@ const ce = () => {
50
50
  }
51
51
  break;
52
52
  }
53
- }, qe = (r, e, t) => {
53
+ }, ke = (r, e, t) => {
54
54
  const n = I, s = I, o = {};
55
55
  o.eOzBp = function(i, c) {
56
56
  return i !== c;
@@ -59,7 +59,7 @@ const ce = () => {
59
59
  }, o[n(421)] = "function";
60
60
  const a = o;
61
61
  a[s(389)](typeof window, a.ooaJk) ? r[s(423)](e, "*", t) : n(423) in r && a.pTvSc(typeof r[s(423)], a[n(421)]) && r.postMessage(e, t);
62
- }, Te = (r, e) => {
62
+ }, qe = (r, e) => {
63
63
  const t = I, n = I, s = {};
64
64
  s.nTCfA = function(a, i) {
65
65
  return a in i;
@@ -81,7 +81,7 @@ class D {
81
81
  var s, o;
82
82
  const a = e;
83
83
  try {
84
- const i = oe.parse(n.data.message);
84
+ const i = re.parse(n.data.message);
85
85
  (s = this.onmessage) == null || s.call(this, i, n[a(412)][a(428)]);
86
86
  } catch (i) {
87
87
  const c = new Error("MessageChannel failed to parse message: " + i);
@@ -122,17 +122,17 @@ class D {
122
122
  }
123
123
  }
124
124
  class $ extends D {
125
- constructor(e, t = ce()) {
125
+ constructor(e, t = ae()) {
126
126
  const n = H, s = { lSpBh: function(a, i, c, l) {
127
127
  return a(i, c, l);
128
128
  } };
129
129
  super(), this._endpoint = e, this._globalObject = t;
130
130
  const o = new MessageChannel();
131
- this._port = o[n(410)], s[n(418)](qe, this._globalObject, { endpoint: this[n(397)] }, [o[n(429)]]);
131
+ this._port = o[n(410)], s[n(418)](ke, this._globalObject, { endpoint: this[n(397)] }, [o[n(429)]]);
132
132
  }
133
133
  }
134
134
  class ee extends D {
135
- constructor(e, t = ce()) {
135
+ constructor(e, t = ae()) {
136
136
  const n = H, s = H, o = { HITdC: function(a, i) {
137
137
  return a === i;
138
138
  }, QdDxM: function(a) {
@@ -146,7 +146,7 @@ class ee extends D {
146
146
  }, pXlad: function(l) {
147
147
  return o.QdDxM(l);
148
148
  } };
149
- o[i(427)](Te, this._globalObject, (l) => {
149
+ o[i(427)](qe, this._globalObject, (l) => {
150
150
  const u = i, d = i;
151
151
  l[u(412)] && c.XlglK(l.data[d(396)], this._endpoint) && (this[u(422)] = l[d(430)][-3036 + -1518 * -2], c.pXlad(a));
152
152
  });
@@ -168,7 +168,7 @@ function I(r, e) {
168
168
  return n = n - (17227 + 1 * -16844), t[n];
169
169
  }, I(r, e);
170
170
  }
171
- const He = () => {
171
+ const Te = () => {
172
172
  const r = new MessageChannel();
173
173
  return [new D(r.port1), new D(r.port2)];
174
174
  };
@@ -182,7 +182,7 @@ const He = () => {
182
182
  s.push(s.shift());
183
183
  }
184
184
  })(W, -411935 * 1 + 228107 + 208149 * 2);
185
- const Me = async (r, e, t) => {
185
+ const He = async (r, e, t) => {
186
186
  var n;
187
187
  const s = x, o = x, a = {};
188
188
  a.VRyiJ = "tools/list", a.VkPYu = "tools/call", a[s(475)] = s(411), a.SoCaE = "resources/templates/list", a[o(484)] = "resources/read", a[s(461)] = "prompts/get", a.srIIC = o(477), a[o(436)] = o(478), a[o(442)] = s(437), a.dEmVs = s(465);
@@ -228,7 +228,7 @@ const Me = async (r, e, t) => {
228
228
  }
229
229
  const h = {};
230
230
  h.result = d, h.jsonrpc = i[o(472)], h.id = c, await ((n = r?.[o(488)]) == null ? void 0 : n[s(460)](h));
231
- }, Ue = async (r, e, t) => {
231
+ }, Me = async (r, e, t) => {
232
232
  var n;
233
233
  const s = x, o = x, a = {};
234
234
  a[s(487)] = o(462), a.ypHTC = "ping", a.fPExS = s(465);
@@ -237,19 +237,19 @@ const Me = async (r, e, t) => {
237
237
  switch (l) {
238
238
  case "roots/list":
239
239
  const f = {};
240
- f.method = l, f[o(446)] = u, d = await e[s(469)](f, xe);
240
+ f.method = l, f[o(446)] = u, d = await e[s(469)](f, pe);
241
241
  break;
242
242
  case "sampling/createMessage":
243
243
  const _ = {};
244
- _[s(481)] = l, _[s(446)] = u, d = await e.request(_, pe);
244
+ _[s(481)] = l, _[s(446)] = u, d = await e.request(_, fe);
245
245
  break;
246
246
  case i[s(487)]:
247
247
  const p = {};
248
- p.method = l, p[o(446)] = u, d = await e.request(p, fe);
248
+ p.method = l, p[o(446)] = u, d = await e.request(p, he);
249
249
  break;
250
250
  case i.ypHTC:
251
251
  const v = {};
252
- v.method = l, d = await e.request(v, he);
252
+ v.method = l, d = await e.request(v, de);
253
253
  break;
254
254
  }
255
255
  const h = {};
@@ -261,7 +261,7 @@ function x(r, e) {
261
261
  return n = n - (-8023 + 4 * -2344 + -17809 * -1), t[n];
262
262
  }, x(r, e);
263
263
  }
264
- const Ne = (r, e) => {
264
+ const Ue = (r, e) => {
265
265
  const t = x, n = x, s = { vYlhn: function(a, i) {
266
266
  return a === i;
267
267
  }, DhPFX: t(470), NYVNC: function(a, i, c, l) {
@@ -271,7 +271,7 @@ const Ne = (r, e) => {
271
271
  var c, l, u, d, h;
272
272
  const f = n, _ = t, { id: p, method: v } = a;
273
273
  try {
274
- s[f(451)](v, s.DhPFX) ? await o.call(r, a, i) : await s[_(474)](Me, r, e, a);
274
+ s[f(451)](v, s.DhPFX) ? await o.call(r, a, i) : await s[_(474)](He, r, e, a);
275
275
  } catch (m) {
276
276
  const { code: b, message: C, data: P } = m;
277
277
  try {
@@ -286,7 +286,7 @@ const Ne = (r, e) => {
286
286
  }
287
287
  }
288
288
  };
289
- }, Fe = (r, e) => {
289
+ }, Ne = (r, e) => {
290
290
  const t = x, n = x, s = {};
291
291
  s[t(476)] = t(439), s[t(431)] = function(a, i) {
292
292
  return a !== i;
@@ -301,13 +301,13 @@ const Ne = (r, e) => {
301
301
  (c = (i = r?.[l(488)]) == null ? void 0 : i[l(480)]) == null || c.call(i, f);
302
302
  }
303
303
  };
304
- }, Ee = (r, e) => async (t) => {
304
+ }, Fe = (r, e) => async (t) => {
305
305
  var n, s, o, a, i;
306
306
  const c = x, l = x, u = { TJhyV: function(d, h, f, _) {
307
307
  return d(h, f, _);
308
308
  }, MMNTY: c(465) };
309
309
  try {
310
- return await u.TJhyV(Ue, r, e, t);
310
+ return await u.TJhyV(Me, r, e, t);
311
311
  } catch (d) {
312
312
  const { code: h, message: f, data: _ } = d;
313
313
  try {
@@ -321,7 +321,7 @@ const Ne = (r, e) => {
321
321
  (i = (a = r?.[c(488)]) == null ? void 0 : a.onerror) == null || i.call(a, p);
322
322
  }
323
323
  }
324
- }, Oe = (r, e) => async (t) => {
324
+ }, Ee = (r, e) => async (t) => {
325
325
  var n, s, o;
326
326
  const a = x, i = x, c = {};
327
327
  c.xmcLM = function(h, f) {
@@ -341,7 +341,7 @@ function W() {
341
341
  return r;
342
342
  }, W();
343
343
  }
344
- const Ae = (r, e) => async (t) => {
344
+ const Oe = (r, e) => async (t) => {
345
345
  var n, s, o, a, i, c;
346
346
  const l = x, u = x, d = {};
347
347
  d.kSvAZ = l(465);
@@ -393,7 +393,7 @@ const Ae = (r, e) => async (t) => {
393
393
  t[c(430)] = -505 * 7 + 1322 + 2213;
394
394
  }, i = {};
395
395
  return i.handleListener = n, i[r(447)] = s, i.removeListener = o, i.clearListener = a, i;
396
- }, Ve = (r) => {
396
+ }, Ae = (r) => {
397
397
  const e = x, t = x, n = { UlqiY: function(s) {
398
398
  return s();
399
399
  }, jsmFN: function(s) {
@@ -411,7 +411,7 @@ const Ae = (r, e) => async (t) => {
411
411
  const { handleListener: s, addListener: o, removeListener: a, clearListener: i } = n.jsmFN(G);
412
412
  r.fallbackNotificationHandler = s, r[e(444)] = o, r.removeNotificationListener = a, r[t(426)] = i;
413
413
  }
414
- }, je = (r, { beforeInit: e, afterInit: t } = {}) => {
414
+ }, Ve = (r, { beforeInit: e, afterInit: t } = {}) => {
415
415
  const n = x, s = x, o = { HucXo: function(i, c) {
416
416
  return i === c;
417
417
  }, HicFO: n(468), JMaxV: function(i) {
@@ -423,14 +423,14 @@ const Ae = (r, e) => async (t) => {
423
423
  }, yCyFn: function(i) {
424
424
  return i();
425
425
  } }, a = new Map(r._notificationHandlers);
426
- r[n(454)].clear(), r._notificationHandlers.clear(), o.HucXo(typeof e, o.HicFO) && o[n(435)](e), o[n(467)](r[n(449)][s(428)], n(449)) && (r[s(413)] = r[s(449)]), o.DclXr(Ve, r), r[s(438)]((i) => {
426
+ r[n(454)].clear(), r._notificationHandlers.clear(), o.HucXo(typeof e, o.HicFO) && o[n(435)](e), o[n(467)](r[n(449)][s(428)], n(449)) && (r[s(413)] = r[s(449)]), o.DclXr(Ae, r), r[s(438)]((i) => {
427
427
  const c = n;
428
428
  r.originalOnResponse[c(440)](r, i);
429
429
  }), o[n(429)](typeof t, o.HicFO) && o[s(425)](t), r[s(444)]((i) => {
430
430
  const c = s, { method: l } = i, u = a[c(483)](l);
431
431
  o[c(467)](typeof u, "function") && u(i);
432
432
  });
433
- }, De = k;
433
+ }, je = k;
434
434
  (function(r, e) {
435
435
  const t = k, n = k, s = r();
436
436
  for (; ; )
@@ -441,7 +441,7 @@ const Ae = (r, e) => async (t) => {
441
441
  s.push(s.shift());
442
442
  }
443
443
  })(X, 995159 + -6 * -266138 + -1619768);
444
- const Be = () => {
444
+ const De = () => {
445
445
  const r = k, e = k, t = {};
446
446
  t.svuxn = function(s, o) {
447
447
  return s & o;
@@ -455,11 +455,11 @@ const Be = () => {
455
455
  const o = r, a = n.svuxn(crypto.getRandomValues(new Uint8Array(-3798 + 8571 * -1 + 12370))[0], -8324 + 8339 * 1);
456
456
  return (n[o(225)](s, "x") ? a : n[o(209)](a, -12998 + -1 * -13001) | 813 * 10 + -3707 + 883 * -5).toString(-1 * -1851 + 6493 + -8328);
457
457
  });
458
- }, We = (r) => {
458
+ }, Be = (r) => {
459
459
  const e = k, t = k, n = new Uint8Array(r);
460
460
  return crypto[e(221)](n), Array[t(218)](n, (s) => s[t(226)](11424 + 4 * -2852).padStart(8950 + 2237 * -4, "0"))[e(213)]("");
461
461
  }, M = {};
462
- M[De(211)] = Be, M.randomBytes = We;
462
+ M[je(211)] = De, M.randomBytes = Be;
463
463
  function k(r, e) {
464
464
  const t = X();
465
465
  return k = function(n, s) {
@@ -489,7 +489,7 @@ const S = q, O = q;
489
489
  s.push(s.shift());
490
490
  }
491
491
  })(Y, -4 * 308317 + 753182 * 2 + 658196);
492
- const Xe = (r, e) => {
492
+ const We = (r, e) => {
493
493
  const t = q, n = q, s = { olCWX: function(c, l, u) {
494
494
  return c(l, u);
495
495
  }, sfXDX: function(c, l, u) {
@@ -497,8 +497,8 @@ const Xe = (r, e) => {
497
497
  }, ksWFu: function(c, l, u) {
498
498
  return c(l, u);
499
499
  } };
500
- s[t(283)](Ne, r, e), Fe(r, e);
501
- const o = s[n(283)](Ee, e, r), a = s[n(294)](Ae, e, r), i = s[t(277)](Oe, e, r);
500
+ s[t(283)](Ue, r, e), Ne(r, e);
501
+ const o = s[n(283)](Fe, e, r), a = s[n(294)](Oe, e, r), i = s[t(277)](Ee, e, r);
502
502
  e.addRequestListener(o), e.addResponseListener(a), e[n(287)](i), r.onclose = () => {
503
503
  const c = t, l = n;
504
504
  e[c(247)](o), e.removeResponseListener(a), e[l(252)](i);
@@ -513,10 +513,10 @@ const Xe = (r, e) => {
513
513
  n.QhPqi(t, V) && ((a = t._eventSource) == null || a.addEventListener(n.AIICR, () => {
514
514
  var i;
515
515
  (i = t[q(295)]) == null || i.close();
516
- })), n.Qalmc(Xe, r, e);
516
+ })), n.Qalmc(We, r, e);
517
517
  }, o = {};
518
- o.afterInit = s, n.Qalmc(je, e, o);
519
- }, le = (r, e = M[S(299)]()) => {
518
+ o.afterInit = s, n.Qalmc(Ve, e, o);
519
+ }, ce = (r, e = M[S(299)]()) => {
520
520
  const t = S, n = S, s = { RVabx: function(u, d, h) {
521
521
  return u(d, h);
522
522
  }, crCTs: "include" }, o = {};
@@ -534,7 +534,7 @@ const Xe = (r, e) => {
534
534
  return p.headers = _, s[f(279)](fetch, u, p);
535
535
  }, withCredentials: !0 } };
536
536
  return r && (l[t(280)].headers.Authorization = "Bearer " + r, a.Authorization = n(256) + r), l;
537
- }, ue = (r, e = M[S(299)]()) => {
537
+ }, le = (r, e = M[S(299)]()) => {
538
538
  const t = O, n = S, s = {};
539
539
  s[t(271)] = "include";
540
540
  const o = s, a = {};
@@ -554,12 +554,12 @@ const Xe = (r, e) => {
554
554
  try {
555
555
  return await r[s(260)](a), a;
556
556
  } catch (i) {
557
- if (o[n(275)](i, ke)) {
557
+ if (o[n(275)](i, Pe)) {
558
558
  const c = await e();
559
559
  return await a[n(257)](c), await ne(r, e, t);
560
560
  } else throw i;
561
561
  }
562
- }, de = (r, e) => {
562
+ }, ue = (r, e) => {
563
563
  const t = O, n = O, s = {};
564
564
  s[t(267)] = function(a, i) {
565
565
  return a in i;
@@ -577,7 +577,7 @@ function Y() {
577
577
  return r;
578
578
  }, Y();
579
579
  }
580
- const Ye = async (r) => {
580
+ const Xe = async (r) => {
581
581
  const e = O, t = S, n = { GKDjq: function(g, N, F) {
582
582
  return g(N, F);
583
583
  }, JzpWy: e(281), mcbiU: "1.0.0", CfBXU: function(g) {
@@ -586,7 +586,7 @@ const Ye = async (r) => {
586
586
  return g(N, F, K);
587
587
  }, KkViY: "sessionId" }, { client: s, url: o, token: a, sessionId: i, authProvider: c, requestInit: l, eventSourceInit: u, waitForOAuthCode: d } = r, h = {};
588
588
  h[t(305)] = c, h.requestInit = l, h.eventSourceInit = u;
589
- const f = h, _ = i || M[t(299)](), p = n[e(289)](le, a, _);
589
+ const f = h, _ = i || M[t(299)](), p = n[e(289)](ce, a, _);
590
590
  if (l) {
591
591
  const g = { ...p.requestInit, ...l };
592
592
  g[t(268)] = { ...p[t(280)][e(268)], ...l.headers }, f.requestInit = g;
@@ -606,13 +606,13 @@ const Ye = async (r) => {
606
606
  const w = new A(C, P), L = () => new V(new URL(o), f);
607
607
  let y = n[e(282)](L);
608
608
  if (c) {
609
- const g = de(c, d);
609
+ const g = ue(c, d);
610
610
  y = await n[e(263)](ne, w, g, L);
611
611
  } else await w.connect(y);
612
612
  te(w, s, y), y.sessionId = y[t(274)].searchParams[e(297)](n.KkViY);
613
613
  const U = {};
614
614
  return U.transport = y, U.sessionId = y[t(286)], U;
615
- }, ze = async (r) => {
615
+ }, Ye = async (r) => {
616
616
  const e = O, t = S, n = { wfHUn: function(g, N, F) {
617
617
  return g(N, F);
618
618
  }, tUMle: "mcp-stream-proxy-client", omKPe: e(248), rSiEq: function(g) {
@@ -621,7 +621,7 @@ const Ye = async (r) => {
621
621
  return g(N, F, K);
622
622
  } }, { client: s, url: o, token: a, sessionId: i, authProvider: c, requestInit: l, reconnectionOptions: u, waitForOAuthCode: d } = r, h = {};
623
623
  h.authProvider = c, h.requestInit = l, h.reconnectionOptions = u;
624
- const f = h, _ = i || M.randomUUID(), p = n[t(272)](ue, a, _);
624
+ const f = h, _ = i || M.randomUUID(), p = n[t(272)](le, a, _);
625
625
  if (l) {
626
626
  const g = { ...p[e(280)], ...l };
627
627
  g.headers = { ...p.requestInit[e(268)], ...l.headers }, f.requestInit = g;
@@ -637,13 +637,13 @@ const Ye = async (r) => {
637
637
  const w = new A(C, P), L = () => new Q(new URL(o), f);
638
638
  let y = n.rSiEq(L);
639
639
  if (c) {
640
- const g = n[e(272)](de, c, d);
640
+ const g = n[e(272)](ue, c, d);
641
641
  y = await n[e(296)](ne, w, g, L);
642
642
  } else await w[e(260)](y);
643
643
  n.PdsSn(te, w, s, y);
644
644
  const U = {};
645
645
  return U.transport = y, U[t(286)] = y[t(286)], U;
646
- }, Ze = async (r) => {
646
+ }, ze = async (r) => {
647
647
  const e = S, t = S, n = { eZwNI: function(m, b, C, P) {
648
648
  return m(b, C, P);
649
649
  } }, { client: s, url: o, token: a, sessionId: i } = r, c = {};
@@ -654,7 +654,7 @@ const Ye = async (r) => {
654
654
  d.name = "mcp-socket-proxy-client", d.version = t(248);
655
655
  const h = {};
656
656
  h[t(251)] = u;
657
- const f = new A(d, h), _ = i || M[t(299)](), p = new ie(new URL(o + "?sessionId=" + _ + t(265) + a));
657
+ const f = new A(d, h), _ = i || M[t(299)](), p = new oe(new URL(o + "?sessionId=" + _ + t(265) + a));
658
658
  await f.connect(p), n[e(259)](te, f, s, p);
659
659
  const v = {};
660
660
  return v.transport = p, v[t(286)] = _, v;
@@ -675,7 +675,7 @@ function R(r, e) {
675
675
  return n = n - (-4158 * 1 + -2 * 581 + -1 * -5510), t[n];
676
676
  }, R(r, e);
677
677
  }
678
- const Je = () => M.randomBytes(-8746 + -382 * -23);
678
+ const Ze = () => M.randomBytes(-8746 + -382 * -23);
679
679
  class ot {
680
680
  constructor(e) {
681
681
  const t = R, n = R, s = { HbwOh: function(u) {
@@ -683,7 +683,7 @@ class ot {
683
683
  } };
684
684
  this._callBackPromise = {};
685
685
  const { clientMetadata: o, state: a, redirectCallback: i, getAuthCodeByState: c, waitForOAuthCode: l } = e;
686
- this._clientMetadata = o, this[t(206)] = o.redirect_uris[-10 * 629 + 1 * 7646 + -1356], this[n(197)] = a || s.HbwOh(Je), this._redirectCallback = i || this[n(202)], this[n(195)] = c || this[t(191)], this.waitForOAuthCode = l || this.waitForOAuthCodeFunction();
686
+ this._clientMetadata = o, this[t(206)] = o.redirect_uris[-10 * 629 + 1 * 7646 + -1356], this[n(197)] = a || s.HbwOh(Ze), this._redirectCallback = i || this[n(202)], this[n(195)] = c || this[t(191)], this.waitForOAuthCode = l || this.waitForOAuthCodeFunction();
687
687
  }
688
688
  async redirectCallbackFunction(e) {
689
689
  var t, n, s, o, a, i;
@@ -792,7 +792,7 @@ class it {
792
792
  completions: {},
793
793
  logging: {}
794
794
  };
795
- this.server = new ae(e || n, t || { capabilities: s }), this.server.server.oninitialized = () => {
795
+ this.server = new ie(e || n, t || { capabilities: s }), this.server.server.oninitialized = () => {
796
796
  this.oninitialized?.();
797
797
  }, this.server.server.onclose = () => {
798
798
  this.onclose?.();
@@ -946,13 +946,13 @@ class it {
946
946
  * Registers a handler for the subscribe request.
947
947
  */
948
948
  onSubscribe(e) {
949
- this.server.server.setRequestHandler(_e, e);
949
+ this.server.server.setRequestHandler(xe, e);
950
950
  }
951
951
  /**
952
952
  * Registers a handler for the unsubscribe request.
953
953
  */
954
954
  onUnsubscribe(e) {
955
- this.server.server.setRequestHandler(ve, e);
955
+ this.server.server.setRequestHandler(_e, e);
956
956
  }
957
957
  /**
958
958
  * Registers a handler for the set log level request.
@@ -964,13 +964,13 @@ class it {
964
964
  * Registers a handler for the list tools request.
965
965
  */
966
966
  onListResources(e) {
967
- this.server.server.setRequestHandler(me, e);
967
+ this.server.server.setRequestHandler(ve, e);
968
968
  }
969
969
  /**
970
970
  * Registers a handler for the roots list changed notification.
971
971
  */
972
972
  onRootsListChanged(e) {
973
- this.server.server.setNotificationHandler(ge, e);
973
+ this.server.server.setNotificationHandler(me, e);
974
974
  }
975
975
  /**
976
976
  * Close the transport for window.addEventListener('pagehide')
@@ -979,7 +979,7 @@ class it {
979
979
  e.persisted || this.transport && typeof this.transport.close == "function" && await this.transport.close();
980
980
  }
981
981
  }
982
- const at = (r, e) => new ee(r, e), ct = () => He(), lt = (r) => r instanceof ee, ut = (r) => r instanceof ae;
982
+ const at = (r, e) => new ee(r, e), ct = () => Te(), lt = (r) => r instanceof ee, ut = (r) => r instanceof ie;
983
983
  class dt {
984
984
  constructor(e, t) {
985
985
  const n = {
@@ -1007,7 +1007,7 @@ class dt {
1007
1007
  const u = { client: this.client, url: t, token: n, sessionId: s };
1008
1008
  let d;
1009
1009
  return await (async () => {
1010
- const { transport: f, sessionId: _ } = o === "sse" ? await Ye(u) : o === "socket" ? await Ze(u) : await ze(u);
1010
+ const { transport: f, sessionId: _ } = o === "sse" ? await Xe(u) : o === "socket" ? await ze(u) : await Ye(u);
1011
1011
  f.onerror = async (p) => {
1012
1012
  i?.(p);
1013
1013
  }, d = { transport: f, sessionId: _ };
@@ -1016,11 +1016,11 @@ class dt {
1016
1016
  const c = new URL(t);
1017
1017
  let l;
1018
1018
  if (o === "channel" && (l = new $(t), await this.client.connect(l)), o === "sse") {
1019
- const u = le(n, s);
1019
+ const u = ce(n, s);
1020
1020
  l = new V(c, u), await this.client.connect(l);
1021
1021
  }
1022
- if (o === "socket" && (l = new ie(new URL(`${t}?sessionId=${s}&token=${n}`)), l.sessionId = s, await this.client.connect(l)), typeof l > "u") {
1023
- const u = ue(n, s);
1022
+ if (o === "socket" && (l = new oe(new URL(`${t}?sessionId=${s}&token=${n}`)), l.sessionId = s, await this.client.connect(l)), typeof l > "u") {
1023
+ const u = le(n, s);
1024
1024
  l = new Q(c, u), await this.client.connect(l);
1025
1025
  }
1026
1026
  return this.transport = l, { transport: this.transport, sessionId: this.transport.sessionId };
@@ -1113,7 +1113,7 @@ class dt {
1113
1113
  * Calls a tool on the server with the given parameters.
1114
1114
  */
1115
1115
  async callTool(e, t) {
1116
- return await this.client.callTool(e, we, t);
1116
+ return await this.client.callTool(e, ge, t);
1117
1117
  }
1118
1118
  /**
1119
1119
  * Lists all tools available on the server.
@@ -1173,63 +1173,63 @@ class dt {
1173
1173
  * Registers a handler for the elicitation request.
1174
1174
  */
1175
1175
  onElicit(e) {
1176
- this.client.setRequestHandler(be, e);
1176
+ this.client.setRequestHandler(we, e);
1177
1177
  }
1178
1178
  /**
1179
1179
  * Registers a handler for the create LLM message request.
1180
1180
  */
1181
1181
  onCreateMessage(e) {
1182
- this.client.setRequestHandler(ye, e);
1182
+ this.client.setRequestHandler(be, e);
1183
1183
  }
1184
1184
  /**
1185
1185
  * Registers a handler for the list roots request.
1186
1186
  */
1187
1187
  onListRoots(e) {
1188
- this.client.setRequestHandler(Ie, e);
1188
+ this.client.setRequestHandler(ye, e);
1189
1189
  }
1190
1190
  /**
1191
1191
  * Registers a handler for the tool list changed notification.
1192
1192
  */
1193
1193
  onToolListChanged(e) {
1194
- this.client.setNotificationHandler(Ce, e);
1194
+ this.client.setNotificationHandler(Ie, e);
1195
1195
  }
1196
1196
  /**
1197
1197
  * Registers a handler for the prompt list changed notification.
1198
1198
  */
1199
1199
  onPromptListChanged(e) {
1200
- this.client.setNotificationHandler(Re, e);
1200
+ this.client.setNotificationHandler(Ce, e);
1201
1201
  }
1202
1202
  /**
1203
1203
  * Registers a handler for the resource list changed notification.
1204
1204
  */
1205
1205
  onResourceListChanged(e) {
1206
- this.client.setNotificationHandler(Se, e);
1206
+ this.client.setNotificationHandler(Re, e);
1207
1207
  }
1208
1208
  /**
1209
1209
  * Registers a handler for the resource updated notification.
1210
1210
  */
1211
1211
  onResourceUpdated(e) {
1212
- this.client.setNotificationHandler(Le, e);
1212
+ this.client.setNotificationHandler(Se, e);
1213
1213
  }
1214
1214
  /**
1215
1215
  * Registers a handler for the logging message notification.
1216
1216
  */
1217
1217
  onLoggingMessage(e) {
1218
- this.client.setNotificationHandler(Pe, e);
1218
+ this.client.setNotificationHandler(Le, e);
1219
1219
  }
1220
1220
  /**
1221
1221
  * Close the transport for window.addEventListener('pagehide')
1222
1222
  */
1223
1223
  async onPagehide(e) {
1224
- e.persisted || (Qe(this.transport) ? await this.transport.terminateSession() : this.transport && typeof this.transport.close == "function" && await this.transport.close());
1224
+ e.persisted || (Je(this.transport) ? await this.transport.terminateSession() : this.transport && typeof this.transport.close == "function" && await this.transport.close());
1225
1225
  }
1226
1226
  }
1227
- const ht = (r, e) => new V(r, e), ft = (r, e) => new Q(r, e), pt = (r, e) => new $(r, e), xt = (r) => r instanceof V, Qe = (r) => r instanceof Q, _t = (r) => r instanceof $, vt = (r) => r instanceof A, Ke = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
1227
+ const ht = (r, e) => new V(r, e), ft = (r, e) => new Q(r, e), pt = (r, e) => new $(r, e), xt = (r) => r instanceof V, Je = (r) => r instanceof Q, _t = (r) => r instanceof $, vt = (r) => r instanceof A, Qe = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
1228
1228
  const e = Math.random() * 16 | 0;
1229
1229
  return (r === "x" ? e : e & 3 | 8).toString(16);
1230
1230
  }), j = (r, e, t) => {
1231
1231
  window.postMessage({ type: r, direction: t, data: e }, "*");
1232
- }, re = (r, e, t) => {
1232
+ }, Ke = (r, e, t) => {
1233
1233
  const n = async function(s) {
1234
1234
  s.source === window && s.data.type === r && s.data.direction === t && await e(s.data.data);
1235
1235
  };
@@ -1237,20 +1237,12 @@ const ht = (r, e) => new V(r, e), ft = (r, e) => new Q(r, e), pt = (r, e) => new
1237
1237
  };
1238
1238
  class mt {
1239
1239
  constructor(e = null) {
1240
- this._isStarted = !1, this._isClosed = !1, this._lastRegistration = null, this.sessionId = e || Ke(), this._messageListener1 = re(
1241
- "sidepanel-ready-to-page",
1242
- () => {
1243
- this._lastRegistration && this._isStarted && this.notifyRegistration(this._lastRegistration).catch((t) => {
1244
- console.error("【Page Svr Transport】 notifyRegistration失败:", t);
1245
- });
1246
- },
1247
- "content->page"
1248
- ), this._messageListener2 = re(
1240
+ this._isStarted = !1, this._isClosed = !1, this._lastRegistration = null, this.sessionId = e || Qe(), this._messageListener2 = Ke(
1249
1241
  "mcp-client-to-server-to-page",
1250
1242
  (t) => {
1251
1243
  if (t.sessionId !== this.sessionId) return;
1252
1244
  console.log("【Page Svr Transport】 即将处理 mcpMessage", t.mcpMessage);
1253
- const n = oe.parse(t.mcpMessage);
1245
+ const n = re.parse(t.mcpMessage);
1254
1246
  this.onmessage?.(n), t.mcpMessage.params?.name && j(
1255
1247
  "update-page-app-message",
1256
1248
  { status: "run", message: t.mcpMessage.params?.name },
@@ -1314,7 +1306,7 @@ class mt {
1314
1306
  async close() {
1315
1307
  if (!this._isClosed)
1316
1308
  try {
1317
- this._messageListener1 && this._messageListener1(), this._messageListener2 && this._messageListener2(), this._isClosed = !0, this._isStarted = !1, this.onclose && this.onclose();
1309
+ this._messageListener2 && this._messageListener2(), this._isClosed = !0, this._isStarted = !1, this.onclose && this.onclose();
1318
1310
  } catch (e) {
1319
1311
  this._throwError(() => !0, "【Page Svr Transport】 关闭时发生错误" + String(e));
1320
1312
  }
@@ -1340,6 +1332,6 @@ export {
1340
1332
  _t as isMessageChannelClientTransport,
1341
1333
  lt as isMessageChannelServerTransport,
1342
1334
  xt as isSSEClientTransport,
1343
- Qe as isStreamableHTTPClientTransport,
1335
+ Je as isStreamableHTTPClientTransport,
1344
1336
  Rt as z
1345
1337
  };