@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
@@ -1,1589 +0,0 @@
1
- import { default as default2 } from "ajv";
2
- import { JSONRPCMessageSchema, EmptyResultSchema, ElicitResultSchema, CreateMessageResultSchema, ListRootsResultSchema, SetLevelRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema, ListResourcesRequestSchema, RootsListChangedNotificationSchema, CallToolResultSchema, ElicitRequestSchema, CreateMessageRequestSchema, ListRootsRequestSchema, ToolListChangedNotificationSchema, PromptListChangedNotificationSchema, ResourceListChangedNotificationSchema, ResourceUpdatedNotificationSchema, LoggingMessageNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
3
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
- import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
5
- import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
6
- import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";
7
- import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
8
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9
- import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
10
- import { z } from "zod";
11
- import { UriTemplate } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
12
- import { completable } from "@modelcontextprotocol/sdk/server/completable.js";
13
- import { getDisplayName } from "@modelcontextprotocol/sdk/shared/metadataUtils.js";
14
- const _0x4f2826 = _0xad7a;
15
- (function(_0x5153c5, _0x3abbea) {
16
- const _0x5f186f = _0xad7a, _0x3f8155 = _0xad7a, _0x5ad68c = _0x5153c5();
17
- while (!![]) {
18
- try {
19
- const _0x1209c2 = parseInt(_0x5f186f(403)) / (-1 * -8962 + 7125 + -1 * 16086) + -parseInt(_0x5f186f(411)) / (-118 * -62 + 5798 + -298 * 44) * (-parseInt(_0x3f8155(406)) / (-3602 + 4764 + -1159 * 1)) + -parseInt(_0x3f8155(425)) / (-878 * 8 + 6350 + 678) * (parseInt(_0x5f186f(387)) / (-2471 + -7095 + 9571)) + -parseInt(_0x3f8155(426)) / (-1158 + 4090 + -266 * 11) + parseInt(_0x3f8155(395)) / (-5007 + 205 * 3 + 83 * 53) * (-parseInt(_0x5f186f(419)) / (-4925 + 9223 + -4290)) + -parseInt(_0x5f186f(413)) / (8348 + -7962 + -1 * 377) + parseInt(_0x3f8155(400)) / (-1828 + 1230 + 608);
20
- if (_0x1209c2 === _0x3abbea) break;
21
- else _0x5ad68c["push"](_0x5ad68c["shift"]());
22
- } catch (_0x3c6d23) {
23
- _0x5ad68c["push"](_0x5ad68c["shift"]());
24
- }
25
- }
26
- })(_0xf7c7, -118057 + 3521 * -35 + -2099 * -233);
27
- const getGlobalObject = () => {
28
- const _0x5b06d9 = _0xad7a, _0x55441c = _0xad7a, _0x3922ee = {};
29
- _0x3922ee[_0x5b06d9(420)] = "3|0|2|1|4", _0x3922ee["vQYJZ"] = function(_0x5e2b69, _0x44350c) {
30
- return _0x5e2b69 !== _0x44350c;
31
- }, _0x3922ee[_0x55441c(394)] = _0x55441c(414), _0x3922ee["ktWqD"] = function(_0x187cae, _0x331f13) {
32
- return _0x187cae !== _0x331f13;
33
- }, _0x3922ee[_0x5b06d9(424)] = _0x5b06d9(391);
34
- const _0x4bc984 = _0x3922ee, _0x58c960 = _0x4bc984[_0x55441c(420)]["split"]("|");
35
- let _0x55d9fc = 859 * 2 + -3 * -1039 + -4835 * 1;
36
- while (!![]) {
37
- switch (_0x58c960[_0x55d9fc++]) {
38
- case "0":
39
- if (_0x4bc984[_0x55441c(407)](typeof window, "undefined")) return window;
40
- continue;
41
- case "1":
42
- if (_0x4bc984["vQYJZ"](typeof self, _0x4bc984["NZmUq"])) return self;
43
- continue;
44
- case "2":
45
- if (_0x4bc984[_0x55441c(405)](typeof global, "undefined")) return global;
46
- continue;
47
- case "3":
48
- if (_0x4bc984[_0x55441c(405)](typeof globalThis, _0x4bc984[_0x5b06d9(394)])) return globalThis;
49
- continue;
50
- case "4":
51
- return Function(_0x4bc984[_0x5b06d9(424)])();
52
- }
53
- break;
54
- }
55
- }, sendMessage = (_0x35d0b8, _0xeea47, _0xfb13f6) => {
56
- const _0x348bd2 = _0xad7a, _0x30ad92 = _0xad7a, _0x31ab0f = {};
57
- _0x31ab0f["eOzBp"] = function(_0xa5b644, _0x9c2e17) {
58
- return _0xa5b644 !== _0x9c2e17;
59
- }, _0x31ab0f["ooaJk"] = "undefined", _0x31ab0f[_0x348bd2(402)] = function(_0x3bec39, _0x3d0904) {
60
- return _0x3bec39 === _0x3d0904;
61
- }, _0x31ab0f[_0x348bd2(421)] = "function";
62
- const _0x3ab65e = _0x31ab0f;
63
- if (_0x3ab65e[_0x30ad92(389)](typeof window, _0x3ab65e["ooaJk"])) _0x35d0b8[_0x30ad92(423)](_0xeea47, "*", _0xfb13f6);
64
- else _0x348bd2(423) in _0x35d0b8 && _0x3ab65e["pTvSc"](typeof _0x35d0b8[_0x30ad92(423)], _0x3ab65e[_0x348bd2(421)]) && _0x35d0b8["postMessage"](_0xeea47, _0xfb13f6);
65
- }, setMessageHandler = (_0x47e26b, _0x56d6f3) => {
66
- const _0x3198b3 = _0xad7a, _0x178e44 = _0xad7a, _0x878ed8 = {};
67
- _0x878ed8["nTCfA"] = function(_0x161049, _0x23c671) {
68
- return _0x161049 in _0x23c671;
69
- }, _0x878ed8[_0x3198b3(390)] = "addEventListener", _0x878ed8[_0x3198b3(385)] = function(_0x113571, _0x525d77) {
70
- return _0x113571 === _0x525d77;
71
- }, _0x878ed8[_0x3198b3(409)] = "function", _0x878ed8["VaHpd"] = _0x178e44(392), _0x878ed8[_0x178e44(384)] = _0x3198b3(417), _0x878ed8["FPOYW"] = function(_0x450905, _0x43bced) {
72
- return _0x450905 !== _0x43bced;
73
- };
74
- const _0xbc5ca5 = _0x878ed8;
75
- if (_0xbc5ca5["nTCfA"](_0xbc5ca5["ogKey"], _0x47e26b) && _0xbc5ca5[_0x178e44(385)](typeof _0x47e26b["addEventListener"], _0xbc5ca5[_0x178e44(409)])) _0x47e26b[_0x178e44(386)](_0xbc5ca5["VaHpd"], _0x56d6f3);
76
- else _0xbc5ca5[_0x178e44(384)] in _0x47e26b && _0xbc5ca5[_0x3198b3(398)](typeof _0x47e26b[_0x178e44(417)], _0x3198b3(414)) && (_0x47e26b["onmessage"] = _0x56d6f3);
77
- };
78
- class MessageChannelTransport {
79
- constructor(_0x34a0c2) {
80
- this["_port"] = _0x34a0c2;
81
- }
82
- async [_0x4f2826(401)]() {
83
- const _0x128b02 = _0x4f2826, _0x5486a4 = _0x4f2826;
84
- if (!this[_0x128b02(422)]) return;
85
- this[_0x5486a4(422)]["onmessage"] = (_0x589d80) => {
86
- var _a, _b;
87
- const _0x48ea76 = _0x128b02;
88
- try {
89
- const _0xb2e035 = JSONRPCMessageSchema["parse"](_0x589d80["data"]["message"]);
90
- (_a = this["onmessage"]) == null ? void 0 : _a.call(this, _0xb2e035, _0x589d80[_0x48ea76(412)][_0x48ea76(428)]);
91
- } catch (_0x28fd34) {
92
- const _0x19f373 = new Error("MessageChannel failed to parse message: " + _0x28fd34);
93
- (_b = this[_0x48ea76(383)]) == null ? void 0 : _b.call(this, _0x19f373);
94
- }
95
- }, this["_port"]["onmessageerror"] = (_0xf11ae3) => {
96
- var _a;
97
- const _0x2e8678 = _0x5486a4, _0x2174a2 = new Error("MessageChannel transport error: " + JSON[_0x2e8678(415)](_0xf11ae3));
98
- (_a = this["onerror"]) == null ? void 0 : _a.call(this, _0x2174a2);
99
- }, this[_0x5486a4(422)]["start"]();
100
- }
101
- async ["send"](_0x53414e, _0x1fad39) {
102
- const _0x242e50 = { "EoBZE": function(_0x5dfbdd) {
103
- return _0x5dfbdd();
104
- }, "leEiG": function(_0x2c92ea, _0x3a00c7) {
105
- return _0x2c92ea instanceof _0x3a00c7;
106
- }, "cDUwk": function(_0x502cb0, _0x62d20e) {
107
- return _0x502cb0(_0x62d20e);
108
- } };
109
- return new Promise((_0x27cc57, _0x179db2) => {
110
- var _a;
111
- const _0x1ce41e = _0xad7a, _0x5396c7 = _0xad7a;
112
- try {
113
- const _0x4c1128 = {};
114
- _0x4c1128[_0x1ce41e(404)] = _0x1fad39 == null ? void 0 : _0x1fad39[_0x1ce41e(404)];
115
- const _0x2b6c6f = {};
116
- _0x2b6c6f[_0x1ce41e(392)] = _0x53414e, _0x2b6c6f["extra"] = _0x4c1128;
117
- if (this["_port"]) this["_port"][_0x5396c7(423)](_0x2b6c6f);
118
- _0x242e50[_0x1ce41e(399)](_0x27cc57);
119
- } catch (_0xd49ca8) {
120
- const _0x306c32 = _0x242e50["leEiG"](_0xd49ca8, Error) ? _0xd49ca8 : new Error(_0x242e50["cDUwk"](String, _0xd49ca8));
121
- (_a = this["onerror"]) == null ? void 0 : _a.call(this, _0x306c32), _0x179db2(_0x306c32);
122
- }
123
- });
124
- }
125
- async ["close"]() {
126
- var _a, _b;
127
- const _0x45fe11 = _0x4f2826, _0x27cc50 = _0x4f2826;
128
- (_a = this["_port"]) == null ? void 0 : _a[_0x45fe11(393)](), this[_0x45fe11(422)] = void 0, (_b = this[_0x27cc50(408)]) == null ? void 0 : _b.call(this);
129
- }
130
- }
131
- class MessageChannelClientTransport extends MessageChannelTransport {
132
- constructor(_0x20201a, _0x4e42d0 = getGlobalObject()) {
133
- const _0xe917b4 = _0x4f2826, _0x2ee57a = { "lSpBh": function(_0x15fcf6, _0xd26994, _0x5aabc7, _0x5b05d2) {
134
- return _0x15fcf6(_0xd26994, _0x5aabc7, _0x5b05d2);
135
- } };
136
- super(), this["_endpoint"] = _0x20201a, this["_globalObject"] = _0x4e42d0;
137
- const _0x24f521 = new MessageChannel();
138
- this["_port"] = _0x24f521[_0xe917b4(410)], _0x2ee57a[_0xe917b4(418)](sendMessage, this["_globalObject"], { "endpoint": this[_0xe917b4(397)] }, [_0x24f521[_0xe917b4(429)]]);
139
- }
140
- }
141
- class MessageChannelServerTransport extends MessageChannelTransport {
142
- constructor(_0x3de1c8, _0x3c4f19 = getGlobalObject()) {
143
- const _0x2eab2a = _0x4f2826, _0x26e754 = _0x4f2826, _0x496337 = { "HITdC": function(_0xf4906b, _0x545503) {
144
- return _0xf4906b === _0x545503;
145
- }, "QdDxM": function(_0xe02af1) {
146
- return _0xe02af1();
147
- }, "jowPp": function(_0x44b8f3, _0x17adcb, _0xc8cd9d) {
148
- return _0x44b8f3(_0x17adcb, _0xc8cd9d);
149
- } };
150
- super(), this[_0x2eab2a(397)] = _0x3de1c8, this[_0x26e754(388)] = _0x3c4f19, this[_0x26e754(416)] = new Promise((_0x1e1df9) => {
151
- const _0x5d87de = _0x2eab2a, _0xb8f004 = { "XlglK": function(_0xfd91d5, _0x4e700d) {
152
- return _0x496337["HITdC"](_0xfd91d5, _0x4e700d);
153
- }, "pXlad": function(_0x35325b) {
154
- return _0x496337["QdDxM"](_0x35325b);
155
- } };
156
- _0x496337[_0x5d87de(427)](setMessageHandler, this["_globalObject"], (_0x594651) => {
157
- const _0x598787 = _0x5d87de, _0x338e8d = _0x5d87de;
158
- _0x594651[_0x598787(412)] && _0xb8f004["XlglK"](_0x594651["data"][_0x338e8d(396)], this["_endpoint"]) && (this[_0x598787(422)] = _0x594651[_0x338e8d(430)][122 * -38 + 1600 + -1518 * -2], _0xb8f004["pXlad"](_0x1e1df9));
159
- });
160
- });
161
- }
162
- async ["listen"]() {
163
- return this["_listen"];
164
- }
165
- }
166
- function _0xf7c7() {
167
- const _0x217378 = ["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"];
168
- _0xf7c7 = function() {
169
- return _0x217378;
170
- };
171
- return _0xf7c7();
172
- }
173
- function _0xad7a(_0x5c8efe, _0x17336f) {
174
- const _0x4b62f0 = _0xf7c7();
175
- return _0xad7a = function(_0x222a68, _0x35aa14) {
176
- _0x222a68 = _0x222a68 - (9175 + 8052 + 1 * -16844);
177
- let _0x4cf37b = _0x4b62f0[_0x222a68];
178
- return _0x4cf37b;
179
- }, _0xad7a(_0x5c8efe, _0x17336f);
180
- }
181
- const createTransportPair = () => {
182
- const _0x4bcc62 = new MessageChannel();
183
- return [new MessageChannelTransport(_0x4bcc62["port1"]), new MessageChannelTransport(_0x4bcc62["port2"])];
184
- };
185
- (function(_0x3d7f1e, _0xfc81c8) {
186
- const _0x276c7b = _0x21a3, _0x2dfe35 = _0x21a3, _0x234d86 = _0x3d7f1e();
187
- while (!![]) {
188
- try {
189
- const _0x380f07 = parseInt(_0x276c7b(452)) / (-9341 * 1 + 3580 + 5762) * (parseInt(_0x2dfe35(441)) / (-6775 + 1161 + 16 * 351)) + parseInt(_0x2dfe35(434)) / (-4159 + -9100 + -349 * -38) * (-parseInt(_0x2dfe35(418)) / (6 * -1155 + 1020 * 9 + 2246 * -1)) + parseInt(_0x276c7b(459)) / (-2939 * -1 + -7622 + 4688) + parseInt(_0x276c7b(482)) / (8451 * 1 + 426 * 14 + -14409) * (-parseInt(_0x276c7b(479)) / (8180 + 7314 + -17 * 911)) + -parseInt(_0x276c7b(458)) / (6370 + -4744 + -1618) * (parseInt(_0x276c7b(457)) / (10 * 983 + 2949 * -3 + -487 * 2)) + -parseInt(_0x2dfe35(416)) / (-1 * -8615 + 9674 + -18279) + -parseInt(_0x276c7b(450)) / (-9359 + 3829 + 5541) * (-parseInt(_0x276c7b(433)) / (6146 + -143 * 39 + 1 * -557));
190
- if (_0x380f07 === _0xfc81c8) break;
191
- else _0x234d86["push"](_0x234d86["shift"]());
192
- } catch (_0x1d5794) {
193
- _0x234d86["push"](_0x234d86["shift"]());
194
- }
195
- }
196
- })(_0x3610, -411935 * 1 + 228107 + 208149 * 2);
197
- const forwardServerRequest = async (_0x1da138, _0x46e2a5, _0xa7e9d) => {
198
- var _a;
199
- const _0x334ed0 = _0x21a3, _0x4f511c = _0x21a3, _0x249fa5 = {};
200
- _0x249fa5["VRyiJ"] = "tools/list", _0x249fa5["VkPYu"] = "tools/call", _0x249fa5[_0x334ed0(475)] = _0x334ed0(411), _0x249fa5["SoCaE"] = "resources/templates/list", _0x249fa5[_0x4f511c(484)] = "resources/read", _0x249fa5[_0x334ed0(461)] = "prompts/get", _0x249fa5["srIIC"] = _0x4f511c(477), _0x249fa5[_0x4f511c(436)] = _0x4f511c(478), _0x249fa5[_0x4f511c(442)] = _0x334ed0(437), _0x249fa5["dEmVs"] = _0x334ed0(465);
201
- const _0x472708 = _0x249fa5, { id: _0x467a84, method: _0x866073, params: _0x4698ee } = _0xa7e9d;
202
- let _0x413eb6 = {};
203
- switch (_0x866073) {
204
- case _0x472708["VRyiJ"]:
205
- _0x413eb6 = await _0x46e2a5["listTools"](_0x4698ee);
206
- break;
207
- case _0x472708["VkPYu"]:
208
- _0x413eb6 = await _0x46e2a5["callTool"](_0x4698ee);
209
- break;
210
- case _0x472708["fgMSD"]:
211
- _0x413eb6 = await _0x46e2a5["listResources"](_0x4698ee);
212
- break;
213
- case _0x472708[_0x4f511c(466)]:
214
- _0x413eb6 = await _0x46e2a5["listResourceTemplates"](_0x4698ee);
215
- break;
216
- case _0x472708["sthgI"]:
217
- _0x413eb6 = await _0x46e2a5[_0x334ed0(455)](_0x4698ee);
218
- break;
219
- case _0x4f511c(486):
220
- _0x413eb6 = await _0x46e2a5["subscribeResource"](_0x4698ee);
221
- break;
222
- case _0x334ed0(410):
223
- _0x413eb6 = await _0x46e2a5["unsubscribeResource"](_0x4698ee);
224
- break;
225
- case _0x472708[_0x4f511c(461)]:
226
- _0x413eb6 = await _0x46e2a5[_0x4f511c(414)](_0x4698ee);
227
- break;
228
- case _0x472708[_0x334ed0(412)]:
229
- _0x413eb6 = await _0x46e2a5[_0x334ed0(491)](_0x4698ee);
230
- break;
231
- case _0x472708[_0x334ed0(436)]:
232
- _0x413eb6 = await _0x46e2a5[_0x334ed0(478)]();
233
- break;
234
- case _0x472708["kkNqg"]:
235
- _0x413eb6 = await _0x46e2a5["complete"](_0x4698ee);
236
- break;
237
- case _0x334ed0(464):
238
- _0x413eb6 = await _0x46e2a5["setLoggingLevel"](_0x4698ee == null ? void 0 : _0x4698ee[_0x4f511c(443)]);
239
- break;
240
- }
241
- const _0x58de11 = {};
242
- _0x58de11["result"] = _0x413eb6, _0x58de11["jsonrpc"] = _0x472708[_0x4f511c(472)], _0x58de11["id"] = _0x467a84, await ((_a = _0x1da138 == null ? void 0 : _0x1da138[_0x4f511c(488)]) == null ? void 0 : _a[_0x334ed0(460)](_0x58de11));
243
- }, forwardClientRequest = async (_0x28a0ac, _0x338cef, _0x40baf5) => {
244
- var _a;
245
- const _0x5efcdf = _0x21a3, _0x450048 = _0x21a3, _0x2c33ce = {};
246
- _0x2c33ce[_0x5efcdf(487)] = _0x450048(462), _0x2c33ce["ypHTC"] = "ping", _0x2c33ce["fPExS"] = _0x5efcdf(465);
247
- const _0x319e5f = _0x2c33ce, { id: _0x70260b, method: _0x3f464d, params: _0x362734 } = _0x40baf5;
248
- let _0xc56c52 = {};
249
- switch (_0x3f464d) {
250
- case "roots/list":
251
- const _0x408740 = {};
252
- _0x408740["method"] = _0x3f464d, _0x408740[_0x450048(446)] = _0x362734, _0xc56c52 = await _0x338cef[_0x5efcdf(469)](_0x408740, ListRootsResultSchema);
253
- break;
254
- case "sampling/createMessage":
255
- const _0x14dd4f = {};
256
- _0x14dd4f[_0x5efcdf(481)] = _0x3f464d, _0x14dd4f[_0x5efcdf(446)] = _0x362734, _0xc56c52 = await _0x338cef["request"](_0x14dd4f, CreateMessageResultSchema);
257
- break;
258
- case _0x319e5f[_0x5efcdf(487)]:
259
- const _0x5991f6 = {};
260
- _0x5991f6["method"] = _0x3f464d, _0x5991f6[_0x450048(446)] = _0x362734, _0xc56c52 = await _0x338cef["request"](_0x5991f6, ElicitResultSchema);
261
- break;
262
- case _0x319e5f["ypHTC"]:
263
- const _0x41ab78 = {};
264
- _0x41ab78["method"] = _0x3f464d, _0xc56c52 = await _0x338cef["request"](_0x41ab78, EmptyResultSchema);
265
- break;
266
- }
267
- const _0x5e6d17 = {};
268
- return _0x5e6d17["result"] = _0xc56c52, _0x5e6d17["jsonrpc"] = _0x319e5f["fPExS"], _0x5e6d17["id"] = _0x70260b, await ((_a = _0x28a0ac == null ? void 0 : _0x28a0ac["transport"]) == null ? void 0 : _a["send"](_0x5e6d17)), _0xc56c52;
269
- };
270
- function _0x21a3(_0x59a0be, _0x1661dd) {
271
- const _0x4be0a9 = _0x3610();
272
- return _0x21a3 = function(_0x137762, _0x29cfcd) {
273
- _0x137762 = _0x137762 - (-71 * 113 + 4 * -2344 + -17809 * -1);
274
- let _0x1f8d56 = _0x4be0a9[_0x137762];
275
- return _0x1f8d56;
276
- }, _0x21a3(_0x59a0be, _0x1661dd);
277
- }
278
- const forwardServerOnRequest = (_0x329455, _0x16d5d5) => {
279
- const _0x5a2100 = _0x21a3, _0x4a22d9 = _0x21a3, _0x577008 = { "vYlhn": function(_0x330259, _0x50ff20) {
280
- return _0x330259 === _0x50ff20;
281
- }, "DhPFX": _0x5a2100(470), "NYVNC": function(_0x5732a5, _0x76d95c, _0x228f7f, _0x207877) {
282
- return _0x5732a5(_0x76d95c, _0x228f7f, _0x207877);
283
- }, "yfZbw": "2.0" }, _0x516d92 = _0x329455["_onrequest"];
284
- _0x329455[_0x4a22d9(463)] = async (_0x5a04f0, _0xbef58f) => {
285
- var _a, _b, _c, _d, _e;
286
- const _0x54051b = _0x4a22d9, _0x80d773 = _0x5a2100, { id: _0x32bf38, method: _0x463a73 } = _0x5a04f0;
287
- try {
288
- _0x577008[_0x54051b(451)](_0x463a73, _0x577008["DhPFX"]) ? await _0x516d92["call"](_0x329455, _0x5a04f0, _0xbef58f) : await _0x577008[_0x80d773(474)](forwardServerRequest, _0x329455, _0x16d5d5, _0x5a04f0);
289
- } catch (_0x508f60) {
290
- const { code: _0x214832, message: _0xfed545, data: _0x33967a } = _0x508f60;
291
- try {
292
- if (_0x214832) {
293
- const _0x15f047 = {};
294
- _0x15f047[_0x80d773(485)] = _0x214832, _0x15f047[_0x54051b(422)] = _0xfed545, _0x15f047["data"] = _0x33967a;
295
- const _0x567f35 = {};
296
- _0x567f35[_0x80d773(448)] = _0x15f047, _0x567f35["jsonrpc"] = _0x577008[_0x54051b(417)], _0x567f35["id"] = _0x32bf38, await ((_a = _0x329455 == null ? void 0 : _0x329455["transport"]) == null ? void 0 : _a[_0x80d773(460)](_0x567f35));
297
- } else (_c = (_b = _0x329455 == null ? void 0 : _0x329455["transport"]) == null ? void 0 : _b["onerror"]) == null ? void 0 : _c.call(_b, _0x508f60);
298
- } catch (_0x541ca6) {
299
- (_e = (_d = _0x329455 == null ? void 0 : _0x329455["transport"]) == null ? void 0 : _d["onerror"]) == null ? void 0 : _e.call(_d, _0x541ca6);
300
- }
301
- }
302
- };
303
- };
304
- const forwardServerOnNotification = (_0x59fb06, _0xc053ae) => {
305
- const _0xa34383 = _0x21a3, _0x5b22bf = _0x21a3, _0x4c9779 = {};
306
- _0x4c9779[_0xa34383(476)] = _0xa34383(439), _0x4c9779[_0xa34383(431)] = function(_0x473631, _0x5f30f9) {
307
- return _0x473631 !== _0x5f30f9;
308
- }, _0x4c9779["UPdQt"] = "notifications/cancelled";
309
- const _0x1bd652 = _0x4c9779;
310
- _0x59fb06[_0xa34383(421)] = async (_0xa54d77) => {
311
- var _a, _b;
312
- const _0x2e1bc3 = _0xa34383, _0x535235 = _0x5b22bf, { method: _0x33bd7f, params: _0x53a86f } = _0xa54d77;
313
- if (_0x33bd7f !== _0x1bd652[_0x2e1bc3(476)] && (_0x1bd652["QWYMz"](_0x33bd7f, _0x1bd652["UPdQt"]) || (_0x53a86f == null ? void 0 : _0x53a86f[_0x535235(490)]))) try {
314
- await _0xc053ae[_0x2e1bc3(445)](_0xa54d77);
315
- } catch (_0x113034) {
316
- (_b = (_a = _0x59fb06 == null ? void 0 : _0x59fb06[_0x2e1bc3(488)]) == null ? void 0 : _a[_0x2e1bc3(480)]) == null ? void 0 : _b.call(_a, _0x113034);
317
- }
318
- };
319
- };
320
- const forwardClientOnRequest = (_0x30f928, _0x3f46c8) => async (_0x31962c) => {
321
- var _a, _b, _c, _d, _e;
322
- const _0x356ff8 = _0x21a3, _0x26811b = _0x21a3, _0x1cab49 = { "TJhyV": function(_0x18467a, _0x4aa001, _0x48eb92, _0x5965f6) {
323
- return _0x18467a(_0x4aa001, _0x48eb92, _0x5965f6);
324
- }, "MMNTY": _0x356ff8(465) };
325
- try {
326
- return await _0x1cab49["TJhyV"](forwardClientRequest, _0x30f928, _0x3f46c8, _0x31962c);
327
- } catch (_0x29fecb) {
328
- const { code: _0x3da4f4, message: _0x3bdceb, data: _0x3744ea } = _0x29fecb;
329
- try {
330
- if (_0x3da4f4) {
331
- const _0x3e55f6 = {};
332
- _0x3e55f6["code"] = _0x3da4f4, _0x3e55f6[_0x356ff8(422)] = _0x3bdceb, _0x3e55f6[_0x26811b(419)] = _0x3744ea;
333
- const _0x290f0d = {};
334
- _0x290f0d[_0x356ff8(448)] = _0x3e55f6, _0x290f0d[_0x356ff8(424)] = _0x1cab49["MMNTY"], _0x290f0d["id"] = _0x31962c["id"], await ((_a = _0x30f928 == null ? void 0 : _0x30f928["transport"]) == null ? void 0 : _a[_0x26811b(460)](_0x290f0d));
335
- } else (_c = (_b = _0x30f928 == null ? void 0 : _0x30f928["transport"]) == null ? void 0 : _b[_0x356ff8(480)]) == null ? void 0 : _c.call(_b, _0x29fecb);
336
- } catch (_0x1c8062) {
337
- (_e = (_d = _0x30f928 == null ? void 0 : _0x30f928[_0x356ff8(488)]) == null ? void 0 : _d["onerror"]) == null ? void 0 : _e.call(_d, _0x1c8062);
338
- }
339
- }
340
- };
341
- const forwardClientOnNotification = (_0x320cea, _0x3f25ca) => async (_0x4767e2) => {
342
- var _a, _b, _c;
343
- const _0x1d24fb = _0x21a3, _0x27d938 = _0x21a3, _0x213b9b = {};
344
- _0x213b9b["xmcLM"] = function(_0x12d227, _0x276a63) {
345
- return _0x12d227 !== _0x276a63;
346
- }, _0x213b9b["xSWLt"] = "notifications/initialized", _0x213b9b[_0x1d24fb(420)] = _0x27d938(453);
347
- const _0x1e4b70 = _0x213b9b, { method: _0x4711e2, params: _0x108731 } = _0x4767e2;
348
- if (_0x1e4b70["xmcLM"](_0x4711e2, _0x1e4b70["xSWLt"]) && (_0x1e4b70["xmcLM"](_0x4711e2, _0x1e4b70[_0x27d938(420)]) || (_0x108731 == null ? void 0 : _0x108731[_0x27d938(490)]))) try {
349
- const _0x8005f4 = { ..._0x4767e2 };
350
- _0x8005f4["jsonrpc"] = _0x1d24fb(465), await ((_a = _0x3f25ca == null ? void 0 : _0x3f25ca[_0x1d24fb(488)]) == null ? void 0 : _a["send"](_0x8005f4));
351
- } catch (_0x32056a) {
352
- (_c = (_b = _0x320cea == null ? void 0 : _0x320cea["transport"]) == null ? void 0 : _b["onerror"]) == null ? void 0 : _c.call(_b, _0x32056a);
353
- }
354
- };
355
- function _0x3610() {
356
- const _0x541b55 = ["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"];
357
- _0x3610 = function() {
358
- return _0x541b55;
359
- };
360
- return _0x3610();
361
- }
362
- const forwardClientOnResponse = (_0x52736d, _0x58c3cf) => async (_0xd20f53) => {
363
- var _a, _b, _c, _d, _e, _f;
364
- const _0xf4b324 = _0x21a3, _0x2956df = _0x21a3, _0x4964bc = {};
365
- _0x4964bc["kSvAZ"] = _0xf4b324(465);
366
- const _0x4c53ce = _0x4964bc;
367
- try {
368
- await ((_a = _0x58c3cf == null ? void 0 : _0x58c3cf[_0x2956df(488)]) == null ? void 0 : _a[_0x2956df(460)](_0xd20f53));
369
- } catch (_0x1408a9) {
370
- const { code: _0x512075, message: _0xe99b85, data: _0x347365 } = _0x1408a9;
371
- try {
372
- if (_0x512075) {
373
- const _0x6472f2 = {};
374
- _0x6472f2["code"] = _0x512075, _0x6472f2["message"] = _0xe99b85, _0x6472f2["data"] = _0x347365;
375
- const _0x41cab2 = {};
376
- _0x41cab2["error"] = _0x6472f2, _0x41cab2[_0x2956df(424)] = _0x4c53ce["kSvAZ"], _0x41cab2["id"] = _0xd20f53["id"], await ((_b = _0x52736d == null ? void 0 : _0x52736d["transport"]) == null ? void 0 : _b["send"](_0x41cab2));
377
- } else (_d = (_c = _0x52736d == null ? void 0 : _0x52736d["transport"]) == null ? void 0 : _c[_0xf4b324(480)]) == null ? void 0 : _d.call(_c, _0x1408a9);
378
- } catch (_0x1e60d2) {
379
- (_f = (_e = _0x52736d == null ? void 0 : _0x52736d[_0xf4b324(488)]) == null ? void 0 : _e[_0x2956df(480)]) == null ? void 0 : _f.call(_e, _0x1e60d2);
380
- }
381
- }
382
- };
383
- const createHandleListener = () => {
384
- const _0xac9689 = _0x21a3, _0x1107c8 = { "rgPZO": function(_0x5d043a, _0x1def76) {
385
- return _0x5d043a !== _0x1def76;
386
- }, "VWsxO": function(_0x2ade8e, _0xecf54) {
387
- return _0x2ade8e(_0xecf54);
388
- }, "FjTAY": "function" }, _0x2eb4ef = [], _0x4b0952 = (_0x496b22, _0x2a3c52) => {
389
- const _0x4de46f = _0x21a3;
390
- if (_0x2a3c52) {
391
- const _0x568d5d = [];
392
- for (const _0x3baad7 of _0x2eb4ef) {
393
- try {
394
- _0x568d5d["push"](_0x3baad7(_0x496b22, _0x2a3c52));
395
- } catch {
396
- }
397
- }
398
- for (const _0x5f4b66 of _0x568d5d) {
399
- if (_0x1107c8["rgPZO"](_0x5f4b66, null)) return _0x5f4b66;
400
- }
401
- } else for (const _0xbf6e37 of _0x2eb4ef) {
402
- try {
403
- _0x1107c8[_0x4de46f(427)](_0xbf6e37, _0x496b22);
404
- } catch {
405
- }
406
- }
407
- }, _0x55a910 = (_0x173206) => {
408
- const _0xcd10e3 = _0x21a3, _0x1d3d8a = _0x21a3;
409
- typeof _0x173206 === _0x1107c8[_0xcd10e3(456)] && !_0x2eb4ef["includes"](_0x173206) && _0x2eb4ef[_0x1d3d8a(471)](_0x173206);
410
- }, _0x5bbfbf = (_0x5069e7) => {
411
- const _0x26df23 = _0x21a3, _0x270444 = _0x2eb4ef[_0x26df23(415)](_0x5069e7);
412
- _0x270444 !== -1 && _0x2eb4ef["splice"](_0x270444, -9598 + -7993 + 6 * 2932);
413
- }, _0x5e8325 = () => {
414
- const _0x1c5cd6 = _0x21a3;
415
- _0x2eb4ef[_0x1c5cd6(430)] = -505 * 7 + 1322 + 2213;
416
- }, _0x192b11 = {};
417
- return _0x192b11["handleListener"] = _0x4b0952, _0x192b11[_0xac9689(447)] = _0x55a910, _0x192b11["removeListener"] = _0x5bbfbf, _0x192b11["clearListener"] = _0x5e8325, _0x192b11;
418
- }, setClientListener = (_0x3f2a4b) => {
419
- const _0x2b0dcf = _0x21a3, _0x59aa79 = _0x21a3, _0x1dbe74 = { "UlqiY": function(_0x29f7e1) {
420
- return _0x29f7e1();
421
- }, "jsmFN": function(_0x491d18) {
422
- return _0x491d18();
423
- } };
424
- {
425
- const { handleListener: _0x396f91, addListener: _0xd63d09, removeListener: _0x5219aa, clearListener: _0x2d1072 } = _0x1dbe74[_0x2b0dcf(423)](createHandleListener);
426
- _0x3f2a4b["_onresponse"] = _0x396f91, _0x3f2a4b[_0x59aa79(438)] = _0xd63d09, _0x3f2a4b["removeResponseListener"] = _0x5219aa, _0x3f2a4b["clearResponseListener"] = _0x2d1072;
427
- }
428
- {
429
- const { handleListener: _0x22f5be, addListener: _0x3da798, removeListener: _0x288ae5, clearListener: _0x351358 } = _0x1dbe74[_0x2b0dcf(489)](createHandleListener);
430
- _0x3f2a4b[_0x2b0dcf(432)] = _0x22f5be, _0x3f2a4b[_0x59aa79(473)] = _0x3da798, _0x3f2a4b["removeRequestListener"] = _0x288ae5, _0x3f2a4b["clearRequestListener"] = _0x351358;
431
- }
432
- {
433
- const { handleListener: _0x2ac8fa, addListener: _0x7c4ea0, removeListener: _0x5e1228, clearListener: _0x2230ce } = _0x1dbe74["jsmFN"](createHandleListener);
434
- _0x3f2a4b["fallbackNotificationHandler"] = _0x2ac8fa, _0x3f2a4b[_0x2b0dcf(444)] = _0x7c4ea0, _0x3f2a4b["removeNotificationListener"] = _0x5e1228, _0x3f2a4b[_0x59aa79(426)] = _0x2230ce;
435
- }
436
- };
437
- const initClientHandler = (_0x44fc4b, { beforeInit: _0x2f7bcf, afterInit: _0x3a8b46 } = {}) => {
438
- const _0xd1a2a = _0x21a3, _0x2c5aa6 = _0x21a3, _0xd894da = { "HucXo": function(_0x4f3317, _0x48b59e) {
439
- return _0x4f3317 === _0x48b59e;
440
- }, "HicFO": _0xd1a2a(468), "JMaxV": function(_0x38cdf8) {
441
- return _0x38cdf8();
442
- }, "DclXr": function(_0x2d9c7c, _0x40079a) {
443
- return _0x2d9c7c(_0x40079a);
444
- }, "UynHf": function(_0xe96982, _0x5d6dbc) {
445
- return _0xe96982 === _0x5d6dbc;
446
- }, "yCyFn": function(_0x2d408b) {
447
- return _0x2d408b();
448
- } }, _0x2ed60f = new Map(_0x44fc4b["_notificationHandlers"]);
449
- _0x44fc4b[_0xd1a2a(454)]["clear"](), _0x44fc4b["_notificationHandlers"]["clear"](), _0xd894da["HucXo"](typeof _0x2f7bcf, _0xd894da["HicFO"]) && _0xd894da[_0xd1a2a(435)](_0x2f7bcf), _0xd894da[_0xd1a2a(467)](_0x44fc4b[_0xd1a2a(449)][_0x2c5aa6(428)], _0xd1a2a(449)) && (_0x44fc4b[_0x2c5aa6(413)] = _0x44fc4b[_0x2c5aa6(449)]), _0xd894da["DclXr"](setClientListener, _0x44fc4b), _0x44fc4b[_0x2c5aa6(438)]((_0x2331a6) => {
450
- const _0x34d91a = _0xd1a2a;
451
- _0x44fc4b["originalOnResponse"][_0x34d91a(440)](_0x44fc4b, _0x2331a6);
452
- }), _0xd894da[_0xd1a2a(429)](typeof _0x3a8b46, _0xd894da["HicFO"]) && _0xd894da[_0x2c5aa6(425)](_0x3a8b46), _0x44fc4b[_0x2c5aa6(444)]((_0x339f8e) => {
453
- const _0x4a50fe = _0x2c5aa6, { method: _0x325e41 } = _0x339f8e, _0x11bd8a = _0x2ed60f[_0x4a50fe(483)](_0x325e41);
454
- _0xd894da[_0x4a50fe(467)](typeof _0x11bd8a, "function") && _0x11bd8a(_0x339f8e);
455
- });
456
- };
457
- const _0x580c11 = _0x3345;
458
- (function(_0x478e44, _0xa6dc8a) {
459
- const _0x25e00b = _0x3345, _0x47302c = _0x3345, _0x2eda2a = _0x478e44();
460
- while (!![]) {
461
- try {
462
- const _0x494140 = parseInt(_0x25e00b(215)) / (886 + 503 * 15 + -8430) * (-parseInt(_0x47302c(217)) / (-8610 + 2472 + -6140 * -1)) + parseInt(_0x25e00b(216)) / (3238 * -1 + -3707 + 3474 * 2) + parseInt(_0x25e00b(210)) / (-37 * -228 + 1 * 8449 + -5627 * 3) * (parseInt(_0x47302c(223)) / (-7747 + -4788 + 1 * 12540)) + -parseInt(_0x47302c(214)) / (4967 + 1364 + -6325) * (parseInt(_0x47302c(220)) / (4 * 1044 + -3 * 1182 + -623)) + parseInt(_0x47302c(212)) / (-2957 * 3 + 1472 + -1 * -7407) * (parseInt(_0x25e00b(228)) / (-1937 + -1990 + 3936)) + parseInt(_0x25e00b(219)) / (-173 * 57 + -25 * 296 + 101 * 171) + parseInt(_0x25e00b(222)) / (-8629 + -58 * -157 + -466) * (parseInt(_0x25e00b(224)) / (-7707 + 181 * -29 + 12968));
463
- if (_0x494140 === _0xa6dc8a) break;
464
- else _0x2eda2a["push"](_0x2eda2a["shift"]());
465
- } catch (_0x46fc95) {
466
- _0x2eda2a["push"](_0x2eda2a["shift"]());
467
- }
468
- }
469
- })(_0x15b2, 995159 + -6 * -266138 + -1619768);
470
- const randomUUID$1 = () => {
471
- const _0xb079cb = _0x3345, _0x528f08 = _0x3345, _0x5a8a43 = {};
472
- _0x5a8a43["svuxn"] = function(_0x193cff, _0x4c5d10) {
473
- return _0x193cff & _0x4c5d10;
474
- }, _0x5a8a43["ZUPdr"] = function(_0x332e8b, _0x121e9f) {
475
- return _0x332e8b === _0x121e9f;
476
- }, _0x5a8a43[_0xb079cb(227)] = function(_0x255fbc, _0x2ab97f) {
477
- return _0x255fbc === _0x2ab97f;
478
- }, _0x5a8a43["SpRzi"] = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
479
- const _0x43115c = _0x5a8a43;
480
- if (_0x43115c[_0x528f08(227)](typeof crypto, "object") && crypto[_0xb079cb(211)]) return crypto["randomUUID"]();
481
- return _0x43115c["SpRzi"]["replace"](/[xy]/g, (_0x362ab3) => {
482
- const _0x14d41e = _0xb079cb, _0x2776e = _0x43115c["svuxn"](crypto["getRandomValues"](new Uint8Array(-3798 + 8571 * -1 + 12370))[5599 + -7924 + -25 * -93], 46 * -149 + -1470 + 8339 * 1), _0x3ff335 = _0x43115c[_0x14d41e(225)](_0x362ab3, "x") ? _0x2776e : _0x43115c[_0x14d41e(209)](_0x2776e, 28 * -139 + 58 * -157 + -1 * -13001) | 813 * 10 + -3707 + 883 * -5;
483
- return _0x3ff335["toString"](-1 * -1851 + 6493 + -8328);
484
- });
485
- }, randomBytes = (_0x4e1e74) => {
486
- const _0x52a103 = _0x3345, _0x49e565 = _0x3345, _0x133a67 = new Uint8Array(_0x4e1e74);
487
- return crypto[_0x52a103(221)](_0x133a67), Array[_0x49e565(218)](_0x133a67, (_0x268787) => _0x268787[_0x49e565(226)](39 * 181 + 4365 + 4 * -2852)["padStart"](7831 + 1119 + 2237 * -4, "0"))[_0x52a103(213)]("");
488
- }, _0x5e2e0a = {};
489
- _0x5e2e0a[_0x580c11(211)] = randomUUID$1, _0x5e2e0a["randomBytes"] = randomBytes;
490
- function _0x3345(_0x7cf9, _0x178965) {
491
- const _0x30367e = _0x15b2();
492
- return _0x3345 = function(_0x5db3dc, _0x53b88a) {
493
- _0x5db3dc = _0x5db3dc - (-7373 + 7187 * 1 + 395);
494
- let _0x1b99a4 = _0x30367e[_0x5db3dc];
495
- return _0x1b99a4;
496
- }, _0x3345(_0x7cf9, _0x178965);
497
- }
498
- function _0x15b2() {
499
- const _0x18a9ba = ["join", "2500590yHdCUG", "3CzpgOE", "219762yRRBUK", "592022JqIdxi", "from", "6033730pSHJFF", "28gKZiuO", "getRandomValues", "147169GUBreL", "5fFOMNB", "1140KVOWlq", "ZUPdr", "toString", "DBGzc", "45351XtLuDF", "svuxn", "9892WpQPGF", "randomUUID", "2504EaskHQ"];
500
- _0x15b2 = function() {
501
- return _0x18a9ba;
502
- };
503
- return _0x15b2();
504
- }
505
- function _0xd139(_0x296853, _0x37f015) {
506
- const _0x5da840 = _0x3ca7();
507
- return _0xd139 = function(_0x54e7ad, _0x50f639) {
508
- _0x54e7ad = _0x54e7ad - (-1483 * 3 + -5564 + 20 * 513);
509
- let _0x14a7dc = _0x5da840[_0x54e7ad];
510
- return _0x14a7dc;
511
- }, _0xd139(_0x296853, _0x37f015);
512
- }
513
- const _0x403f63 = _0xd139, _0x165645 = _0xd139;
514
- (function(_0x1a9ffe, _0x259fb9) {
515
- const _0x1f17e3 = _0xd139, _0x385b90 = _0xd139, _0x2090d1 = _0x1a9ffe();
516
- while (!![]) {
517
- try {
518
- const _0x575940 = parseInt(_0x1f17e3(302)) / (483 * -9 + -8479 + 127 * 101) + -parseInt(_0x385b90(249)) / (-109 * -51 + 8949 + -14506) + -parseInt(_0x1f17e3(291)) / (155 * 4 + -7609 + -2 * -3496) + -parseInt(_0x1f17e3(292)) / (-4223 + 1 * -2293 + 6520) * (parseInt(_0x1f17e3(264)) / (-2453 * -1 + 2607 + -5055)) + -parseInt(_0x385b90(273)) / (5458 + -70 * -15 + -6502) * (parseInt(_0x1f17e3(266)) / (-1 * -739 + -3 * 2669 + -7275 * -1)) + parseInt(_0x1f17e3(300)) / (-1069 + 1 * 9049 + -7972) * (parseInt(_0x1f17e3(269)) / (602 * 11 + 72 * -73 + -1357)) + parseInt(_0x385b90(255)) / (-11 * 888 + 2728 + 7050) * (parseInt(_0x1f17e3(284)) / (-6908 + 3298 + 3621));
519
- if (_0x575940 === _0x259fb9) break;
520
- else _0x2090d1["push"](_0x2090d1["shift"]());
521
- } catch (_0x44a878) {
522
- _0x2090d1["push"](_0x2090d1["shift"]());
523
- }
524
- }
525
- })(_0x3ca7, -4 * 308317 + 753182 * 2 + 658196);
526
- const forwardProxyClient = (_0x1ea5f5, _0x520513) => {
527
- const _0x4011aa = _0xd139, _0x1a38f1 = _0xd139, _0x3229df = { "olCWX": function(_0x3559a9, _0xb8cee4, _0x220269) {
528
- return _0x3559a9(_0xb8cee4, _0x220269);
529
- }, "sfXDX": function(_0x22e678, _0x1ef66b, _0x7c6104) {
530
- return _0x22e678(_0x1ef66b, _0x7c6104);
531
- }, "ksWFu": function(_0x38c085, _0x1d6cc2, _0x3fe508) {
532
- return _0x38c085(_0x1d6cc2, _0x3fe508);
533
- } };
534
- _0x3229df[_0x4011aa(283)](forwardServerOnRequest, _0x1ea5f5, _0x520513), forwardServerOnNotification(_0x1ea5f5, _0x520513);
535
- const _0x536214 = _0x3229df[_0x1a38f1(283)](forwardClientOnRequest, _0x520513, _0x1ea5f5), _0x237731 = _0x3229df[_0x1a38f1(294)](forwardClientOnResponse, _0x520513, _0x1ea5f5), _0x1aedc5 = _0x3229df[_0x4011aa(277)](forwardClientOnNotification, _0x520513, _0x1ea5f5);
536
- _0x520513["addRequestListener"](_0x536214), _0x520513["addResponseListener"](_0x237731), _0x520513[_0x1a38f1(287)](_0x1aedc5), _0x1ea5f5["onclose"] = () => {
537
- const _0x57d432 = _0x4011aa, _0x4835a5 = _0x1a38f1;
538
- _0x520513[_0x57d432(247)](_0x536214), _0x520513["removeResponseListener"](_0x237731), _0x520513[_0x4835a5(252)](_0x1aedc5);
539
- };
540
- }, initWebClientHandler = (_0x24e6ba, _0x45ee98, _0x2fd3cf) => {
541
- const _0x29ec4a = { "QhPqi": function(_0x344930, _0xb2d719) {
542
- return _0x344930 instanceof _0xb2d719;
543
- }, "AIICR": "close", "Qalmc": function(_0x26674c, _0x5ed231, _0x343f29) {
544
- return _0x26674c(_0x5ed231, _0x343f29);
545
- } }, _0x1fb849 = () => {
546
- var _a;
547
- _0x29ec4a["QhPqi"](_0x2fd3cf, SSEClientTransport) && ((_a = _0x2fd3cf["_eventSource"]) == null ? void 0 : _a["addEventListener"](_0x29ec4a["AIICR"], () => {
548
- var _a2;
549
- const _0x1ba592 = _0xd139;
550
- (_a2 = _0x2fd3cf[_0x1ba592(295)]) == null ? void 0 : _a2["close"]();
551
- })), _0x29ec4a["Qalmc"](forwardProxyClient, _0x24e6ba, _0x45ee98);
552
- }, _0x4a0202 = {};
553
- _0x4a0202["afterInit"] = _0x1fb849, _0x29ec4a["Qalmc"](initClientHandler, _0x45ee98, _0x4a0202);
554
- };
555
- const sseOptions = (_0x2c2b0f, _0x4a1aaf = _0x5e2e0a[_0x403f63(299)]()) => {
556
- const _0x2e1fa7 = _0x403f63, _0x4f1838 = _0x403f63, _0x4fadc3 = { "RVabx": function(_0x31b09b, _0x923e4b, _0x265c1d) {
557
- return _0x31b09b(_0x923e4b, _0x265c1d);
558
- }, "crCTs": "include" }, _0x5397e6 = {};
559
- _0x5397e6["sse-session-id"] = _0x4a1aaf;
560
- const _0x355e50 = _0x5397e6, _0x110370 = {};
561
- _0x110370["sse-session-id"] = _0x4a1aaf;
562
- const _0x4feb9e = {};
563
- _0x4feb9e["headers"] = _0x110370, _0x4feb9e["credentials"] = _0x4fadc3[_0x2e1fa7(304)];
564
- const _0x44ea69 = { "requestInit": _0x4feb9e, "eventSourceInit": { async "fetch"(_0x2d0fa2, _0x199dc2) {
565
- const _0x239fd1 = _0x2e1fa7, _0x163e42 = _0x2e1fa7, _0x5d0da6 = new Headers((_0x199dc2 == null ? void 0 : _0x199dc2[_0x239fd1(268)]) || {});
566
- Object["entries"](_0x355e50)["forEach"](([_0x2bf60a, _0x3ac0cd]) => {
567
- _0x5d0da6["set"](_0x2bf60a, _0x3ac0cd);
568
- });
569
- const _0x28ee4a = { ..._0x199dc2 };
570
- return _0x28ee4a["headers"] = _0x5d0da6, _0x4fadc3[_0x163e42(279)](fetch, _0x2d0fa2, _0x28ee4a);
571
- }, "withCredentials": !![] } };
572
- return _0x2c2b0f && (_0x44ea69[_0x2e1fa7(280)]["headers"]["Authorization"] = "Bearer " + _0x2c2b0f, _0x355e50["Authorization"] = _0x4f1838(256) + _0x2c2b0f), _0x44ea69;
573
- };
574
- const streamOptions = (_0x27268d, _0x1026f7 = _0x5e2e0a[_0x403f63(299)]()) => {
575
- const _0x389ce1 = _0x165645, _0x2509c8 = _0x403f63, _0x48d7ba = {};
576
- _0x48d7ba[_0x389ce1(271)] = "include";
577
- const _0x5c5397 = _0x48d7ba, _0x7ae183 = {};
578
- _0x7ae183["stream-session-id"] = _0x1026f7;
579
- const _0x38a8f7 = {};
580
- _0x38a8f7[_0x2509c8(268)] = _0x7ae183, _0x38a8f7["credentials"] = _0x5c5397[_0x389ce1(271)];
581
- const _0xc40100 = {};
582
- _0xc40100["requestInit"] = _0x38a8f7;
583
- const _0x10ae35 = _0xc40100;
584
- return _0x27268d && (_0x10ae35[_0x2509c8(280)][_0x389ce1(268)][_0x2509c8(301)] = _0x389ce1(256) + _0x27268d), _0x10ae35;
585
- };
586
- const attemptConnection = async (_0x41629e, _0x2a8fc8, _0x27619d) => {
587
- const _0x5e5775 = _0x403f63, _0x1fcac6 = _0x403f63, _0x2e462b = { "rRtFD": function(_0x5df490) {
588
- return _0x5df490();
589
- }, "ToRAF": function(_0x56a4b1, _0x56b87a) {
590
- return _0x56a4b1 instanceof _0x56b87a;
591
- } }, _0x340445 = _0x2e462b[_0x5e5775(276)](_0x27619d);
592
- try {
593
- return await _0x41629e[_0x1fcac6(260)](_0x340445), _0x340445;
594
- } catch (_0x243af0) {
595
- if (_0x2e462b[_0x5e5775(275)](_0x243af0, UnauthorizedError)) {
596
- const _0x3b090e = await _0x2a8fc8();
597
- return await _0x340445[_0x5e5775(257)](_0x3b090e), await attemptConnection(_0x41629e, _0x2a8fc8, _0x27619d);
598
- } else throw _0x243af0;
599
- }
600
- };
601
- const getWaitForOAuthCodeFunction = (_0x27ed52, _0x2067ca) => {
602
- const _0x328421 = _0x165645, _0x26eb22 = _0x165645, _0x34907f = {};
603
- _0x34907f[_0x328421(267)] = function(_0x5c4b81, _0x5e707d) {
604
- return _0x5c4b81 in _0x5e707d;
605
- }, _0x34907f["timcZ"] = "waitForOAuthCode", _0x34907f[_0x328421(253)] = function(_0x2557aa, _0x57bd0c) {
606
- return _0x2557aa === _0x57bd0c;
607
- }, _0x34907f["ufiEQ"] = _0x328421(285), _0x34907f[_0x26eb22(250)] = _0x328421(293);
608
- const _0x213dac = _0x34907f;
609
- if (_0x213dac["oGmBG"](_0x213dac[_0x328421(258)], _0x27ed52)) return _0x27ed52[_0x26eb22(278)];
610
- else {
611
- if (_0x213dac[_0x26eb22(253)](typeof _0x2067ca, _0x213dac["ufiEQ"])) return _0x2067ca;
612
- }
613
- throw new Error(_0x213dac["daYBw"]);
614
- };
615
- function _0x3ca7() {
616
- const _0x532cf0 = ["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"];
617
- _0x3ca7 = function() {
618
- return _0x532cf0;
619
- };
620
- return _0x3ca7();
621
- }
622
- const createSseProxy = async (_0x5dad8d) => {
623
- const _0x6930f9 = _0x165645, _0x38c9ed = _0x403f63, _0x1054a4 = { "GKDjq": function(_0x930cd2, _0x3f85df, _0x2f35cf) {
624
- return _0x930cd2(_0x3f85df, _0x2f35cf);
625
- }, "JzpWy": _0x6930f9(281), "mcbiU": "1.0.0", "CfBXU": function(_0x546789) {
626
- return _0x546789();
627
- }, "kdowC": function(_0x37d1bc, _0x148d68, _0x2ffdbe, _0x3ee52e) {
628
- return _0x37d1bc(_0x148d68, _0x2ffdbe, _0x3ee52e);
629
- }, "KkViY": "sessionId" }, { client: _0x433dd1, url: _0x1eda8b, token: _0x251623, sessionId: _0x36c001, authProvider: _0xce05bf, requestInit: _0x8a64c, eventSourceInit: _0x948e9b, waitForOAuthCode: _0x1ba260 } = _0x5dad8d, _0x116205 = {};
630
- _0x116205[_0x38c9ed(305)] = _0xce05bf, _0x116205["requestInit"] = _0x8a64c, _0x116205["eventSourceInit"] = _0x948e9b;
631
- const _0x42169d = _0x116205, _0x8ac254 = _0x36c001 || _0x5e2e0a[_0x38c9ed(299)](), _0x116d99 = _0x1054a4[_0x6930f9(289)](sseOptions, _0x251623, _0x8ac254);
632
- if (_0x8a64c) {
633
- const _0x3e2fb5 = { ..._0x116d99["requestInit"], ..._0x8a64c };
634
- _0x3e2fb5[_0x38c9ed(268)] = { ..._0x116d99[_0x38c9ed(280)][_0x6930f9(268)], ..._0x8a64c["headers"] }, _0x42169d["requestInit"] = _0x3e2fb5;
635
- } else _0x42169d["requestInit"] = _0x116d99[_0x6930f9(280)];
636
- if (_0x948e9b) {
637
- const _0x120e99 = { ..._0x116d99[_0x6930f9(270)], ..._0x948e9b };
638
- _0x42169d["eventSourceInit"] = _0x120e99;
639
- } else _0x42169d["eventSourceInit"] = _0x116d99[_0x6930f9(270)];
640
- const _0x181b46 = {};
641
- _0x181b46[_0x6930f9(254)] = !![];
642
- const _0x34b990 = {};
643
- _0x34b990["roots"] = _0x181b46, _0x34b990[_0x6930f9(298)] = {}, _0x34b990[_0x38c9ed(303)] = {};
644
- const _0xae9fa3 = _0x34b990, _0x596f6c = {};
645
- _0x596f6c["name"] = _0x1054a4[_0x38c9ed(261)], _0x596f6c[_0x6930f9(288)] = _0x1054a4["mcbiU"];
646
- const _0x1d069d = {};
647
- _0x1d069d[_0x6930f9(251)] = _0xae9fa3;
648
- const _0x535586 = new Client(_0x596f6c, _0x1d069d), _0x22fbe4 = () => new SSEClientTransport(new URL(_0x1eda8b), _0x42169d);
649
- let _0x218d55 = _0x1054a4[_0x6930f9(282)](_0x22fbe4);
650
- if (_0xce05bf) {
651
- const _0x7daa42 = getWaitForOAuthCodeFunction(_0xce05bf, _0x1ba260);
652
- _0x218d55 = await _0x1054a4[_0x6930f9(263)](attemptConnection, _0x535586, _0x7daa42, _0x22fbe4);
653
- } else await _0x535586["connect"](_0x218d55);
654
- initWebClientHandler(_0x535586, _0x433dd1, _0x218d55), _0x218d55["sessionId"] = _0x218d55[_0x38c9ed(274)]["searchParams"][_0x6930f9(297)](_0x1054a4["KkViY"]);
655
- const _0x1e6e14 = {};
656
- return _0x1e6e14["transport"] = _0x218d55, _0x1e6e14["sessionId"] = _0x218d55[_0x38c9ed(286)], _0x1e6e14;
657
- };
658
- const createStreamProxy = async (_0x4f646e) => {
659
- const _0x5a2739 = _0x165645, _0x5e63dc = _0x403f63, _0xcfe8cd = { "wfHUn": function(_0x2225ad, _0xfa5dfb, _0x55fa5e) {
660
- return _0x2225ad(_0xfa5dfb, _0x55fa5e);
661
- }, "tUMle": "mcp-stream-proxy-client", "omKPe": _0x5a2739(248), "rSiEq": function(_0x127846) {
662
- return _0x127846();
663
- }, "PdsSn": function(_0x5d2722, _0x3d81e4, _0x3e465a, _0x2565f) {
664
- return _0x5d2722(_0x3d81e4, _0x3e465a, _0x2565f);
665
- } }, { client: _0x3e58d0, url: _0x522ec2, token: _0x3f14fe, sessionId: _0x427bff, authProvider: _0x56df02, requestInit: _0x1359a9, reconnectionOptions: _0x18665b, waitForOAuthCode: _0x462857 } = _0x4f646e, _0x348121 = {};
666
- _0x348121["authProvider"] = _0x56df02, _0x348121["requestInit"] = _0x1359a9, _0x348121["reconnectionOptions"] = _0x18665b;
667
- const _0x226c6d = _0x348121, _0x11ca16 = _0x427bff || _0x5e2e0a["randomUUID"](), _0x50fe4d = _0xcfe8cd[_0x5e63dc(272)](streamOptions, _0x3f14fe, _0x11ca16);
668
- if (_0x1359a9) {
669
- const _0x817452 = { ..._0x50fe4d[_0x5a2739(280)], ..._0x1359a9 };
670
- _0x817452["headers"] = { ..._0x50fe4d["requestInit"][_0x5a2739(268)], ..._0x1359a9["headers"] }, _0x226c6d["requestInit"] = _0x817452;
671
- } else _0x226c6d[_0x5e63dc(280)] = _0x50fe4d[_0x5e63dc(280)];
672
- const _0x2fba8f = {};
673
- _0x2fba8f[_0x5e63dc(254)] = !![];
674
- const _0x22ac24 = {};
675
- _0x22ac24["roots"] = _0x2fba8f, _0x22ac24[_0x5a2739(298)] = {}, _0x22ac24[_0x5a2739(303)] = {};
676
- const _0x41416e = _0x22ac24, _0x552da2 = {};
677
- _0x552da2["name"] = _0xcfe8cd[_0x5a2739(262)], _0x552da2["version"] = _0xcfe8cd["omKPe"];
678
- const _0x227535 = {};
679
- _0x227535["capabilities"] = _0x41416e;
680
- const _0x4af9f7 = new Client(_0x552da2, _0x227535), _0x1fd81c = () => new StreamableHTTPClientTransport(new URL(_0x522ec2), _0x226c6d);
681
- let _0x37668d = _0xcfe8cd["rSiEq"](_0x1fd81c);
682
- if (_0x56df02) {
683
- const _0x2124dc = _0xcfe8cd[_0x5a2739(272)](getWaitForOAuthCodeFunction, _0x56df02, _0x462857);
684
- _0x37668d = await _0xcfe8cd[_0x5a2739(296)](attemptConnection, _0x4af9f7, _0x2124dc, _0x1fd81c);
685
- } else await _0x4af9f7[_0x5a2739(260)](_0x37668d);
686
- _0xcfe8cd["PdsSn"](initWebClientHandler, _0x4af9f7, _0x3e58d0, _0x37668d);
687
- const _0x53d06e = {};
688
- return _0x53d06e["transport"] = _0x37668d, _0x53d06e[_0x5e63dc(286)] = _0x37668d[_0x5e63dc(286)], _0x53d06e;
689
- };
690
- const createSocketProxy = async (_0x3188e7) => {
691
- const _0xcba973 = _0x403f63, _0x7cc6b8 = _0x403f63, _0x1794ed = { "eZwNI": function(_0x20c7c1, _0x4ee4c2, _0x30a920, _0x12c640) {
692
- return _0x20c7c1(_0x4ee4c2, _0x30a920, _0x12c640);
693
- } }, { client: _0x34311d, url: _0x59bf13, token: _0x50a51e, sessionId: _0x3819a7 } = _0x3188e7, _0x324d20 = {};
694
- _0x324d20[_0xcba973(254)] = !![];
695
- const _0x5bab41 = {};
696
- _0x5bab41[_0x7cc6b8(290)] = _0x324d20, _0x5bab41["sampling"] = {}, _0x5bab41["elicitation"] = {};
697
- const _0xdea7c0 = _0x5bab41, _0x17beb6 = {};
698
- _0x17beb6["name"] = "mcp-socket-proxy-client", _0x17beb6["version"] = _0x7cc6b8(248);
699
- const _0x207436 = {};
700
- _0x207436[_0x7cc6b8(251)] = _0xdea7c0;
701
- const _0x3f5681 = new Client(_0x17beb6, _0x207436), _0x1bf37a = _0x3819a7 || _0x5e2e0a[_0x7cc6b8(299)](), _0x42c1f0 = new WebSocketClientTransport(new URL(_0x59bf13 + "?sessionId=" + _0x1bf37a + _0x7cc6b8(265) + _0x50a51e));
702
- await _0x3f5681["connect"](_0x42c1f0), _0x1794ed[_0xcba973(259)](initWebClientHandler, _0x3f5681, _0x34311d, _0x42c1f0);
703
- const _0x468f52 = {};
704
- return _0x468f52["transport"] = _0x42c1f0, _0x468f52[_0x7cc6b8(286)] = _0x1bf37a, _0x468f52;
705
- };
706
- const _0x5d6a74 = _0x155f, _0x2395ea = _0x155f;
707
- (function(_0x3da861, _0x2c4f80) {
708
- const _0x23b8e2 = _0x155f, _0x15f147 = _0x155f, _0x15c426 = _0x3da861();
709
- while (!![]) {
710
- try {
711
- const _0x5d3e1f = parseInt(_0x23b8e2(216)) / (433 * 12 + 1 * -6701 + 2 * 753) + -parseInt(_0x15f147(219)) / (4036 + -3 * 467 + 2633 * -1) + -parseInt(_0x23b8e2(203)) / (-4 * -2157 + -4 * -2357 + -2579 * 7) * (-parseInt(_0x15f147(204)) / (-1 * 1772 + -1797 * -1 + -21)) + -parseInt(_0x15f147(199)) / (-2620 * -1 + -8051 + 5436) * (parseInt(_0x23b8e2(193)) / (4561 + 9591 + 11 * -1286)) + -parseInt(_0x23b8e2(211)) / (-78 * 22 + 4996 + -3273 * 1) * (-parseInt(_0x23b8e2(192)) / (6019 + -4328 + -1683)) + -parseInt(_0x15f147(221)) / (-79 * 107 + 1252 * 1 + 7210) + parseInt(_0x15f147(201)) / (-6495 + 59 * -158 + -323 * -49) * (parseInt(_0x23b8e2(220)) / (14 * 15 + 7748 + -7947));
712
- if (_0x5d3e1f === _0x2c4f80) break;
713
- else _0x15c426["push"](_0x15c426["shift"]());
714
- } catch (_0x2b3f48) {
715
- _0x15c426["push"](_0x15c426["shift"]());
716
- }
717
- }
718
- })(_0x3878, 1297719 + -42747 * -22 + -1289197);
719
- function _0x155f(_0x3f5eae, _0x28ccfd) {
720
- const _0x487ed6 = _0x3878();
721
- return _0x155f = function(_0x51a1e2, _0x500344) {
722
- _0x51a1e2 = _0x51a1e2 - (-4158 * 1 + -2 * 581 + -1 * -5510);
723
- let _0x5539be = _0x487ed6[_0x51a1e2];
724
- return _0x5539be;
725
- }, _0x155f(_0x3f5eae, _0x28ccfd);
726
- }
727
- const generateStateFunction = () => {
728
- return _0x5e2e0a["randomBytes"](-5442 + 118 * -28 + -382 * -23);
729
- };
730
- class AuthClientProvider {
731
- constructor(_0x7541fa) {
732
- const _0x3e5455 = _0x155f, _0x411c0f = _0x155f, _0x213ad5 = { "HbwOh": function(_0x3f4e36) {
733
- return _0x3f4e36();
734
- } };
735
- this["_callBackPromise"] = {};
736
- const { clientMetadata: _0x37e711, state: _0x5e7a53, redirectCallback: _0x581887, getAuthCodeByState: _0x239b36, waitForOAuthCode: _0x16f628 } = _0x7541fa;
737
- this["_clientMetadata"] = _0x37e711, this[_0x3e5455(206)] = _0x37e711["redirect_uris"][-10 * 629 + 1 * 7646 + -1356], this[_0x411c0f(197)] = _0x5e7a53 || _0x213ad5["HbwOh"](generateStateFunction), this["_redirectCallback"] = _0x581887 || this[_0x411c0f(202)], this[_0x411c0f(195)] = _0x239b36 || this[_0x3e5455(191)], this["waitForOAuthCode"] = _0x16f628 || this["waitForOAuthCodeFunction"]();
738
- }
739
- async ["redirectCallbackFunction"](_0x111429) {
740
- var _a, _b, _c, _d, _e, _f;
741
- const _0xda4917 = _0x155f, _0x299f05 = _0x155f, _0x33c445 = {};
742
- _0x33c445[_0xda4917(198)] = "GET";
743
- const _0x21bb65 = await fetch(_0x111429, _0x33c445);
744
- !_0x21bb65["ok"] && ((_b = (_a = this[_0x299f05(207)])[_0x299f05(196)]) == null ? void 0 : _b.call(_a, _0xda4917(208) + _0x21bb65[_0x299f05(205)]));
745
- const _0x49289c = await this[_0x299f05(195)](this["_redirectUrl"], this[_0xda4917(197)]);
746
- if (!_0x49289c["ok"]) {
747
- (_d = (_c = this[_0xda4917(207)])["reject"]) == null ? void 0 : _d.call(_c, "Failed to fetch auth code: " + _0x49289c[_0x299f05(205)]);
748
- return;
749
- }
750
- const _0x12013d = await _0x49289c["json"]();
751
- (_f = (_e = this["_callBackPromise"])["resolve"]) == null ? void 0 : _f.call(_e, _0x12013d["code"]);
752
- }
753
- async [_0x5d6a74(191)](_0x24164a, _0x2684e7) {
754
- const _0x2cbcf5 = _0x5d6a74, _0x12b20b = {};
755
- _0x12b20b["xAOmI"] = "POST";
756
- const _0x4cc43f = _0x12b20b, _0x3a3763 = {};
757
- _0x3a3763["Content-Type"] = _0x2cbcf5(217);
758
- const _0x53a66f = {};
759
- return _0x53a66f["state"] = _0x2684e7, fetch(_0x24164a, { "method": _0x4cc43f["xAOmI"], "headers": _0x3a3763, "body": new URLSearchParams(_0x53a66f) });
760
- }
761
- ["waitForOAuthCodeFunction"]() {
762
- const _0x1ca4ed = this["_callBackPromise"];
763
- return () => new Promise((_0x1030cc, _0x539f31) => {
764
- const _0x2c12d5 = _0x155f;
765
- _0x1ca4ed["resolve"] = _0x1030cc, _0x1ca4ed[_0x2c12d5(196)] = _0x539f31;
766
- });
767
- }
768
- get ["redirectUrl"]() {
769
- const _0x31ba8b = _0x5d6a74;
770
- return this[_0x31ba8b(206)];
771
- }
772
- get [_0x2395ea(190)]() {
773
- return this["_clientMetadata"];
774
- }
775
- [_0x5d6a74(213)]() {
776
- const _0x4de20c = _0x5d6a74;
777
- return this[_0x4de20c(197)];
778
- }
779
- [_0x2395ea(218)]() {
780
- const _0x487d24 = _0x2395ea;
781
- return this[_0x487d24(200)];
782
- }
783
- [_0x5d6a74(194)](_0x1ddce1) {
784
- this["_clientInformation"] = _0x1ddce1;
785
- }
786
- ["tokens"]() {
787
- const _0x15a6fa = _0x2395ea;
788
- return this[_0x15a6fa(210)];
789
- }
790
- ["saveTokens"](_0x2abe82) {
791
- const _0x3a88e4 = _0x2395ea;
792
- this[_0x3a88e4(210)] = _0x2abe82;
793
- }
794
- ["redirectToAuthorization"](_0xa7df50) {
795
- this["_redirectCallback"](_0xa7df50);
796
- }
797
- ["saveCodeVerifier"](_0x2163a6) {
798
- this["_codeVerifier"] = _0x2163a6;
799
- }
800
- [_0x5d6a74(212)]() {
801
- const _0x49e0fc = _0x5d6a74, _0x461a37 = {};
802
- _0x461a37[_0x49e0fc(215)] = _0x49e0fc(214);
803
- const _0x200fe3 = _0x461a37;
804
- if (!this[_0x49e0fc(209)]) throw new Error(_0x200fe3["mMdVl"]);
805
- return this[_0x49e0fc(209)];
806
- }
807
- }
808
- function _0x3878() {
809
- const _0x43619a = ["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"];
810
- _0x3878 = function() {
811
- return _0x43619a;
812
- };
813
- return _0x3878();
814
- }
815
- (function(_0x3939bd, _0x20a19c) {
816
- var _0x4403de = _0x275e, _0x27ff39 = _0x275e, _0x55a20b = _0x3939bd();
817
- while (!![]) {
818
- try {
819
- var _0x6b5cfe = parseInt(_0x4403de(291)) / (2899 + 8885 + 11783 * -1) + -parseInt(_0x4403de(295)) / (9470 + 4321 + 1 * -13789) * (parseInt(_0x4403de(288)) / (7018 + -2 * 207 + -7 * 943)) + parseInt(_0x4403de(290)) / (951 * 7 + 3954 * -2 + 1255 * 1) * (parseInt(_0x4403de(296)) / (7894 + 4576 + -12465)) + -parseInt(_0x27ff39(289)) / (8155 + -2779 + -5370) + parseInt(_0x4403de(293)) / (-2063 * -3 + -495 + -5687) * (-parseInt(_0x27ff39(294)) / (-91 * -11 + 4 * 2180 + -9713)) + parseInt(_0x27ff39(287)) / (-3006 + 3593 * 1 + -578) + parseInt(_0x27ff39(292)) / (-3955 + -6641 + 10606);
820
- if (_0x6b5cfe === _0x20a19c) break;
821
- else _0x55a20b["push"](_0x55a20b["shift"]());
822
- } catch (_0x38beb8) {
823
- _0x55a20b["push"](_0x55a20b["shift"]());
824
- }
825
- }
826
- })(_0x204d, 262 * -2438 + 1346066 * -1 + 2 * 1373311);
827
- function _0x204d() {
828
- var _0x54e54d = ["279100FsqxFu", "7326315yxcNFg", "50823VTWXXj", "6441948uoPUwt", "92BSiBRu", "1361711dyawqa", "5202960gnlAWp", "7tNVFlv", "11056792usEcvw", "90CRWXmt"];
829
- _0x204d = function() {
830
- return _0x54e54d;
831
- };
832
- return _0x204d();
833
- }
834
- function _0x275e(_0x25fced, _0x3ae797) {
835
- var _0x266459 = _0x204d();
836
- return _0x275e = function(_0x2ae679, _0x528716) {
837
- _0x2ae679 = _0x2ae679 - (6359 + 5503 + -11575);
838
- var _0x462119 = _0x266459[_0x2ae679];
839
- return _0x462119;
840
- }, _0x275e(_0x25fced, _0x3ae797);
841
- }
842
- class WebMcpServer {
843
- constructor(serverInfo, options) {
844
- const info = {
845
- name: "web-mcp-server",
846
- version: "1.0.0"
847
- };
848
- const capabilities = {
849
- prompts: { listChanged: true },
850
- resources: { subscribe: true, listChanged: true },
851
- tools: { listChanged: true },
852
- completions: {},
853
- logging: {}
854
- };
855
- this.server = new McpServer(serverInfo || info, options || { capabilities });
856
- this.server.server.oninitialized = () => {
857
- this.oninitialized?.();
858
- };
859
- this.server.server.onclose = () => {
860
- this.onclose?.();
861
- };
862
- this.server.server.onerror = (error) => {
863
- this.onerror?.(error);
864
- };
865
- this.server.server.setRequestHandler(SetLevelRequestSchema, async () => {
866
- return {};
867
- });
868
- }
869
- /**
870
- * Connects the server to a transport via the specified option.
871
- */
872
- async connect(options) {
873
- if (typeof options["start"] === "function") {
874
- this.transport = options;
875
- this.transport.onclose = void 0;
876
- this.transport.onerror = void 0;
877
- this.transport.onmessage = void 0;
878
- } else {
879
- this.transport = new MessageChannelServerTransport(options);
880
- await this.transport.listen();
881
- }
882
- await this.server.connect(this.transport);
883
- return this.transport;
884
- }
885
- /**
886
- * Closes the connection.
887
- */
888
- async close() {
889
- await this.server.close();
890
- }
891
- /**
892
- * Registers a tool with a config object and callback.
893
- */
894
- registerTool(name, config, cb) {
895
- return this.server.registerTool(name, config, cb);
896
- }
897
- /**
898
- * Registers a prompt with a config object and callback.
899
- */
900
- registerPrompt(name, config, cb) {
901
- return this.server.registerPrompt(name, config, cb);
902
- }
903
- registerResource(name, uriOrTemplate, config, readCallback) {
904
- if (typeof uriOrTemplate === "string") {
905
- return this.server.registerResource(name, uriOrTemplate, config, readCallback);
906
- } else {
907
- return this.server.registerResource(name, uriOrTemplate, config, readCallback);
908
- }
909
- }
910
- /**
911
- * Checks if the server is connected to a transport.
912
- * @returns True if the server is connected
913
- */
914
- isConnected() {
915
- return this.server.isConnected();
916
- }
917
- /**
918
- * Sends a resource list changed event to the client, if connected.
919
- */
920
- sendResourceListChanged() {
921
- this.server.sendResourceListChanged();
922
- }
923
- /**
924
- * Sends a tool list changed event to the client, if connected.
925
- */
926
- sendToolListChanged() {
927
- this.server.sendToolListChanged();
928
- }
929
- /**
930
- * Sends a prompt list changed event to the client, if connected.
931
- */
932
- sendPromptListChanged() {
933
- this.server.sendPromptListChanged();
934
- }
935
- /**
936
- * After initialization has completed, this will be populated with the client's reported capabilities.
937
- */
938
- getClientCapabilities() {
939
- return this.server.server.getClientCapabilities();
940
- }
941
- /**
942
- * After initialization has completed, this will be populated with information about the client's name and version.
943
- */
944
- getClientVersion() {
945
- return this.server.server.getClientVersion();
946
- }
947
- /**
948
- * Sends a ping to the client to check if it is still connected.
949
- */
950
- async ping() {
951
- return await this.server.server.ping();
952
- }
953
- /**
954
- * Creates a LLM message to be sent to the client.
955
- */
956
- async createMessage(params, options) {
957
- return await this.server.server.createMessage(params, options);
958
- }
959
- /**
960
- * Elicits input from the client, such as a prompt or resource.
961
- */
962
- async elicitInput(params, options) {
963
- return await this.server.server.elicitInput(params, options);
964
- }
965
- /**
966
- * Lists the root resources available to the client.
967
- */
968
- async listRoots(params, options) {
969
- return await this.server.server.listRoots(params, options);
970
- }
971
- /**
972
- * Sends a logging message to the client.
973
- */
974
- async sendLoggingMessage(params) {
975
- return await this.server.server.sendLoggingMessage(params);
976
- }
977
- /**
978
- * Sends a resource updated notification to the client.
979
- */
980
- async sendResourceUpdated(params) {
981
- return await this.server.server.sendResourceUpdated(params);
982
- }
983
- /**
984
- * Sends a request and wait for a response.
985
- *
986
- * Do not use this method to emit notifications! Use notification() instead.
987
- */
988
- request(request, resultSchema, options) {
989
- return this.server.server.request(request, resultSchema, options);
990
- }
991
- /**
992
- * Emits a notification, which is a one-way message that does not expect a response.
993
- */
994
- async notification(notification, options) {
995
- return await this.server.server.notification(notification, options);
996
- }
997
- /**
998
- * Registers a handler to invoke when this protocol object receives a request with the given method.
999
- *
1000
- * Note that this will replace any previous request handler for the same method.
1001
- */
1002
- setRequestHandler(requestSchema, handler) {
1003
- this.server.server.setRequestHandler(requestSchema, handler);
1004
- }
1005
- /**
1006
- * Removes the request handler for the given method.
1007
- */
1008
- removeRequestHandler(method) {
1009
- this.server.server.removeRequestHandler(method);
1010
- }
1011
- /**
1012
- * Registers a handler to invoke when this protocol object receives a notification with the given method.
1013
- *
1014
- * Note that this will replace any previous notification handler for the same method.
1015
- */
1016
- setNotificationHandler(notificationSchema, handler) {
1017
- this.server.server.setNotificationHandler(notificationSchema, handler);
1018
- }
1019
- /**
1020
- * Removes the notification handler for the given method.
1021
- */
1022
- removeNotificationHandler(method) {
1023
- this.server.server.removeNotificationHandler(method);
1024
- }
1025
- /**
1026
- * Registers a handler for the subscribe request.
1027
- */
1028
- onSubscribe(handler) {
1029
- this.server.server.setRequestHandler(SubscribeRequestSchema, handler);
1030
- }
1031
- /**
1032
- * Registers a handler for the unsubscribe request.
1033
- */
1034
- onUnsubscribe(handler) {
1035
- this.server.server.setRequestHandler(UnsubscribeRequestSchema, handler);
1036
- }
1037
- /**
1038
- * Registers a handler for the set log level request.
1039
- */
1040
- onSetLogLevel(handler) {
1041
- this.server.server.setRequestHandler(SetLevelRequestSchema, handler);
1042
- }
1043
- /**
1044
- * Registers a handler for the list tools request.
1045
- */
1046
- onListResources(handler) {
1047
- this.server.server.setRequestHandler(ListResourcesRequestSchema, handler);
1048
- }
1049
- /**
1050
- * Registers a handler for the roots list changed notification.
1051
- */
1052
- onRootsListChanged(handler) {
1053
- this.server.server.setNotificationHandler(RootsListChangedNotificationSchema, handler);
1054
- }
1055
- /**
1056
- * Close the transport for window.addEventListener('pagehide')
1057
- */
1058
- async onPagehide(event) {
1059
- if (event.persisted) {
1060
- return;
1061
- }
1062
- if (this.transport && typeof this.transport["close"] === "function") {
1063
- await this.transport.close();
1064
- }
1065
- }
1066
- }
1067
- const createMessageChannelServerTransport = (endpoint, globalObject) => new MessageChannelServerTransport(endpoint, globalObject);
1068
- const createMessageChannelPairTransport = () => createTransportPair();
1069
- const isMessageChannelServerTransport = (transport) => transport instanceof MessageChannelServerTransport;
1070
- const isMcpServer = (server) => server instanceof McpServer;
1071
- const setupBuiltinProxy = (transport) => {
1072
- const getNativeCtx = () => {
1073
- if (typeof navigator === "undefined") return null;
1074
- const nav = navigator;
1075
- return nav.modelContextTesting || null;
1076
- };
1077
- transport.onmessage = async (message) => {
1078
- if (!message || typeof message !== "object") return;
1079
- const id = message.id;
1080
- const method = message.method;
1081
- try {
1082
- if (method === "initialize") {
1083
- await transport.send({
1084
- jsonrpc: "2.0",
1085
- id,
1086
- result: {
1087
- protocolVersion: "2024-11-05",
1088
- capabilities: {
1089
- tools: { listChanged: true },
1090
- logging: {}
1091
- },
1092
- serverInfo: { name: "browser-builtin-webmcp-proxy", version: "1.0.0" }
1093
- }
1094
- });
1095
- } else if (method === "notifications/initialized") {
1096
- } else if (method === "ping" || method === "custom_ping") {
1097
- await transport.send({ jsonrpc: "2.0", id, result: {} });
1098
- } else if (method === "tools/list") {
1099
- const nativeCtx = getNativeCtx();
1100
- if (nativeCtx && nativeCtx.listTools) {
1101
- const rawTools = await nativeCtx.listTools();
1102
- const tools = rawTools.map((t) => {
1103
- let schemaObj = {};
1104
- if (typeof t.inputSchema === "string") {
1105
- try {
1106
- schemaObj = JSON.parse(t.inputSchema);
1107
- } catch (e) {
1108
- console.error("Failed to parse inputSchema:", e);
1109
- }
1110
- } else if (typeof t.inputSchema === "object" && t.inputSchema !== null) {
1111
- schemaObj = t.inputSchema;
1112
- }
1113
- return {
1114
- name: t.name,
1115
- description: t.description || "",
1116
- inputSchema: {
1117
- type: "object",
1118
- properties: schemaObj.properties || {},
1119
- required: schemaObj.required || []
1120
- }
1121
- };
1122
- });
1123
- await transport.send({ jsonrpc: "2.0", id, result: { tools } });
1124
- } else {
1125
- await transport.send({ jsonrpc: "2.0", id, result: { tools: [] } });
1126
- }
1127
- } else if (method === "tools/call") {
1128
- const nativeCtx = getNativeCtx();
1129
- if (nativeCtx && nativeCtx.executeTool) {
1130
- if (!message.params || typeof message.params !== "object" || !message.params.name) {
1131
- const error = new Error('Invalid params: "name" is required and params must be an object');
1132
- error.code = -32602;
1133
- throw error;
1134
- }
1135
- const { name, arguments: args } = message.params;
1136
- const result = await nativeCtx.executeTool(name, JSON.stringify(args || {}));
1137
- const finalResult = result && typeof result === "object" && "content" in result ? result : { content: [{ type: "text", text: typeof result === "string" ? result : JSON.stringify(result) }] };
1138
- await transport.send({ jsonrpc: "2.0", id, result: finalResult });
1139
- } else {
1140
- const error = new Error("executeTool not implemented in Browser built-in WebMCP");
1141
- error.code = -32601;
1142
- throw error;
1143
- }
1144
- } else if (method === "logging/setLevel") {
1145
- await transport.send({ jsonrpc: "2.0", id, result: {} });
1146
- } else if (method === "prompts/list") {
1147
- await transport.send({ jsonrpc: "2.0", id, result: { prompts: [] } });
1148
- } else if (method === "resources/list") {
1149
- await transport.send({ jsonrpc: "2.0", id, result: { resources: [] } });
1150
- } else if (id !== void 0) {
1151
- await transport.send({
1152
- jsonrpc: "2.0",
1153
- id,
1154
- error: { code: -32601, message: `Method not found: ${method}` }
1155
- });
1156
- }
1157
- } catch (err) {
1158
- if (id !== void 0) {
1159
- await transport.send({
1160
- jsonrpc: "2.0",
1161
- id,
1162
- error: { code: err.code || -32e3, message: err.message || String(err) }
1163
- });
1164
- }
1165
- }
1166
- };
1167
- };
1168
- class WebMcpClient {
1169
- constructor(clientInfo, options) {
1170
- const info = {
1171
- name: "web-mcp-client",
1172
- version: "1.0.0"
1173
- };
1174
- const capabilities = {
1175
- roots: { listChanged: true },
1176
- sampling: {},
1177
- elicitation: {}
1178
- };
1179
- this.client = new Client(clientInfo || info, options || { capabilities });
1180
- this.client.onclose = () => {
1181
- this.onclose?.();
1182
- };
1183
- this.client.onerror = (error) => {
1184
- this.onerror?.(error);
1185
- };
1186
- }
1187
- /**
1188
- * Connects the client to a transport via the specified option.
1189
- */
1190
- async connect(options) {
1191
- if (typeof options["start"] === "function") {
1192
- this.transport = options;
1193
- this.transport.onclose = void 0;
1194
- this.transport.onerror = void 0;
1195
- this.transport.onmessage = void 0;
1196
- await this.client.connect(this.transport);
1197
- return { transport: this.transport, sessionId: this.transport.sessionId };
1198
- }
1199
- const { url, token, sessionId, type, agent, builtin, onError } = options;
1200
- if (agent) {
1201
- const proxyOptions = { client: this.client, url, token, sessionId };
1202
- const response = type === "sse" ? await createSseProxy(proxyOptions) : type === "socket" ? await createSocketProxy(proxyOptions) : await createStreamProxy(proxyOptions);
1203
- response.transport.onerror = async (error) => {
1204
- onError?.(error);
1205
- };
1206
- if (builtin) {
1207
- setupBuiltinProxy(response.transport);
1208
- }
1209
- return response;
1210
- }
1211
- const endpoint = new URL(url);
1212
- let transport;
1213
- if (type === "channel") {
1214
- transport = new MessageChannelClientTransport(url);
1215
- await this.client.connect(transport);
1216
- }
1217
- if (type === "sse") {
1218
- const opts = sseOptions(token, sessionId);
1219
- transport = new SSEClientTransport(endpoint, opts);
1220
- await this.client.connect(transport);
1221
- }
1222
- if (type === "socket") {
1223
- transport = new WebSocketClientTransport(new URL(`${url}?sessionId=${sessionId}&token=${token}`));
1224
- transport.sessionId = sessionId;
1225
- await this.client.connect(transport);
1226
- }
1227
- if (type === "stream" || typeof transport === "undefined") {
1228
- const opts = streamOptions(token, sessionId);
1229
- transport = new StreamableHTTPClientTransport(endpoint, opts);
1230
- await this.client.connect(transport);
1231
- }
1232
- this.transport = transport;
1233
- return { transport: this.transport, sessionId: this.transport.sessionId };
1234
- }
1235
- /**
1236
- * Closes the connection.
1237
- */
1238
- async close() {
1239
- await this.client.close();
1240
- }
1241
- /**
1242
- * After initialization has completed, this will be populated with the server's reported capabilities.
1243
- */
1244
- getServerCapabilities() {
1245
- return this.client.getServerCapabilities();
1246
- }
1247
- /**
1248
- * After initialization has completed, this will be populated with information about the server's name and version.
1249
- */
1250
- getServerVersion() {
1251
- return this.client.getServerVersion();
1252
- }
1253
- /**
1254
- * After initialization has completed, this may be populated with information about the server's instructions.
1255
- */
1256
- getInstructions() {
1257
- return this.client.getInstructions();
1258
- }
1259
- /**
1260
- * Sends a ping to the server to check if it is still connected.
1261
- */
1262
- async ping(options) {
1263
- return await this.client.ping(options);
1264
- }
1265
- /**
1266
- * Sends a completion request to the server.
1267
- */
1268
- async complete(params, options) {
1269
- return await this.client.complete(params, options);
1270
- }
1271
- /**
1272
- * Sends a request for setting the logging level to the server.
1273
- */
1274
- async setLoggingLevel(level, options) {
1275
- return await this.client.setLoggingLevel(level, options);
1276
- }
1277
- /**
1278
- * Gets the prompt with the given params from the server.
1279
- */
1280
- async getPrompt(params, options) {
1281
- return await this.client.getPrompt(params, options);
1282
- }
1283
- /**
1284
- * Lists all prompts available on the server.
1285
- */
1286
- async listPrompts(params, options) {
1287
- return await this.client.listPrompts(params, options);
1288
- }
1289
- /**
1290
- * Lists all resources available on the server.
1291
- */
1292
- async listResources(params, options) {
1293
- return await this.client.listResources(params, options);
1294
- }
1295
- /**
1296
- * Lists all resource templates available on the server.
1297
- */
1298
- async listResourceTemplates(params, options) {
1299
- return await this.client.listResourceTemplates(params, options);
1300
- }
1301
- /**
1302
- * Reads the resource with the given params from the server.
1303
- */
1304
- async readResource(params, options) {
1305
- return await this.client.readResource(params, options);
1306
- }
1307
- /**
1308
- * Subscribes to a resource on the server.
1309
- */
1310
- async subscribeResource(params, options) {
1311
- return await this.client.subscribeResource(params, options);
1312
- }
1313
- /**
1314
- * Unsubscribes from a resource on the server.
1315
- */
1316
- async unsubscribeResource(params, options) {
1317
- return await this.client.unsubscribeResource(params, options);
1318
- }
1319
- /**
1320
- * Calls a tool on the server with the given parameters.
1321
- */
1322
- async callTool(params, options) {
1323
- return await this.client.callTool(params, CallToolResultSchema, options);
1324
- }
1325
- /**
1326
- * Lists all tools available on the server.
1327
- */
1328
- async listTools(params, options) {
1329
- return await this.client.listTools(params, options);
1330
- }
1331
- /**
1332
- * Sends a notification for the roots list changed event to the server.
1333
- */
1334
- async sendRootsListChanged() {
1335
- return await this.client.sendRootsListChanged();
1336
- }
1337
- /**
1338
- * Sends a request and wait for a response.
1339
- *
1340
- * Do not use this method to emit notifications! Use notification() instead.
1341
- */
1342
- request(request, resultSchema, options) {
1343
- return this.client.request(request, resultSchema, options);
1344
- }
1345
- /**
1346
- * Emits a notification, which is a one-way message that does not expect a response.
1347
- */
1348
- async notification(notification, options) {
1349
- return await this.client.notification(notification, options);
1350
- }
1351
- /**
1352
- * Registers a handler to invoke when this protocol object receives a request with the given method.
1353
- *
1354
- * Note that this will replace any previous request handler for the same method.
1355
- */
1356
- setRequestHandler(requestSchema, handler) {
1357
- this.client.setRequestHandler(requestSchema, handler);
1358
- }
1359
- /**
1360
- * Removes the request handler for the given method.
1361
- */
1362
- removeRequestHandler(method) {
1363
- this.client.removeRequestHandler(method);
1364
- }
1365
- /**
1366
- * Registers a handler to invoke when this protocol object receives a notification with the given method.
1367
- *
1368
- * Note that this will replace any previous notification handler for the same method.
1369
- */
1370
- setNotificationHandler(notificationSchema, handler) {
1371
- this.client.setNotificationHandler(notificationSchema, handler);
1372
- }
1373
- /**
1374
- * Removes the notification handler for the given method.
1375
- */
1376
- removeNotificationHandler(method) {
1377
- this.client.removeNotificationHandler(method);
1378
- }
1379
- /**
1380
- * Registers a handler for the elicitation request.
1381
- */
1382
- onElicit(handler) {
1383
- this.client.setRequestHandler(ElicitRequestSchema, handler);
1384
- }
1385
- /**
1386
- * Registers a handler for the create LLM message request.
1387
- */
1388
- onCreateMessage(handler) {
1389
- this.client.setRequestHandler(CreateMessageRequestSchema, handler);
1390
- }
1391
- /**
1392
- * Registers a handler for the list roots request.
1393
- */
1394
- onListRoots(handler) {
1395
- this.client.setRequestHandler(ListRootsRequestSchema, handler);
1396
- }
1397
- /**
1398
- * Registers a handler for the tool list changed notification.
1399
- */
1400
- onToolListChanged(handler) {
1401
- this.client.setNotificationHandler(ToolListChangedNotificationSchema, handler);
1402
- }
1403
- /**
1404
- * Registers a handler for the prompt list changed notification.
1405
- */
1406
- onPromptListChanged(handler) {
1407
- this.client.setNotificationHandler(PromptListChangedNotificationSchema, handler);
1408
- }
1409
- /**
1410
- * Registers a handler for the resource list changed notification.
1411
- */
1412
- onResourceListChanged(handler) {
1413
- this.client.setNotificationHandler(ResourceListChangedNotificationSchema, handler);
1414
- }
1415
- /**
1416
- * Registers a handler for the resource updated notification.
1417
- */
1418
- onResourceUpdated(handler) {
1419
- this.client.setNotificationHandler(ResourceUpdatedNotificationSchema, handler);
1420
- }
1421
- /**
1422
- * Registers a handler for the logging message notification.
1423
- */
1424
- onLoggingMessage(handler) {
1425
- this.client.setNotificationHandler(LoggingMessageNotificationSchema, handler);
1426
- }
1427
- /**
1428
- * Close the transport for window.addEventListener('pagehide')
1429
- */
1430
- async onPagehide(event) {
1431
- if (event.persisted) {
1432
- return;
1433
- }
1434
- if (isStreamableHTTPClientTransport(this.transport)) {
1435
- await this.transport.terminateSession();
1436
- } else if (this.transport && typeof this.transport["close"] === "function") {
1437
- await this.transport.close();
1438
- }
1439
- }
1440
- }
1441
- const createSSEClientTransport = (url, opts) => new SSEClientTransport(url, opts);
1442
- const createStreamableHTTPClientTransport = (url, opts) => new StreamableHTTPClientTransport(url, opts);
1443
- const createMessageChannelClientTransport = (endpoint, globalObject) => new MessageChannelClientTransport(endpoint, globalObject);
1444
- const isSSEClientTransport = (transport) => transport instanceof SSEClientTransport;
1445
- const isStreamableHTTPClientTransport = (transport) => transport instanceof StreamableHTTPClientTransport;
1446
- const isMessageChannelClientTransport = (transport) => transport instanceof MessageChannelClientTransport;
1447
- const isMcpClient = (client) => client instanceof Client;
1448
- const randomUUID = () => {
1449
- if (typeof crypto !== "undefined" && crypto.randomUUID) {
1450
- return crypto.randomUUID();
1451
- }
1452
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
1453
- const r = Math.random() * 16 | 0;
1454
- const v = c === "x" ? r : r & 3 | 8;
1455
- return v.toString(16);
1456
- });
1457
- };
1458
- const sendWindowMessage = (type, data, direction) => {
1459
- window.postMessage({ type, direction, data }, "*");
1460
- };
1461
- const onWindowMessage = (type, cb, direction) => {
1462
- const handler = async function(event) {
1463
- if (event.source === window && event.data.type === type && event.data.direction === direction) {
1464
- await cb(event.data.data);
1465
- }
1466
- };
1467
- window.addEventListener("message", handler);
1468
- return () => window.removeEventListener("message", handler);
1469
- };
1470
- class ExtensionPageServerTransport {
1471
- constructor(sessionId = null) {
1472
- this._isStarted = false;
1473
- this._isClosed = false;
1474
- this._lastRegistration = null;
1475
- this.sessionId = sessionId || randomUUID();
1476
- this._messageListener2 = onWindowMessage(
1477
- "mcp-client-to-server-to-page",
1478
- (data) => {
1479
- if (data.sessionId !== this.sessionId) return;
1480
- console.log("【Page Svr Transport】 即将处理 mcpMessage", data.mcpMessage);
1481
- const mcpMessage = JSONRPCMessageSchema.parse(data.mcpMessage);
1482
- this.onmessage?.(mcpMessage);
1483
- const toolName = data.mcpMessage.params?.name;
1484
- if (toolName) {
1485
- sendWindowMessage(
1486
- "update-page-app-message",
1487
- { status: "run", message: data.mcpMessage.params?.name },
1488
- "page->content"
1489
- );
1490
- }
1491
- },
1492
- "content->page"
1493
- );
1494
- }
1495
- // 最后一次注册信息(用于 Sidepanel 刷新后重新注册)
1496
- _throwError(whenFn, message) {
1497
- if (whenFn()) {
1498
- const error = new Error(message);
1499
- console.log(message, error);
1500
- if (this.onerror) {
1501
- this.onerror(error);
1502
- }
1503
- throw error;
1504
- }
1505
- }
1506
- /** 启动 transport,开始监听消息 */
1507
- async start() {
1508
- if (this._isStarted) return;
1509
- if (this._isClosed) throw new Error("【Page Svr Transport】 已关闭,无法重新启动");
1510
- this._isStarted = true;
1511
- }
1512
- /** 发送消息到 MCP Client */
1513
- async send(message, _options) {
1514
- this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法发送消息");
1515
- this._throwError(() => this._isClosed, "【Page Svr Transport】 已关闭,无法发送消息");
1516
- sendWindowMessage(
1517
- "mcp-server-to-client-from-page",
1518
- {
1519
- sessionId: this.sessionId,
1520
- mcpMessage: message
1521
- },
1522
- "page->content"
1523
- );
1524
- if ("result" in message && message.result?.content) {
1525
- sendWindowMessage(
1526
- "update-page-app-message",
1527
- { status: "ready", message: "" },
1528
- "page->content"
1529
- // 此处应该是 content->content, 但为了和pageServerTransport统一。
1530
- );
1531
- }
1532
- }
1533
- /** 通知 Sidepanel 此 Server 已启动并准备接受连接 */
1534
- async notifyRegistration(serverInfo) {
1535
- this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法注册消息");
1536
- this._lastRegistration = serverInfo;
1537
- try {
1538
- sendWindowMessage(
1539
- "mcp-server-register-from-page",
1540
- {
1541
- sessionId: this.sessionId,
1542
- serverInfo: {
1543
- ...serverInfo,
1544
- url: window.location.origin,
1545
- title: document.title
1546
- }
1547
- },
1548
- "page->content"
1549
- );
1550
- } catch (error) {
1551
- this._throwError(() => true, "【Page Svr Transport】 注册 server 失败" + String(error));
1552
- }
1553
- }
1554
- /** 关闭 transport */
1555
- async close() {
1556
- if (this._isClosed) return;
1557
- try {
1558
- this._messageListener2 && this._messageListener2();
1559
- this._isClosed = true;
1560
- this._isStarted = false;
1561
- this.onclose && this.onclose();
1562
- } catch (error) {
1563
- this._throwError(() => true, "【Page Svr Transport】 关闭时发生错误" + String(error));
1564
- }
1565
- }
1566
- }
1567
- export {
1568
- default2 as Ajv,
1569
- AuthClientProvider,
1570
- ExtensionPageServerTransport,
1571
- ResourceTemplate,
1572
- UriTemplate,
1573
- WebMcpClient,
1574
- WebMcpServer,
1575
- completable,
1576
- createMessageChannelClientTransport,
1577
- createMessageChannelPairTransport,
1578
- createMessageChannelServerTransport,
1579
- createSSEClientTransport,
1580
- createStreamableHTTPClientTransport,
1581
- getDisplayName,
1582
- isMcpClient,
1583
- isMcpServer,
1584
- isMessageChannelClientTransport,
1585
- isMessageChannelServerTransport,
1586
- isSSEClientTransport,
1587
- isStreamableHTTPClientTransport,
1588
- z
1589
- };