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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/webmcp.js CHANGED
@@ -1 +1 @@
1
- (function(f,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("ajv"),require("@modelcontextprotocol/sdk/types.js"),require("@modelcontextprotocol/sdk/client/index.js"),require("@modelcontextprotocol/sdk/client/sse.js"),require("@modelcontextprotocol/sdk/client/streamableHttp.js"),require("@modelcontextprotocol/sdk/client/websocket.js"),require("@modelcontextprotocol/sdk/client/auth.js"),require("@modelcontextprotocol/sdk/server/mcp.js"),require("zod"),require("@modelcontextprotocol/sdk/shared/uriTemplate.js"),require("@modelcontextprotocol/sdk/server/completable.js"),require("@modelcontextprotocol/sdk/shared/metadataUtils.js")):typeof define=="function"&&define.amd?define(["exports","ajv","@modelcontextprotocol/sdk/types.js","@modelcontextprotocol/sdk/client/index.js","@modelcontextprotocol/sdk/client/sse.js","@modelcontextprotocol/sdk/client/streamableHttp.js","@modelcontextprotocol/sdk/client/websocket.js","@modelcontextprotocol/sdk/client/auth.js","@modelcontextprotocol/sdk/server/mcp.js","zod","@modelcontextprotocol/sdk/shared/uriTemplate.js","@modelcontextprotocol/sdk/server/completable.js","@modelcontextprotocol/sdk/shared/metadataUtils.js"],D):(f=typeof globalThis<"u"?globalThis:f||self,D(f.WebMCP={},f.MCPSDK,f.MCPSDK,f.MCPSDK,f.MCPSDK,f.MCPSDK,f.websocket_js,f.MCPSDK,f.MCPSDK,f.Zod,f.MCPSDK,f.MCPSDK,f.MCPSDK))})(this,(function(f,D,b,A,V,j,ae,pe,ee,xe,_e,me,ve){"use strict";const H=y;(function(r,e){const t=y,n=y,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(K,-118057+3521*-35+-2099*-233);const ce=()=>{const r=y,e=y,t={};t[r(420)]="3|0|2|1|4",t.vQYJZ=function(a,i){return a!==i},t[e(394)]=e(414),t.ktWqD=function(a,i){return a!==i},t[r(424)]=r(391);const n=t,s=n[e(420)].split("|");let o=859*2+-3*-1039+-4835*1;for(;;){switch(s[o++]){case"0":if(n[e(407)](typeof window,"undefined"))return window;continue;case"1":if(n.vQYJZ(typeof self,n.NZmUq))return self;continue;case"2":if(n[e(405)](typeof global,"undefined"))return global;continue;case"3":if(n[e(405)](typeof globalThis,n[r(394)]))return globalThis;continue;case"4":return Function(n[r(424)])()}break}},ge=(r,e,t)=>{const n=y,s=y,o={};o.eOzBp=function(i,c){return i!==c},o.ooaJk="undefined",o[n(402)]=function(i,c){return i===c},o[n(421)]="function";const a=o;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)},we=(r,e)=>{const t=y,n=y,s={};s.nTCfA=function(a,i){return a in i},s[t(390)]="addEventListener",s[t(385)]=function(a,i){return a===i},s[t(409)]="function",s.VaHpd=n(392),s[n(384)]=t(417),s.FPOYW=function(a,i){return a!==i};const o=s;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)};class z{constructor(e){this._port=e}async[H(401)](){const e=H,t=H;this[e(422)]&&(this[t(422)].onmessage=n=>{var s,o;const a=e;try{const i=b.JSONRPCMessageSchema.parse(n.data.message);(s=this.onmessage)==null||s.call(this,i,n[a(412)][a(428)])}catch(i){const c=new Error("MessageChannel failed to parse message: "+i);(o=this[a(383)])==null||o.call(this,c)}},this._port.onmessageerror=n=>{var s;const o=t,a=new Error("MessageChannel transport error: "+JSON[o(415)](n));(s=this.onerror)==null||s.call(this,a)},this[t(422)].start())}async send(e,t){const n={EoBZE:function(s){return s()},leEiG:function(s,o){return s instanceof o},cDUwk:function(s,o){return s(o)}};return new Promise((s,o)=>{var a;const i=y,c=y;try{const l={};l[i(404)]=t?.[i(404)];const d={};d[i(392)]=e,d.extra=l,this._port&&this._port[c(423)](d),n[i(399)](s)}catch(l){const d=n.leEiG(l,Error)?l:new Error(n.cDUwk(String,l));(a=this.onerror)==null||a.call(this,d),o(d)}})}async close(){var e,t;const n=H,s=H;(e=this._port)==null||e[n(393)](),this[n(422)]=void 0,(t=this[s(408)])==null||t.call(this)}}class te extends z{constructor(e,t=ce()){const n=H,s={lSpBh:function(a,i,c,l){return a(i,c,l)}};super(),this._endpoint=e,this._globalObject=t;const o=new MessageChannel;this._port=o[n(410)],s[n(418)](ge,this._globalObject,{endpoint:this[n(397)]},[o[n(429)]])}}class ne extends z{constructor(e,t=ce()){const n=H,s=H,o={HITdC:function(a,i){return a===i},QdDxM:function(a){return a()},jowPp:function(a,i,c){return a(i,c)}};super(),this[n(397)]=e,this[s(388)]=t,this[s(416)]=new Promise(a=>{const i=n,c={XlglK:function(l,d){return o.HITdC(l,d)},pXlad:function(l){return o.QdDxM(l)}};o[i(427)](we,this._globalObject,l=>{const d=i,u=i;l[d(412)]&&c.XlglK(l.data[u(396)],this._endpoint)&&(this[d(422)]=l[u(430)][-3036+-1518*-2],c.pXlad(a))})})}async listen(){return this._listen}}function K(){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"];return K=function(){return r},K()}function y(r,e){const t=K();return y=function(n,s){return n=n-(17227+1*-16844),t[n]},y(r,e)}const be=()=>{const r=new MessageChannel;return[new z(r.port1),new z(r.port2)]};(function(r,e){const t=_,n=_,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(X,-411935*1+228107+208149*2);const Ce=async(r,e,t)=>{var n;const s=_,o=_,a={};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);const i=a,{id:c,method:l,params:d}=t;let u={};switch(l){case i.VRyiJ:u=await e.listTools(d);break;case i.VkPYu:u=await e.callTool(d);break;case i.fgMSD:u=await e.listResources(d);break;case i[o(466)]:u=await e.listResourceTemplates(d);break;case i.sthgI:u=await e[s(455)](d);break;case o(486):u=await e.subscribeResource(d);break;case s(410):u=await e.unsubscribeResource(d);break;case i[o(461)]:u=await e[o(414)](d);break;case i[s(412)]:u=await e[s(491)](d);break;case i[s(436)]:u=await e[s(478)]();break;case i.kkNqg:u=await e.complete(d);break;case s(464):u=await e.setLoggingLevel(d?.[o(443)]);break}const h={};h.result=u,h.jsonrpc=i[o(472)],h.id=c,await((n=r?.[o(488)])==null?void 0:n[s(460)](h))},ye=async(r,e,t)=>{var n;const s=_,o=_,a={};a[s(487)]=o(462),a.ypHTC="ping",a.fPExS=s(465);const i=a,{id:c,method:l,params:d}=t;let u={};switch(l){case"roots/list":const p={};p.method=l,p[o(446)]=d,u=await e[s(469)](p,b.ListRootsResultSchema);break;case"sampling/createMessage":const m={};m[s(481)]=l,m[s(446)]=d,u=await e.request(m,b.CreateMessageResultSchema);break;case i[s(487)]:const x={};x.method=l,x[o(446)]=d,u=await e.request(x,b.ElicitResultSchema);break;case i.ypHTC:const v={};v.method=l,u=await e.request(v,b.EmptyResultSchema);break}const h={};return h.result=u,h.jsonrpc=i.fPExS,h.id=c,await((n=r?.transport)==null?void 0:n.send(h)),u};function _(r,e){const t=X();return _=function(n,s){return n=n-(-8023+4*-2344+-17809*-1),t[n]},_(r,e)}const Se=(r,e)=>{const t=_,n=_,s={vYlhn:function(a,i){return a===i},DhPFX:t(470),NYVNC:function(a,i,c,l){return a(i,c,l)},yfZbw:"2.0"},o=r._onrequest;r[n(463)]=async(a,i)=>{var c,l,d,u,h;const p=n,m=t,{id:x,method:v}=a;try{s[p(451)](v,s.DhPFX)?await o.call(r,a,i):await s[m(474)](Ce,r,e,a)}catch(g){const{code:S,message:P,data:q}=g;try{if(S){const C={};C[m(485)]=S,C[p(422)]=P,C.data=q;const k={};k[m(448)]=C,k.jsonrpc=s[p(417)],k.id=x,await((c=r?.transport)==null?void 0:c[m(460)](k))}else(d=(l=r?.transport)==null?void 0:l.onerror)==null||d.call(l,g)}catch(C){(h=(u=r?.transport)==null?void 0:u.onerror)==null||h.call(u,C)}}}},Ie=(r,e)=>{const t=_,n=_,s={};s[t(476)]=t(439),s[t(431)]=function(a,i){return a!==i},s.UPdQt="notifications/cancelled";const o=s;r[t(421)]=async a=>{var i,c;const l=t,d=n,{method:u,params:h}=a;if(u!==o[l(476)]&&(o.QWYMz(u,o.UPdQt)||h?.[d(490)]))try{await e[l(445)](a)}catch(p){(c=(i=r?.[l(488)])==null?void 0:i[l(480)])==null||c.call(i,p)}}},Re=(r,e)=>async t=>{var n,s,o,a,i;const c=_,l=_,d={TJhyV:function(u,h,p,m){return u(h,p,m)},MMNTY:c(465)};try{return await d.TJhyV(ye,r,e,t)}catch(u){const{code:h,message:p,data:m}=u;try{if(h){const x={};x.code=h,x[c(422)]=p,x[l(419)]=m;const v={};v[c(448)]=x,v[c(424)]=d.MMNTY,v.id=t.id,await((n=r?.transport)==null?void 0:n[l(460)](v))}else(o=(s=r?.transport)==null?void 0:s[c(480)])==null||o.call(s,u)}catch(x){(i=(a=r?.[c(488)])==null?void 0:a.onerror)==null||i.call(a,x)}}},Te=(r,e)=>async t=>{var n,s,o;const a=_,i=_,c={};c.xmcLM=function(h,p){return h!==p},c.xSWLt="notifications/initialized",c[a(420)]=i(453);const l=c,{method:d,params:u}=t;if(l.xmcLM(d,l.xSWLt)&&(l.xmcLM(d,l[i(420)])||u?.[i(490)]))try{const h={...t};h.jsonrpc=a(465),await((n=e?.[a(488)])==null?void 0:n.send(h))}catch(h){(o=(s=r?.transport)==null?void 0:s.onerror)==null||o.call(s,h)}};function X(){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"];return X=function(){return r},X()}const Pe=(r,e)=>async t=>{var n,s,o,a,i,c;const l=_,d=_,u={};u.kSvAZ=l(465);const h=u;try{await((n=e?.[d(488)])==null?void 0:n[d(460)](t))}catch(p){const{code:m,message:x,data:v}=p;try{if(m){const g={};g.code=m,g.message=x,g.data=v;const S={};S.error=g,S[d(424)]=h.kSvAZ,S.id=t.id,await((s=r?.transport)==null?void 0:s.send(S))}else(a=(o=r?.transport)==null?void 0:o[l(480)])==null||a.call(o,p)}catch(g){(c=(i=r?.[l(488)])==null?void 0:i[d(480)])==null||c.call(i,g)}}},se=()=>{const r=_,e={rgPZO:function(c,l){return c!==l},VWsxO:function(c,l){return c(l)},FjTAY:"function"},t=[],n=(c,l)=>{const d=_;if(l){const u=[];for(const h of t)try{u.push(h(c,l))}catch{}for(const h of u)if(e.rgPZO(h,null))return h}else for(const u of t)try{e[d(427)](u,c)}catch{}},s=c=>{const l=_,d=_;typeof c===e[l(456)]&&!t.includes(c)&&t[d(471)](c)},o=c=>{const l=_,d=t[l(415)](c);d!==-1&&t.splice(d,-17591+6*2932)},a=()=>{const c=_;t[c(430)]=-505*7+1322+2213},i={};return i.handleListener=n,i[r(447)]=s,i.removeListener=o,i.clearListener=a,i},ke=r=>{const e=_,t=_,n={UlqiY:function(s){return s()},jsmFN:function(s){return s()}};{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(423)](se);r._onresponse=s,r[t(438)]=o,r.removeResponseListener=a,r.clearResponseListener=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(489)](se);r[e(432)]=s,r[t(473)]=o,r.removeRequestListener=a,r.clearRequestListener=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n.jsmFN(se);r.fallbackNotificationHandler=s,r[e(444)]=o,r.removeNotificationListener=a,r[t(426)]=i}},Le=(r,{beforeInit:e,afterInit:t}={})=>{const n=_,s=_,o={HucXo:function(i,c){return i===c},HicFO:n(468),JMaxV:function(i){return i()},DclXr:function(i,c){return i(c)},UynHf:function(i,c){return i===c},yCyFn:function(i){return i()}},a=new Map(r._notificationHandlers);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(ke,r),r[s(438)](i=>{const c=n;r.originalOnResponse[c(440)](r,i)}),o[n(429)](typeof t,o.HicFO)&&o[s(425)](t),r[s(444)](i=>{const c=s,{method:l}=i,d=a[c(483)](l);o[c(467)](typeof d,"function")&&d(i)})},Me=L;(function(r,e){const t=L,n=L,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(Y,995159+-6*-266138+-1619768);const qe=()=>{const r=L,e=L,t={};t.svuxn=function(s,o){return s&o},t.ZUPdr=function(s,o){return s===o},t[r(227)]=function(s,o){return s===o},t.SpRzi="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";const n=t;return n[e(227)](typeof crypto,"object")&&crypto[r(211)]?crypto.randomUUID():n.SpRzi.replace(/[xy]/g,s=>{const o=r,a=n.svuxn(crypto.getRandomValues(new Uint8Array(-3798+8571*-1+12370))[0],-8324+8339*1);return(n[o(225)](s,"x")?a:n[o(209)](a,-12998+-1*-13001)|813*10+-3707+883*-5).toString(-1*-1851+6493+-8328)})},He=r=>{const e=L,t=L,n=new Uint8Array(r);return crypto[e(221)](n),Array[t(218)](n,s=>s[t(226)](11424+4*-2852).padStart(8950+2237*-4,"0"))[e(213)]("")},U={};U[Me(211)]=qe,U.randomBytes=He;function L(r,e){const t=Y();return L=function(n,s){return n=n-(-7373+7187*1+395),t[n]},L(r,e)}function Y(){const r=["join","2500590yHdCUG","3CzpgOE","219762yRRBUK","592022JqIdxi","from","6033730pSHJFF","28gKZiuO","getRandomValues","147169GUBreL","5fFOMNB","1140KVOWlq","ZUPdr","toString","DBGzc","45351XtLuDF","svuxn","9892WpQPGF","randomUUID","2504EaskHQ"];return Y=function(){return r},Y()}function M(r,e){const t=Z();return M=function(n,s){return n=n-(-1483*3+-5564+20*513),t[n]},M(r,e)}const R=M,W=M;(function(r,e){const t=M,n=M,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(Z,-4*308317+753182*2+658196);const Ue=(r,e)=>{const t=M,n=M,s={olCWX:function(c,l,d){return c(l,d)},sfXDX:function(c,l,d){return c(l,d)},ksWFu:function(c,l,d){return c(l,d)}};s[t(283)](Se,r,e),Ie(r,e);const o=s[n(283)](Re,e,r),a=s[n(294)](Pe,e,r),i=s[t(277)](Te,e,r);e.addRequestListener(o),e.addResponseListener(a),e[n(287)](i),r.onclose=()=>{const c=t,l=n;e[c(247)](o),e.removeResponseListener(a),e[l(252)](i)}},re=(r,e,t)=>{const n={QhPqi:function(a,i){return a instanceof i},AIICR:"close",Qalmc:function(a,i,c){return a(i,c)}},s=()=>{var a;n.QhPqi(t,V.SSEClientTransport)&&((a=t._eventSource)==null||a.addEventListener(n.AIICR,()=>{var i;(i=t[M(295)])==null||i.close()})),n.Qalmc(Ue,r,e)},o={};o.afterInit=s,n.Qalmc(Le,e,o)},le=(r,e=U[R(299)]())=>{const t=R,n=R,s={RVabx:function(d,u,h){return d(u,h)},crCTs:"include"},o={};o["sse-session-id"]=e;const a=o,i={};i["sse-session-id"]=e;const c={};c.headers=i,c.credentials=s[t(304)];const l={requestInit:c,eventSourceInit:{async fetch(d,u){const h=t,p=t,m=new Headers(u?.[h(268)]||{});Object.entries(a).forEach(([v,g])=>{m.set(v,g)});const x={...u};return x.headers=m,s[p(279)](fetch,d,x)},withCredentials:!0}};return r&&(l[t(280)].headers.Authorization="Bearer "+r,a.Authorization=n(256)+r),l},de=(r,e=U[R(299)]())=>{const t=W,n=R,s={};s[t(271)]="include";const o=s,a={};a["stream-session-id"]=e;const i={};i[n(268)]=a,i.credentials=o[t(271)];const c={};c.requestInit=i;const l=c;return r&&(l[n(280)][t(268)][n(301)]=t(256)+r),l},oe=async(r,e,t)=>{const n=R,s=R,o={rRtFD:function(i){return i()},ToRAF:function(i,c){return i instanceof c}},a=o[n(276)](t);try{return await r[s(260)](a),a}catch(i){if(o[n(275)](i,pe.UnauthorizedError)){const c=await e();return await a[n(257)](c),await oe(r,e,t)}else throw i}},ue=(r,e)=>{const t=W,n=W,s={};s[t(267)]=function(a,i){return a in i},s.timcZ="waitForOAuthCode",s[t(253)]=function(a,i){return a===i},s.ufiEQ=t(285),s[n(250)]=t(293);const o=s;if(o.oGmBG(o[t(258)],r))return r[n(278)];if(o[n(253)](typeof e,o.ufiEQ))return e;throw new Error(o.daYBw)};function Z(){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"];return Z=function(){return r},Z()}const Ee=async r=>{const e=W,t=R,n={GKDjq:function(w,O,F){return w(O,F)},JzpWy:e(281),mcbiU:"1.0.0",CfBXU:function(w){return w()},kdowC:function(w,O,F,ie){return w(O,F,ie)},KkViY:"sessionId"},{client:s,url:o,token:a,sessionId:i,authProvider:c,requestInit:l,eventSourceInit:d,waitForOAuthCode:u}=r,h={};h[t(305)]=c,h.requestInit=l,h.eventSourceInit=d;const p=h,m=i||U[t(299)](),x=n[e(289)](le,a,m);if(l){const w={...x.requestInit,...l};w[t(268)]={...x[t(280)][e(268)],...l.headers},p.requestInit=w}else p.requestInit=x[e(280)];if(d){const w={...x[e(270)],...d};p.eventSourceInit=w}else p.eventSourceInit=x[e(270)];const v={};v[e(254)]=!0;const g={};g.roots=v,g[e(298)]={},g[t(303)]={};const S=g,P={};P.name=n[t(261)],P[e(288)]=n.mcbiU;const q={};q[e(251)]=S;const C=new A.Client(P,q),k=()=>new V.SSEClientTransport(new URL(o),p);let I=n[e(282)](k);if(c){const w=ue(c,u);I=await n[e(263)](oe,C,w,k)}else await C.connect(I);re(C,s,I),I.sessionId=I[t(274)].searchParams[e(297)](n.KkViY);const N={};return N.transport=I,N.sessionId=I[t(286)],N},Ne=async r=>{const e=W,t=R,n={wfHUn:function(w,O,F){return w(O,F)},tUMle:"mcp-stream-proxy-client",omKPe:e(248),rSiEq:function(w){return w()},PdsSn:function(w,O,F,ie){return w(O,F,ie)}},{client:s,url:o,token:a,sessionId:i,authProvider:c,requestInit:l,reconnectionOptions:d,waitForOAuthCode:u}=r,h={};h.authProvider=c,h.requestInit=l,h.reconnectionOptions=d;const p=h,m=i||U.randomUUID(),x=n[t(272)](de,a,m);if(l){const w={...x[e(280)],...l};w.headers={...x.requestInit[e(268)],...l.headers},p.requestInit=w}else p[t(280)]=x[t(280)];const v={};v[t(254)]=!0;const g={};g.roots=v,g[e(298)]={},g[e(303)]={};const S=g,P={};P.name=n[e(262)],P.version=n.omKPe;const q={};q.capabilities=S;const C=new A.Client(P,q),k=()=>new j.StreamableHTTPClientTransport(new URL(o),p);let I=n.rSiEq(k);if(c){const w=n[e(272)](ue,c,u);I=await n[e(296)](oe,C,w,k)}else await C[e(260)](I);n.PdsSn(re,C,s,I);const N={};return N.transport=I,N[t(286)]=I[t(286)],N},Oe=async r=>{const e=R,t=R,n={eZwNI:function(g,S,P,q){return g(S,P,q)}},{client:s,url:o,token:a,sessionId:i}=r,c={};c[e(254)]=!0;const l={};l[t(290)]=c,l.sampling={},l.elicitation={};const d=l,u={};u.name="mcp-socket-proxy-client",u.version=t(248);const h={};h[t(251)]=d;const p=new A.Client(u,h),m=i||U[t(299)](),x=new ae.WebSocketClientTransport(new URL(o+"?sessionId="+m+t(265)+a));await p.connect(x),n[e(259)](re,p,s,x);const v={};return v.transport=x,v[t(286)]=m,v},E=T,B=T;(function(r,e){const t=T,n=T,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(J,1297719+-42747*-22+-1289197);function T(r,e){const t=J();return T=function(n,s){return n=n-(-4158*1+-2*581+-1*-5510),t[n]},T(r,e)}const Fe=()=>U.randomBytes(-8746+-382*-23);class De{constructor(e){const t=T,n=T,s={HbwOh:function(d){return d()}};this._callBackPromise={};const{clientMetadata:o,state:a,redirectCallback:i,getAuthCodeByState:c,waitForOAuthCode:l}=e;this._clientMetadata=o,this[t(206)]=o.redirect_uris[-10*629+1*7646+-1356],this[n(197)]=a||s.HbwOh(Fe),this._redirectCallback=i||this[n(202)],this[n(195)]=c||this[t(191)],this.waitForOAuthCode=l||this.waitForOAuthCodeFunction()}async redirectCallbackFunction(e){var t,n,s,o,a,i;const c=T,l=T,d={};d[c(198)]="GET";const u=await fetch(e,d);!u.ok&&((n=(t=this[l(207)])[l(196)])==null||n.call(t,c(208)+u[l(205)]));const h=await this[l(195)](this._redirectUrl,this[c(197)]);if(!h.ok){(o=(s=this[c(207)]).reject)==null||o.call(s,"Failed to fetch auth code: "+h[l(205)]);return}const p=await h.json();(i=(a=this._callBackPromise).resolve)==null||i.call(a,p.code)}async[E(191)](e,t){const n=E,s={};s.xAOmI="POST";const o=s,a={};a["Content-Type"]=n(217);const i={};return i.state=t,fetch(e,{method:o.xAOmI,headers:a,body:new URLSearchParams(i)})}waitForOAuthCodeFunction(){const e=this._callBackPromise;return()=>new Promise((t,n)=>{const s=T;e.resolve=t,e[s(196)]=n})}get redirectUrl(){return this[E(206)]}get[B(190)](){return this._clientMetadata}[E(213)](){return this[E(197)]}[B(218)](){return this[B(200)]}[E(194)](e){this._clientInformation=e}tokens(){return this[B(210)]}saveTokens(e){const t=B;this[t(210)]=e}redirectToAuthorization(e){this._redirectCallback(e)}saveCodeVerifier(e){this._codeVerifier=e}[E(212)](){const e=E,t={};t[e(215)]=e(214);const n=t;if(!this[e(209)])throw new Error(n.mMdVl);return this[e(209)]}}function J(){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"];return J=function(){return r},J()}(function(r,e){for(var t=G,n=G,s=r();;)try{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;if(o===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Q,262*-2438+1346066*-1+2*1373311);function Q(){var r=["279100FsqxFu","7326315yxcNFg","50823VTWXXj","6441948uoPUwt","92BSiBRu","1361711dyawqa","5202960gnlAWp","7tNVFlv","11056792usEcvw","90CRWXmt"];return Q=function(){return r},Q()}function G(r,e){var t=Q();return G=function(n,s){n=n-287;var o=t[n];return o},G(r,e)}class Ae{constructor(e,t){const n={name:"web-mcp-server",version:"1.0.0"},s={prompts:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},completions:{},logging:{}};this.server=new ee.McpServer(e||n,t||{capabilities:s}),this.server.server.oninitialized=()=>{this.oninitialized?.()},this.server.server.onclose=()=>{this.onclose?.()},this.server.server.onerror=o=>{this.onerror?.(o)},this.server.server.setRequestHandler(b.SetLevelRequestSchema,async()=>({}))}async connect(e){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 ne(e),await this.transport.listen()),await this.server.connect(this.transport),this.transport}async close(){await this.server.close()}registerTool(e,t,n){return this.server.registerTool(e,t,n)}registerPrompt(e,t,n){return this.server.registerPrompt(e,t,n)}registerResource(e,t,n,s){return typeof t=="string"?this.server.registerResource(e,t,n,s):this.server.registerResource(e,t,n,s)}isConnected(){return this.server.isConnected()}sendResourceListChanged(){this.server.sendResourceListChanged()}sendToolListChanged(){this.server.sendToolListChanged()}sendPromptListChanged(){this.server.sendPromptListChanged()}getClientCapabilities(){return this.server.server.getClientCapabilities()}getClientVersion(){return this.server.server.getClientVersion()}async ping(){return await this.server.server.ping()}async createMessage(e,t){return await this.server.server.createMessage(e,t)}async elicitInput(e,t){return await this.server.server.elicitInput(e,t)}async listRoots(e,t){return await this.server.server.listRoots(e,t)}async sendLoggingMessage(e){return await this.server.server.sendLoggingMessage(e)}async sendResourceUpdated(e){return await this.server.server.sendResourceUpdated(e)}request(e,t,n){return this.server.server.request(e,t,n)}async notification(e,t){return await this.server.server.notification(e,t)}setRequestHandler(e,t){this.server.server.setRequestHandler(e,t)}removeRequestHandler(e){this.server.server.removeRequestHandler(e)}setNotificationHandler(e,t){this.server.server.setNotificationHandler(e,t)}removeNotificationHandler(e){this.server.server.removeNotificationHandler(e)}onSubscribe(e){this.server.server.setRequestHandler(b.SubscribeRequestSchema,e)}onUnsubscribe(e){this.server.server.setRequestHandler(b.UnsubscribeRequestSchema,e)}onSetLogLevel(e){this.server.server.setRequestHandler(b.SetLevelRequestSchema,e)}onListResources(e){this.server.server.setRequestHandler(b.ListResourcesRequestSchema,e)}onRootsListChanged(e){this.server.server.setNotificationHandler(b.RootsListChangedNotificationSchema,e)}async onPagehide(e){e.persisted||this.transport&&typeof this.transport.close=="function"&&await this.transport.close()}}const Ve=(r,e)=>new ne(r,e),We=()=>be(),Be=r=>r instanceof ne,je=r=>r instanceof ee.McpServer;class ze{constructor(e,t){const n={name:"web-mcp-client",version:"1.0.0"},s={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new A.Client(e||n,t||{capabilities:s}),this.client.onclose=()=>{this.onclose?.()},this.client.onerror=o=>{this.onerror?.(o)}}async connect(e){if(typeof e.start=="function")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};const{url:t,token:n,sessionId:s,type:o,agent:a,onError:i}=e;if(a===!0){const d={client:this.client,url:t,token:n,sessionId:s};let u;return await(async()=>{const{transport:p,sessionId:m}=o==="sse"?await Ee(d):o==="socket"?await Oe(d):await Ne(d);p.onerror=async x=>{i?.(x)},u={transport:p,sessionId:m}})(),u}const c=new URL(t);let l;if(o==="channel"&&(l=new te(t),await this.client.connect(l)),o==="sse"){const d=le(n,s);l=new V.SSEClientTransport(c,d),await this.client.connect(l)}if(o==="socket"&&(l=new ae.WebSocketClientTransport(new URL(`${t}?sessionId=${s}&token=${n}`)),l.sessionId=s,await this.client.connect(l)),typeof l>"u"){const d=de(n,s);l=new j.StreamableHTTPClientTransport(c,d),await this.client.connect(l)}return this.transport=l,{transport:this.transport,sessionId:this.transport.sessionId}}async close(){await this.client.close()}getServerCapabilities(){return this.client.getServerCapabilities()}getServerVersion(){return this.client.getServerVersion()}getInstructions(){return this.client.getInstructions()}async ping(e){return await this.client.ping(e)}async complete(e,t){return await this.client.complete(e,t)}async setLoggingLevel(e,t){return await this.client.setLoggingLevel(e,t)}async getPrompt(e,t){return await this.client.getPrompt(e,t)}async listPrompts(e,t){return await this.client.listPrompts(e,t)}async listResources(e,t){return await this.client.listResources(e,t)}async listResourceTemplates(e,t){return await this.client.listResourceTemplates(e,t)}async readResource(e,t){return await this.client.readResource(e,t)}async subscribeResource(e,t){return await this.client.subscribeResource(e,t)}async unsubscribeResource(e,t){return await this.client.unsubscribeResource(e,t)}async callTool(e,t){return await this.client.callTool(e,b.CallToolResultSchema,t)}async listTools(e,t){return await this.client.listTools(e,t)}async sendRootsListChanged(){return await this.client.sendRootsListChanged()}request(e,t,n){return this.client.request(e,t,n)}async notification(e,t){return await this.client.notification(e,t)}setRequestHandler(e,t){this.client.setRequestHandler(e,t)}removeRequestHandler(e){this.client.removeRequestHandler(e)}setNotificationHandler(e,t){this.client.setNotificationHandler(e,t)}removeNotificationHandler(e){this.client.removeNotificationHandler(e)}onElicit(e){this.client.setRequestHandler(b.ElicitRequestSchema,e)}onCreateMessage(e){this.client.setRequestHandler(b.CreateMessageRequestSchema,e)}onListRoots(e){this.client.setRequestHandler(b.ListRootsRequestSchema,e)}onToolListChanged(e){this.client.setNotificationHandler(b.ToolListChangedNotificationSchema,e)}onPromptListChanged(e){this.client.setNotificationHandler(b.PromptListChangedNotificationSchema,e)}onResourceListChanged(e){this.client.setNotificationHandler(b.ResourceListChangedNotificationSchema,e)}onResourceUpdated(e){this.client.setNotificationHandler(b.ResourceUpdatedNotificationSchema,e)}onLoggingMessage(e){this.client.setNotificationHandler(b.LoggingMessageNotificationSchema,e)}async onPagehide(e){e.persisted||(he(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const Ke=(r,e)=>new V.SSEClientTransport(r,e),Xe=(r,e)=>new j.StreamableHTTPClientTransport(r,e),Ye=(r,e)=>new te(r,e),Ze=r=>r instanceof V.SSEClientTransport,he=r=>r instanceof j.StreamableHTTPClientTransport,Je=r=>r instanceof te,Qe=r=>r instanceof A.Client,Ge=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)}),$=(r,e,t)=>{window.postMessage({type:r,direction:t,data:e},"*")},fe=(r,e,t)=>{const n=async function(s){s.source===window&&s.data.type===r&&s.data.direction===t&&await e(s.data.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)};class $e{constructor(e=null){this._isStarted=!1,this._isClosed=!1,this._lastRegistration=null,this.sessionId=e||Ge(),this._messageListener1=fe("sidepanel-ready-to-page",()=>{this._lastRegistration&&this._isStarted&&this.notifyRegistration(this._lastRegistration).catch(t=>{console.error("【Page Svr Transport】 notifyRegistration失败:",t)})},"content->page"),this._messageListener2=fe("mcp-client-to-server-to-page",t=>{if(t.sessionId!==this.sessionId)return;console.log("【Page Svr Transport】 即将处理 mcpMessage",t.mcpMessage);const n=b.JSONRPCMessageSchema.parse(t.mcpMessage);this.onmessage?.(n),t.mcpMessage.params?.name&&$("update-page-app-message",{status:"run",message:t.mcpMessage.params?.name},"page->content")},"content->page")}_throwError(e,t){if(e()){const n=new Error(t);throw console.log(t,n),this.onerror&&this.onerror(n),n}}async start(){if(!this._isStarted){if(this._isClosed)throw new Error("【Page Svr Transport】 已关闭,无法重新启动");this._isStarted=!0}}async send(e,t){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法发送消息"),this._throwError(()=>this._isClosed,"【Page Svr Transport】 已关闭,无法发送消息"),$("mcp-server-to-client-from-page",{sessionId:this.sessionId,mcpMessage:e},"page->content"),"result"in e&&e.result?.content&&$("update-page-app-message",{status:"ready",message:""},"page->content")}async notifyRegistration(e){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法注册消息"),this._lastRegistration=e;try{$("mcp-server-register-from-page",{sessionId:this.sessionId,serverInfo:{...e,url:window.location.origin,title:document.title}},"page->content")}catch(t){this._throwError(()=>!0,"【Page Svr Transport】 注册 server 失败"+String(t))}}async close(){if(!this._isClosed)try{this._messageListener1&&this._messageListener1(),this._messageListener2&&this._messageListener2(),this._isClosed=!0,this._isStarted=!1,this.onclose&&this.onclose()}catch(e){this._throwError(()=>!0,"【Page Svr Transport】 关闭时发生错误"+String(e))}}}f.Ajv=D,Object.defineProperty(f,"ResourceTemplate",{enumerable:!0,get:()=>ee.ResourceTemplate}),Object.defineProperty(f,"z",{enumerable:!0,get:()=>xe.z}),Object.defineProperty(f,"UriTemplate",{enumerable:!0,get:()=>_e.UriTemplate}),Object.defineProperty(f,"completable",{enumerable:!0,get:()=>me.completable}),Object.defineProperty(f,"getDisplayName",{enumerable:!0,get:()=>ve.getDisplayName}),f.AuthClientProvider=De,f.ExtensionPageServerTransport=$e,f.WebMcpClient=ze,f.WebMcpServer=Ae,f.createMessageChannelClientTransport=Ye,f.createMessageChannelPairTransport=We,f.createMessageChannelServerTransport=Ve,f.createSSEClientTransport=Ke,f.createStreamableHTTPClientTransport=Xe,f.isMcpClient=Qe,f.isMcpServer=je,f.isMessageChannelClientTransport=Je,f.isMessageChannelServerTransport=Be,f.isSSEClientTransport=Ze,f.isStreamableHTTPClientTransport=he,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(f,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("ajv"),require("@modelcontextprotocol/sdk/types.js"),require("@modelcontextprotocol/sdk/client/index.js"),require("@modelcontextprotocol/sdk/client/sse.js"),require("@modelcontextprotocol/sdk/client/streamableHttp.js"),require("@modelcontextprotocol/sdk/client/websocket.js"),require("@modelcontextprotocol/sdk/client/auth.js"),require("@modelcontextprotocol/sdk/server/mcp.js"),require("zod"),require("@modelcontextprotocol/sdk/shared/uriTemplate.js"),require("@modelcontextprotocol/sdk/server/completable.js"),require("@modelcontextprotocol/sdk/shared/metadataUtils.js")):typeof define=="function"&&define.amd?define(["exports","ajv","@modelcontextprotocol/sdk/types.js","@modelcontextprotocol/sdk/client/index.js","@modelcontextprotocol/sdk/client/sse.js","@modelcontextprotocol/sdk/client/streamableHttp.js","@modelcontextprotocol/sdk/client/websocket.js","@modelcontextprotocol/sdk/client/auth.js","@modelcontextprotocol/sdk/server/mcp.js","zod","@modelcontextprotocol/sdk/shared/uriTemplate.js","@modelcontextprotocol/sdk/server/completable.js","@modelcontextprotocol/sdk/shared/metadataUtils.js"],D):(f=typeof globalThis<"u"?globalThis:f||self,D(f.WebMCP={},f.MCPSDK,f.MCPSDK,f.MCPSDK,f.MCPSDK,f.MCPSDK,f.websocket_js,f.MCPSDK,f.MCPSDK,f.Zod,f.MCPSDK,f.MCPSDK,f.MCPSDK))})(this,(function(f,D,b,A,V,j,ae,fe,ee,pe,xe,_e,ve){"use strict";const H=S;(function(r,e){const t=S,n=S,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(K,-118057+3521*-35+-2099*-233);const ce=()=>{const r=S,e=S,t={};t[r(420)]="3|0|2|1|4",t.vQYJZ=function(a,i){return a!==i},t[e(394)]=e(414),t.ktWqD=function(a,i){return a!==i},t[r(424)]=r(391);const n=t,s=n[e(420)].split("|");let o=859*2+-3*-1039+-4835*1;for(;;){switch(s[o++]){case"0":if(n[e(407)](typeof window,"undefined"))return window;continue;case"1":if(n.vQYJZ(typeof self,n.NZmUq))return self;continue;case"2":if(n[e(405)](typeof global,"undefined"))return global;continue;case"3":if(n[e(405)](typeof globalThis,n[r(394)]))return globalThis;continue;case"4":return Function(n[r(424)])()}break}},me=(r,e,t)=>{const n=S,s=S,o={};o.eOzBp=function(i,c){return i!==c},o.ooaJk="undefined",o[n(402)]=function(i,c){return i===c},o[n(421)]="function";const a=o;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)},ge=(r,e)=>{const t=S,n=S,s={};s.nTCfA=function(a,i){return a in i},s[t(390)]="addEventListener",s[t(385)]=function(a,i){return a===i},s[t(409)]="function",s.VaHpd=n(392),s[n(384)]=t(417),s.FPOYW=function(a,i){return a!==i};const o=s;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)};class z{constructor(e){this._port=e}async[H(401)](){const e=H,t=H;this[e(422)]&&(this[t(422)].onmessage=n=>{var s,o;const a=e;try{const i=b.JSONRPCMessageSchema.parse(n.data.message);(s=this.onmessage)==null||s.call(this,i,n[a(412)][a(428)])}catch(i){const c=new Error("MessageChannel failed to parse message: "+i);(o=this[a(383)])==null||o.call(this,c)}},this._port.onmessageerror=n=>{var s;const o=t,a=new Error("MessageChannel transport error: "+JSON[o(415)](n));(s=this.onerror)==null||s.call(this,a)},this[t(422)].start())}async send(e,t){const n={EoBZE:function(s){return s()},leEiG:function(s,o){return s instanceof o},cDUwk:function(s,o){return s(o)}};return new Promise((s,o)=>{var a;const i=S,c=S;try{const l={};l[i(404)]=t?.[i(404)];const u={};u[i(392)]=e,u.extra=l,this._port&&this._port[c(423)](u),n[i(399)](s)}catch(l){const u=n.leEiG(l,Error)?l:new Error(n.cDUwk(String,l));(a=this.onerror)==null||a.call(this,u),o(u)}})}async close(){var e,t;const n=H,s=H;(e=this._port)==null||e[n(393)](),this[n(422)]=void 0,(t=this[s(408)])==null||t.call(this)}}class te extends z{constructor(e,t=ce()){const n=H,s={lSpBh:function(a,i,c,l){return a(i,c,l)}};super(),this._endpoint=e,this._globalObject=t;const o=new MessageChannel;this._port=o[n(410)],s[n(418)](me,this._globalObject,{endpoint:this[n(397)]},[o[n(429)]])}}class ne extends z{constructor(e,t=ce()){const n=H,s=H,o={HITdC:function(a,i){return a===i},QdDxM:function(a){return a()},jowPp:function(a,i,c){return a(i,c)}};super(),this[n(397)]=e,this[s(388)]=t,this[s(416)]=new Promise(a=>{const i=n,c={XlglK:function(l,u){return o.HITdC(l,u)},pXlad:function(l){return o.QdDxM(l)}};o[i(427)](ge,this._globalObject,l=>{const u=i,d=i;l[u(412)]&&c.XlglK(l.data[d(396)],this._endpoint)&&(this[u(422)]=l[d(430)][-3036+-1518*-2],c.pXlad(a))})})}async listen(){return this._listen}}function K(){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"];return K=function(){return r},K()}function S(r,e){const t=K();return S=function(n,s){return n=n-(17227+1*-16844),t[n]},S(r,e)}const we=()=>{const r=new MessageChannel;return[new z(r.port1),new z(r.port2)]};(function(r,e){const t=_,n=_,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(X,-411935*1+228107+208149*2);const be=async(r,e,t)=>{var n;const s=_,o=_,a={};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);const i=a,{id:c,method:l,params:u}=t;let d={};switch(l){case i.VRyiJ:d=await e.listTools(u);break;case i.VkPYu:d=await e.callTool(u);break;case i.fgMSD:d=await e.listResources(u);break;case i[o(466)]:d=await e.listResourceTemplates(u);break;case i.sthgI:d=await e[s(455)](u);break;case o(486):d=await e.subscribeResource(u);break;case s(410):d=await e.unsubscribeResource(u);break;case i[o(461)]:d=await e[o(414)](u);break;case i[s(412)]:d=await e[s(491)](u);break;case i[s(436)]:d=await e[s(478)]();break;case i.kkNqg:d=await e.complete(u);break;case s(464):d=await e.setLoggingLevel(u?.[o(443)]);break}const h={};h.result=d,h.jsonrpc=i[o(472)],h.id=c,await((n=r?.[o(488)])==null?void 0:n[s(460)](h))},Ce=async(r,e,t)=>{var n;const s=_,o=_,a={};a[s(487)]=o(462),a.ypHTC="ping",a.fPExS=s(465);const i=a,{id:c,method:l,params:u}=t;let d={};switch(l){case"roots/list":const p={};p.method=l,p[o(446)]=u,d=await e[s(469)](p,b.ListRootsResultSchema);break;case"sampling/createMessage":const v={};v[s(481)]=l,v[s(446)]=u,d=await e.request(v,b.CreateMessageResultSchema);break;case i[s(487)]:const x={};x.method=l,x[o(446)]=u,d=await e.request(x,b.ElicitResultSchema);break;case i.ypHTC:const m={};m.method=l,d=await e.request(m,b.EmptyResultSchema);break}const h={};return h.result=d,h.jsonrpc=i.fPExS,h.id=c,await((n=r?.transport)==null?void 0:n.send(h)),d};function _(r,e){const t=X();return _=function(n,s){return n=n-(-8023+4*-2344+-17809*-1),t[n]},_(r,e)}const Se=(r,e)=>{const t=_,n=_,s={vYlhn:function(a,i){return a===i},DhPFX:t(470),NYVNC:function(a,i,c,l){return a(i,c,l)},yfZbw:"2.0"},o=r._onrequest;r[n(463)]=async(a,i)=>{var c,l,u,d,h;const p=n,v=t,{id:x,method:m}=a;try{s[p(451)](m,s.DhPFX)?await o.call(r,a,i):await s[v(474)](be,r,e,a)}catch(g){const{code:y,message:P,data:q}=g;try{if(y){const C={};C[v(485)]=y,C[p(422)]=P,C.data=q;const k={};k[v(448)]=C,k.jsonrpc=s[p(417)],k.id=x,await((c=r?.transport)==null?void 0:c[v(460)](k))}else(u=(l=r?.transport)==null?void 0:l.onerror)==null||u.call(l,g)}catch(C){(h=(d=r?.transport)==null?void 0:d.onerror)==null||h.call(d,C)}}}},ye=(r,e)=>{const t=_,n=_,s={};s[t(476)]=t(439),s[t(431)]=function(a,i){return a!==i},s.UPdQt="notifications/cancelled";const o=s;r[t(421)]=async a=>{var i,c;const l=t,u=n,{method:d,params:h}=a;if(d!==o[l(476)]&&(o.QWYMz(d,o.UPdQt)||h?.[u(490)]))try{await e[l(445)](a)}catch(p){(c=(i=r?.[l(488)])==null?void 0:i[l(480)])==null||c.call(i,p)}}},Ie=(r,e)=>async t=>{var n,s,o,a,i;const c=_,l=_,u={TJhyV:function(d,h,p,v){return d(h,p,v)},MMNTY:c(465)};try{return await u.TJhyV(Ce,r,e,t)}catch(d){const{code:h,message:p,data:v}=d;try{if(h){const x={};x.code=h,x[c(422)]=p,x[l(419)]=v;const m={};m[c(448)]=x,m[c(424)]=u.MMNTY,m.id=t.id,await((n=r?.transport)==null?void 0:n[l(460)](m))}else(o=(s=r?.transport)==null?void 0:s[c(480)])==null||o.call(s,d)}catch(x){(i=(a=r?.[c(488)])==null?void 0:a.onerror)==null||i.call(a,x)}}},Re=(r,e)=>async t=>{var n,s,o;const a=_,i=_,c={};c.xmcLM=function(h,p){return h!==p},c.xSWLt="notifications/initialized",c[a(420)]=i(453);const l=c,{method:u,params:d}=t;if(l.xmcLM(u,l.xSWLt)&&(l.xmcLM(u,l[i(420)])||d?.[i(490)]))try{const h={...t};h.jsonrpc=a(465),await((n=e?.[a(488)])==null?void 0:n.send(h))}catch(h){(o=(s=r?.transport)==null?void 0:s.onerror)==null||o.call(s,h)}};function X(){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"];return X=function(){return r},X()}const Te=(r,e)=>async t=>{var n,s,o,a,i,c;const l=_,u=_,d={};d.kSvAZ=l(465);const h=d;try{await((n=e?.[u(488)])==null?void 0:n[u(460)](t))}catch(p){const{code:v,message:x,data:m}=p;try{if(v){const g={};g.code=v,g.message=x,g.data=m;const y={};y.error=g,y[u(424)]=h.kSvAZ,y.id=t.id,await((s=r?.transport)==null?void 0:s.send(y))}else(a=(o=r?.transport)==null?void 0:o[l(480)])==null||a.call(o,p)}catch(g){(c=(i=r?.[l(488)])==null?void 0:i[u(480)])==null||c.call(i,g)}}},se=()=>{const r=_,e={rgPZO:function(c,l){return c!==l},VWsxO:function(c,l){return c(l)},FjTAY:"function"},t=[],n=(c,l)=>{const u=_;if(l){const d=[];for(const h of t)try{d.push(h(c,l))}catch{}for(const h of d)if(e.rgPZO(h,null))return h}else for(const d of t)try{e[u(427)](d,c)}catch{}},s=c=>{const l=_,u=_;typeof c===e[l(456)]&&!t.includes(c)&&t[u(471)](c)},o=c=>{const l=_,u=t[l(415)](c);u!==-1&&t.splice(u,-17591+6*2932)},a=()=>{const c=_;t[c(430)]=-505*7+1322+2213},i={};return i.handleListener=n,i[r(447)]=s,i.removeListener=o,i.clearListener=a,i},Pe=r=>{const e=_,t=_,n={UlqiY:function(s){return s()},jsmFN:function(s){return s()}};{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(423)](se);r._onresponse=s,r[t(438)]=o,r.removeResponseListener=a,r.clearResponseListener=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(489)](se);r[e(432)]=s,r[t(473)]=o,r.removeRequestListener=a,r.clearRequestListener=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n.jsmFN(se);r.fallbackNotificationHandler=s,r[e(444)]=o,r.removeNotificationListener=a,r[t(426)]=i}},ke=(r,{beforeInit:e,afterInit:t}={})=>{const n=_,s=_,o={HucXo:function(i,c){return i===c},HicFO:n(468),JMaxV:function(i){return i()},DclXr:function(i,c){return i(c)},UynHf:function(i,c){return i===c},yCyFn:function(i){return i()}},a=new Map(r._notificationHandlers);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(Pe,r),r[s(438)](i=>{const c=n;r.originalOnResponse[c(440)](r,i)}),o[n(429)](typeof t,o.HicFO)&&o[s(425)](t),r[s(444)](i=>{const c=s,{method:l}=i,u=a[c(483)](l);o[c(467)](typeof u,"function")&&u(i)})},Le=L;(function(r,e){const t=L,n=L,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(Y,995159+-6*-266138+-1619768);const Me=()=>{const r=L,e=L,t={};t.svuxn=function(s,o){return s&o},t.ZUPdr=function(s,o){return s===o},t[r(227)]=function(s,o){return s===o},t.SpRzi="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";const n=t;return n[e(227)](typeof crypto,"object")&&crypto[r(211)]?crypto.randomUUID():n.SpRzi.replace(/[xy]/g,s=>{const o=r,a=n.svuxn(crypto.getRandomValues(new Uint8Array(-3798+8571*-1+12370))[0],-8324+8339*1);return(n[o(225)](s,"x")?a:n[o(209)](a,-12998+-1*-13001)|813*10+-3707+883*-5).toString(-1*-1851+6493+-8328)})},qe=r=>{const e=L,t=L,n=new Uint8Array(r);return crypto[e(221)](n),Array[t(218)](n,s=>s[t(226)](11424+4*-2852).padStart(8950+2237*-4,"0"))[e(213)]("")},U={};U[Le(211)]=Me,U.randomBytes=qe;function L(r,e){const t=Y();return L=function(n,s){return n=n-(-7373+7187*1+395),t[n]},L(r,e)}function Y(){const r=["join","2500590yHdCUG","3CzpgOE","219762yRRBUK","592022JqIdxi","from","6033730pSHJFF","28gKZiuO","getRandomValues","147169GUBreL","5fFOMNB","1140KVOWlq","ZUPdr","toString","DBGzc","45351XtLuDF","svuxn","9892WpQPGF","randomUUID","2504EaskHQ"];return Y=function(){return r},Y()}function M(r,e){const t=Z();return M=function(n,s){return n=n-(-1483*3+-5564+20*513),t[n]},M(r,e)}const R=M,W=M;(function(r,e){const t=M,n=M,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(Z,-4*308317+753182*2+658196);const He=(r,e)=>{const t=M,n=M,s={olCWX:function(c,l,u){return c(l,u)},sfXDX:function(c,l,u){return c(l,u)},ksWFu:function(c,l,u){return c(l,u)}};s[t(283)](Se,r,e),ye(r,e);const o=s[n(283)](Ie,e,r),a=s[n(294)](Te,e,r),i=s[t(277)](Re,e,r);e.addRequestListener(o),e.addResponseListener(a),e[n(287)](i),r.onclose=()=>{const c=t,l=n;e[c(247)](o),e.removeResponseListener(a),e[l(252)](i)}},re=(r,e,t)=>{const n={QhPqi:function(a,i){return a instanceof i},AIICR:"close",Qalmc:function(a,i,c){return a(i,c)}},s=()=>{var a;n.QhPqi(t,V.SSEClientTransport)&&((a=t._eventSource)==null||a.addEventListener(n.AIICR,()=>{var i;(i=t[M(295)])==null||i.close()})),n.Qalmc(He,r,e)},o={};o.afterInit=s,n.Qalmc(ke,e,o)},le=(r,e=U[R(299)]())=>{const t=R,n=R,s={RVabx:function(u,d,h){return u(d,h)},crCTs:"include"},o={};o["sse-session-id"]=e;const a=o,i={};i["sse-session-id"]=e;const c={};c.headers=i,c.credentials=s[t(304)];const l={requestInit:c,eventSourceInit:{async fetch(u,d){const h=t,p=t,v=new Headers(d?.[h(268)]||{});Object.entries(a).forEach(([m,g])=>{v.set(m,g)});const x={...d};return x.headers=v,s[p(279)](fetch,u,x)},withCredentials:!0}};return r&&(l[t(280)].headers.Authorization="Bearer "+r,a.Authorization=n(256)+r),l},ue=(r,e=U[R(299)]())=>{const t=W,n=R,s={};s[t(271)]="include";const o=s,a={};a["stream-session-id"]=e;const i={};i[n(268)]=a,i.credentials=o[t(271)];const c={};c.requestInit=i;const l=c;return r&&(l[n(280)][t(268)][n(301)]=t(256)+r),l},oe=async(r,e,t)=>{const n=R,s=R,o={rRtFD:function(i){return i()},ToRAF:function(i,c){return i instanceof c}},a=o[n(276)](t);try{return await r[s(260)](a),a}catch(i){if(o[n(275)](i,fe.UnauthorizedError)){const c=await e();return await a[n(257)](c),await oe(r,e,t)}else throw i}},de=(r,e)=>{const t=W,n=W,s={};s[t(267)]=function(a,i){return a in i},s.timcZ="waitForOAuthCode",s[t(253)]=function(a,i){return a===i},s.ufiEQ=t(285),s[n(250)]=t(293);const o=s;if(o.oGmBG(o[t(258)],r))return r[n(278)];if(o[n(253)](typeof e,o.ufiEQ))return e;throw new Error(o.daYBw)};function Z(){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"];return Z=function(){return r},Z()}const Ue=async r=>{const e=W,t=R,n={GKDjq:function(w,O,F){return w(O,F)},JzpWy:e(281),mcbiU:"1.0.0",CfBXU:function(w){return w()},kdowC:function(w,O,F,ie){return w(O,F,ie)},KkViY:"sessionId"},{client:s,url:o,token:a,sessionId:i,authProvider:c,requestInit:l,eventSourceInit:u,waitForOAuthCode:d}=r,h={};h[t(305)]=c,h.requestInit=l,h.eventSourceInit=u;const p=h,v=i||U[t(299)](),x=n[e(289)](le,a,v);if(l){const w={...x.requestInit,...l};w[t(268)]={...x[t(280)][e(268)],...l.headers},p.requestInit=w}else p.requestInit=x[e(280)];if(u){const w={...x[e(270)],...u};p.eventSourceInit=w}else p.eventSourceInit=x[e(270)];const m={};m[e(254)]=!0;const g={};g.roots=m,g[e(298)]={},g[t(303)]={};const y=g,P={};P.name=n[t(261)],P[e(288)]=n.mcbiU;const q={};q[e(251)]=y;const C=new A.Client(P,q),k=()=>new V.SSEClientTransport(new URL(o),p);let I=n[e(282)](k);if(c){const w=de(c,d);I=await n[e(263)](oe,C,w,k)}else await C.connect(I);re(C,s,I),I.sessionId=I[t(274)].searchParams[e(297)](n.KkViY);const N={};return N.transport=I,N.sessionId=I[t(286)],N},Ee=async r=>{const e=W,t=R,n={wfHUn:function(w,O,F){return w(O,F)},tUMle:"mcp-stream-proxy-client",omKPe:e(248),rSiEq:function(w){return w()},PdsSn:function(w,O,F,ie){return w(O,F,ie)}},{client:s,url:o,token:a,sessionId:i,authProvider:c,requestInit:l,reconnectionOptions:u,waitForOAuthCode:d}=r,h={};h.authProvider=c,h.requestInit=l,h.reconnectionOptions=u;const p=h,v=i||U.randomUUID(),x=n[t(272)](ue,a,v);if(l){const w={...x[e(280)],...l};w.headers={...x.requestInit[e(268)],...l.headers},p.requestInit=w}else p[t(280)]=x[t(280)];const m={};m[t(254)]=!0;const g={};g.roots=m,g[e(298)]={},g[e(303)]={};const y=g,P={};P.name=n[e(262)],P.version=n.omKPe;const q={};q.capabilities=y;const C=new A.Client(P,q),k=()=>new j.StreamableHTTPClientTransport(new URL(o),p);let I=n.rSiEq(k);if(c){const w=n[e(272)](de,c,d);I=await n[e(296)](oe,C,w,k)}else await C[e(260)](I);n.PdsSn(re,C,s,I);const N={};return N.transport=I,N[t(286)]=I[t(286)],N},Ne=async r=>{const e=R,t=R,n={eZwNI:function(g,y,P,q){return g(y,P,q)}},{client:s,url:o,token:a,sessionId:i}=r,c={};c[e(254)]=!0;const l={};l[t(290)]=c,l.sampling={},l.elicitation={};const u=l,d={};d.name="mcp-socket-proxy-client",d.version=t(248);const h={};h[t(251)]=u;const p=new A.Client(d,h),v=i||U[t(299)](),x=new ae.WebSocketClientTransport(new URL(o+"?sessionId="+v+t(265)+a));await p.connect(x),n[e(259)](re,p,s,x);const m={};return m.transport=x,m[t(286)]=v,m},E=T,B=T;(function(r,e){const t=T,n=T,s=r();for(;;)try{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;s.push(s.shift())}catch{s.push(s.shift())}})(J,1297719+-42747*-22+-1289197);function T(r,e){const t=J();return T=function(n,s){return n=n-(-4158*1+-2*581+-1*-5510),t[n]},T(r,e)}const Oe=()=>U.randomBytes(-8746+-382*-23);class Fe{constructor(e){const t=T,n=T,s={HbwOh:function(u){return u()}};this._callBackPromise={};const{clientMetadata:o,state:a,redirectCallback:i,getAuthCodeByState:c,waitForOAuthCode:l}=e;this._clientMetadata=o,this[t(206)]=o.redirect_uris[-10*629+1*7646+-1356],this[n(197)]=a||s.HbwOh(Oe),this._redirectCallback=i||this[n(202)],this[n(195)]=c||this[t(191)],this.waitForOAuthCode=l||this.waitForOAuthCodeFunction()}async redirectCallbackFunction(e){var t,n,s,o,a,i;const c=T,l=T,u={};u[c(198)]="GET";const d=await fetch(e,u);!d.ok&&((n=(t=this[l(207)])[l(196)])==null||n.call(t,c(208)+d[l(205)]));const h=await this[l(195)](this._redirectUrl,this[c(197)]);if(!h.ok){(o=(s=this[c(207)]).reject)==null||o.call(s,"Failed to fetch auth code: "+h[l(205)]);return}const p=await h.json();(i=(a=this._callBackPromise).resolve)==null||i.call(a,p.code)}async[E(191)](e,t){const n=E,s={};s.xAOmI="POST";const o=s,a={};a["Content-Type"]=n(217);const i={};return i.state=t,fetch(e,{method:o.xAOmI,headers:a,body:new URLSearchParams(i)})}waitForOAuthCodeFunction(){const e=this._callBackPromise;return()=>new Promise((t,n)=>{const s=T;e.resolve=t,e[s(196)]=n})}get redirectUrl(){return this[E(206)]}get[B(190)](){return this._clientMetadata}[E(213)](){return this[E(197)]}[B(218)](){return this[B(200)]}[E(194)](e){this._clientInformation=e}tokens(){return this[B(210)]}saveTokens(e){const t=B;this[t(210)]=e}redirectToAuthorization(e){this._redirectCallback(e)}saveCodeVerifier(e){this._codeVerifier=e}[E(212)](){const e=E,t={};t[e(215)]=e(214);const n=t;if(!this[e(209)])throw new Error(n.mMdVl);return this[e(209)]}}function J(){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"];return J=function(){return r},J()}(function(r,e){for(var t=G,n=G,s=r();;)try{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;if(o===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Q,262*-2438+1346066*-1+2*1373311);function Q(){var r=["279100FsqxFu","7326315yxcNFg","50823VTWXXj","6441948uoPUwt","92BSiBRu","1361711dyawqa","5202960gnlAWp","7tNVFlv","11056792usEcvw","90CRWXmt"];return Q=function(){return r},Q()}function G(r,e){var t=Q();return G=function(n,s){n=n-287;var o=t[n];return o},G(r,e)}class De{constructor(e,t){const n={name:"web-mcp-server",version:"1.0.0"},s={prompts:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},completions:{},logging:{}};this.server=new ee.McpServer(e||n,t||{capabilities:s}),this.server.server.oninitialized=()=>{this.oninitialized?.()},this.server.server.onclose=()=>{this.onclose?.()},this.server.server.onerror=o=>{this.onerror?.(o)},this.server.server.setRequestHandler(b.SetLevelRequestSchema,async()=>({}))}async connect(e){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 ne(e),await this.transport.listen()),await this.server.connect(this.transport),this.transport}async close(){await this.server.close()}registerTool(e,t,n){return this.server.registerTool(e,t,n)}registerPrompt(e,t,n){return this.server.registerPrompt(e,t,n)}registerResource(e,t,n,s){return typeof t=="string"?this.server.registerResource(e,t,n,s):this.server.registerResource(e,t,n,s)}isConnected(){return this.server.isConnected()}sendResourceListChanged(){this.server.sendResourceListChanged()}sendToolListChanged(){this.server.sendToolListChanged()}sendPromptListChanged(){this.server.sendPromptListChanged()}getClientCapabilities(){return this.server.server.getClientCapabilities()}getClientVersion(){return this.server.server.getClientVersion()}async ping(){return await this.server.server.ping()}async createMessage(e,t){return await this.server.server.createMessage(e,t)}async elicitInput(e,t){return await this.server.server.elicitInput(e,t)}async listRoots(e,t){return await this.server.server.listRoots(e,t)}async sendLoggingMessage(e){return await this.server.server.sendLoggingMessage(e)}async sendResourceUpdated(e){return await this.server.server.sendResourceUpdated(e)}request(e,t,n){return this.server.server.request(e,t,n)}async notification(e,t){return await this.server.server.notification(e,t)}setRequestHandler(e,t){this.server.server.setRequestHandler(e,t)}removeRequestHandler(e){this.server.server.removeRequestHandler(e)}setNotificationHandler(e,t){this.server.server.setNotificationHandler(e,t)}removeNotificationHandler(e){this.server.server.removeNotificationHandler(e)}onSubscribe(e){this.server.server.setRequestHandler(b.SubscribeRequestSchema,e)}onUnsubscribe(e){this.server.server.setRequestHandler(b.UnsubscribeRequestSchema,e)}onSetLogLevel(e){this.server.server.setRequestHandler(b.SetLevelRequestSchema,e)}onListResources(e){this.server.server.setRequestHandler(b.ListResourcesRequestSchema,e)}onRootsListChanged(e){this.server.server.setNotificationHandler(b.RootsListChangedNotificationSchema,e)}async onPagehide(e){e.persisted||this.transport&&typeof this.transport.close=="function"&&await this.transport.close()}}const Ae=(r,e)=>new ne(r,e),Ve=()=>we(),We=r=>r instanceof ne,Be=r=>r instanceof ee.McpServer;class je{constructor(e,t){const n={name:"web-mcp-client",version:"1.0.0"},s={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new A.Client(e||n,t||{capabilities:s}),this.client.onclose=()=>{this.onclose?.()},this.client.onerror=o=>{this.onerror?.(o)}}async connect(e){if(typeof e.start=="function")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};const{url:t,token:n,sessionId:s,type:o,agent:a,onError:i}=e;if(a===!0){const u={client:this.client,url:t,token:n,sessionId:s};let d;return await(async()=>{const{transport:p,sessionId:v}=o==="sse"?await Ue(u):o==="socket"?await Ne(u):await Ee(u);p.onerror=async x=>{i?.(x)},d={transport:p,sessionId:v}})(),d}const c=new URL(t);let l;if(o==="channel"&&(l=new te(t),await this.client.connect(l)),o==="sse"){const u=le(n,s);l=new V.SSEClientTransport(c,u),await this.client.connect(l)}if(o==="socket"&&(l=new ae.WebSocketClientTransport(new URL(`${t}?sessionId=${s}&token=${n}`)),l.sessionId=s,await this.client.connect(l)),typeof l>"u"){const u=ue(n,s);l=new j.StreamableHTTPClientTransport(c,u),await this.client.connect(l)}return this.transport=l,{transport:this.transport,sessionId:this.transport.sessionId}}async close(){await this.client.close()}getServerCapabilities(){return this.client.getServerCapabilities()}getServerVersion(){return this.client.getServerVersion()}getInstructions(){return this.client.getInstructions()}async ping(e){return await this.client.ping(e)}async complete(e,t){return await this.client.complete(e,t)}async setLoggingLevel(e,t){return await this.client.setLoggingLevel(e,t)}async getPrompt(e,t){return await this.client.getPrompt(e,t)}async listPrompts(e,t){return await this.client.listPrompts(e,t)}async listResources(e,t){return await this.client.listResources(e,t)}async listResourceTemplates(e,t){return await this.client.listResourceTemplates(e,t)}async readResource(e,t){return await this.client.readResource(e,t)}async subscribeResource(e,t){return await this.client.subscribeResource(e,t)}async unsubscribeResource(e,t){return await this.client.unsubscribeResource(e,t)}async callTool(e,t){return await this.client.callTool(e,b.CallToolResultSchema,t)}async listTools(e,t){return await this.client.listTools(e,t)}async sendRootsListChanged(){return await this.client.sendRootsListChanged()}request(e,t,n){return this.client.request(e,t,n)}async notification(e,t){return await this.client.notification(e,t)}setRequestHandler(e,t){this.client.setRequestHandler(e,t)}removeRequestHandler(e){this.client.removeRequestHandler(e)}setNotificationHandler(e,t){this.client.setNotificationHandler(e,t)}removeNotificationHandler(e){this.client.removeNotificationHandler(e)}onElicit(e){this.client.setRequestHandler(b.ElicitRequestSchema,e)}onCreateMessage(e){this.client.setRequestHandler(b.CreateMessageRequestSchema,e)}onListRoots(e){this.client.setRequestHandler(b.ListRootsRequestSchema,e)}onToolListChanged(e){this.client.setNotificationHandler(b.ToolListChangedNotificationSchema,e)}onPromptListChanged(e){this.client.setNotificationHandler(b.PromptListChangedNotificationSchema,e)}onResourceListChanged(e){this.client.setNotificationHandler(b.ResourceListChangedNotificationSchema,e)}onResourceUpdated(e){this.client.setNotificationHandler(b.ResourceUpdatedNotificationSchema,e)}onLoggingMessage(e){this.client.setNotificationHandler(b.LoggingMessageNotificationSchema,e)}async onPagehide(e){e.persisted||(he(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const ze=(r,e)=>new V.SSEClientTransport(r,e),Ke=(r,e)=>new j.StreamableHTTPClientTransport(r,e),Xe=(r,e)=>new te(r,e),Ye=r=>r instanceof V.SSEClientTransport,he=r=>r instanceof j.StreamableHTTPClientTransport,Ze=r=>r instanceof te,Je=r=>r instanceof A.Client,Qe=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)}),$=(r,e,t)=>{window.postMessage({type:r,direction:t,data:e},"*")},Ge=(r,e,t)=>{const n=async function(s){s.source===window&&s.data.type===r&&s.data.direction===t&&await e(s.data.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)};class $e{constructor(e=null){this._isStarted=!1,this._isClosed=!1,this._lastRegistration=null,this.sessionId=e||Qe(),this._messageListener2=Ge("mcp-client-to-server-to-page",t=>{if(t.sessionId!==this.sessionId)return;console.log("【Page Svr Transport】 即将处理 mcpMessage",t.mcpMessage);const n=b.JSONRPCMessageSchema.parse(t.mcpMessage);this.onmessage?.(n),t.mcpMessage.params?.name&&$("update-page-app-message",{status:"run",message:t.mcpMessage.params?.name},"page->content")},"content->page")}_throwError(e,t){if(e()){const n=new Error(t);throw console.log(t,n),this.onerror&&this.onerror(n),n}}async start(){if(!this._isStarted){if(this._isClosed)throw new Error("【Page Svr Transport】 已关闭,无法重新启动");this._isStarted=!0}}async send(e,t){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法发送消息"),this._throwError(()=>this._isClosed,"【Page Svr Transport】 已关闭,无法发送消息"),$("mcp-server-to-client-from-page",{sessionId:this.sessionId,mcpMessage:e},"page->content"),"result"in e&&e.result?.content&&$("update-page-app-message",{status:"ready",message:""},"page->content")}async notifyRegistration(e){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法注册消息"),this._lastRegistration=e;try{$("mcp-server-register-from-page",{sessionId:this.sessionId,serverInfo:{...e,url:window.location.origin,title:document.title}},"page->content")}catch(t){this._throwError(()=>!0,"【Page Svr Transport】 注册 server 失败"+String(t))}}async close(){if(!this._isClosed)try{this._messageListener2&&this._messageListener2(),this._isClosed=!0,this._isStarted=!1,this.onclose&&this.onclose()}catch(e){this._throwError(()=>!0,"【Page Svr Transport】 关闭时发生错误"+String(e))}}}f.Ajv=D,Object.defineProperty(f,"ResourceTemplate",{enumerable:!0,get:()=>ee.ResourceTemplate}),Object.defineProperty(f,"z",{enumerable:!0,get:()=>pe.z}),Object.defineProperty(f,"UriTemplate",{enumerable:!0,get:()=>xe.UriTemplate}),Object.defineProperty(f,"completable",{enumerable:!0,get:()=>_e.completable}),Object.defineProperty(f,"getDisplayName",{enumerable:!0,get:()=>ve.getDisplayName}),f.AuthClientProvider=Fe,f.ExtensionPageServerTransport=$e,f.WebMcpClient=je,f.WebMcpServer=De,f.createMessageChannelClientTransport=Xe,f.createMessageChannelPairTransport=Ve,f.createMessageChannelServerTransport=Ae,f.createSSEClientTransport=ze,f.createStreamableHTTPClientTransport=Ke,f.isMcpClient=Je,f.isMcpServer=Be,f.isMessageChannelClientTransport=Ze,f.isMessageChannelServerTransport=We,f.isSSEClientTransport=Ye,f.isStreamableHTTPClientTransport=he,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/next-sdk",
3
- "version": "0.2.9",
3
+ "version": "0.3.0-alpha.0",
4
4
  "type": "module",
5
5
  "homepage": "https://docs.opentiny.design/next-sdk/guide/",
6
6
  "repository": {
@@ -22,6 +22,16 @@
22
22
  "main": "dist/index.js",
23
23
  "module": "dist/index.js",
24
24
  "types": "dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "import": "./dist/index.js",
28
+ "types": "./dist/index.d.ts"
29
+ },
30
+ "./core": {
31
+ "import": "./dist/core.js",
32
+ "types": "./dist/core.d.ts"
33
+ }
34
+ },
25
35
  "description": "A frontend intelligent application development toolkit designed to simplify WebAgent integration and usage, supporting multiple programming languages and frontend frameworks to help developers rapidly implement intelligent features",
26
36
  "dependencies": {
27
37
  "@modelcontextprotocol/sdk": "~1.25.2",