@opentiny/next-sdk 0.3.3 → 0.4.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.
Files changed (134) hide show
  1. package/agent/AgentModelProvider.ts +78 -81
  2. package/agent/type.ts +6 -9
  3. package/agent/utils/getAISDKTools.ts +0 -1
  4. package/agent/utils/getBuiltinMcpTools.ts +7 -7
  5. package/core.ts +1 -3
  6. package/dist/SimulatorMask-BHVXyogh-iNUb4dyF.js +361 -0
  7. package/dist/agent/type.d.ts +4 -12
  8. package/dist/agent/utils/getBuiltinMcpTools.d.ts +3 -3
  9. package/dist/core.d.ts +1 -1
  10. package/dist/core.js +18 -18
  11. package/dist/index-CXK8CcKq.js +6076 -0
  12. package/dist/index.d.ts +2 -4
  13. package/dist/index.js +57 -2783
  14. package/dist/initialize-builtin-WebMCP-rALfqS-o.js +6389 -0
  15. package/dist/page-tools/a11y/build.d.ts +11 -0
  16. package/dist/page-tools/a11y/constants.d.ts +9 -0
  17. package/dist/page-tools/a11y/search.d.ts +17 -0
  18. package/dist/page-tools/a11y/types.d.ts +104 -0
  19. package/dist/page-tools/a11y/utils.d.ts +34 -0
  20. package/dist/page-tools/a11y/vnode.d.ts +37 -0
  21. package/dist/page-tools/a11y-tree.d.ts +12 -0
  22. package/dist/page-tools/bridge.d.ts +0 -6
  23. package/dist/page-tools/constants.d.ts +22 -0
  24. package/dist/page-tools/context.d.ts +28 -0
  25. package/dist/page-tools/handlers/browserState.d.ts +8 -0
  26. package/dist/page-tools/handlers/click.d.ts +8 -0
  27. package/dist/page-tools/handlers/executeJavascript.d.ts +8 -0
  28. package/dist/page-tools/handlers/fill.d.ts +8 -0
  29. package/dist/page-tools/handlers/scroll.d.ts +8 -0
  30. package/dist/page-tools/handlers/searchTree.d.ts +8 -0
  31. package/dist/page-tools/handlers/select.d.ts +8 -0
  32. package/dist/page-tools/initialize-builtin-WebMCP.d.ts +1 -0
  33. package/dist/page-tools/page-agent-highlight/index.d.ts +9 -0
  34. package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +14 -0
  35. package/dist/page-tools/page-agent-mask/checkDarkMode.d.ts +5 -0
  36. package/dist/page-tools/page-agent-tool.d.ts +4 -0
  37. package/dist/page-tools/page-state-cache.d.ts +36 -0
  38. package/dist/page-tools/schema.d.ts +43 -0
  39. package/dist/page-tools/utils/dom.d.ts +6 -0
  40. package/dist/page-tools/utils/scroll.d.ts +15 -0
  41. package/dist/runtime.d.ts +4 -0
  42. package/dist/runtime.js +744 -0
  43. package/dist/utils/builtinProxy.d.ts +1 -1
  44. package/index.ts +2 -19
  45. package/package.json +14 -18
  46. package/page-tools/a11y/build.ts +70 -0
  47. package/page-tools/a11y/constants.ts +110 -0
  48. package/page-tools/a11y/search.ts +129 -0
  49. package/page-tools/a11y/types.ts +108 -0
  50. package/page-tools/a11y/utils.ts +266 -0
  51. package/page-tools/a11y/vnode.ts +229 -0
  52. package/page-tools/a11y-tree.ts +13 -0
  53. package/page-tools/bridge.ts +49 -15
  54. package/page-tools/constants.ts +72 -0
  55. package/page-tools/context.ts +13 -0
  56. package/page-tools/handlers/browserState.ts +12 -0
  57. package/page-tools/handlers/click.ts +26 -0
  58. package/page-tools/handlers/executeJavascript.ts +22 -0
  59. package/page-tools/handlers/fill.ts +60 -0
  60. package/page-tools/handlers/scroll.ts +66 -0
  61. package/page-tools/handlers/searchTree.ts +30 -0
  62. package/page-tools/handlers/select.ts +34 -0
  63. package/page-tools/initialize-builtin-WebMCP.ts +20 -0
  64. package/page-tools/page-agent-highlight/index.ts +198 -0
  65. package/page-tools/page-agent-mask/SimulatorMask.module.css +14 -0
  66. package/page-tools/page-agent-mask/SimulatorMask.ts +279 -0
  67. package/page-tools/page-agent-mask/checkDarkMode.ts +181 -0
  68. package/page-tools/page-agent-mask/cursor-border.svg +3 -0
  69. package/page-tools/page-agent-mask/cursor-fill.svg +5 -0
  70. package/page-tools/page-agent-mask/cursor.module.css +70 -0
  71. package/page-tools/page-agent-prompt.md +139 -0
  72. package/page-tools/page-agent-tool.ts +175 -0
  73. package/page-tools/page-state-cache.ts +78 -0
  74. package/page-tools/schema.ts +51 -0
  75. package/page-tools/utils/dom.ts +155 -0
  76. package/page-tools/utils/scroll.ts +58 -0
  77. package/runtime.ts +13 -0
  78. package/utils/builtinProxy.ts +45 -13
  79. package/vite.config.runtime.ts +22 -0
  80. package/vite.config.ts +52 -8
  81. package/McpSdk.ts +0 -14
  82. package/WebAgent.ts +0 -5
  83. package/WebMcp.ts +0 -20
  84. package/Zod.ts +0 -1
  85. package/dist/AgentModelProvider-CwqOT28f.js +0 -4198
  86. package/dist/McpSdk.d.ts +0 -14
  87. package/dist/WebAgent.d.ts +0 -5
  88. package/dist/WebMcp.d.ts +0 -20
  89. package/dist/Zod.d.ts +0 -1
  90. package/dist/index.es.dev.js +0 -53427
  91. package/dist/index.es.js +0 -42147
  92. package/dist/index.umd.dev.js +0 -53820
  93. package/dist/index.umd.js +0 -814
  94. package/dist/mcpsdk@1.25.3.dev.js +0 -22621
  95. package/dist/mcpsdk@1.25.3.es.dev.js +0 -22619
  96. package/dist/mcpsdk@1.25.3.es.js +0 -16802
  97. package/dist/mcpsdk@1.25.3.js +0 -43
  98. package/dist/transport/ExtensionClientTransport.d.ts +0 -24
  99. package/dist/transport/ExtensionContentServerTransport.d.ts +0 -39
  100. package/dist/transport/ExtensionPageServerTransport.d.ts +0 -36
  101. package/dist/transport/messages.d.ts +0 -9
  102. package/dist/vite.config.mcpSdk.d.ts +0 -2
  103. package/dist/vite.config.webAgent.d.ts +0 -2
  104. package/dist/vite.config.webMcp.d.ts +0 -2
  105. package/dist/vite.config.webMcpFull.d.ts +0 -2
  106. package/dist/vite.config.zod.d.ts +0 -2
  107. package/dist/webagent.dev.js +0 -47597
  108. package/dist/webagent.es.dev.js +0 -47204
  109. package/dist/webagent.es.js +0 -37494
  110. package/dist/webagent.js +0 -634
  111. package/dist/webmcp-full.dev.js +0 -24430
  112. package/dist/webmcp-full.es.dev.js +0 -24426
  113. package/dist/webmcp-full.es.js +0 -18333
  114. package/dist/webmcp-full.js +0 -43
  115. package/dist/webmcp.dev.js +0 -1595
  116. package/dist/webmcp.es.dev.js +0 -1589
  117. package/dist/webmcp.es.js +0 -1406
  118. package/dist/webmcp.js +0 -1
  119. package/dist/zod@3.25.76.dev.js +0 -4037
  120. package/dist/zod@3.25.76.es.dev.js +0 -4033
  121. package/dist/zod@3.25.76.es.js +0 -2945
  122. package/dist/zod@3.25.76.js +0 -1
  123. package/transport/ExtensionClientTransport.ts +0 -100
  124. package/transport/ExtensionContentServerTransport.ts +0 -162
  125. package/transport/ExtensionPageServerTransport.ts +0 -149
  126. package/transport/messages.ts +0 -63
  127. package/vite-build-tsc.ts +0 -63
  128. package/vite-env.d.ts +0 -5
  129. package/vite.config.mcpSdk.ts +0 -28
  130. package/vite.config.webAgent.ts +0 -19
  131. package/vite.config.webMcp.ts +0 -40
  132. package/vite.config.webMcpFull.ts +0 -19
  133. package/vite.config.zod.ts +0 -23
  134. /package/dist/{vite-build-tsc.d.ts → vite.config.runtime.d.ts} +0 -0
package/dist/webmcp.es.js DELETED
@@ -1,1406 +0,0 @@
1
- import { default as yt } from "ajv";
2
- import { JSONRPCMessageSchema as re, EmptyResultSchema as de, ElicitResultSchema as pe, CreateMessageResultSchema as fe, ListRootsResultSchema as he, SetLevelRequestSchema as se, SubscribeRequestSchema as xe, UnsubscribeRequestSchema as _e, ListResourcesRequestSchema as me, RootsListChangedNotificationSchema as ve, CallToolResultSchema as ge, ElicitRequestSchema as we, CreateMessageRequestSchema as be, ListRootsRequestSchema as ye, ToolListChangedNotificationSchema as Ie, PromptListChangedNotificationSchema as Ce, ResourceListChangedNotificationSchema as Se, ResourceUpdatedNotificationSchema as Re, LoggingMessageNotificationSchema as Le } from "@modelcontextprotocol/sdk/types.js";
3
- import { Client as j } from "@modelcontextprotocol/sdk/client/index.js";
4
- import { SSEClientTransport as A } from "@modelcontextprotocol/sdk/client/sse.js";
5
- import { StreamableHTTPClientTransport as Q } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
6
- import { WebSocketClientTransport as oe } from "@modelcontextprotocol/sdk/client/websocket.js";
7
- import { UnauthorizedError as Te } from "@modelcontextprotocol/sdk/client/auth.js";
8
- import { McpServer as ie } from "@modelcontextprotocol/sdk/server/mcp.js";
9
- import { ResourceTemplate as Ct } from "@modelcontextprotocol/sdk/server/mcp.js";
10
- import { z as Rt } from "zod";
11
- import { UriTemplate as Tt } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
12
- import { completable as qt } from "@modelcontextprotocol/sdk/server/completable.js";
13
- import { getDisplayName as Mt } from "@modelcontextprotocol/sdk/shared/metadataUtils.js";
14
- const M = I;
15
- (function(r, e) {
16
- const t = I, n = I, s = r();
17
- for (; ; )
18
- try {
19
- if (parseInt(t(403)) / 1 + -parseInt(t(411)) / 2 * (-parseInt(n(406)) / 3) + -parseInt(n(425)) / 4 * (parseInt(t(387)) / 5) + -parseInt(n(426)) / 6 + parseInt(n(395)) / 7 * (-parseInt(t(419)) / 8) + -parseInt(t(413)) / 9 + parseInt(n(400)) / 10 === e) break;
20
- s.push(s.shift());
21
- } catch {
22
- s.push(s.shift());
23
- }
24
- })(D, -118057 + 3521 * -35 + -2099 * -233);
25
- const ae = () => {
26
- const r = I, e = I, t = {};
27
- t[r(420)] = "3|0|2|1|4", t.vQYJZ = function(a, i) {
28
- return a !== i;
29
- }, t[e(394)] = e(414), t.ktWqD = function(a, i) {
30
- return a !== i;
31
- }, t[r(424)] = r(391);
32
- const n = t, s = n[e(420)].split("|");
33
- let o = 859 * 2 + -3 * -1039 + -4835 * 1;
34
- for (; ; ) {
35
- switch (s[o++]) {
36
- case "0":
37
- if (n[e(407)](typeof window, "undefined")) return window;
38
- continue;
39
- case "1":
40
- if (n.vQYJZ(typeof self, n.NZmUq)) return self;
41
- continue;
42
- case "2":
43
- if (n[e(405)](typeof global, "undefined")) return global;
44
- continue;
45
- case "3":
46
- if (n[e(405)](typeof globalThis, n[r(394)])) return globalThis;
47
- continue;
48
- case "4":
49
- return Function(n[r(424)])();
50
- }
51
- break;
52
- }
53
- }, Pe = (r, e, t) => {
54
- const n = I, s = I, o = {};
55
- o.eOzBp = function(i, c) {
56
- return i !== c;
57
- }, o.ooaJk = "undefined", o[n(402)] = function(i, c) {
58
- return i === c;
59
- }, o[n(421)] = "function";
60
- const a = o;
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
- }, qe = (r, e) => {
63
- const t = I, n = I, s = {};
64
- s.nTCfA = function(a, i) {
65
- return a in i;
66
- }, s[t(390)] = "addEventListener", s[t(385)] = function(a, i) {
67
- return a === i;
68
- }, s[t(409)] = "function", s.VaHpd = n(392), s[n(384)] = t(417), s.FPOYW = function(a, i) {
69
- return a !== i;
70
- };
71
- const o = s;
72
- o.nTCfA(o.ogKey, r) && o[n(385)](typeof r.addEventListener, o[n(409)]) ? r[n(386)](o.VaHpd, e) : o[n(384)] in r && o[t(398)](typeof r[n(417)], t(414)) && (r.onmessage = e);
73
- };
74
- class B {
75
- constructor(e) {
76
- this._port = e;
77
- }
78
- async [M(401)]() {
79
- const e = M, t = M;
80
- this[e(422)] && (this[t(422)].onmessage = (n) => {
81
- var s, o;
82
- const a = e;
83
- try {
84
- const i = re.parse(n.data.message);
85
- (s = this.onmessage) == null || s.call(this, i, n[a(412)][a(428)]);
86
- } catch (i) {
87
- const c = new Error("MessageChannel failed to parse message: " + i);
88
- (o = this[a(383)]) == null || o.call(this, c);
89
- }
90
- }, this._port.onmessageerror = (n) => {
91
- var s;
92
- const o = t, a = new Error("MessageChannel transport error: " + JSON[o(415)](n));
93
- (s = this.onerror) == null || s.call(this, a);
94
- }, this[t(422)].start());
95
- }
96
- async send(e, t) {
97
- const n = { EoBZE: function(s) {
98
- return s();
99
- }, leEiG: function(s, o) {
100
- return s instanceof o;
101
- }, cDUwk: function(s, o) {
102
- return s(o);
103
- } };
104
- return new Promise((s, o) => {
105
- var a;
106
- const i = I, c = I;
107
- try {
108
- const l = {};
109
- l[i(404)] = t?.[i(404)];
110
- const u = {};
111
- u[i(392)] = e, u.extra = l, this._port && this._port[c(423)](u), n[i(399)](s);
112
- } catch (l) {
113
- const u = n.leEiG(l, Error) ? l : new Error(n.cDUwk(String, l));
114
- (a = this.onerror) == null || a.call(this, u), o(u);
115
- }
116
- });
117
- }
118
- async close() {
119
- var e, t;
120
- const n = M, s = M;
121
- (e = this._port) == null || e[n(393)](), this[n(422)] = void 0, (t = this[s(408)]) == null || t.call(this);
122
- }
123
- }
124
- class $ extends B {
125
- constructor(e, t = ae()) {
126
- const n = M, s = { lSpBh: function(a, i, c, l) {
127
- return a(i, c, l);
128
- } };
129
- super(), this._endpoint = e, this._globalObject = t;
130
- const o = new MessageChannel();
131
- this._port = o[n(410)], s[n(418)](Pe, this._globalObject, { endpoint: this[n(397)] }, [o[n(429)]]);
132
- }
133
- }
134
- class ee extends B {
135
- constructor(e, t = ae()) {
136
- const n = M, s = M, o = { HITdC: function(a, i) {
137
- return a === i;
138
- }, QdDxM: function(a) {
139
- return a();
140
- }, jowPp: function(a, i, c) {
141
- return a(i, c);
142
- } };
143
- super(), this[n(397)] = e, this[s(388)] = t, this[s(416)] = new Promise((a) => {
144
- const i = n, c = { XlglK: function(l, u) {
145
- return o.HITdC(l, u);
146
- }, pXlad: function(l) {
147
- return o.QdDxM(l);
148
- } };
149
- o[i(427)](qe, this._globalObject, (l) => {
150
- const u = i, d = i;
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
- });
153
- });
154
- }
155
- async listen() {
156
- return this._listen;
157
- }
158
- }
159
- function D() {
160
- const r = ["message", "close", "NZmUq", "177464iLQCGm", "endpoint", "_endpoint", "FPOYW", "EoBZE", "3022630ngzRBs", "start", "pTvSc", "272809yMhhPJ", "authInfo", "ktWqD", "21849KofsKk", "vQYJZ", "onclose", "mkHJS", "port1", "22dUTKmE", "data", "608229RXNlUs", "undefined", "stringify", "_listen", "onmessage", "lSpBh", "8FmlYyF", "XwdDB", "cHbAW", "_port", "postMessage", "kFtNB", "72572mbPnfL", "689424jqaGZE", "jowPp", "extra", "port2", "ports", "onerror", "Fzdib", "mkuHv", "addEventListener", "55juYkZZ", "_globalObject", "eOzBp", "ogKey", "return this"];
161
- return D = function() {
162
- return r;
163
- }, D();
164
- }
165
- function I(r, e) {
166
- const t = D();
167
- return I = function(n, s) {
168
- return n = n - (17227 + 1 * -16844), t[n];
169
- }, I(r, e);
170
- }
171
- const ke = () => {
172
- const r = new MessageChannel();
173
- return [new B(r.port1), new B(r.port2)];
174
- };
175
- (function(r, e) {
176
- const t = x, n = x, s = r();
177
- for (; ; )
178
- try {
179
- if (parseInt(t(452)) / 1 * (parseInt(n(441)) / 2) + parseInt(n(434)) / 3 * (-parseInt(n(418)) / 4) + parseInt(t(459)) / 5 + parseInt(t(482)) / 6 * (-parseInt(t(479)) / 7) + -parseInt(t(458)) / 8 * (parseInt(t(457)) / 9) + -parseInt(n(416)) / 10 + -parseInt(t(450)) / 11 * (-parseInt(t(433)) / 12) === e) break;
180
- s.push(s.shift());
181
- } catch {
182
- s.push(s.shift());
183
- }
184
- })(W, -411935 * 1 + 228107 + 208149 * 2);
185
- const Me = async (r, e, t) => {
186
- var n;
187
- const s = x, o = x, a = {};
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);
189
- const i = a, { id: c, method: l, params: u } = t;
190
- let d = {};
191
- switch (l) {
192
- case i.VRyiJ:
193
- d = await e.listTools(u);
194
- break;
195
- case i.VkPYu:
196
- d = await e.callTool(u);
197
- break;
198
- case i.fgMSD:
199
- d = await e.listResources(u);
200
- break;
201
- case i[o(466)]:
202
- d = await e.listResourceTemplates(u);
203
- break;
204
- case i.sthgI:
205
- d = await e[s(455)](u);
206
- break;
207
- case o(486):
208
- d = await e.subscribeResource(u);
209
- break;
210
- case s(410):
211
- d = await e.unsubscribeResource(u);
212
- break;
213
- case i[o(461)]:
214
- d = await e[o(414)](u);
215
- break;
216
- case i[s(412)]:
217
- d = await e[s(491)](u);
218
- break;
219
- case i[s(436)]:
220
- d = await e[s(478)]();
221
- break;
222
- case i.kkNqg:
223
- d = await e.complete(u);
224
- break;
225
- case s(464):
226
- d = await e.setLoggingLevel(u?.[o(443)]);
227
- break;
228
- }
229
- const p = {};
230
- p.result = d, p.jsonrpc = i[o(472)], p.id = c, await ((n = r?.[o(488)]) == null ? void 0 : n[s(460)](p));
231
- }, He = async (r, e, t) => {
232
- var n;
233
- const s = x, o = x, a = {};
234
- a[s(487)] = o(462), a.ypHTC = "ping", a.fPExS = s(465);
235
- const i = a, { id: c, method: l, params: u } = t;
236
- let d = {};
237
- switch (l) {
238
- case "roots/list":
239
- const f = {};
240
- f.method = l, f[o(446)] = u, d = await e[s(469)](f, he);
241
- break;
242
- case "sampling/createMessage":
243
- const _ = {};
244
- _[s(481)] = l, _[s(446)] = u, d = await e.request(_, fe);
245
- break;
246
- case i[s(487)]:
247
- const h = {};
248
- h.method = l, h[o(446)] = u, d = await e.request(h, pe);
249
- break;
250
- case i.ypHTC:
251
- const m = {};
252
- m.method = l, d = await e.request(m, de);
253
- break;
254
- }
255
- const p = {};
256
- return p.result = d, p.jsonrpc = i.fPExS, p.id = c, await ((n = r?.transport) == null ? void 0 : n.send(p)), d;
257
- };
258
- function x(r, e) {
259
- const t = W();
260
- return x = function(n, s) {
261
- return n = n - (-8023 + 4 * -2344 + -17809 * -1), t[n];
262
- }, x(r, e);
263
- }
264
- const Ne = (r, e) => {
265
- const t = x, n = x, s = { vYlhn: function(a, i) {
266
- return a === i;
267
- }, DhPFX: t(470), NYVNC: function(a, i, c, l) {
268
- return a(i, c, l);
269
- }, yfZbw: "2.0" }, o = r._onrequest;
270
- r[n(463)] = async (a, i) => {
271
- var c, l, u, d, p;
272
- const f = n, _ = t, { id: h, method: m } = a;
273
- try {
274
- s[f(451)](m, s.DhPFX) ? await o.call(r, a, i) : await s[_(474)](Me, r, e, a);
275
- } catch (v) {
276
- const { code: b, message: C, data: T } = v;
277
- try {
278
- if (b) {
279
- const w = {};
280
- w[_(485)] = b, w[f(422)] = C, w.data = T;
281
- const L = {};
282
- L[_(448)] = w, L.jsonrpc = s[f(417)], L.id = h, await ((c = r?.transport) == null ? void 0 : c[_(460)](L));
283
- } else (u = (l = r?.transport) == null ? void 0 : l.onerror) == null || u.call(l, v);
284
- } catch (w) {
285
- (p = (d = r?.transport) == null ? void 0 : d.onerror) == null || p.call(d, w);
286
- }
287
- }
288
- };
289
- }, Ue = (r, e) => {
290
- const t = x, n = x, s = {};
291
- s[t(476)] = t(439), s[t(431)] = function(a, i) {
292
- return a !== i;
293
- }, s.UPdQt = "notifications/cancelled";
294
- const o = s;
295
- r[t(421)] = async (a) => {
296
- var i, c;
297
- const l = t, u = n, { method: d, params: p } = a;
298
- if (d !== o[l(476)] && (o.QWYMz(d, o.UPdQt) || p?.[u(490)])) try {
299
- await e[l(445)](a);
300
- } catch (f) {
301
- (c = (i = r?.[l(488)]) == null ? void 0 : i[l(480)]) == null || c.call(i, f);
302
- }
303
- };
304
- }, Fe = (r, e) => async (t) => {
305
- var n, s, o, a, i;
306
- const c = x, l = x, u = { TJhyV: function(d, p, f, _) {
307
- return d(p, f, _);
308
- }, MMNTY: c(465) };
309
- try {
310
- return await u.TJhyV(He, r, e, t);
311
- } catch (d) {
312
- const { code: p, message: f, data: _ } = d;
313
- try {
314
- if (p) {
315
- const h = {};
316
- h.code = p, h[c(422)] = f, h[l(419)] = _;
317
- const m = {};
318
- m[c(448)] = h, m[c(424)] = u.MMNTY, m.id = t.id, await ((n = r?.transport) == null ? void 0 : n[l(460)](m));
319
- } else (o = (s = r?.transport) == null ? void 0 : s[c(480)]) == null || o.call(s, d);
320
- } catch (h) {
321
- (i = (a = r?.[c(488)]) == null ? void 0 : a.onerror) == null || i.call(a, h);
322
- }
323
- }
324
- }, Ee = (r, e) => async (t) => {
325
- var n, s, o;
326
- const a = x, i = x, c = {};
327
- c.xmcLM = function(p, f) {
328
- return p !== f;
329
- }, c.xSWLt = "notifications/initialized", c[a(420)] = i(453);
330
- const l = c, { method: u, params: d } = t;
331
- if (l.xmcLM(u, l.xSWLt) && (l.xmcLM(u, l[i(420)]) || d?.[i(490)])) try {
332
- const p = { ...t };
333
- p.jsonrpc = a(465), await ((n = e?.[a(488)]) == null ? void 0 : n.send(p));
334
- } catch (p) {
335
- (o = (s = r?.transport) == null ? void 0 : s.onerror) == null || o.call(s, p);
336
- }
337
- };
338
- function W() {
339
- const r = ["JMaxV", "cNneM", "completion/complete", "addResponseListener", "notifications/initialized", "call", "570686biwZQB", "kkNqg", "level", "addNotificationListener", "notification", "params", "addListener", "error", "_onresponse", "164054EGcqjc", "vYlhn", "1PDRdga", "notifications/cancelled", "_requestHandlers", "readResource", "FjTAY", "1782ueLDLp", "4496TJFZWc", "1767765yPcVQJ", "send", "HefvS", "elicitation/create", "_onrequest", "logging/setLevel", "2.0", "SoCaE", "HucXo", "function", "request", "initialize", "push", "dEmVs", "addRequestListener", "NYVNC", "fgMSD", "CSjwA", "prompts/list", "ping", "35pZrnNj", "onerror", "method", "238086YifXhM", "get", "sthgI", "code", "resources/subscribe", "sttJM", "transport", "jsmFN", "forward", "listPrompts", "resources/unsubscribe", "resources/list", "srIIC", "originalOnResponse", "getPrompt", "indexOf", "3653560KcjkMk", "yfZbw", "4SAWlvk", "data", "rCDHw", "_onnotification", "message", "UlqiY", "jsonrpc", "yCyFn", "clearNotificationListener", "VWsxO", "name", "UynHf", "length", "QWYMz", "fallbackRequestHandler", "492jTClKn", "1028589HsbHVQ"];
340
- return W = function() {
341
- return r;
342
- }, W();
343
- }
344
- const Oe = (r, e) => async (t) => {
345
- var n, s, o, a, i, c;
346
- const l = x, u = x, d = {};
347
- d.kSvAZ = l(465);
348
- const p = d;
349
- try {
350
- await ((n = e?.[u(488)]) == null ? void 0 : n[u(460)](t));
351
- } catch (f) {
352
- const { code: _, message: h, data: m } = f;
353
- try {
354
- if (_) {
355
- const v = {};
356
- v.code = _, v.message = h, v.data = m;
357
- const b = {};
358
- b.error = v, b[u(424)] = p.kSvAZ, b.id = t.id, await ((s = r?.transport) == null ? void 0 : s.send(b));
359
- } else (a = (o = r?.transport) == null ? void 0 : o[l(480)]) == null || a.call(o, f);
360
- } catch (v) {
361
- (c = (i = r?.[l(488)]) == null ? void 0 : i[u(480)]) == null || c.call(i, v);
362
- }
363
- }
364
- }, G = () => {
365
- const r = x, e = { rgPZO: function(c, l) {
366
- return c !== l;
367
- }, VWsxO: function(c, l) {
368
- return c(l);
369
- }, FjTAY: "function" }, t = [], n = (c, l) => {
370
- const u = x;
371
- if (l) {
372
- const d = [];
373
- for (const p of t)
374
- try {
375
- d.push(p(c, l));
376
- } catch {
377
- }
378
- for (const p of d)
379
- if (e.rgPZO(p, null)) return p;
380
- } else for (const d of t)
381
- try {
382
- e[u(427)](d, c);
383
- } catch {
384
- }
385
- }, s = (c) => {
386
- const l = x, u = x;
387
- typeof c === e[l(456)] && !t.includes(c) && t[u(471)](c);
388
- }, o = (c) => {
389
- const l = x, u = t[l(415)](c);
390
- u !== -1 && t.splice(u, -17591 + 6 * 2932);
391
- }, a = () => {
392
- const c = x;
393
- t[c(430)] = -505 * 7 + 1322 + 2213;
394
- }, i = {};
395
- return i.handleListener = n, i[r(447)] = s, i.removeListener = o, i.clearListener = a, i;
396
- }, je = (r) => {
397
- const e = x, t = x, n = { UlqiY: function(s) {
398
- return s();
399
- }, jsmFN: function(s) {
400
- return s();
401
- } };
402
- {
403
- const { handleListener: s, addListener: o, removeListener: a, clearListener: i } = n[e(423)](G);
404
- r._onresponse = s, r[t(438)] = o, r.removeResponseListener = a, r.clearResponseListener = i;
405
- }
406
- {
407
- const { handleListener: s, addListener: o, removeListener: a, clearListener: i } = n[e(489)](G);
408
- r[e(432)] = s, r[t(473)] = o, r.removeRequestListener = a, r.clearRequestListener = i;
409
- }
410
- {
411
- const { handleListener: s, addListener: o, removeListener: a, clearListener: i } = n.jsmFN(G);
412
- r.fallbackNotificationHandler = s, r[e(444)] = o, r.removeNotificationListener = a, r[t(426)] = i;
413
- }
414
- }, Ae = (r, { beforeInit: e, afterInit: t } = {}) => {
415
- const n = x, s = x, o = { HucXo: function(i, c) {
416
- return i === c;
417
- }, HicFO: n(468), JMaxV: function(i) {
418
- return i();
419
- }, DclXr: function(i, c) {
420
- return i(c);
421
- }, UynHf: function(i, c) {
422
- return i === c;
423
- }, yCyFn: function(i) {
424
- return i();
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(je, r), r[s(438)]((i) => {
427
- const c = n;
428
- r.originalOnResponse[c(440)](r, i);
429
- }), o[n(429)](typeof t, o.HicFO) && o[s(425)](t), r[s(444)]((i) => {
430
- const c = s, { method: l } = i, u = a[c(483)](l);
431
- o[c(467)](typeof u, "function") && u(i);
432
- });
433
- }, Ve = P;
434
- (function(r, e) {
435
- const t = P, n = P, s = r();
436
- for (; ; )
437
- try {
438
- if (parseInt(t(215)) / 1 * (-parseInt(n(217)) / 2) + parseInt(t(216)) / 3 + parseInt(t(210)) / 4 * (parseInt(n(223)) / 5) + -parseInt(n(214)) / 6 * (parseInt(n(220)) / 7) + parseInt(n(212)) / 8 * (parseInt(t(228)) / 9) + parseInt(t(219)) / 10 + parseInt(t(222)) / 11 * (parseInt(t(224)) / 12) === e) break;
439
- s.push(s.shift());
440
- } catch {
441
- s.push(s.shift());
442
- }
443
- })(z, 995159 + -6 * -266138 + -1619768);
444
- const Be = () => {
445
- const r = P, e = P, t = {};
446
- t.svuxn = function(s, o) {
447
- return s & o;
448
- }, t.ZUPdr = function(s, o) {
449
- return s === o;
450
- }, t[r(227)] = function(s, o) {
451
- return s === o;
452
- }, t.SpRzi = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
453
- const n = t;
454
- return n[e(227)](typeof crypto, "object") && crypto[r(211)] ? crypto.randomUUID() : n.SpRzi.replace(/[xy]/g, (s) => {
455
- const o = r, a = n.svuxn(crypto.getRandomValues(new Uint8Array(-3798 + 8571 * -1 + 12370))[0], -8324 + 8339 * 1);
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
- });
458
- }, De = (r) => {
459
- const e = P, t = P, n = new Uint8Array(r);
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
- }, H = {};
462
- H[Ve(211)] = Be, H.randomBytes = De;
463
- function P(r, e) {
464
- const t = z();
465
- return P = function(n, s) {
466
- return n = n - (-7373 + 7187 * 1 + 395), t[n];
467
- }, P(r, e);
468
- }
469
- function z() {
470
- const r = ["join", "2500590yHdCUG", "3CzpgOE", "219762yRRBUK", "592022JqIdxi", "from", "6033730pSHJFF", "28gKZiuO", "getRandomValues", "147169GUBreL", "5fFOMNB", "1140KVOWlq", "ZUPdr", "toString", "DBGzc", "45351XtLuDF", "svuxn", "9892WpQPGF", "randomUUID", "2504EaskHQ"];
471
- return z = function() {
472
- return r;
473
- }, z();
474
- }
475
- function q(r, e) {
476
- const t = X();
477
- return q = function(n, s) {
478
- return n = n - (-1483 * 3 + -5564 + 20 * 513), t[n];
479
- }, q(r, e);
480
- }
481
- const R = q, O = q;
482
- (function(r, e) {
483
- const t = q, n = q, s = r();
484
- for (; ; )
485
- try {
486
- if (parseInt(t(302)) / 1 + -parseInt(n(249)) / 2 + -parseInt(t(291)) / 3 + -parseInt(t(292)) / 4 * (parseInt(t(264)) / 5) + -parseInt(n(273)) / 6 * (parseInt(t(266)) / 7) + parseInt(t(300)) / 8 * (parseInt(t(269)) / 9) + parseInt(n(255)) / 10 * (parseInt(t(284)) / 11) === e) break;
487
- s.push(s.shift());
488
- } catch {
489
- s.push(s.shift());
490
- }
491
- })(X, -4 * 308317 + 753182 * 2 + 658196);
492
- const We = (r, e) => {
493
- const t = q, n = q, s = { olCWX: function(c, l, u) {
494
- return c(l, u);
495
- }, sfXDX: function(c, l, u) {
496
- return c(l, u);
497
- }, ksWFu: function(c, l, u) {
498
- return c(l, u);
499
- } };
500
- s[t(283)](Ne, r, e), Ue(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
- e.addRequestListener(o), e.addResponseListener(a), e[n(287)](i), r.onclose = () => {
503
- const c = t, l = n;
504
- e[c(247)](o), e.removeResponseListener(a), e[l(252)](i);
505
- };
506
- }, te = (r, e, t) => {
507
- const n = { QhPqi: function(a, i) {
508
- return a instanceof i;
509
- }, AIICR: "close", Qalmc: function(a, i, c) {
510
- return a(i, c);
511
- } }, s = () => {
512
- var a;
513
- n.QhPqi(t, A) && ((a = t._eventSource) == null || a.addEventListener(n.AIICR, () => {
514
- var i;
515
- (i = t[q(295)]) == null || i.close();
516
- })), n.Qalmc(We, r, e);
517
- }, o = {};
518
- o.afterInit = s, n.Qalmc(Ae, e, o);
519
- }, ce = (r, e = H[R(299)]()) => {
520
- const t = R, n = R, s = { RVabx: function(u, d, p) {
521
- return u(d, p);
522
- }, crCTs: "include" }, o = {};
523
- o["sse-session-id"] = e;
524
- const a = o, i = {};
525
- i["sse-session-id"] = e;
526
- const c = {};
527
- c.headers = i, c.credentials = s[t(304)];
528
- const l = { requestInit: c, eventSourceInit: { async fetch(u, d) {
529
- const p = t, f = t, _ = new Headers(d?.[p(268)] || {});
530
- Object.entries(a).forEach(([m, v]) => {
531
- _.set(m, v);
532
- });
533
- const h = { ...d };
534
- return h.headers = _, s[f(279)](fetch, u, h);
535
- }, withCredentials: !0 } };
536
- return r && (l[t(280)].headers.Authorization = "Bearer " + r, a.Authorization = n(256) + r), l;
537
- }, le = (r, e = H[R(299)]()) => {
538
- const t = O, n = R, s = {};
539
- s[t(271)] = "include";
540
- const o = s, a = {};
541
- a["stream-session-id"] = e;
542
- const i = {};
543
- i[n(268)] = a, i.credentials = o[t(271)];
544
- const c = {};
545
- c.requestInit = i;
546
- const l = c;
547
- return r && (l[n(280)][t(268)][n(301)] = t(256) + r), l;
548
- }, ne = async (r, e, t) => {
549
- const n = R, s = R, o = { rRtFD: function(i) {
550
- return i();
551
- }, ToRAF: function(i, c) {
552
- return i instanceof c;
553
- } }, a = o[n(276)](t);
554
- try {
555
- return await r[s(260)](a), a;
556
- } catch (i) {
557
- if (o[n(275)](i, Te)) {
558
- const c = await e();
559
- return await a[n(257)](c), await ne(r, e, t);
560
- } else throw i;
561
- }
562
- }, ue = (r, e) => {
563
- const t = O, n = O, s = {};
564
- s[t(267)] = function(a, i) {
565
- return a in i;
566
- }, s.timcZ = "waitForOAuthCode", s[t(253)] = function(a, i) {
567
- return a === i;
568
- }, s.ufiEQ = t(285), s[n(250)] = t(293);
569
- const o = s;
570
- if (o.oGmBG(o[t(258)], r)) return r[n(278)];
571
- if (o[n(253)](typeof e, o.ufiEQ)) return e;
572
- throw new Error(o.daYBw);
573
- };
574
- function X() {
575
- const r = ["oGmBG", "headers", "1233BqDPfE", "eventSourceInit", "jmVYh", "wfHUn", "1336686qzpbXm", "_endpoint", "ToRAF", "rRtFD", "ksWFu", "waitForOAuthCode", "RVabx", "requestInit", "mcp-sse-proxy-client", "CfBXU", "olCWX", "341WrxLOu", "function", "sessionId", "addNotificationListener", "version", "GKDjq", "roots", "5390433vAXkON", "4NpGpPF", "waitForOAuthCode need to be provided when authProvider is provided", "sfXDX", "_eventSource", "PdsSn", "get", "sampling", "randomUUID", "4064jocfPO", "Authorization", "452565rqIeHi", "elicitation", "crCTs", "authProvider", "removeRequestListener", "1.0.0", "104070FoHgyi", "daYBw", "capabilities", "removeNotificationListener", "lauIp", "listChanged", "1255910ovFXHu", "Bearer ", "finishAuth", "timcZ", "eZwNI", "connect", "JzpWy", "tUMle", "kdowC", "379385gxVFVP", "&token=", "49TIzdXg"];
576
- return X = function() {
577
- return r;
578
- }, X();
579
- }
580
- const ze = async (r) => {
581
- const e = O, t = R, n = { GKDjq: function(g, U, F) {
582
- return g(U, F);
583
- }, JzpWy: e(281), mcbiU: "1.0.0", CfBXU: function(g) {
584
- return g();
585
- }, kdowC: function(g, U, F, K) {
586
- return g(U, F, K);
587
- }, KkViY: "sessionId" }, { client: s, url: o, token: a, sessionId: i, authProvider: c, requestInit: l, eventSourceInit: u, waitForOAuthCode: d } = r, p = {};
588
- p[t(305)] = c, p.requestInit = l, p.eventSourceInit = u;
589
- const f = p, _ = i || H[t(299)](), h = n[e(289)](ce, a, _);
590
- if (l) {
591
- const g = { ...h.requestInit, ...l };
592
- g[t(268)] = { ...h[t(280)][e(268)], ...l.headers }, f.requestInit = g;
593
- } else f.requestInit = h[e(280)];
594
- if (u) {
595
- const g = { ...h[e(270)], ...u };
596
- f.eventSourceInit = g;
597
- } else f.eventSourceInit = h[e(270)];
598
- const m = {};
599
- m[e(254)] = !0;
600
- const v = {};
601
- v.roots = m, v[e(298)] = {}, v[t(303)] = {};
602
- const b = v, C = {};
603
- C.name = n[t(261)], C[e(288)] = n.mcbiU;
604
- const T = {};
605
- T[e(251)] = b;
606
- const w = new j(C, T), L = () => new A(new URL(o), f);
607
- let y = n[e(282)](L);
608
- if (c) {
609
- const g = ue(c, d);
610
- y = await n[e(263)](ne, w, g, L);
611
- } else await w.connect(y);
612
- te(w, s, y), y.sessionId = y[t(274)].searchParams[e(297)](n.KkViY);
613
- const N = {};
614
- return N.transport = y, N.sessionId = y[t(286)], N;
615
- }, Xe = async (r) => {
616
- const e = O, t = R, n = { wfHUn: function(g, U, F) {
617
- return g(U, F);
618
- }, tUMle: "mcp-stream-proxy-client", omKPe: e(248), rSiEq: function(g) {
619
- return g();
620
- }, PdsSn: function(g, U, F, K) {
621
- return g(U, F, K);
622
- } }, { client: s, url: o, token: a, sessionId: i, authProvider: c, requestInit: l, reconnectionOptions: u, waitForOAuthCode: d } = r, p = {};
623
- p.authProvider = c, p.requestInit = l, p.reconnectionOptions = u;
624
- const f = p, _ = i || H.randomUUID(), h = n[t(272)](le, a, _);
625
- if (l) {
626
- const g = { ...h[e(280)], ...l };
627
- g.headers = { ...h.requestInit[e(268)], ...l.headers }, f.requestInit = g;
628
- } else f[t(280)] = h[t(280)];
629
- const m = {};
630
- m[t(254)] = !0;
631
- const v = {};
632
- v.roots = m, v[e(298)] = {}, v[e(303)] = {};
633
- const b = v, C = {};
634
- C.name = n[e(262)], C.version = n.omKPe;
635
- const T = {};
636
- T.capabilities = b;
637
- const w = new j(C, T), L = () => new Q(new URL(o), f);
638
- let y = n.rSiEq(L);
639
- if (c) {
640
- const g = n[e(272)](ue, c, d);
641
- y = await n[e(296)](ne, w, g, L);
642
- } else await w[e(260)](y);
643
- n.PdsSn(te, w, s, y);
644
- const N = {};
645
- return N.transport = y, N[t(286)] = y[t(286)], N;
646
- }, Ye = async (r) => {
647
- const e = R, t = R, n = { eZwNI: function(v, b, C, T) {
648
- return v(b, C, T);
649
- } }, { client: s, url: o, token: a, sessionId: i } = r, c = {};
650
- c[e(254)] = !0;
651
- const l = {};
652
- l[t(290)] = c, l.sampling = {}, l.elicitation = {};
653
- const u = l, d = {};
654
- d.name = "mcp-socket-proxy-client", d.version = t(248);
655
- const p = {};
656
- p[t(251)] = u;
657
- const f = new j(d, p), _ = i || H[t(299)](), h = new oe(new URL(o + "?sessionId=" + _ + t(265) + a));
658
- await f.connect(h), n[e(259)](te, f, s, h);
659
- const m = {};
660
- return m.transport = h, m[t(286)] = _, m;
661
- }, k = S, E = S;
662
- (function(r, e) {
663
- const t = S, n = S, s = r();
664
- for (; ; )
665
- try {
666
- if (parseInt(t(216)) / 1 + -parseInt(n(219)) / 2 + -parseInt(t(203)) / 3 * (-parseInt(n(204)) / 4) + -parseInt(n(199)) / 5 * (parseInt(t(193)) / 6) + -parseInt(t(211)) / 7 * (-parseInt(t(192)) / 8) + -parseInt(n(221)) / 9 + parseInt(n(201)) / 10 * (parseInt(t(220)) / 11) === e) break;
667
- s.push(s.shift());
668
- } catch {
669
- s.push(s.shift());
670
- }
671
- })(Y, 1297719 + -42747 * -22 + -1289197);
672
- function S(r, e) {
673
- const t = Y();
674
- return S = function(n, s) {
675
- return n = n - (-4158 * 1 + -2 * 581 + -1 * -5510), t[n];
676
- }, S(r, e);
677
- }
678
- const Je = () => H.randomBytes(-8746 + -382 * -23);
679
- class it {
680
- constructor(e) {
681
- const t = S, n = S, s = { HbwOh: function(u) {
682
- return u();
683
- } };
684
- this._callBackPromise = {};
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();
687
- }
688
- async redirectCallbackFunction(e) {
689
- var t, n, s, o, a, i;
690
- const c = S, l = S, u = {};
691
- u[c(198)] = "GET";
692
- const d = await fetch(e, u);
693
- !d.ok && ((n = (t = this[l(207)])[l(196)]) == null || n.call(t, c(208) + d[l(205)]));
694
- const p = await this[l(195)](this._redirectUrl, this[c(197)]);
695
- if (!p.ok) {
696
- (o = (s = this[c(207)]).reject) == null || o.call(s, "Failed to fetch auth code: " + p[l(205)]);
697
- return;
698
- }
699
- const f = await p.json();
700
- (i = (a = this._callBackPromise).resolve) == null || i.call(a, f.code);
701
- }
702
- async [k(191)](e, t) {
703
- const n = k, s = {};
704
- s.xAOmI = "POST";
705
- const o = s, a = {};
706
- a["Content-Type"] = n(217);
707
- const i = {};
708
- return i.state = t, fetch(e, { method: o.xAOmI, headers: a, body: new URLSearchParams(i) });
709
- }
710
- waitForOAuthCodeFunction() {
711
- const e = this._callBackPromise;
712
- return () => new Promise((t, n) => {
713
- const s = S;
714
- e.resolve = t, e[s(196)] = n;
715
- });
716
- }
717
- get redirectUrl() {
718
- return this[k(206)];
719
- }
720
- get [E(190)]() {
721
- return this._clientMetadata;
722
- }
723
- [k(213)]() {
724
- return this[k(197)];
725
- }
726
- [E(218)]() {
727
- return this[E(200)];
728
- }
729
- [k(194)](e) {
730
- this._clientInformation = e;
731
- }
732
- tokens() {
733
- return this[E(210)];
734
- }
735
- saveTokens(e) {
736
- const t = E;
737
- this[t(210)] = e;
738
- }
739
- redirectToAuthorization(e) {
740
- this._redirectCallback(e);
741
- }
742
- saveCodeVerifier(e) {
743
- this._codeVerifier = e;
744
- }
745
- [k(212)]() {
746
- const e = k, t = {};
747
- t[e(215)] = e(214);
748
- const n = t;
749
- if (!this[e(209)]) throw new Error(n.mMdVl);
750
- return this[e(209)];
751
- }
752
- }
753
- function Y() {
754
- const r = ["370aKMzOb", "redirectCallbackFunction", "6AWGiLu", "697420WEpDtk", "statusText", "_redirectUrl", "_callBackPromise", "Failed to redirect: ", "_codeVerifier", "_tokens", "21ofrYNd", "codeVerifier", "state", "No code verifier saved", "mMdVl", "1546908KURscU", "application/x-www-form-urlencoded", "clientInformation", "2551694UzDoIS", "571637jVsNJQ", "4355271orhxAD", "clientMetadata", "getAuthCodeByStateFunction", "1400360ybYjeP", "30zRTJNb", "saveClientInformation", "_getAuthCodeByState", "reject", "_state", "method", "1634810cQPomO", "_clientInformation"];
755
- return Y = function() {
756
- return r;
757
- }, Y();
758
- }
759
- (function(r, e) {
760
- for (var t = Z, n = Z, s = r(); ; )
761
- try {
762
- var o = parseInt(t(291)) / 1 + -parseInt(t(295)) / 2 * (parseInt(t(288)) / 3) + parseInt(t(290)) / 4 * (parseInt(t(296)) / 5) + -parseInt(n(289)) / 6 + parseInt(t(293)) / 7 * (-parseInt(n(294)) / 8) + parseInt(n(287)) / 9 + parseInt(n(292)) / 10;
763
- if (o === e) break;
764
- s.push(s.shift());
765
- } catch {
766
- s.push(s.shift());
767
- }
768
- })(J, 262 * -2438 + 1346066 * -1 + 2 * 1373311);
769
- function J() {
770
- var r = ["279100FsqxFu", "7326315yxcNFg", "50823VTWXXj", "6441948uoPUwt", "92BSiBRu", "1361711dyawqa", "5202960gnlAWp", "7tNVFlv", "11056792usEcvw", "90CRWXmt"];
771
- return J = function() {
772
- return r;
773
- }, J();
774
- }
775
- function Z(r, e) {
776
- var t = J();
777
- return Z = function(n, s) {
778
- n = n - 287;
779
- var o = t[n];
780
- return o;
781
- }, Z(r, e);
782
- }
783
- class at {
784
- constructor(e, t) {
785
- const n = {
786
- name: "web-mcp-server",
787
- version: "1.0.0"
788
- }, s = {
789
- prompts: { listChanged: !0 },
790
- resources: { subscribe: !0, listChanged: !0 },
791
- tools: { listChanged: !0 },
792
- completions: {},
793
- logging: {}
794
- };
795
- this.server = new ie(e || n, t || { capabilities: s }), this.server.server.oninitialized = () => {
796
- this.oninitialized?.();
797
- }, this.server.server.onclose = () => {
798
- this.onclose?.();
799
- }, this.server.server.onerror = (o) => {
800
- this.onerror?.(o);
801
- }, this.server.server.setRequestHandler(se, async () => ({}));
802
- }
803
- /**
804
- * Connects the server to a transport via the specified option.
805
- */
806
- async connect(e) {
807
- return typeof e.start == "function" ? (this.transport = e, this.transport.onclose = void 0, this.transport.onerror = void 0, this.transport.onmessage = void 0) : (this.transport = new ee(e), await this.transport.listen()), await this.server.connect(this.transport), this.transport;
808
- }
809
- /**
810
- * Closes the connection.
811
- */
812
- async close() {
813
- await this.server.close();
814
- }
815
- /**
816
- * Registers a tool with a config object and callback.
817
- */
818
- registerTool(e, t, n) {
819
- return this.server.registerTool(e, t, n);
820
- }
821
- /**
822
- * Registers a prompt with a config object and callback.
823
- */
824
- registerPrompt(e, t, n) {
825
- return this.server.registerPrompt(e, t, n);
826
- }
827
- registerResource(e, t, n, s) {
828
- return typeof t == "string" ? this.server.registerResource(e, t, n, s) : this.server.registerResource(e, t, n, s);
829
- }
830
- /**
831
- * Checks if the server is connected to a transport.
832
- * @returns True if the server is connected
833
- */
834
- isConnected() {
835
- return this.server.isConnected();
836
- }
837
- /**
838
- * Sends a resource list changed event to the client, if connected.
839
- */
840
- sendResourceListChanged() {
841
- this.server.sendResourceListChanged();
842
- }
843
- /**
844
- * Sends a tool list changed event to the client, if connected.
845
- */
846
- sendToolListChanged() {
847
- this.server.sendToolListChanged();
848
- }
849
- /**
850
- * Sends a prompt list changed event to the client, if connected.
851
- */
852
- sendPromptListChanged() {
853
- this.server.sendPromptListChanged();
854
- }
855
- /**
856
- * After initialization has completed, this will be populated with the client's reported capabilities.
857
- */
858
- getClientCapabilities() {
859
- return this.server.server.getClientCapabilities();
860
- }
861
- /**
862
- * After initialization has completed, this will be populated with information about the client's name and version.
863
- */
864
- getClientVersion() {
865
- return this.server.server.getClientVersion();
866
- }
867
- /**
868
- * Sends a ping to the client to check if it is still connected.
869
- */
870
- async ping() {
871
- return await this.server.server.ping();
872
- }
873
- /**
874
- * Creates a LLM message to be sent to the client.
875
- */
876
- async createMessage(e, t) {
877
- return await this.server.server.createMessage(e, t);
878
- }
879
- /**
880
- * Elicits input from the client, such as a prompt or resource.
881
- */
882
- async elicitInput(e, t) {
883
- return await this.server.server.elicitInput(e, t);
884
- }
885
- /**
886
- * Lists the root resources available to the client.
887
- */
888
- async listRoots(e, t) {
889
- return await this.server.server.listRoots(e, t);
890
- }
891
- /**
892
- * Sends a logging message to the client.
893
- */
894
- async sendLoggingMessage(e) {
895
- return await this.server.server.sendLoggingMessage(e);
896
- }
897
- /**
898
- * Sends a resource updated notification to the client.
899
- */
900
- async sendResourceUpdated(e) {
901
- return await this.server.server.sendResourceUpdated(e);
902
- }
903
- /**
904
- * Sends a request and wait for a response.
905
- *
906
- * Do not use this method to emit notifications! Use notification() instead.
907
- */
908
- request(e, t, n) {
909
- return this.server.server.request(e, t, n);
910
- }
911
- /**
912
- * Emits a notification, which is a one-way message that does not expect a response.
913
- */
914
- async notification(e, t) {
915
- return await this.server.server.notification(e, t);
916
- }
917
- /**
918
- * Registers a handler to invoke when this protocol object receives a request with the given method.
919
- *
920
- * Note that this will replace any previous request handler for the same method.
921
- */
922
- setRequestHandler(e, t) {
923
- this.server.server.setRequestHandler(e, t);
924
- }
925
- /**
926
- * Removes the request handler for the given method.
927
- */
928
- removeRequestHandler(e) {
929
- this.server.server.removeRequestHandler(e);
930
- }
931
- /**
932
- * Registers a handler to invoke when this protocol object receives a notification with the given method.
933
- *
934
- * Note that this will replace any previous notification handler for the same method.
935
- */
936
- setNotificationHandler(e, t) {
937
- this.server.server.setNotificationHandler(e, t);
938
- }
939
- /**
940
- * Removes the notification handler for the given method.
941
- */
942
- removeNotificationHandler(e) {
943
- this.server.server.removeNotificationHandler(e);
944
- }
945
- /**
946
- * Registers a handler for the subscribe request.
947
- */
948
- onSubscribe(e) {
949
- this.server.server.setRequestHandler(xe, e);
950
- }
951
- /**
952
- * Registers a handler for the unsubscribe request.
953
- */
954
- onUnsubscribe(e) {
955
- this.server.server.setRequestHandler(_e, e);
956
- }
957
- /**
958
- * Registers a handler for the set log level request.
959
- */
960
- onSetLogLevel(e) {
961
- this.server.server.setRequestHandler(se, e);
962
- }
963
- /**
964
- * Registers a handler for the list tools request.
965
- */
966
- onListResources(e) {
967
- this.server.server.setRequestHandler(me, e);
968
- }
969
- /**
970
- * Registers a handler for the roots list changed notification.
971
- */
972
- onRootsListChanged(e) {
973
- this.server.server.setNotificationHandler(ve, e);
974
- }
975
- /**
976
- * Close the transport for window.addEventListener('pagehide')
977
- */
978
- async onPagehide(e) {
979
- e.persisted || this.transport && typeof this.transport.close == "function" && await this.transport.close();
980
- }
981
- }
982
- const ct = (r, e) => new ee(r, e), lt = () => ke(), ut = (r) => r instanceof ee, dt = (r) => r instanceof ie, Ze = (r) => {
983
- const e = () => typeof navigator > "u" ? null : navigator.modelContextTesting || null;
984
- r.onmessage = async (t) => {
985
- if (!t || typeof t != "object") return;
986
- const n = t.id, s = t.method;
987
- try {
988
- if (s === "initialize")
989
- await r.send({
990
- jsonrpc: "2.0",
991
- id: n,
992
- result: {
993
- protocolVersion: "2024-11-05",
994
- capabilities: {
995
- tools: { listChanged: !0 },
996
- logging: {}
997
- },
998
- serverInfo: { name: "browser-builtin-webmcp-proxy", version: "1.0.0" }
999
- }
1000
- });
1001
- else if (s !== "notifications/initialized")
1002
- if (s === "ping" || s === "custom_ping")
1003
- await r.send({ jsonrpc: "2.0", id: n, result: {} });
1004
- else if (s === "tools/list") {
1005
- const o = e();
1006
- if (o && o.listTools) {
1007
- const i = (await o.listTools()).map((c) => {
1008
- let l = {};
1009
- if (typeof c.inputSchema == "string")
1010
- try {
1011
- l = JSON.parse(c.inputSchema);
1012
- } catch (u) {
1013
- console.error("Failed to parse inputSchema:", u);
1014
- }
1015
- else typeof c.inputSchema == "object" && c.inputSchema !== null && (l = c.inputSchema);
1016
- return {
1017
- name: c.name,
1018
- description: c.description || "",
1019
- inputSchema: {
1020
- type: "object",
1021
- properties: l.properties || {},
1022
- required: l.required || []
1023
- }
1024
- };
1025
- });
1026
- await r.send({ jsonrpc: "2.0", id: n, result: { tools: i } });
1027
- } else
1028
- await r.send({ jsonrpc: "2.0", id: n, result: { tools: [] } });
1029
- } else if (s === "tools/call") {
1030
- const o = e();
1031
- if (o && o.executeTool) {
1032
- if (!t.params || typeof t.params != "object" || !t.params.name) {
1033
- const u = new Error('Invalid params: "name" is required and params must be an object');
1034
- throw u.code = -32602, u;
1035
- }
1036
- const { name: a, arguments: i } = t.params, c = await o.executeTool(a, JSON.stringify(i || {})), l = c && typeof c == "object" && "content" in c ? c : { content: [{ type: "text", text: typeof c == "string" ? c : JSON.stringify(c) }] };
1037
- await r.send({ jsonrpc: "2.0", id: n, result: l });
1038
- } else {
1039
- const a = new Error("executeTool not implemented in Browser built-in WebMCP");
1040
- throw a.code = -32601, a;
1041
- }
1042
- } else s === "logging/setLevel" ? await r.send({ jsonrpc: "2.0", id: n, result: {} }) : s === "prompts/list" ? await r.send({ jsonrpc: "2.0", id: n, result: { prompts: [] } }) : s === "resources/list" ? await r.send({ jsonrpc: "2.0", id: n, result: { resources: [] } }) : n !== void 0 && await r.send({
1043
- jsonrpc: "2.0",
1044
- id: n,
1045
- error: { code: -32601, message: `Method not found: ${s}` }
1046
- });
1047
- } catch (o) {
1048
- n !== void 0 && await r.send({
1049
- jsonrpc: "2.0",
1050
- id: n,
1051
- error: { code: o.code || -32e3, message: o.message || String(o) }
1052
- });
1053
- }
1054
- };
1055
- };
1056
- class pt {
1057
- constructor(e, t) {
1058
- const n = {
1059
- name: "web-mcp-client",
1060
- version: "1.0.0"
1061
- }, s = {
1062
- roots: { listChanged: !0 },
1063
- sampling: {},
1064
- elicitation: {}
1065
- };
1066
- this.client = new j(e || n, t || { capabilities: s }), this.client.onclose = () => {
1067
- this.onclose?.();
1068
- }, this.client.onerror = (o) => {
1069
- this.onerror?.(o);
1070
- };
1071
- }
1072
- /**
1073
- * Connects the client to a transport via the specified option.
1074
- */
1075
- async connect(e) {
1076
- if (typeof e.start == "function")
1077
- return this.transport = e, this.transport.onclose = void 0, this.transport.onerror = void 0, this.transport.onmessage = void 0, await this.client.connect(this.transport), { transport: this.transport, sessionId: this.transport.sessionId };
1078
- const { url: t, token: n, sessionId: s, type: o, agent: a, builtin: i, onError: c } = e;
1079
- if (a) {
1080
- const d = { client: this.client, url: t, token: n, sessionId: s }, p = o === "sse" ? await ze(d) : o === "socket" ? await Ye(d) : await Xe(d);
1081
- return p.transport.onerror = async (f) => {
1082
- c?.(f);
1083
- }, i && Ze(p.transport), p;
1084
- }
1085
- const l = new URL(t);
1086
- let u;
1087
- if (o === "channel" && (u = new $(t), await this.client.connect(u)), o === "sse") {
1088
- const d = ce(n, s);
1089
- u = new A(l, d), await this.client.connect(u);
1090
- }
1091
- if (o === "socket" && (u = new oe(new URL(`${t}?sessionId=${s}&token=${n}`)), u.sessionId = s, await this.client.connect(u)), o === "stream" || typeof u > "u") {
1092
- const d = le(n, s);
1093
- u = new Q(l, d), await this.client.connect(u);
1094
- }
1095
- return this.transport = u, { transport: this.transport, sessionId: this.transport.sessionId };
1096
- }
1097
- /**
1098
- * Closes the connection.
1099
- */
1100
- async close() {
1101
- await this.client.close();
1102
- }
1103
- /**
1104
- * After initialization has completed, this will be populated with the server's reported capabilities.
1105
- */
1106
- getServerCapabilities() {
1107
- return this.client.getServerCapabilities();
1108
- }
1109
- /**
1110
- * After initialization has completed, this will be populated with information about the server's name and version.
1111
- */
1112
- getServerVersion() {
1113
- return this.client.getServerVersion();
1114
- }
1115
- /**
1116
- * After initialization has completed, this may be populated with information about the server's instructions.
1117
- */
1118
- getInstructions() {
1119
- return this.client.getInstructions();
1120
- }
1121
- /**
1122
- * Sends a ping to the server to check if it is still connected.
1123
- */
1124
- async ping(e) {
1125
- return await this.client.ping(e);
1126
- }
1127
- /**
1128
- * Sends a completion request to the server.
1129
- */
1130
- async complete(e, t) {
1131
- return await this.client.complete(e, t);
1132
- }
1133
- /**
1134
- * Sends a request for setting the logging level to the server.
1135
- */
1136
- async setLoggingLevel(e, t) {
1137
- return await this.client.setLoggingLevel(e, t);
1138
- }
1139
- /**
1140
- * Gets the prompt with the given params from the server.
1141
- */
1142
- async getPrompt(e, t) {
1143
- return await this.client.getPrompt(e, t);
1144
- }
1145
- /**
1146
- * Lists all prompts available on the server.
1147
- */
1148
- async listPrompts(e, t) {
1149
- return await this.client.listPrompts(e, t);
1150
- }
1151
- /**
1152
- * Lists all resources available on the server.
1153
- */
1154
- async listResources(e, t) {
1155
- return await this.client.listResources(e, t);
1156
- }
1157
- /**
1158
- * Lists all resource templates available on the server.
1159
- */
1160
- async listResourceTemplates(e, t) {
1161
- return await this.client.listResourceTemplates(e, t);
1162
- }
1163
- /**
1164
- * Reads the resource with the given params from the server.
1165
- */
1166
- async readResource(e, t) {
1167
- return await this.client.readResource(e, t);
1168
- }
1169
- /**
1170
- * Subscribes to a resource on the server.
1171
- */
1172
- async subscribeResource(e, t) {
1173
- return await this.client.subscribeResource(e, t);
1174
- }
1175
- /**
1176
- * Unsubscribes from a resource on the server.
1177
- */
1178
- async unsubscribeResource(e, t) {
1179
- return await this.client.unsubscribeResource(e, t);
1180
- }
1181
- /**
1182
- * Calls a tool on the server with the given parameters.
1183
- */
1184
- async callTool(e, t) {
1185
- return await this.client.callTool(e, ge, t);
1186
- }
1187
- /**
1188
- * Lists all tools available on the server.
1189
- */
1190
- async listTools(e, t) {
1191
- return await this.client.listTools(e, t);
1192
- }
1193
- /**
1194
- * Sends a notification for the roots list changed event to the server.
1195
- */
1196
- async sendRootsListChanged() {
1197
- return await this.client.sendRootsListChanged();
1198
- }
1199
- /**
1200
- * Sends a request and wait for a response.
1201
- *
1202
- * Do not use this method to emit notifications! Use notification() instead.
1203
- */
1204
- request(e, t, n) {
1205
- return this.client.request(e, t, n);
1206
- }
1207
- /**
1208
- * Emits a notification, which is a one-way message that does not expect a response.
1209
- */
1210
- async notification(e, t) {
1211
- return await this.client.notification(e, t);
1212
- }
1213
- /**
1214
- * Registers a handler to invoke when this protocol object receives a request with the given method.
1215
- *
1216
- * Note that this will replace any previous request handler for the same method.
1217
- */
1218
- setRequestHandler(e, t) {
1219
- this.client.setRequestHandler(e, t);
1220
- }
1221
- /**
1222
- * Removes the request handler for the given method.
1223
- */
1224
- removeRequestHandler(e) {
1225
- this.client.removeRequestHandler(e);
1226
- }
1227
- /**
1228
- * Registers a handler to invoke when this protocol object receives a notification with the given method.
1229
- *
1230
- * Note that this will replace any previous notification handler for the same method.
1231
- */
1232
- setNotificationHandler(e, t) {
1233
- this.client.setNotificationHandler(e, t);
1234
- }
1235
- /**
1236
- * Removes the notification handler for the given method.
1237
- */
1238
- removeNotificationHandler(e) {
1239
- this.client.removeNotificationHandler(e);
1240
- }
1241
- /**
1242
- * Registers a handler for the elicitation request.
1243
- */
1244
- onElicit(e) {
1245
- this.client.setRequestHandler(we, e);
1246
- }
1247
- /**
1248
- * Registers a handler for the create LLM message request.
1249
- */
1250
- onCreateMessage(e) {
1251
- this.client.setRequestHandler(be, e);
1252
- }
1253
- /**
1254
- * Registers a handler for the list roots request.
1255
- */
1256
- onListRoots(e) {
1257
- this.client.setRequestHandler(ye, e);
1258
- }
1259
- /**
1260
- * Registers a handler for the tool list changed notification.
1261
- */
1262
- onToolListChanged(e) {
1263
- this.client.setNotificationHandler(Ie, e);
1264
- }
1265
- /**
1266
- * Registers a handler for the prompt list changed notification.
1267
- */
1268
- onPromptListChanged(e) {
1269
- this.client.setNotificationHandler(Ce, e);
1270
- }
1271
- /**
1272
- * Registers a handler for the resource list changed notification.
1273
- */
1274
- onResourceListChanged(e) {
1275
- this.client.setNotificationHandler(Se, e);
1276
- }
1277
- /**
1278
- * Registers a handler for the resource updated notification.
1279
- */
1280
- onResourceUpdated(e) {
1281
- this.client.setNotificationHandler(Re, e);
1282
- }
1283
- /**
1284
- * Registers a handler for the logging message notification.
1285
- */
1286
- onLoggingMessage(e) {
1287
- this.client.setNotificationHandler(Le, e);
1288
- }
1289
- /**
1290
- * Close the transport for window.addEventListener('pagehide')
1291
- */
1292
- async onPagehide(e) {
1293
- e.persisted || (Qe(this.transport) ? await this.transport.terminateSession() : this.transport && typeof this.transport.close == "function" && await this.transport.close());
1294
- }
1295
- }
1296
- const ft = (r, e) => new A(r, e), ht = (r, e) => new Q(r, e), xt = (r, e) => new $(r, e), _t = (r) => r instanceof A, Qe = (r) => r instanceof Q, mt = (r) => r instanceof $, vt = (r) => r instanceof j, Ke = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
1297
- const e = Math.random() * 16 | 0;
1298
- return (r === "x" ? e : e & 3 | 8).toString(16);
1299
- }), V = (r, e, t) => {
1300
- window.postMessage({ type: r, direction: t, data: e }, "*");
1301
- }, Ge = (r, e, t) => {
1302
- const n = async function(s) {
1303
- s.source === window && s.data.type === r && s.data.direction === t && await e(s.data.data);
1304
- };
1305
- return window.addEventListener("message", n), () => window.removeEventListener("message", n);
1306
- };
1307
- class gt {
1308
- constructor(e = null) {
1309
- this._isStarted = !1, this._isClosed = !1, this._lastRegistration = null, this.sessionId = e || Ke(), this._messageListener2 = Ge(
1310
- "mcp-client-to-server-to-page",
1311
- (t) => {
1312
- if (t.sessionId !== this.sessionId) return;
1313
- console.log("【Page Svr Transport】 即将处理 mcpMessage", t.mcpMessage);
1314
- const n = re.parse(t.mcpMessage);
1315
- this.onmessage?.(n), t.mcpMessage.params?.name && V(
1316
- "update-page-app-message",
1317
- { status: "run", message: t.mcpMessage.params?.name },
1318
- "page->content"
1319
- );
1320
- },
1321
- "content->page"
1322
- );
1323
- }
1324
- // 最后一次注册信息(用于 Sidepanel 刷新后重新注册)
1325
- _throwError(e, t) {
1326
- if (e()) {
1327
- const n = new Error(t);
1328
- throw console.log(t, n), this.onerror && this.onerror(n), n;
1329
- }
1330
- }
1331
- /** 启动 transport,开始监听消息 */
1332
- async start() {
1333
- if (!this._isStarted) {
1334
- if (this._isClosed) throw new Error("【Page Svr Transport】 已关闭,无法重新启动");
1335
- this._isStarted = !0;
1336
- }
1337
- }
1338
- /** 发送消息到 MCP Client */
1339
- async send(e, t) {
1340
- this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法发送消息"), this._throwError(() => this._isClosed, "【Page Svr Transport】 已关闭,无法发送消息"), V(
1341
- "mcp-server-to-client-from-page",
1342
- {
1343
- sessionId: this.sessionId,
1344
- mcpMessage: e
1345
- },
1346
- "page->content"
1347
- ), "result" in e && e.result?.content && V(
1348
- "update-page-app-message",
1349
- { status: "ready", message: "" },
1350
- "page->content"
1351
- // 此处应该是 content->content, 但为了和pageServerTransport统一。
1352
- );
1353
- }
1354
- /** 通知 Sidepanel 此 Server 已启动并准备接受连接 */
1355
- async notifyRegistration(e) {
1356
- this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法注册消息"), this._lastRegistration = e;
1357
- try {
1358
- V(
1359
- "mcp-server-register-from-page",
1360
- {
1361
- sessionId: this.sessionId,
1362
- serverInfo: {
1363
- ...e,
1364
- url: window.location.origin,
1365
- title: document.title
1366
- }
1367
- },
1368
- "page->content"
1369
- );
1370
- } catch (t) {
1371
- this._throwError(() => !0, "【Page Svr Transport】 注册 server 失败" + String(t));
1372
- }
1373
- }
1374
- /** 关闭 transport */
1375
- async close() {
1376
- if (!this._isClosed)
1377
- try {
1378
- this._messageListener2 && this._messageListener2(), this._isClosed = !0, this._isStarted = !1, this.onclose && this.onclose();
1379
- } catch (e) {
1380
- this._throwError(() => !0, "【Page Svr Transport】 关闭时发生错误" + String(e));
1381
- }
1382
- }
1383
- }
1384
- export {
1385
- yt as Ajv,
1386
- it as AuthClientProvider,
1387
- gt as ExtensionPageServerTransport,
1388
- Ct as ResourceTemplate,
1389
- Tt as UriTemplate,
1390
- pt as WebMcpClient,
1391
- at as WebMcpServer,
1392
- qt as completable,
1393
- xt as createMessageChannelClientTransport,
1394
- lt as createMessageChannelPairTransport,
1395
- ct as createMessageChannelServerTransport,
1396
- ft as createSSEClientTransport,
1397
- ht as createStreamableHTTPClientTransport,
1398
- Mt as getDisplayName,
1399
- vt as isMcpClient,
1400
- dt as isMcpServer,
1401
- mt as isMessageChannelClientTransport,
1402
- ut as isMessageChannelServerTransport,
1403
- _t as isSSEClientTransport,
1404
- Qe as isStreamableHTTPClientTransport,
1405
- Rt as z
1406
- };