@opentiny/next-sdk 0.1.15-beta.4 → 0.1.15-beta.5

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(p,O){typeof exports=="object"&&typeof module<"u"?O(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"],O):(p=typeof globalThis<"u"?globalThis:p||self,O(p.WebMCP={},p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.websocket_js,p.MCPSDK,p.MCPSDK,p.Zod,p.MCPSDK,p.MCPSDK,p.MCPSDK))})(this,(function(p,O,w,F,N,z,oe,he,$,fe,pe,xe,_e){"use strict";function W(){const r=["224340fQYLJj","function","onmessage","port2","341XVdnBD","313767JEBgqL","950bpstaX","1354759gUhUbE","wRKyh","onclose","2044SvCTUj","endpoint","24msSkHx","164VuWYGY","mOWMr","EkZCC","addEventListener","postMessage","120705iyGzUz","8878392ivIdKn","close","_listen","3619482FaLQHc","start","_endpoint","kgkem","bzNYT","MessageChannel transport error: ","stringify","onmessageerror","HvyCv","undefined","Jwyua","message","_globalObject","parse","authInfo","thraG","220pGvxgp","_port","EGhzU","onerror","data","MhriV"];return W=function(){return r},W()}(function(r,e){const t=y,n=y,s=r();for(;;)try{if(parseInt(t(417))/1*(parseInt(t(421))/2)+parseInt(t(433))/3+parseInt(t(424))/4*(-parseInt(n(429))/5)+parseInt(n(423))/6*(-parseInt(n(418))/7)+-parseInt(n(430))/8+-parseInt(t(416))/9*(-parseInt(t(405))/10)+-parseInt(t(415))/11*(-parseInt(t(411))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(W,650197);const ie=()=>{const r=y,e={EGhzU:function(t,n){return t!==n},kIrDB:"undefined",llYQe:function(t,n){return t!==n},PZfJg:function(t,n){return t(n)},Jwyua:"return this"};return typeof globalThis<"u"?globalThis:e[r(407)](typeof window,e.kIrDB)?window:e.llYQe(typeof global,e.kIrDB)?global:typeof self!==r(398)?self:e.PZfJg(Function,e[r(399)])()},ve=(r,e,t)=>{const n=y,s=y,o={};o[n(410)]=s(398),o.dBkaX=function(i,l){return i===l},o[s(393)]="function";const a=o;typeof window!==a[s(410)]?r.postMessage(e,"*",t):s(428)in r&&a.dBkaX(typeof r.postMessage,a[n(393)])&&r.postMessage(e,t)},ge=(r,e)=>{const t=y,n=y,s={};s.MbsGh="addEventListener",s.PPniK=function(a,i){return a===i},s[t(419)]=n(412),s[n(404)]="onmessage",s[t(397)]="undefined";const o=s;o.MbsGh in r&&o.PPniK(typeof r[t(427)],o.wRKyh)?r[t(427)](t(400),e):o.thraG in r&&typeof r[n(413)]!==o[n(397)]&&(r.onmessage=e)};class A{constructor(e){const t=y;this[t(406)]=e}async start(){const e=y,t=y;this[e(406)]&&(this[e(406)][e(413)]=n=>{var s,o;const a=e,i=t;try{const l=w.JSONRPCMessageSchema[a(402)](n.data[a(400)]);(s=this[a(413)])==null||s.call(this,l,n[i(409)].extra)}catch(l){const c=new Error("MessageChannel failed to parse message: "+l);(o=this[i(408)])==null||o.call(this,c)}},this._port[e(396)]=n=>{var s;const o=t,a=t,i=new Error(o(394)+JSON[a(395)](n));(s=this.onerror)==null||s.call(this,i)},this[e(406)][e(434)]())}async send(e,t){const n={lEyuq:function(s){return s()},YihNw:function(s,o){return s(o)}};return new Promise((s,o)=>{var a;const i=y,l=y;try{const c={};c[i(403)]=t?.[i(403)];const d={};d[l(400)]=e,d.extra=c,this[l(406)]&&this[i(406)].postMessage(d),n.lEyuq(s)}catch(c){const d=c instanceof Error?c:new Error(n.YihNw(String,c));(a=this[l(408)])==null||a.call(this,d),o(d)}})}async close(){var e,t;const n=y,s=y;(e=this._port)==null||e[n(431)](),this._port=void 0,(t=this[s(420)])==null||t.call(this)}}class ee extends A{constructor(e,t=ie()){const n=y,s=y,o={EkZCC:function(i,l,c,d){return i(l,c,d)}};super(),this[n(391)]=e,this[s(401)]=t;const a=new MessageChannel;this[s(406)]=a.port1,o[s(426)](ve,this[n(401)],{endpoint:this[s(391)]},[a[s(414)]])}}class te extends A{constructor(e,t=ie()){const n=y,s={mOWMr:function(o,a){return o===a},kgkem:function(o,a,i){return o(a,i)}};super(),this._endpoint=e,this._globalObject=t,this[n(432)]=new Promise(o=>{const a=n,i=n;s[a(392)](ge,this[i(401)],l=>{const c=i,d=i;l.data&&s[c(425)](l.data[d(422)],this[d(391)])&&(this[d(406)]=l.ports[-1*4852+1*1601+3251],o())})})}async listen(){return this[y(432)]}}function y(r,e){const t=W();return y=function(n,s){return n=n-(17*-491+-669+9407),t[n]},y(r,e)}const me=()=>{const r=new MessageChannel;return[new A(r.port1),new A(r.port2)]};(function(r,e){const t=m,n=m,s=r();for(;;)try{if(parseInt(t(355))/1+-parseInt(t(356))/2*(-parseInt(t(373))/3)+-parseInt(t(337))/4+parseInt(n(357))/5+-parseInt(n(389))/6*(-parseInt(t(396))/7)+parseInt(n(325))/8*(parseInt(t(382))/9)+-parseInt(t(366))/10===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(B,-763475+-52067*10+1724410);const be=async(r,e,t)=>{var n;const s=m,o=m,a={};a[s(345)]="tools/list",a.rqstG="tools/call",a.WqUnk="resources/list",a[s(329)]=o(358),a[s(365)]=s(335),a.ookoz="resources/unsubscribe",a[s(385)]=s(340),a.VTIWq="prompts/list",a.SkoRK=s(376),a.QUtUV=s(388),a.XtowM=o(332);const i=a,{id:l,method:c,params:d}=t;let u={};switch(c){case i[o(345)]:u=await e.listTools(d);break;case i.rqstG:u=await e.callTool(d);break;case i[s(334)]:u=await e[s(350)](d);break;case i[o(329)]:u=await e.listResourceTemplates(d);break;case s(372):u=await e[s(383)](d);break;case i.HgYgW:u=await e.subscribeResource(d);break;case i.ookoz:u=await e.unsubscribeResource(d);break;case i[s(385)]:u=await e.getPrompt(d);break;case i.VTIWq:u=await e.listPrompts(d);break;case i[s(344)]:u=await e[s(376)]();break;case i.QUtUV:u=await e.complete(d);break;case s(390):u=await e[s(336)](d?.level);break}const h={};h[s(361)]=u,h[s(394)]=i[s(364)],h.id=l,await((n=r?.transport)==null?void 0:n[s(392)](h))},we=async(r,e,t)=>{var n;const s=m,o=m,a={};a.jQBBS="sampling/createMessage",a.EZqgC="elicitation/create",a[s(370)]=o(376),a.aVeaL=o(332);const i=a,{id:l,method:c,params:d}=t;let u={};switch(c){case s(368):const f={};f.method=c,f[o(367)]=d,u=await e.request(f,w.ListRootsResultSchema);break;case i[o(391)]:const _={};_.method=c,_[o(367)]=d,u=await e[o(381)](_,w.CreateMessageResultSchema);break;case i.EZqgC:const x={};x.method=c,x.params=d,u=await e.request(x,w.ElicitResultSchema);break;case i[o(370)]:const v={};v.method=c,u=await e[o(381)](v,w.EmptyResultSchema);break}const h={};return h[o(361)]=u,h.jsonrpc=i[o(387)],h.id=l,await((n=r?.[s(371)])==null?void 0:n.send(h)),u},ye=(r,e)=>{const t=m,n={gXsjT:function(o,a){return o===a},oegpC:t(351),lZOUC:function(o,a,i,l){return o(a,i,l)},ifIKG:"2.0"},s=r._onrequest;r._onrequest=async(o,a)=>{var i,l,c,d,u;const h=t,f=t,{id:_,method:x}=o;try{n[h(333)](x,n.oegpC)?await s[h(386)](r,o,a):await n.lZOUC(be,r,e,o)}catch(v){const{code:g,message:R,data:P}=v;try{if(g){const I={};I.code=g,I.message=R,I.data=P;const k={};k.error=I,k[h(394)]=n[f(331)],k.id=_,await((i=r?.transport)==null?void 0:i.send(k))}else(c=(l=r?.[f(371)])==null?void 0:l.onerror)==null||c.call(l,v)}catch(I){(u=(d=r?.[h(371)])==null?void 0:d.onerror)==null||u.call(d,I)}}}},Ce=(r,e)=>{const t=m,n=m,s={};s[t(363)]=function(a,i){return a!==i},s[t(398)]=t(353),s.hzhyg="notifications/cancelled";const o=s;r._onnotification=async a=>{var i,l;const c=t,d=n,{method:u,params:h}=a;if(o[c(363)](u,o[d(398)])&&(o[c(363)](u,o.hzhyg)||h?.forward))try{await e.notification(a)}catch(f){(l=(i=r?.transport)==null?void 0:i.onerror)==null||l.call(i,f)}}},Ie=(r,e)=>async t=>{var n,s,o,a,i;const l=m,c=m,d={};d.SEmWX=l(332);const u=d;try{return await we(r,e,t)}catch(h){const{code:f,message:_,data:x}=h;try{if(f){const v={};v[c(377)]=f,v.message=_,v.data=x;const g={};g[c(348)]=v,g.jsonrpc=u[l(338)],g.id=t.id,await((n=r?.transport)==null?void 0:n[c(392)](g))}else(o=(s=r?.transport)==null?void 0:s[c(339)])==null||o.call(s,h)}catch(v){(i=(a=r?.[l(371)])==null?void 0:a[c(339)])==null||i.call(a,v)}}},Se=(r,e)=>async t=>{var n,s,o;const a=m,i=m,l={};l.dtUgZ=function(h,f){return h!==f},l.jgCIb=a(353),l.uUjKY="2.0";const c=l,{method:d,params:u}=t;if(c.dtUgZ(d,c.jgCIb)&&(d!==a(400)||u?.forward))try{const h={...t};h[a(394)]=c[i(352)],await((n=e?.[a(371)])==null?void 0:n[a(392)](h))}catch(h){(o=(s=r?.[a(371)])==null?void 0:s[i(339)])==null||o.call(s,h)}};function m(r,e){const t=B();return m=function(n,s){return n=n-(-1017+-1439*-1+-97),t[n]},m(r,e)}const Re=(r,e)=>async t=>{var n,s,o,a,i,l;const c=m,d=m,u={};u[c(401)]=d(332);const h=u;try{await((n=e?.transport)==null?void 0:n.send(t))}catch(f){const{code:_,message:x,data:v}=f;try{if(_){const g={};g.code=_,g[c(399)]=x,g.data=v;const R={};R[c(348)]=g,R[c(394)]=h.OhJjz,R.id=t.id,await((s=r?.[c(371)])==null?void 0:s.send(R))}else(a=(o=r?.transport)==null?void 0:o[d(339)])==null||a.call(o,f)}catch(g){(l=(i=r?.transport)==null?void 0:i.onerror)==null||l.call(i,g)}}},ne=()=>{const r=m,e=m,t={vnkqu:function(c,d){return c!==d},wxDWr:function(c,d){return c(d)},GdkkV:function(c,d){return c===d}},n=[],s=(c,d)=>{const u=m,h=m;if(d){const f=[];for(const _ of n)try{f.push(_(c,d))}catch{}for(const _ of f)if(t[u(379)](_,null))return _}else for(const f of n)try{t[h(343)](f,c)}catch{}},o=c=>{const d=m;t[d(384)](typeof c,d(369))&&!n.includes(c)&&n.push(c)},a=c=>{const d=n.indexOf(c);d!==-1&&n.splice(d,1*-6854+-264+7119)},i=()=>{const c=m;n[c(374)]=7102*1+5522+-526*24},l={};return l[r(346)]=s,l[e(330)]=o,l.removeListener=a,l[r(359)]=i,l},Te=r=>{const e=m,t=m,n={xwPeb:function(s){return s()},Mfvzm:function(s){return s()}};{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(326)](ne);r._onresponse=s,r[e(395)]=o,r.removeResponseListener=a,r.clearResponseListener=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[t(326)](ne);r[t(328)]=s,r.addRequestListener=o,r[t(354)]=a,r[t(341)]=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(375)](ne);r[e(342)]=s,r[e(327)]=o,r.removeNotificationListener=a,r.clearNotificationListener=i}};function B(){const r=["uUjKY","notifications/initialized","removeRequestListener","96194JysfjF","36346SGEWAV","1357830AJaOeY","resources/templates/list","clearListener","iQqcJ","result","tqDZP","sSeCz","XtowM","HgYgW","3913230mjiatC","params","roots/list","function","bfmJT","transport","resources/read","27FNuDmk","length","Mfvzm","ping","code","_onresponse","vnkqu","cjSoZ","request","9gIMIPC","readResource","GdkkV","ptMjy","call","aVeaL","completion/complete","5035122lFbpzR","logging/setLevel","jQBBS","send","_requestHandlers","jsonrpc","addResponseListener","7SpcenI","ElOQH","MDIkN","message","notifications/cancelled","OhJjz","clear","672216JzFEyR","xwPeb","addNotificationListener","fallbackRequestHandler","sYzPD","addListener","ifIKG","2.0","gXsjT","WqUnk","resources/subscribe","setLoggingLevel","2491772kFUWFh","SEmWX","onerror","prompts/get","clearRequestListener","fallbackNotificationHandler","wxDWr","SkoRK","uTeHc","handleListener","Zybtx","error","originalOnResponse","listResources","initialize"];return B=function(){return r},B()}const ke=(r,{beforeInit:e,afterInit:t}={})=>{const n=m,s=m,o={tqDZP:function(i,l){return i===l},cjSoZ:"function",iQqcJ:n(378),Zybtx:function(i,l){return i(l)},ElOQH:function(i){return i()}},a=new Map(r._notificationHandlers);r[n(393)][n(402)](),r._notificationHandlers[n(402)](),o.tqDZP(typeof e,o[n(380)])&&e(),o[n(362)](r._onresponse.name,o[n(360)])&&(r[s(349)]=r._onresponse),o[n(347)](Te,r),r.addResponseListener(i=>{const l=s;r.originalOnResponse[l(386)](r,i)}),o.tqDZP(typeof t,o[s(380)])&&o[n(397)](t),r[s(327)](i=>{const{method:l}=i,c=a.get(l);o.tqDZP(typeof c,o.cjSoZ)&&c(i)})},Pe=q,qe=q;(function(r,e){const t=q,n=q,s=r();for(;;)try{if(-parseInt(t(393))/1+parseInt(t(397))/2*(-parseInt(t(400))/3)+-parseInt(n(398))/4+parseInt(t(390))/5*(parseInt(n(388))/6)+-parseInt(t(389))/7+-parseInt(t(402))/8*(-parseInt(n(395))/9)+parseInt(n(399))/10*(parseInt(n(385))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Z,-1*-881393+2*180895+1*-644809);function q(r,e){const t=Z();return q=function(n,s){return n=n-(-1861+-499*4+4241),t[n]},q(r,e)}function Z(){const r=["toString","getRandomValues","2101mUsYMI","EQHzo","padStart","30UvDAkd","1609706yzlqYx","974735GrhZVO","randomUUID","REzPF","562771BvAnoG","dHTfU","2047455boiYXf","randomBytes","14664qHAdbF","3772144jLpQch","52310AkWksx","318MkjaVb","from","40WRwnSc"];return Z=function(){return r},Z()}const Le=()=>{const r=q,e=q,t={};t.REzPF=function(s,o){return s&o},t.suJHI=function(s,o){return s===o},t[r(386)]=function(s,o){return s&o},t[e(394)]="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";const n=t;return n.suJHI(typeof crypto,"object")&&crypto.randomUUID?crypto[e(391)]():n.dHTfU.replace(/[xy]/g,s=>{const o=r,a=r,i=n[o(392)](crypto[o(384)](new Uint8Array(8663+2*-4331))[741*2+-1385*-2+4252*-1],15);return(n.suJHI(s,"x")?i:n[a(386)](i,-4377+4*1095)|5079+461*-11).toString(9449+4*-461+-7589)})},Me=r=>{const e=q,t=q,n=new Uint8Array(r);return crypto.getRandomValues(n),Array[e(401)](n,s=>s[t(403)](-3*1739+-6509+2*5871)[e(387)](2,"0")).join("")},U={};U[Pe(391)]=Le,U[qe(396)]=Me;const S=L;(function(r,e){const t=L,n=L,s=r();for(;;)try{if(parseInt(t(521))/1*(parseInt(n(499))/2)+parseInt(n(543))/3*(parseInt(n(514))/4)+parseInt(t(502))/5*(parseInt(n(539))/6)+parseInt(t(553))/7+parseInt(t(516))/8*(-parseInt(t(518))/9)+-parseInt(t(531))/10+-parseInt(t(545))/11*(parseInt(t(541))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Y,1472653*1+-2*-897917+-2275789);const He=(r,e)=>{const t=L,n=L,s={FyYHt:function(l,c,d){return l(c,d)},Fxtoq:function(l,c,d){return l(c,d)}};ye(r,e),Ce(r,e);const o=Ie(e,r),a=s[t(510)](Re,e,r),i=s[n(549)](Se,e,r);e[n(537)](o),e[t(519)](a),e.addNotificationListener(i),r[n(556)]=()=>{const l=n;e.removeRequestListener(o),e[l(530)](a),e[l(529)](i)}},se=(r,e,t)=>{const n=L,s={pMiva:function(i,l){return i instanceof l},TeTEy:n(546),fyZbd:function(i,l,c){return i(l,c)}},o=()=>{var i;const l=n;s.pMiva(t,N.SSEClientTransport)&&((i=t._eventSource)==null||i.addEventListener(s[l(547)],()=>{var c;const d=l;(c=t[d(509)])==null||c[d(546)]()})),He(r,e)},a={};a.afterInit=o,s.fyZbd(ke,e,a)},ae=(r,e=U.randomUUID())=>{const t=L,n=L,s={OfssH:function(d,u,h){return d(u,h)}},o={};o[t(528)]=e;const a=o,i={};i[t(528)]=e;const l={};l[n(558)]=i,l[t(534)]=t(524);const c={requestInit:l,eventSourceInit:{async fetch(d,u){const h=t,f=n,_=new Headers(u?.[h(558)]||{});Object.entries(a)[f(498)](([v,g])=>{_[f(527)](v,g)});const x={...u};return x[f(558)]=_,s.OfssH(fetch,d,x)},withCredentials:!0}};return r&&(c.requestInit[t(558)].Authorization=t(533)+r,a.Authorization="Bearer "+r),c},ce=(r,e=U[S(517)]())=>{const t=S,n=S,s={};s.nwQhY="include";const o=s,a={};a["stream-session-id"]=e;const i={};i.headers=a,i.credentials=o[t(520)];const l={};l[t(544)]=i;const c=l;return r&&(c.requestInit.headers[n(552)]=n(533)+r),c},re=async(r,e,t)=>{const n=S,s=S,o={CFfFC:function(i){return i()},egwVO:function(i,l,c,d){return i(l,c,d)}},a=o.CFfFC(t);try{return await r[n(538)](a),a}catch(i){if(i instanceof he.UnauthorizedError){const l=await e();return await a[s(505)](l),await o[n(525)](re,r,e,t)}else throw i}};function L(r,e){const t=Y();return L=function(n,s){return n=n-498,t[n]},L(r,e)}const le=(r,e)=>{const t=S,n=S,s={};s.RsKXs=function(a,i){return a in i},s.PBhps="waitForOAuthCode",s[t(535)]="function",s[t(507)]="waitForOAuthCode need to be provided when authProvider is provided";const o=s;if(o.RsKXs(o[n(551)],r))return r[n(523)];if(typeof e===o.yTKoP)return e;throw new Error(o.RZhOv)},Ue=async r=>{const e=S,t=S,n={TFSRn:function(b,M,H){return b(M,H)},HwvVa:"mcp-sse-proxy-client",ufTHS:function(b){return b()},WIVYl:function(b,M,H,V){return b(M,H,V)},jniGY:"sessionId"},{client:s,url:o,token:a,sessionId:i,authProvider:l,requestInit:c,eventSourceInit:d,waitForOAuthCode:u}=r,h={};h.authProvider=l,h.requestInit=c,h.eventSourceInit=d;const f=h,_=i||U.randomUUID(),x=n[e(506)](ae,a,_);if(c){const b={...x.requestInit,...c};b.headers={...x[e(544)].headers,...c.headers},f.requestInit=b}else f[t(544)]=x.requestInit;if(d){const b={...x[e(559)],...d};f.eventSourceInit=b}else f.eventSourceInit=x.eventSourceInit;const v={};v.listChanged=!0;const g={};g.roots=v,g.sampling={},g[e(511)]={};const R=g,P={};P[t(536)]=n.HwvVa,P.version=e(526);const I={};I.capabilities=R;const k=new F.Client(P,I),j=()=>new N.SSEClientTransport(new URL(o),f);let T=n[t(504)](j);if(l){const b=n[e(506)](le,l,u);T=await n[t(513)](re,k,b,j)}else await k[e(538)](T);n[t(513)](se,k,s,T),T[t(557)]=T[t(542)].searchParams[t(532)](n.jniGY);const E={};return E.transport=T,E.sessionId=T[e(557)],E};function Y(){const r=["ufTHS","finishAuth","TFSRn","RZhOv","Vajmx","_eventSource","FyYHt","elicitation","transport","WIVYl","13320uyrBtN","sampling","8WTwLJD","randomUUID","6438654bkJHij","addResponseListener","nwQhY","11721GVgRMJ","?sessionId=","waitForOAuthCode","include","egwVO","1.0.0","set","sse-session-id","removeNotificationListener","removeResponseListener","11838520fNkjrV","get","Bearer ","credentials","yTKoP","name","addRequestListener","connect","18VhCgQv","mcp-socket-proxy-client","2819364JNqkQZ","_endpoint","699JyrxCR","requestInit","44ofbsvb","close","TeTEy","QgzDy","Fxtoq","roots","PBhps","Authorization","11309130xGCFwl","&token=","version","onclose","sessionId","headers","eventSourceInit","forEach","62FcOkCa","mcp-stream-proxy-client","zXcpO","1794855cQEXDT","biJOc"];return Y=function(){return r},Y()}const Ee=async r=>{const e=S,t=S,n={Vajmx:e(500),biJOc:function(b){return b()},zXcpO:function(b,M,H){return b(M,H)},zDnjZ:function(b,M,H,V){return b(M,H,V)},FQMAh:function(b,M,H,V){return b(M,H,V)}},{client:s,url:o,token:a,sessionId:i,authProvider:l,requestInit:c,reconnectionOptions:d,waitForOAuthCode:u}=r,h={};h.authProvider=l,h.requestInit=c,h.reconnectionOptions=d;const f=h,_=i||U.randomUUID(),x=ce(a,_);if(c){const b={...x.requestInit,...c};b.headers={...x.requestInit.headers,...c.headers},f[e(544)]=b}else f.requestInit=x.requestInit;const v={};v.listChanged=!0;const g={};g[t(550)]=v,g.sampling={},g.elicitation={};const R=g,P={};P[e(536)]=n[t(508)],P[e(555)]="1.0.0";const I={};I.capabilities=R;const k=new F.Client(P,I),j=()=>new z.StreamableHTTPClientTransport(new URL(o),f);let T=n[e(503)](j);if(l){const b=n[e(501)](le,l,u);T=await n.zDnjZ(re,k,b,j)}else await k.connect(T);n.FQMAh(se,k,s,T);const E={};return E.transport=T,E[t(557)]=T.sessionId,E},Oe=async r=>{const e=S,t=S,n={QgzDy:e(540),jkaVB:function(g,R,P,I){return g(R,P,I)}},{client:s,url:o,token:a,sessionId:i}=r,l={};l.listChanged=!0;const c={};c[e(550)]=l,c[e(515)]={},c[t(511)]={};const d=c,u={};u.name=n[t(548)],u[t(555)]=t(526);const h={};h.capabilities=d;const f=new F.Client(u,h),_=i||U[t(517)](),x=new oe.WebSocketClientTransport(new URL(o+e(522)+_+t(554)+a));await f.connect(x),n.jkaVB(se,f,s,x);const v={};return v[e(512)]=x,v[t(557)]=_,v},D=C,J=C;function C(r,e){const t=G();return C=function(n,s){return n=n-(-16761+51*337),t[n]},C(r,e)}(function(r,e){const t=C,n=C,s=r();for(;;)try{if(-parseInt(t(440))/1+-parseInt(t(458))/2*(parseInt(t(448))/3)+-parseInt(t(451))/4*(parseInt(n(449))/5)+-parseInt(n(455))/6+-parseInt(t(427))/7+-parseInt(n(438))/8*(parseInt(n(459))/9)+parseInt(t(430))/10*(parseInt(n(436))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(G,-220880+1*-333337+-2*-384996);function G(){const r=["650XPHLhD","redirectToAuthorization","10856jPvMVb","GET","qcFPW","_redirectUrl","2187414WnlGuZ","resolve","tokens","3976YyOqUl","27ejNHsa","Content-Type","waitForOAuthCode","2903796yvWZFa","_clientMetadata","application/x-www-form-urlencoded","10beEWJk","json","code","_callBackPromise","reject","saveClientInformation","20776349mLNCcF","_codeVerifier","629912aTknXq","_tokens","52074GwcpRo","state","_state","_redirectCallback","_clientInformation","redirect_uris","Failed to redirect: ","clientInformation","381aduWsB"];return G=function(){return r},G()}const Fe=()=>U.randomBytes(3485*1+-261+-3184);class Ne{constructor(e){const t=C,n=C;this._callBackPromise={};const{clientMetadata:s,state:o,redirectCallback:a,getAuthCodeByState:i,waitForOAuthCode:l}=e;this[t(428)]=s,this[t(454)]=s[t(445)][0],this._state=o||Fe(),this._redirectCallback=a||this.redirectCallbackFunction,this._getAuthCodeByState=i||this.getAuthCodeByStateFunction,this[n(426)]=l||this.waitForOAuthCodeFunction()}async redirectCallbackFunction(e){var t,n,s,o,a,i;const l=C,c=C,d={qITTp:function(_,x,v){return _(x,v)},qcFPW:l(452)},u=await d.qITTp(fetch,e,{method:d[l(453)]});!u.ok&&((n=(t=this._callBackPromise).reject)==null||n.call(t,c(446)+u.statusText));const h=await this._getAuthCodeByState(this[c(454)],this[l(442)]);if(!h.ok){(o=(s=this[l(433)]).reject)==null||o.call(s,"Failed to fetch auth code: "+h.statusText);return}const f=await h[l(431)]();(i=(a=this[c(433)])[l(456)])==null||i.call(a,f[l(432)])}async getAuthCodeByStateFunction(e,t){const n=C,s=C,o={};o.tuSmb=n(429);const a=o,i={};i[n(460)]=a.tuSmb;const l={};return l[s(441)]=t,fetch(e,{method:"POST",headers:i,body:new URLSearchParams(l)})}waitForOAuthCodeFunction(){const e=C,t=this[e(433)];return()=>new Promise((n,s)=>{const o=e;t.resolve=n,t[o(434)]=s})}get redirectUrl(){return this[C(454)]}get clientMetadata(){return this._clientMetadata}state(){return this._state}[D(447)](){return this[D(444)]}[J(435)](e){const t=D;this[t(444)]=e}[J(457)](){return this[J(439)]}saveTokens(e){this._tokens=e}[J(450)](e){this[D(443)](e)}saveCodeVerifier(e){this._codeVerifier=e}codeVerifier(){if(!this[D(437)])throw new Error("No code verifier saved");return this._codeVerifier}}(function(r,e){for(var t=Q,n=Q,s=r();;)try{var o=parseInt(t(361))/1*(parseInt(n(363))/2)+-parseInt(t(358))/3+parseInt(t(359))/4*(parseInt(t(357))/5)+parseInt(n(354))/6*(parseInt(t(360))/7)+parseInt(n(362))/8+parseInt(n(364))/9+-parseInt(n(356))/10*(parseInt(t(355))/11);if(o===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(K,-73523*-3+1*-407717+530518);function K(){var r=["40ecBYYe","1095owKKYD","486870YOVwZy","5752xWiyTO","561484biNVMw","1fWJmxQ","1866064SPnyhb","1109522vMiuMX","1602351pPEGwH","12sVyMLL","2573296LTwOhv"];return K=function(){return r},K()}function Q(r,e){var t=K();return Q=function(n,s){n=n-(-1*-642+503*-5+2227);var o=t[n];return o},Q(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 $.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(w.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 te(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(w.SubscribeRequestSchema,e)}onUnsubscribe(e){this.server.server.setRequestHandler(w.UnsubscribeRequestSchema,e)}onSetLogLevel(e){this.server.server.setRequestHandler(w.SetLevelRequestSchema,e)}onListResources(e){this.server.server.setRequestHandler(w.ListResourcesRequestSchema,e)}onRootsListChanged(e){this.server.server.setNotificationHandler(w.RootsListChangedNotificationSchema,e)}async onPagehide(e){e.persisted||this.transport&&typeof this.transport.close=="function"&&await this.transport.close()}}const je=(r,e)=>new te(r,e),Ve=()=>me(),ze=r=>r instanceof te,We=r=>r instanceof $.McpServer;class Ae{constructor(e,t){const n={name:"web-mcp-client",version:"1.0.0"},s={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new F.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:f,sessionId:_}=o==="sse"?await Ue(d):o==="socket"?await Oe(d):await Ee(d);f.onerror=async x=>{i?.(x)},u={transport:f,sessionId:_}})(),u}const l=new URL(t);let c;if(o==="channel"&&(c=new ee(t),await this.client.connect(c)),o==="sse"){const d=ae(n,s);c=new N.SSEClientTransport(l,d),await this.client.connect(c)}if(o==="socket"&&(c=new oe.WebSocketClientTransport(new URL(`${t}?sessionId=${s}&token=${n}`)),c.sessionId=s,await this.client.connect(c)),typeof c>"u"){const d=ce(n,s);c=new z.StreamableHTTPClientTransport(l,d),await this.client.connect(c)}return this.transport=c,{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,w.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(w.ElicitRequestSchema,e)}onCreateMessage(e){this.client.setRequestHandler(w.CreateMessageRequestSchema,e)}onListRoots(e){this.client.setRequestHandler(w.ListRootsRequestSchema,e)}onToolListChanged(e){this.client.setNotificationHandler(w.ToolListChangedNotificationSchema,e)}onPromptListChanged(e){this.client.setNotificationHandler(w.PromptListChangedNotificationSchema,e)}onResourceListChanged(e){this.client.setNotificationHandler(w.ResourceListChangedNotificationSchema,e)}onResourceUpdated(e){this.client.setNotificationHandler(w.ResourceUpdatedNotificationSchema,e)}onLoggingMessage(e){this.client.setNotificationHandler(w.LoggingMessageNotificationSchema,e)}async onPagehide(e){e.persisted||(de(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const Be=(r,e)=>new N.SSEClientTransport(r,e),Ze=(r,e)=>new z.StreamableHTTPClientTransport(r,e),Ye=(r,e)=>new ee(r,e),Je=r=>r instanceof N.SSEClientTransport,de=r=>r instanceof z.StreamableHTTPClientTransport,Ge=r=>r instanceof ee,Ke=r=>r instanceof F.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)}),X=(r,e,t)=>{window.postMessage({type:r,direction:t,data:e},"*")},ue=(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 Xe{constructor(e=null){this._isStarted=!1,this._isClosed=!1,this._lastRegistration=null,this.sessionId=e||Qe(),this._messageListener1=ue("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=ue("mcp-client-to-server-to-page",t=>{if(t.sessionId!==this.sessionId)return;console.log("【Page Svr Transport】 即将处理 mcpMessage",t.mcpMessage);const n=w.JSONRPCMessageSchema.parse(t.mcpMessage);this.onmessage?.(n),t.mcpMessage.params?.name&&X("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】 已关闭,无法发送消息"),X("mcp-server-to-client-from-page",{sessionId:this.sessionId,mcpMessage:e},"page->content"),"result"in e&&e.result?.content&&X("update-page-app-message",{status:"ready",message:""},"page->content")}async notifyRegistration(e){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法注册消息"),this._lastRegistration=e;try{X("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))}}}p.Ajv=O,Object.defineProperty(p,"ResourceTemplate",{enumerable:!0,get:()=>$.ResourceTemplate}),Object.defineProperty(p,"z",{enumerable:!0,get:()=>fe.z}),Object.defineProperty(p,"UriTemplate",{enumerable:!0,get:()=>pe.UriTemplate}),Object.defineProperty(p,"completable",{enumerable:!0,get:()=>xe.completable}),Object.defineProperty(p,"getDisplayName",{enumerable:!0,get:()=>_e.getDisplayName}),p.AuthClientProvider=Ne,p.ExtensionPageServerTransport=Xe,p.WebMcpClient=Ae,p.WebMcpServer=De,p.createMessageChannelClientTransport=Ye,p.createMessageChannelPairTransport=Ve,p.createMessageChannelServerTransport=je,p.createSSEClientTransport=Be,p.createStreamableHTTPClientTransport=Ze,p.isMcpClient=Ke,p.isMcpServer=We,p.isMessageChannelClientTransport=Ge,p.isMessageChannelServerTransport=ze,p.isSSEClientTransport=Je,p.isStreamableHTTPClientTransport=de,Object.defineProperty(p,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,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"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/next-sdk",
3
- "version": "0.1.15-beta.4",
3
+ "version": "0.1.15-beta.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Chunhui Mo",
@@ -9,7 +9,7 @@
9
9
  "types": "dist/index.d.ts",
10
10
  "description": "OpenTiny NEXT SDK",
11
11
  "dependencies": {
12
- "@modelcontextprotocol/sdk": "~1.24.3",
12
+ "@modelcontextprotocol/sdk": "~1.23.0",
13
13
  "@opentiny/next": "^0.3.1",
14
14
  "@ai-sdk/openai": "^2.0.76",
15
15
  "@ai-sdk/deepseek": "1.0.30",