@opentiny/next-sdk 0.1.3 → 0.1.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/McpSdk.ts +14 -0
- package/WebAgent.ts +5 -0
- package/WebMcp.ts +18 -0
- package/Zod.ts +1 -0
- package/agent/AgentModelProvider.ts +150 -36
- package/agent/type.ts +1 -1
- package/agent/utils/getAISDKTools.ts +35 -0
- package/dist/agent/AgentModelProvider.d.ts +43 -4
- package/dist/agent/AgentModelProvider.js +145 -24
- package/dist/agent/type.d.ts +1 -1
- package/dist/agent/utils/getAISDKTools.d.ts +8 -0
- package/dist/agent/utils/getAISDKTools.js +36 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.es.dev.js +42947 -0
- package/dist/index.es.js +18006 -17750
- package/dist/index.js +10 -4
- package/dist/index.umd.dev.js +43341 -0
- package/dist/index.umd.js +285 -114
- package/dist/mcpsdk@1.17.0.dev.js +21391 -0
- package/dist/mcpsdk@1.17.0.es.dev.js +21389 -0
- package/dist/mcpsdk@1.17.0.es.js +14525 -0
- package/dist/mcpsdk@1.17.0.js +16 -0
- package/dist/remoter/createRemoter.d.ts +10 -2
- package/dist/remoter/createRemoter.js +312 -55
- package/dist/webagent.dev.js +27509 -0
- package/dist/webagent.es.dev.js +27115 -0
- package/dist/webagent.es.js +21448 -0
- package/dist/webagent.js +529 -0
- package/dist/webmcp-full.dev.js +22879 -0
- package/dist/webmcp-full.es.dev.js +22875 -0
- package/dist/webmcp-full.es.js +15821 -0
- package/dist/webmcp-full.js +16 -0
- package/dist/webmcp.dev.js +1373 -0
- package/dist/webmcp.es.dev.js +1366 -0
- package/dist/webmcp.es.js +1232 -0
- package/dist/webmcp.js +1 -0
- package/dist/zod@3.25.76.dev.js +4039 -0
- package/dist/zod@3.25.76.es.dev.js +4035 -0
- package/dist/zod@3.25.76.es.js +2947 -0
- package/dist/zod@3.25.76.js +1 -0
- package/index.ts +16 -4
- package/package.json +16 -4
- package/remoter/createRemoter.ts +327 -62
- package/runtime.html +98 -0
- package/script/utils.ts +26 -0
- package/vite.config.mcpSdk.ts +28 -0
- package/vite.config.ts +13 -12
- package/vite.config.webAgent.ts +19 -0
- package/vite.config.webMcp.ts +40 -0
- package/vite.config.webMcpFull.ts +19 -0
- package/vite.config.zod.ts +23 -0
- package/agent/utils/aiProviderFactories.ts +0 -7
- package/agent/utils/index.ts +0 -79
- package/dist/agent/utils/aiProviderFactories.d.ts +0 -6
- package/dist/agent/utils/aiProviderFactories.js +0 -6
- package/dist/agent/utils/index.d.ts +0 -14
- package/dist/agent/utils/index.js +0 -72
- package/dist/index.cjs.js +0 -365
package/dist/webmcp.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(p,z){typeof exports=="object"&&typeof module<"u"?z(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/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/auth.js","@modelcontextprotocol/sdk/server/mcp.js","zod","@modelcontextprotocol/sdk/shared/uriTemplate.js","@modelcontextprotocol/sdk/server/completable.js","@modelcontextprotocol/sdk/shared/metadataUtils.js"],z):(p=typeof globalThis<"u"?globalThis:p||self,z(p.WebMCP={},p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.Zod,p.MCPSDK,p.MCPSDK,p.MCPSDK))})(this,function(p,z,w,V,F,B,de,$,fe,he,pe,xe){"use strict";const ee=C;(function(s,e){const t=C,n=C,r=s();for(;;)try{if(parseInt(t(145))/1*(-parseInt(n(169))/2)+-parseInt(t(143))/3*(-parseInt(t(176))/4)+-parseInt(t(134))/5*(-parseInt(n(154))/6)+-parseInt(t(160))/7*(-parseInt(n(170))/8)+parseInt(t(133))/9+parseInt(t(163))/10*(parseInt(n(165))/11)+-parseInt(t(161))/12===e)break;r.push(r.shift())}catch{r.push(r.shift())}})(W,-1617767+7318*202+963472);function C(s,e){const t=W();return C=function(n,r){return n=n-129,t[n]},C(s,e)}const oe=()=>{const s=C,e=C,t={SUplI:function(n,r){return n!==r},gdsVr:s(173),fDJxn:function(n,r){return n!==r},FzgVC:function(n,r){return n(r)},RphJy:"return this"};return t[s(139)](typeof globalThis,t[e(164)])?globalThis:t[s(139)](typeof window,"undefined")?window:t[s(172)](typeof global,t.gdsVr)?global:typeof self!==t.gdsVr?self:t[s(156)](Function,t[e(155)])()},_e=(s,e,t)=>{const n=C,r=C,o={};o.BODwV=function(a,c){return a!==c},o.axlRk="undefined",o.WGYMl=function(a,c){return a in c},o[n(162)]=r(131),o[r(142)]=function(a,c){return a===c},o[r(159)]=n(166);const i=o;i[r(147)](typeof window,i.axlRk)?s.postMessage(e,"*",t):i.WGYMl(i[n(162)],s)&&i[n(142)](typeof s[n(131)],i.LnNVQ)&&s.postMessage(e,t)},ve=(s,e)=>{const t=C,n=C,r={};r.tblHl=t(152),r.CQBXk=function(i,a){return i===a},r.rzcdo=n(166),r[n(140)]=function(i,a){return i in a},r[t(157)]="onmessage",r.jnGTR=function(i,a){return i!==a},r.xkAIW="undefined";const o=r;o.tblHl in s&&o.CQBXk(typeof s[n(152)],o.rzcdo)?s[n(152)]("message",e):o.SjhYv(o[n(157)],s)&&o[n(158)](typeof s.onmessage,o.xkAIW)&&(s[n(130)]=e)};class E{constructor(e){this._port=e}async start(){const e=C;this._port&&(this[e(138)].onmessage=t=>{var n,r;const o=e;try{const i=w.JSONRPCMessageSchema.parse(t[o(135)].message);(n=this.onmessage)==null||n.call(this,i,t[o(135)].extra)}catch(i){const a=new Error("MessageChannel failed to parse message: "+i);(r=this.onerror)==null||r.call(this,a)}},this._port.onmessageerror=t=>{var n;const r=new Error("MessageChannel transport error: "+JSON.stringify(t));(n=this.onerror)==null||n.call(this,r)},this[e(138)][e(153)]())}async send(e,t){const n={OXUfv:function(r){return r()},HGTbd:function(r,o){return r(o)},Pfhxv:function(r,o){return r(o)}};return new Promise((r,o)=>{var i;const a=C,c=C;try{const l={};l.authInfo=t==null?void 0:t[a(132)];const u={};u[c(148)]=e,u[a(141)]=l,this[a(138)]&&this[c(138)].postMessage(u),n[c(144)](r)}catch(l){const u=l instanceof Error?l:new Error(n.HGTbd(String,l));(i=this[a(137)])==null||i.call(this,u),n[a(151)](o,u)}})}async close(){var e,t;const n=C,r=C;(e=this._port)==null||e[n(129)](),this[r(138)]=void 0,(t=this.onclose)==null||t.call(this)}}function W(){const s=["start","18osCtKg","RphJy","FzgVC","MJJde","jnGTR","LnNVQ","1051519VVnrnU","33477396wnvbno","sxstg","5032460FukhmU","gdsVr","11iMeJBh","function","_endpoint","_listen","1275704COqcWf","56LfVOEz","listen","fDJxn","undefined","ports","JlLHy","4dKwrPa","close","onmessage","postMessage","authInfo","11129553jiEKRY","776455JhRkBm","data","port2","onerror","_port","SUplI","SjhYv","extra","cgHZW","2982963YuFHfk","OXUfv","1sYviCF","port1","BODwV","message","ZJoRh","_globalObject","Pfhxv","addEventListener"];return W=function(){return s},W()}class te extends E{constructor(e,t=oe()){const n=C,r={JlLHy:function(i,a,c,l){return i(a,c,l)}};super(),this[n(167)]=e,this[n(150)]=t;const o=new MessageChannel;this._port=o.port1,r[n(175)](_e,this._globalObject,{endpoint:this._endpoint},[o.port2])}}class ne extends E{constructor(e,t=oe()){const n=C,r={vqpjH:function(o,i){return o===i},iWjpS:function(o){return o()},ZJoRh:function(o,i,a){return o(i,a)}};super(),this._endpoint=e,this[n(150)]=t,this._listen=new Promise(o=>{const i=n;r[i(149)](ve,this[i(150)],a=>{const c=i;a.data&&r.vqpjH(a.data.endpoint,this._endpoint)&&(this[c(138)]=a[c(174)][-9452+-4726*-2],r.iWjpS(o))})})}async[ee(171)](){return this[ee(168)]}}const me=()=>{const s=ee,e=new MessageChannel;return[new E(e[s(146)]),new E(e[s(136)])]};(function(s,e){const t=v,n=v,r=s();for(;;)try{if(-parseInt(t(415))/1+-parseInt(n(357))/2*(parseInt(t(368))/3)+-parseInt(n(408))/4+parseInt(t(371))/5+-parseInt(n(429))/6*(-parseInt(t(412))/7)+parseInt(t(407))/8*(parseInt(t(423))/9)+-parseInt(t(375))/10===e)break;r.push(r.shift())}catch{r.push(r.shift())}})(j,-7527*130+350160+1329539);const be=async(s,e,t)=>{var n;const r=v,o=v,i={};i.PgGRq="tools/call",i[r(354)]=r(387),i[o(369)]=r(364),i[o(394)]=o(426),i[r(406)]="ping",i.BWglk=r(360),i[o(409)]="logging/setLevel",i.YTglM=o(399);const a=i,{id:c,method:l,params:u}=t;let f={};switch(l){case"tools/list":f=await e.listTools(u);break;case a.PgGRq:f=await e.callTool(u);break;case r(390):f=await e.listResources(u);break;case a[r(354)]:f=await e[r(382)](u);break;case"resources/read":f=await e[r(376)](u);break;case a.INhFO:f=await e[o(418)](u);break;case"resources/unsubscribe":f=await e[r(393)](u);break;case"prompts/get":f=await e.getPrompt(u);break;case a[o(394)]:f=await e[r(422)](u);break;case a[o(406)]:f=await e.ping();break;case a.BWglk:f=await e.complete(u);break;case a.exSlO:f=await e.setLoggingLevel(u==null?void 0:u[o(355)]);break}const d={};d.result=f,d[o(374)]=a[o(361)],d.id=c,await((n=s==null?void 0:s.transport)==null?void 0:n.send(d))},ge=async(s,e,t)=>{var n;const r=v,o=v,i={};i.mKgNI="roots/list",i[r(391)]=r(380),i.BUcjm="ping",i[o(367)]="2.0";const a=i,{id:c,method:l,params:u}=t;let f={};switch(l){case a[o(397)]:const h={};h.method=l,h[o(395)]=u,f=await e[o(377)](h,w.ListRootsResultSchema);break;case"sampling/createMessage":const _={};_[r(365)]=l,_[r(395)]=u,f=await e[o(377)](_,w.CreateMessageResultSchema);break;case a.HHuTf:const x={};x.method=l,x.params=u,f=await e.request(x,w.ElicitResultSchema);break;case a.BUcjm:const b={};b.method=l,f=await e.request(b,w.EmptyResultSchema);break}const d={};return d[o(401)]=f,d.jsonrpc=a[r(367)],d.id=c,await((n=s==null?void 0:s.transport)==null?void 0:n[r(388)](d)),f},we=(s,e)=>{const t=v,n=v,r={lfNNa:function(i,a,c,l){return i(a,c,l)},ERLmZ:t(399)},o=s[n(362)];s._onrequest=async(i,a)=>{var c,l,u,f,d;const h=n,_=t,{id:x,method:b}=i;try{b===h(398)?await o[_(428)](s,i,a):await r[_(425)](be,s,e,i)}catch(g){const{code:I,message:T,data:N}=g;try{if(I){const S={};S.code=I,S.message=T,S.data=N;const H={};H.error=S,H.jsonrpc=r[_(370)],H.id=x,await((c=s==null?void 0:s[_(381)])==null?void 0:c.send(H))}else(u=(l=s==null?void 0:s[h(381)])==null?void 0:l.onerror)==null||u.call(l,g)}catch(S){(d=(f=s==null?void 0:s[h(381)])==null?void 0:f.onerror)==null||d.call(f,S)}}}},Ce=(s,e)=>{const t=v,n=v,r={};r.HMnPG=function(i,a){return i!==a},r[t(402)]=t(404),r.FwMpF="notifications/cancelled";const o=r;s[t(403)]=async i=>{var a,c;const l=n,u=t,{method:f,params:d}=i;if(o.HMnPG(f,o[l(402)])&&(o[l(396)](f,o.FwMpF)||d!=null&&d[u(359)]))try{await e.notification(i)}catch(h){(c=(a=s==null?void 0:s.transport)==null?void 0:a.onerror)==null||c.call(a,h)}}},Se=(s,e)=>async t=>{var n,r,o,i,a;const c=v,l=v,u={SAxlc:function(f,d,h,_){return f(d,h,_)},dFopk:"2.0"};try{return await u[c(383)](ge,s,e,t)}catch(f){const{code:d,message:h,data:_}=f;try{if(d){const x={};x[l(427)]=d,x[c(358)]=h,x[l(353)]=_;const b={};b[c(392)]=x,b.jsonrpc=u[c(421)],b.id=t.id,await((n=s==null?void 0:s.transport)==null?void 0:n.send(b))}else(o=(r=s==null?void 0:s[l(381)])==null?void 0:r.onerror)==null||o.call(r,f)}catch(x){(a=(i=s==null?void 0:s[c(381)])==null?void 0:i.onerror)==null||a.call(i,x)}}};function j(){const s=["level","originalOnResponse","55170mBdYDU","message","forward","completion/complete","YTglM","_onrequest","push","resources/subscribe","method","evRYg","IwJLf","36vWOzfl","INhFO","ERLmZ","4771400ICkNjz","removeListener","bepKH","jsonrpc","1588030zEKxZA","readResource","request","indexOf","_onresponse","elicitation/create","transport","listResourceTemplates","SAxlc","TivTb","VvMvg","lKSxx","resources/templates/list","send","removeRequestListener","resources/list","HHuTf","error","unsubscribeResource","JgvOQ","params","HMnPG","mKgNI","initialize","2.0","clearListener","result","xAZkD","_onnotification","notifications/initialized","DNAeN","deQam","18856juHcqp","1408312pVrTzy","exSlO","_notificationHandlers","fallbackRequestHandler","1770391vhkQKM","clear","length","917098eoebuK","onerror","eBAUu","subscribeResource","get","clearRequestListener","dFopk","listPrompts","2853mVPrjm","addNotificationListener","lfNNa","prompts/list","code","call","18wkYBws","addResponseListener","data","RZSpk"];return j=function(){return s},j()}const ye=(s,e)=>async t=>{var n,r,o;const i=v,a=v,c={};c[i(384)]=function(d,h){return d!==h},c.HBVzz="notifications/cancelled",c.bepKH="2.0";const l=c,{method:u,params:f}=t;if(l.TivTb(u,"notifications/initialized")&&(u!==l.HBVzz||f!=null&&f[a(359)]))try{const d={...t};d[i(374)]=l[a(373)],await((n=e==null?void 0:e.transport)==null?void 0:n[a(388)](d))}catch(d){(o=(r=s==null?void 0:s.transport)==null?void 0:r.onerror)==null||o.call(r,d)}};function v(s,e){const t=j();return v=function(n,r){return n=n-(14*-396+-8764+-2932*-5),t[n]},v(s,e)}const Ie=(s,e)=>async t=>{var n,r,o,i,a,c;const l=v,u=v,f={};f.lCWNU="2.0";const d=f;try{await((n=e==null?void 0:e.transport)==null?void 0:n.send(t))}catch(h){const{code:_,message:x,data:b}=h;try{if(_){const g={};g.code=_,g[l(358)]=x,g[l(353)]=b;const I={};I.error=g,I.jsonrpc=d.lCWNU,I.id=t.id,await((r=s==null?void 0:s[l(381)])==null?void 0:r[u(388)](I))}else(i=(o=s==null?void 0:s.transport)==null?void 0:o.onerror)==null||i.call(o,h)}catch(g){(c=(a=s==null?void 0:s[l(381)])==null?void 0:a[l(416)])==null||c.call(a,g)}}},re=()=>{const s=v,e={ppppd:function(c,l){return c!==l},VvMvg:function(c,l){return c(l)},kyvea:function(c,l){return c===l},Finqx:"function",DNAeN:function(c,l){return c!==l}},t=[],n=(c,l)=>{const u=v;if(l){const f=[];for(const d of t)try{f[u(363)](d(c,l))}catch{}for(const d of f)if(e.ppppd(d,null))return d}else for(const f of t)try{e[u(385)](f,c)}catch{}},r=c=>{const l=v;e.kyvea(typeof c,e.Finqx)&&!t.includes(c)&&t[l(363)](c)},o=c=>{const l=v,u=t[l(378)](c);e[l(405)](u,-1)&&t.splice(u,-9316+-82*53+-1*-13663)},i=()=>{const c=v;t[c(414)]=-1*-9084+-3251*-1+12335*-1},a={};return a.handleListener=n,a.addListener=r,a[s(372)]=o,a[s(400)]=i,a},Re=s=>{const e=v,t=v,n={nsbwy:function(r){return r()},evRYg:function(r){return r()},SwOnF:function(r){return r()}};{const{handleListener:r,addListener:o,removeListener:i,clearListener:a}=n.nsbwy(re);s._onresponse=r,s[e(352)]=o,s.removeResponseListener=i,s.clearResponseListener=a}{const{handleListener:r,addListener:o,removeListener:i,clearListener:a}=n[t(366)](re);s[e(411)]=r,s.addRequestListener=o,s[e(389)]=i,s[t(420)]=a}{const{handleListener:r,addListener:o,removeListener:i,clearListener:a}=n.SwOnF(re);s.fallbackNotificationHandler=r,s.addNotificationListener=o,s.removeNotificationListener=i,s.clearNotificationListener=a}},Te=(s,{beforeInit:e,afterInit:t}={})=>{const n=v,r=v,o={eBAUu:"function",uldJU:function(a,c){return a(c)},nOioM:function(a,c){return a===c},mYMiK:function(a){return a()},lKSxx:function(a){return a()}},i=new Map(s._notificationHandlers);s._requestHandlers[n(413)](),s[r(410)][n(413)](),o.nOioM(typeof e,o.eBAUu)&&o.mYMiK(e),s._onresponse.name===r(379)&&(s[r(356)]=s._onresponse),Re(s),s[r(352)](a=>{s[n(356)].call(s,a)}),o.nOioM(typeof t,o[r(417)])&&o[n(386)](t),s[r(424)](a=>{const c=n,{method:l}=a,u=i[c(419)](l);typeof u===o.eBAUu&&o.uldJU(u,a)})},Le=P;function P(s,e){const t=Y();return P=function(n,r){return n=n-(-499*3+1*-890+-337*-8),t[n]},P(s,e)}(function(s,e){const t=P,n=P,r=s();for(;;)try{if(parseInt(t(315))/1*(-parseInt(t(316))/2)+parseInt(t(319))/3*(-parseInt(t(320))/4)+-parseInt(n(324))/5+parseInt(t(327))/6*(-parseInt(n(323))/7)+parseInt(n(312))/8+-parseInt(t(310))/9+parseInt(t(325))/10*(parseInt(t(322))/11)===e)break;r.push(r.shift())}catch{r.push(r.shift())}})(Y,815846+-859697*1+650566);const qe=()=>{const s=P,e=P,t={};t[s(317)]=function(r,o){return r&o},t[e(326)]=function(r,o){return r|o},t.CJbSq=function(r,o){return r&o},t[e(313)]=function(r,o){return r===o},t.aiAIs=e(309);const n=t;return n[s(313)](typeof crypto,n.aiAIs)&&crypto[s(314)]?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const o=s,i=s,a=n[o(317)](crypto[i(321)](new Uint8Array(-8718+124*25+5619))[-6393+-329*-4+1*5077],222*-2+-5419*-1+-496*10);return(r==="x"?a:n.koxtC(n.CJbSq(a,1510+1*-1507),737*-3+-3740+5959)).toString(16)})},Me=s=>{const e=P,t=P,n=new Uint8Array(s);return crypto[e(321)](n),Array[e(311)](n,r=>r.toString(-9830*1+15*-389+15681).padStart(2,"0"))[t(328)]("")},O={};function Y(){const s=["322602YEeXTL","cWMWo","randomBytes","360714cQwoni","4jGlyZR","getRandomValues","11vuSHLa","7coyLYd","576200ZDqfSL","25441610RPtFTZ","koxtC","4124070gqAgCl","join","object","8383374JYLMHO","from","4496536egULKP","bXzKK","randomUUID","4ZgaCxq"];return Y=function(){return s},Y()}O.randomUUID=qe,O[Le(318)]=Me;const D=M,U=M;(function(s,e){const t=M,n=M,r=s();for(;;)try{if(-parseInt(t(202))/1+-parseInt(n(206))/2+-parseInt(n(205))/3+parseInt(t(176))/4+-parseInt(n(180))/5+-parseInt(n(194))/6+parseInt(t(188))/7===e)break;r.push(r.shift())}catch{r.push(r.shift())}})(Z,112621*2+-1*-1870746+-1103066);function Z(){const s=["function","JPlVw","removeRequestListener","authProvider","1.0.0","rmzgk","ZXEHq","KmDTz","oHJBZ","TIBus","credentials","197184QVZkrq","removeResponseListener","set","searchParams","9184715GDLahr","version","listChanged","KaUfV","include","Authorization","afterInit","entries","50977584KLIJFM","sampling","capabilities","randomUUID","close","requestInit","1757244qRFdUY","headers","transport","mcp-sse-proxy-client","sessionId","wZCHj","roots","removeNotificationListener","1628495nlouLW","addRequestListener","xZlrW","4650435ijSJjJ","2060858ZiIYSc","SUlgi","_eventSource","eventSourceInit","MRyfg","mcp-stream-proxy-client","sse-session-id","name","alwWV","aDqLK"];return Z=function(){return s},Z()}const ke=(s,e)=>{const t=M,n=M,r={MRyfg:function(c,l,u){return c(l,u)}};r[t(210)](we,s,e),r.MRyfg(Ce,s,e);const o=Se(e,s),i=r.MRyfg(Ie,e,s),a=ye(e,s);e[t(203)](o),e.addResponseListener(i),e.addNotificationListener(a),s.onclose=()=>{const c=t,l=n;e[c(218)](o),e[c(177)](i),e[l(201)](a)}},ie=(s,e,t)=>{const n=M,r=M,o={oHJBZ:function(c,l){return c instanceof l},THMqs:n(192),Ukaqt:function(c,l,u){return c(l,u)},pgcGT:function(c,l,u){return c(l,u)}},i=()=>{var c;const l=n,u=n;o[l(173)](t,F.SSEClientTransport)&&((c=t[u(208)])==null||c.addEventListener(o.THMqs,()=>{var f;const d=l;(f=t._eventSource)==null||f[d(192)]()})),o.Ukaqt(ke,s,e)},a={};a[r(186)]=i,o.pgcGT(Te,e,a)},ae=(s,e=O[D(191)]())=>{const t=D,n=D,r={sFqUo:function(u,f,d){return u(f,d)},KmDTz:t(184)},o={};o[n(212)]=e;const i=o,a={};a["sse-session-id"]=e;const c={};c[n(195)]=a,c[t(175)]=r[t(172)];const l={requestInit:c,eventSourceInit:{async fetch(u,f){const d=t,h=new Headers((f==null?void 0:f.headers)||{});Object[d(187)](i).forEach(([x,b])=>{h[d(178)](x,b)});const _={...f};return _.headers=h,r.sFqUo(fetch,u,_)},withCredentials:!0}};return s&&(l[n(193)][t(195)].Authorization="Bearer "+s,i.Authorization="Bearer "+s),l},ce=(s,e=O[U(191)]())=>{const t=U,n=D,r={};r["stream-session-id"]=e;const o={};o.headers=r,o[t(175)]=t(184);const i={};i[n(193)]=o;const a=i;return s&&(a.requestInit[t(195)][t(185)]="Bearer "+s),a};function M(s,e){const t=Z();return M=function(n,r){return n=n-(-1*-8402+-921*-6+13759*-1),t[n]},M(s,e)}const J=async(s,e,t)=>{const n=U,r={YdzuA:function(i,a){return i instanceof a},uzBvt:function(i){return i()},alwWV:function(i,a,c,l){return i(a,c,l)}},o=t();try{return await s.connect(o),o}catch(i){if(r.YdzuA(i,de.UnauthorizedError)){const a=await r.uzBvt(e);return await o.finishAuth(a),await r[n(214)](J,s,e,t)}else throw i}},le=(s,e)=>{const t=U,n=U,r={};r[t(199)]="waitForOAuthCode",r[t(183)]=function(i,a){return i===a},r[n(207)]=t(216);const o=r;if(o.wZCHj in s)return s.waitForOAuthCode;if(o.KaUfV(typeof e,o[t(207)]))return e;throw new Error("waitForOAuthCode need to be provided when authProvider is provided")},He=async s=>{const e=U,t=U,n={rasho:e(197),rmzgk:t(169),JPlVw:function(m){return m()},TIBus:function(m,L,q){return m(L,q)},JyYqS:function(m,L,q,K){return m(L,q,K)},ywGtJ:function(m,L,q,K){return m(L,q,K)}},{client:r,url:o,token:i,sessionId:a,authProvider:c,requestInit:l,eventSourceInit:u,waitForOAuthCode:f}=s,d={};d[e(219)]=c,d[e(193)]=l,d.eventSourceInit=u;const h=d,_=a||O[t(191)](),x=ae(i,_);if(l){const m={...x.requestInit,...l};m.headers={...x[t(193)][t(195)],...l[e(195)]},h[t(193)]=m}else h[e(193)]=x[t(193)];if(u){const m={...x.eventSourceInit,...u};h[e(209)]=m}else h[e(209)]=x[e(209)];const b={};b[t(182)]=!0;const g={};g[t(200)]=b,g.sampling={},g.elicitation={};const I=g,T={};T[t(213)]=n.rasho,T[t(181)]=n[e(170)];const N={};N.capabilities=I;const S=new V.Client(T,N),H=()=>new F.SSEClientTransport(new URL(o),h);let R=n[e(217)](H);if(c){const m=n[t(174)](le,c,f);R=await n.JyYqS(J,S,m,H)}else await S.connect(R);n.ywGtJ(ie,S,r,R),R[e(198)]=R._endpoint[t(179)].get("sessionId");const A={};return A.transport=R,A[e(198)]=R[t(198)],A},Pe=async s=>{const e=U,t=D,n={AJbbW:function(m,L,q){return m(L,q)},ZXEHq:e(211),aDqLK:function(m){return m()},nKQkl:function(m,L,q){return m(L,q)},xZlrW:function(m,L,q,K){return m(L,q,K)}},{client:r,url:o,token:i,sessionId:a,authProvider:c,requestInit:l,reconnectionOptions:u,waitForOAuthCode:f}=s,d={};d.authProvider=c,d.requestInit=l,d.reconnectionOptions=u;const h=d,_=a||O.randomUUID(),x=n.AJbbW(ce,i,_);if(l){const m={...x[e(193)],...l};m.headers={...x.requestInit.headers,...l[t(195)]},h.requestInit=m}else h[e(193)]=x[e(193)];const b={};b[t(182)]=!0;const g={};g[e(200)]=b,g[e(189)]={},g.elicitation={};const I=g,T={};T[e(213)]=n[e(171)],T.version=e(169);const N={};N[e(190)]=I;const S=new V.Client(T,N),H=()=>new B.StreamableHTTPClientTransport(new URL(o),h);let R=n[e(215)](H);if(c){const m=n.nKQkl(le,c,f);R=await n[t(204)](J,S,m,H)}else await S.connect(R);ie(S,r,R);const A={};return A[t(196)]=R,A[e(198)]=R[e(198)],A};function G(){const s=["_callBackPromise","clientMetadata","clientInformation","_redirectCallback","134455mslyQC","558338pOTNJB","510616LiqUbS","json","7441KftUnn","20YdRwwG","POST","code","_getAuthCodeByState","DjZmq","statusText","17336099YnGEHr","saveCodeVerifier","996bqURbL","Failed to fetch auth code: ","_clientMetadata","saveTokens","VGvoL","No code verifier saved","redirect_uris","reject","693422ltcndC","Failed to redirect: ","redirectUrl","99IWgtlv","6UDGeyf","waitForOAuthCode","codeVerifier","waitForOAuthCodeFunction","GET","_codeVerifier","_clientInformation","resolve","getAuthCodeByStateFunction","_tokens","8655150IwrNAp","_state"];return G=function(){return s},G()}const k=y,se=y;(function(s,e){const t=y,n=y,r=s();for(;;)try{if(parseInt(t(259))/1+parseInt(n(239))/2*(-parseInt(n(263))/3)+parseInt(t(243))/4*(parseInt(n(238))/5)+parseInt(t(251))/6*(parseInt(t(242))/7)+-parseInt(n(240))/8*(-parseInt(t(262))/9)+parseInt(t(273))/10+-parseInt(n(249))/11===e)break;r.push(r.shift())}catch{r.push(r.shift())}})(G,437600);const Ue=()=>O.randomBytes(8128+115*-5+-7513);function y(s,e){const t=G();return y=function(n,r){return n=n-(-1*2069+9*832+54*-96),t[n]},y(s,e)}class Oe{constructor(e){const t=y,n=y;this[t(275)]={};const{clientMetadata:r,state:o,redirectCallback:i,getAuthCodeByState:a,waitForOAuthCode:c}=e;this[n(253)]=r,this._redirectUrl=r[t(257)][-9616+-4068*-1+5548],this._state=o||Ue(),this[n(237)]=i||this.redirectCallbackFunction,this[n(246)]=a||this[t(271)],this[t(264)]=c||this[n(266)]()}async redirectCallbackFunction(e){var t,n,r,o,i,a;const c=y,l=y,u={};u.TspJZ=c(267);const f=u,d={};d.method=f.TspJZ;const h=await fetch(e,d);!h.ok&&((n=(t=this._callBackPromise).reject)==null||n.call(t,c(260)+h.statusText));const _=await this[l(246)](this._redirectUrl,this[l(274)]);if(!_.ok){(o=(r=this[l(275)])[l(258)])==null||o.call(r,l(252)+_[l(248)]);return}const x=await _[c(241)]();(a=(i=this[c(275)])[l(270)])==null||a.call(i,x[l(245)])}async getAuthCodeByStateFunction(e,t){const n=y,r=y,o={DjZmq:function(a,c,l){return a(c,l)},WUtMg:"application/x-www-form-urlencoded"},i={};return i.state=t,o[n(247)](fetch,e,{method:r(244),headers:{"Content-Type":o.WUtMg},body:new URLSearchParams(i)})}waitForOAuthCodeFunction(){const e=this._callBackPromise;return()=>new Promise((t,n)=>{const r=y;e.resolve=t,e[r(258)]=n})}get[k(261)](){return this._redirectUrl}get[se(235)](){return this._clientMetadata}state(){return this[k(274)]}[k(236)](){return this._clientInformation}saveClientInformation(e){const t=se;this[t(269)]=e}tokens(){return this._tokens}[se(254)](e){const t=k;this[t(272)]=e}redirectToAuthorization(e){this[k(237)](e)}[k(250)](e){const t=k;this[t(268)]=e}[k(265)](){const e=k,t=k,n={};n[e(255)]=e(256);const r=n;if(!this._codeVerifier)throw new Error(r[t(255)]);return this[t(268)]}}(function(s,e){for(var t=X,n=X,r=s();;)try{var o=-parseInt(t(299))/1*(-parseInt(n(296))/2)+-parseInt(n(298))/3+parseInt(n(300))/4+-parseInt(t(292))/5+parseInt(n(295))/6*(parseInt(t(294))/7)+-parseInt(t(297))/8+-parseInt(n(293))/9;if(o===e)break;r.push(r.shift())}catch{r.push(r.shift())}})(Q,722500+-10*107029+902741);function Q(){var s=["2iLxULY","1547872TvYRpQ","3124428cOXNRq","1035197lJDFGt","3486564wwalRD","2645980SUHNlu","872424UrZLEr","2905TFXGtD","7362fQOePf"];return Q=function(){return s},Q()}function X(s,e){var t=Q();return X=function(n,r){n=n-(2152*2+-563*12+2744);var o=t[n];return o},X(s,e)}class Ne{constructor(e,t){const n={name:"web-mcp-server",version:"1.0.0"},r={prompts:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},completions:{},logging:{}};this.server=new $.McpServer(e||n,t||{capabilities:r}),this.server.server.oninitialized=()=>{var o;(o=this.oninitialized)==null||o.call(this)},this.server.server.onclose=()=>{var o;(o=this.onclose)==null||o.call(this)},this.server.server.onerror=o=>{var i;(i=this.onerror)==null||i.call(this,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 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,r){return typeof t=="string"?this.server.registerResource(e,t,n,r):this.server.registerResource(e,t,n,r)}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 Ae=(s,e)=>new ne(s,e),Fe=()=>me(),ze=s=>s instanceof ne,Be=s=>s instanceof $.McpServer;class De{constructor(e,t){const n={name:"web-mcp-client",version:"1.0.0"},r={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new V.Client(e||n,t||{capabilities:r}),this.client.onclose=()=>{var o;(o=this.onclose)==null||o.call(this)},this.client.onerror=o=>{var i;(i=this.onerror)==null||i.call(this,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:r,authProvider:o,type:i,agent:a,onError:c,onUnauthorized:l,onReconnect:u}=e;if(a===!0){const h={client:this.client,url:t,token:n,sessionId:r,authProvider:o};let _=!1,x;const b=async()=>{const{transport:g,sessionId:I}=i==="sse"?await He(h):await Pe(h);g.onerror=async T=>{c==null||c(T),T.message==="Unauthorized"&&!_&&(typeof l=="function"?await l(b):(_=!0,await b(),_=!1,await(u==null?void 0:u())))},x={transport:g,sessionId:I}};return await b(),x}const f=new URL(t);let d;if(i==="channel"&&(d=new te(t),await this.client.connect(d)),i==="sse")if(o){const h=()=>new F.SSEClientTransport(f,{authProvider:o});d=await J(this.client,o.waitForOAuthCode,h)}else{const h=ae(n,r);d=new F.SSEClientTransport(f,h),await this.client.connect(d)}if(typeof d>"u")if(o){const h=()=>new B.StreamableHTTPClientTransport(f,{authProvider:o});d=await J(this.client,o.waitForOAuthCode,h)}else{const h=ce(n,r);d=new B.StreamableHTTPClientTransport(f,h),await this.client.connect(d)}return this.transport=d,{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||(ue(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const Je=(s,e)=>new F.SSEClientTransport(s,e),Ke=(s,e)=>new B.StreamableHTTPClientTransport(s,e),Ve=(s,e)=>new te(s,e),Ee=s=>s instanceof F.SSEClientTransport,ue=s=>s instanceof B.StreamableHTTPClientTransport,We=s=>s instanceof te,je=s=>s instanceof V.Client;p.Ajv=z,Object.defineProperty(p,"ResourceTemplate",{enumerable:!0,get:()=>$.ResourceTemplate}),Object.defineProperty(p,"z",{enumerable:!0,get:()=>fe.z}),Object.defineProperty(p,"UriTemplate",{enumerable:!0,get:()=>he.UriTemplate}),Object.defineProperty(p,"completable",{enumerable:!0,get:()=>pe.completable}),Object.defineProperty(p,"getDisplayName",{enumerable:!0,get:()=>xe.getDisplayName}),p.AuthClientProvider=Oe,p.WebMcpClient=De,p.WebMcpServer=Ne,p.createMessageChannelClientTransport=Ve,p.createMessageChannelPairTransport=Fe,p.createMessageChannelServerTransport=Ae,p.createSSEClientTransport=Je,p.createStreamableHTTPClientTransport=Ke,p.isMcpClient=je,p.isMcpServer=Be,p.isMessageChannelClientTransport=We,p.isMessageChannelServerTransport=ze,p.isSSEClientTransport=Ee,p.isStreamableHTTPClientTransport=ue,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|